1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-30 03:15:32 +00:00

[General] Add and use getShortDescription() for ESM::Cell

ESM::Cell's getDescription() method was modified by aa5161f99e despite being used heavily by TES3MP. All instances of it in the TES3MP code have now been changed into the newly added getShortDescription() that is identical to the previous getDescription().
This commit is contained in:
David Cernat 2021-09-17 19:14:55 +02:00
parent 2f98f31af2
commit 7393e3def6
46 changed files with 140 additions and 108 deletions

View file

@ -28,21 +28,21 @@ void Cell::addPlayer(Player *player)
if (it != end())
{
LOG_APPEND(TimedLog::LOG_INFO, "- Attempt to add %s to Cell %s again was ignored", player->npc.mName.c_str(), getDescription().c_str());
LOG_APPEND(TimedLog::LOG_INFO, "- Attempt to add %s to Cell %s again was ignored", player->npc.mName.c_str(), getShortDescription().c_str());
return;
}
auto it2 = find(player->cells.begin(), player->cells.end(), this);
if (it2 == player->cells.end())
{
LOG_APPEND(TimedLog::LOG_INFO, "- Adding %s to Player %s", getDescription().c_str(), player->npc.mName.c_str());
LOG_APPEND(TimedLog::LOG_INFO, "- Adding %s to Player %s", getShortDescription().c_str(), player->npc.mName.c_str());
player->cells.push_back(this);
}
LOG_APPEND(TimedLog::LOG_INFO, "- Adding %s to Cell %s", player->npc.mName.c_str(), getDescription().c_str());
LOG_APPEND(TimedLog::LOG_INFO, "- Adding %s to Cell %s", player->npc.mName.c_str(), getShortDescription().c_str());
Script::Call<Script::CallbackIdentity("OnCellLoad")>(player->getId(), getDescription().c_str());
Script::Call<Script::CallbackIdentity("OnCellLoad")>(player->getId(), getShortDescription().c_str());
players.push_back(player);
}
@ -58,15 +58,15 @@ void Cell::removePlayer(Player *player, bool cleanPlayer)
auto it2 = find(player->cells.begin(), player->cells.end(), this);
if (it2 != player->cells.end())
{
LOG_APPEND(TimedLog::LOG_INFO, "- Removing %s from Player %s", getDescription().c_str(), player->npc.mName.c_str());
LOG_APPEND(TimedLog::LOG_INFO, "- Removing %s from Player %s", getShortDescription().c_str(), player->npc.mName.c_str());
player->cells.erase(it2);
}
}
LOG_APPEND(TimedLog::LOG_INFO, "- Removing %s from Cell %s", player->npc.mName.c_str(), getDescription().c_str());
LOG_APPEND(TimedLog::LOG_INFO, "- Removing %s from Cell %s", player->npc.mName.c_str(), getShortDescription().c_str());
Script::Call<Script::CallbackIdentity("OnCellUnload")>(player->getId(), getDescription().c_str());
Script::Call<Script::CallbackIdentity("OnCellUnload")>(player->getId(), getShortDescription().c_str());
players.erase(it);
return;
@ -235,7 +235,7 @@ void Cell::sendToLoaded(mwmp::ObjectPacket *objectPacket, mwmp::BaseObjectList *
}
}
std::string Cell::getDescription() const
std::string Cell::getShortDescription() const
{
return cell.getDescription();
return cell.getShortDescription();
}

View file

@ -39,7 +39,7 @@ public:
void sendToLoaded(mwmp::ActorPacket *actorPacket, mwmp::BaseActorList *baseActorList) const;
void sendToLoaded(mwmp::ObjectPacket *objectPacket, mwmp::BaseObjectList *baseObjectList) const;
std::string getDescription() const;
std::string getShortDescription() const;
private:

View file

@ -98,14 +98,14 @@ Cell *CellController::addCell(ESM::Cell cellData)
Cell *cell;
if (it == cells.end())
{
LOG_APPEND(TimedLog::LOG_INFO, "- Adding %s to CellController", cellData.getDescription().c_str());
LOG_APPEND(TimedLog::LOG_INFO, "- Adding %s to CellController", cellData.getShortDescription().c_str());
cell = new Cell(cellData);
cells.push_back(cell);
}
else
{
LOG_APPEND(TimedLog::LOG_INFO, "- Found %s in CellController", cellData.getDescription().c_str());
LOG_APPEND(TimedLog::LOG_INFO, "- Found %s in CellController", cellData.getShortDescription().c_str());
cell = *it;
}
@ -121,8 +121,8 @@ void CellController::removeCell(Cell *cell)
{
if (*it != nullptr && *it == cell)
{
Script::Call<Script::CallbackIdentity("OnCellDeletion")>(cell->getDescription().c_str());
LOG_APPEND(TimedLog::LOG_INFO, "- Removing %s from CellController", cell->getDescription().c_str());
Script::Call<Script::CallbackIdentity("OnCellDeletion")>(cell->getShortDescription().c_str());
LOG_APPEND(TimedLog::LOG_INFO, "- Removing %s from CellController", cell->getShortDescription().c_str());
delete *it;
it = cells.erase(it);
@ -151,7 +151,7 @@ void CellController::deletePlayer(Player *player)
for (auto &&cell : toDelete)
{
LOG_APPEND(TimedLog::LOG_INFO, "- Cell %s has no players left", cell->getDescription().c_str());
LOG_APPEND(TimedLog::LOG_INFO, "- Cell %s has no players left", cell->getShortDescription().c_str());
removeCell(cell);
}
}
@ -185,7 +185,7 @@ void CellController::update(Player *player)
}
for (auto &&cell : toDelete)
{
LOG_APPEND(TimedLog::LOG_INFO, "- Cell %s has no players left", cell->getDescription().c_str());
LOG_APPEND(TimedLog::LOG_INFO, "- Cell %s has no players left", cell->getShortDescription().c_str());
removeCell(cell);
}
}

