[Server] Remove redundant newlines & keep ~120 columns

0.6.1
Koncord 8 years ago
parent 83d0cbedb2
commit 0442ebd607

@ -14,16 +14,12 @@ void Cell::addPlayer(Player *player)
auto it = find(player->cells.begin(), player->cells.end(), this);
if (it == player->cells.end())
{
LOG_APPEND(Log::LOG_INFO, "- Adding %s to Player %s",
getDescription().c_str(),
player->npc.mName.c_str());
LOG_APPEND(Log::LOG_INFO, "- Adding %s to Player %s", getDescription().c_str(), player->npc.mName.c_str());
player->cells.push_back(this);
}
LOG_APPEND(Log::LOG_INFO, "- Adding %s to Cell %s",
player->npc.mName.c_str(),
getDescription().c_str());
LOG_APPEND(Log::LOG_INFO, "- Adding %s to Cell %s", player->npc.mName.c_str(), getDescription().c_str());
players.push_back(player);
}
@ -37,16 +33,13 @@ void Cell::removePlayer(Player *player)
auto it2 = find(player->cells.begin(), player->cells.end(), this);
if (it2 != player->cells.end())
{
LOG_APPEND(Log::LOG_INFO, "- Removing %s from Player %s",
getDescription().c_str(),
player->npc.mName.c_str());
LOG_APPEND(Log::LOG_INFO, "- Removing %s from Player %s", getDescription().c_str(),
player->npc.mName.c_str());
player->cells.erase(it2);
}
LOG_APPEND(Log::LOG_INFO, "- Removing %s from Cell %s",
player->npc.mName.c_str(),
getDescription().c_str());
LOG_APPEND(Log::LOG_INFO, "- Removing %s from Cell %s", player->npc.mName.c_str(), getDescription().c_str());
players.erase(it);
return;
@ -92,9 +85,7 @@ CellController::CellController()
CellController::~CellController()
{
for (auto cell : cells)
{
delete cell;
}
}
CellController *CellController::sThis = nullptr;
@ -161,10 +152,10 @@ Cell *CellController::getCellByName(std::string cellName)
Cell *CellController::addCell(ESM::Cell cellData)
{
LOG_APPEND(Log::LOG_INFO, "- Loaded cells: %d",
cells.size());
LOG_APPEND(Log::LOG_INFO, "- Loaded cells: %d", cells.size());
auto it = find_if(cells.begin(), cells.end(), [cellData](const Cell *c) {
//return c->cell.sRecordId == cellData.sRecordId; // Currently we cannot compare because plugin lists can be loaded in different order
// Currently we cannot compare because plugin lists can be loaded in different order
//return c->cell.sRecordId == cellData.sRecordId;
return c->cell.isExterior() ? (c->cell.mData.mX == cellData.mData.mX && c->cell.mData.mY == cellData.mData.mY) :
(c->cell.mName == cellData.mName);
});
@ -172,16 +163,14 @@ Cell *CellController::addCell(ESM::Cell cellData)
Cell *cell;
if (it == cells.end())
{
LOG_APPEND(Log::LOG_INFO, "- Adding %s to CellController",
cellData.getDescription().c_str());
LOG_APPEND(Log::LOG_INFO, "- Adding %s to CellController", cellData.getDescription().c_str());
cell = new Cell(cellData);
cells.push_back(cell);
}
else
{
LOG_APPEND(Log::LOG_INFO, "- Found %s in CellController",
cellData.getDescription().c_str());
LOG_APPEND(Log::LOG_INFO, "- Found %s in CellController", cellData.getDescription().c_str());
cell = *it;
}
@ -199,8 +188,7 @@ void CellController::removeCell(Cell *cell)
{
if (*it != nullptr && *it == cell)
{
LOG_APPEND(Log::LOG_INFO, "- Removing %s from CellController",
cell->getDescription().c_str());
LOG_APPEND(Log::LOG_INFO, "- Removing %s from CellController", cell->getDescription().c_str());
delete *it;
it = cells.erase(it);
@ -216,8 +204,7 @@ void CellController::removePlayer(Cell *cell, Player *player)
if (cell->players.empty())
{
LOG_APPEND(Log::LOG_INFO, "- Deleting empty cell from memory: %s",
cell->getDescription().c_str());
LOG_APPEND(Log::LOG_INFO, "- Deleting empty cell from memory: %s", cell->getDescription().c_str());
auto it = find(cells.begin(), cells.end(), cell);
delete *it;
cells.erase(it);
@ -226,13 +213,10 @@ void CellController::removePlayer(Cell *cell, Player *player)
void CellController::deletePlayer(Player *player)
{
LOG_APPEND(Log::LOG_INFO, "- Iterating through Cells from Player %s",
player->npc.mName.c_str());
LOG_APPEND(Log::LOG_INFO, "- Iterating through Cells from Player %s", player->npc.mName.c_str());
for (auto it = player->getCells()->begin(); player->getCells()->size() != 0; ++it)
{
removePlayer(*it, player);
}
}
void CellController::update(Player *player)

@ -81,9 +81,8 @@ void Networking::processPlayerPacket(RakNet::Packet *packet)
if (player->isHandshaked())
{
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Wrong handshake with player %d, name: %s",
player->getId(),
player->npc.mName.c_str());
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Wrong handshake with player %d, name: %s", player->getId(),
player->npc.mName.c_str());
kickPlayer(player->guid);
return;
}
@ -91,9 +90,7 @@ void Networking::processPlayerPacket(RakNet::Packet *packet)
if (player->passw != serverPassword)
{
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Wrong server password for player %d, name: %s (pass: %s)",
player->getId(),
player->npc.mName.c_str(),
player->passw.c_str());
player->getId(), player->npc.mName.c_str(), player->passw.c_str());
kickPlayer(player->guid);
return;
}
@ -103,8 +100,7 @@ void Networking::processPlayerPacket(RakNet::Packet *packet)
if (!player->isHandshaked())
{
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Have not completed handshake with player %d",
player->getId());
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Have not completed handshake with player %d", player->getId());
//KickPlayer(player->guid);
return;
}
@ -126,8 +122,7 @@ void Networking::processPlayerPacket(RakNet::Packet *packet)
}
else if (packet->data[0] == ID_PLAYER_BASEINFO)
{
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Received ID_PLAYER_BASEINFO about %s",
player->npc.mName.c_str());
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Received ID_PLAYER_BASEINFO about %s", player->npc.mName.c_str());
myPacket->Read(player);
myPacket->Send(player, true);
@ -146,13 +141,12 @@ void Networking::processPlayerPacket(RakNet::Packet *packet)
{
case ID_PLAYER_BASEINFO:
{
/*LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Received ID_PLAYER_BASEINFO about %s",
player->npc.mName.c_str());
/*LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Received ID_PLAYER_BASEINFO about %s", player->npc.mName.c_str());
myPacket->Read(player);
myPacket->Send(player, true);*/
myPacket->Read(player);
myPacket->Send(player, true);*/
break;
break;
}
case ID_PLAYER_POS:
{
@ -171,26 +165,25 @@ void Networking::processPlayerPacket(RakNet::Packet *packet)
}
case ID_PLAYER_CELL_CHANGE:
{
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Received ID_PLAYER_CELL_CHANGE from %s",
player->npc.mName.c_str());
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Received ID_PLAYER_CELL_CHANGE from %s", player->npc.mName.c_str());
if (!player->creatureStats.mDead)
{
myPacket->Read(player);
LOG_APPEND(Log::LOG_INFO, "- Moved to %s",
player->cell.getDescription().c_str());
LOG_APPEND(Log::LOG_INFO, "- Moved to %s", player->cell.getDescription().c_str());
player->forEachLoaded([this](Player *pl, Player *other) {
if (other == nullptr)
{
LOG_APPEND(Log::LOG_INFO, "- Tried to exchange information with nullptr!\n- Please report this to a developer");
LOG_APPEND(Log::LOG_INFO, "- Tried to exchange information with nullptr!");
LOG_APPEND(Log::LOG_INFO, "- Please report this to a developer");
}
else
{
LOG_APPEND(Log::LOG_INFO, "- Started information exchange with %s",
other->npc.mName.c_str());
other->npc.mName.c_str());
playerController->GetPacket(ID_PLAYER_DYNAMICSTATS)->Send(other, pl->guid);
playerController->GetPacket(ID_PLAYER_ATTRIBUTE)->Send(other, pl->guid);
@ -205,8 +198,7 @@ void Networking::processPlayerPacket(RakNet::Packet *packet)
playerController->GetPacket(ID_PLAYER_EQUIPMENT)->Send(pl, other->guid);
playerController->GetPacket(ID_PLAYER_DRAWSTATE)->Send(pl, other->guid);
LOG_APPEND(Log::LOG_INFO, "- Finished information exchange with %s",
other->npc.mName.c_str());
LOG_APPEND(Log::LOG_INFO, "- Finished information exchange with %s", other->npc.mName.c_str());
}
});
@ -215,21 +207,16 @@ void Networking::processPlayerPacket(RakNet::Packet *packet)
Script::Call<Script::CallbackIdentity("OnPlayerCellChange")>(player->getId());
LOG_APPEND(Log::LOG_INFO, "- Finished processing ID_PLAYER_CELL_CHANGE",
player->cell.getDescription().c_str());
LOG_APPEND(Log::LOG_INFO, "- Finished processing ID_PLAYER_CELL_CHANGE", player->cell.getDescription().c_str());
}
else
{
LOG_APPEND(Log::LOG_INFO, "- Ignored because %s is dead",
player->npc.mName.c_str());
}
LOG_APPEND(Log::LOG_INFO, "- Ignored because %s is dead", player->npc.mName.c_str());
break;
}
case ID_PLAYER_CELL_STATE:
{
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Received ID_PLAYER_CELL_STATE from %s",
player->npc.mName.c_str());
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Received ID_PLAYER_CELL_STATE from %s", player->npc.mName.c_str());
myPacket->Read(player);
@ -339,7 +326,7 @@ void Networking::processPlayerPacket(RakNet::Packet *packet)
target = player;
LOG_MESSAGE_SIMPLE(Log::LOG_VERBOSE, "Player: %s attacked %s state: %d", player->npc.mName.c_str(),
target->npc.mName.c_str(), player->attack.pressed == 1);
target->npc.mName.c_str(), player->attack.pressed == 1);
if (player->attack.pressed == 0)
{
LOG_APPEND(Log::LOG_VERBOSE, "success: %d", player->attack.success == 1);
@ -371,8 +358,7 @@ void Networking::processPlayerPacket(RakNet::Packet *packet)
case ID_GAME_DIE:
{
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Received ID_GAME_DIE from %s",
player->npc.mName.c_str());
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Received ID_GAME_DIE from %s", player->npc.mName.c_str());
Player *killer = Players::getPlayer(player->getLastAttackerId());
@ -445,10 +431,7 @@ void Networking::processPlayerPacket(RakNet::Packet *packet)
myPacket->Read(player);
if (player->charGenStage.current == player->charGenStage.end && player->charGenStage.current != 0)
{
Script::Call<Script::CallbackIdentity("OnPlayerEndCharGen")>(player->getId());
cout << "RACE: " << player->npc.mRace << endl;
}
break;
}
@ -470,8 +453,7 @@ void Networking::processPlayerPacket(RakNet::Packet *packet)
}
default:
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Unhandled PlayerPacket with identifier %i has arrived",
packet->data[0]);
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Unhandled PlayerPacket with identifier %i has arrived", packet->data[0]);
break;
}
}
@ -495,83 +477,67 @@ void Networking::processWorldPacket(RakNet::Packet *packet)
case ID_OBJECT_PLACE:
{
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Received ID_OBJECT_PLACE from %s",
player->npc.mName.c_str());
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Received ID_OBJECT_PLACE from %s", player->npc.mName.c_str());
myPacket->Read(&baseEvent);
myPacket->Send(&baseEvent, true);
Script::Call<Script::CallbackIdentity("OnObjectPlace")>(
player->getId(),
baseEvent.cell.getDescription().c_str());
Script::Call<Script::CallbackIdentity("OnObjectPlace")>(player->getId(), baseEvent.cell.getDescription().c_str());
break;
}
case ID_OBJECT_DELETE:
{
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Received ID_OBJECT_DELETE from %s",
player->npc.mName.c_str());
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Received ID_OBJECT_DELETE from %s", player->npc.mName.c_str());
myPacket->Read(&baseEvent);
myPacket->Send(&baseEvent, true);
Script::Call<Script::CallbackIdentity("OnObjectDelete")>(
player->getId(),
baseEvent.cell.getDescription().c_str());
Script::Call<Script::CallbackIdentity("OnObjectDelete")>(player->getId(), baseEvent.cell.getDescription().c_str());
break;
}
case ID_OBJECT_SCALE:
{
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Received ID_OBJECT_SCALE from %s",
player->npc.mName.c_str());
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Received ID_OBJECT_SCALE from %s", player->npc.mName.c_str());
myPacket->Read(&baseEvent);
myPacket->Send(&baseEvent, true);
Script::Call<Script::CallbackIdentity("OnObjectScale")>(
player->getId(),
baseEvent.cell.getDescription().c_str());
Script::Call<Script::CallbackIdentity("OnObjectScale")>(player->getId(), baseEvent.cell.getDescription().c_str());
break;
}
case ID_OBJECT_LOCK:
{
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Received ID_OBJECT_LOCK from %s",
player->npc.mName.c_str());
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Received ID_OBJECT_LOCK from %s", player->npc.mName.c_str());
myPacket->Read(&baseEvent);
myPacket->Send(&baseEvent, true);
Script::Call<Script::CallbackIdentity("OnObjectLock")>(
player->getId(),
baseEvent.cell.getDescription().c_str());
Script::Call<Script::CallbackIdentity("OnObjectLock")>(player->getId(), baseEvent.cell.getDescription().c_str());
break;
}
case ID_OBJECT_UNLOCK:
{
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Received ID_OBJECT_UNLOCK from %s",
player->npc.mName.c_str());
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Received ID_OBJECT_UNLOCK from %s", player->npc.mName.c_str());
myPacket->Read(&baseEvent);
myPacket->Send(&baseEvent, true);
Script::Call<Script::CallbackIdentity("OnObjectUnlock")>(
player->getId(),
baseEvent.cell.getDescription().c_str());
Script::Call<Script::CallbackIdentity("OnObjectUnlock")>(player->getId(), baseEvent.cell.getDescription().c_str());
break;
}
case ID_OBJECT_MOVE:
{
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Received ID_OBJECT_MOVE from %s",
player->npc.mName.c_str());
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Received ID_OBJECT_MOVE from %s", player->npc.mName.c_str());
myPacket->Read(&baseEvent);
myPacket->Send(&baseEvent, true);
@ -581,8 +547,7 @@ void Networking::processWorldPacket(RakNet::Packet *packet)
case ID_OBJECT_ROTATE:
{
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Received ID_OBJECT_ROTATE from %s",
player->npc.mName.c_str());
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Received ID_OBJECT_ROTATE from %s", player->npc.mName.c_str());
myPacket->Read(&baseEvent);
myPacket->Send(&baseEvent, true);
@ -592,8 +557,7 @@ void Networking::processWorldPacket(RakNet::Packet *packet)
case ID_OBJECT_ANIM_PLAY:
{
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Received ID_OBJECT_ANIM_PLAY from %s",
player->npc.mName.c_str());
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Received ID_OBJECT_ANIM_PLAY from %s", player->npc.mName.c_str());
myPacket->Read(&baseEvent);
myPacket->Send(&baseEvent, true);
@ -603,23 +567,19 @@ void Networking::processWorldPacket(RakNet::Packet *packet)
case ID_DOOR_STATE:
{
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Received ID_DOOR_STATE from %s",
player->npc.mName.c_str());
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Received ID_DOOR_STATE from %s", player->npc.mName.c_str());
myPacket->Read(&baseEvent);
myPacket->Send(&baseEvent, true);
Script::Call<Script::CallbackIdentity("OnDoorState")>(
player->getId(),
baseEvent.cell.getDescription().c_str());
Script::Call<Script::CallbackIdentity("OnDoorState")>(player->getId(), baseEvent.cell.getDescription().c_str());
break;
}
case ID_CONTAINER:
{
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Received ID_CONTAINER from %s",
player->npc.mName.c_str());
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Received ID_CONTAINER from %s", player->npc.mName.c_str());
myPacket->Read(&baseEvent);
@ -633,9 +593,7 @@ void Networking::processWorldPacket(RakNet::Packet *packet)
else
myPacket->Send(&baseEvent, true);
Script::Call<Script::CallbackIdentity("OnContainer")>(
player->getId(),
baseEvent.cell.getDescription().c_str());
Script::Call<Script::CallbackIdentity("OnContainer")>(player->getId(), baseEvent.cell.getDescription().c_str());
LOG_APPEND(Log::LOG_INFO, "- Finished processing ID_CONTAINER");
@ -644,8 +602,7 @@ void Networking::processWorldPacket(RakNet::Packet *packet)
case ID_SCRIPT_LOCAL_SHORT:
{
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Received ID_SCRIPT_LOCAL_SHORT from %s",
player->npc.mName.c_str());
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Received ID_SCRIPT_LOCAL_SHORT from %s", player->npc.mName.c_str());
myPacket->Read(&baseEvent);
myPacket->Send(&baseEvent, true);
@ -655,8 +612,7 @@ void Networking::processWorldPacket(RakNet::Packet *packet)
case ID_SCRIPT_LOCAL_FLOAT:
{
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Received ID_SCRIPT_LOCAL_FLOAT from %s",
player->npc.mName.c_str());
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Received ID_SCRIPT_LOCAL_FLOAT from %s", player->npc.mName.c_str());
myPacket->Read(&baseEvent);
myPacket->Send(&baseEvent, true);
@ -666,8 +622,7 @@ void Networking::processWorldPacket(RakNet::Packet *packet)
case ID_SCRIPT_MEMBER_SHORT:
{
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Received ID_SCRIPT_MEMBER_SHORT from %s",
player->npc.mName.c_str());
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Received ID_SCRIPT_MEMBER_SHORT from %s", player->npc.mName.c_str());
myPacket->Read(&baseEvent);
myPacket->Send(&baseEvent, true);
@ -677,8 +632,7 @@ void Networking::processWorldPacket(RakNet::Packet *packet)
case ID_SCRIPT_GLOBAL_SHORT:
{
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Received ID_SCRIPT_GLOBAL_SHORT from %s",
player->npc.mName.c_str());
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Received ID_SCRIPT_GLOBAL_SHORT from %s", player->npc.mName.c_str());
myPacket->Read(&baseEvent);
myPacket->Send(&baseEvent, true);
@ -688,8 +642,7 @@ void Networking::processWorldPacket(RakNet::Packet *packet)
case ID_MUSIC_PLAY:
{
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Received ID_MUSIC_PLAY from %s",
player->npc.mName.c_str());
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Received ID_MUSIC_PLAY from %s", player->npc.mName.c_str());
myPacket->Read(&baseEvent);
myPacket->Send(&baseEvent, true);
@ -699,8 +652,7 @@ void Networking::processWorldPacket(RakNet::Packet *packet)
case ID_VIDEO_PLAY:
{
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Received ID_VIDEO_PLAY from %s",
player->npc.mName.c_str());
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Received ID_VIDEO_PLAY from %s", player->npc.mName.c_str());
myPacket->Read(&baseEvent);
myPacket->Send(&baseEvent, true);
@ -709,8 +661,7 @@ void Networking::processWorldPacket(RakNet::Packet *packet)
}
default:
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Unhandled WorldPacket with identifier %i has arrived",
packet->data[0]);
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Unhandled WorldPacket with identifier %i has arrived", packet->data[0]);
break;
}
@ -745,10 +696,7 @@ void Networking::update(RakNet::Packet *packet)
processWorldPacket(packet);
}
else
{
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Unhandled RakNet packet with identifier %i has arrived",
packet->data[0]);
}
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Unhandled RakNet packet with identifier %i has arrived", packet->data[0]);
}
void Networking::newPlayer(RakNet::RakNetGUID guid)
@ -759,8 +707,7 @@ void Networking::newPlayer(RakNet::RakNetGUID guid)
playerController->GetPacket(ID_PLAYER_CELL_CHANGE)->RequestData(guid);
playerController->GetPacket(ID_PLAYER_EQUIPMENT)->RequestData(guid);
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Sending info about other players to %lu",
guid.g);
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Sending info about other players to %lu", guid.g);
for (TPlayers::iterator pl = players->begin(); pl != players->end(); pl++) //sending other players to new player
{
@ -845,16 +792,13 @@ int Networking::mainLoop()
switch (packet->data[0])
{
case ID_REMOTE_DISCONNECTION_NOTIFICATION:
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Client at %s has disconnected",
packet->systemAddress.ToString());
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Client at %s has disconnected", packet->systemAddress.ToString());
break;
case ID_REMOTE_CONNECTION_LOST:
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Client at %s has lost connection",
packet->systemAddress.ToString());
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Client at %s has lost connection", packet->systemAddress.ToString());
break;
case ID_REMOTE_NEW_INCOMING_CONNECTION:
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Client at %s has connected",
packet->systemAddress.ToString());
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Client at %s has connected", packet->systemAddress.ToString());
break;
case ID_CONNECTION_REQUEST_ACCEPTED: // client to server
{
@ -862,20 +806,17 @@ int Networking::mainLoop()
break;
}
case ID_NEW_INCOMING_CONNECTION:
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "A connection is incoming from %s",
packet->systemAddress.ToString());
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "A connection is incoming from %s", packet->systemAddress.ToString());
break;
case ID_NO_FREE_INCOMING_CONNECTIONS:
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "The server is full");
break;
case ID_DISCONNECTION_NOTIFICATION:
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Client at %s has disconnected",
packet->systemAddress.ToString());
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Client at %s has disconnected", packet->systemAddress.ToString());
disconnectPlayer(packet->guid);
break;
case ID_CONNECTION_LOST:
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Client at %s has lost connection",
packet->systemAddress.ToString());
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Client at %s has lost connection", packet->systemAddress.ToString());
disconnectPlayer(packet->guid);
break;
case ID_CONNECTED_PING:
@ -883,8 +824,7 @@ int Networking::mainLoop()
break;
case ID_MASTER_QUERY:
{
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Query request from %s",
packet->systemAddress.ToString());
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Query request from %s", packet->systemAddress.ToString());
RakNet::BitStream bs;
bs.Write((unsigned char) ID_MASTER_QUERY);
bs.Write(Players::getPlayers()->size());

