diff --git a/Source/objects.cpp b/Source/objects.cpp index dd3ded867..7f6a5bfcc 100644 --- a/Source/objects.cpp +++ b/Source/objects.cpp @@ -299,7 +299,7 @@ bool RndLocOk(int xp, int yp) return leveltype != DTYPE_CATHEDRAL || dPiece[xp][yp] <= 126 || dPiece[xp][yp] >= 144; } -static bool WallTrapLocOkK(int xp, int yp) +bool CanPlaceWallTrap(int xp, int yp) { if ((dFlags[xp][yp] & BFLAG_POPULATED) != 0) return false; @@ -519,7 +519,7 @@ void InitRndBarrels() } } -void add_crypt_objs(int x1, int y1, int x2, int y2) +void AddCryptObjects(int x1, int y1, int x2, int y2) { for (int j = y1; j < y2; j++) { for (int i = x1; i < x2; i++) { @@ -598,7 +598,7 @@ void AddObjTraps() while (IsTileNotSolid({ xp, j })) // BUGFIX: check if xp >= 0 xp--; - if (!WallTrapLocOkK(xp, j) || i - xp <= 1) + if (!CanPlaceWallTrap(xp, j) || i - xp <= 1) continue; AddObject(OBJ_TRAPL, { xp, j }); @@ -611,7 +611,7 @@ void AddObjTraps() while (IsTileNotSolid({ i, yp })) // BUGFIX: check if yp >= 0 yp--; - if (!WallTrapLocOkK(i, yp) || j - yp <= 1) + if (!CanPlaceWallTrap(i, yp) || j - yp <= 1) continue; AddObject(OBJ_TRAPR, { i, yp }); @@ -1191,7 +1191,7 @@ void AddTrap(int i) Objects[i]._oVar4 = 0; } -void AddObjLight(int i, int r) +void AddObjectLight(int i, int r) { if (ApplyObjectLighting) { DoLighting(Objects[i].position, r, -1); @@ -1408,7 +1408,7 @@ void AddMushPatch() } } -void Obj_Light(int i, int lightRadius) +void UpdateObjectLight(int i, int lightRadius) { if (Objects[i]._oVar1 == -1) { return; @@ -1441,7 +1441,7 @@ void Obj_Light(int i, int lightRadius) } } -void Obj_Circle(int i) +void UpdateCircle(int i) { if (Players[MyPlayerId].position.tile != Objects[i].position) { if (Objects[i]._otype == OBJ_MCIRCLE1) @@ -1478,7 +1478,7 @@ void Obj_Circle(int i) } } -void Obj_StopAnim(int i) +void ObjectStopAnim(int i) { if (Objects[i]._oAnimFrame == Objects[i]._oAnimLen) { Objects[i]._oAnimCnt = 0; @@ -1486,7 +1486,7 @@ void Obj_StopAnim(int i) } } -void Obj_Door(int i) +void UpdateDoor(int i) { if (Objects[i]._oVar4 == 0) { Objects[i]._oSelFlag = 3; @@ -1505,7 +1505,7 @@ void Obj_Door(int i) Objects[i]._oMissFlag = true; } -void Obj_Sarc(int i) +void UpdateSarcoffagus(int i) { if (Objects[i]._oAnimFrame == Objects[i]._oAnimLen) Objects[i]._oAnimFlag = 0; @@ -1524,7 +1524,7 @@ void ActivateTrapLine(int ttype, int tid) } } -void Obj_FlameTrap(int i) +void UpdateFlameTrap(int i) { if (Objects[i]._oVar2 != 0) { if (Objects[i]._oVar4 != 0) { @@ -1578,7 +1578,7 @@ void Obj_FlameTrap(int i) } } -void Obj_BCrossDamage(int i) +void UpdateBurningCrossDamage(int i) { int damage[4] = { 6, 8, 10, 12 }; @@ -1682,7 +1682,7 @@ void ObjL2Special(int x1, int y1, int x2, int y2) } } -void objects_set_door_piece(Point position) +void SetDoorPiece(Point position) { int pn = dPiece[position.x][position.y] - 1; @@ -1795,7 +1795,7 @@ void DoorSet(Point position, bool isLeftDoor) * @param doorPos Map tile where the door is in its closed position * @return true if the door is free to be closed, false if anything is blocking it */ -static inline bool IsDoorClear(const Point &doorPosition) +inline bool IsDoorClear(const Point &doorPosition) { return dDead[doorPosition.x][doorPosition.y] == 0 && dMonster[doorPosition.x][doorPosition.y] == 0 @@ -1829,7 +1829,7 @@ void OperateL1RDoor(int pnum, int oi, bool sendflag) } else { dSpecial[door.position.x][door.position.y] = 2; } - objects_set_door_piece(door.position + Direction::DIR_NE); + SetDoorPiece(door.position + Direction::DIR_NE); door._oAnimFrame += 2; door._oPreFlag = true; DoorSet(door.position + Direction::DIR_NW, false); @@ -1910,7 +1910,7 @@ void OperateL1LDoor(int pnum, int oi, bool sendflag) } else { dSpecial[door.position.x][door.position.y] = 1; } - objects_set_door_piece(door.position + Direction::DIR_NW); + SetDoorPiece(door.position + Direction::DIR_NW); door._oAnimFrame += 2; door._oPreFlag = true; DoorSet(door.position + Direction::DIR_NE, true); @@ -4274,24 +4274,24 @@ void SyncL1Doors(ObjectStruct &door) if (isLeftDoor) { ObjSetMicro(door.position, door._oVar1 == 214 ? 408 : 393); dSpecial[door.position.x][door.position.y] = 7; - objects_set_door_piece(door.position + Direction::DIR_NW); + SetDoorPiece(door.position + Direction::DIR_NW); DoorSet(door.position + Direction::DIR_NE, isLeftDoor); } else { ObjSetMicro(door.position, 395); dSpecial[door.position.x][door.position.y] = 8; - objects_set_door_piece(door.position + Direction::DIR_NE); + SetDoorPiece(door.position + Direction::DIR_NE); DoorSet(door.position + Direction::DIR_NW, isLeftDoor); } } else { if (isLeftDoor) { ObjSetMicro(door.position, 206); dSpecial[door.position.x][door.position.y] = 1; - objects_set_door_piece(door.position + Direction::DIR_NW); + SetDoorPiece(door.position + Direction::DIR_NW); DoorSet(door.position + Direction::DIR_NE, isLeftDoor); } else { ObjSetMicro(door.position, 209); dSpecial[door.position.x][door.position.y] = 2; - objects_set_door_piece(door.position + Direction::DIR_NE); + SetDoorPiece(door.position + Direction::DIR_NE); DoorSet(door.position + Direction::DIR_NW, isLeftDoor); } } @@ -4462,7 +4462,7 @@ void InitObjects() AddObject(OBJ_SIGNCHEST, { 2 * setpc_x + 26, 2 * setpc_y + 19 }); InitRndLocBigObj(10, 15, OBJ_SARC); if (currlevel >= 21) - add_crypt_objs(0, 0, MAXDUNX, MAXDUNY); + AddCryptObjects(0, 0, MAXDUNX, MAXDUNY); else AddL1Objs(0, 0, MAXDUNX, MAXDUNY); InitRndBarrels(); @@ -4648,16 +4648,16 @@ void AddObject(_object_id objType, Point objPos) case OBJ_CANDLE1: case OBJ_CANDLE2: case OBJ_BOOKCANDLE: - AddObjLight(oi, 5); + AddObjectLight(oi, 5); break; case OBJ_STORYCANDLE: - AddObjLight(oi, 3); + AddObjectLight(oi, 3); break; case OBJ_TORCHL: case OBJ_TORCHR: case OBJ_TORCHL2: case OBJ_TORCHR2: - AddObjLight(oi, 8); + AddObjectLight(oi, 8); break; case OBJ_L1LDOOR: case OBJ_L1RDOOR: @@ -4760,7 +4760,7 @@ void AddObject(_object_id objType, Point objPos) case OBJ_BCROSS: case OBJ_TBCROSS: AddBrnCross(oi); - AddObjLight(oi, 5); + AddObjectLight(oi, 5); break; case OBJ_PEDISTAL: AddPedistal(oi); @@ -4831,15 +4831,15 @@ void ProcessObjects() int oi = ActiveObjects[i]; switch (Objects[oi]._otype) { case OBJ_L1LIGHT: - Obj_Light(oi, 10); + UpdateObjectLight(oi, 10); break; case OBJ_SKFIRE: case OBJ_CANDLE2: case OBJ_BOOKCANDLE: - Obj_Light(oi, 5); + UpdateObjectLight(oi, 5); break; case OBJ_STORYCANDLE: - Obj_Light(oi, 3); + UpdateObjectLight(oi, 3); break; case OBJ_CRUX1: case OBJ_CRUX2: @@ -4848,7 +4848,7 @@ void ProcessObjects() case OBJ_BARRELEX: case OBJ_SHRINEL: case OBJ_SHRINER: - Obj_StopAnim(oi); + ObjectStopAnim(oi); break; case OBJ_L1LDOOR: case OBJ_L1RDOOR: @@ -4856,19 +4856,19 @@ void ProcessObjects() case OBJ_L2RDOOR: case OBJ_L3LDOOR: case OBJ_L3RDOOR: - Obj_Door(oi); + UpdateDoor(oi); break; case OBJ_TORCHL: case OBJ_TORCHR: case OBJ_TORCHL2: case OBJ_TORCHR2: - Obj_Light(oi, 8); + UpdateObjectLight(oi, 8); break; case OBJ_SARC: - Obj_Sarc(oi); + UpdateSarcoffagus(oi); break; case OBJ_FLAMEHOLE: - Obj_FlameTrap(oi); + UpdateFlameTrap(oi); break; case OBJ_TRAPL: case OBJ_TRAPR: @@ -4876,12 +4876,12 @@ void ProcessObjects() break; case OBJ_MCIRCLE1: case OBJ_MCIRCLE2: - Obj_Circle(oi); + UpdateCircle(oi); break; case OBJ_BCROSS: case OBJ_TBCROSS: - Obj_Light(oi, 10); - Obj_BCrossDamage(oi); + UpdateObjectLight(oi, 10); + UpdateBurningCrossDamage(oi); break; default: break; diff --git a/Source/options.cpp b/Source/options.cpp index adcbdcd84..072a2eeea 100644 --- a/Source/options.cpp +++ b/Source/options.cpp @@ -59,7 +59,7 @@ CSimpleIni &GetIni() return ini; } -static bool IniChanged = false; +bool IniChanged = false; /** * @brief Checks if a ini entry is changed by comparing value before and after @@ -68,30 +68,31 @@ class IniChangedChecker { public: IniChangedChecker(const char *sectionName, const char *keyName) { - this->sectionName = sectionName; - this->keyName = keyName; + this->sectionName_ = sectionName; + this->keyName_ = keyName; std::list values; if (!GetIni().GetAllValues(sectionName, keyName, values)) { // No entry found in original ini => new entry => changed IniChanged = true; } - auto value = GetIni().GetValue(sectionName, keyName); + const auto *value = GetIni().GetValue(sectionName, keyName); if (value != nullptr) - oldValue = value; + oldValue_ = value; } ~IniChangedChecker() { - auto value = GetIni().GetValue(sectionName, keyName); + const auto *value = GetIni().GetValue(sectionName_, keyName_); std::string newValue; if (value != nullptr) newValue = value; - if (oldValue != newValue) + if (oldValue_ != newValue) IniChanged = true; } + private: - std::string oldValue; - const char *sectionName; - const char *keyName; + std::string oldValue_; + const char *sectionName_; + const char *keyName_; }; int GetIniInt(const char *keyname, const char *valuename, int defaultValue) diff --git a/Source/pack.cpp b/Source/pack.cpp index 3618a4575..ed510bc0e 100644 --- a/Source/pack.cpp +++ b/Source/pack.cpp @@ -15,7 +15,7 @@ namespace devilution { namespace { -static void VerifyGoldSeeds(PlayerStruct &player) +void VerifyGoldSeeds(PlayerStruct &player) { for (int i = 0; i < player._pNumInv; i++) { if (player.InvList[i].IDidx != IDI_GOLD) diff --git a/Source/palette.cpp b/Source/palette.cpp index b3fe965bd..372e66960 100644 --- a/Source/palette.cpp +++ b/Source/palette.cpp @@ -24,7 +24,7 @@ namespace { /** Specifies whether the palette has max brightness. */ bool sgbFadedIn = true; -static void LoadGamma() +void LoadGamma() { int gammaValue = sgOptions.Graphics.nGammaCorrection; @@ -36,7 +36,7 @@ static void LoadGamma() sgOptions.Graphics.nGammaCorrection = gammaValue - gammaValue % 5; } -static Uint8 FindBestMatchForColor(SDL_Color *palette, SDL_Color color, int skipFrom, int skipTo) +Uint8 FindBestMatchForColor(SDL_Color *palette, SDL_Color color, int skipFrom, int skipTo) { Uint8 best; Uint32 bestDiff = SDL_MAX_UINT32; @@ -69,7 +69,7 @@ static Uint8 FindBestMatchForColor(SDL_Color *palette, SDL_Color color, int skip * @param skipTo Do not use colors between skipFrom and this index * @param toUpdate Only update the first n colors */ -static void GenerateBlendedLookupTable(SDL_Color *palette, int skipFrom, int skipTo, int toUpdate = 256) +void GenerateBlendedLookupTable(SDL_Color *palette, int skipFrom, int skipTo, int toUpdate = 256) { for (int i = 0; i < 256; i++) { for (int j = 0; j < 256; j++) { @@ -100,7 +100,7 @@ static void GenerateBlendedLookupTable(SDL_Color *palette, int skipFrom, int ski * @param from First color index of the range * @param to First color index of the range */ -static void CycleColors(int from, int to) +void CycleColors(int from, int to) { { SDL_Color col = system_palette[from]; @@ -134,7 +134,7 @@ static void CycleColors(int from, int to) * @param from First color index of the range * @param to First color index of the range */ -static void CycleColorsReverse(int from, int to) +void CycleColorsReverse(int from, int to) { { SDL_Color col = system_palette[to]; @@ -355,41 +355,41 @@ void palette_update_caves() void palette_update_crypt() { - static int dword_6E2D58 = 0; - static int dword_6E2D54 = 0; + static int LaveDelay = 0; + static int GlowDelay = 0; - if (dword_6E2D58 > 1) { + if (LaveDelay > 1) { CycleColorsReverse(1, 15); - dword_6E2D58 = 0; + LaveDelay = 0; } else { - dword_6E2D58++; + LaveDelay++; } - if (dword_6E2D54 > 0) { + if (GlowDelay > 0) { CycleColorsReverse(16, 31); palette_update(); - dword_6E2D54++; + GlowDelay++; } else { - dword_6E2D54 = 1; + GlowDelay = 1; } } void palette_update_hive() { - static int dword_6E2D60 = 0; - static int dword_6E2D5C = 0; + static int WaveDelay = 0; + static int BubbleDelay = 0; - if (dword_6E2D60 == 2) { + if (WaveDelay == 2) { CycleColorsReverse(1, 8); - dword_6E2D60 = 0; + WaveDelay = 0; } else { - dword_6E2D60++; + WaveDelay++; } - if (dword_6E2D5C == 2) { + if (BubbleDelay == 2) { CycleColorsReverse(9, 15); palette_update(); - dword_6E2D5C = 0; + BubbleDelay = 0; } else { - dword_6E2D5C++; + BubbleDelay++; } } diff --git a/Source/path.cpp b/Source/path.cpp index a985d4351..7874c0ee2 100644 --- a/Source/path.cpp +++ b/Source/path.cpp @@ -9,6 +9,7 @@ #include "objects.h" namespace devilution { + namespace { /** A linked list of the A* frontier, sorted by distance */ @@ -16,7 +17,7 @@ PATHNODE *path_2_nodes; /** * @brief return a node for a position on the frontier, or NULL if not found */ -PATHNODE *path_get_node1(Point targetPosition) +PATHNODE *GetNode1(Point targetPosition) { PATHNODE *result = path_2_nodes->NextNode; while (result != nullptr) { @@ -30,7 +31,7 @@ PATHNODE *path_get_node1(Point targetPosition) /** * @brief insert pPath into the frontier (keeping the frontier sorted by total distance) */ -void path_next_node(PATHNODE *pPath) +void NextNode(PATHNODE *pPath) { if (path_2_nodes->NextNode == nullptr) { path_2_nodes->NextNode = pPath; @@ -53,7 +54,7 @@ PATHNODE *pnode_ptr; /** * @brief return a node for this position if it was visited, or NULL if not found */ -PATHNODE *path_get_node2(Point targetPosition) +PATHNODE *GetNode2(Point targetPosition) { PATHNODE *result = pnode_ptr->NextNode; while (result != nullptr) { @@ -89,7 +90,7 @@ uint32_t gdwCurNodes; /** * @brief zero one of the preallocated nodes and return a pointer to it, or NULL if none are available */ -PATHNODE *path_new_step() +PATHNODE *NewStep() { if (gdwCurNodes >= MAXPATHNODES) return nullptr; @@ -107,7 +108,7 @@ uint32_t gdwCurPathStep; /** * @brief push pPath onto the pnode_tblptr stack */ -void path_push_active_step(PATHNODE *pPath) +void PushActiveStep(PATHNODE *pPath) { assert(gdwCurPathStep < MAXPATHNODES); pnode_tblptr[gdwCurPathStep] = pPath; @@ -117,7 +118,7 @@ void path_push_active_step(PATHNODE *pPath) /** * @brief pop and return a node from the pnode_tblptr stack */ -PATHNODE *path_pop_active_step() +PATHNODE *PopActiveStep() { gdwCurPathStep--; return pnode_tblptr[gdwCurPathStep]; @@ -130,7 +131,7 @@ PATHNODE *path_pop_active_step() * of sqrt(2). That's approximately 1.5, so they multiply all step costs by 2, * except diagonal steps which are times 3 */ -int path_check_equal(Point startPosition, Point destinationPosition) +int CheckEqual(Point startPosition, Point destinationPosition) { if (startPosition.x == destinationPosition.x || startPosition.y == destinationPosition.y) return 2; @@ -141,22 +142,22 @@ int path_check_equal(Point startPosition, Point destinationPosition) /** * @brief update all path costs using depth-first search starting at pPath */ -void path_set_coords(PATHNODE *pPath) +void SetCoords(PATHNODE *pPath) { - path_push_active_step(pPath); + PushActiveStep(pPath); // while there are path nodes to check while (gdwCurPathStep > 0) { - PATHNODE *pathOld = path_pop_active_step(); + PATHNODE *pathOld = PopActiveStep(); for (auto *pathAct : pathOld->Child) { if (pathAct == nullptr) break; - if (pathOld->g + path_check_equal(pathOld->position, pathAct->position) < pathAct->g) { + if (pathOld->g + CheckEqual(pathOld->position, pathAct->position) < pathAct->g) { if (path_solid_pieces(pathOld->position, pathAct->position)) { pathAct->Parent = pathOld; - pathAct->g = pathOld->g + path_check_equal(pathOld->position, pathAct->position); + pathAct->g = pathOld->g + CheckEqual(pathOld->position, pathAct->position); pathAct->f = pathAct->g + pathAct->h; - path_push_active_step(pathAct); + PushActiveStep(pathAct); } } } @@ -176,14 +177,14 @@ void path_set_coords(PATHNODE *pPath) */ int8_t GetPathDirection(Point startPosition, Point destinationPosition) { - constexpr int8_t path_directions[9] = { 5, 1, 6, 2, 0, 3, 8, 4, 7 }; - return path_directions[3 * (destinationPosition.y - startPosition.y) + 4 + destinationPosition.x - startPosition.x]; + constexpr int8_t PathDirections[9] = { 5, 1, 6, 2, 0, 3, 8, 4, 7 }; + return PathDirections[3 * (destinationPosition.y - startPosition.y) + 4 + destinationPosition.x - startPosition.x]; } /** * @brief heuristic, estimated cost from startPosition to destinationPosition. */ -int path_get_heuristic_cost(Point startPosition, Point destinationPosition) +int GetHeuristicCost(Point startPosition, Point destinationPosition) { // see path_check_equal for why this is times 2 return 2 * startPosition.ManhattanDistance(destinationPosition); @@ -197,13 +198,13 @@ int path_get_heuristic_cost(Point startPosition, Point destinationPosition) * @param destinationPosition where we hope to end up * @return true if step successfully added, false if we ran out of nodes to use */ -bool path_parent_path(PATHNODE *pPath, Point candidatePosition, Point destinationPosition) +bool ParentPath(PATHNODE *pPath, Point candidatePosition, Point destinationPosition) { - int nextG = pPath->g + path_check_equal(pPath->position, candidatePosition); + int nextG = pPath->g + CheckEqual(pPath->position, candidatePosition); // 3 cases to consider // case 1: (dx,dy) is already on the frontier - PATHNODE *dxdy = path_get_node1(candidatePosition); + PATHNODE *dxdy = GetNode1(candidatePosition); if (dxdy != nullptr) { int i; for (i = 0; i < 8; i++) { @@ -221,7 +222,7 @@ bool path_parent_path(PATHNODE *pPath, Point candidatePosition, Point destinatio } } else { // case 2: (dx,dy) was already visited - dxdy = path_get_node2(candidatePosition); + dxdy = GetNode2(candidatePosition); if (dxdy != nullptr) { int i; for (i = 0; i < 8; i++) { @@ -235,20 +236,20 @@ bool path_parent_path(PATHNODE *pPath, Point candidatePosition, Point destinatio dxdy->g = nextG; dxdy->f = nextG + dxdy->h; // already explored, so re-update others starting from that node - path_set_coords(dxdy); + SetCoords(dxdy); } } else { // case 3: (dx,dy) is totally new - dxdy = path_new_step(); + dxdy = NewStep(); if (dxdy == nullptr) return false; dxdy->Parent = pPath; dxdy->g = nextG; - dxdy->h = path_get_heuristic_cost(candidatePosition, destinationPosition); + dxdy->h = GetHeuristicCost(candidatePosition, destinationPosition); dxdy->f = nextG + dxdy->h; dxdy->position = candidatePosition; // add it to the frontier - path_next_node(dxdy); + NextNode(dxdy); int i; for (i = 0; i < 8; i++) { @@ -266,13 +267,13 @@ bool path_parent_path(PATHNODE *pPath, Point candidatePosition, Point destinatio * * @return false if we ran out of preallocated nodes to use, else true */ -bool path_get_path(const std::function &posOk, PATHNODE *pPath, Point destination) +bool GetPath(const std::function &posOk, PATHNODE *pPath, Point destination) { for (auto dir : PathDirs) { Point tile = pPath->position + dir; bool ok = posOk(tile); if ((ok && path_solid_pieces(pPath->position, tile)) || (!ok && tile == destination)) { - if (!path_parent_path(pPath, tile, destination)) + if (!ParentPath(pPath, tile, destination)) return false; } } @@ -315,16 +316,16 @@ int FindPath(const std::function &posOk, Point startPosition, Point * for reconstructing the path after the A* search is done. The longest * possible path is actually 24 steps, even though we can fit 25 */ - static int8_t pnode_vals[MAX_PATH_LENGTH]; + static int8_t pnodeVals[MAX_PATH_LENGTH]; // clear all nodes, create root nodes for the visited/frontier linked lists gdwCurNodes = 0; - path_2_nodes = path_new_step(); - pnode_ptr = path_new_step(); + path_2_nodes = NewStep(); + pnode_ptr = NewStep(); gdwCurPathStep = 0; - PATHNODE *pathStart = path_new_step(); + PATHNODE *pathStart = NewStep(); pathStart->g = 0; - pathStart->h = path_get_heuristic_cost(startPosition, destinationPosition); + pathStart->h = GetHeuristicCost(startPosition, destinationPosition); pathStart->f = pathStart->h + pathStart->g; pathStart->position = startPosition; path_2_nodes->NextNode = pathStart; @@ -338,19 +339,19 @@ int FindPath(const std::function &posOk, Point startPosition, Point while (current->Parent != nullptr) { if (pathLength >= MAX_PATH_LENGTH) break; - pnode_vals[pathLength++] = GetPathDirection(current->Parent->position, current->position); + pnodeVals[pathLength++] = GetPathDirection(current->Parent->position, current->position); current = current->Parent; } if (pathLength != MAX_PATH_LENGTH) { int i; for (i = 0; i < pathLength; i++) - path[i] = pnode_vals[pathLength - i - 1]; + path[i] = pnodeVals[pathLength - i - 1]; return i; } return 0; } // ran out of nodes, abort! - if (!path_get_path(posOk, nextNode, destinationPosition)) + if (!GetPath(posOk, nextNode, destinationPosition)) return 0; } // frontier is empty, no path! @@ -382,7 +383,7 @@ bool path_solid_pieces(Point startPosition, Point destinationPosition) #ifdef RUN_TESTS int TestPathGetHeuristicCost(Point startPosition, Point destinationPosition) { - return path_get_heuristic_cost(startPosition, destinationPosition); + return GetHeuristicCost(startPosition, destinationPosition); } #endif diff --git a/Source/player.cpp b/Source/player.cpp index 24b19782b..447f56d5b 100644 --- a/Source/player.cpp +++ b/Source/player.cpp @@ -407,7 +407,7 @@ void SetPlayerGPtrs(const char *path, std::unique_ptr &data, std::array< } } -static void ClearPlrPVars(PlayerStruct &player) +void ClearStateVariables(PlayerStruct &player) { player.position.temp = { 0, 0 }; player.tempDirection = DIR_S; @@ -436,7 +436,7 @@ void StartWalkStand(int pnum) } } -void PM_ChangeOffset(int pnum) +void ChangeOffset(int pnum) { if ((DWORD)pnum >= MAX_PLRS) { app_fatal("PM_ChangeOffset: illegal player %i", pnum); @@ -569,7 +569,7 @@ void StartSpell(int pnum, Direction d, int cx, int cy) player._pVar4 = GetSpellLevel(pnum, player._pSpell); } -static void RespawnDeadItem(ItemStruct *itm, Point target) +void RespawnDeadItem(ItemStruct *itm, Point target) { if (ActiveItemCount >= MAXITEMS) return; @@ -585,7 +585,7 @@ static void RespawnDeadItem(ItemStruct *itm, Point target) itm->_itype = ITYPE_NONE; } -static void PlrDeadItem(PlayerStruct &player, ItemStruct *itm, Displacement direction) +void DeadItem(PlayerStruct &player, ItemStruct *itm, Displacement direction) { if (itm->isEmpty()) return; @@ -613,7 +613,7 @@ static void PlrDeadItem(PlayerStruct &player, ItemStruct *itm, Displacement dire } } -static int DropGold(int pnum, int amount, bool skipFullStacks) +int DropGold(int pnum, int amount, bool skipFullStacks) { auto &player = Players[pnum]; @@ -629,7 +629,7 @@ static int DropGold(int pnum, int amount, bool skipFullStacks) GetGoldSeed(pnum, &player.HoldItem); SetPlrHandGoldCurs(&player.HoldItem); player.HoldItem._ivalue = amount; - PlrDeadItem(player, &player.HoldItem, { 0, 0 }); + DeadItem(player, &player.HoldItem, { 0, 0 }); return 0; } @@ -639,7 +639,7 @@ static int DropGold(int pnum, int amount, bool skipFullStacks) GetGoldSeed(pnum, &player.HoldItem); SetPlrHandGoldCurs(&player.HoldItem); player.HoldItem._ivalue = item._ivalue; - PlrDeadItem(player, &player.HoldItem, { 0, 0 }); + DeadItem(player, &player.HoldItem, { 0, 0 }); i = -1; } @@ -693,7 +693,7 @@ void InitLevelChange(int pnum) /** * @brief Continue movement towards new tile */ -bool PM_DoWalk(int pnum, int variant) +bool DoWalk(int pnum, int variant) { if ((DWORD)pnum >= MAX_PLRS) { app_fatal("PM_DoWalk: illegal player %i", pnum); @@ -747,7 +747,7 @@ bool PM_DoWalk(int pnum, int variant) StartStand(pnum, player.tempDirection); } - ClearPlrPVars(player); + ClearStateVariables(player); //Reset the "sub-tile" position of the player's light entry to 0 if (leveltype != DTYPE_TOWN) { @@ -757,11 +757,11 @@ bool PM_DoWalk(int pnum, int variant) AutoGoldPickup(pnum); return true; } //We didn't reach new tile so update player's "sub-tile" position - PM_ChangeOffset(pnum); + ChangeOffset(pnum); return false; } -static bool WeaponDurDecay(int pnum, int ii) +bool WeaponDecay(int pnum, int ii) { auto &player = Players[pnum]; @@ -778,15 +778,15 @@ static bool WeaponDurDecay(int pnum, int ii) return false; } -bool WeaponDur(int pnum, int durrnd) +bool DamageWeapon(int pnum, int durrnd) { if (pnum != MyPlayerId) { return false; } - if (WeaponDurDecay(pnum, INVLOC_HAND_LEFT)) + if (WeaponDecay(pnum, INVLOC_HAND_LEFT)) return true; - if (WeaponDurDecay(pnum, INVLOC_HAND_RIGHT)) + if (WeaponDecay(pnum, INVLOC_HAND_RIGHT)) return true; if (GenerateRnd(durrnd) != 0) { @@ -1201,7 +1201,7 @@ bool PlrHitObj(int pnum, int mx, int my) return false; } -bool PM_DoAttack(int pnum) +bool DoAttack(int pnum) { if ((DWORD)pnum >= MAX_PLRS) { app_fatal("PM_DoAttack: illegal player %i", pnum); @@ -1290,23 +1290,23 @@ bool PM_DoAttack(int pnum) } } - if (didhit && WeaponDur(pnum, 30)) { + if (didhit && DamageWeapon(pnum, 30)) { StartStand(pnum, player._pdir); - ClearPlrPVars(player); + ClearStateVariables(player); return true; } } if (player.AnimInfo.CurrentFrame == player._pAFrames) { StartStand(pnum, player._pdir); - ClearPlrPVars(player); + ClearStateVariables(player); return true; } return false; } -bool PM_DoRangeAttack(int pnum) +bool DoRangeAttack(int pnum) { if ((DWORD)pnum >= MAX_PLRS) { app_fatal("PM_DoRangeAttack: illegal player %i", pnum); @@ -1361,16 +1361,16 @@ bool PM_DoRangeAttack(int pnum) PlaySfxLoc(arrows != 1 ? IS_STING1 : PS_BFIRE, player.position.tile); } - if (WeaponDur(pnum, 40)) { + if (DamageWeapon(pnum, 40)) { StartStand(pnum, player._pdir); - ClearPlrPVars(player); + ClearStateVariables(player); return true; } } if (player.AnimInfo.CurrentFrame >= player._pAFrames) { StartStand(pnum, player._pdir); - ClearPlrPVars(player); + ClearStateVariables(player); return true; } return false; @@ -1412,7 +1412,7 @@ void ShieldDur(int pnum) } } -bool PM_DoBlock(int pnum) +bool DoBlock(int pnum) { if ((DWORD)pnum >= MAX_PLRS) { app_fatal("PM_DoBlock: illegal player %i", pnum); @@ -1421,7 +1421,7 @@ bool PM_DoBlock(int pnum) if (player.AnimInfo.CurrentFrame >= player._pBFrames) { StartStand(pnum, player._pdir); - ClearPlrPVars(player); + ClearStateVariables(player); if (GenerateRnd(10) == 0) { ShieldDur(pnum); @@ -1432,7 +1432,7 @@ bool PM_DoBlock(int pnum) return false; } -static void ArmorDur(int pnum) +void DamageArmor(int pnum) { int a; ItemStruct *pi; @@ -1442,7 +1442,7 @@ static void ArmorDur(int pnum) } if ((DWORD)pnum >= MAX_PLRS) { - app_fatal("ArmorDur: illegal player %i", pnum); + app_fatal("DamageArmor: illegal player %i", pnum); } auto &player = Players[pnum]; @@ -1481,7 +1481,7 @@ static void ArmorDur(int pnum) CalcPlrInv(pnum, true); } -bool PM_DoSpell(int pnum) +bool DoSpell(int pnum) { if ((DWORD)pnum >= MAX_PLRS) { app_fatal("PM_DoSpell: illegal player %i", pnum); @@ -1506,14 +1506,14 @@ bool PM_DoSpell(int pnum) if (currentSpellFrame >= player._pSFrames) { StartStand(pnum, player._pdir); - ClearPlrPVars(player); + ClearStateVariables(player); return true; } return false; } -bool PM_DoGotHit(int pnum) +bool DoGotHit(int pnum) { if ((DWORD)pnum >= MAX_PLRS) { app_fatal("PM_DoGotHit: illegal player %i", pnum); @@ -1522,9 +1522,9 @@ bool PM_DoGotHit(int pnum) if (player.AnimInfo.CurrentFrame >= player._pHFrames) { StartStand(pnum, player._pdir); - ClearPlrPVars(player); + ClearStateVariables(player); if (GenerateRnd(4) != 0) { - ArmorDur(pnum); + DamageArmor(pnum); } return true; @@ -1533,7 +1533,7 @@ bool PM_DoGotHit(int pnum) return false; } -bool PM_DoDeath(int pnum) +bool DoDeath(int pnum) { if ((DWORD)pnum >= MAX_PLRS) { app_fatal("PM_DoDeath: illegal player %i", pnum); @@ -1980,7 +1980,7 @@ void ValidatePlayer() myPlayer._pMemSpells &= msk; } -static void CheckCheatStats(PlayerStruct &player) +void CheckCheatStats(PlayerStruct &player) { if (player._pStrength > 750) { player._pStrength = 750; @@ -2792,7 +2792,7 @@ void InitPlayer(int pnum, bool firstTime) player.position.offset = { 0, 0 }; player.position.velocity = { 0, 0 }; - ClearPlrPVars(player); + ClearStateVariables(player); if (player._pHitPoints >> 6 > 0) { player._pmode = PM_STAND; @@ -3126,7 +3126,7 @@ StartPlayerKill(int pnum, int earflag) deathdelay = 30; if (pcurs >= CURSOR_FIRSTITEM) { - PlrDeadItem(player, &player.HoldItem, { 0, 0 }); + DeadItem(player, &player.HoldItem, { 0, 0 }); NewCursor(CURSOR_HAND); } @@ -3157,13 +3157,13 @@ StartPlayerKill(int pnum, int earflag) ear._ivalue = player._pLevel; if (FindGetItem(IDI_EAR, ear._iCreateInfo, ear._iSeed) == -1) { - PlrDeadItem(player, &ear, { 0, 0 }); + DeadItem(player, &ear, { 0, 0 }); } } else { Direction pdd = player._pdir; for (auto &item : player.InvBody) { pdd = left[pdd]; - PlrDeadItem(player, &item, Displacement::fromDirection(pdd)); + DeadItem(player, &item, Displacement::fromDirection(pdd)); } CalcPlrInv(pnum, false); @@ -3194,7 +3194,7 @@ void StripTopGold(int pnum) player.HoldItem._ivalue = val; SetPlrHandGoldCurs(&player.HoldItem); if (!GoldAutoPlace(player)) - PlrDeadItem(player, &player.HoldItem, { 0, 0 }); + DeadItem(player, &player.HoldItem, { 0, 0 }); } } } @@ -3454,25 +3454,25 @@ void ProcessPlayers() case PM_WALK: case PM_WALK2: case PM_WALK3: - tplayer = PM_DoWalk(pnum, player._pmode); + tplayer = DoWalk(pnum, player._pmode); break; case PM_ATTACK: - tplayer = PM_DoAttack(pnum); + tplayer = DoAttack(pnum); break; case PM_RATTACK: - tplayer = PM_DoRangeAttack(pnum); + tplayer = DoRangeAttack(pnum); break; case PM_BLOCK: - tplayer = PM_DoBlock(pnum); + tplayer = DoBlock(pnum); break; case PM_SPELL: - tplayer = PM_DoSpell(pnum); + tplayer = DoSpell(pnum); break; case PM_GOTHIT: - tplayer = PM_DoGotHit(pnum); + tplayer = DoGotHit(pnum); break; case PM_DEATH: - tplayer = PM_DoDeath(pnum); + tplayer = DoDeath(pnum); break; } CheckNewPath(pnum, tplayer); @@ -4079,7 +4079,7 @@ void PlayDungMsgs() #ifdef RUN_TESTS bool TestPlayerDoGotHit(int pnum) { - return PM_DoGotHit(pnum); + return DoGotHit(pnum); } #endif diff --git a/Source/plrmsg.cpp b/Source/plrmsg.cpp index 539ed86fe..14ccbcbca 100644 --- a/Source/plrmsg.cpp +++ b/Source/plrmsg.cpp @@ -18,13 +18,13 @@ namespace { #define PMSG_COUNT 8 -static uint8_t plr_msg_slot; +uint8_t plr_msg_slot; _plrmsg plr_msgs[PMSG_COUNT]; /** Maps from player_num to text color, as used in chat messages. */ const UiFlags TextColorFromPlayerId[MAX_PLRS + 1] = { UIS_SILVER, UIS_SILVER, UIS_SILVER, UIS_SILVER, UIS_GOLD }; -static void PrintPlrMsg(const Surface &out, int x, int y, int width, char *text, uint16_t style) +void PrintChatMessage(const Surface &out, int x, int y, int width, char *text, uint16_t style) { int length = strlen(text); for (int i = 0; i < length; i++) { @@ -125,7 +125,7 @@ void DrawPlrMsg(const Surface &out) pMsg = plr_msgs; for (int i = 0; i < PMSG_COUNT; i++) { if (pMsg->str[0] != '\0') - PrintPlrMsg(out, x, y, width, pMsg->str, TextColorFromPlayerId[pMsg->player]); + PrintChatMessage(out, x, y, width, pMsg->str, TextColorFromPlayerId[pMsg->player]); pMsg++; y += 35; } diff --git a/Source/tmsg.cpp b/Source/tmsg.cpp index b908d1fcd..7f4462f5d 100644 --- a/Source/tmsg.cpp +++ b/Source/tmsg.cpp @@ -4,6 +4,7 @@ * Implementation of functionality transmitting chat messages. */ #include + #include "tmsg.h" #include "diablo.h" @@ -17,9 +18,9 @@ struct TMsg { uint8_t len; TMsg(uint32_t time, byte *data, uint8_t len) - : time(time) - , body(new byte[len]) - , len(len) + : time(time) + , body(new byte[len]) + , len(len) { memcpy(body.get(), data, len); }