View file

@ -71,7 +71,7 @@ unsigned char ActorFunctions::GetActorListAction() noexcept
const char *ActorFunctions::GetActorCell(unsigned int index) noexcept
{
tempCellDescription = readActorList->baseActors.at(index).cell.getDescription();
tempCellDescription = readActorList->baseActors.at(index).cell.getShortDescription();
return tempCellDescription.c_str();
}

View file

@ -35,7 +35,7 @@ const char *CellFunctions::GetCellStateDescription(unsigned short pid, unsigned
if (index >= player->cellStateChanges.size())
return "invalid";
tempCellDescription = player->cellStateChanges.at(index).cell.getDescription();
tempCellDescription = player->cellStateChanges.at(index).cell.getShortDescription();
return tempCellDescription.c_str();
}
@ -44,7 +44,7 @@ const char *CellFunctions::GetCell(unsigned short pid) noexcept
Player *player;
GET_PLAYER(pid, player, 0);
tempCellDescription = player->cell.getDescription().c_str();
tempCellDescription = player->cell.getShortDescription().c_str();
return tempCellDescription.c_str();
}
@ -92,7 +92,7 @@ void CellFunctions::SetCell(unsigned short pid, const char *cellDescription) noe
GET_PLAYER(pid, player,);
LOG_MESSAGE_SIMPLE(TimedLog::LOG_INFO, "Script is moving %s from %s to %s", player->npc.mName.c_str(),
player->cell.getDescription().c_str(), cellDescription);
player->cell.getShortDescription().c_str(), cellDescription);
player->cell = Utils::getCellFromDescription(cellDescription);
}
@ -103,7 +103,7 @@ void CellFunctions::SetExteriorCell(unsigned short pid, int x, int y) noexcept
GET_PLAYER(pid, player,);
LOG_MESSAGE_SIMPLE(TimedLog::LOG_INFO, "Script is moving %s from %s to %i,%i", player->npc.mName.c_str(),
player->cell.getDescription().c_str(), x, y);
player->cell.getShortDescription().c_str(), x, y);
// If the player is currently in an interior, turn off the interior flag
// from the cell

View file

@ -31,7 +31,7 @@ const char *MechanicsFunctions::GetMarkCell(unsigned short pid) noexcept
Player *player;
GET_PLAYER(pid, player, 0);
tempCellDescription = player->cell.getDescription().c_str();
tempCellDescription = player->cell.getShortDescription().c_str();
return tempCellDescription.c_str();
}

View file

@ -19,7 +19,7 @@ namespace mwmp
if (serverCell != nullptr)
{
Script::Call<Script::CallbackIdentity("OnActorAI")>(player.getId(), actorList.cell.getDescription().c_str());
Script::Call<Script::CallbackIdentity("OnActorAI")>(player.getId(), actorList.cell.getShortDescription().c_str());
}
}
};

View file

@ -37,7 +37,7 @@ namespace mwmp
{
serverCell->removeActors(&actorList);
Script::Call<Script::CallbackIdentity("OnActorCellChange")>(player.getId(), actorList.cell.getDescription().c_str());
Script::Call<Script::CallbackIdentity("OnActorCellChange")>(player.getId(), actorList.cell.getShortDescription().c_str());
// Send this to everyone
packet.Send(true);

View file

@ -20,7 +20,7 @@ namespace mwmp
if (serverCell != nullptr && *serverCell->getAuthority() == actorList.guid)
{
Script::Call<Script::CallbackIdentity("OnActorDeath")>(player.getId(), actorList.cell.getDescription().c_str());
Script::Call<Script::CallbackIdentity("OnActorDeath")>(player.getId(), actorList.cell.getShortDescription().c_str());
serverCell->sendToLoaded(&packet, &actorList);
}

View file

@ -20,7 +20,7 @@ namespace mwmp
if (serverCell != nullptr)
{
Script::Call<Script::CallbackIdentity("OnActorEquipment")>(player.getId(), actorList.cell.getDescription().c_str());
Script::Call<Script::CallbackIdentity("OnActorEquipment")>(player.getId(), actorList.cell.getShortDescription().c_str());
serverCell->sendToLoaded(&packet, &actorList);
}

View file

@ -23,7 +23,7 @@ namespace mwmp
if (serverCell != nullptr)
serverCell->sendToLoaded(&packet, &actorList);
Script::Call<Script::CallbackIdentity("OnActorList")>(player.getId(), actorList.cell.getDescription().c_str());
Script::Call<Script::CallbackIdentity("OnActorList")>(player.getId(), actorList.cell.getShortDescription().c_str());
}
};
}

View file

@ -20,7 +20,7 @@ namespace mwmp
if (serverCell != nullptr && *serverCell->getAuthority() == actorList.guid)
{
Script::Call<Script::CallbackIdentity("OnActorSpellsActive")>(player.getId(), actorList.cell.getDescription().c_str());
Script::Call<Script::CallbackIdentity("OnActorSpellsActive")>(player.getId(), actorList.cell.getShortDescription().c_str());
serverCell->sendToLoaded(&packet, &actorList);
}

View file

@ -21,7 +21,7 @@ namespace mwmp
if (serverCell != nullptr)
serverCell->sendToLoaded(&packet, &actorList);
Script::Call<Script::CallbackIdentity("OnActorTest")>(player.getId(), actorList.cell.getDescription().c_str());
Script::Call<Script::CallbackIdentity("OnActorTest")>(player.getId(), actorList.cell.getShortDescription().c_str());
}
};
}

View file

@ -17,7 +17,7 @@ namespace mwmp
{
LOG_MESSAGE_SIMPLE(TimedLog::LOG_INFO, "Received %s from %s", strPacketID.c_str(), player.npc.mName.c_str());
Script::Call<Script::CallbackIdentity("OnClientScriptLocal")>(player.getId(), objectList.cell.getDescription().c_str());
Script::Call<Script::CallbackIdentity("OnClientScriptLocal")>(player.getId(), objectList.cell.getShortDescription().c_str());
}
};
}