@ -10,15 +10,13 @@ TSlots Players::slots;
void Players::deletePlayer(RakNet::RakNetGUID guid)
{
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Deleting player with guid %lu",
guid.g);
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Deleting player with guid %lu", guid.g);
if (players[guid] != 0)
{
CellController::get()->deletePlayer(players[guid]);
LOG_APPEND(Log::LOG_INFO, "- Emptying slot %i",
players[guid]->getId());
LOG_APPEND(Log::LOG_INFO, "- Emptying slot %i", players[guid]->getId());
slots[players[guid]->getId()] = 0;
delete players[guid];
@ -28,8 +26,7 @@ void Players::deletePlayer(RakNet::RakNetGUID guid)
void Players::newPlayer(RakNet::RakNetGUID guid)
{
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Creating new player with guid %lu",
guid.g);
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Creating new player with guid %lu", guid.g);
players[guid] = new Player(guid);
players[guid]->cell.blank();
@ -42,8 +39,7 @@ void Players::newPlayer(RakNet::RakNetGUID guid)
{
if (slots[i] == 0)
{
LOG_APPEND(Log::LOG_INFO, "- Storing in slot %i",
i);
LOG_APPEND(Log::LOG_INFO, "- Storing in slot %i", i);
slots[i] = players[guid];
slots[i]->setId(i);

@ -54,17 +54,14 @@ void CellFunctions::SetCell(unsigned short pid, const char *name) noexcept
Player *player;
GET_PLAYER(pid, player,);
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Script is moving %s from %s to %s",
player->npc.mName.c_str(),
player->cell.getDescription().c_str(),
name);
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Script is moving %s from %s to %s", player->npc.mName.c_str(),
player->cell.getDescription().c_str(), name);
// If the player is currently in an exterior, turn on the interior flag
// from the cell so the player doesn't get teleported to their exterior
// grid position (which we haven't changed)
if (player->cell.isExterior()) {
if (player->cell.isExterior())
player->cell.mData.mFlags |= ESM::Cell::Interior;
}
player->cell.mName = name;
}
@ -74,17 +71,13 @@ void CellFunctions::SetExterior(unsigned short pid, int x, int y) noexcept
Player *player;
GET_PLAYER(pid, player,);
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Script is moving %s from %s to %i,%i",
player->npc.mName.c_str(),
player->cell.getDescription().c_str(),
x,
y);
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Script is moving %s from %s to %i,%i", player->npc.mName.c_str(),
player->cell.getDescription().c_str(), x, y);
// If the player is currently in an interior, turn off the interior flag
// from the cell
if (!player->cell.isExterior()) {
if (!player->cell.isExterior())
player->cell.mData.mFlags &= ~ESM::Cell::Interior;
}
player->cell.mData.mX = x;
player->cell.mData.mY = y;

