Skip to content

Commit

Permalink
9 players stackpos bug
Browse files Browse the repository at this point in the history
Commited by MillhioreBT, further commited by kokekanon

Co-Authored-By: kokekanon <114332266+kokekanon@users.noreply.github.com>
  • Loading branch information
ralke23 and kokekanon committed Jun 7, 2023
1 parent 1c99242 commit 4473d68
Show file tree
Hide file tree
Showing 9 changed files with 112 additions and 162 deletions.
2 changes: 1 addition & 1 deletion src/definitions.h
Expand Up @@ -20,7 +20,7 @@
#ifndef FS_DEFINITIONS_H_877452FEC245450C9F96B8FD268D8963
#define FS_DEFINITIONS_H_877452FEC245450C9F96B8FD268D8963

static constexpr auto STATUS_SERVER_NAME = "GreedOT TFS";
static constexpr auto STATUS_SERVER_NAME = "Greed";
static constexpr auto STATUS_SERVER_VERSION = "1.5";
static constexpr auto STATUS_SERVER_DEVELOPERS = "ralke";

Expand Down
2 changes: 1 addition & 1 deletion src/game.cpp
Expand Up @@ -573,7 +573,7 @@ bool Game::removeCreature(Creature* creature, bool isLogout/* = true*/)
for (Creature* spectator : spectators) {
if (Player* player = spectator->getPlayer()) {
if (player->canSeeCreature(creature)) {
player->sendRemoveTileCreature(creature, tilePosition, oldStackPosVector[i++]);
player->sendRemoveTileThing(tilePosition, oldStackPosVector[i++]);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/luascript.cpp
Expand Up @@ -9713,7 +9713,7 @@ int LuaScriptInterface::luaPlayerSetGhostMode(lua_State* L)
Player* tmpPlayer = spectator->getPlayer();
if (tmpPlayer != player && !tmpPlayer->isAccessPlayer()) {
if (enabled) {
tmpPlayer->sendRemoveTileCreature(player, position, tile->getClientIndexOfCreature(tmpPlayer, player));
tmpPlayer->sendRemoveTileThing(position, tile->getClientIndexOfCreature(tmpPlayer, player));
} else {
tmpPlayer->sendCreatureAppear(player, position, showEffect);
}
Expand Down
7 changes: 4 additions & 3 deletions src/map.cpp
Expand Up @@ -327,9 +327,10 @@ void Map::moveCreature(Creature& creature, Tile& newTile, bool forceTeleport/* =
for (Creature* spectator : spectators) {
if (Player* tmpPlayer = spectator->getPlayer()) {
//Use the correct stackpos
int32_t stackpos = oldStackPosVector[i++];
if (stackpos != -1) {
tmpPlayer->sendCreatureMove(&creature, newPos, newTile.getClientIndexOfCreature(tmpPlayer, &creature), oldPos, stackpos, teleport);
int32_t oldStackPos = oldStackPosVector[i++];
if (oldStackPos != -1) {
tmpPlayer->sendCreatureMove(&creature, newPos, newTile.getClientIndexOfCreature(tmpPlayer, &creature),
oldPos, oldStackPos, teleport);
}
}
}
Expand Down
8 changes: 2 additions & 6 deletions src/player.h
Expand Up @@ -676,11 +676,7 @@ class Player final : public Creature, public Cylinder
client->sendUpdateTileCreature(creature->getPosition(), creature->getTile()->getClientIndexOfCreature(this, creature), creature);
}
}
void sendRemoveTileCreature(const Creature* creature, const Position& pos, int32_t stackpos) {
if (client) {
client->sendRemoveTileCreature(creature, pos, stackpos);
}
}

void sendUpdateTile(const Tile* tile, const Position& pos) {
if (client) {
client->sendUpdateTile(tile, pos);
Expand Down Expand Up @@ -753,7 +749,7 @@ class Player final : public Creature, public Cylinder
if (visible) {
client->sendAddCreature(creature, creature->getPosition(), stackpos, false);
} else {
client->sendRemoveTileCreature(creature, creature->getPosition(), stackpos);
client->sendRemoveTileThing(creature->getPosition(), stackpos);
}
}
}
Expand Down

0 comments on commit 4473d68

Please sign in to comment.