View file

@ -17,7 +17,7 @@ namespace mwmp
{
LOG_MESSAGE_SIMPLE(TimedLog::LOG_INFO, "Received %s from %s", strPacketID.c_str(), player.npc.mName.c_str());
Script::Call<Script::CallbackIdentity("OnConsoleCommand")>(player.getId(), objectList.cell.getDescription().c_str());
Script::Call<Script::CallbackIdentity("OnConsoleCommand")>(player.getId(), objectList.cell.getShortDescription().c_str());
}
};
}

View file

@ -22,7 +22,7 @@ namespace mwmp
// container packets to ensure their integrity based on what exists in the
// server data
Script::Call<Script::CallbackIdentity("OnContainer")>(player.getId(), objectList.cell.getDescription().c_str());
Script::Call<Script::CallbackIdentity("OnContainer")>(player.getId(), objectList.cell.getShortDescription().c_str());
LOG_APPEND(TimedLog::LOG_INFO, "- Finished processing ID_CONTAINER");
}

View file

@ -17,7 +17,7 @@ namespace mwmp
{
packet.Send(true);
Script::Call<Script::CallbackIdentity("OnDoorState")>(player.getId(), objectList.cell.getDescription().c_str());
Script::Call<Script::CallbackIdentity("OnDoorState")>(player.getId(), objectList.cell.getShortDescription().c_str());
}
};
}

View file

@ -18,7 +18,7 @@ namespace mwmp
{
LOG_MESSAGE_SIMPLE(TimedLog::LOG_INFO, "Received %s from %s", strPacketID.c_str(), player.npc.mName.c_str());
Script::Call<Script::CallbackIdentity("OnObjectActivate")>(player.getId(), objectList.cell.getDescription().c_str());
Script::Call<Script::CallbackIdentity("OnObjectActivate")>(player.getId(), objectList.cell.getShortDescription().c_str());
}
};
}

View file

@ -17,7 +17,7 @@ namespace mwmp
{
LOG_MESSAGE_SIMPLE(TimedLog::LOG_INFO, "Received %s from %s", strPacketID.c_str(), player.npc.mName.c_str());
Script::Call<Script::CallbackIdentity("OnObjectDelete")>(player.getId(), objectList.cell.getDescription().c_str());
Script::Call<Script::CallbackIdentity("OnObjectDelete")>(player.getId(), objectList.cell.getShortDescription().c_str());
}
};
}

View file

@ -18,7 +18,7 @@ namespace mwmp
{
LOG_MESSAGE_SIMPLE(TimedLog::LOG_INFO, "Received %s from %s", strPacketID.c_str(), player.npc.mName.c_str());
Script::Call<Script::CallbackIdentity("OnObjectDialogueChoice")>(player.getId(), objectList.cell.getDescription().c_str());
Script::Call<Script::CallbackIdentity("OnObjectDialogueChoice")>(player.getId(), objectList.cell.getShortDescription().c_str());
}
};
}

View file

@ -17,7 +17,7 @@ namespace mwmp
{
LOG_MESSAGE_SIMPLE(TimedLog::LOG_INFO, "Received %s from %s", strPacketID.c_str(), player.npc.mName.c_str());
Script::Call<Script::CallbackIdentity("OnObjectHit")>(player.getId(), objectList.cell.getDescription().c_str());
Script::Call<Script::CallbackIdentity("OnObjectHit")>(player.getId(), objectList.cell.getShortDescription().c_str());
}
};
}

View file

@ -17,7 +17,7 @@ namespace mwmp
{
LOG_MESSAGE_SIMPLE(TimedLog::LOG_INFO, "Received %s from %s", strPacketID.c_str(), player.npc.mName.c_str());
Script::Call<Script::CallbackIdentity("OnObjectLock")>(player.getId(), objectList.cell.getDescription().c_str());
Script::Call<Script::CallbackIdentity("OnObjectLock")>(player.getId(), objectList.cell.getShortDescription().c_str());
}
};
}

View file

@ -17,7 +17,7 @@ namespace mwmp
{
LOG_MESSAGE_SIMPLE(TimedLog::LOG_INFO, "Received %s from %s", strPacketID.c_str(), player.npc.mName.c_str());
Script::Call<Script::CallbackIdentity("OnObjectMiscellaneous")>(player.getId(), objectList.cell.getDescription().c_str());
Script::Call<Script::CallbackIdentity("OnObjectMiscellaneous")>(player.getId(), objectList.cell.getShortDescription().c_str());
}
};
}

View file

@ -23,7 +23,7 @@ namespace mwmp
objectList.baseObjects.at(i).mpNum = mwmp::Networking::getPtr()->incrementMpNum();
}
Script::Call<Script::CallbackIdentity("OnObjectPlace")>(player.getId(), objectList.cell.getDescription().c_str());
Script::Call<Script::CallbackIdentity("OnObjectPlace")>(player.getId(), objectList.cell.getShortDescription().c_str());
}
};
}

View file

@ -17,7 +17,7 @@ namespace mwmp
{
LOG_MESSAGE_SIMPLE(TimedLog::LOG_INFO, "Received %s from %s", strPacketID.c_str(), player.npc.mName.c_str());
Script::Call<Script::CallbackIdentity("OnObjectRestock")>(player.getId(), objectList.cell.getDescription().c_str());
Script::Call<Script::CallbackIdentity("OnObjectRestock")>(player.getId(), objectList.cell.getShortDescription().c_str());
}
};
}

View file