@ -63,10 +63,8 @@ void StatsFunctions::SetRace(unsigned short pid, const char *race) noexcept
if (player->npc.mRace == race)
return;
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Setting race for %s: %s -> %s",
player->npc.mName.c_str(),
player->npc.mRace.c_str(),
race);
LOG_MESSAGE_SIMPLE(Log::LOG_VERBOSE, "Setting race for %s: %s -> %s", player->npc.mName.c_str(),
player->npc.mRace.c_str(), race);
player->npc.mRace = race;
}

@ -63,7 +63,8 @@ static typename enable_if<ScriptFunctions::functions[I].func.ret == 'v', int>::t
template<unsigned int I>
static typename enable_if<ScriptFunctions::functions[I].func.ret != 'v', int>::type wrapper(lua_State* lua) noexcept {
auto ret = Lua_dispatch_<ScriptFunctions::functions[I].func.numargs, I>::template Lua_dispatch<typename CharType<ScriptFunctions::functions[I].func.ret>::type>(forward<lua_State*>(lua));
auto ret = Lua_dispatch_<ScriptFunctions::functions[I].func.numargs, I>::template Lua_dispatch<
typename CharType<ScriptFunctions::functions[I].func.ret>::type>(forward<lua_State*>(lua));
luabridge::Stack <typename CharType<ScriptFunctions::functions[I].func.ret>::type>::push (lua, ret);
return 1;
}

