[Scummvm-git-logs] scummvm master -> 6e1f2f39c08adc6abda157981855b4a3dbdd0aad
dreammaster
paulfgilbert at gmail.com
Sun Apr 19 00:15:05 UTC 2020
This automated email contains information about 3 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
8bcebdec5f ULTIMA4: Enable keymapper actions to optionally trigger on kbd repeats
046be21193 KEYMAPPER: More complete keyboard repeat handling
6e1f2f39c0 ULTIMA4: Janitorial
Commit: 8bcebdec5f3df7387d88ed69c2ecb6b5a4bf9f03
https://github.com/scummvm/scummvm/commit/8bcebdec5f3df7387d88ed69c2ecb6b5a4bf9f03
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2020-04-18T17:12:03-07:00
Commit Message:
ULTIMA4: Enable keymapper actions to optionally trigger on kbd repeats
Changed paths:
backends/keymapper/action.h
backends/keymapper/keymapper.cpp
engines/ultima/ultima4/meta_engine.cpp
diff --git a/backends/keymapper/action.h b/backends/keymapper/action.h
index f798d2f50a..6fa9ed4e44 100644
--- a/backends/keymapper/action.h
+++ b/backends/keymapper/action.h
@@ -114,6 +114,14 @@ public:
setEvent(EVENT_X2BUTTONDOWN);
}
+ /**
+ * Allows an action bound to a keyboard event to be repeatedly
+ * triggered by key repeats
+ */
+ void allowKbdReapets() {
+ event.kbdRepeat = true;
+ }
+
/**
* Add a default input mapping for the action
*
diff --git a/backends/keymapper/keymapper.cpp b/backends/keymapper/keymapper.cpp
index a823611792..0e285bed64 100644
--- a/backends/keymapper/keymapper.cpp
+++ b/backends/keymapper/keymapper.cpp
@@ -186,10 +186,10 @@ List<Event> Keymapper::mapEvent(const Event &ev) {
}
}
- // Ignore keyboard repeat events. Repeat event are meant for text input,
- // the keymapper / keymaps are supposed to be disabled during text input.
- // TODO: Add a way to keep repeat events if needed.
- if (!mappedEvents.empty() && ev.type == EVENT_KEYDOWN && ev.kbdRepeat) {
+ // Ignore keyboard repeat events unless the action explicitly allows it.
+ // This is a convenience to prevent actions getting triggered multiple times
+ if (!mappedEvents.empty() && ev.type == EVENT_KEYDOWN && ev.kbdRepeat
+ && !mappedEvents.front().kbdRepeat) {
return List<Event>();
}
diff --git a/engines/ultima/ultima4/meta_engine.cpp b/engines/ultima/ultima4/meta_engine.cpp
index fec9fa983f..c8872c8207 100644
--- a/engines/ultima/ultima4/meta_engine.cpp
+++ b/engines/ultima/ultima4/meta_engine.cpp
@@ -155,6 +155,11 @@ Common::KeymapArray MetaEngine::initKeymaps() {
act->addDefaultInputMapping(r->_key);
if (r->_joy)
act->addDefaultInputMapping(r->_joy);
+ if (r->_action == KEYBIND_UP || r->_action == KEYBIND_DOWN ||
+ r->_action == KEYBIND_LEFT || r->_action == KEYBIND_RIGHT)
+ // Allow movement actions to be triggered on keyboard repeats
+ act->allowKbdReapets();
+
keyMap->addAction(act);
}
}
Commit: 046be21193d04dc76a86d741984f9516eb1455d1
https://github.com/scummvm/scummvm/commit/046be21193d04dc76a86d741984f9516eb1455d1
Author: Bastien Bouclet (bastien.bouclet at gmail.com)
Date: 2020-04-18T17:12:03-07:00
Commit Message:
KEYMAPPER: More complete keyboard repeat handling
Changed paths:
backends/keymapper/action.cpp
backends/keymapper/action.h
backends/keymapper/keymapper.cpp
engines/ultima/ultima4/meta_engine.cpp
diff --git a/backends/keymapper/action.cpp b/backends/keymapper/action.cpp
index ecb4f47449..948c359441 100644
--- a/backends/keymapper/action.cpp
+++ b/backends/keymapper/action.cpp
@@ -28,7 +28,8 @@ namespace Common {
Action::Action(const char *i, const String &des) :
id(i),
- description(des) {
+ description(des),
+ _shouldTriggerOnKbdRepeats(false) {
assert(i);
}
diff --git a/backends/keymapper/action.h b/backends/keymapper/action.h
index 6fa9ed4e44..50c2627d43 100644
--- a/backends/keymapper/action.h
+++ b/backends/keymapper/action.h
@@ -49,6 +49,7 @@ struct Action {
private:
Array<String> _defaultInputMapping;
+ bool _shouldTriggerOnKbdRepeats;
public:
Action(const char *id, const String &description);
@@ -117,11 +118,19 @@ public:
/**
* Allows an action bound to a keyboard event to be repeatedly
* triggered by key repeats
+ *
+ * Note that key repeat events should probably not be used for anything
+ * else than text input as they do not trigger when the action is bound
+ * to something else than a keyboard key. Furthermore, the frequency at
+ * which they trigger and whether they trigger at all is operating system
+ * controlled.
*/
- void allowKbdReapets() {
- event.kbdRepeat = true;
+ void allowKbdRepeats() {
+ _shouldTriggerOnKbdRepeats = true;
}
+ bool shouldTriggerOnKbdRepeats() const { return _shouldTriggerOnKbdRepeats; }
+
/**
* Add a default input mapping for the action
*
diff --git a/backends/keymapper/keymapper.cpp b/backends/keymapper/keymapper.cpp
index 0e285bed64..277a383b3c 100644
--- a/backends/keymapper/keymapper.cpp
+++ b/backends/keymapper/keymapper.cpp
@@ -171,11 +171,12 @@ List<Event> Keymapper::mapEvent(const Event &ev) {
hardcodedEventMapping(ev);
List<Event> mappedEvents;
- if (!mapEvent(ev, _enabledKeymapType, mappedEvents)) {
+ bool matchedAction = mapEvent(ev, _enabledKeymapType, mappedEvents);
+ if (!matchedAction) {
// If we found actions matching this input in the game / gui keymaps,
// no need to look at the global keymaps. An input resulting in actions
// from system and game keymaps would lead to unexpected user experience.
- mapEvent(ev, Keymap::kKeymapTypeGlobal, mappedEvents);
+ matchedAction = mapEvent(ev, Keymap::kKeymapTypeGlobal, mappedEvents);
}
if (ev.type == EVENT_JOYAXIS_MOTION && ev.joystick.axis < ARRAYSIZE(_joystickAxisPreviouslyPressed)) {
@@ -186,14 +187,7 @@ List<Event> Keymapper::mapEvent(const Event &ev) {
}
}
- // Ignore keyboard repeat events unless the action explicitly allows it.
- // This is a convenience to prevent actions getting triggered multiple times
- if (!mappedEvents.empty() && ev.type == EVENT_KEYDOWN && ev.kbdRepeat
- && !mappedEvents.front().kbdRepeat) {
- return List<Event>();
- }
-
- if (mappedEvents.empty()) {
+ if (!matchedAction) {
// if it didn't get mapped, just pass it through
mappedEvents.push_back(ev);
}
@@ -295,6 +289,11 @@ Event Keymapper::executeAction(const Action *action, const Event &incomingEvent)
return outgoingEvent;
}
+ if (incomingEvent.type == EVENT_KEYDOWN && incomingEvent.kbdRepeat && !action->shouldTriggerOnKbdRepeats()) {
+ outgoingEvent.type = EVENT_INVALID;
+ return outgoingEvent;
+ }
+
EventType convertedType = convertStartToEnd(outgoingEvent.type);
// hardware keys need to send up instead when they are up
@@ -302,6 +301,10 @@ Event Keymapper::executeAction(const Action *action, const Event &incomingEvent)
outgoingEvent.type = convertedType;
}
+ if (outgoingEvent.type == EVENT_KEYDOWN && incomingEvent.type == EVENT_KEYDOWN) {
+ outgoingEvent.kbdRepeat = incomingEvent.kbdRepeat;
+ }
+
if (isMouseEvent(outgoingEvent)) {
if (isMouseEvent(incomingEvent)) {
outgoingEvent.mouse = incomingEvent.mouse;
diff --git a/engines/ultima/ultima4/meta_engine.cpp b/engines/ultima/ultima4/meta_engine.cpp
index c8872c8207..27052f52b5 100644
--- a/engines/ultima/ultima4/meta_engine.cpp
+++ b/engines/ultima/ultima4/meta_engine.cpp
@@ -158,7 +158,7 @@ Common::KeymapArray MetaEngine::initKeymaps() {
if (r->_action == KEYBIND_UP || r->_action == KEYBIND_DOWN ||
r->_action == KEYBIND_LEFT || r->_action == KEYBIND_RIGHT)
// Allow movement actions to be triggered on keyboard repeats
- act->allowKbdReapets();
+ act->allowKbdRepeats();
keyMap->addAction(act);
}
Commit: 6e1f2f39c08adc6abda157981855b4a3dbdd0aad
https://github.com/scummvm/scummvm/commit/6e1f2f39c08adc6abda157981855b4a3dbdd0aad
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2020-04-18T17:12:03-07:00
Commit Message:
ULTIMA4: Janitorial
Changed paths:
engines/ultima/ultima4/controllers/alpha_action_controller.cpp
engines/ultima/ultima4/controllers/alpha_action_controller.h
engines/ultima/ultima4/controllers/camp_controller.cpp
engines/ultima/ultima4/controllers/combat_controller.cpp
engines/ultima/ultima4/controllers/combat_controller.h
engines/ultima/ultima4/controllers/game_controller.cpp
engines/ultima/ultima4/controllers/game_controller.h
engines/ultima/ultima4/controllers/inn_controller.cpp
engines/ultima/ultima4/controllers/intro_controller.cpp
engines/ultima/ultima4/controllers/intro_controller.h
engines/ultima/ultima4/controllers/key_handler_controller.cpp
engines/ultima/ultima4/controllers/key_handler_controller.h
engines/ultima/ultima4/controllers/read_choice_controller.h
engines/ultima/ultima4/controllers/read_int_controller.cpp
engines/ultima/ultima4/controllers/read_int_controller.h
engines/ultima/ultima4/controllers/read_string_controller.cpp
engines/ultima/ultima4/controllers/read_string_controller.h
engines/ultima/ultima4/controllers/wait_controller.cpp
engines/ultima/ultima4/controllers/wait_controller.h
engines/ultima/ultima4/controllers/ztats_controller.cpp
engines/ultima/ultima4/conversation/conversation.cpp
engines/ultima/ultima4/conversation/conversation.h
engines/ultima/ultima4/conversation/dialogueloader_hw.cpp
engines/ultima/ultima4/conversation/dialogueloader_lb.cpp
engines/ultima/ultima4/conversation/dialogueloader_tlk.cpp
engines/ultima/ultima4/core/debugger.cpp
engines/ultima/ultima4/core/debugger_actions.cpp
engines/ultima/ultima4/core/debugger_actions.h
engines/ultima/ultima4/core/lzw/hash.cpp
engines/ultima/ultima4/core/lzw/hash.h
engines/ultima/ultima4/core/lzw/lzw.cpp
engines/ultima/ultima4/core/observable.h
engines/ultima/ultima4/core/settings.cpp
engines/ultima/ultima4/core/types.h
engines/ultima/ultima4/core/utils.cpp
engines/ultima/ultima4/core/utils.h
engines/ultima/ultima4/events/event.cpp
engines/ultima/ultima4/events/event.h
engines/ultima/ultima4/events/event_scummvm.cpp
engines/ultima/ultima4/events/timed_event_mgr.cpp
engines/ultima/ultima4/events/timed_event_mgr.h
engines/ultima/ultima4/filesys/filesystem.cpp
engines/ultima/ultima4/filesys/rle.cpp
engines/ultima/ultima4/filesys/rle.h
engines/ultima/ultima4/filesys/savegame.cpp
engines/ultima/ultima4/filesys/savegame.h
engines/ultima/ultima4/filesys/u4file.cpp
engines/ultima/ultima4/game/armor.cpp
engines/ultima/ultima4/game/armor.h
engines/ultima/ultima4/game/aura.cpp
engines/ultima/ultima4/game/context.cpp
engines/ultima/ultima4/game/creature.cpp
engines/ultima/ultima4/game/creature.h
engines/ultima/ultima4/game/death.cpp
engines/ultima/ultima4/game/game.cpp
engines/ultima/ultima4/game/item.cpp
engines/ultima/ultima4/game/item.h
engines/ultima/ultima4/game/menu.cpp
engines/ultima/ultima4/game/menu.h
engines/ultima/ultima4/game/moongate.cpp
engines/ultima/ultima4/game/object.cpp
engines/ultima/ultima4/game/person.cpp
engines/ultima/ultima4/game/player.cpp
engines/ultima/ultima4/game/player.h
engines/ultima/ultima4/game/portal.cpp
engines/ultima/ultima4/game/script.cpp
engines/ultima/ultima4/game/script.h
engines/ultima/ultima4/game/spell.cpp
engines/ultima/ultima4/game/spell.h
engines/ultima/ultima4/game/stats.cpp
engines/ultima/ultima4/game/textview.cpp
engines/ultima/ultima4/game/textview.h
engines/ultima/ultima4/game/view.cpp
engines/ultima/ultima4/game/weapon.cpp
engines/ultima/ultima4/gfx/image.cpp
engines/ultima/ultima4/gfx/image.h
engines/ultima/ultima4/gfx/imageloader_fmtowns.cpp
engines/ultima/ultima4/gfx/imageloader_u4.cpp
engines/ultima/ultima4/gfx/imagemgr.cpp
engines/ultima/ultima4/gfx/scale.cpp
engines/ultima/ultima4/gfx/screen.cpp
engines/ultima/ultima4/gfx/screen.h
engines/ultima/ultima4/map/city.cpp
engines/ultima/ultima4/map/city.h
engines/ultima/ultima4/map/dungeon.cpp
engines/ultima/ultima4/map/dungeon.h
engines/ultima/ultima4/map/dungeonview.cpp
engines/ultima/ultima4/map/location.cpp
engines/ultima/ultima4/map/location.h
engines/ultima/ultima4/map/map.cpp
engines/ultima/ultima4/map/map.h
engines/ultima/ultima4/map/maploader.cpp
engines/ultima/ultima4/map/mapmgr.cpp
engines/ultima/ultima4/map/movement.cpp
engines/ultima/ultima4/map/shrine.cpp
engines/ultima/ultima4/map/tile.cpp
engines/ultima/ultima4/map/tileanim.cpp
engines/ultima/ultima4/map/tilemap.cpp
engines/ultima/ultima4/map/tilemap.h
engines/ultima/ultima4/map/tileset.cpp
engines/ultima/ultima4/map/tileset.h
engines/ultima/ultima4/map/tileview.cpp
engines/ultima/ultima4/sound/music.cpp
engines/ultima/ultima4/sound/sound.cpp
engines/ultima/ultima4/sound/sound.h
engines/ultima/ultima4/sound/sound_p.h
diff --git a/engines/ultima/ultima4/controllers/alpha_action_controller.cpp b/engines/ultima/ultima4/controllers/alpha_action_controller.cpp
index 92d4ec108e..df0ddcc4fb 100644
--- a/engines/ultima/ultima4/controllers/alpha_action_controller.cpp
+++ b/engines/ultima/ultima4/controllers/alpha_action_controller.cpp
@@ -41,7 +41,7 @@ bool AlphaActionController::keyPressed(int key) {
} else {
g_screen->screenMessage("\n%s", _prompt.c_str());
g_screen->update();
- return KeyHandler::defaultHandler(key, NULL);
+ return KeyHandler::defaultHandler(key, nullptr);
}
return true;
}
diff --git a/engines/ultima/ultima4/controllers/alpha_action_controller.h b/engines/ultima/ultima4/controllers/alpha_action_controller.h
index 90efd64793..0a7b335150 100644
--- a/engines/ultima/ultima4/controllers/alpha_action_controller.h
+++ b/engines/ultima/ultima4/controllers/alpha_action_controller.h
@@ -39,7 +39,7 @@ public:
}
bool keyPressed(int key) override;
- static int get(char lastValidLetter, const Common::String &prompt, EventHandler *eh = NULL);
+ static int get(char lastValidLetter, const Common::String &prompt, EventHandler *eh = nullptr);
private:
char _lastValidLetter;
diff --git a/engines/ultima/ultima4/controllers/camp_controller.cpp b/engines/ultima/ultima4/controllers/camp_controller.cpp
index f9319d5e8d..6162066e9a 100644
--- a/engines/ultima/ultima4/controllers/camp_controller.cpp
+++ b/engines/ultima/ultima4/controllers/camp_controller.cpp
@@ -39,7 +39,7 @@ CampController::CampController() {
id = MAP_CAMP_CON;
_map = getCombatMap(mapMgr->get(id));
- g_game->setMap(_map, true, NULL, this);
+ g_game->setMap(_map, true, nullptr, this);
}
void CampController::init(Creature *m) {
diff --git a/engines/ultima/ultima4/controllers/combat_controller.cpp b/engines/ultima/ultima4/controllers/combat_controller.cpp
index 200baeb346..727c90b800 100644
--- a/engines/ultima/ultima4/controllers/combat_controller.cpp
+++ b/engines/ultima/ultima4/controllers/combat_controller.cpp
@@ -61,7 +61,7 @@ extern void gameDestroyAllCreatures();
*/
bool isCombatMap(Map *punknown) {
CombatMap *ps;
- if ((ps = dynamic_cast<CombatMap *>(punknown)) != NULL)
+ if ((ps = dynamic_cast<CombatMap *>(punknown)) != nullptr)
return true;
else
return false;
@@ -72,31 +72,31 @@ bool isCombatMap(Map *punknown) {
* passed, or a CombatMap pointer to the current map
* if no arguments were passed.
*
- * Returns NULL if the map provided (or current map)
+ * Returns nullptr if the map provided (or current map)
* is not a combat map.
*/
CombatMap *getCombatMap(Map *punknown) {
Map *m = punknown ? punknown : g_context->_location->_map;
if (!isCombatMap(m))
- return NULL;
+ return nullptr;
else return dynamic_cast<CombatMap *>(m);
}
/**
* CombatController class implementation
*/
-CombatController::CombatController() : _map(NULL) {
+CombatController::CombatController() : _map(nullptr) {
g_context->_party->addObserver(this);
}
CombatController::CombatController(CombatMap *m) : _map(m) {
- g_game->setMap(_map, true, NULL, this);
+ g_game->setMap(_map, true, nullptr, this);
g_context->_party->addObserver(this);
}
CombatController::CombatController(MapId id) {
_map = getCombatMap(mapMgr->get(id));
- g_game->setMap(_map, true, NULL, this);
+ g_game->setMap(_map, true, nullptr, this);
g_context->_party->addObserver(this);
_forceStandardEncounterSize = false;
}
@@ -115,7 +115,7 @@ bool CombatController::isWinOrLose() const {
Direction CombatController::getExitDir() const {
return _exitDir;
}
-unsigned char CombatController::getFocus() const {
+byte CombatController::getFocus() const {
return _focus;
}
CombatMap *CombatController::getMap() const {
@@ -148,7 +148,7 @@ void CombatController::init(class Creature *m) {
int i;
_creature = m;
- _placeCreaturesOnMap = (m == NULL) ? false : true;
+ _placeCreaturesOnMap = (m == nullptr) ? false : true;
_placePartyOnMap = true;
_winOrLose = true;
_map->setDungeonRoom(false);
@@ -158,11 +158,11 @@ void CombatController::init(class Creature *m) {
/* initialize creature info */
for (i = 0; i < AREA_CREATURES; i++) {
- creatureTable[i] = NULL;
+ creatureTable[i] = nullptr;
}
for (i = 0; i < AREA_PLAYERS; i++) {
- _party.push_back(NULL);
+ _party.push_back(nullptr);
}
/* fill the creature table if a creature was provided to create */
@@ -174,14 +174,13 @@ void CombatController::init(class Creature *m) {
void CombatController::initDungeonRoom(int room, Direction from) {
int offset, i;
- init(NULL);
+ init(nullptr);
ASSERT(g_context->_location->_prev->_context & CTX_DUNGEON, "Error: called initDungeonRoom from non-dungeon context");
{
Dungeon *dng = dynamic_cast<Dungeon *>(g_context->_location->_prev->_map);
- unsigned char
- *party_x = &dng->_rooms[room]._partyNorthStartX[0],
- *party_y = &dng->_rooms[room]._partyNorthStartY[0];
+ byte *party_x = &dng->_rooms[room]._partyNorthStartX[0],
+ *party_y = &dng->_rooms[room]._partyNorthStartY[0];
/* load the dungeon room properties */
_winOrLose = false;
@@ -381,7 +380,7 @@ void CombatController::end(bool adjustKarma) {
void CombatController::fillCreatureTable(const Creature *creature) {
int i, j;
- if (creature != NULL) {
+ if (creature != nullptr) {
const Creature *baseCreature = creature, *current;
int numCreatures = initialNumberOfCreatures(creature);
@@ -394,7 +393,7 @@ void CombatController::fillCreatureTable(const Creature *creature) {
/* find a free spot in the creature table */
do {
j = xu4_random(AREA_CREATURES) ;
- } while (creatureTable[j] != NULL);
+ } while (creatureTable[j] != nullptr);
/* see if creature is a leader or leader's leader */
if (creatureMgr->getById(baseCreature->getLeader()) != baseCreature && /* leader is a different creature */
@@ -461,7 +460,7 @@ void CombatController::moveCreatures() {
// XXX: this iterator is rather complex; but the vector::iterator can
// break and crash if we delete elements while iterating it, which we do
// if a jinxed monster kills another
- for (unsigned int i = 0; i < _map->getCreatures().size(); i++) {
+ for (uint i = 0; i < _map->getCreatures().size(); i++) {
m = _map->getCreatures().at(i);
//GameController::doScreenAnimationsWhilePausing(1);
m->act(this);
@@ -541,8 +540,8 @@ void CombatController::awardLoot() {
}
bool CombatController::attackHit(Creature *attacker, Creature *defender) {
- ASSERT(attacker != NULL, "attacker must not be NULL");
- ASSERT(defender != NULL, "defender must not be NULL");
+ ASSERT(attacker != nullptr, "attacker must not be nullptr");
+ ASSERT(defender != nullptr, "defender must not be nullptr");
int attackValue = xu4_random(0x100) + attacker->getAttackBonus();
int defenseValue = defender->getDefense();
@@ -589,7 +588,7 @@ bool CombatController::attackAt(const Coords &coords, PartyMember *attacker, int
/* apply the damage to the creature */
if (!attacker->dealDamage(creature, attacker->getDamage())) {
- creature = NULL;
+ creature = nullptr;
GameController::flashTile(coords, hittile, 1);
}
}
@@ -1084,7 +1083,7 @@ void CombatController::attack() {
Std::vector<Coords> path = gameGetDirectionalActionPath(MASK_DIR(dir), MASK_DIR_ALL,
attacker->getCoords(), 1, range,
- weapon->canAttackThroughObjects() ? NULL : &Tile::canAttackOverTile,
+ weapon->canAttackThroughObjects() ? nullptr : &Tile::canAttackOverTile,
false);
bool foundTarget = false;
@@ -1165,7 +1164,7 @@ PartyMember *CombatMap::partyMemberAt(Coords coords) {
if ((*i)->getCoords() == coords)
return *i;
}
- return NULL;
+ return nullptr;
}
Creature *CombatMap::creatureAt(Coords coords) {
@@ -1176,7 +1175,7 @@ Creature *CombatMap::creatureAt(Coords coords) {
if ((*i)->getCoords() == coords)
return *i;
}
- return NULL;
+ return nullptr;
}
MapId CombatMap::mapForTile(const Tile *groundTile, const Tile *transport, Object *obj) {
diff --git a/engines/ultima/ultima4/controllers/combat_controller.h b/engines/ultima/ultima4/controllers/combat_controller.h
index 13b8d51720..8f9b92f51b 100644
--- a/engines/ultima/ultima4/controllers/combat_controller.h
+++ b/engines/ultima/ultima4/controllers/combat_controller.h
@@ -73,7 +73,7 @@ public:
bool isCamping() const;
bool isWinOrLose() const;
Direction getExitDir() const;
- unsigned char getFocus() const;
+ byte getFocus() const;
CombatMap *getMap() const;
Creature *getCreature() const;
PartyMemberVector *getParty();
@@ -184,7 +184,7 @@ protected:
CombatMap *_map;
PartyMemberVector _party;
- unsigned char _focus;
+ byte _focus;
const Creature *creatureTable[AREA_CREATURES];
Creature *_creature;
@@ -221,13 +221,13 @@ public:
/**
* Returns the party member at the given coords, if there is one,
- * NULL if otherwise.
+ * nullptr if otherwise.
*/
PartyMember *partyMemberAt(Coords coords);
/**
* Returns the creature at the given coords, if there is one,
- * NULL if otherwise.
+ * nullptr if otherwise.
*/
Creature *creatureAt(Coords coords);
@@ -273,7 +273,7 @@ public:
};
bool isCombatMap(Map *punknown);
-CombatMap *getCombatMap(Map *punknown = NULL);
+CombatMap *getCombatMap(Map *punknown = nullptr);
} // End of namespace Ultima4
} // End of namespace Ultima
diff --git a/engines/ultima/ultima4/controllers/game_controller.cpp b/engines/ultima/ultima4/controllers/game_controller.cpp
index 8d930d7537..efaaf14107 100644
--- a/engines/ultima/ultima4/controllers/game_controller.cpp
+++ b/engines/ultima/ultima4/controllers/game_controller.cpp
@@ -45,7 +45,7 @@ namespace Ultima4 {
using namespace std;
-GameController *g_game = NULL;
+GameController *g_game = nullptr;
static const MouseArea MOUSE_AREAS[] = {
{ 3, { { 8, 8 }, { 8, 184 }, { 96, 96 } }, MC_WEST, { U4_ENTER, 0, U4_LEFT } },
@@ -95,7 +95,7 @@ void GameController::init() {
g_context->_horseSpeed = 0;
g_context->_opacity = 1;
g_context->_lastCommandTime = g_system->getMillis();
- g_context->_lastShip = NULL;
+ g_context->_lastShip = nullptr;
}
void GameController::setMap(Map *map, bool saveLocation, const Portal *portal, TurnCompleter *turnCompleter) {
@@ -164,7 +164,7 @@ int GameController::exitToParentMap() {
if (!g_context->_location)
return 0;
- if (g_context->_location->_prev != NULL) {
+ if (g_context->_location->_prev != nullptr) {
// Create the balloon for Hythloth
if (g_context->_location->_map->_id == MAP_HYTHLOTH)
createBalloon(g_context->_location->_prev->_map);
@@ -193,7 +193,7 @@ int GameController::exitToParentMap() {
void GameController::finishTurn() {
g_context->_lastCommandTime = g_system->getMillis();
- Creature *attacker = NULL;
+ Creature *attacker = nullptr;
while (1) {
@@ -375,10 +375,10 @@ bool GameController::keyPressed(int key) {
else key = 'x';
/* Klimb? */
- if ((g_context->_location->_map->portalAt(g_context->_location->_coords, ACTION_KLIMB) != NULL))
+ if ((g_context->_location->_map->portalAt(g_context->_location->_coords, ACTION_KLIMB) != nullptr))
key = 'k';
/* Descend? */
- else if ((g_context->_location->_map->portalAt(g_context->_location->_coords, ACTION_DESCEND) != NULL))
+ else if ((g_context->_location->_map->portalAt(g_context->_location->_coords, ACTION_DESCEND) != nullptr))
key = 'd';
if (g_context->_location->_context == CTX_DUNGEON) {
@@ -400,7 +400,7 @@ bool GameController::keyPressed(int key) {
}
/* Enter? */
- if (g_context->_location->_map->portalAt(g_context->_location->_coords, ACTION_ENTER) != NULL)
+ if (g_context->_location->_map->portalAt(g_context->_location->_coords, ACTION_ENTER) != nullptr)
key = 'e';
/* Get Chest? */
@@ -425,15 +425,15 @@ bool GameController::keyPressed(int key) {
g_screen->screenPrompt();
}
- return valid || KeyHandler::defaultHandler(key, NULL);
+ return valid || KeyHandler::defaultHandler(key, nullptr);
}
void GameController::initMoons() {
int trammelphase = g_ultima->_saveGame->_trammelPhase,
feluccaphase = g_ultima->_saveGame->_feluccaPhase;
- ASSERT(g_context != NULL, "Game context doesn't exist!");
- ASSERT(g_ultima->_saveGame != NULL, "Savegame doesn't exist!");
+ ASSERT(g_context != nullptr, "Game context doesn't exist!");
+ ASSERT(g_ultima->_saveGame != nullptr, "Savegame doesn't exist!");
//ASSERT(mapIsWorldMap(c->location->map) && c->location->viewMode == VIEW_NORMAL, "Can only call gameInitMoons() from the world map!");
g_ultima->_saveGame->_trammelPhase = g_ultima->_saveGame->_feluccaPhase = 0;
@@ -564,8 +564,8 @@ void GameController::avatarMoved(MoveEvent &event) {
} else if (tile->getTileType()->isLockedDoor()) {
g_debugger->jimmyAt(new_coords);
event._result = (MoveResult)(MOVE_SUCCEEDED | MOVE_END_TURN);
- } /*else if (mapPersonAt(c->location->map, new_coords) != NULL) {
- talkAtCoord(newx, newy, 1, NULL);
+ } /*else if (mapPersonAt(c->location->map, new_coords) != nullptr) {
+ talkAtCoord(newx, newy, 1, nullptr);
event.result = MOVE_SUCCEEDED | MOVE_END_TURN;
}*/
}
@@ -684,8 +684,8 @@ void GameController::timerFired() {
* force pass if no commands within last 20 seconds
*/
Controller *controller = eventHandler->getController();
- if (controller != NULL && (eventHandler->getController() == g_game ||
- dynamic_cast<CombatController *>(eventHandler->getController()) != NULL) &&
+ if (controller != nullptr && (eventHandler->getController() == g_game ||
+ dynamic_cast<CombatController *>(eventHandler->getController()) != nullptr) &&
gameTimeSinceLastCommand() > 20) {
/* pass the turn, and redraw the text area so the prompt is shown */
@@ -761,7 +761,7 @@ bool GameController::checkMoongates() {
if (!g_context->_party->canEnterShrine(VIRT_SPIRITUALITY))
return true;
- setMap(shrine_spirituality, 1, NULL);
+ setMap(shrine_spirituality, 1, nullptr);
g_music->play();
shrine_spirituality->enter();
@@ -805,7 +805,7 @@ void GameController::checkRandomCreatures() {
xu4_random(spawnDivisor) != 0)
return;
- gameSpawnCreature(NULL);
+ gameSpawnCreature(nullptr);
}
void GameController::checkBridgeTrolls() {
diff --git a/engines/ultima/ultima4/controllers/game_controller.h b/engines/ultima/ultima4/controllers/game_controller.h
index af3b2ddb99..d69d5da2bb 100644
--- a/engines/ultima/ultima4/controllers/game_controller.h
+++ b/engines/ultima/ultima4/controllers/game_controller.h
@@ -74,7 +74,7 @@ public:
void init();
void initScreen();
void initScreenWithoutReloadingState();
- void setMap(Map *map, bool saveLocation, const Portal *portal, TurnCompleter *turnCompleter = NULL);
+ void setMap(Map *map, bool saveLocation, const Portal *portal, TurnCompleter *turnCompleter = nullptr);
/**
* Exits the current map and location and returns to its parent location
diff --git a/engines/ultima/ultima4/controllers/inn_controller.cpp b/engines/ultima/ultima4/controllers/inn_controller.cpp
index 8d4f3184d2..b47cdbd8fc 100644
--- a/engines/ultima/ultima4/controllers/inn_controller.cpp
+++ b/engines/ultima/ultima4/controllers/inn_controller.cpp
@@ -32,7 +32,7 @@ namespace Ultima4 {
void innTimer(void *data);
InnController::InnController() {
- _map = NULL;
+ _map = nullptr;
/*
* Normally in cities, only one opponent per encounter; inn's
* override this to get the regular encounter size.
@@ -161,7 +161,7 @@ void InnController::maybeAmbush() {
_map = getCombatMap(mapMgr->get(mapid));
- g_game->setMap(_map, true, NULL, this);
+ g_game->setMap(_map, true, nullptr, this);
init(creature);
showCombatMessage(showMessage);
diff --git a/engines/ultima/ultima4/controllers/intro_controller.cpp b/engines/ultima/ultima4/controllers/intro_controller.cpp
index 3f13a5b11b..360fa58052 100644
--- a/engines/ultima/ultima4/controllers/intro_controller.cpp
+++ b/engines/ultima/ultima4/controllers/intro_controller.cpp
@@ -52,7 +52,7 @@ using namespace std;
Common::String profileName;
bool useProfile;
-IntroController *intro = NULL;
+IntroController *intro = nullptr;
#define INTRO_MAP_HEIGHT 5
#define INTRO_MAP_WIDTH 19
@@ -101,11 +101,11 @@ void IntroController::AnimElement::shufflePlotData() {
}
IntroBinData::IntroBinData() :
- _sigData(NULL),
- _scriptTable(NULL),
- _baseTileTable(NULL),
- _beastie1FrameTable(NULL),
- _beastie2FrameTable(NULL) {
+ _sigData(nullptr),
+ _scriptTable(nullptr),
+ _baseTileTable(nullptr),
+ _beastie1FrameTable(nullptr),
+ _beastie2FrameTable(nullptr) {
}
IntroBinData::~IntroBinData() {
@@ -142,7 +142,7 @@ bool IntroBinData::load() {
if (_sigData)
delete _sigData;
- _sigData = new unsigned char[533];
+ _sigData = new byte[533];
u4fseek(title, INTRO_FIXUPDATA_OFFSET, SEEK_SET);
u4fread(_sigData, 1, 533, title);
@@ -153,7 +153,7 @@ bool IntroBinData::load() {
_introMap[i] = TileMap::get("base")->translate(u4fgetc(title));
u4fseek(title, INTRO_SCRIPT_TABLE_OFFSET, SEEK_SET);
- _scriptTable = new unsigned char[INTRO_SCRIPT_TABLE_SIZE];
+ _scriptTable = new byte[INTRO_SCRIPT_TABLE_SIZE];
for (i = 0; i < INTRO_SCRIPT_TABLE_SIZE; i++)
_scriptTable[i] = u4fgetc(title);
@@ -167,7 +167,7 @@ bool IntroBinData::load() {
/* --------------------------
load beastie frame table 1
-------------------------- */
- _beastie1FrameTable = new unsigned char[BEASTIE1_FRAMES];
+ _beastie1FrameTable = new byte[BEASTIE1_FRAMES];
u4fseek(title, BEASTIE_FRAME_TABLE_OFFSET + BEASTIE1_FRAMES_OFFSET, SEEK_SET);
for (i = 0; i < BEASTIE1_FRAMES; i++) {
_beastie1FrameTable[i] = u4fgetc(title);
@@ -176,7 +176,7 @@ bool IntroBinData::load() {
/* --------------------------
load beastie frame table 2
-------------------------- */
- _beastie2FrameTable = new unsigned char[BEASTIE2_FRAMES];
+ _beastie2FrameTable = new byte[BEASTIE2_FRAMES];
u4fseek(title, BEASTIE_FRAME_TABLE_OFFSET + BEASTIE2_FRAMES_OFFSET, SEEK_SET);
for (i = 0; i < BEASTIE2_FRAMES; i++) {
_beastie2FrameTable[i] = u4fgetc(title);
@@ -194,7 +194,7 @@ IntroController::IntroController() :
_extendedMenuArea(2 * CHAR_WIDTH, 10 * CHAR_HEIGHT, 36, 13),
_questionArea(INTRO_TEXT_X * CHAR_WIDTH, INTRO_TEXT_Y * CHAR_HEIGHT, INTRO_TEXT_WIDTH, INTRO_TEXT_HEIGHT),
_mapArea(BORDER_WIDTH, (TILE_HEIGHT * 6) + BORDER_HEIGHT, INTRO_MAP_WIDTH, INTRO_MAP_HEIGHT, "base"),
- _binData(NULL),
+ _binData(nullptr),
_titles(), // element list
_title(_titles.begin()), // element iterator
_transparentIndex(13), // palette index for transparency
@@ -358,16 +358,16 @@ bool IntroController::hasInitiatedNewGame() {
void IntroController::deleteIntro() {
delete _binData;
- _binData = NULL;
+ _binData = nullptr;
delete [] _objectStateTable;
- _objectStateTable = NULL;
+ _objectStateTable = nullptr;
imageMgr->freeIntroBackgrounds();
}
-unsigned char *IntroController::getSigData() {
- ASSERT(_binData->_sigData != NULL, "intro sig data not loaded");
+byte *IntroController::getSigData() {
+ ASSERT(_binData->_sigData != nullptr, "intro sig data not loaded");
return _binData->_sigData;
}
@@ -440,7 +440,7 @@ bool IntroController::keyPressed(int key) {
return true;
}
- return valid || KeyHandler::defaultHandler(key, NULL);
+ return valid || KeyHandler::defaultHandler(key, nullptr);
}
void IntroController::drawMap() {
@@ -449,8 +449,8 @@ void IntroController::drawMap() {
drawMapAnimated();
_sleepCycles--;
} else {
- unsigned char commandNibble;
- unsigned char dataNibble;
+ byte commandNibble;
+ byte dataNibble;
do {
commandNibble = _binData->_scriptTable[_scrPos] >> 4;
@@ -1371,13 +1371,13 @@ void IntroController::initPlayers(SaveGame *saveGame) {
}
}
- PartyMember player(NULL, &saveGame->_players[0]);
+ PartyMember player(nullptr, &saveGame->_players[0]);
saveGame->_players[0]._hp = saveGame->_players[0]._hpMax = player.getMaxLevel() * 100;
saveGame->_players[0]._mp = player.getMaxMp();
p = 1;
for (i = 0; i < VIRT_MAX; i++) {
- player = PartyMember(NULL, &saveGame->_players[i]);
+ player = PartyMember(nullptr, &saveGame->_players[i]);
/* Initial setup for party members that aren't in your group yet... */
if (i != saveGame->_players[0]._class) {
@@ -1446,8 +1446,8 @@ void IntroController::addTitle(int x, int y, int w, int h, AnimType method, int
0, // timeBase
delay, // delay before rendering begins
duration, // total animation time
- NULL, // storage for the source image
- NULL, // storage for the animation frame
+ nullptr, // storage for the source image
+ nullptr, // storage for the animation frame
Std::vector<AnimPlot>(),
false
}; // prescaled
@@ -1455,8 +1455,8 @@ void IntroController::addTitle(int x, int y, int w, int h, AnimType method, int
}
void IntroController::getTitleSourceData() {
- unsigned int r, g, b, a; // color values
- unsigned char *srcData; // plot data
+ uint r, g, b, a; // color values
+ byte *srcData; // plot data
const int BLUE[16] = {
255, 250, 226, 226, 210, 194, 161, 161,
129, 97, 97, 64, 64, 32, 32, 0
@@ -1908,7 +1908,7 @@ bool IntroController::updateTitle() {
void IntroController::compactTitle() {
if (_title->_srcImage) {
delete _title->_srcImage;
- _title->_srcImage = NULL;
+ _title->_srcImage = nullptr;
}
_title->_plotData.clear();
}
@@ -1933,7 +1933,7 @@ void IntroController::drawTitle() {
if (!_title->_prescaled) {
delete scaled;
- scaled = NULL;
+ scaled = nullptr;
}
}
diff --git a/engines/ultima/ultima4/controllers/intro_controller.h b/engines/ultima/ultima4/controllers/intro_controller.h
index 9aad402ab0..a265091ebb 100644
--- a/engines/ultima/ultima4/controllers/intro_controller.h
+++ b/engines/ultima/ultima4/controllers/intro_controller.h
@@ -61,11 +61,11 @@ public:
bool load();
Std::vector<MapTile> _introMap;
- unsigned char *_sigData;
- unsigned char *_scriptTable;
+ byte *_sigData;
+ byte *_scriptTable;
Tile **_baseTileTable;
- unsigned char *_beastie1FrameTable;
- unsigned char *_beastie2FrameTable;
+ byte *_beastie1FrameTable;
+ byte *_beastie2FrameTable;
Std::vector<Common::String> _introText;
Std::vector<Common::String> _introQuestions;
Std::vector<Common::String> _introGypsy;
@@ -111,7 +111,7 @@ public:
* Handles keystrokes during the introduction.
*/
bool keyPressed(int key);
- unsigned char *getSigData();
+ byte *getSigData();
/**
* Paints the screen.
diff --git a/engines/ultima/ultima4/controllers/key_handler_controller.cpp b/engines/ultima/ultima4/controllers/key_handler_controller.cpp
index 1f8925b78d..b13c096c75 100644
--- a/engines/ultima/ultima4/controllers/key_handler_controller.cpp
+++ b/engines/ultima/ultima4/controllers/key_handler_controller.cpp
@@ -128,7 +128,7 @@ KeyHandlerController::~KeyHandlerController() {
}
bool KeyHandlerController::keyPressed(int key) {
- ASSERT(_handler != NULL, "key handler must be initialized");
+ ASSERT(_handler != nullptr, "key handler must be initialized");
return _handler->handle(key);
}
diff --git a/engines/ultima/ultima4/controllers/key_handler_controller.h b/engines/ultima/ultima4/controllers/key_handler_controller.h
index f9f47b57cf..52dbf53892 100644
--- a/engines/ultima/ultima4/controllers/key_handler_controller.h
+++ b/engines/ultima/ultima4/controllers/key_handler_controller.h
@@ -53,7 +53,7 @@ public:
} GetChoice;
/* Constructors */
- KeyHandler(Callback func, void *data = NULL, bool asyncronous = true);
+ KeyHandler(Callback func, void *data = nullptr, bool asyncronous = true);
/* Static functions */
static int setKeyRepeat(int delay, int interval);
diff --git a/engines/ultima/ultima4/controllers/read_choice_controller.h b/engines/ultima/ultima4/controllers/read_choice_controller.h
index 4410e2df3e..2a448dc29b 100644
--- a/engines/ultima/ultima4/controllers/read_choice_controller.h
+++ b/engines/ultima/ultima4/controllers/read_choice_controller.h
@@ -37,7 +37,7 @@ public:
ReadChoiceController(const Common::String &choices);
bool keyPressed(int key) override;
- static char get(const Common::String &choices, EventHandler *eh = NULL);
+ static char get(const Common::String &choices, EventHandler *eh = nullptr);
protected:
Common::String _choices;
diff --git a/engines/ultima/ultima4/controllers/read_int_controller.cpp b/engines/ultima/ultima4/controllers/read_int_controller.cpp
index 56083667b1..c920e64f85 100644
--- a/engines/ultima/ultima4/controllers/read_int_controller.cpp
+++ b/engines/ultima/ultima4/controllers/read_int_controller.cpp
@@ -39,7 +39,7 @@ int ReadIntController::get(int maxlen, int screenX, int screenY, EventHandler *e
}
int ReadIntController::getInt() const {
- return static_cast<int>(strtol(_value.c_str(), NULL, 10));
+ return static_cast<int>(strtol(_value.c_str(), nullptr, 10));
}
} // End of namespace Ultima4
diff --git a/engines/ultima/ultima4/controllers/read_int_controller.h b/engines/ultima/ultima4/controllers/read_int_controller.h
index 05d025e62d..ff9e6b34f2 100644
--- a/engines/ultima/ultima4/controllers/read_int_controller.h
+++ b/engines/ultima/ultima4/controllers/read_int_controller.h
@@ -36,7 +36,7 @@ class ReadIntController : public ReadStringController {
public:
ReadIntController(int maxlen, int screenX, int screenY);
- static int get(int maxlen, int screenX, int screenY, EventHandler *eh = NULL);
+ static int get(int maxlen, int screenX, int screenY, EventHandler *eh = nullptr);
int getInt() const;
};
diff --git a/engines/ultima/ultima4/controllers/read_string_controller.cpp b/engines/ultima/ultima4/controllers/read_string_controller.cpp
index a819a52a97..d9c9987885 100644
--- a/engines/ultima/ultima4/controllers/read_string_controller.cpp
+++ b/engines/ultima/ultima4/controllers/read_string_controller.cpp
@@ -31,7 +31,7 @@ ReadStringController::ReadStringController(int maxlen, int screenX, int screenY,
_maxLen = maxlen;
_screenX = screenX;
_screenY = screenY;
- _view = NULL;
+ _view = nullptr;
_accepted = accepted_chars;
}
@@ -84,7 +84,7 @@ bool ReadStringController::keyPressed(int key) {
}
} else valid = false;
- return valid || KeyHandler::defaultHandler(key, NULL);
+ return valid || KeyHandler::defaultHandler(key, nullptr);
}
Common::String ReadStringController::get(int maxlen, int screenX, int screenY, EventHandler *eh) {
diff --git a/engines/ultima/ultima4/controllers/read_string_controller.h b/engines/ultima/ultima4/controllers/read_string_controller.h
index 8f910c0487..aea84785cd 100644
--- a/engines/ultima/ultima4/controllers/read_string_controller.h
+++ b/engines/ultima/ultima4/controllers/read_string_controller.h
@@ -45,8 +45,8 @@ public:
ReadStringController(int maxlen, TextView *view, const Common::String &accepted_chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890 \n\r\010");
bool keyPressed(int key) override;
- static Common::String get(int maxlen, int screenX, int screenY, EventHandler *eh = NULL);
- static Common::String get(int maxlen, TextView *view, EventHandler *eh = NULL);
+ static Common::String get(int maxlen, int screenX, int screenY, EventHandler *eh = nullptr);
+ static Common::String get(int maxlen, TextView *view, EventHandler *eh = nullptr);
#ifdef IOS
void setValue(const Common::String &utf8StringValue) {
value = utf8StringValue;
diff --git a/engines/ultima/ultima4/controllers/wait_controller.cpp b/engines/ultima/ultima4/controllers/wait_controller.cpp
index 121d99fde8..4bdc9a88cf 100644
--- a/engines/ultima/ultima4/controllers/wait_controller.cpp
+++ b/engines/ultima/ultima4/controllers/wait_controller.cpp
@@ -26,7 +26,7 @@
namespace Ultima {
namespace Ultima4 {
-WaitController::WaitController(unsigned int c) : Controller(), _cycles(c), _current(0) {
+WaitController::WaitController(uint c) : Controller(), _cycles(c), _current(0) {
}
void WaitController::timerFired() {
diff --git a/engines/ultima/ultima4/controllers/wait_controller.h b/engines/ultima/ultima4/controllers/wait_controller.h
index b3717359af..e7aa49b214 100644
--- a/engines/ultima/ultima4/controllers/wait_controller.h
+++ b/engines/ultima/ultima4/controllers/wait_controller.h
@@ -34,7 +34,7 @@ namespace Ultima4 {
*/
class WaitController : public Controller {
public:
- WaitController(unsigned int cycles);
+ WaitController(uint cycles);
bool keyPressed(int key) override;
void timerFired() override;
@@ -42,8 +42,8 @@ public:
void setCycles(int c);
private:
- unsigned int _cycles;
- unsigned int _current;
+ uint _cycles;
+ uint _current;
};
} // End of namespace Ultima4
diff --git a/engines/ultima/ultima4/controllers/ztats_controller.cpp b/engines/ultima/ultima4/controllers/ztats_controller.cpp
index 15b3d60dd4..94fb76e915 100644
--- a/engines/ultima/ultima4/controllers/ztats_controller.cpp
+++ b/engines/ultima/ultima4/controllers/ztats_controller.cpp
@@ -60,7 +60,7 @@ bool ZtatsController::keyPressed(int key) {
doneWaiting();
return true;
default:
- return KeyHandler::defaultHandler(key, NULL);
+ return KeyHandler::defaultHandler(key, nullptr);
}
}
diff --git a/engines/ultima/ultima4/conversation/conversation.cpp b/engines/ultima/ultima4/conversation/conversation.cpp
index ad07101df6..4854fe6c6e 100644
--- a/engines/ultima/ultima4/conversation/conversation.cpp
+++ b/engines/ultima/ultima4/conversation/conversation.cpp
@@ -40,7 +40,7 @@ const ResponsePart ResponsePart::STARTMUSIC_LB("<STARTMUSIC_LB>", "", true);
const ResponsePart ResponsePart::STARTMUSIC_HW("<STARTMUSIC_HW>", "", true);
const ResponsePart ResponsePart::STOPMUSIC("<STOPMUSIC>", "", true);
const ResponsePart ResponsePart::HAWKWIND("<HAWKWIND>", "", true);
-const unsigned int Conversation::BUFFERLEN = 16;
+const uint Conversation::BUFFERLEN = 16;
Response::Response(const Common::String &response) : _references(0) {
add(response);
@@ -94,7 +94,7 @@ bool ResponsePart::isCommand() const {
DynamicResponse::DynamicResponse(Response * (*generator)(const DynamicResponse *), const Common::String ¶m) :
Response(""), _param(param) {
_generator = generator;
- _currentResponse = NULL;
+ _currentResponse = nullptr;
}
DynamicResponse::~DynamicResponse() {
@@ -162,10 +162,10 @@ bool Dialogue::Keyword::operator==(const Common::String &kw) const {
*/
Dialogue::Dialogue()
- : _intro(NULL)
- , _longIntro(NULL)
- , _defaultAnswer(NULL)
- , _question(NULL) {
+ : _intro(nullptr)
+ , _longIntro(nullptr)
+ , _defaultAnswer(nullptr)
+ , _question(nullptr) {
}
Dialogue::~Dialogue() {
@@ -194,7 +194,7 @@ Dialogue::Keyword *Dialogue::operator[](const Common::String &kw) {
return i->_value;
}
}
- return NULL;
+ return nullptr;
}
const ResponsePart &Dialogue::getAction() const {
diff --git a/engines/ultima/ultima4/conversation/conversation.h b/engines/ultima/ultima4/conversation/conversation.h
index 84682700a7..3b72b5e930 100644
--- a/engines/ultima/ultima4/conversation/conversation.h
+++ b/engines/ultima/ultima4/conversation/conversation.h
@@ -293,13 +293,13 @@ public:
InputType getInputRequired(int *bufferLen);
/* Static variables */
- static const unsigned int BUFFERLEN; /**< The default maxixum length of input */
+ static const uint BUFFERLEN; /**< The default maxixum length of input */
public:
State _state; /**< The state of the conversation */
Common::String _playerInput; /**< A Common::String holding the text the player inputs */
Common::List<Common::String> _reply; /**< What the talker says */
- class Script *_script; /**< A script that this person follows during the conversation (may be NULL) */
+ class Script *_script; /**< A script that this person follows during the conversation (may be nullptr) */
Dialogue::Question *_question; /**< The current question the player is being asked */
int _quant; /**< For vendor transactions */
int _player; /**< For vendor transactions */
diff --git a/engines/ultima/ultima4/conversation/dialogueloader_hw.cpp b/engines/ultima/ultima4/conversation/dialogueloader_hw.cpp
index ae5799242d..f858a37fc3 100644
--- a/engines/ultima/ultima4/conversation/dialogueloader_hw.cpp
+++ b/engines/ultima/ultima4/conversation/dialogueloader_hw.cpp
@@ -59,7 +59,7 @@ vector<Common::String> hawkwindText;
Dialogue *U4HWDialogueLoader::load(void *source) {
U4FILE *avatar = u4fopen("avatar.exe");
if (!avatar)
- return NULL;
+ return nullptr;
hawkwindText = u4read_stringtable(avatar, 74729, 53);
diff --git a/engines/ultima/ultima4/conversation/dialogueloader_lb.cpp b/engines/ultima/ultima4/conversation/dialogueloader_lb.cpp
index 9c49fb9a90..d2c93f88cf 100644
--- a/engines/ultima/ultima4/conversation/dialogueloader_lb.cpp
+++ b/engines/ultima/ultima4/conversation/dialogueloader_lb.cpp
@@ -45,7 +45,7 @@ Response *lordBritishGetIntro(const DynamicResponse *resp);
Dialogue *U4LBDialogueLoader::load(void *source) {
U4FILE *avatar = u4fopen("avatar.exe");
if (!avatar)
- return NULL;
+ return nullptr;
Std::vector<Common::String> lbKeywords = u4read_stringtable(avatar, 87581, 24);
/* There's a \0 in the 19th Common::String so we get a
diff --git a/engines/ultima/ultima4/conversation/dialogueloader_tlk.cpp b/engines/ultima/ultima4/conversation/dialogueloader_tlk.cpp
index f3c023e721..a1b4a61817 100644
--- a/engines/ultima/ultima4/conversation/dialogueloader_tlk.cpp
+++ b/engines/ultima/ultima4/conversation/dialogueloader_tlk.cpp
@@ -47,7 +47,7 @@ Dialogue *U4TlkDialogueLoader::load(void *source) {
/* there's no dialogues left in the file */
char tlk_buffer[288];
if (u4fread(tlk_buffer, 1, sizeof(tlk_buffer), file) != sizeof(tlk_buffer))
- return NULL;
+ return nullptr;
char *ptr = &tlk_buffer[3];
Std::vector<Common::String> strings;
@@ -57,7 +57,7 @@ Dialogue *U4TlkDialogueLoader::load(void *source) {
}
Dialogue *dlg = new Dialogue();
- unsigned char prob = tlk_buffer[2];
+ byte prob = tlk_buffer[2];
QTrigger qtrigger = QTrigger(tlk_buffer[0]);
bool humilityTestQuestion = tlk_buffer[1] == 1;
diff --git a/engines/ultima/ultima4/core/debugger.cpp b/engines/ultima/ultima4/core/debugger.cpp
index bb9c82e349..be1070ef82 100644
--- a/engines/ultima/ultima4/core/debugger.cpp
+++ b/engines/ultima/ultima4/core/debugger.cpp
@@ -241,7 +241,7 @@ bool Debugger::cmdAttack(int argc, const char **argv) {
Std::vector<Coords> path = gameGetDirectionalActionPath(
MASK_DIR(dir), MASK_DIR_ALL, g_context->_location->_coords,
- 1, 1, NULL, true);
+ 1, 1, nullptr, true);
for (Std::vector<Coords>::iterator i = path.begin(); i != path.end(); i++) {
if (attackAt(*i))
return isDebuggerActive();
@@ -520,7 +520,7 @@ bool Debugger::cmdFire(int argc, const char **argv) {
// nothing (not even mountains!) can block cannonballs
Std::vector<Coords> path = gameGetDirectionalActionPath(MASK_DIR(dir), broadsidesDirs, g_context->_location->_coords,
- 1, 3, NULL, false);
+ 1, 3, nullptr, false);
for (Std::vector<Coords>::iterator i = path.begin(); i != path.end(); i++) {
if (fireAt(*i, true))
return isDebuggerActive();
@@ -550,7 +550,7 @@ bool Debugger::cmdGet(int argc, const char **argv) {
/* get the object for the chest, if it is indeed an object */
Object *obj = g_context->_location->_map->objectAt(coords);
if (obj && !obj->getTile().getTileType()->isChest())
- obj = NULL;
+ obj = nullptr;
if (tile->isChest() || obj) {
// if a spell was cast to open this chest,
@@ -578,7 +578,7 @@ bool Debugger::cmdGet(int argc, const char **argv) {
g_screen->screenPrompt();
- if (isCity(g_context->_location->_map) && obj == NULL)
+ if (isCity(g_context->_location->_map) && obj == nullptr)
g_context->_party->adjustKarma(KA_STOLE_CHEST);
} else {
print("%cNot Here!%c", FG_GREY, FG_WHITE);
@@ -601,7 +601,7 @@ bool Debugger::cmdHoleUp(int argc, const char **argv) {
}
CombatController *cc = new CampController();
- cc->init(NULL);
+ cc->init(nullptr);
cc->begin();
return isDebuggerActive();
@@ -627,7 +627,7 @@ bool Debugger::cmdJimmy(int argc, const char **argv) {
return isDebuggerActive();
Std::vector<Coords> path = gameGetDirectionalActionPath(MASK_DIR(dir), MASK_DIR_ALL, g_context->_location->_coords,
- 1, 1, NULL, true);
+ 1, 1, nullptr, true);
for (Std::vector<Coords>::iterator i = path.begin(); i != path.end(); i++) {
if (jimmyAt(*i))
return isDebuggerActive();
@@ -772,7 +772,7 @@ bool Debugger::cmdOpenDoor(int argc, const char **argv) {
return isDebuggerActive();
Std::vector<Coords> path = gameGetDirectionalActionPath(MASK_DIR(dir), MASK_DIR_ALL, g_context->_location->_coords,
- 1, 1, NULL, true);
+ 1, 1, nullptr, true);
for (Std::vector<Coords>::iterator i = path.begin(); i != path.end(); i++) {
if (openAt(*i))
return isDebuggerActive();
@@ -896,7 +896,7 @@ bool Debugger::cmdSearch(int argc, const char **argv) {
const ItemLocation *item = itemAtLocation(g_context->_location->_map, g_context->_location->_coords);
if (item) {
- if (*item->_isItemInInventory != NULL && (*item->_isItemInInventory)(item->_data))
+ if (*item->_isItemInInventory != nullptr && (*item->_isItemInInventory)(item->_data))
print("%cNothing Here!%c", FG_GREY, FG_WHITE);
else {
if (item->_name)
@@ -1084,7 +1084,7 @@ bool Debugger::cmdAbyss(int argc, const char **argv) {
// first teleport to the abyss
g_context->_location->_coords.x = 0xe9;
g_context->_location->_coords.y = 0xe9;
- g_game->setMap(mapMgr->get(MAP_ABYSS), 1, NULL);
+ g_game->setMap(mapMgr->get(MAP_ABYSS), 1, nullptr);
// then to the final altar
g_context->_location->_coords.x = 7;
@@ -1107,7 +1107,7 @@ bool Debugger::cmdCollisions(int argc, const char **argv) {
bool Debugger::cmdCompanions(int argc, const char **argv) {
for (int m = g_ultima->_saveGame->_members; m < 8; m++) {
- if (g_context->_party->canPersonJoin(g_ultima->_saveGame->_players[m].name, NULL)) {
+ if (g_context->_party->canPersonJoin(g_ultima->_saveGame->_players[m].name, nullptr)) {
g_context->_party->join(g_ultima->_saveGame->_players[m].name);
}
}
@@ -1134,7 +1134,7 @@ bool Debugger::cmdDestroy(int argc, const char **argv) {
return isDebuggerActive();
Std::vector<Coords> path = gameGetDirectionalActionPath(MASK_DIR(dir),
- MASK_DIR_ALL, g_context->_location->_coords, 1, 1, NULL, true);
+ MASK_DIR_ALL, g_context->_location->_coords, 1, 1, nullptr, true);
for (Std::vector<Coords>::iterator i = path.begin(); i != path.end(); i++) {
if (destroyAt(*i)) {
return false;
@@ -1154,15 +1154,15 @@ bool Debugger::cmdDungeon(int argc, const char **argv) {
g_context->_location->_coords = g_context->_location->_map->_portals[dungNum - 1]->_coords;
return false;
} else if (dungNum == 9) {
- g_game->setMap(mapMgr->get(MAP_DECEIT), 1, NULL);
+ g_game->setMap(mapMgr->get(MAP_DECEIT), 1, nullptr);
g_context->_location->_coords = MapCoords(1, 0, 7);
g_ultima->_saveGame->_orientation = DIR_SOUTH;
} else if (dungNum == 10) {
- g_game->setMap(mapMgr->get(MAP_DESPISE), 1, NULL);
+ g_game->setMap(mapMgr->get(MAP_DESPISE), 1, nullptr);
g_context->_location->_coords = MapCoords(3, 2, 7);
g_ultima->_saveGame->_orientation = DIR_SOUTH;
} else if (dungNum == 11) {
- g_game->setMap(mapMgr->get(MAP_DESTARD), 1, NULL);
+ g_game->setMap(mapMgr->get(MAP_DESTARD), 1, nullptr);
g_context->_location->_coords = MapCoords(7, 6, 7);
g_ultima->_saveGame->_orientation = DIR_SOUTH;
} else {
diff --git a/engines/ultima/ultima4/core/debugger_actions.cpp b/engines/ultima/ultima4/core/debugger_actions.cpp
index 91600162ce..4cd6e72a6e 100644
--- a/engines/ultima/ultima4/core/debugger_actions.cpp
+++ b/engines/ultima/ultima4/core/debugger_actions.cpp
@@ -40,7 +40,7 @@ namespace Ultima {
namespace Ultima4 {
void DebuggerActions::summonCreature(const Common::String &name) {
- const Creature *m = NULL;
+ const Creature *m = nullptr;
Common::String creatureName = name;
creatureName.trim();
@@ -50,7 +50,7 @@ void DebuggerActions::summonCreature(const Common::String &name) {
}
/* find the creature by its id and spawn it */
- unsigned int id = atoi(creatureName.c_str());
+ uint id = atoi(creatureName.c_str());
if (id > 0)
m = creatureMgr->getById(id);
@@ -113,7 +113,7 @@ bool DebuggerActions::attackAt(const Coords &coords) {
m = dynamic_cast<Creature *>(g_context->_location->_map->objectAt(coords));
/* nothing attackable: move on to next tile */
- if (m == NULL || !m->isAttackable())
+ if (m == nullptr || !m->isAttackable())
return false;
/* attack successful */
@@ -336,7 +336,7 @@ bool DebuggerActions::openAt(const Coords &coords) {
return true;
}
-void DebuggerActions::gameCastSpell(unsigned int spell, int caster, int param) {
+void DebuggerActions::gameCastSpell(uint spell, int caster, int param) {
SpellCastError spellError;
Common::String msg;
diff --git a/engines/ultima/ultima4/core/debugger_actions.h b/engines/ultima/ultima4/core/debugger_actions.h
index 5b1d9e65a6..88bdb422ea 100644
--- a/engines/ultima/ultima4/core/debugger_actions.h
+++ b/engines/ultima/ultima4/core/debugger_actions.h
@@ -121,7 +121,7 @@ public:
*/
bool openAt(const Coords &coords);
- void gameCastSpell(unsigned int spell, int caster, int param);
+ void gameCastSpell(uint spell, int caster, int param);
/**
diff --git a/engines/ultima/ultima4/core/lzw/hash.cpp b/engines/ultima/ultima4/core/lzw/hash.cpp
index a3b33ee384..4c9b3a5a91 100644
--- a/engines/ultima/ultima4/core/lzw/hash.cpp
+++ b/engines/ultima/ultima4/core/lzw/hash.cpp
@@ -26,13 +26,13 @@ namespace Ultima {
namespace Ultima4 {
namespace LZW {
-int probe1(unsigned char root, int codeword) {
+int probe1(byte root, int codeword) {
int newHashCode = ((root << 4) ^ codeword) & 0xfff;
return (newHashCode);
}
/* The secondary probe uses some assembler instructions that aren't easily translated to C. */
-int probe2(unsigned char root, int codeword) {
+int probe2(byte root, int codeword) {
/* registers[0] == AX, registers[1] == DX */
long registers[2], temp;
long carry, oldCarry;
diff --git a/engines/ultima/ultima4/core/lzw/hash.h b/engines/ultima/ultima4/core/lzw/hash.h
index 8c40d2bf9f..aaed0417e1 100644
--- a/engines/ultima/ultima4/core/lzw/hash.h
+++ b/engines/ultima/ultima4/core/lzw/hash.h
@@ -23,12 +23,14 @@
#ifndef ULTIMA4_CORE_LZW_HASH_H
#define ULTIMA4_CORE_LZW_HASH_H
+#include "common/scummsys.h"
+
namespace Ultima {
namespace Ultima4 {
namespace LZW {
-int probe1(unsigned char root, int codeword);
-int probe2(unsigned char root, int codeword);
+int probe1(byte root, int codeword);
+int probe2(byte root, int codeword);
int probe3(int hashCode);
} // End of namespace LZW
diff --git a/engines/ultima/ultima4/core/lzw/lzw.cpp b/engines/ultima/ultima4/core/lzw/lzw.cpp
index 95ffdf6970..8cb65d450b 100644
--- a/engines/ultima/ultima4/core/lzw/lzw.cpp
+++ b/engines/ultima/ultima4/core/lzw/lzw.cpp
@@ -70,7 +70,7 @@ byte hashPosFound(int hashCode, byte root, int codeword, lzwDictionaryEntry *dic
* Error: (long) -1
*/
long lzwGetDecompressedSize(byte *compressedMem, long compressedSize) {
- return (generalizedDecompress(&discardRoot, compressedMem, NULL, compressedSize));
+ return (generalizedDecompress(&discardRoot, compressedMem, nullptr, compressedSize));
}
/*
diff --git a/engines/ultima/ultima4/core/observable.h b/engines/ultima/ultima4/core/observable.h
index 7f28422b7b..c541c28a4f 100644
--- a/engines/ultima/ultima4/core/observable.h
+++ b/engines/ultima/ultima4/core/observable.h
@@ -40,7 +40,7 @@ namespace Ultima4 {
* The A class can be any additional information to pass to observers.
* Observables that don't need to pass an argument when they update
* observers should use the default "NoArg" class for the second
- * template parameter and pass NULL to notifyObservers.
+ * template parameter and pass nullptr to notifyObservers.
*/
template <class O, class A = NoArg *>
class Observable {
diff --git a/engines/ultima/ultima4/core/settings.cpp b/engines/ultima/ultima4/core/settings.cpp
index 655ee5bb0d..e14b602efc 100644
--- a/engines/ultima/ultima4/core/settings.cpp
+++ b/engines/ultima/ultima4/core/settings.cpp
@@ -34,7 +34,7 @@ namespace Ultima4 {
/*
* Initialize static members
*/
-Settings *Settings::_instance = NULL;
+Settings *Settings::_instance = nullptr;
bool SettingsEnhancementOptions::operator==(const SettingsEnhancementOptions &s) const {
return _activePlayer == s._activePlayer
@@ -100,7 +100,7 @@ void Settings::init() {
}
Settings &Settings::getInstance() {
- if (_instance == NULL)
+ if (_instance == nullptr)
_instance = new Settings();
return *_instance;
}
diff --git a/engines/ultima/ultima4/core/types.h b/engines/ultima/ultima4/core/types.h
index 579b576e3c..bf9a47306a 100644
--- a/engines/ultima/ultima4/core/types.h
+++ b/engines/ultima/ultima4/core/types.h
@@ -24,14 +24,15 @@
#define ULTIMA4_CORE_TYPEDEFS_H
#include "ultima/ultima4/map/direction.h"
+#include "common/scummsys.h"
namespace Ultima {
namespace Ultima4 {
class Tile;
-typedef unsigned int TileId;
-typedef unsigned char MapId;
+typedef uint TileId;
+typedef byte MapId;
enum TileSpeed {
FAST,
@@ -67,13 +68,13 @@ enum TileAnimationStyle {
class MapTile {
public:
MapTile() : _id(0), _frame(0) {}
- MapTile(const TileId &i, unsigned char f = 0) : _id(i), _frame(f), _freezeAnimation(false) {}
+ MapTile(const TileId &i, byte f = 0) : _id(i), _frame(f), _freezeAnimation(false) {}
MapTile(const MapTile &t) : _id(t._id), _frame(t._frame), _freezeAnimation(t._freezeAnimation) {}
TileId getId() const {
return _id;
}
- unsigned char getFrame() const {
+ byte getFrame() const {
return _frame;
}
bool getFreezeAnimation() const {
@@ -106,7 +107,7 @@ public:
// Properties
TileId _id;
- unsigned char _frame;
+ byte _frame;
bool _freezeAnimation;
};
diff --git a/engines/ultima/ultima4/core/utils.cpp b/engines/ultima/ultima4/core/utils.cpp
index c3ba81f6dd..16be7b780f 100644
--- a/engines/ultima/ultima4/core/utils.cpp
+++ b/engines/ultima/ultima4/core/utils.cpp
@@ -37,7 +37,7 @@ void ASSERT(bool exp, const char *desc, ...) {
}
void xu4_srandom() {
-// srand((unsigned int)time(NULL));
+// srand((uint)time(nullptr));
}
int xu4_random(int upperRange) {
diff --git a/engines/ultima/ultima4/core/utils.h b/engines/ultima/ultima4/core/utils.h
index 5b549c9b83..4c30a5f2e0 100644
--- a/engines/ultima/ultima4/core/utils.h
+++ b/engines/ultima/ultima4/core/utils.h
@@ -85,7 +85,7 @@ inline void AdjustValue(unsigned short &v, int val, int max, int min) {
/**
* Seed the random number generator.
*/
-void xu4_srandom(void);
+void xu4_srandom();
/**
* Generate a random number between 0 and (upperRange - 1)
diff --git a/engines/ultima/ultima4/events/event.cpp b/engines/ultima/ultima4/events/event.cpp
index aa1ede9414..d1d71c78c5 100644
--- a/engines/ultima/ultima4/events/event.cpp
+++ b/engines/ultima/ultima4/events/event.cpp
@@ -45,7 +45,7 @@ EventHandler *EventHandler::getInstance() {
return _instance;
}
-void EventHandler::wait_msecs(unsigned int msecs) {
+void EventHandler::wait_msecs(uint msecs) {
int msecs_per_cycle = (1000 / settings._gameCyclesPerSecond);
int cycles = msecs / msecs_per_cycle;
@@ -58,7 +58,7 @@ void EventHandler::wait_msecs(unsigned int msecs) {
EventHandler::sleep(msecs % msecs_per_cycle);
}
-void EventHandler::wait_cycles(unsigned int cycles) {
+void EventHandler::wait_cycles(uint cycles) {
WaitController waitCtrl(cycles);
getInstance()->pushController(&waitCtrl);
waitCtrl.wait();
diff --git a/engines/ultima/ultima4/events/event.h b/engines/ultima/ultima4/events/event.h
index 2aab6508ea..00c54cf98b 100644
--- a/engines/ultima/ultima4/events/event.h
+++ b/engines/ultima/ultima4/events/event.h
@@ -70,7 +70,7 @@ typedef void *UIEvent;
#endif
#endif
-typedef void(*updateScreenCallback)(void);
+typedef void(*updateScreenCallback)();
/**
* A class for handling game events.
*/
@@ -93,17 +93,17 @@ public:
* This doesn't actually stop events, but it stops the user from interacting
* While some important event happens (e.g., getting hit by a cannon ball or a spell effect).
*/
- static void sleep(unsigned int usec);
+ static void sleep(uint usec);
/**
* Waits a given number of milliseconds before continuing
*/
- static void wait_msecs(unsigned int msecs);
+ static void wait_msecs(uint msecs);
/**
* Waits a given number of game cycles before continuing
*/
- static void wait_cycles(unsigned int cycles);
+ static void wait_cycles(uint cycles);
static void setControllerDone(bool exit = true);
static bool getControllerDone();
@@ -144,7 +144,7 @@ public:
/**
* Returns a pointer to the current key handler.
- * Returns NULL if there is no key handler.
+ * Returns nullptr if there is no key handler.
*/
KeyHandler *getKeyHandler() const;
diff --git a/engines/ultima/ultima4/events/event_scummvm.cpp b/engines/ultima/ultima4/events/event_scummvm.cpp
index 4b86286e1d..e9a86bb30b 100644
--- a/engines/ultima/ultima4/events/event_scummvm.cpp
+++ b/engines/ultima/ultima4/events/event_scummvm.cpp
@@ -34,7 +34,7 @@
namespace Ultima {
namespace Ultima4 {
-EventHandler::EventHandler() : _timer(settings._eventTimerGranularity), _updateScreen(NULL) {
+EventHandler::EventHandler() : _timer(settings._eventTimerGranularity), _updateScreen(nullptr) {
}
static void handleMouseMotionEvent(const Common::Event &event) {
@@ -110,7 +110,7 @@ static void handleKeyDownEvent(const Common::Event &event, Controller *controlle
}
}
-void EventHandler::sleep(unsigned int msec) {
+void EventHandler::sleep(uint msec) {
g_system->delayMillis(msec);
}
@@ -177,18 +177,18 @@ void EventHandler::popKeyHandler() {
KeyHandler *EventHandler::getKeyHandler() const {
if (_controllers.empty())
- return NULL;
+ return nullptr;
KeyHandlerController *khc = dynamic_cast<KeyHandlerController *>(_controllers.back());
- ASSERT(khc != NULL, "EventHandler::getKeyHandler called when controller wasn't a keyhandler");
- if (khc == NULL)
- return NULL;
+ ASSERT(khc != nullptr, "EventHandler::getKeyHandler called when controller wasn't a keyhandler");
+ if (khc == nullptr)
+ return nullptr;
return khc->getKeyHandler();
}
void EventHandler::setKeyHandler(KeyHandler kh) {
- while (popController() != NULL) {}
+ while (popController() != nullptr) {}
pushKeyHandler(kh);
}
@@ -197,14 +197,14 @@ const MouseArea *EventHandler::mouseAreaForPoint(int x, int y) {
const MouseArea *areas = getMouseAreaSet();
if (!areas)
- return NULL;
+ return nullptr;
for (i = 0; areas[i]._nPoints != 0; i++) {
if (g_screen->screenPointInMouseArea(x, y, &(areas[i]))) {
return &(areas[i]);
}
}
- return NULL;
+ return nullptr;
}
} // End of namespace Ultima4
diff --git a/engines/ultima/ultima4/events/timed_event_mgr.cpp b/engines/ultima/ultima4/events/timed_event_mgr.cpp
index e8142b41d0..51a2c66dbf 100644
--- a/engines/ultima/ultima4/events/timed_event_mgr.cpp
+++ b/engines/ultima/ultima4/events/timed_event_mgr.cpp
@@ -41,7 +41,7 @@ void TimedEventMgr::poll() {
}
}
-void TimedEventMgr::reset(unsigned int interval) {
+void TimedEventMgr::reset(uint interval) {
_baseInterval = interval;
stop();
start();
@@ -51,7 +51,7 @@ void TimedEventMgr::stop() {
#ifdef TODO
if (id) {
SDL_RemoveTimer(static_cast<SDL_TimerID>(id));
- id = NULL;
+ id = nullptr;
}
#endif
}
diff --git a/engines/ultima/ultima4/events/timed_event_mgr.h b/engines/ultima/ultima4/events/timed_event_mgr.h
index 9f54006d56..f442fdd7dc 100644
--- a/engines/ultima/ultima4/events/timed_event_mgr.h
+++ b/engines/ultima/ultima4/events/timed_event_mgr.h
@@ -38,7 +38,7 @@ public:
typedef void (*Callback)(void *);
/* Constructors */
- TimedEvent(Callback callback, int interval, void *data = NULL);
+ TimedEvent(Callback callback, int interval, void *data = nullptr);
/* Member functions */
Callback getCallback() const;
@@ -97,14 +97,14 @@ public:
/**
* Adds a timed event to the event queue.
*/
- void add(TimedEvent::Callback theCallback, int interval, void *data = NULL);
+ void add(TimedEvent::Callback theCallback, int interval, void *data = nullptr);
/**
* Removes a timed event from the event queue.
*/
List::iterator remove(List::iterator i);
void remove(TimedEvent *event);
- void remove(TimedEvent::Callback theCallback, void *data = NULL);
+ void remove(TimedEvent::Callback theCallback, void *data = nullptr);
/**
* Runs each of the callback functions of the TimedEvents associated with this manager.
@@ -116,7 +116,7 @@ public:
/**
* Re-initializes the timer manager to a new timer granularity
*/
- void reset(unsigned int interval); /**< Re-initializes the event manager to a new base interval */
+ void reset(uint interval); /**< Re-initializes the event manager to a new base interval */
#if defined(IOS)
bool hasActiveTimer() const;
#endif
diff --git a/engines/ultima/ultima4/filesys/filesystem.cpp b/engines/ultima/ultima4/filesys/filesystem.cpp
index a9480bcedc..b6eb55965c 100644
--- a/engines/ultima/ultima4/filesys/filesystem.cpp
+++ b/engines/ultima/ultima4/filesys/filesystem.cpp
@@ -36,7 +36,7 @@ const char Path::delim = '/';
#endif
Path::Path(const Common::String &p) : path(p) {
- unsigned int pos;
+ uint pos;
bool _exists = false, isDir = false;
/* determine if the path really exists */
diff --git a/engines/ultima/ultima4/filesys/rle.cpp b/engines/ultima/ultima4/filesys/rle.cpp
index 70a157474d..22fdc04713 100644
--- a/engines/ultima/ultima4/filesys/rle.cpp
+++ b/engines/ultima/ultima4/filesys/rle.cpp
@@ -48,14 +48,14 @@ long rleDecompressFile(Common::ReadStream *in, long inlen, void **out) {
}
long rleDecompressMemory(void *in, long inlen, void **out) {
- unsigned char *indata, *outdata;
+ byte *indata, *outdata;
long outlen;
/* input should be longer than 0 bytes */
if (inlen <= 0)
return -1;
- indata = (unsigned char *)in;
+ indata = (byte *)in;
/* determine decompressed file size */
outlen = rleGetDecompressedSize(indata, inlen);
@@ -64,7 +64,7 @@ long rleDecompressMemory(void *in, long inlen, void **out) {
return -1;
/* decompress file from inlen to outlen */
- outdata = (unsigned char *) malloc(outlen);
+ outdata = (byte *) malloc(outlen);
rleDecompress(indata, inlen, outdata, outlen);
*out = outdata;
@@ -75,9 +75,9 @@ long rleDecompressMemory(void *in, long inlen, void **out) {
/**
* Determine the uncompressed size of RLE compressed data.
*/
-long rleGetDecompressedSize(unsigned char *indata, long inlen) {
- unsigned char *p;
- unsigned char ch, count;
+long rleGetDecompressedSize(byte *indata, long inlen) {
+ byte *p;
+ byte ch, count;
long len = 0;
p = indata;
@@ -97,10 +97,10 @@ long rleGetDecompressedSize(unsigned char *indata, long inlen) {
/**
* Decompress a block of RLE encoded memory.
*/
-long rleDecompress(unsigned char *indata, long inlen, unsigned char *outdata, long outlen) {
+long rleDecompress(byte *indata, long inlen, byte *outdata, long outlen) {
int i;
- unsigned char *p, *q;
- unsigned char ch, count, val;
+ byte *p, *q;
+ byte ch, count, val;
p = indata;
q = outdata;
diff --git a/engines/ultima/ultima4/filesys/rle.h b/engines/ultima/ultima4/filesys/rle.h
index 17240e27aa..4b4707cbb5 100644
--- a/engines/ultima/ultima4/filesys/rle.h
+++ b/engines/ultima/ultima4/filesys/rle.h
@@ -32,8 +32,8 @@ namespace Ultima4 {
long rleDecompressFile(Common::ReadStream *in, long inlen, void **out);
long rleDecompressMemory(void *in, long inlen, void **out);
-long rleGetDecompressedSize(unsigned char *indata, long inlen);
-long rleDecompress(unsigned char *indata, long inlen, unsigned char *outdata, long outlen);
+long rleGetDecompressedSize(byte *indata, long inlen);
+long rleDecompress(byte *indata, long inlen, byte *outdata, long outlen);
} // End of namespace Ultima4
} // End of namespace Ultima
diff --git a/engines/ultima/ultima4/filesys/savegame.cpp b/engines/ultima/ultima4/filesys/savegame.cpp
index 6a510cf3a3..c5d46eb9df 100644
--- a/engines/ultima/ultima4/filesys/savegame.cpp
+++ b/engines/ultima/ultima4/filesys/savegame.cpp
@@ -75,7 +75,7 @@ void SaveGame::save(Common::WriteStream *stream) {
* Write dungeon info
*/
if (g_context->_location && g_context->_location->_context & CTX_DUNGEON) {
- unsigned int x, y, z;
+ uint x, y, z;
typedef Std::map<const Creature *, int, Std::PointerHash> DngCreatureIdMap;
static DngCreatureIdMap id_map;
@@ -104,7 +104,7 @@ void SaveGame::save(Common::WriteStream *stream) {
for (z = 0; z < g_context->_location->_map->_levels; z++) {
for (y = 0; y < g_context->_location->_map->_height; y++) {
for (x = 0; x < g_context->_location->_map->_width; x++) {
- unsigned char tile = g_context->_location->_map->translateToRawTileIndex(*g_context->_location->_map->getTileFromData(MapCoords(x, y, z)));
+ byte tile = g_context->_location->_map->translateToRawTileIndex(*g_context->_location->_map->getTileFromData(MapCoords(x, y, z)));
Object *obj = g_context->_location->_map->objectAt(MapCoords(x, y, z));
/**
@@ -164,7 +164,7 @@ void SaveGame::load(Common::SeekableReadStream *stream) {
}
// set the map to the world map
- g_game->setMap(mapMgr->get(MAP_WORLD), 0, NULL);
+ g_game->setMap(mapMgr->get(MAP_WORLD), 0, nullptr);
g_context->_location->_map->clearObjects();
// initialize our start location
@@ -172,7 +172,7 @@ void SaveGame::load(Common::SeekableReadStream *stream) {
// if our map is not the world map, then load our map
if (map->_type != Map::WORLD)
- g_game->setMap(map, 1, NULL);
+ g_game->setMap(map, 1, nullptr);
else
// initialize the moons (must be done from the world map)
g_game->initMoons();
diff --git a/engines/ultima/ultima4/filesys/savegame.h b/engines/ultima/ultima4/filesys/savegame.h
index a6d755502c..2958c07723 100644
--- a/engines/ultima/ultima4/filesys/savegame.h
+++ b/engines/ultima/ultima4/filesys/savegame.h
@@ -251,8 +251,8 @@ struct SaveGame {
*/
void synchronize(Common::Serializer &s);
- unsigned int _unknown1;
- unsigned int _moves;
+ uint _unknown1;
+ uint _moves;
SaveGamePlayerRecord _players[8];
int _food;
short _gold;
diff --git a/engines/ultima/ultima4/filesys/u4file.cpp b/engines/ultima/ultima4/filesys/u4file.cpp
index d561c8f9cf..f1325dc374 100644
--- a/engines/ultima/ultima4/filesys/u4file.cpp
+++ b/engines/ultima/ultima4/filesys/u4file.cpp
@@ -86,7 +86,7 @@ private:
bool u4isUpgradeAvailable() {
bool avail = false;
U4FILE *pal;
- if ((pal = u4fopen("u4vga.pal")) != NULL) {
+ if ((pal = u4fopen("u4vga.pal")) != nullptr) {
avail = true;
u4fclose(pal);
}
@@ -98,7 +98,7 @@ bool u4isUpgradeAvailable() {
* (switch.bat or setup.bat has been run)
*/
bool u4isUpgradeInstalled() {
- U4FILE *u4f = NULL;
+ U4FILE *u4f = nullptr;
long int filelength;
bool result = false;
@@ -140,19 +140,19 @@ const Common::String &U4ZipPackage::translate(const Common::String &name) const
return name;
}
-U4ZipPackageMgr *U4ZipPackageMgr::_instance = NULL;
+U4ZipPackageMgr *U4ZipPackageMgr::_instance = nullptr;
U4ZipPackageMgr *U4ZipPackageMgr::getInstance() {
- if (_instance == NULL) {
+ if (_instance == nullptr) {
_instance = new U4ZipPackageMgr();
}
return _instance;
}
void U4ZipPackageMgr::destroy() {
- if (_instance != NULL) {
+ if (_instance != nullptr) {
delete _instance;
- _instance = NULL;
+ _instance = nullptr;
}
}
@@ -386,13 +386,13 @@ U4FILE *U4FILE_zip::open(const Common::String &fname, const U4ZipPackage *packag
f = unzOpen(package->getFilename().c_str());
if (!f)
- return NULL;
+ return nullptr;
Common::String pathname = package->getInternalPath() + package->translate(fname);
if (unzLocateFile(f, pathname.c_str(), 2) == UNZ_END_OF_LIST_OF_FILE) {
unzClose(f);
- return NULL;
+ return nullptr;
}
unzOpenCurrentFile(f);
@@ -460,7 +460,7 @@ size_t U4FILE_zip::read(void *ptr, size_t size, size_t nmemb) {
int U4FILE_zip::getc() {
#ifdef TODO
int retval;
- unsigned char c;
+ byte c;
if (unzReadCurrentFile(zfile, &c, 1) > 0)
retval = c;
@@ -483,9 +483,9 @@ long U4FILE_zip::length() {
unz_file_info fileinfo;
unzGetCurrentFileInfo(zfile, &fileinfo,
- NULL, 0,
- NULL, 0,
- NULL, 0);
+ nullptr, 0,
+ nullptr, 0,
+ nullptr, 0);
return fileinfo.uncompressed_size;
#else
return 0;
@@ -496,7 +496,7 @@ long U4FILE_zip::length() {
* Open a data file from the Ultima 4 for DOS installation
*/
U4FILE *u4fopen(const Common::String &fname) {
- U4FILE *u4f = NULL;
+ U4FILE *u4f = nullptr;
debug(1, "looking for %s\n", fname.c_str());
#ifdef TODO
@@ -518,7 +518,7 @@ U4FILE *u4fopen(const Common::String &fname) {
if (!fname.empty()) {
u4f = U4FILE_stdio::openForReading(fname);
- if (u4f != NULL)
+ if (u4f != nullptr)
debug(1, "%s successfully opened\n", fname.c_str());
}
@@ -608,7 +608,7 @@ vector<Common::String> u4read_stringtable(U4FILE *f, long offset, int nstrings)
Common::String u4find_path(const Common::String &fname, Common::List<Common::String> specificSubPaths) {
#ifdef TODO
- FILE *f = NULL;
+ FILE *f = nullptr;
// Try absolute first
char path[2048]; // Sometimes paths get big.
@@ -618,7 +618,7 @@ Common::String u4find_path(const Common::String &fname, Common::List<Common::Str
strcpy(path, fname.c_str());
// Try 'file://' protocol if specified
- if (f == NULL) {
+ if (f == nullptr) {
const Common::String file_url_prefix("file://");
if (fname.compare(0, file_url_prefix.length(), file_url_prefix) == 0) {
@@ -631,7 +631,7 @@ Common::String u4find_path(const Common::String &fname, Common::List<Common::Str
}
// Try paths
- if (f == NULL) {
+ if (f == nullptr) {
for (Common::List<Common::String>::iterator rootItr = u4Path.rootResourcePaths.begin();
rootItr != u4Path.rootResourcePaths.end() && !f;
++rootItr) {
@@ -644,13 +644,13 @@ Common::String u4find_path(const Common::String &fname, Common::List<Common::Str
if (verbose) {
debug("trying to open %s\n", path);
}
- if ((f = fopen(path, "rb")) != NULL)
+ if ((f = fopen(path, "rb")) != nullptr)
break;
}
}
}
#if defined(IOS)
- if (f == NULL) {
+ if (f == nullptr) {
Common::String base = fname;
Common::String ext = "";
Common::String dir = "";
@@ -677,7 +677,7 @@ Common::String u4find_path(const Common::String &fname, Common::List<Common::Str
#endif
if (verbose) {
- if (f != NULL)
+ if (f != nullptr)
debug("%s successfully found\n", path);
else
debug("%s not found\n", fname.c_str());
diff --git a/engines/ultima/ultima4/game/armor.cpp b/engines/ultima/ultima4/game/armor.cpp
index cf484ccad2..9744c91915 100644
--- a/engines/ultima/ultima4/game/armor.cpp
+++ b/engines/ultima/ultima4/game/armor.cpp
@@ -41,7 +41,7 @@ const Armor *Armor::get(ArmorType a) {
loadConf();
if (static_cast<unsigned>(a) >= _armors.size())
- return NULL;
+ return nullptr;
return _armors[a];
}
@@ -53,7 +53,7 @@ const Armor *Armor::get(const string &name) {
if (scumm_stricmp(name.c_str(), _armors[i]->_name.c_str()) == 0)
return _armors[i];
}
- return NULL;
+ return nullptr;
}
Armor::Armor(const ConfigElement &conf) {
@@ -65,7 +65,7 @@ Armor::Armor(const ConfigElement &conf) {
vector<ConfigElement> contraintConfs = conf.getChildren();
for (Std::vector<ConfigElement>::iterator i = contraintConfs.begin(); i != contraintConfs.end(); i++) {
- unsigned char useMask = 0;
+ byte useMask = 0;
if (i->getName() != "constraint")
continue;
diff --git a/engines/ultima/ultima4/game/armor.h b/engines/ultima/ultima4/game/armor.h
index 89a1b09007..7ceb380193 100644
--- a/engines/ultima/ultima4/game/armor.h
+++ b/engines/ultima/ultima4/game/armor.h
@@ -70,7 +70,7 @@ private:
ArmorType _type;
string _name;
- unsigned char _canUse;
+ byte _canUse;
int _defense;
unsigned short _mask;
};
diff --git a/engines/ultima/ultima4/game/aura.cpp b/engines/ultima/ultima4/game/aura.cpp
index 5da940d5de..163f37d97c 100644
--- a/engines/ultima/ultima4/game/aura.cpp
+++ b/engines/ultima/ultima4/game/aura.cpp
@@ -30,20 +30,20 @@ Aura::Aura() : _type(NONE), _duration(0) {}
void Aura::setDuration(int d) {
_duration = d;
setChanged();
- notifyObservers(NULL);
+ notifyObservers(nullptr);
}
void Aura::set(Type t, int d) {
_type = t;
_duration = d;
setChanged();
- notifyObservers(NULL);
+ notifyObservers(nullptr);
}
void Aura::setType(Type t) {
_type = t;
setChanged();
- notifyObservers(NULL);
+ notifyObservers(nullptr);
}
void Aura::passTurn() {
@@ -54,7 +54,7 @@ void Aura::passTurn() {
_type = NONE;
setChanged();
- notifyObservers(NULL);
+ notifyObservers(nullptr);
}
}
}
diff --git a/engines/ultima/ultima4/game/context.cpp b/engines/ultima/ultima4/game/context.cpp
index 82e0abca72..038eaf9966 100644
--- a/engines/ultima/ultima4/game/context.cpp
+++ b/engines/ultima/ultima4/game/context.cpp
@@ -27,7 +27,7 @@ namespace Ultima4 {
Context *g_context;
-Context::Context() : _party(NULL), _location(NULL) {
+Context::Context() : _party(nullptr), _location(nullptr) {
g_context = this;
}
diff --git a/engines/ultima/ultima4/game/creature.cpp b/engines/ultima/ultima4/game/creature.cpp
index a97a39ba6b..700df04747 100644
--- a/engines/ultima/ultima4/game/creature.cpp
+++ b/engines/ultima/ultima4/game/creature.cpp
@@ -39,11 +39,11 @@
namespace Ultima {
namespace Ultima4 {
-CreatureMgr *CreatureMgr::_instance = NULL;
+CreatureMgr *CreatureMgr::_instance = nullptr;
bool isCreature(Object *punknown) {
Creature *m;
- if ((m = dynamic_cast<Creature *>(punknown)) != NULL)
+ if ((m = dynamic_cast<Creature *>(punknown)) != nullptr)
return true;
else
return false;
@@ -57,11 +57,11 @@ Creature::Creature(MapTile tile) :
}
void Creature::load(const ConfigElement &conf) {
- unsigned int idx;
+ uint idx;
static const struct {
const char *name;
- unsigned int mask;
+ uint mask;
} booleanAttributes[] = {
{ "undead", MATTR_UNDEAD },
{ "good", MATTR_GOOD },
@@ -80,7 +80,7 @@ void Creature::load(const ConfigElement &conf) {
/* steals="" */
static const struct {
const char *name;
- unsigned int mask;
+ uint mask;
} steals[] = {
{ "food", MATTR_STEALFOOD },
{ "gold", MATTR_STEALGOLD }
@@ -89,7 +89,7 @@ void Creature::load(const ConfigElement &conf) {
/* casts="" */
static const struct {
const char *name;
- unsigned int mask;
+ uint mask;
} casts[] = {
{ "sleep", MATTR_CASTS_SLEEP },
{ "negate", MATTR_NEGATE }
@@ -98,7 +98,7 @@ void Creature::load(const ConfigElement &conf) {
/* movement="" */
static const struct {
const char *name;
- unsigned int mask;
+ uint mask;
} movement[] = {
{ "none", MATTR_STATIONARY },
{ "wanders", MATTR_WANDERS }
@@ -107,7 +107,7 @@ void Creature::load(const ConfigElement &conf) {
/* boolean attributes that affect movement */
static const struct {
const char *name;
- unsigned int mask;
+ uint mask;
} movementBoolean[] = {
{ "swims", MATTR_SWIMS },
{ "sails", MATTR_SAILS },
@@ -130,7 +130,7 @@ void Creature::load(const ConfigElement &conf) {
_id = static_cast<unsigned short>(conf.getInt("id"));
/* Get the leader if it's been included, otherwise the leader is itself */
- _leader = static_cast<unsigned char>(conf.getInt("leader", _id));
+ _leader = static_cast<byte>(conf.getInt("leader", _id));
_xp = static_cast<unsigned short>(conf.getInt("exp"));
_ranged = conf.getBool("ranged");
@@ -225,7 +225,7 @@ void Creature::load(const ConfigElement &conf) {
if (conf.exists("spawnsOnDeath")) {
_mAttr = static_cast<CreatureAttrib>(_mAttr | MATTR_SPAWNSONDEATH);
- _spawn = static_cast<unsigned char>(conf.getInt("spawnsOnDeath"));
+ _spawn = static_cast<byte>(conf.getInt("spawnsOnDeath"));
}
/* Figure out which 'slowed' function to use */
@@ -334,7 +334,7 @@ bool Creature::specialAction() {
*/
if (mapdist <= 3 && xu4_random(2) == 0 && (g_context->_location->_context & CTX_CITY) == 0) {
Std::vector<Coords> path = gameGetDirectionalActionPath(dir, MASK_DIR_ALL, _coords,
- 1, 3, NULL, false);
+ 1, 3, nullptr, false);
for (Std::vector<Coords>::iterator i = path.begin(); i != path.end(); i++) {
if (creatureRangeAttack(*i, this))
break;
@@ -355,7 +355,7 @@ bool Creature::specialAction() {
// nothing (not even mountains!) can block cannonballs
Std::vector<Coords> path = gameGetDirectionalActionPath(dir, broadsidesDirs, _coords,
- 1, 3, NULL, false);
+ 1, 3, nullptr, false);
for (Std::vector<Coords>::iterator i = path.begin(); i != path.end(); i++) {
if (fireAt(*i, false))
break;
@@ -500,7 +500,7 @@ void Creature::act(CombatController *controller) {
*/
target = nearestOpponent(&dist, action == CA_RANGED);
- if (target == NULL)
+ if (target == nullptr)
return;
if (action == CA_ATTACK && dist > 1)
@@ -520,7 +520,7 @@ void Creature::act(CombatController *controller) {
if (!dealDamage(target, getDamage()))
- target = NULL;
+ target = nullptr;
if (target && isPartyMember(target)) {
/* steal gold if the creature steals gold */
@@ -745,7 +745,7 @@ bool Creature::hideOrShow() {
int dist;
/* ok, now we've got the nearest party member. Now, see if they're close enough */
- if (nearestOpponent(&dist, false) != NULL) {
+ if (nearestOpponent(&dist, false) != nullptr) {
if ((dist < 5) && !isVisible())
setVisible(); /* show yourself */
else if (dist >= 5)
@@ -756,7 +756,7 @@ bool Creature::hideOrShow() {
}
Creature *Creature::nearestOpponent(int *dist, bool ranged) {
- Creature *opponent = NULL;
+ Creature *opponent = nullptr;
int d, leastDist = 0xFFFF;
ObjectDeque::iterator i;
bool jinx = (*g_context->_aura == Aura::JINX);
@@ -886,7 +886,7 @@ bool Creature::dealDamage(Creature *m, int damage) {
* CreatureMgr class implementation
*/
CreatureMgr *CreatureMgr::getInstance() {
- if (_instance == NULL) {
+ if (_instance == nullptr) {
_instance = new CreatureMgr();
_instance->loadAll();
}
@@ -919,14 +919,14 @@ Creature *CreatureMgr::getByTile(MapTile tile) {
// if (tile.id)
// errorWarning("Did not find creature for tile %d", tile.id);
- return NULL;
+ return nullptr;
}
Creature *CreatureMgr::getById(CreatureId id) {
CreatureMap::const_iterator i = _creatures.find(id);
if (i != _creatures.end())
return i->_value;
- else return NULL;
+ else return nullptr;
}
Creature *CreatureMgr::getByName(Common::String name) {
@@ -935,7 +935,7 @@ Creature *CreatureMgr::getByName(Common::String name) {
if (scumm_stricmp(i->_value->getName().c_str(), name.c_str()) == 0)
return i->_value;
}
- return NULL;
+ return nullptr;
}
Creature *CreatureMgr::randomForTile(const Tile *tile) {
@@ -958,7 +958,7 @@ Creature *CreatureMgr::randomForTile(const Tile *tile) {
}
if (!tile->isCreatureWalkable())
- return NULL;
+ return nullptr;
//if (c->saveGame->_moves > 100000) // FIXME: what's 100,000 moves all about (if anything)?
if (g_ultima->_saveGame->_moves > 30000)
@@ -1014,7 +1014,7 @@ Creature *CreatureMgr::randomAmbushing() {
}
error("failed to find an ambushing creature");
- return NULL;
+ return nullptr;
}
} // End of namespace Ultima4
diff --git a/engines/ultima/ultima4/game/creature.h b/engines/ultima/ultima4/game/creature.h
index ab29007537..a4c328a091 100644
--- a/engines/ultima/ultima4/game/creature.h
+++ b/engines/ultima/ultima4/game/creature.h
@@ -199,7 +199,7 @@ public:
int getEncounterSize() const {
return _encounterSize;
}
- unsigned char getResists() const {
+ byte getResists() const {
return _resists;
}
@@ -373,14 +373,14 @@ protected:
int _hp;
StatusList _status;
int _xp;
- unsigned char _ranged;
+ byte _ranged;
Common::String _worldRangedTile;
bool _leavesTile;
CreatureAttrib _mAttr;
CreatureMovementAttrib _movementAttr;
SlowedType _slowedType;
int _encounterSize;
- unsigned char _resists;
+ byte _resists;
CreatureId _spawn;
};
@@ -395,20 +395,20 @@ public:
/**
* Returns a creature using a tile to find which one to create
- * or NULL if a creature with that tile cannot be found
+ * or nullptr if a creature with that tile cannot be found
*/
Creature *getByTile(MapTile tile);
/**
* Returns the creature that has the corresponding id
- * or returns NULL if no creature with that id could
+ * or returns nullptr if no creature with that id could
* be found.
*/
Creature *getById(CreatureId id);
/**
* Returns the creature that has the corresponding name
- * or returns NULL if no creature can be found with
+ * or returns nullptr if no creature can be found with
* that name (case insensitive)
*/
Creature *getByName(Common::String name);
diff --git a/engines/ultima/ultima4/game/death.cpp b/engines/ultima/ultima4/game/death.cpp
index 2530ff192d..f2e0756263 100644
--- a/engines/ultima/ultima4/game/death.cpp
+++ b/engines/ultima/ultima4/game/death.cpp
@@ -48,11 +48,11 @@ namespace Ultima4 {
#define REVIVE_CASTLE_Y 8
int timerCount;
-unsigned int timerMsg;
+uint timerMsg;
int deathSequenceRunning = 0;
void deathTimer(void *data);
-void deathRevive(void);
+void deathRevive();
const struct {
int timeout; /* pause in seconds */
@@ -112,7 +112,7 @@ void deathTimer(void *data) {
}
void deathRevive() {
- while (!g_context->_location->_map->isWorldMap() && g_context->_location->_prev != NULL) {
+ while (!g_context->_location->_map->isWorldMap() && g_context->_location->_prev != nullptr) {
g_game->exitToParentMap();
}
@@ -126,7 +126,7 @@ void deathRevive() {
/* Now, move the avatar into the castle and put him
in front of Lord British */
- g_game->setMap(mapMgr->get(100), 1, NULL);
+ g_game->setMap(mapMgr->get(100), 1, nullptr);
g_context->_location->_coords.x = REVIVE_CASTLE_X;
g_context->_location->_coords.y = REVIVE_CASTLE_Y;
g_context->_location->_coords.z = 0;
diff --git a/engines/ultima/ultima4/game/game.cpp b/engines/ultima/ultima4/game/game.cpp
index 914d4897a8..fc24d2a4ea 100644
--- a/engines/ultima/ultima4/game/game.cpp
+++ b/engines/ultima/ultima4/game/game.cpp
@@ -82,9 +82,9 @@ using namespace std;
/* main game functions */
void gameAdvanceLevel(PartyMember *player);
-void gameInnHandler(void);
+void gameInnHandler();
void gameLostEighth(Virtue virtue);
-void gamePartyStarving(void);
+void gamePartyStarving();
void mixReagentsSuper();
@@ -244,7 +244,7 @@ bool fireAt(const Coords &coords, bool originAvatar) {
bool hitsAvatar = false;
bool objectHit = false;
- Object *obj = NULL;
+ Object *obj = nullptr;
MapTile tile(g_context->_location->_map->_tileset->getByName("miss_flash")->getId());
@@ -305,8 +305,8 @@ bool gamePeerCity(int city, void *data) {
peerMap = mapMgr->get((MapId)(city + 1));
- if (peerMap != NULL) {
- g_game->setMap(peerMap, 1, NULL);
+ if (peerMap != nullptr) {
+ g_game->setMap(peerMap, 1, nullptr);
g_context->_location->_viewMode = VIEW_GEM;
g_game->_paused = true;
g_game->_pausedTimer = 0;
@@ -627,7 +627,7 @@ void gameSetActivePlayer(int player) {
/**
* Spawns a creature (m) just offscreen of the avatar.
- * If (m==NULL) then it finds its own creature to spawn and spawns it.
+ * If (m==nullptr) then it finds its own creature to spawn and spawns it.
*/
bool gameSpawnCreature(const Creature *m) {
int t, i;
diff --git a/engines/ultima/ultima4/game/item.cpp b/engines/ultima/ultima4/game/item.cpp
index f6b15b21f8..3522969bd5 100644
--- a/engines/ultima/ultima4/game/item.cpp
+++ b/engines/ultima/ultima4/game/item.cpp
@@ -53,7 +53,7 @@ void itemSetDestroyAllCreaturesCallback(DestroyAllCreaturesCallback callback) {
}
int needStoneNames = 0;
-unsigned char stoneMask = 0;
+byte stoneMask = 0;
bool isRuneInInventory(int virt);
void putRuneInInventory(int virt);
@@ -80,20 +80,20 @@ void itemHandleStones(const Common::String &color);
static const ItemLocation ITEMS[] = {
{
- "Mandrake Root", NULL, "mandrake1",
- &isReagentInInventory, &putReagentInInventory, NULL, REAG_MANDRAKE, SC_NEWMOONS | SC_REAGENTDELAY
+ "Mandrake Root", nullptr, "mandrake1",
+ &isReagentInInventory, &putReagentInInventory, nullptr, REAG_MANDRAKE, SC_NEWMOONS | SC_REAGENTDELAY
},
{
- "Mandrake Root", NULL, "mandrake2",
- &isReagentInInventory, &putReagentInInventory, NULL, REAG_MANDRAKE, SC_NEWMOONS | SC_REAGENTDELAY
+ "Mandrake Root", nullptr, "mandrake2",
+ &isReagentInInventory, &putReagentInInventory, nullptr, REAG_MANDRAKE, SC_NEWMOONS | SC_REAGENTDELAY
},
{
- "Nightshade", NULL, "nightshade1",
- &isReagentInInventory, &putReagentInInventory, NULL, REAG_NIGHTSHADE, SC_NEWMOONS | SC_REAGENTDELAY
+ "Nightshade", nullptr, "nightshade1",
+ &isReagentInInventory, &putReagentInInventory, nullptr, REAG_NIGHTSHADE, SC_NEWMOONS | SC_REAGENTDELAY
},
{
- "Nightshade", NULL, "nightshade2",
- &isReagentInInventory, &putReagentInInventory, NULL, REAG_NIGHTSHADE, SC_NEWMOONS | SC_REAGENTDELAY
+ "Nightshade", nullptr, "nightshade2",
+ &isReagentInInventory, &putReagentInInventory, nullptr, REAG_NIGHTSHADE, SC_NEWMOONS | SC_REAGENTDELAY
},
{
"the Bell of Courage", "bell", "bell",
@@ -153,58 +153,58 @@ static const ItemLocation ITEMS[] = {
},
/* handlers for using generic objects */
- { NULL, "stone", NULL, &isStoneInInventory, NULL, &useStone, -1, 0 },
- { NULL, "stones", NULL, &isStoneInInventory, NULL, &useStone, -1, 0 },
- { NULL, "key", NULL, &isItemInInventory, NULL, &useKey, (ITEM_KEY_C | ITEM_KEY_L | ITEM_KEY_T), 0 },
- { NULL, "keys", NULL, &isItemInInventory, NULL, &useKey, (ITEM_KEY_C | ITEM_KEY_L | ITEM_KEY_T), 0 },
+ { nullptr, "stone", nullptr, &isStoneInInventory, nullptr, &useStone, -1, 0 },
+ { nullptr, "stones", nullptr, &isStoneInInventory, nullptr, &useStone, -1, 0 },
+ { nullptr, "key", nullptr, &isItemInInventory, nullptr, &useKey, (ITEM_KEY_C | ITEM_KEY_L | ITEM_KEY_T), 0 },
+ { nullptr, "keys", nullptr, &isItemInInventory, nullptr, &useKey, (ITEM_KEY_C | ITEM_KEY_L | ITEM_KEY_T), 0 },
/* Lycaeum telescope */
- { NULL, NULL, "telescope", NULL, &useTelescope, NULL, 0, 0 },
+ { nullptr, nullptr, "telescope", nullptr, &useTelescope, nullptr, 0, 0 },
{
- "Mystic Armor", NULL, "mysticarmor",
- &isMysticInInventory, &putMysticInInventory, NULL, ARMR_MYSTICROBES, SC_FULLAVATAR
+ "Mystic Armor", nullptr, "mysticarmor",
+ &isMysticInInventory, &putMysticInInventory, nullptr, ARMR_MYSTICROBES, SC_FULLAVATAR
},
{
- "Mystic Swords", NULL, "mysticswords",
- &isMysticInInventory, &putMysticInInventory, NULL, WEAP_MYSTICSWORD, SC_FULLAVATAR
+ "Mystic Swords", nullptr, "mysticswords",
+ &isMysticInInventory, &putMysticInInventory, nullptr, WEAP_MYSTICSWORD, SC_FULLAVATAR
},
{
- "the sulfury remains of an ancient Sosarian Laser Gun. It turns to ash in your fingers", NULL, "lasergun", // lol, where'd that come from?
+ "the sulfury remains of an ancient Sosarian Laser Gun. It turns to ash in your fingers", nullptr, "lasergun", // lol, where'd that come from?
//Looks like someone was experimenting with "maps.xml". It effectively increments sulfur ash by one due to '16' being an invalid weapon index.
- &isWeaponInInventory, &putWeaponInInventory, NULL, 16, 0
+ &isWeaponInInventory, &putWeaponInInventory, nullptr, 16, 0
},
{
- "the rune of Honesty", NULL, "honestyrune",
- &isRuneInInventory, &putRuneInInventory, NULL, RUNE_HONESTY, 0
+ "the rune of Honesty", nullptr, "honestyrune",
+ &isRuneInInventory, &putRuneInInventory, nullptr, RUNE_HONESTY, 0
},
{
- "the rune of Compassion", NULL, "compassionrune",
- &isRuneInInventory, &putRuneInInventory, NULL, RUNE_COMPASSION, 0
+ "the rune of Compassion", nullptr, "compassionrune",
+ &isRuneInInventory, &putRuneInInventory, nullptr, RUNE_COMPASSION, 0
},
{
- "the rune of Valor", NULL, "valorrune",
- &isRuneInInventory, &putRuneInInventory, NULL, RUNE_VALOR, 0
+ "the rune of Valor", nullptr, "valorrune",
+ &isRuneInInventory, &putRuneInInventory, nullptr, RUNE_VALOR, 0
},
{
- "the rune of Justice", NULL, "justicerune",
- &isRuneInInventory, &putRuneInInventory, NULL, RUNE_JUSTICE, 0
+ "the rune of Justice", nullptr, "justicerune",
+ &isRuneInInventory, &putRuneInInventory, nullptr, RUNE_JUSTICE, 0
},
{
- "the rune of Sacrifice", NULL, "sacrificerune",
- &isRuneInInventory, &putRuneInInventory, NULL, RUNE_SACRIFICE, 0
+ "the rune of Sacrifice", nullptr, "sacrificerune",
+ &isRuneInInventory, &putRuneInInventory, nullptr, RUNE_SACRIFICE, 0
},
{
- "the rune of Honor", NULL, "honorrune",
- &isRuneInInventory, &putRuneInInventory, NULL, RUNE_HONOR, 0
+ "the rune of Honor", nullptr, "honorrune",
+ &isRuneInInventory, &putRuneInInventory, nullptr, RUNE_HONOR, 0
},
{
- "the rune of Spirituality", NULL, "spiritualityrune",
- &isRuneInInventory, &putRuneInInventory, NULL, RUNE_SPIRITUALITY, 0
+ "the rune of Spirituality", nullptr, "spiritualityrune",
+ &isRuneInInventory, &putRuneInInventory, nullptr, RUNE_SPIRITUALITY, 0
},
{
- "the rune of Humility", NULL, "humilityrune",
- &isRuneInInventory, &putRuneInInventory, NULL, RUNE_HUMILITY, 0
+ "the rune of Humility", nullptr, "humilityrune",
+ &isRuneInInventory, &putRuneInInventory, nullptr, RUNE_HUMILITY, 0
}
};
@@ -448,12 +448,12 @@ void useSkull(int item) {
*/
void useStone(int item) {
MapCoords coords;
- unsigned char stone = static_cast<unsigned char>(item);
+ byte stone = static_cast<byte>(item);
- static unsigned char truth = STONE_WHITE | STONE_PURPLE | STONE_GREEN | STONE_BLUE;
- static unsigned char love = STONE_WHITE | STONE_YELLOW | STONE_GREEN | STONE_ORANGE;
- static unsigned char courage = STONE_WHITE | STONE_RED | STONE_PURPLE | STONE_ORANGE;
- static unsigned char *attr = NULL;
+ static byte truth = STONE_WHITE | STONE_PURPLE | STONE_GREEN | STONE_BLUE;
+ static byte love = STONE_WHITE | STONE_YELLOW | STONE_GREEN | STONE_ORANGE;
+ static byte courage = STONE_WHITE | STONE_RED | STONE_PURPLE | STONE_ORANGE;
+ static byte *attr = nullptr;
g_context->_location->getCurrentPosition(&coords);
@@ -677,7 +677,7 @@ void useTelescope(int notused) {
if (choice == -1)
return;
- gamePeerCity(choice, NULL);
+ gamePeerCity(choice, nullptr);
}
bool isReagentInInventory(int reag) {
@@ -698,7 +698,7 @@ void putReagentInInventory(int reag) {
/**
* Returns true if the specified conditions are met to be able to get the item
*/
-bool itemConditionsMet(unsigned char conditions) {
+bool itemConditionsMet(byte conditions) {
int i;
if ((conditions & SC_NEWMOONS) &&
@@ -720,7 +720,7 @@ bool itemConditionsMet(unsigned char conditions) {
}
const ItemLocation *itemAtLocation(const Map *map, const Coords &coords) {
- unsigned int i;
+ uint i;
for (i = 0; i < N_ITEMS; i++) {
if (!ITEMS[i]._locationLabel)
continue;
@@ -728,12 +728,12 @@ const ItemLocation *itemAtLocation(const Map *map, const Coords &coords) {
itemConditionsMet(ITEMS[i]._conditions))
return &(ITEMS[i]);
}
- return NULL;
+ return nullptr;
}
void itemUse(const Common::String &shortname) {
- unsigned int i;
- const ItemLocation *item = NULL;
+ uint i;
+ const ItemLocation *item = nullptr;
for (i = 0; i < N_ITEMS; i++) {
if (ITEMS[i]._shortName &&
diff --git a/engines/ultima/ultima4/game/item.h b/engines/ultima/ultima4/game/item.h
index d998861351..6a23c3be64 100644
--- a/engines/ultima/ultima4/game/item.h
+++ b/engines/ultima/ultima4/game/item.h
@@ -47,16 +47,16 @@ struct ItemLocation {
void (*_putItemInInventory)(int item);
void (*_useItem)(int item);
int _data;
- unsigned char _conditions;
+ byte _conditions;
};
-typedef void (*DestroyAllCreaturesCallback)(void);
+typedef void (*DestroyAllCreaturesCallback)();
void itemSetDestroyAllCreaturesCallback(DestroyAllCreaturesCallback callback);
/**
* Returns an item location record if a searchable object exists at
- * the given location. NULL is returned if nothing is there.
+ * the given location. nullptr is returned if nothing is there.
*/
const ItemLocation *itemAtLocation(const Map *map, const Coords &coords);
diff --git a/engines/ultima/ultima4/game/menu.cpp b/engines/ultima/ultima4/game/menu.cpp
index 597647ec02..25af36fb68 100644
--- a/engines/ultima/ultima4/game/menu.cpp
+++ b/engines/ultima/ultima4/game/menu.cpp
@@ -222,7 +222,7 @@ MenuItem *Menu::getItemById(int id) {
_current = getById(id);
if (_current != _items.end())
return *_current;
- return NULL;
+ return nullptr;
}
void Menu::activateItem(int id, MenuEvent::Type action) {
diff --git a/engines/ultima/ultima4/game/menu.h b/engines/ultima/ultima4/game/menu.h
index be7df79d0a..6db6e388a7 100644
--- a/engines/ultima/ultima4/game/menu.h
+++ b/engines/ultima/ultima4/game/menu.h
@@ -45,7 +45,7 @@ public:
RESET
};
- MenuEvent(const Menu *menu, Type type, const MenuItem *item = NULL) {
+ MenuEvent(const Menu *menu, Type type, const MenuItem *item = nullptr) {
this->_menu = menu;
this->_type = type;
this->_item = item;
diff --git a/engines/ultima/ultima4/game/moongate.cpp b/engines/ultima/ultima4/game/moongate.cpp
index fb79083aa8..373e70c238 100644
--- a/engines/ultima/ultima4/game/moongate.cpp
+++ b/engines/ultima/ultima4/game/moongate.cpp
@@ -46,7 +46,7 @@ const Coords *moongateGetGateCoordsForPhase(int phase) {
moongate = gates.find(phase);
if (moongate != gates.end())
return &moongate->_value;
- return NULL;
+ return nullptr;
}
bool moongateFindActiveGateAt(int trammel, int felucca, const Coords &src, Coords &dest) {
diff --git a/engines/ultima/ultima4/game/object.cpp b/engines/ultima/ultima4/game/object.cpp
index 2e9f63124f..6e112263b4 100644
--- a/engines/ultima/ultima4/game/object.cpp
+++ b/engines/ultima/ultima4/game/object.cpp
@@ -42,13 +42,13 @@ void Object::setMap(class Map *m) {
Map *Object::getMap() {
if (_maps.empty())
- return NULL;
+ return nullptr;
return _maps.back();
}
void Object::remove() {
- unsigned int size = _maps.size();
- for (unsigned int i = 0; i < size; i++) {
+ uint size = _maps.size();
+ for (uint i = 0; i < size; i++) {
if (i == size - 1)
_maps[i]->removeObject(this);
else _maps[i]->removeObject(this, false);
diff --git a/engines/ultima/ultima4/game/person.cpp b/engines/ultima/ultima4/game/person.cpp
index 3236a2c9e3..3ea5209ffa 100644
--- a/engines/ultima/ultima4/game/person.cpp
+++ b/engines/ultima/ultima4/game/person.cpp
@@ -55,7 +55,7 @@ int chars_needed(const char *s, int columnmax, int linesdesired, int *real_lines
*/
bool isPerson(Object *punknown) {
Person *p;
- if ((p = dynamic_cast<Person *>(punknown)) != NULL)
+ if ((p = dynamic_cast<Person *>(punknown)) != nullptr)
return true;
else
return false;
@@ -73,10 +73,10 @@ Common::List<Common::String> replySplit(const Common::String &text) {
if ((pos = str.find("\n\n")) == 0)
str = str.substr(pos + 1);
- unsigned int num_chars = chars_needed(str.c_str(), TEXT_AREA_W, TEXT_AREA_H, &real_lines);
+ uint num_chars = chars_needed(str.c_str(), TEXT_AREA_W, TEXT_AREA_H, &real_lines);
/* we only have one chunk, no need to split it up */
- unsigned int len = str.size();
+ uint len = str.size();
if (num_chars == len)
reply.push_back(str);
else {
@@ -108,7 +108,7 @@ Common::List<Common::String> replySplit(const Common::String &text) {
Person::Person(MapTile tile) : Creature(tile), _start(0, 0) {
setType(Object::PERSON);
- _dialogue = NULL;
+ _dialogue = nullptr;
_npcType = NPC_EMPTY;
}
@@ -117,7 +117,7 @@ Person::Person(const Person *p) : Creature(p->_tile) {
}
bool Person::canConverse() const {
- return isVendor() || _dialogue != NULL;
+ return isVendor() || _dialogue != nullptr;
}
bool Person::isVendor() const {
@@ -151,7 +151,7 @@ void Person::setDialogue(Dialogue *d) {
void Person::setNpcType(PersonNpcType t) {
_npcType = t;
- ASSERT(!isVendor() || _dialogue == NULL, "vendor has dialogue");
+ ASSERT(!isVendor() || _dialogue == nullptr, "vendor has dialogue");
}
Common::List<Common::String> Person::getConversationText(Conversation *cnv, const char *inquiry) {
@@ -330,7 +330,7 @@ const char *Person::getChoices(Conversation *cnv) {
error("invalid state: %d", cnv->_state);
}
- return NULL;
+ return nullptr;
}
Common::String Person::getIntro(Conversation *cnv) {
@@ -476,7 +476,7 @@ Common::String Person::talkerGetQuestionResponse(Conversation *cnv, const char *
Common::String Person::beggarGetQuantityResponse(Conversation *cnv, const char *response) {
Common::String reply;
- cnv->_quant = (int) strtol(response, NULL, 10);
+ cnv->_quant = (int) strtol(response, nullptr, 10);
cnv->_state = Conversation::TALK;
if (cnv->_quant > 0) {
@@ -572,7 +572,7 @@ int chars_needed(const char *s, int columnmax, int linesdesired, int *real_lines
// try breaking text into paragraphs first
Common::String text = s;
Common::String paragraphs;
- unsigned int pos;
+ uint pos;
int lines = 0;
while ((pos = text.find("\n\n")) < text.size()) {
Common::String p = text.substr(0, pos);
diff --git a/engines/ultima/ultima4/game/player.cpp b/engines/ultima/ultima4/game/player.cpp
index d1a17c69ba..70b21e08a8 100644
--- a/engines/ultima/ultima4/game/player.cpp
+++ b/engines/ultima/ultima4/game/player.cpp
@@ -40,7 +40,7 @@ namespace Ultima4 {
bool isPartyMember(Object *punknown) {
PartyMember *pm;
- if ((pm = dynamic_cast<PartyMember *>(punknown)) != NULL)
+ if ((pm = dynamic_cast<PartyMember *>(punknown)) != nullptr)
return true;
else
return false;
@@ -508,7 +508,7 @@ void PartyMember::wakeUp() {
}
MapTile PartyMember::tileForClass(int klass) {
- const char *name = NULL;
+ const char *name = nullptr;
switch (klass) {
case CLASS_MAGE:
@@ -615,7 +615,7 @@ Common::String Party::translate(Std::vector<Common::String> &parts) {
size_t pos = str.findFirstOf("1234567890");
if (pos != Common::String::npos) {
str = str.substr(pos);
- int p_member = (int)strtol(str.c_str(), NULL, 10);
+ int p_member = (int)strtol(str.c_str(), nullptr, 10);
// Make the party member translate its own stuff
if (p_member > 0)
@@ -842,7 +842,7 @@ bool Party::canPersonJoin(Common::String name, Virtue *v) {
return false;
}
-void Party::damageShip(unsigned int pts) {
+void Party::damageShip(uint pts) {
_saveGame->_shipHull -= pts;
if ((short)_saveGame->_shipHull < 0)
_saveGame->_shipHull = 0;
@@ -926,7 +926,7 @@ int Party::getTorchDuration() const {
return _torchDuration;
}
-void Party::healShip(unsigned int pts) {
+void Party::healShip(uint pts) {
_saveGame->_shipHull += pts;
if (_saveGame->_shipHull > 50)
_saveGame->_shipHull = 50;
diff --git a/engines/ultima/ultima4/game/player.h b/engines/ultima/ultima4/game/player.h
index 6a3912d316..afc89f2ae1 100644
--- a/engines/ultima/ultima4/game/player.h
+++ b/engines/ultima/ultima4/game/player.h
@@ -337,7 +337,7 @@ public:
/**
* Damages the party's ship
*/
- void damageShip(unsigned int pts);
+ void damageShip(uint pts);
/**
* Donates 'quantity' gold. Returns true if the donation succeeded,
@@ -363,7 +363,7 @@ public:
/**
* Heals the ship's hull strength by 'pts' points
*/
- void healShip(unsigned int pts);
+ void healShip(uint pts);
/**
* Returns true if the balloon is currently in the air
diff --git a/engines/ultima/ultima4/game/portal.cpp b/engines/ultima/ultima4/game/portal.cpp
index ea3611e56c..2e3dd98f2a 100644
--- a/engines/ultima/ultima4/game/portal.cpp
+++ b/engines/ultima/ultima4/game/portal.cpp
@@ -45,9 +45,9 @@ void createDngLadder(Location *location, PortalTriggerAction action, Portal *p)
p->_destid = 1;
} else p->_exitPortal = false;
p->_message = "";
- p->_portalConditionsMet = NULL;
+ p->_portalConditionsMet = nullptr;
p->_portalTransportRequisites = TRANSPORT_FOOT_OR_HORSE;
- p->_retroActiveDest = NULL;
+ p->_retroActiveDest = nullptr;
p->_saveLocation = false;
p->_start = location->_coords;
p->_start.z += (action == ACTION_KLIMB) ? -1 : 1;
diff --git a/engines/ultima/ultima4/game/script.cpp b/engines/ultima/ultima4/game/script.cpp
index aa119b97e8..4c34a3152b 100644
--- a/engines/ultima/ultima4/game/script.cpp
+++ b/engines/ultima/ultima4/game/script.cpp
@@ -52,7 +52,7 @@ extern SpellEffectCallback spellEffectCallback;
*/
Script::Variable::Variable() : _iVal(0), _sVal(""), _set(false) {}
Script::Variable::Variable(const Common::String &v) : _set(true) {
- _iVal = static_cast<int>(strtol(v.c_str(), NULL, 10));
+ _iVal = static_cast<int>(strtol(v.c_str(), nullptr, 10));
_sVal = v;
}
@@ -100,7 +100,7 @@ bool Script::Variable::isSet() const {
*/
Script::ActionMap Script::_actionMap;
-Script::Script() : _vendorScriptDoc(NULL), _scriptNode(NULL), _debug(false), _state(STATE_UNLOADED),
+Script::Script() : _vendorScriptDoc(nullptr), _scriptNode(nullptr), _debug(false), _state(STATE_UNLOADED),
_nounName("item"), _idPropName("id") {
_actionMap["context"] = ACTION_SET_CONTEXT;
_actionMap["unset_context"] = ACTION_UNSET_CONTEXT;
@@ -186,8 +186,8 @@ bool Script::load(const Common::String &filename, const Common::String &baseId,
if (root->hasProperty("id_prop"))
_idPropName = root->getProperty("id_prop");
- _currentScript = NULL;
- _currentItem = NULL;
+ _currentScript = nullptr;
+ _currentItem = nullptr;
for (node = root->firstChild(); node; node = node->getNext()) {
if (node->nodeIsText() || !node->id().equalsIgnoreCase("script"))
@@ -256,7 +256,7 @@ bool Script::load(const Common::String &filename, const Common::String &baseId,
void Script::unload() {
if (_vendorScriptDoc) {
_vendorScriptDoc->freeDoc();
- _vendorScriptDoc = NULL;
+ _vendorScriptDoc = nullptr;
}
}
@@ -285,7 +285,7 @@ Script::ReturnCode Script::execute(Shared::XMLNode *script, Shared::XMLNode *cur
if (!script->hasChildren()) {
/* redirect the script to another node */
if (script->hasProperty("redirect"))
- retval = redirect(NULL, script);
+ retval = redirect(nullptr, script);
/* end the conversation */
else {
if (_debug)
@@ -503,7 +503,7 @@ int Script::getInputMaxLen() {
}
void Script::translate(Common::String *text) {
- unsigned int pos;
+ uint pos;
bool nochars = true;
Shared::XMLNode *node = _translationContext.back();
@@ -531,7 +531,7 @@ void Script::translate(Common::String *text) {
int total_pos = 0;
Common::String current = item;
while (true) {
- unsigned int open = current.findFirstOf("{"),
+ uint open = current.findFirstOf("{"),
close = current.findFirstOf("}");
if (close == current.size())
@@ -607,7 +607,7 @@ void Script::translate(Common::String *text) {
/* set translation context to nodePtr */
_translationContext.push_back(nodePtr);
- execute(itemShowScript, NULL, &prop);
+ execute(itemShowScript, nullptr, &prop);
_translationContext.pop_back();
_iterator++;
@@ -716,7 +716,7 @@ void Script::translate(Common::String *text) {
/* generate a random number */
else if (funcName == "random")
- prop = xu4_to_string(xu4_random((int)strtol(content.c_str(), NULL, 10)));
+ prop = xu4_to_string(xu4_random((int)strtol(content.c_str(), nullptr, 10)));
/* replaced with "true" if content is empty, or "false" if not */
else if (funcName == "isempty") {
@@ -769,7 +769,7 @@ Shared::XMLNode *Script::find(Shared::XMLNode *node, const Common::String &scrip
current = find(node, script_to_find, "", true);
return current;
}
- return NULL;
+ return nullptr;
}
Common::String Script::getPropAsStr(Std::list<Shared::XMLNode *> &nodes, const Common::String &prop, bool recursive) {
@@ -1389,8 +1389,8 @@ bool Script::mathParse(const Common::String &str, int *lval, int *rval, Common::
if (!Common::isDigit(left[0]) || !Common::isDigit(right[0]))
return false;
- *lval = (int)strtol(left.c_str(), NULL, 10);
- *rval = (int)strtol(right.c_str(), NULL, 10);
+ *lval = (int)strtol(left.c_str(), nullptr, 10);
+ *rval = (int)strtol(right.c_str(), nullptr, 10);
return true;
}
@@ -1423,7 +1423,7 @@ int Script::mathValue(const Common::String &str) {
/* something was invalid, just return the integer value */
if (!mathParse(str, &lval, &rval, &op))
- return (int)strtol(str.c_str(), NULL, 10);
+ return (int)strtol(str.c_str(), nullptr, 10);
else
return math(lval, rval, op);
}
@@ -1519,7 +1519,7 @@ bool Script::compare(const Common::String &statement) {
}
void Script::funcParse(const Common::String &str, Common::String *funcName, Common::String *contents) {
- unsigned int pos;
+ uint pos;
*funcName = str;
pos = funcName->findFirstOf("(");
diff --git a/engines/ultima/ultima4/game/script.h b/engines/ultima/ultima4/game/script.h
index 1937964658..37d0cfc5ef 100644
--- a/engines/ultima/ultima4/game/script.h
+++ b/engines/ultima/ultima4/game/script.h
@@ -181,7 +181,7 @@ public:
/**
* Executes the subscript 'script' of the main script
*/
- ReturnCode execute(Shared::XMLNode *script, Shared::XMLNode *currentItem = NULL, Common::String *output = NULL);
+ ReturnCode execute(Shared::XMLNode *script, Shared::XMLNode *currentItem = nullptr, Common::String *output = nullptr);
/**
* Continues the script from where it left off, or where the last script indicated
diff --git a/engines/ultima/ultima4/game/spell.cpp b/engines/ultima/ultima4/game/spell.cpp
index 4619dcc6da..4d4eededa2 100644
--- a/engines/ultima/ultima4/game/spell.cpp
+++ b/engines/ultima/ultima4/game/spell.cpp
@@ -45,7 +45,7 @@
namespace Ultima {
namespace Ultima4 {
-SpellEffectCallback spellEffectCallback = NULL;
+SpellEffectCallback spellEffectCallback = nullptr;
CombatController *spellCombatController();
void spellMagicAttack(const Common::String &tilename, Direction dir, int minDamage, int maxDamage);
@@ -208,32 +208,32 @@ void Ingredients::multiply(int batches) {
}
}
-const char *spellGetName(unsigned int spell) {
+const char *spellGetName(uint spell) {
ASSERT(spell < N_SPELLS, "invalid spell: %d", spell);
return spells[spell]._name;
}
-int spellGetRequiredMP(unsigned int spell) {
+int spellGetRequiredMP(uint spell) {
ASSERT(spell < N_SPELLS, "invalid spell: %d", spell);
return spells[spell]._mp;
}
-LocationContext spellGetContext(unsigned int spell) {
+LocationContext spellGetContext(uint spell) {
ASSERT(spell < N_SPELLS, "invalid spell: %d", spell);
return spells[spell]._context;
}
-TransportContext spellGetTransportContext(unsigned int spell) {
+TransportContext spellGetTransportContext(uint spell) {
ASSERT(spell < N_SPELLS, "invalid spell: %d", spell);
return spells[spell]._transportContext;
}
-Common::String spellGetErrorMessage(unsigned int spell, SpellCastError error) {
- unsigned int i;
+Common::String spellGetErrorMessage(uint spell, SpellCastError error) {
+ uint i;
SpellCastError err = error;
/* try to find a more specific error message */
@@ -266,7 +266,7 @@ Common::String spellGetErrorMessage(unsigned int spell, SpellCastError error) {
* Mix reagents for a spell. Fails and returns false if the reagents
* selected were not correct.
*/
-int spellMix(unsigned int spell, const Ingredients *ingredients) {
+int spellMix(uint spell, const Ingredients *ingredients) {
int regmask, reg;
ASSERT(spell < N_SPELLS, "invalid spell: %d", spell);
@@ -285,7 +285,7 @@ int spellMix(unsigned int spell, const Ingredients *ingredients) {
return 1;
}
-Spell::Param spellGetParamType(unsigned int spell) {
+Spell::Param spellGetParamType(uint spell) {
ASSERT(spell < N_SPELLS, "invalid spell: %d", spell);
return spells[spell]._paramType;
@@ -296,7 +296,7 @@ Spell::Param spellGetParamType(unsigned int spell) {
* error if no mixture is available, the context is invalid, or the
* character doesn't have enough magic points.
*/
-SpellCastError spellCheckPrerequisites(unsigned int spell, int character) {
+SpellCastError spellCheckPrerequisites(uint spell, int character) {
ASSERT(spell < N_SPELLS, "invalid spell: %d", spell);
ASSERT(character >= 0 && character < g_ultima->_saveGame->_members, "character out of range: %d", character);
@@ -319,7 +319,7 @@ SpellCastError spellCheckPrerequisites(unsigned int spell, int character) {
* Casts spell. Fails and returns false if the spell cannot be cast.
* The error code is updated with the reason for failure.
*/
-bool spellCast(unsigned int spell, int character, int param, SpellCastError *error, bool spellEffect) {
+bool spellCast(uint spell, int character, int param, SpellCastError *error, bool spellEffect) {
int subject = (spells[spell]._paramType == Spell::PARAM_PLAYER) ? param : -1;
PartyMember *p = g_context->_party->member(character);
diff --git a/engines/ultima/ultima4/game/spell.h b/engines/ultima/ultima4/game/spell.h
index 6cc75e10b3..231e19ab26 100644
--- a/engines/ultima/ultima4/game/spell.h
+++ b/engines/ultima/ultima4/game/spell.h
@@ -98,15 +98,15 @@ struct Spell {
typedef void (*SpellEffectCallback)(int spell, int player, Sound sound);
void spellSetEffectCallback(SpellEffectCallback callback);
-const char *spellGetName(unsigned int spell);
-int spellGetRequiredMP(unsigned int spell);
-LocationContext spellGetContext(unsigned int spell);
-TransportContext spellGetTransportContext(unsigned int spell);
-Common::String spellGetErrorMessage(unsigned int spell, SpellCastError error);
-int spellMix(unsigned int spell, const Ingredients *ingredients);
-Spell::Param spellGetParamType(unsigned int spell);
-SpellCastError spellCheckPrerequisites(unsigned int spell, int character);
-bool spellCast(unsigned int spell, int character, int param, SpellCastError *error, bool spellEffect);
+const char *spellGetName(uint spell);
+int spellGetRequiredMP(uint spell);
+LocationContext spellGetContext(uint spell);
+TransportContext spellGetTransportContext(uint spell);
+Common::String spellGetErrorMessage(uint spell, SpellCastError error);
+int spellMix(uint spell, const Ingredients *ingredients);
+Spell::Param spellGetParamType(uint spell);
+SpellCastError spellCheckPrerequisites(uint spell, int character);
+bool spellCast(uint spell, int character, int param, SpellCastError *error, bool spellEffect);
const Spell *getSpell(int i);
} // End of namespace Ultima4
diff --git a/engines/ultima/ultima4/game/stats.cpp b/engines/ultima/ultima4/game/stats.cpp
index a107d1e6d3..ec11b74715 100644
--- a/engines/ultima/ultima4/game/stats.cpp
+++ b/engines/ultima/ultima4/game/stats.cpp
@@ -141,7 +141,7 @@ void StatsArea::update(Aura *observable, NoArg *arg) {
}
void StatsArea::update(Aura *aura) {
- unsigned char mask = 0xff;
+ byte mask = 0xff;
for (int i = 0; i < VIRT_MAX; i++) {
if (g_ultima->_saveGame->_karma[i] == 0)
mask &= ~(1 << i);
@@ -209,7 +209,7 @@ void StatsArea::setTitle(const Common::String &s) {
void StatsArea::showPartyView(bool avatarOnly) {
const char *format = "%d%c%-9.8s%3d%s";
- PartyMember *p = NULL;
+ PartyMember *p = nullptr;
int activePlayer = g_context->_party->getActivePlayer();
ASSERT(g_context->_party->size() <= 8, "party members out of range: %d", g_context->_party->size());
diff --git a/engines/ultima/ultima4/game/textview.cpp b/engines/ultima/ultima4/game/textview.cpp
index 95e780ef21..06af97fee9 100644
--- a/engines/ultima/ultima4/game/textview.cpp
+++ b/engines/ultima/ultima4/game/textview.cpp
@@ -30,7 +30,7 @@
namespace Ultima {
namespace Ultima4 {
-Image *TextView::_charset = NULL;
+Image *TextView::_charset = nullptr;
TextView::TextView(int x, int y, int columns, int rows) : View(x, y, columns * CHAR_WIDTH, rows * CHAR_HEIGHT) {
this->_columns = columns;
@@ -40,7 +40,7 @@ TextView::TextView(int x, int y, int columns, int rows) : View(x, y, columns * C
this->_cursorX = 0;
this->_cursorY = 0;
this->_cursorPhase = 0;
- if (_charset == NULL)
+ if (_charset == nullptr)
_charset = imageMgr->get(BKGD_CHARSET)->_image;
eventHandler->getTimer()->add(&cursorTimer, /*SCR_CYCLE_PER_SECOND*/4, this);
}
@@ -65,7 +65,7 @@ void TextView::drawChar(int chr, int x, int y) {
SCALED(CHAR_HEIGHT));
}
-void TextView::drawCharMasked(int chr, int x, int y, unsigned char mask) {
+void TextView::drawCharMasked(int chr, int x, int y, byte mask) {
drawChar(chr, x, y);
for (int i = 0; i < 8; i++) {
if (mask & (1 << i)) {
@@ -118,7 +118,7 @@ Common::String TextView::colorizeStatus(char statustype) {
return output;
}
-Common::String TextView::colorizeString(Common::String input, ColorFG color, unsigned int colorstart, unsigned int colorlength) {
+Common::String TextView::colorizeString(Common::String input, ColorFG color, uint colorstart, uint colorlength) {
if (!settings._enhancements || !settings._enhancementsOptions._textColorization)
return input;
@@ -166,8 +166,8 @@ void TextView::setFontColorBG(ColorBG bg) {
void TextView::textAt(int x, int y, const char *fmt, ...) {
char buffer[1024];
- unsigned int i;
- unsigned int offset = 0;
+ uint i;
+ uint offset = 0;
bool reenableCursor = false;
if (_cursorFollowsText && _cursorEnabled) {
diff --git a/engines/ultima/ultima4/game/textview.h b/engines/ultima/ultima4/game/textview.h
index f9feb17fce..5649e976c7 100644
--- a/engines/ultima/ultima4/game/textview.h
+++ b/engines/ultima/ultima4/game/textview.h
@@ -68,7 +68,7 @@ public:
* statistics area, where a line is masked out for each virtue in
* which the player is not an avatar.
*/
- void drawCharMasked(int chr, int x, int y, unsigned char mask);
+ void drawCharMasked(int chr, int x, int y, byte mask);
void textAt(int x, int y, const char *fmt, ...) PRINTF_LIKE(4, 5);
void scroll();
@@ -100,7 +100,7 @@ public:
/**
* Depending on the status type, apply colorization to the character
*/
- Common::String colorizeString(Common::String input, ColorFG color, unsigned int colorstart, unsigned int colorlength = 0);
+ Common::String colorizeString(Common::String input, ColorFG color, uint colorstart, uint colorlength = 0);
protected:
int _columns, _rows; /**< size of the view in character cells */
diff --git a/engines/ultima/ultima4/game/view.cpp b/engines/ultima/ultima4/game/view.cpp
index 3429aea0af..e798ed68b4 100644
--- a/engines/ultima/ultima4/game/view.cpp
+++ b/engines/ultima/ultima4/game/view.cpp
@@ -28,11 +28,11 @@
namespace Ultima {
namespace Ultima4 {
-Image *View::_screen = NULL;
+Image *View::_screen = nullptr;
View::View(int x, int y, int width, int height) : _x(x), _y(y), _width(width), _height(height),
_highlighted(false), _highlightX(0), _highlightY(0), _highlightW(0), _highlightH(0) {
- if (_screen == NULL)
+ if (_screen == nullptr)
_screen = imageMgr->get("screen")->_image;
}
diff --git a/engines/ultima/ultima4/game/weapon.cpp b/engines/ultima/ultima4/game/weapon.cpp
index d9c84a3c32..da4c53f34c 100644
--- a/engines/ultima/ultima4/game/weapon.cpp
+++ b/engines/ultima/ultima4/game/weapon.cpp
@@ -36,7 +36,7 @@ const Weapon *Weapon::get(WeaponType w) {
loadConf();
if (static_cast<unsigned>(w) >= _weapons.size())
- return NULL;
+ return nullptr;
return _weapons[w];
}
@@ -48,7 +48,7 @@ const Weapon *Weapon::get(const Common::String &name) {
if (scumm_stricmp(name.c_str(), _weapons[i]->_name.c_str()) == 0)
return _weapons[i];
}
- return NULL;
+ return nullptr;
}
Weapon::Weapon(const ConfigElement &conf)
@@ -64,7 +64,7 @@ Weapon::Weapon(const ConfigElement &conf)
, _flags(0) {
static const struct {
const char *name;
- unsigned int flag;
+ uint flag;
} booleanAttributes[] = {
{ "lose", WEAP_LOSE },
{ "losewhenranged", WEAP_LOSEWHENRANGED },
@@ -110,7 +110,7 @@ Weapon::Weapon(const ConfigElement &conf)
Std::vector<ConfigElement> contraintConfs = conf.getChildren();
for (Std::vector<ConfigElement>::iterator i = contraintConfs.begin(); i != contraintConfs.end(); i++) {
- unsigned char mask = 0;
+ byte mask = 0;
if (i->getName() != "constraint")
continue;
diff --git a/engines/ultima/ultima4/gfx/image.cpp b/engines/ultima/ultima4/gfx/image.cpp
index 93b761c345..54f1875d72 100644
--- a/engines/ultima/ultima4/gfx/image.cpp
+++ b/engines/ultima/ultima4/gfx/image.cpp
@@ -207,7 +207,7 @@ bool Image::setFontColorBG(ColorBG bg) {
return true;
}
-bool Image::setPaletteIndex(unsigned int index, RGBA color) {
+bool Image::setPaletteIndex(uint index, RGBA color) {
if (!_paletted)
return false;
@@ -218,7 +218,7 @@ bool Image::setPaletteIndex(unsigned int index, RGBA color) {
return true;
}
-bool Image::getTransparentIndex(unsigned int &index) const {
+bool Image::getTransparentIndex(uint &index) const {
if (!_paletted || !_surface->hasTransparentColor())
return false;
@@ -280,24 +280,24 @@ void Image::makeBackgroundColorTransparent(int haloSize, int shadowOpacity) {
}
//TODO Separate functionalities found in here
-void Image::performTransparencyHack(unsigned int colorValue, unsigned int numFrames,
- unsigned int currentFrameIndex, unsigned int haloWidth,
- unsigned int haloOpacityIncrementByPixelDistance) {
- Common::List<Std::pair<unsigned int, unsigned int> > opaqueXYs;
- unsigned int x, y;
+void Image::performTransparencyHack(uint colorValue, uint numFrames,
+ uint currentFrameIndex, uint haloWidth,
+ uint haloOpacityIncrementByPixelDistance) {
+ Common::List<Std::pair<uint, uint> > opaqueXYs;
+ uint x, y;
byte t_r, t_g, t_b;
_surface->format.colorToRGB(colorValue, t_r, t_g, t_b);
- unsigned int frameHeight = _surface->h / numFrames;
+ uint frameHeight = _surface->h / numFrames;
//Min'd so that they never go out of range (>=h)
- unsigned int top = MIN(_surface->h, (uint16)(currentFrameIndex * frameHeight));
- unsigned int bottom = MIN(_surface->h, (uint16)(top + frameHeight));
+ uint top = MIN(_surface->h, (uint16)(currentFrameIndex * frameHeight));
+ uint bottom = MIN(_surface->h, (uint16)(top + frameHeight));
for (y = top; y < bottom; y++) {
for (x = 0; x < _surface->w; x++) {
- unsigned int r, g, b, a;
+ uint r, g, b, a;
getPixel(x, y, r, g, b, a);
if (r == t_r &&
g == t_g &&
@@ -306,27 +306,27 @@ void Image::performTransparencyHack(unsigned int colorValue, unsigned int numFra
} else {
putPixel(x, y, r, g, b, a);
if (haloWidth)
- opaqueXYs.push_back(Std::pair<unsigned int, unsigned int>(x, y));
+ opaqueXYs.push_back(Std::pair<uint, uint>(x, y));
}
}
}
int ox, oy;
- for (Common::List<Std::pair<unsigned int, unsigned int> >::iterator xy = opaqueXYs.begin();
+ for (Common::List<Std::pair<uint, uint> >::iterator xy = opaqueXYs.begin();
xy != opaqueXYs.end();
++xy) {
ox = xy->first;
oy = xy->second;
int span = int(haloWidth);
- unsigned int x_start = MAX(0, ox - span);
- unsigned int x_finish = MIN(int(_surface->w), ox + span + 1);
+ uint x_start = MAX(0, ox - span);
+ uint x_finish = MIN(int(_surface->w), ox + span + 1);
for (x = x_start; x < x_finish; ++x) {
- unsigned int y_start = MAX(int(top), oy - span);
- unsigned int y_finish = MIN(int(bottom), oy + span + 1);
+ uint y_start = MAX(int(top), oy - span);
+ uint y_finish = MIN(int(bottom), oy + span + 1);
for (y = y_start; y < y_finish; ++y) {
int divisor = 1 + span * 2 - abs(int(ox - x)) - abs(int(oy - y));
- unsigned int r, g, b, a;
+ uint r, g, b, a;
getPixel(x, y, r, g, b, a);
if (a != IM_OPAQUE) {
putPixel(x, y, r, g, b, MIN(IM_OPAQUE, a + haloOpacityIncrementByPixelDistance / divisor));
@@ -338,12 +338,12 @@ void Image::performTransparencyHack(unsigned int colorValue, unsigned int numFra
}
-void Image::setTransparentIndex(unsigned int index) {
+void Image::setTransparentIndex(uint index) {
if (_paletted)
_surface->setTransparentColor(index);
}
-void Image::putPixelIndex(int x, int y, unsigned int index) {
+void Image::putPixelIndex(int x, int y, uint index) {
int bpp;
byte *p;
@@ -373,8 +373,8 @@ void Image::fillRect(int x, int y, int w, int h, int r, int g, int b, int a) {
_surface->fillRect(Common::Rect(x, y, x + w, y + h), color);
}
-void Image::getPixel(int x, int y, unsigned int &r, unsigned int &g, unsigned int &b, unsigned int &a) const {
- unsigned int index;
+void Image::getPixel(int x, int y, uint &r, uint &g, uint &b, uint &a) const {
+ uint index;
byte r1, g1, b1, a1;
getPixelIndex(x, y, index);
@@ -394,7 +394,7 @@ void Image::getPixel(int x, int y, unsigned int &r, unsigned int &g, unsigned in
}
}
-void Image::getPixelIndex(int x, int y, unsigned int &index) const {
+void Image::getPixelIndex(int x, int y, uint &index) const {
int bpp = _surface->format.bytesPerPixel;
byte *p = (byte *)_surface->getBasePtr(x, y);
diff --git a/engines/ultima/ultima4/gfx/image.h b/engines/ultima/ultima4/gfx/image.h
index 9b57d620e7..c08552a2ed 100644
--- a/engines/ultima/ultima4/gfx/image.h
+++ b/engines/ultima/ultima4/gfx/image.h
@@ -38,7 +38,7 @@ typedef Graphics::ManagedSurface *BackendSurface;
struct RGBA {
RGBA(int red, int green, int blue, int alpha) : r(red), g(green), b(blue), a(alpha) {}
RGBA() : r(0), g(0), b(0), a(255) {}
- unsigned int r, g, b, a;
+ uint r, g, b, a;
operator uint32() const {
return r | (g << 8) | (b << 16) | (0xff << 24);
@@ -54,7 +54,7 @@ struct SubImage {
int x, y, width, height;
};
-#define IM_OPAQUE (unsigned int) 255
+#define IM_OPAQUE (uint) 255
#define IM_TRANSPARENT 0
/**
@@ -122,9 +122,9 @@ public:
* Copies the palette from another image.
*/
void setPaletteFromImage(const Image *src);
- bool getTransparentIndex(unsigned int &index) const;
- void performTransparencyHack(unsigned int colorValue, unsigned int numFrames, unsigned int currentFrameIndex, unsigned int haloWidth, unsigned int haloOpacityIncrementByPixelDistance);
- void setTransparentIndex(unsigned int index);
+ bool getTransparentIndex(uint &index) const;
+ void performTransparencyHack(uint colorValue, uint numFrames, uint currentFrameIndex, uint haloWidth, uint haloOpacityIncrementByPixelDistance);
+ void setTransparentIndex(uint index);
/**
* Sets the specified font colors
@@ -149,7 +149,7 @@ public:
/**
* Sets the specified palette index to the specified RGB color
*/
- bool setPaletteIndex(unsigned int index, RGBA color);
+ bool setPaletteIndex(uint index, RGBA color);
/**
* Returns the palette index of the specified RGB color
@@ -170,7 +170,7 @@ public:
void makeBackgroundColorTransparent(int haloSize = 0, int shadowOpacity = 255);
- //void finalizeAlphaSurface(RGBA * key = NULL);
+ //void finalizeAlphaSurface(RGBA * key = nullptr);
/* writing to image */
@@ -184,7 +184,7 @@ public:
* indexed mode, then the index is simply the palette entry number.
* If the image is RGB, it is a packed RGB triplet.
*/
- void putPixelIndex(int x, int y, unsigned int index);
+ void putPixelIndex(int x, int y, uint index);
/**
* Fills a rectangle in the image with a given color.
@@ -197,21 +197,21 @@ public:
/**
* Gets the color of a single pixel.
*/
- void getPixel(int x, int y, unsigned int &r, unsigned int &g, unsigned int &b, unsigned int &a) const;
+ void getPixel(int x, int y, uint &r, uint &g, uint &b, uint &a) const;
/**
* Gets the palette index of a single pixel. If the image is in
* indexed mode, then the index is simply the palette entry number.
* If the image is RGB, it is a packed RGB triplet.
*/
- void getPixelIndex(int x, int y, unsigned int &index) const;
+ void getPixelIndex(int x, int y, uint &index) const;
/* image drawing methods */
/**
* Draws the entire image onto the screen at the given offset.
*/
void draw(int x, int y) const {
- drawOn(NULL, x, y);
+ drawOn(nullptr, x, y);
}
/**
@@ -220,7 +220,7 @@ public:
* rw, rh.
*/
void drawSubRect(int x, int y, int rx, int ry, int rw, int rh) const {
- drawSubRectOn(NULL, x, y, rx, ry, rw, rh);
+ drawSubRectOn(nullptr, x, y, rx, ry, rw, rh);
}
/**
@@ -229,7 +229,7 @@ public:
* rw, rh.
*/
void drawSubRectInverted(int x, int y, int rx, int ry, int rw, int rh) const {
- drawSubRectInvertedOn(NULL, x, y, rx, ry, rw, rh);
+ drawSubRectInvertedOn(nullptr, x, y, rx, ry, rw, rh);
}
/* image drawing methods for drawing onto another image instead of the screen */
diff --git a/engines/ultima/ultima4/gfx/imageloader_fmtowns.cpp b/engines/ultima/ultima4/gfx/imageloader_fmtowns.cpp
index feb98a898e..d8122f6bc2 100644
--- a/engines/ultima/ultima4/gfx/imageloader_fmtowns.cpp
+++ b/engines/ultima/ultima4/gfx/imageloader_fmtowns.cpp
@@ -42,7 +42,7 @@ Image *FMTOWNSImageLoader::load(U4FILE *file, int width, int height, int bpp) {
long rawLen = file->length() - _offset;
file->seek(_offset, 0);
- unsigned char *raw = (unsigned char *) malloc(rawLen);
+ byte *raw = (byte *) malloc(rawLen);
file->read(raw, 1, rawLen);
long requiredLength = (width * height * bpp / 8);
@@ -50,14 +50,14 @@ Image *FMTOWNSImageLoader::load(U4FILE *file, int width, int height, int bpp) {
if (raw)
free(raw);
errorWarning("FMTOWNS Image of size %d does not fit anticipated size %d", rawLen, requiredLength);
- return NULL;
+ return nullptr;
}
Image *image = Image::create(width, height, bpp <= 8, Image::HARDWARE);
if (!image) {
if (raw)
free(raw);
- return NULL;
+ return nullptr;
}
if (bpp == 4) {
@@ -66,7 +66,7 @@ Image *FMTOWNSImageLoader::load(U4FILE *file, int width, int height, int bpp) {
setFromRawData(image, width, height, bpp, raw);
// if (width % 2)
// errorFatal("FMTOWNS 4bit images cannot handle widths not divisible by 2!");
-// unsigned char nibble_mask = 0x0F;
+// byte nibble_mask = 0x0F;
// for (int y = 0; y < height; y++)
// {
// for (int x = 0; x < width; x+=2)
@@ -87,17 +87,17 @@ Image *FMTOWNSImageLoader::load(U4FILE *file, int width, int height, int bpp) {
//Masks
//------------------------ // 0000000011111111 --Byte 0 and 1
//------------------------ // RRRRRGGGGGBBBBB?
- unsigned char low5 = 0x1F; // 11111000-------- low5
- unsigned char high6 = (byte)~3U; // --------00111111 high6
- unsigned char high3 = (byte)~31U; // 00000111-------- high3
- unsigned char low2 = 3; // --------11000000 low2
- unsigned char lastbit = 128; // --------00000001 low2
+ byte low5 = 0x1F; // 11111000-------- low5
+ byte high6 = (byte)~3U; // --------00111111 high6
+ byte high3 = (byte)~31U; // 00000111-------- high3
+ byte low2 = 3; // --------11000000 low2
+ byte lastbit = 128; // --------00000001 low2
// Warning, this diagram is left-to-right, not standard right-to-left
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
- unsigned char byte0 = raw[(y * width + x) * 2];
- unsigned char byte1 = raw[(y * width + x) * 2 + 1];
+ byte byte0 = raw[(y * width + x) * 2];
+ byte byte1 = raw[(y * width + x) * 2 + 1];
int r = (byte0 & low5);
r <<= 3;
diff --git a/engines/ultima/ultima4/gfx/imageloader_u4.cpp b/engines/ultima/ultima4/gfx/imageloader_u4.cpp
index 9230b57424..723289363f 100644
--- a/engines/ultima/ultima4/gfx/imageloader_u4.cpp
+++ b/engines/ultima/ultima4/gfx/imageloader_u4.cpp
@@ -34,9 +34,9 @@ namespace Ultima4 {
using Std::vector;
-RGBA *U4PaletteLoader::_bwPalette = NULL;
-RGBA *U4PaletteLoader::_egaPalette = NULL;
-RGBA *U4PaletteLoader::_vgaPalette = NULL;
+RGBA *U4PaletteLoader::_bwPalette = nullptr;
+RGBA *U4PaletteLoader::_egaPalette = nullptr;
+RGBA *U4PaletteLoader::_vgaPalette = nullptr;
Image *U4RawImageLoader::load(U4FILE *file, int width, int height, int bpp) {
if (width == -1 || height == -1 || bpp == -1) {
@@ -46,7 +46,7 @@ Image *U4RawImageLoader::load(U4FILE *file, int width, int height, int bpp) {
ASSERT(bpp == 1 || bpp == 4 || bpp == 8 || bpp == 24 || bpp == 32, "invalid bpp: %d", bpp);
long rawLen = file->length();
- unsigned char *raw = (unsigned char *) malloc(rawLen);
+ byte *raw = (byte *) malloc(rawLen);
file->read(raw, 1, rawLen);
long requiredLength = (width * height * bpp / 8);
@@ -54,14 +54,14 @@ Image *U4RawImageLoader::load(U4FILE *file, int width, int height, int bpp) {
if (raw)
free(raw);
errorWarning("u4Raw Image of size %ld does not fit anticipated size %ld", rawLen, requiredLength);
- return NULL;
+ return nullptr;
}
Image *image = Image::create(width, height, bpp <= 8, Image::HARDWARE);
if (!image) {
if (raw)
free(raw);
- return NULL;
+ return nullptr;
}
U4PaletteLoader paletteLoader;
@@ -91,24 +91,24 @@ Image *U4RleImageLoader::load(U4FILE *file, int width, int height, int bpp) {
ASSERT(bpp == 1 || bpp == 4 || bpp == 8 || bpp == 24 || bpp == 32, "invalid bpp: %d", bpp);
long compressedLen = file->length();
- unsigned char *compressed = (unsigned char *) malloc(compressedLen);
+ byte *compressed = (byte *) malloc(compressedLen);
file->read(compressed, 1, compressedLen);
- unsigned char *raw = NULL;
+ byte *raw = nullptr;
long rawLen = rleDecompressMemory(compressed, compressedLen, (void **) &raw);
free(compressed);
if (rawLen != (width * height * bpp / 8)) {
if (raw)
free(raw);
- return NULL;
+ return nullptr;
}
Image *image = Image::create(width, height, bpp <= 8, Image::HARDWARE);
if (!image) {
if (raw)
free(raw);
- return NULL;
+ return nullptr;
}
U4PaletteLoader paletteLoader;
@@ -138,24 +138,24 @@ Image *U4LzwImageLoader::load(U4FILE *file, int width, int height, int bpp) {
ASSERT(bpp == 1 || bpp == 4 || bpp == 8 || bpp == 24 || bpp == 32, "invalid bpp: %d", bpp);
long compressedLen = file->length();
- unsigned char *compressed = (unsigned char *) malloc(compressedLen);
+ byte *compressed = (byte *) malloc(compressedLen);
file->read(compressed, 1, compressedLen);
- unsigned char *raw = NULL;
+ byte *raw = nullptr;
long rawLen = LZW::decompress_u4_memory(compressed, compressedLen, (void **) &raw);
free(compressed);
if (rawLen != (width * height * bpp / 8)) {
if (raw)
free(raw);
- return NULL;
+ return nullptr;
}
Image *image = Image::create(width, height, bpp <= 8, Image::HARDWARE);
if (!image) {
if (raw)
free(raw);
- return NULL;
+ return nullptr;
}
U4PaletteLoader paletteLoader;
@@ -177,7 +177,7 @@ Image *U4LzwImageLoader::load(U4FILE *file, int width, int height, int bpp) {
* Loads a simple black & white palette
*/
RGBA *U4PaletteLoader::loadBWPalette() {
- if (_bwPalette == NULL) {
+ if (_bwPalette == nullptr) {
_bwPalette = new RGBA[2];
_bwPalette[0].r = 0;
@@ -196,7 +196,7 @@ RGBA *U4PaletteLoader::loadBWPalette() {
* Loads the basic EGA palette from egaPalette.xml
*/
RGBA *U4PaletteLoader::loadEgaPalette() {
- if (_egaPalette == NULL) {
+ if (_egaPalette == nullptr) {
int index = 0;
const Config *config = Config::getInstance();
@@ -222,10 +222,10 @@ RGBA *U4PaletteLoader::loadEgaPalette() {
* Load the 256 color VGA palette from a file.
*/
RGBA *U4PaletteLoader::loadVgaPalette() {
- if (_vgaPalette == NULL) {
+ if (_vgaPalette == nullptr) {
U4FILE *pal = u4fopen("u4vga.pal");
if (!pal)
- return NULL;
+ return nullptr;
_vgaPalette = new RGBA[256];
diff --git a/engines/ultima/ultima4/gfx/imagemgr.cpp b/engines/ultima/ultima4/gfx/imagemgr.cpp
index 94796e4ce7..6644a3bb6e 100644
--- a/engines/ultima/ultima4/gfx/imagemgr.cpp
+++ b/engines/ultima/ultima4/gfx/imagemgr.cpp
@@ -52,10 +52,10 @@ public:
map<Common::String, ImageInfo *> _info;
};
-ImageMgr *ImageMgr::_instance = NULL;
+ImageMgr *ImageMgr::_instance = nullptr;
ImageMgr *ImageMgr::getInstance() {
- if (_instance == NULL) {
+ if (_instance == nullptr) {
_instance = new ImageMgr();
_instance->init();
}
@@ -63,9 +63,9 @@ ImageMgr *ImageMgr::getInstance() {
}
void ImageMgr::destroy() {
- if (_instance != NULL) {
+ if (_instance != nullptr) {
delete _instance;
- _instance = NULL;
+ _instance = nullptr;
}
}
@@ -146,7 +146,7 @@ ImageSet *ImageMgr::loadImageSetFromConf(const ConfigElement &conf) {
ImageInfo *ImageMgr::loadImageInfoFromConf(const ConfigElement &conf) {
ImageInfo *info;
- static const char *fixupEnumStrings[] = { "none", "intro", "abyss", "abacus", "dungns", "blackTransparencyHack", "fmtownsscreen", NULL };
+ static const char *fixupEnumStrings[] = { "none", "intro", "abyss", "abacus", "dungns", "blackTransparencyHack", "fmtownsscreen", nullptr };
info = new ImageInfo();
info->_name = conf.getString("name");
@@ -162,7 +162,7 @@ ImageInfo *ImageMgr::loadImageInfoFromConf(const ConfigElement &conf) {
info->_xu4Graphic = conf.getBool("xu4Graphic");
info->_fixup = static_cast<ImageFixup>(conf.getEnum("fixup", fixupEnumStrings));
- info->_image = NULL;
+ info->_image = nullptr;
vector<ConfigElement> children = conf.getChildren();
for (Std::vector<ConfigElement>::iterator i = children.begin(); i != children.end(); i++) {
@@ -210,7 +210,7 @@ SubImage *ImageMgr::loadSubImageFromConf(const ImageInfo *info, const ConfigElem
}
void ImageMgr::fixupIntro(Image *im, int prescale) {
- const unsigned char *sigData;
+ const byte *sigData;
int i, x, y;
bool alpha = im->isAlphaOn();
RGBA color;
@@ -331,7 +331,7 @@ void ImageMgr::fixupIntro(Image *im, int prescale) {
errorFatal("ERROR 1001: Unable to load the \"%s\" data file.\t\n\nIs %s installed?\n\nVisit the XU4 website for additional information.\n\thttp://xu4.sourceforge.net/", BKGD_BORDERS, settings._game.c_str());
delete borderInfo->_image;
- borderInfo->_image = NULL;
+ borderInfo->_image = nullptr;
borderInfo = imageMgr->get(BKGD_BORDERS, true);
im->setPaletteFromImage(borderInfo->_image);
@@ -356,7 +356,7 @@ void ImageMgr::fixupIntro(Image *im, int prescale) {
borderInfo->_image->alphaOn();
delete borderInfo->_image;
- borderInfo->_image = NULL;
+ borderInfo->_image = nullptr;
}
/* -----------------------------
@@ -399,28 +399,28 @@ void ImageMgr::fixupIntro(Image *im, int prescale) {
}
void ImageMgr::fixupAbyssVision(Image *im, int prescale) {
- static unsigned int *data = NULL;
+ static uint *data = nullptr;
/*
* Each VGA vision components must be XORed with all the previous
* vision components to get the actual image.
*/
- if (data != NULL) {
+ if (data != nullptr) {
for (int y = 0; y < im->height(); y++) {
for (int x = 0; x < im->width(); x++) {
- unsigned int index;
+ uint index;
im->getPixelIndex(x, y, index);
index ^= data[y * im->width() + x];
im->putPixelIndex(x, y, index);
}
}
} else {
- data = new unsigned int[im->width() * im->height()];
+ data = new uint[im->width() * im->height()];
}
for (int y = 0; y < im->height(); y++) {
for (int x = 0; x < im->width(); x++) {
- unsigned int index;
+ uint index;
im->getPixelIndex(x, y, index);
data[y * im->width() + x] = index;
}
@@ -448,7 +448,7 @@ void ImageMgr::fixupAbacus(Image *im, int prescale) {
void ImageMgr::fixupDungNS(Image *im, int prescale) {
for (int y = 0; y < im->height(); y++) {
for (int x = 0; x < im->width(); x++) {
- unsigned int index;
+ uint index;
im->getPixelIndex(x, y, index);
if (index == 1)
im->putPixelIndex(x, y, 2);
@@ -461,7 +461,7 @@ void ImageMgr::fixupDungNS(Image *im, int prescale) {
void ImageMgr::fixupFMTowns(Image *im, int prescale) {
for (int y = 20; y < im->height(); y++) {
for (int x = 0; x < im->width(); x++) {
- unsigned int index;
+ uint index;
im->getPixelIndex(x, y, index);
im->putPixelIndex(x, y - 20, index);
}
@@ -473,7 +473,7 @@ ImageSet *ImageMgr::getSet(const Common::String &setname) {
if (i != _imageSets.end())
return i->_value;
else
- return NULL;
+ return nullptr;
}
ImageInfo *ImageMgr::getInfo(const Common::String &name) {
@@ -482,7 +482,7 @@ ImageInfo *ImageMgr::getInfo(const Common::String &name) {
ImageInfo *ImageMgr::getInfoFromSet(const Common::String &name, ImageSet *imageset) {
if (!imageset)
- return NULL;
+ return nullptr;
/* if the image set contains the image we want, AND IT EXISTS we are done */
Std::map<Common::String, ImageInfo *>::iterator i = imageset->_info.find(name);
@@ -497,7 +497,7 @@ ImageInfo *ImageMgr::getInfoFromSet(const Common::String &name, ImageSet *images
}
//errorWarning("Searched recursively from imageset %s through to %s and couldn't find %s", baseSet->name.c_str(), imageset->name.c_str(), name.c_str());
- return NULL;
+ return nullptr;
}
Common::String ImageMgr::guessFileType(const Common::String &filename) {
@@ -538,9 +538,9 @@ U4FILE *ImageMgr::getImageFile(ImageInfo *info) {
}
if (filename == "")
- return NULL;
+ return nullptr;
- U4FILE *file = NULL;
+ U4FILE *file = nullptr;
if (info->_xu4Graphic) {
Common::String pathname(u4find_graphics(filename));
@@ -556,20 +556,20 @@ U4FILE *ImageMgr::getImageFile(ImageInfo *info) {
ImageInfo *ImageMgr::get(const Common::String &name, bool returnUnscaled) {
ImageInfo *info = getInfo(name);
if (!info)
- return NULL;
+ return nullptr;
/* return if already loaded */
- if (info->_image != NULL)
+ if (info->_image != nullptr)
return info;
U4FILE *file = getImageFile(info);
- Image *unscaled = NULL;
+ Image *unscaled = nullptr;
if (file) {
if (info->_filetype.empty())
info->_filetype = guessFileType(info->_filename);
Common::String filetype = info->_filetype;
ImageLoader *loader = g_ultima->_imageLoaders->getLoader(filetype);
- if (loader == NULL)
+ if (loader == nullptr)
errorWarning("can't find loader to load image \"%s\" with type \"%s\"", info->_filename.c_str(), filetype.c_str());
else {
unscaled = loader->load(file, info->_width, info->_height, info->_depth);
@@ -583,11 +583,11 @@ ImageInfo *ImageMgr::get(const Common::String &name, bool returnUnscaled) {
u4fclose(file);
} else {
errorWarning("Failed to open file %s for reading.", info->_filename.c_str());
- return NULL;
+ return nullptr;
}
- if (unscaled == NULL)
- return NULL;
+ if (unscaled == nullptr)
+ return nullptr;
if (info->_transparentIndex != -1)
unscaled->setTransparentIndex(info->_transparentIndex);
@@ -658,7 +658,7 @@ SubImage *ImageMgr::getSubImage(const Common::String &name) {
ImageSet *set = _baseSet;
- while (set != NULL) {
+ while (set != nullptr) {
for (Std::map<Common::String, ImageInfo *>::iterator i = set->_info.begin(); i != set->_info.end(); i++) {
ImageInfo *info = (ImageInfo *) i->_value;
Std::map<Common::String, SubImage *>::iterator j = info->_subImages.find(name);
@@ -669,7 +669,7 @@ SubImage *ImageMgr::getSubImage(const Common::String &name) {
set = getSet(set->_extends);
}
- return NULL;
+ return nullptr;
}
void ImageMgr::freeIntroBackgrounds() {
@@ -677,9 +677,9 @@ void ImageMgr::freeIntroBackgrounds() {
ImageSet *set = i->_value;
for (Std::map<Common::String, ImageInfo *>::iterator j = set->_info.begin(); j != set->_info.end(); j++) {
ImageInfo *info = j->_value;
- if (info->_image != NULL && info->_introOnly) {
+ if (info->_image != nullptr && info->_introOnly) {
delete info->_image;
- info->_image = NULL;
+ info->_image = nullptr;
}
}
}
@@ -708,7 +708,7 @@ ImageSet::~ImageSet() {
ImageInfo::~ImageInfo() {
for (Std::map<Common::String, SubImage *>::iterator i = _subImages.begin(); i != _subImages.end(); i++)
delete i->_value;
- if (_image != NULL)
+ if (_image != nullptr)
delete _image;
}
diff --git a/engines/ultima/ultima4/gfx/scale.cpp b/engines/ultima/ultima4/gfx/scale.cpp
index 8ed83e4df7..232bba2636 100644
--- a/engines/ultima/ultima4/gfx/scale.cpp
+++ b/engines/ultima/ultima4/gfx/scale.cpp
@@ -44,7 +44,7 @@ Scaler scalerGet(const Common::String &filter) {
else if (filter == "Scale2x")
return &scaleScale2x;
else
- return NULL;
+ return nullptr;
}
/**
@@ -63,7 +63,7 @@ Image *scalePoint(Image *src, int scale, int n) {
dest = Image::create(src->width() * scale, src->height() * scale, src->isIndexed(), Image::HARDWARE);
if (!dest)
- return NULL;
+ return nullptr;
if (dest->isIndexed())
dest->setPaletteFromImage(src);
@@ -72,7 +72,7 @@ Image *scalePoint(Image *src, int scale, int n) {
for (x = 0; x < src->width(); x++) {
for (i = 0; i < scale; i++) {
for (j = 0; j < scale; j++) {
- unsigned int index;
+ uint index;
src->getPixelIndex(x, y, index);
dest->putPixelIndex(x * scale + j, y * scale + i, index);
}
@@ -97,7 +97,7 @@ Image *scale2xBilinear(Image *src, int scale, int n) {
dest = Image::create(src->width() * scale, src->height() * scale, false, Image::HARDWARE);
if (!dest)
- return NULL;
+ return nullptr;
/*
* Each pixel in the source image is translated into four in the
@@ -199,7 +199,7 @@ Image *scale2xSaI(Image *src, int scale, int N) {
dest = Image::create(src->width() * scale, src->height() * scale, false, Image::HARDWARE);
if (!dest)
- return NULL;
+ return nullptr;
/*
* Each pixel in the source image is translated into four in the
@@ -365,7 +365,7 @@ Image *scaleScale2x(Image *src, int scale, int n) {
dest = Image::create(src->width() * scale, src->height() * scale, src->isIndexed(), Image::HARDWARE);
if (!dest)
- return NULL;
+ return nullptr;
if (dest->isIndexed())
dest->setPaletteFromImage(src);
diff --git a/engines/ultima/ultima4/gfx/screen.cpp b/engines/ultima/ultima4/gfx/screen.cpp
index 7761ebebff..42590b061e 100644
--- a/engines/ultima/ultima4/gfx/screen.cpp
+++ b/engines/ultima/ultima4/gfx/screen.cpp
@@ -231,7 +231,7 @@ void Screen::screenReInit() {
void Screen::screenTextAt(int x, int y, const char *fmt, ...) {
char buffer[BUFFER_SIZE];
- unsigned int i;
+ uint i;
va_list args;
va_start(args, fmt);
@@ -257,7 +257,7 @@ void Screen::screenMessage(const char *fmt, ...) {
if (!g_context)
return; //Because some cases (like the intro) don't have the context initiated.
char buffer[BUFFER_SIZE];
- unsigned int i;
+ uint i;
int wordlen;
va_list args;
@@ -398,7 +398,7 @@ Layout *Screen::screenLoadLayoutFromConf(const ConfigElement &conf) {
}
-Std::vector<MapTile> Screen::screenViewportTile(unsigned int width, unsigned int height, int x, int y, bool &focus) {
+Std::vector<MapTile> Screen::screenViewportTile(uint width, uint height, int x, int y, bool &focus) {
MapCoords center = g_context->_location->_coords;
static MapTile grass = g_context->_location->_map->_tileset->getByName("grass")->getId();
@@ -1164,7 +1164,7 @@ void Screen::screenShowGemTile(Layout *layout, Map *map, MapTile &t, bool focus,
if (!looks_like.empty())
t = map->_tileset->getByName(looks_like)->getId();
- unsigned int tile = map->translateToRawTileIndex(t);
+ uint tile = map->translateToRawTileIndex(t);
if (map->_type == Map::DUNGEON) {
ASSERT(_charSetInfo, "charset not initialized");
@@ -1334,7 +1334,7 @@ void Screen::screenWait(int numberOfAnimationFrames) {
Image *Screen::screenScale(Image *src, int scale, int n, int filter) {
Image *dest = nullptr;
bool isTransparent;
- unsigned int transparentIndex;
+ uint transparentIndex;
bool alpha = src->isAlphaOn();
if (n == 0)
@@ -1373,7 +1373,7 @@ Image *Screen::screenScaleDown(Image *src, int scale) {
int x, y;
Image *dest;
bool isTransparent;
- unsigned int transparentIndex;
+ uint transparentIndex;
bool alpha = src->isAlphaOn();
isTransparent = src->getTransparentIndex(transparentIndex);
@@ -1392,7 +1392,7 @@ Image *Screen::screenScaleDown(Image *src, int scale) {
for (y = 0; y < src->height(); y += scale) {
for (x = 0; x < src->width(); x += scale) {
- unsigned int index;
+ uint index;
src->getPixelIndex(x, y, index);
dest->putPixelIndex(x / scale, y / scale, index);
}
diff --git a/engines/ultima/ultima4/gfx/screen.h b/engines/ultima/ultima4/gfx/screen.h
index 2b11d2578a..8d489aa2bc 100644
--- a/engines/ultima/ultima4/gfx/screen.h
+++ b/engines/ultima/ultima4/gfx/screen.h
@@ -214,7 +214,7 @@ public:
/**
* Re-initializes the screen and implements any changes made in settings
*/
- void screenReInit(void);
+ void screenReInit();
void screenWait(int numberOfAnimationFrames);
/**
@@ -223,20 +223,20 @@ public:
void screenDrawImage(const Common::String &name, int x = 0, int y = 0);
void screenDrawImageInMapArea(const Common::String &bkgd);
- void screenCycle(void);
- void screenEraseMapArea(void);
+ void screenCycle();
+ void screenEraseMapArea();
void screenEraseTextArea(int x, int y, int width, int height);
- void screenGemUpdate(void);
+ void screenGemUpdate();
void screenMessage(const char *fmt, ...);
- void screenPrompt(void);
- void screenRedrawMapArea(void);
+ void screenPrompt();
+ void screenRedrawMapArea();
void screenRedrawTextArea(int x, int y, int width, int height);
/**
* Scroll the text in the message area up one position.
*/
- void screenScrollMessageArea(void);
+ void screenScrollMessageArea();
/**
* Do the tremor spell effect where the screen shakes.
@@ -261,15 +261,15 @@ public:
* neither is set, the map area is left untouched.
*/
void screenUpdate(TileView *view, bool showmap, bool blackout);
- void screenUpdateCursor(void);
- void screenUpdateMoons(void);
- void screenUpdateWind(void);
- Std::vector<MapTile> screenViewportTile(unsigned int width, unsigned int height, int x, int y, bool &focus);
-
- void screenShowCursor(void);
- void screenHideCursor(void);
- void screenEnableCursor(void);
- void screenDisableCursor(void);
+ void screenUpdateCursor();
+ void screenUpdateMoons();
+ void screenUpdateWind();
+ Std::vector<MapTile> screenViewportTile(uint width, uint height, int x, int y, bool &focus);
+
+ void screenShowCursor();
+ void screenHideCursor();
+ void screenEnableCursor();
+ void screenDisableCursor();
void screenSetCursorPos(int x, int y);
/**
diff --git a/engines/ultima/ultima4/map/city.cpp b/engines/ultima/ultima4/map/city.cpp
index acd0ec872a..82e63b95f3 100644
--- a/engines/ultima/ultima4/map/city.cpp
+++ b/engines/ultima/ultima4/map/city.cpp
@@ -73,7 +73,7 @@ void City::addPeople() {
for (current = _persons.begin(); current != _persons.end(); current++) {
Person *p = *current;
if ((p->getTile() != 0)
- && !(g_context->_party->canPersonJoin(p->getName(), NULL)
+ && !(g_context->_party->canPersonJoin(p->getName(), nullptr)
&& g_context->_party->isPersonJoined(p->getName()))
)
addPerson(p);
@@ -96,7 +96,7 @@ Person *City::personAt(const Coords &coords) {
if (isPerson(obj))
return dynamic_cast<Person *>(obj);
else
- return NULL;
+ return nullptr;
}
/**
@@ -105,7 +105,7 @@ Person *City::personAt(const Coords &coords) {
*/
bool isCity(Map *punknown) {
City *pCity;
- if ((pCity = dynamic_cast<City *>(punknown)) != NULL)
+ if ((pCity = dynamic_cast<City *>(punknown)) != nullptr)
return true;
else
return false;
diff --git a/engines/ultima/ultima4/map/city.h b/engines/ultima/ultima4/map/city.h
index a3d12a5d4d..ec1ea9599a 100644
--- a/engines/ultima/ultima4/map/city.h
+++ b/engines/ultima/ultima4/map/city.h
@@ -68,7 +68,7 @@ public:
/**
* Returns the person object at the given (x,y,z) coords, if one exists.
- * Otherwise, returns NULL.
+ * Otherwise, returns nullptr.
*/
Person *personAt(const Coords &coords);
diff --git a/engines/ultima/ultima4/map/dungeon.cpp b/engines/ultima/ultima4/map/dungeon.cpp
index 93df4775fe..3b16bfeae2 100644
--- a/engines/ultima/ultima4/map/dungeon.cpp
+++ b/engines/ultima/ultima4/map/dungeon.cpp
@@ -41,7 +41,7 @@ namespace Ultima4 {
*/
bool isDungeon(Map *punknown) {
Dungeon *pd;
- if ((pd = dynamic_cast<Dungeon *>(punknown)) != NULL)
+ if ((pd = dynamic_cast<Dungeon *>(punknown)) != nullptr)
return true;
else
return false;
@@ -86,7 +86,7 @@ DungeonToken Dungeon::currentToken() {
* Return the dungeon sub-token associated with the given dungeon tile.
*
*/
-unsigned char Dungeon::currentSubToken() {
+byte Dungeon::currentSubToken() {
return subTokenAt(g_context->_location->_coords);
}
@@ -94,7 +94,7 @@ DungeonToken Dungeon::tokenAt(MapCoords coords) {
return tokenForTile(*getTileFromData(coords));
}
-unsigned char Dungeon::subTokenAt(MapCoords coords) {
+byte Dungeon::subTokenAt(MapCoords coords) {
int index = coords.x + (coords.y * _width) + (_width * _height * coords.z);
return _dataSubTokens[index];
}
@@ -126,7 +126,7 @@ void dungeonSearch(void) {
/* see if there is an item at the current location (stones on altars, etc.) */
item = itemAtLocation(dungeon, g_context->_location->_coords);
if (item) {
- if (*item->_isItemInInventory != NULL && (*item->_isItemInInventory)(item->_data))
+ if (*item->_isItemInInventory != nullptr && (*item->_isItemInInventory)(item->_data))
g_screen->screenMessage("Nothing Here!\n");
else {
if (item->_name)
diff --git a/engines/ultima/ultima4/map/dungeon.h b/engines/ultima/ultima4/map/dungeon.h
index 4fbce7ee66..7240ee81b1 100644
--- a/engines/ultima/ultima4/map/dungeon.h
+++ b/engines/ultima/ultima4/map/dungeon.h
@@ -39,27 +39,27 @@ enum StatsBonusType {
};
struct Trigger {
- unsigned char _tile;
- unsigned char x, y;
- unsigned char _changeX1, _changeY1, changeX2, changeY2;
+ byte _tile;
+ byte x, y;
+ byte _changeX1, _changeY1, changeX2, changeY2;
};
struct DngRoom {
Trigger _triggers[DNGROOM_NTRIGGERS];
- unsigned char _creatureTiles[16];
- unsigned char _creatureStartX[16];
- unsigned char _creatureStartY[16];
- unsigned char _partyNorthStartX[8];
- unsigned char _partyNorthStartY[8];
- unsigned char _partyEastStartX[8];
- unsigned char _partyEastStartY[8];
- unsigned char _partySouthStartX[8];
- unsigned char _partySouthStartY[8];
- unsigned char _partyWestStartX[8];
- unsigned char _partyWestStartY[8];
+ byte _creatureTiles[16];
+ byte _creatureStartX[16];
+ byte _creatureStartY[16];
+ byte _partyNorthStartX[8];
+ byte _partyNorthStartY[8];
+ byte _partyEastStartX[8];
+ byte _partyEastStartY[8];
+ byte _partySouthStartX[8];
+ byte _partySouthStartY[8];
+ byte _partyWestStartX[8];
+ byte _partyWestStartY[8];
MapData _mapData; // This is OK to change to MapData since sizeof(DngRoom) or
// anything like it is not being used.
- unsigned char _buffer[7];
+ byte _buffer[7];
};
/**
@@ -107,7 +107,7 @@ public:
/**
* Returns the dungeon sub-token for the current location
*/
- unsigned char currentSubToken();
+ byte currentSubToken();
/**
* Returns the dungeon token for the given coordinates
@@ -121,7 +121,7 @@ public:
* This function will always need type-casting to the token type
* necessary
*/
- unsigned char subTokenAt(MapCoords coords);
+ byte subTokenAt(MapCoords coords);
/**
* Returns true if a ladder-up is found at the given coordinates
@@ -137,13 +137,13 @@ public:
// Properties
Common::String _name;
- unsigned int _nRooms;
- Std::vector<unsigned char> _dataSubTokens;
+ uint _nRooms;
+ Std::vector<byte> _dataSubTokens;
DngRoom *_rooms;
CombatMap **_roomMaps;
int _currentRoom;
- unsigned char _partyStartX[8];
- unsigned char _partyStartY[8];
+ byte _partyStartX[8];
+ byte _partyStartY[8];
};
/**
@@ -170,7 +170,7 @@ enum FieldType {
FIELD_SLEEP = 0x3
};
-void dungeonSearch(void);
+void dungeonSearch();
void dungeonDrinkFountain();
void dungeonTouchOrb();
bool dungeonHandleTrap(TrapType trap);
diff --git a/engines/ultima/ultima4/map/dungeonview.cpp b/engines/ultima/ultima4/map/dungeonview.cpp
index 69e9e6c262..e712937f46 100644
--- a/engines/ultima/ultima4/map/dungeonview.cpp
+++ b/engines/ultima/ultima4/map/dungeonview.cpp
@@ -40,7 +40,7 @@ DungeonView::DungeonView(int x, int y, int columns, int rows) : TileView(x, y, r
}
-DungeonView *DungeonView::_instance(NULL);
+DungeonView *DungeonView::_instance(nullptr);
DungeonView *DungeonView::getInstance() {
if (!_instance) {
_instance = new DungeonView(BORDER_WIDTH, BORDER_HEIGHT, VIEWPORT_W, VIEWPORT_H);
@@ -439,7 +439,7 @@ void DungeonView::drawWall(int xoffset, int distance, Direction orientation, Dun
g_screen->screenDrawImage(dngGraphicInfo[index].subimage, (BORDER_WIDTH + x) * settings._scale,
(BORDER_HEIGHT + y) * settings._scale);
- if (dngGraphicInfo[index].subimage2 != NULL) {
+ if (dngGraphicInfo[index].subimage2 != nullptr) {
// FIXME: subimage2 is a horrible hack, needs to be cleaned up
if (settings._videoType == "EGA")
g_screen->screenDrawImage(dngGraphicInfo[index].subimage2,
diff --git a/engines/ultima/ultima4/map/location.cpp b/engines/ultima/ultima4/map/location.cpp
index 3eb8f0f61c..65c271da81 100644
--- a/engines/ultima/ultima4/map/location.cpp
+++ b/engines/ultima/ultima4/map/location.cpp
@@ -269,7 +269,7 @@ Location *locationPush(Location *stack, Location *loc) {
Location *locationPop(Location **stack) {
Location *loc = *stack;
*stack = (*stack)->_prev;
- loc->_prev = NULL;
+ loc->_prev = nullptr;
return loc;
}
diff --git a/engines/ultima/ultima4/map/location.h b/engines/ultima/ultima4/map/location.h
index 1e6cc5310e..731d90532a 100644
--- a/engines/ultima/ultima4/map/location.h
+++ b/engines/ultima/ultima4/map/location.h
@@ -50,7 +50,7 @@ class TurnCompleter;
class Location : public Observable<Location *, MoveEvent &> {
public:
/**
- * Add a new location to the stack, or start a new stack if 'prev' is NULL
+ * Add a new location to the stack, or start a new stack if 'prev' is nullptr
*/
Location(MapCoords coords, Map *map, int viewmode, LocationContext ctx, TurnCompleter *turnCompleter, Location *prev);
diff --git a/engines/ultima/ultima4/map/map.cpp b/engines/ultima/ultima4/map/map.cpp
index 3e148bf53a..994b45056c 100644
--- a/engines/ultima/ultima4/map/map.cpp
+++ b/engines/ultima/ultima4/map/map.cpp
@@ -243,8 +243,8 @@ Map::Map() {
_chunkHeight = 0;
_offset = 0;
_id = 0;
- _tileset = NULL;
- _tilemap = NULL;
+ _tileset = nullptr;
+ _tilemap = nullptr;
}
Map::~Map() {
@@ -260,7 +260,7 @@ Common::String Map::getName() {
Object *Map::objectAt(const Coords &coords) {
/* FIXME: return a list instead of one object */
ObjectDeque::const_iterator i;
- Object *objAt = NULL;
+ Object *objAt = nullptr;
for (i = _objects.begin(); i != _objects.end(); i++) {
Object *obj = *i;
@@ -287,7 +287,7 @@ const Portal *Map::portalAt(const Coords &coords, int actionFlags) {
((*i)->_triggerAction & actionFlags))
return *i;
}
- return NULL;
+ return nullptr;
}
MapTile *Map::getTileFromData(const Coords &coords) {
@@ -337,7 +337,7 @@ bool Map::isWorldMap() {
}
bool Map::isEnclosed(const Coords &party) {
- unsigned int x, y;
+ uint x, y;
int *path_data;
if (_borderBehavior != BORDER_WRAP)
@@ -451,9 +451,9 @@ ObjectDeque::iterator Map::removeObject(ObjectDeque::iterator rem, bool deleteOb
}
Creature *Map::moveObjects(MapCoords avatar) {
- Creature *attacker = NULL;
+ Creature *attacker = nullptr;
- for (unsigned int i = 0; i < _objects.size(); i++) {
+ for (uint i = 0; i < _objects.size(); i++) {
Creature *m = dynamic_cast<Creature *>(_objects[i]);
if (m) {
@@ -771,12 +771,12 @@ bool Map::fillMonsterTable() {
}
MapTile Map::translateFromRawTileIndex(int raw) const {
- ASSERT(_tilemap != NULL, "tilemap hasn't been set");
+ ASSERT(_tilemap != nullptr, "tilemap hasn't been set");
return _tilemap->translate(raw);
}
-unsigned int Map::translateToRawTileIndex(MapTile &tile) const {
+uint Map::translateToRawTileIndex(MapTile &tile) const {
return _tilemap->untranslate(tile);
}
diff --git a/engines/ultima/ultima4/map/map.h b/engines/ultima/ultima4/map/map.h
index 10c2454985..6b36d24d44 100644
--- a/engines/ultima/ultima4/map/map.h
+++ b/engines/ultima/ultima4/map/map.h
@@ -82,8 +82,8 @@ public:
MapCoords &wrap(const class Map *map);
MapCoords &putInBounds(const class Map *map);
- MapCoords &move(Direction d, const class Map *map = NULL);
- MapCoords &move(int dx, int dy, const class Map *map = NULL);
+ MapCoords &move(Direction d, const class Map *map = nullptr);
+ MapCoords &move(int dx, int dy, const class Map *map = nullptr);
/**
* Returns a mask of directions that indicate where one point is relative
@@ -94,7 +94,7 @@ public:
* itself accordingly. If the two coordinates are not on the same z-plane,
* then this function return DIR_NONE.
*/
- int getRelativeDirection(const MapCoords &c, const class Map *map = NULL) const;
+ int getRelativeDirection(const MapCoords &c, const class Map *map = nullptr) const;
/**
* Finds the appropriate direction to travel to get from one point to
@@ -103,7 +103,7 @@ public:
* This function also takes into account map boundaries and adjusts
* itself accordingly, provided the 'map' parameter is passed
*/
- Direction pathTo(const MapCoords &c, int valid_dirs = MASK_DIR_ALL, bool towards = true, const class Map *map = NULL) const;
+ Direction pathTo(const MapCoords &c, int valid_dirs = MASK_DIR_ALL, bool towards = true, const class Map *map = nullptr) const;
/**
* Finds the appropriate direction to travel to move away from one point
@@ -115,14 +115,14 @@ public:
* on a map, taking into account map boundaries and such. If the two coords
* are not on the same z-plane, then this function returns -1;
*/
- int movementDistance(const MapCoords &c, const class Map *map = NULL) const;
+ int movementDistance(const MapCoords &c, const class Map *map = nullptr) const;
/**
* Finds the distance (using diagonals) from point a to point b on a map
* If the two coordinates are not on the same z-plane, then this function
* returns -1. This function also takes into account map boundaries.
*/
- int distance(const MapCoords &c, const class Map *map = NULL) const;
+ int distance(const MapCoords &c, const class Map *map = nullptr) const;
static MapCoords nowhere;
};
@@ -164,14 +164,14 @@ public:
/**
* Returns the object at the given (x,y,z) coords, if one exists.
- * Otherwise, returns NULL.
+ * Otherwise, returns nullptr.
*/
Object *objectAt(const Coords &coords);
/**
* Returns the portal for the correspoding action(s) given.
* If there is no portal that corresponds to the actions flagged
- * by 'actionFlags' at the given (x,y,z) coords, it returns NULL.
+ * by 'actionFlags' at the given (x,y,z) coords, it returns nullptr.
*/
const Portal *portalAt(const Coords &coords, int actionFlags);
@@ -257,18 +257,18 @@ public:
// u4dos compatibility
bool fillMonsterTable();
MapTile translateFromRawTileIndex(int c) const;
- unsigned int translateToRawTileIndex(MapTile &tile) const;
+ uint translateToRawTileIndex(MapTile &tile) const;
public:
MapId _id;
Common::String _fname;
Type _type;
- unsigned int _width,
+ uint _width,
_height,
_levels;
- unsigned int _chunkWidth,
+ uint _chunkWidth,
_chunkHeight;
- unsigned int _offset;
+ uint _offset;
Source _baseSource;
Common::List<Source> _extraSources;
diff --git a/engines/ultima/ultima4/map/maploader.cpp b/engines/ultima/ultima4/map/maploader.cpp
index 4465c8657b..b9d0bd345f 100644
--- a/engines/ultima/ultima4/map/maploader.cpp
+++ b/engines/ultima/ultima4/map/maploader.cpp
@@ -47,7 +47,7 @@
namespace Ultima {
namespace Ultima4 {
-Std::map<Map::Type, MapLoader *, MapType_Hash> *MapLoader::loaderMap = NULL;
+Std::map<Map::Type, MapLoader *, MapType_Hash> *MapLoader::loaderMap = nullptr;
MapLoader *CityMapLoader::_instance = MapLoader::registerLoader(new CityMapLoader, Map::CITY);
MapLoader *ConMapLoader::_instance = MapLoader::registerLoader(MapLoader::registerLoader(new ConMapLoader, Map::COMBAT), Map::SHRINE);
@@ -55,14 +55,14 @@ MapLoader *DngMapLoader::_instance = MapLoader::registerLoader(new DngMapLoader,
MapLoader *WorldMapLoader::_instance = MapLoader::registerLoader(new WorldMapLoader, Map::WORLD);
MapLoader *MapLoader::getLoader(Map::Type type) {
- ASSERT(loaderMap != NULL, "ImageLoader::getLoader loaderMap not initialized");
+ ASSERT(loaderMap != nullptr, "ImageLoader::getLoader loaderMap not initialized");
if (loaderMap->find(type) == loaderMap->end())
- return NULL;
+ return nullptr;
return (*loaderMap)[type];
}
MapLoader *MapLoader::registerLoader(MapLoader *loader, Map::Type type) {
- if (loaderMap == NULL)
+ if (loaderMap == nullptr)
loaderMap = new Std::map<Map::Type, MapLoader *, MapType_Hash>();
if (loaderMap->find(type) != loaderMap->end())
@@ -73,7 +73,7 @@ MapLoader *MapLoader::registerLoader(MapLoader *loader, Map::Type type) {
}
bool MapLoader::loadData(Map *map, U4FILE *f) {
- unsigned int x, xch, y, ych;
+ uint x, xch, y, ych;
/* allocate the space we need for the map data */
map->_data.clear();
@@ -130,7 +130,7 @@ bool MapLoader::isChunkCompressed(Map *map, int chunk) {
bool CityMapLoader::load(Map *map) {
City *city = dynamic_cast<City *>(map);
- unsigned int i, j;
+ uint i, j;
Person *people[CITY_MAX_PERSONS];
Dialogue *dialogues[CITY_MAX_PERSONS];
DialogueLoader *dlgLoader = DialogueLoaders::getLoader("application/x-u4tlk");
@@ -164,7 +164,7 @@ bool CityMapLoader::load(Map *map) {
u4fgetc(ult); /* read redundant startx/starty */
for (i = 0; i < CITY_MAX_PERSONS; i++) {
- unsigned char c = u4fgetc(ult);
+ byte c = u4fgetc(ult);
if (c == 0)
people[i]->setMovementBehavior(MOVEMENT_FIXED);
else if (c == 1)
@@ -177,7 +177,7 @@ bool CityMapLoader::load(Map *map) {
return false;
}
- unsigned char conv_idx[CITY_MAX_PERSONS];
+ byte conv_idx[CITY_MAX_PERSONS];
for (i = 0; i < CITY_MAX_PERSONS; i++) {
conv_idx[i] = u4fgetc(ult);
}
@@ -221,9 +221,9 @@ bool CityMapLoader::load(Map *map) {
for (current = city->_personRoles.begin(); current != city->_personRoles.end(); current++) {
if ((unsigned)(*current)->_id == (i + 1)) {
if ((*current)->_role == NPC_LORD_BRITISH)
- people[i]->setDialogue(DialogueLoaders::getLoader("application/x-u4lbtlk")->load(NULL));
+ people[i]->setDialogue(DialogueLoaders::getLoader("application/x-u4lbtlk")->load(nullptr));
else if ((*current)->_role == NPC_HAWKWIND)
- people[i]->setDialogue(DialogueLoaders::getLoader("application/x-u4hwtlk")->load(NULL));
+ people[i]->setDialogue(DialogueLoaders::getLoader("application/x-u4hwtlk")->load(nullptr));
people[i]->setNpcType(static_cast<PersonNpcType>((*current)->_role));
}
}
@@ -294,9 +294,9 @@ bool DngMapLoader::load(Map *map) {
ASSERT(dungeon->_height == DNG_HEIGHT, "map height is %d, should be %d", dungeon->_height, DNG_HEIGHT);
/* load the dungeon map */
- unsigned int i, j;
+ uint i, j;
for (i = 0; i < (DNG_HEIGHT * DNG_WIDTH * dungeon->_levels); i++) {
- unsigned char mapData = u4fgetc(dng);
+ byte mapData = u4fgetc(dng);
MapTile tile = map->translateFromRawTileIndex(mapData);
/* determine what type of tile it is */
@@ -309,7 +309,7 @@ bool DngMapLoader::load(Map *map) {
dungeon->_rooms = new DngRoom[dungeon->_nRooms];
for (i = 0; i < dungeon->_nRooms; i++) {
- unsigned char room_tiles[121];
+ byte room_tiles[121];
for (j = 0; j < DNGROOM_NTRIGGERS; j++) {
int tmp;
@@ -361,7 +361,7 @@ bool DngMapLoader::load(Map *map) {
// dungeon room fixup
//
if (map->_id == MAP_HYTHLOTH) {
- // A couple rooms in hythloth have NULL player start positions,
+ // A couple rooms in hythloth have nullptr player start positions,
// which causes the entire party to appear in the upper-left
// tile when entering the dungeon room.
//
@@ -373,25 +373,25 @@ bool DngMapLoader::load(Map *map) {
//
if (i == 0x7) {
// update party start positions when entering from the east
- const unsigned char x1[8] = { 0x8, 0x8, 0x9, 0x9, 0x9, 0xA, 0xA, 0xA },
+ const byte x1[8] = { 0x8, 0x8, 0x9, 0x9, 0x9, 0xA, 0xA, 0xA },
y1[8] = { 0x3, 0x2, 0x3, 0x2, 0x1, 0x3, 0x2, 0x1 };
memcpy(dungeon->_rooms[i]._partyEastStartX, x1, sizeof(x1));
memcpy(dungeon->_rooms[i]._partyEastStartY, y1, sizeof(y1));
// update party start positions when entering from the south
- const unsigned char x2[8] = { 0x3, 0x2, 0x3, 0x2, 0x1, 0x3, 0x2, 0x1 },
+ const byte x2[8] = { 0x3, 0x2, 0x3, 0x2, 0x1, 0x3, 0x2, 0x1 },
y2[8] = { 0x8, 0x8, 0x9, 0x9, 0x9, 0xA, 0xA, 0xA };
memcpy(dungeon->_rooms[i]._partySouthStartX, x2, sizeof(x2));
memcpy(dungeon->_rooms[i]._partySouthStartY, y2, sizeof(y2));
} else if (i == 0x9) {
// update the starting position of monsters 7, 8, and 9
- const unsigned char x1[3] = { 0x4, 0x6, 0x5 },
+ const byte x1[3] = { 0x4, 0x6, 0x5 },
y1[3] = { 0x5, 0x5, 0x6 };
memcpy(dungeon->_rooms[i]._creatureStartX + 7, x1, sizeof(x1));
memcpy(dungeon->_rooms[i]._creatureStartY + 7, y1, sizeof(y1));
// update party start positions when entering from the west
- const unsigned char x2[8] = { 0x2, 0x2, 0x1, 0x1, 0x1, 0x0, 0x0, 0x0 },
+ const byte x2[8] = { 0x2, 0x2, 0x1, 0x1, 0x1, 0x0, 0x0, 0x0 },
y2[8] = { 0x9, 0x8, 0x9, 0x8, 0x7, 0x9, 0x8, 0x7 };
memcpy(dungeon->_rooms[i]._partyWestStartX, x2, sizeof(x2));
memcpy(dungeon->_rooms[i]._partyWestStartY, y2, sizeof(y2));
diff --git a/engines/ultima/ultima4/map/mapmgr.cpp b/engines/ultima/ultima4/map/mapmgr.cpp
index 1c427c852a..324aefdd9e 100644
--- a/engines/ultima/ultima4/map/mapmgr.cpp
+++ b/engines/ultima/ultima4/map/mapmgr.cpp
@@ -45,21 +45,21 @@ namespace Ultima4 {
using Std::vector;
using Std::pair;
-MapMgr *MapMgr::_instance = NULL;
+MapMgr *MapMgr::_instance = nullptr;
extern bool isAbyssOpened(const Portal *p);
extern bool shrineCanEnter(const Portal *p);
MapMgr *MapMgr::getInstance() {
- if (_instance == NULL)
+ if (_instance == nullptr)
_instance = new MapMgr();
return _instance;
}
void MapMgr::destroy() {
- if (_instance != NULL) {
+ if (_instance != nullptr) {
delete _instance;
- _instance = NULL;
+ _instance = nullptr;
}
}
@@ -132,7 +132,7 @@ Map *MapMgr::get(MapId id) {
/* if the map hasn't been loaded yet, load it! */
if (!_mapList[id]->_data.size()) {
MapLoader *loader = MapLoader::getLoader(_mapList[id]->_type);
- if (loader == NULL)
+ if (loader == nullptr)
errorFatal("can't load map of type \"%d\"", _mapList[id]->_type);
loader->load(_mapList[id]);
@@ -142,9 +142,9 @@ Map *MapMgr::get(MapId id) {
void MapMgr::registerMap(Map *map) {
if (_mapList.size() <= map->_id)
- _mapList.resize(map->_id + 1, NULL);
+ _mapList.resize(map->_id + 1, nullptr);
- if (_mapList[map->_id] != NULL)
+ if (_mapList[map->_id] != nullptr)
errorFatal("Error: A map with id '%d' already exists", map->_id);
_mapList[map->_id] = map;
@@ -152,12 +152,12 @@ void MapMgr::registerMap(Map *map) {
Map *MapMgr::initMapFromConf(const ConfigElement &mapConf) {
Map *map;
- static const char *mapTypeEnumStrings[] = { "world", "city", "shrine", "combat", "dungeon", NULL };
- static const char *borderBehaviorEnumStrings[] = { "wrap", "exit", "fixed", NULL };
+ static const char *mapTypeEnumStrings[] = { "world", "city", "shrine", "combat", "dungeon", nullptr };
+ static const char *borderBehaviorEnumStrings[] = { "wrap", "exit", "fixed", nullptr };
map = initMap(static_cast<Map::Type>(mapConf.getEnum("type", mapTypeEnumStrings)));
if (!map)
- return NULL;
+ return nullptr;
map->_id = static_cast<MapId>(mapConf.getInt("id"));
map->_type = static_cast<Map::Type>(mapConf.getEnum("type", mapTypeEnumStrings));
@@ -231,7 +231,7 @@ PersonRole *MapMgr::initPersonRoleFromConf(const ConfigElement &personRoleConf)
PersonRole *personrole;
static const char *roleEnumStrings[] = { "companion", "weaponsvendor", "armorvendor", "foodvendor", "tavernkeeper",
"reagentsvendor", "healer", "innkeeper", "guildvendor", "horsevendor",
- "lordbritish", "hawkwind", NULL
+ "lordbritish", "hawkwind", nullptr
};
personrole = new PersonRole();
@@ -247,8 +247,8 @@ Portal *MapMgr::initPortalFromConf(const ConfigElement &portalConf) {
portal = new Portal();
- portal->_portalConditionsMet = NULL;
- portal->_retroActiveDest = NULL;
+ portal->_portalConditionsMet = nullptr;
+ portal->_retroActiveDest = nullptr;
portal->_coords = MapCoords(
portalConf.getInt("x"),
@@ -320,7 +320,7 @@ Portal *MapMgr::initPortalFromConf(const ConfigElement &portalConf) {
}
void MapMgr::initShrineFromConf(const ConfigElement &shrineConf, Shrine *shrine) {
- static const char *virtues[] = {"Honesty", "Compassion", "Valor", "Justice", "Sacrifice", "Honor", "Spirituality", "Humility", NULL};
+ static const char *virtues[] = {"Honesty", "Compassion", "Valor", "Justice", "Sacrifice", "Honor", "Spirituality", "Humility", nullptr};
shrine->setVirtue(static_cast<Virtue>(shrineConf.getEnum("virtue", virtues)));
shrine->setMantra(shrineConf.getString("mantra"));
@@ -328,8 +328,8 @@ void MapMgr::initShrineFromConf(const ConfigElement &shrineConf, Shrine *shrine)
void MapMgr::initDungeonFromConf(const ConfigElement &dungeonConf, Dungeon *dungeon) {
dungeon->_nRooms = dungeonConf.getInt("rooms");
- dungeon->_rooms = NULL;
- dungeon->_roomMaps = NULL;
+ dungeon->_rooms = nullptr;
+ dungeon->_roomMaps = nullptr;
dungeon->_name = dungeonConf.getString("name");
}
diff --git a/engines/ultima/ultima4/map/movement.cpp b/engines/ultima/ultima4/map/movement.cpp
index b0c4d6a783..ebcff53ab2 100644
--- a/engines/ultima/ultima4/map/movement.cpp
+++ b/engines/ultima/ultima4/map/movement.cpp
@@ -360,7 +360,7 @@ void movePartyMember(MoveEvent &event) {
ct->setExitDir(event._dir);
g_context->_location->_map->removeObject((*party)[member]);
- (*party)[member] = NULL;
+ (*party)[member] = nullptr;
event._result = (MoveResult)(MOVE_EXIT_TO_PARENT | MOVE_MAP_CHANGE | MOVE_SUCCEEDED | MOVE_END_TURN);
return;
} else {
diff --git a/engines/ultima/ultima4/map/shrine.cpp b/engines/ultima/ultima4/map/shrine.cpp
index 25aac77c49..b031a37416 100644
--- a/engines/ultima/ultima4/map/shrine.cpp
+++ b/engines/ultima/ultima4/map/shrine.cpp
@@ -69,7 +69,7 @@ bool shrineCanEnter(const Portal *p) {
*/
bool isShrine(Map *punknown) {
Shrine *ps;
- if ((ps = dynamic_cast<Shrine *>(punknown)) != NULL)
+ if ((ps = dynamic_cast<Shrine *>(punknown)) != nullptr)
return true;
else
return false;
diff --git a/engines/ultima/ultima4/map/tile.cpp b/engines/ultima/ultima4/map/tile.cpp
index 53525f510d..c7d58a2a08 100644
--- a/engines/ultima/ultima4/map/tile.cpp
+++ b/engines/ultima/ultima4/map/tile.cpp
@@ -48,14 +48,14 @@ Tile::Tile(Tileset *tileset)
, _h(0)
, _frames(0)
, _scale(1)
- , _anim(NULL)
+ , _anim(nullptr)
, _opaque(false)
, _foreground()
, _waterForeground()
- , rule(NULL)
+ , rule(nullptr)
, _imageName()
, _looksLike()
- , _image(NULL)
+ , _image(nullptr)
, _tiledInDungeon(false)
, _directions()
, _animationRule("") {
@@ -82,7 +82,7 @@ void Tile::loadProperties(const ConfigElement &conf) {
if there is no rule specified, it defaults to the "default" rule */
if (conf.exists("rule")) {
rule = TileRule::findByName(conf.getString("rule"));
- if (rule == NULL)
+ if (rule == nullptr)
rule = TileRule::findByName("default");
} else rule = TileRule::findByName("default");
@@ -126,7 +126,7 @@ void Tile::loadImage() {
if (!_image) {
_scale = settings._scale;
- SubImage *subimage = NULL;
+ SubImage *subimage = nullptr;
ImageInfo *info = imageMgr->get(_imageName);
if (!info) {
@@ -169,10 +169,10 @@ void Tile::loadImage() {
}
if (_animationRule.size() > 0) {
- _anim = NULL;
+ _anim = nullptr;
if (g_screen->_tileAnims)
_anim = g_screen->_tileAnims->getByName(_animationRule);
- if (_anim == NULL)
+ if (_anim == nullptr)
errorWarning("Warning: animation style '%s' not found", _animationRule.c_str());
}
@@ -187,7 +187,7 @@ void Tile::loadImage() {
void Tile::deleteImage() {
if (_image) {
delete _image;
- _image = NULL;
+ _image = nullptr;
}
_scale = settings._scale;
}
diff --git a/engines/ultima/ultima4/map/tileanim.cpp b/engines/ultima/ultima4/map/tileanim.cpp
index 4baa21dea8..d59fcacd7c 100644
--- a/engines/ultima/ultima4/map/tileanim.cpp
+++ b/engines/ultima/ultima4/map/tileanim.cpp
@@ -37,7 +37,7 @@ using Std::vector;
TileAnimTransform *TileAnimTransform::create(const ConfigElement &conf) {
TileAnimTransform *transform;
- static const char *transformTypeEnumStrings[] = { "invert", "pixel", "scroll", "frame", "pixel_color", NULL };
+ static const char *transformTypeEnumStrings[] = { "invert", "pixel", "scroll", "frame", "pixel_color", nullptr };
int type = conf.getEnum("type", transformTypeEnumStrings);
@@ -220,8 +220,8 @@ void TileAnimPixelColorTransform::draw(Image *dest, Tile *tile, MapTile &mapTile
TileAnimContext *TileAnimContext::create(const ConfigElement &conf) {
TileAnimContext *context;
- static const char *contextTypeEnumStrings[] = { "frame", "dir", NULL };
- static const char *dirEnumStrings[] = { "none", "west", "north", "east", "south", NULL };
+ static const char *contextTypeEnumStrings[] = { "frame", "dir", nullptr };
+ static const char *dirEnumStrings[] = { "none", "west", "north", "east", "south", nullptr };
TileAnimContext::Type type = (TileAnimContext::Type)conf.getEnum("type", contextTypeEnumStrings);
@@ -233,7 +233,7 @@ TileAnimContext *TileAnimContext::create(const ConfigElement &conf) {
context = new TileAnimPlayerDirContext(Direction(conf.getEnum("dir", dirEnumStrings)));
break;
default:
- context = NULL;
+ context = nullptr;
break;
}
@@ -288,7 +288,7 @@ TileAnimSet::TileAnimSet(const ConfigElement &conf) {
TileAnim *TileAnimSet::getByName(const Common::String &name) {
TileAnimMap::iterator i = _tileAnims.find(name);
if (i == _tileAnims.end())
- return NULL;
+ return nullptr;
return i->_value;
}
diff --git a/engines/ultima/ultima4/map/tilemap.cpp b/engines/ultima/ultima4/map/tilemap.cpp
index eafd6a2f7a..ef31098e3c 100644
--- a/engines/ultima/ultima4/map/tilemap.cpp
+++ b/engines/ultima/ultima4/map/tilemap.cpp
@@ -117,17 +117,17 @@ void TileMap::load(const ConfigElement &tilemapConf) {
TileMap *TileMap::get(Common::String name) {
if (_tileMaps.find(name) != _tileMaps.end())
return _tileMaps[name];
- else return NULL;
+ else return nullptr;
}
-MapTile TileMap::translate(unsigned int index) {
+MapTile TileMap::translate(uint index) {
return _tileMap[index];
}
-unsigned int TileMap::untranslate(MapTile &tile) {
- unsigned int index = 0;
+uint TileMap::untranslate(MapTile &tile) {
+ uint index = 0;
- for (Std::map<unsigned int, MapTile>::iterator i = _tileMap.begin(); i != _tileMap.end(); i++) {
+ for (Std::map<uint, MapTile>::iterator i = _tileMap.begin(); i != _tileMap.end(); i++) {
if (i->_value == tile) {
index = i->_key;
break;
diff --git a/engines/ultima/ultima4/map/tilemap.h b/engines/ultima/ultima4/map/tilemap.h
index c2caa986a6..8b22dbe5e0 100644
--- a/engines/ultima/ultima4/map/tilemap.h
+++ b/engines/ultima/ultima4/map/tilemap.h
@@ -41,8 +41,8 @@ public:
/**
* Translates a raw index to a MapTile.
*/
- MapTile translate(unsigned int index);
- unsigned int untranslate(MapTile &tile);
+ MapTile translate(uint index);
+ uint untranslate(MapTile &tile);
/**
* Load all tilemaps from the specified xml file
@@ -68,7 +68,7 @@ private:
static void load(const ConfigElement &tilemapConf);
static TileIndexMapMap _tileMaps;
- Std::map<unsigned int, MapTile> _tileMap;
+ Std::map<uint, MapTile> _tileMap;
};
} // End of namespace Ultima4
diff --git a/engines/ultima/ultima4/map/tileset.cpp b/engines/ultima/ultima4/map/tileset.cpp
index 52c0812da3..dd374eadcf 100644
--- a/engines/ultima/ultima4/map/tileset.cpp
+++ b/engines/ultima/ultima4/map/tileset.cpp
@@ -42,7 +42,7 @@ TileRule *TileRule::findByName(const Common::String &name) {
TileRuleMap::iterator i = _rules.find(name);
if (i != _rules.end())
return i->_value;
- return NULL;
+ return nullptr;
}
void TileRule::load() {
@@ -55,16 +55,16 @@ void TileRule::load() {
TileRule::_rules[rule->_name] = rule;
}
- if (TileRule::findByName("default") == NULL)
+ if (TileRule::findByName("default") == nullptr)
errorFatal("no 'default' rule found in tile rules");
}
bool TileRule::initFromConf(const ConfigElement &conf) {
- unsigned int i;
+ uint i;
static const struct {
const char *name;
- unsigned int mask;
+ uint mask;
} booleanAttributes[] = {
{ "dispel", MASK_DISPEL },
{ "talkover", MASK_TALKOVER },
@@ -85,15 +85,15 @@ bool TileRule::initFromConf(const ConfigElement &conf) {
static const struct {
const char *name;
- unsigned int mask;
+ uint mask;
} movementBooleanAttr[] = {
{ "swimable", MASK_SWIMABLE },
{ "sailable", MASK_SAILABLE },
{ "unflyable", MASK_UNFLYABLE },
{ "creatureunwalkable", MASK_CREATURE_UNWALKABLE }
};
- static const char *speedEnumStrings[] = { "fast", "slow", "vslow", "vvslow", NULL };
- static const char *effectsEnumStrings[] = { "none", "fire", "sleep", "poison", "poisonField", "electricity", "lava", NULL };
+ static const char *speedEnumStrings[] = { "fast", "slow", "vslow", "vvslow", nullptr };
+ static const char *effectsEnumStrings[] = { "none", "fire", "sleep", "poison", "poisonField", "electricity", "lava", nullptr };
this->_mask = 0;
this->_movementMask = 0;
@@ -215,7 +215,7 @@ void Tileset::unloadAllImages() {
Tileset *Tileset::get(const Common::String &name) {
if (tilesets.find(name) != tilesets.end())
return tilesets[name];
- else return NULL;
+ else return nullptr;
}
Tile *Tileset::findTileByName(const Common::String &name) {
@@ -226,7 +226,7 @@ Tile *Tileset::findTileByName(const Common::String &name) {
return t;
}
- return NULL;
+ return nullptr;
}
Tile *Tileset::findTileById(TileId id) {
@@ -237,7 +237,7 @@ Tile *Tileset::findTileById(TileId id) {
return t;
}
- return NULL;
+ return nullptr;
}
void Tileset::load(const ConfigElement &tilesetConf) {
@@ -246,7 +246,7 @@ void Tileset::load(const ConfigElement &tilesetConf) {
_imageName = tilesetConf.getString("imageName");
if (tilesetConf.exists("extends"))
_extends = Tileset::get(tilesetConf.getString("extends"));
- else _extends = NULL;
+ else _extends = nullptr;
int index = 0;
vector<ConfigElement> children = tilesetConf.getChildren();
@@ -292,7 +292,7 @@ Tile *Tileset::get(TileId id) {
return _tiles[id];
else if (_extends)
return _extends->get(id);
- return NULL;
+ return nullptr;
}
Tile *Tileset::getByName(const Common::String &name) {
@@ -300,7 +300,7 @@ Tile *Tileset::getByName(const Common::String &name) {
return _nameMap[name];
else if (_extends)
return _extends->getByName(name);
- else return NULL;
+ else return nullptr;
}
Common::String Tileset::getImageName() const {
@@ -309,11 +309,11 @@ Common::String Tileset::getImageName() const {
else return _imageName;
}
-unsigned int Tileset::numTiles() const {
+uint Tileset::numTiles() const {
return _tiles.size();
}
-unsigned int Tileset::numFrames() const {
+uint Tileset::numFrames() const {
return _totalFrames;
}
diff --git a/engines/ultima/ultima4/map/tileset.h b/engines/ultima/ultima4/map/tileset.h
index 27da4431a8..ec1622a0bf 100644
--- a/engines/ultima/ultima4/map/tileset.h
+++ b/engines/ultima/ultima4/map/tileset.h
@@ -40,7 +40,7 @@ typedef Common::HashMap<Common::String, class TileRule *> TileRuleMap;
class TileRule {
public:
/**
- * Returns the tile rule with the given name, or NULL if none could be found
+ * Returns the tile rule with the given name, or nullptr if none could be found
*/
static TileRule *findByName(const Common::String &name);
@@ -130,19 +130,19 @@ public:
/**
* Returns the number of tiles in the tileset
*/
- unsigned int numTiles() const;
+ uint numTiles() const;
/**
* Returns the total number of frames in the tileset
*/
- unsigned int numFrames() const;
+ uint numFrames() const;
private:
static TilesetMap tilesets;
Common::String _name;
TileIdMap _tiles;
- unsigned int _totalFrames;
+ uint _totalFrames;
Common::String _imageName;
Tileset *_extends;
diff --git a/engines/ultima/ultima4/map/tileview.cpp b/engines/ultima/ultima4/map/tileview.cpp
index 7bcb849744..abe27fa53c 100644
--- a/engines/ultima/ultima4/map/tileview.cpp
+++ b/engines/ultima/ultima4/map/tileview.cpp
@@ -66,7 +66,7 @@ void TileView::reinit() {
// Scratchpad needs to be re-inited if we rescale...
if (_animated) {
delete _animated;
- _animated = NULL;
+ _animated = nullptr;
}
_animated = Image::create(SCALED(_tileWidth), SCALED(_tileHeight), false, Image::HARDWARE);
}
diff --git a/engines/ultima/ultima4/sound/music.cpp b/engines/ultima/ultima4/sound/music.cpp
index cd3c6a4c88..1a38882141 100644
--- a/engines/ultima/ultima4/sound/music.cpp
+++ b/engines/ultima/ultima4/sound/music.cpp
@@ -221,7 +221,7 @@ void Music::destroy_sys() {
bool Music::load_sys(const Common::String &pathName) {
delete _playing;
- _playing = NULL;
+ _playing = nullptr;
if (pathName.hasSuffixIgnoreCase(".it")) {
warning("TODO: Play music file - %s", pathName.c_str());
diff --git a/engines/ultima/ultima4/sound/sound.cpp b/engines/ultima/ultima4/sound/sound.cpp
index 091be475b4..f1bb6e0b8a 100644
--- a/engines/ultima/ultima4/sound/sound.cpp
+++ b/engines/ultima/ultima4/sound/sound.cpp
@@ -94,7 +94,7 @@ bool SoundManager::load(Sound sound) {
if (!Music::_functional || !settings._soundVol)
return false;
- if (_soundChunk[sound] == NULL) {
+ if (_soundChunk[sound] == nullptr) {
Common::String pathname(u4find_sound(_soundFilenames[sound]));
Common::String basename = pathname.substr(pathname.findLastOf("/") + 1);
if (!basename.empty())
@@ -111,7 +111,7 @@ void SoundManager::play(Sound sound, bool onlyOnce, int specificDurationInTicks)
if (!Music::_functional || !settings._soundVol)
return;
- if (_soundChunk[sound] == NULL) {
+ if (_soundChunk[sound] == nullptr) {
if (!load(sound)) {
return;
}
diff --git a/engines/ultima/ultima4/sound/sound.h b/engines/ultima/ultima4/sound/sound.h
index b9f86992fa..78c2a4737b 100644
--- a/engines/ultima/ultima4/sound/sound.h
+++ b/engines/ultima/ultima4/sound/sound.h
@@ -61,8 +61,8 @@ enum Sound {
SOUND_MAX
};
-int soundInit(void);
-void soundDelete(void);
+int soundInit();
+void soundDelete();
void soundPlay(Sound sound, bool onlyOnce = true, int specificDurationInTicks = -1);
diff --git a/engines/ultima/ultima4/sound/sound_p.h b/engines/ultima/ultima4/sound/sound_p.h
index dd7bb1526a..6abe336c2c 100644
--- a/engines/ultima/ultima4/sound/sound_p.h
+++ b/engines/ultima/ultima4/sound/sound_p.h
@@ -37,7 +37,7 @@ class SoundManager {
public:
~SoundManager();
static SoundManager *getInstance();
- int init(void);
+ int init();
void play(Sound sound, bool onlyOnce = true, int specificDurationInTicks = -1);
void stop(int channel = 1);
private:
More information about the Scummvm-git-logs
mailing list