@ -17,7 +17,7 @@ namespace mwmp
{
LOG_MESSAGE_SIMPLE(TimedLog::LOG_INFO, "Received %s from %s", strPacketID.c_str(), player.npc.mName.c_str());
Script::Call<Script::CallbackIdentity("OnObjectScale")>(player.getId(), objectList.cell.getDescription().c_str());
Script::Call<Script::CallbackIdentity("OnObjectScale")>(player.getId(), objectList.cell.getShortDescription().c_str());
}
};
}

View file

@ -17,7 +17,7 @@ namespace mwmp
{
LOG_MESSAGE_SIMPLE(TimedLog::LOG_INFO, "Received %s from %s", strPacketID.c_str(), player.npc.mName.c_str());
Script::Call<Script::CallbackIdentity("OnObjectSound")>(player.getId(), objectList.cell.getDescription().c_str());
Script::Call<Script::CallbackIdentity("OnObjectSound")>(player.getId(), objectList.cell.getShortDescription().c_str());
}
};
}

View file

@ -23,7 +23,7 @@ namespace mwmp
objectList.baseObjects.at(i).mpNum = mwmp::Networking::getPtr()->incrementMpNum();
}
Script::Call<Script::CallbackIdentity("OnObjectSpawn")>(player.getId(), objectList.cell.getDescription().c_str());
Script::Call<Script::CallbackIdentity("OnObjectSpawn")>(player.getId(), objectList.cell.getShortDescription().c_str());
}
};
}

View file

@ -17,7 +17,7 @@ namespace mwmp
{
LOG_MESSAGE_SIMPLE(TimedLog::LOG_INFO, "Received %s from %s", strPacketID.c_str(), player.npc.mName.c_str());
Script::Call<Script::CallbackIdentity("OnObjectState")>(player.getId(), objectList.cell.getDescription().c_str());
Script::Call<Script::CallbackIdentity("OnObjectState")>(player.getId(), objectList.cell.getShortDescription().c_str());
}
};
}

View file

@ -17,7 +17,7 @@ namespace mwmp
{
LOG_MESSAGE_SIMPLE(TimedLog::LOG_INFO, "Received %s from %s", strPacketID.c_str(), player.npc.mName.c_str());
Script::Call<Script::CallbackIdentity("OnObjectTrap")>(player.getId(), objectList.cell.getDescription().c_str());
Script::Call<Script::CallbackIdentity("OnObjectTrap")>(player.getId(), objectList.cell.getShortDescription().c_str());
}
};
}

View file

@ -17,7 +17,7 @@ namespace mwmp
{
LOG_MESSAGE_SIMPLE(TimedLog::LOG_INFO, "Received %s from %s", strPacketID.c_str(), player.npc.mName.c_str());
Script::Call<Script::CallbackIdentity("OnVideoPlay")>(player.getId(), objectList.cell.getDescription().c_str());
Script::Call<Script::CallbackIdentity("OnVideoPlay")>(player.getId(), objectList.cell.getShortDescription().c_str());
}
};
}

View file

@ -21,7 +21,7 @@ namespace mwmp
void Do(PlayerPacket &packet, Player &player) override
{
LOG_MESSAGE_SIMPLE(TimedLog::LOG_INFO, "Received %s from %s", strPacketID.c_str(), player.npc.mName.c_str());
LOG_APPEND(TimedLog::LOG_INFO, "- Moved to %s", player.cell.getDescription().c_str());
LOG_APPEND(TimedLog::LOG_INFO, "- Moved to %s", player.cell.getShortDescription().c_str());
Script::Call<Script::CallbackIdentity("OnPlayerCellChange")>(player.getId());
@ -73,7 +73,7 @@ namespace mwmp
packet.setPlayer(&player);
packet.Send(true); //send to other clients
LOG_APPEND(TimedLog::LOG_INFO, "- Finished processing ID_PLAYER_CELL_CHANGE", player.cell.getDescription().c_str());
LOG_APPEND(TimedLog::LOG_INFO, "- Finished processing ID_PLAYER_CELL_CHANGE", player.cell.getShortDescription().c_str());
player.exchangeFullInfo = false;
}

View file