@ -77,7 +77,8 @@ public:
template<unsigned int I, bool B = false, typename... Args>
static unsigned int Call(CallBackReturn<I>& result, Args&&... args) {
constexpr ScriptCallbackData const& data = CallBackData(I);
static_assert(data.callback.matches(TypeString<typename std::remove_reference<Args>::type...>::value), "Wrong number or types of arguments");
static_assert(data.callback.matches(TypeString<typename std::remove_reference<Args>::type...>::value),
"Wrong number or types of arguments");
unsigned int count = 0;
@ -119,7 +120,8 @@ public:
template<unsigned int I, bool B = false, typename... Args>
static unsigned int Call(Args&&... args) {
constexpr ScriptCallbackData const& data = CallBackData(I);
static_assert(data.callback.matches(TypeString<typename std::remove_reference<Args>::type...>::value), "Wrong number or types of arguments");
static_assert(data.callback.matches(TypeString<typename std::remove_reference<Args>::type...>::value),
"Wrong number or types of arguments");
unsigned int count = 0;

@ -16,20 +16,22 @@
using namespace std;
ScriptFunction::ScriptFunction(ScriptFunc fCpp,char ret_type, const string &def) : fCpp(fCpp), ret_type(ret_type), def(def), script_type(SCRIPT_CPP)
ScriptFunction::ScriptFunction(ScriptFunc fCpp,char ret_type, const string &def) :
fCpp(fCpp), ret_type(ret_type), def(def), script_type(SCRIPT_CPP)
{
}
#if defined (ENABLE_LUA)
ScriptFunction::ScriptFunction(const ScriptFuncLua &fLua, lua_State *lua, char ret_type, const std::string &def) :fLua({lua, fLua}), ret_type(ret_type), def(def), script_type(SCRIPT_LUA)
ScriptFunction::ScriptFunction(const ScriptFuncLua &fLua, lua_State *lua, char ret_type, const std::string &def) :
fLua({lua, fLua}), ret_type(ret_type), def(def), script_type(SCRIPT_LUA)
{
}
#endif
#if defined (ENABLE_PAWN)
ScriptFunction::ScriptFunction(const ScriptFuncPAWN &fPawn, AMX *amx, char ret_type, const string &def) : fPawn({amx, fPawn}),
def(def), ret_type(ret_type), script_type(SCRIPT_PAWN)
ScriptFunction::ScriptFunction(const ScriptFuncPAWN &fPawn, AMX *amx, char ret_type, const string &def) :
fPawn({amx, fPawn}), def(def), ret_type(ret_type), script_type(SCRIPT_PAWN)
{
}

Loading…
Cancel
Save