@ -62,15 +62,15 @@ void Cell::updateLocal(bool forceUpdate)
if (cellController->hasLocalAuthority(actor->cell))
{
LOG_APPEND(TimedLog::LOG_VERBOSE, "- Moving LocalActor %s to our authority in %s",
mapIndex.c_str(), actor->cell.getDescription().c_str());
mapIndex.c_str(), actor->cell.getShortDescription().c_str());
Cell *newCell = cellController->getCell(actor->cell);
newCell->localActors[mapIndex] = actor;
cellController->setLocalActorRecord(mapIndex, newCell->getDescription());
cellController->setLocalActorRecord(mapIndex, newCell->getShortDescription());
}
else
{
LOG_APPEND(TimedLog::LOG_VERBOSE, "- Deleting LocalActor %s which is no longer under our authority",
mapIndex.c_str(), getDescription().c_str());
mapIndex.c_str(), getShortDescription().c_str());
cellController->removeLocalActorRecord(mapIndex);
delete actor;
}
@ -227,7 +227,7 @@ void Cell::readDeath(ActorList& actorList)
Main::get().getCellController()->setQueuedDeathState(actor->getPtr(), baseActor.deathState);
LOG_MESSAGE_SIMPLE(TimedLog::LOG_INFO, "Received ID_ACTOR_DEATH about %s %i-%i in cell %s\n- deathState: %d\n-isInstantDeath: %s",
actor->refId.c_str(), actor->refNum, actor->mpNum, getDescription().c_str(),
actor->refId.c_str(), actor->refNum, actor->mpNum, getShortDescription().c_str(),
baseActor.deathState, baseActor.isInstantDeath ? "true" : "false");
if (baseActor.isInstantDeath)
@ -401,10 +401,10 @@ void Cell::readCellChange(ActorList& actorList)
std::string mapIndex = Main::get().getCellController()->generateMapIndex(baseActor);
// Is a packet mistakenly moving the actor to the cell it's already in? If so, ignore it
if (Misc::StringUtils::ciEqual(getDescription(), baseActor.cell.getDescription()))
if (Misc::StringUtils::ciEqual(getShortDescription(), baseActor.cell.getShortDescription()))
{
LOG_MESSAGE_SIMPLE(TimedLog::LOG_WARN, "Server says DedicatedActor %s moved to %s, but it was already there",
mapIndex.c_str(), getDescription().c_str());
mapIndex.c_str(), getShortDescription().c_str());
continue;
}
@ -416,7 +416,7 @@ void Cell::readCellChange(ActorList& actorList)
dedicatedActor->direction = baseActor.direction;
LOG_MESSAGE_SIMPLE(TimedLog::LOG_VERBOSE, "Server says DedicatedActor %s moved to %s",
mapIndex.c_str(), dedicatedActor->cell.getDescription().c_str());
mapIndex.c_str(), dedicatedActor->cell.getShortDescription().c_str());
MWWorld::CellStore *newStore = cellController->getCellStore(dedicatedActor->cell);
dedicatedActor->setCell(newStore);
@ -425,18 +425,18 @@ void Cell::readCellChange(ActorList& actorList)
if (cellController->isActiveWorldCell(dedicatedActor->cell) && !cellController->hasLocalAuthority(dedicatedActor->cell))
{
LOG_APPEND(TimedLog::LOG_VERBOSE, "- Moving DedicatedActor %s to our active cell %s",
mapIndex.c_str(), dedicatedActor->cell.getDescription().c_str());
mapIndex.c_str(), dedicatedActor->cell.getShortDescription().c_str());
cellController->initializeCell(dedicatedActor->cell);
Cell *newCell = cellController->getCell(dedicatedActor->cell);
newCell->dedicatedActors[mapIndex] = dedicatedActor;
cellController->setDedicatedActorRecord(mapIndex, newCell->getDescription());
cellController->setDedicatedActorRecord(mapIndex, newCell->getShortDescription());
}
else
{
if (cellController->hasLocalAuthority(dedicatedActor->cell))
{
LOG_APPEND(TimedLog::LOG_VERBOSE, "- Creating new LocalActor based on %s in %s",
mapIndex.c_str(), dedicatedActor->cell.getDescription().c_str());
mapIndex.c_str(), dedicatedActor->cell.getShortDescription().c_str());
Cell *newCell = cellController->getCell(dedicatedActor->cell);
LocalActor *localActor = new LocalActor();
localActor->cell = dedicatedActor->cell;
@ -449,11 +449,11 @@ void Cell::readCellChange(ActorList& actorList)
localActor->creatureStats = dedicatedActor->creatureStats;
newCell->localActors[mapIndex] = localActor;
cellController->setLocalActorRecord(mapIndex, newCell->getDescription());
cellController->setLocalActorRecord(mapIndex, newCell->getShortDescription());
}
LOG_APPEND(TimedLog::LOG_VERBOSE, "- Deleting DedicatedActor %s which is no longer needed",
mapIndex.c_str(), getDescription().c_str());
mapIndex.c_str(), getShortDescription().c_str());
cellController->removeDedicatedActorRecord(mapIndex);
delete dedicatedActor;
}
@ -466,7 +466,7 @@ void Cell::readCellChange(ActorList& actorList)
void Cell::initializeLocalActor(const MWWorld::Ptr& ptr)
{
std::string mapIndex = Main::get().getCellController()->generateMapIndex(ptr);
LOG_APPEND(TimedLog::LOG_VERBOSE, "- Initializing LocalActor %s in %s", mapIndex.c_str(), getDescription().c_str());
LOG_APPEND(TimedLog::LOG_VERBOSE, "- Initializing LocalActor %s in %s", mapIndex.c_str(), getShortDescription().c_str());
LocalActor *actor = new LocalActor();
actor->cell = *store->getCell();
@ -474,14 +474,14 @@ void Cell::initializeLocalActor(const MWWorld::Ptr& ptr)
localActors[mapIndex] = actor;
Main::get().getCellController()->setLocalActorRecord(mapIndex, getDescription());
Main::get().getCellController()->setLocalActorRecord(mapIndex, getShortDescription());
LOG_APPEND(TimedLog::LOG_VERBOSE, "- Successfully initialized LocalActor %s in %s", mapIndex.c_str(), getDescription().c_str());
LOG_APPEND(TimedLog::LOG_VERBOSE, "- Successfully initialized LocalActor %s in %s", mapIndex.c_str(), getShortDescription().c_str());
}
void Cell::initializeLocalActors()
{
LOG_MESSAGE_SIMPLE(TimedLog::LOG_VERBOSE, "Initializing LocalActors in %s", getDescription().c_str());
LOG_MESSAGE_SIMPLE(TimedLog::LOG_VERBOSE, "Initializing LocalActors in %s", getShortDescription().c_str());
for (const auto &mergedRef : store->getMergedRefs())
{
@ -503,13 +503,13 @@ void Cell::initializeLocalActors()
}
}
LOG_APPEND(TimedLog::LOG_VERBOSE, "- Successfully initialized LocalActors in %s", getDescription().c_str());
LOG_APPEND(TimedLog::LOG_VERBOSE, "- Successfully initialized LocalActors in %s", getShortDescription().c_str());
}
void Cell::initializeDedicatedActor(const MWWorld::Ptr& ptr)
{
std::string mapIndex = Main::get().getCellController()->generateMapIndex(ptr);
LOG_APPEND(TimedLog::LOG_VERBOSE, "- Initializing DedicatedActor %s in %s", mapIndex.c_str(), getDescription().c_str());
LOG_APPEND(TimedLog::LOG_VERBOSE, "- Initializing DedicatedActor %s in %s", mapIndex.c_str(), getShortDescription().c_str());
DedicatedActor *actor = new DedicatedActor();
actor->cell = *store->getCell();
@ -517,9 +517,9 @@ void Cell::initializeDedicatedActor(const MWWorld::Ptr& ptr)
dedicatedActors[mapIndex] = actor;
Main::get().getCellController()->setDedicatedActorRecord(mapIndex, getDescription());
Main::get().getCellController()->setDedicatedActorRecord(mapIndex, getShortDescription());
LOG_APPEND(TimedLog::LOG_VERBOSE, "- Successfully initialized DedicatedActor %s in %s", mapIndex.c_str(), getDescription().c_str());
LOG_APPEND(TimedLog::LOG_VERBOSE, "- Successfully initialized DedicatedActor %s in %s", mapIndex.c_str(), getShortDescription().c_str());
}
void Cell::initializeDedicatedActors(ActorList& actorList)
@ -598,7 +598,7 @@ MWWorld::CellStore *Cell::getCellStore()
return store;
}
std::string Cell::getDescription()
std::string Cell::getShortDescription()
{
return store->getCell()->getDescription();
return store->getCell()->getShortDescription();
}

View file

@ -48,7 +48,7 @@ namespace mwmp
void setAuthority(const RakNet::RakNetGUID& guid);
MWWorld::CellStore* getCellStore();
std::string getDescription();
std::string getShortDescription();
bool shouldInitializeActors;

View file

@ -85,12 +85,12 @@ void CellController::updateDedicated(float dt)
void CellController::initializeCell(const ESM::Cell& cell)
{
std::string mapIndex = cell.getDescription();
std::string mapIndex = cell.getShortDescription();
// If this key doesn't exist, create it
if (cellsInitialized.count(mapIndex) == 0)
{
LOG_MESSAGE_SIMPLE(TimedLog::LOG_INFO, "Initializing mwmp::Cell %s", cell.getDescription().c_str());
LOG_MESSAGE_SIMPLE(TimedLog::LOG_INFO, "Initializing mwmp::Cell %s", cell.getShortDescription().c_str());
MWWorld::CellStore *cellStore = getCellStore(cell);
@ -99,13 +99,13 @@ void CellController::initializeCell(const ESM::Cell& cell)
mwmp::Cell *mpCell = new mwmp::Cell(cellStore);
cellsInitialized[mapIndex] = mpCell;
LOG_APPEND(TimedLog::LOG_VERBOSE, "- Successfully initialized mwmp::Cell %s", cell.getDescription().c_str());
LOG_APPEND(TimedLog::LOG_VERBOSE, "- Successfully initialized mwmp::Cell %s", cell.getShortDescription().c_str());
}
}
void CellController::uninitializeCell(const ESM::Cell& cell)
{
std::string mapIndex = cell.getDescription();
std::string mapIndex = cell.getShortDescription();
// If this key exists, erase the key-value pair from the map
if (cellsInitialized.count(mapIndex) > 0)
@ -136,7 +136,7 @@ void CellController::uninitializeCells()
void CellController::readPositions(ActorList& actorList)
{
std::string mapIndex = actorList.cell.getDescription();
std::string mapIndex = actorList.cell.getShortDescription();
initializeCell(actorList.cell);
@ -147,7 +147,7 @@ void CellController::readPositions(ActorList& actorList)
void CellController::readAnimFlags(ActorList& actorList)
{
std::string mapIndex = actorList.cell.getDescription();
std::string mapIndex = actorList.cell.getShortDescription();
initializeCell(actorList.cell);
@ -158,7 +158,7 @@ void CellController::readAnimFlags(ActorList& actorList)
void CellController::readAnimPlay(ActorList& actorList)
{
std::string mapIndex = actorList.cell.getDescription();
std::string mapIndex = actorList.cell.getShortDescription();
initializeCell(actorList.cell);
@ -169,7 +169,7 @@ void CellController::readAnimPlay(ActorList& actorList)
void CellController::readStatsDynamic(ActorList& actorList)
{
std::string mapIndex = actorList.cell.getDescription();
std::string mapIndex = actorList.cell.getShortDescription();
initializeCell(actorList.cell);
@ -180,7 +180,7 @@ void CellController::readStatsDynamic(ActorList& actorList)
void CellController::readDeath(ActorList& actorList)
{
std::string mapIndex = actorList.cell.getDescription();
std::string mapIndex = actorList.cell.getShortDescription();
initializeCell(actorList.cell);
@ -191,7 +191,7 @@ void CellController::readDeath(ActorList& actorList)
void CellController::readEquipment(ActorList& actorList)
{
std::string mapIndex = actorList.cell.getDescription();
std::string mapIndex = actorList.cell.getShortDescription();
initializeCell(actorList.cell);
@ -202,7 +202,7 @@ void CellController::readEquipment(ActorList& actorList)
void CellController::readSpeech(ActorList& actorList)
{
std::string mapIndex = actorList.cell.getDescription();
std::string mapIndex = actorList.cell.getShortDescription();
initializeCell(actorList.cell);
@ -213,7 +213,7 @@ void CellController::readSpeech(ActorList& actorList)
void CellController::readSpellsActive(ActorList& actorList)
{
std::string mapIndex = actorList.cell.getDescription();
std::string mapIndex = actorList.cell.getShortDescription();
initializeCell(actorList.cell);
@ -224,7 +224,7 @@ void CellController::readSpellsActive(ActorList& actorList)
void CellController::readAi(ActorList& actorList)
{
std::string mapIndex = actorList.cell.getDescription();
std::string mapIndex = actorList.cell.getShortDescription();
initializeCell(actorList.cell);
@ -235,7 +235,7 @@ void CellController::readAi(ActorList& actorList)
void CellController::readAttack(ActorList& actorList)
{
std::string mapIndex = actorList.cell.getDescription();
std::string mapIndex = actorList.cell.getShortDescription();
initializeCell(actorList.cell);
@ -246,7 +246,7 @@ void CellController::readAttack(ActorList& actorList)
void CellController::readCast(ActorList& actorList)
{
std::string mapIndex = actorList.cell.getDescription();
std::string mapIndex = actorList.cell.getShortDescription();
initializeCell(actorList.cell);
@ -257,7 +257,7 @@ void CellController::readCast(ActorList& actorList)
void CellController::readCellChange(ActorList& actorList)
{
std::string mapIndex = actorList.cell.getDescription();
std::string mapIndex = actorList.cell.getShortDescription();
initializeCell(actorList.cell);
@ -412,7 +412,7 @@ bool CellController::isInitializedCell(const std::string& cellDescription)
bool CellController::isInitializedCell(const ESM::Cell& cell)
{
return isInitializedCell(cell.getDescription());
return isInitializedCell(cell.getShortDescription());
}
bool CellController::isActiveWorldCell(const ESM::Cell& cell)
@ -422,7 +422,7 @@ bool CellController::isActiveWorldCell(const ESM::Cell& cell)
Cell *CellController::getCell(const ESM::Cell& cell)
{
return cellsInitialized.at(cell.getDescription());
return cellsInitialized.at(cell.getShortDescription());
}
MWWorld::CellStore *CellController::getCellStore(const ESM::Cell& cell)

View file

@ -381,7 +381,7 @@ void DedicatedPlayer::setCell()
MWBase::World *world = MWBase::Environment::get().getWorld();
LOG_MESSAGE_SIMPLE(TimedLog::LOG_INFO, "Server says DedicatedPlayer %s moved to %s",
npc.mName.c_str(), cell.getDescription().c_str());
npc.mName.c_str(), cell.getShortDescription().c_str());
MWWorld::CellStore *cellStore = Main::get().getCellController()->getCellStore(cell);

View file

@ -74,9 +74,9 @@ void LocalActor::update(bool forceUpdate)
void LocalActor::updateCell()
{
LOG_MESSAGE_SIMPLE(TimedLog::LOG_VERBOSE, "Sending ID_ACTOR_CELL_CHANGE about %s %i-%i in cell %s to server",
refId.c_str(), refNum, mpNum, cell.getDescription().c_str());
refId.c_str(), refNum, mpNum, cell.getShortDescription().c_str());
LOG_APPEND(TimedLog::LOG_VERBOSE, "- Moved to cell %s", ptr.getCell()->getCell()->getDescription().c_str());
LOG_APPEND(TimedLog::LOG_VERBOSE, "- Moved to cell %s", ptr.getCell()->getCell()->getShortDescription().c_str());
cell = *ptr.getCell()->getCell();
position = ptr.getRefData().getPosition();
@ -346,7 +346,7 @@ void LocalActor::sendDeath(char newDeathState)
killer = MechanicsHelper::getTarget(ptr);
LOG_MESSAGE_SIMPLE(TimedLog::LOG_INFO, "Sending ID_ACTOR_DEATH about %s %i-%i in cell %s to server\n- deathState: %d",
refId.c_str(), refNum, mpNum, cell.getDescription().c_str(), deathState);
refId.c_str(), refNum, mpNum, cell.getShortDescription().c_str(), deathState);
ActorList actorList;
actorList.cell = cell;

View file

@ -424,8 +424,8 @@ void LocalPlayer::updateCell(bool forceUpdate)
{
LOG_MESSAGE_SIMPLE(TimedLog::LOG_INFO, "Sending ID_PLAYER_CELL_CHANGE about LocalPlayer to server");
LOG_APPEND(TimedLog::LOG_INFO, "- Moved from %s to %s", cell.getDescription().c_str(),
ptrCell->getDescription().c_str());
LOG_APPEND(TimedLog::LOG_INFO, "- Moved from %s to %s", cell.getShortDescription().c_str(),
ptrCell->getShortDescription().c_str());
if (!Misc::StringUtils::ciEqual(cell.mRegion, ptrCell->mRegion))
{
@ -1891,7 +1891,7 @@ void LocalPlayer::storeCellState(const ESM::Cell& storedCell, int stateType)
{
// If there's already a cell state recorded for this particular cell,
// remove it
if (storedCell.getDescription() == (*iter).cell.getDescription())
if (storedCell.getShortDescription() == (*iter).cell.getShortDescription())
iter = cellStateChanges.erase(iter);
else
++iter;

View file

@ -919,7 +919,7 @@ void ObjectList::setDoorDestinations(MWWorld::CellStore* cellStore)
if (baseObject.destinationCell.isExterior())
ptrFound.getCellRef().setDestCell("");
else
ptrFound.getCellRef().setDestCell(baseObject.destinationCell.getDescription());
ptrFound.getCellRef().setDestCell(baseObject.destinationCell.getShortDescription());
}
}
}
@ -1460,7 +1460,7 @@ void ObjectList::sendObjectPlace()
if (baseObjects.size() == 0)
return;
LOG_MESSAGE_SIMPLE(TimedLog::LOG_VERBOSE, "Sending ID_OBJECT_PLACE about %s", cell.getDescription().c_str());
LOG_MESSAGE_SIMPLE(TimedLog::LOG_VERBOSE, "Sending ID_OBJECT_PLACE about %s", cell.getShortDescription().c_str());
for (const auto &baseObject : baseObjects)
LOG_APPEND(TimedLog::LOG_VERBOSE, "- cellRef: %s, count: %i", baseObject.refId.c_str(), baseObject.count);
@ -1474,7 +1474,7 @@ void ObjectList::sendObjectSpawn()
if (baseObjects.size() == 0)
return;
LOG_MESSAGE_SIMPLE(TimedLog::LOG_VERBOSE, "Sending ID_OBJECT_SPAWN about %s", cell.getDescription().c_str());
LOG_MESSAGE_SIMPLE(TimedLog::LOG_VERBOSE, "Sending ID_OBJECT_SPAWN about %s", cell.getShortDescription().c_str());
for (const auto &baseObject : baseObjects)
LOG_APPEND(TimedLog::LOG_VERBOSE, "- cellRef: %s-%i", baseObject.refId.c_str(), baseObject.refNum);
@ -1545,7 +1545,7 @@ void ObjectList::sendObjectAnimPlay()
void ObjectList::sendDoorState()
{
LOG_MESSAGE_SIMPLE(TimedLog::LOG_VERBOSE, "Sending ID_DOOR_STATE about %s", cell.getDescription().c_str());
LOG_MESSAGE_SIMPLE(TimedLog::LOG_VERBOSE, "Sending ID_DOOR_STATE about %s", cell.getShortDescription().c_str());
for (const auto &baseObject : baseObjects)
LOG_APPEND(TimedLog::LOG_VERBOSE, "- cellRef: %s-%i, state: %s", baseObject.refId.c_str(), baseObject.refNum,
@ -1569,7 +1569,7 @@ void ObjectList::sendVideoPlay()
void ObjectList::sendClientScriptLocal()
{
LOG_MESSAGE_SIMPLE(TimedLog::LOG_VERBOSE, "Sending ID_CLIENT_SCRIPT_LOCAL about %s", cell.getDescription().c_str());
LOG_MESSAGE_SIMPLE(TimedLog::LOG_VERBOSE, "Sending ID_CLIENT_SCRIPT_LOCAL about %s", cell.getShortDescription().c_str());
for (const auto &baseObject : baseObjects)
{
@ -1637,7 +1637,7 @@ void ObjectList::sendContainer()
else if (containerSubAction == mwmp::BaseObjectList::REPLY_TO_REQUEST)
debugMessage += "REPLY_TO_REQUEST";
debugMessage += "\n- cell " + cell.getDescription();
debugMessage += "\n- cell " + cell.getShortDescription();
for (const auto &baseObject : baseObjects)
{

View file

@ -17,7 +17,7 @@ namespace mwmp
virtual void Do(ActorPacket &packet, ActorList &actorList)
{
LOG_MESSAGE_SIMPLE(TimedLog::LOG_INFO, "Received %s about %s", strPacketID.c_str(), actorList.cell.getDescription().c_str());
LOG_MESSAGE_SIMPLE(TimedLog::LOG_INFO, "Received %s about %s", strPacketID.c_str(), actorList.cell.getShortDescription().c_str());
Main::get().getCellController()->readAi(actorList);
}

View file

@ -19,7 +19,7 @@ namespace mwmp
virtual void Do(ActorPacket &packet, ActorList &actorList)
{
LOG_MESSAGE_SIMPLE(TimedLog::LOG_INFO, "Received %s about %s", strPacketID.c_str(), actorList.cell.getDescription().c_str());
LOG_MESSAGE_SIMPLE(TimedLog::LOG_INFO, "Received %s about %s", strPacketID.c_str(), actorList.cell.getShortDescription().c_str());
mwmp::CellController *cellController = Main::get().getCellController();
// Never initialize LocalActors in a cell that is no longer loaded, if the server's packet arrived too late

View file

@ -22,7 +22,7 @@ namespace mwmp
if (!ptrCellStore) return;
LOG_MESSAGE_SIMPLE(TimedLog::LOG_VERBOSE, "Received %s about %s", strPacketID.c_str(), actorList.cell.getDescription().c_str());
LOG_MESSAGE_SIMPLE(TimedLog::LOG_VERBOSE, "Received %s about %s", strPacketID.c_str(), actorList.cell.getShortDescription().c_str());
LOG_APPEND(TimedLog::LOG_VERBOSE, "- action: %i", actorList.action);
// If we've received a request for information, comply with it

View file

@ -13,7 +13,7 @@ namespace mwmp
public:
virtual void Do(ObjectPacket &packet, ObjectList &objectList)
{
LOG_MESSAGE_SIMPLE(TimedLog::LOG_VERBOSE, "Received %s about %s", strPacketID.c_str(), objectList.cell.getDescription().c_str());
LOG_MESSAGE_SIMPLE(TimedLog::LOG_VERBOSE, "Received %s about %s", strPacketID.c_str(), objectList.cell.getShortDescription().c_str());
}
protected:
MWWorld::CellStore *ptrCellStore;

View file

@ -55,7 +55,7 @@ namespace mwmp
if (objectList.baseObjectCount == 0)
{
LOG_APPEND(TimedLog::LOG_VERBOSE, "- Request had no objects attached, so we are sending all containers in the cell %s",
objectList.cell.getDescription().c_str());
objectList.cell.getShortDescription().c_str());
objectList.reset();
objectList.cell = *ptrCellStore->getCell();
objectList.action = mwmp::BaseObjectList::SET;

View file

@ -221,6 +221,27 @@ namespace ESM
return region + ' ' + cellGrid;
}
/*
Start of tes3mp addition
Add a method that returns cell descriptions in OpenMW's previous way, because it was widely
used in TES3MP
*/
std::string Cell::getShortDescription() const
{
if (mData.mFlags & Interior)
{
return mName;
}
else
{
return std::to_string(mData.mX) + ", " + std::to_string(mData.mY);
}
}
/*
End of tes3mp addition
*/
bool Cell::getNextRef(ESMReader &esm, CellRef &ref, bool &isDeleted, bool ignoreMoves, MovedCellRef *mref)
{
isDeleted = false;

View file

@ -174,6 +174,17 @@ struct Cell
std::string getDescription() const;
///< Return a short string describing the cell (mostly used for debugging/logging purpose)
/*
Start of tes3mp addition
Add a method that returns cell descriptions in OpenMW's previous way, because it was widely
used in TES3MP
*/
std::string getShortDescription() const;
/*
End of tes3mp addition
*/
/* Get the next reference in this cell, if any. Returns false when
there are no more references in the cell.