Use logger for most console messages

coverity_scan^2
David Cernat 8 years ago
parent 535731c018
commit 97f944dde7

@ -80,14 +80,19 @@ void Networking::Update(RakNet::Packet *packet)
if (player->isHandshaked())
{
DEBUG_PRINTF("Wrong handshake with player %d, name: %s\n", player->GetID(), player->Npc()->mName.c_str());
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Wrong handshake with player %d, name: %s\n",
player->GetID(),
player->Npc()->mName.c_str());
KickPlayer(player->guid);
return;
}
if (*player->GetPassw() != passw)
{
DEBUG_PRINTF("Wrong server password (player %d, name: %s) pass: %s\n", player->GetID(), player->Npc()->mName.c_str(), player->GetPassw()->c_str());
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Wrong server password for player %d, name: %s (pass: %s)\n",
player->GetID(),
player->Npc()->mName.c_str(),
player->GetPassw()->c_str());
KickPlayer(player->guid);
return;
}
@ -110,7 +115,9 @@ void Networking::Update(RakNet::Packet *packet)
if (!player->isHandshaked())
{
DEBUG_PRINTF("Wrong auth player %d, name: %s\n", player->GetID(), player->Npc()->mName.c_str());
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Wrong auth for player %d, name: %s\n",
player->GetID(),
player->Npc()->mName.c_str());
//KickPlayer(player->guid);
return;
}
@ -119,7 +126,8 @@ void Networking::Update(RakNet::Packet *packet)
{
case ID_GAME_BASE_INFO:
{
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Received ID_GAME_BASE_INFO about %s", player->Npc()->mName.c_str());
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Received ID_GAME_BASE_INFO about %s",
player->Npc()->mName.c_str());
myPacket->Read(player);
myPacket->Send(player, true);

@ -8,6 +8,7 @@
#include <components/esm/attr.hpp>
#include <components/esm/loadskil.hpp>
#include <components/misc/stringops.hpp>
#include <components/openmw-mp/Log.hpp>
#include <iostream>
using namespace std;
@ -62,7 +63,10 @@ void ScriptFunctions::SetRace(unsigned short pid, const char *race) noexcept
if (player->Npc()->mRace == race)
return;
printf("Attempt to set race %s -> %s\n", player->Npc()->mRace.c_str(), race);
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Seting race for %s: %s -> %s\n",
player->Npc()->mName.c_str(),
player->Npc()->mRace.c_str(),
race);
player->Npc()->mRace = race;
}

@ -19,6 +19,7 @@
#include "../mwworld/action.hpp"
#include <apps/openmw/mwworld/inventorystore.hpp>
#include <boost/algorithm/clamp.hpp>
#include <components/openmw-mp/Log.hpp>
using namespace mwmp;
using namespace std;
@ -389,6 +390,7 @@ DedicatedPlayer *Players::GetPlayer(const MWWorld::Ptr &ptr)
void DedicatedPlayer::UpdateDrawState()
{
using namespace MWMechanics;
if (drawState == 0)
ptr.getClass().getNpcStats(ptr).setDrawState(DrawState_Nothing);
@ -421,12 +423,10 @@ void DedicatedPlayer::updateCell()
else
return;
// tes3mp debug start
printf("Server says %s (%s) moved to %s\n",
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Server says %s (%s) moved to %s\n",
ptr.getBase()->mRef.getRefId().c_str(),
this->Npc()->mName.c_str(),
cellStore->getCell()->getDescription().c_str());
// tes3mp debug end
// Allow this player's reference to move across a cell now that
// a manual cell update has been called

@ -87,7 +87,6 @@ void mwmp::GUIController::ShowCustomMessageBox(const BasePlayer::GUIMessageBox &
void mwmp::GUIController::ShowInputBox(const BasePlayer::GUIMessageBox &guiMessageBox)
{
printf("test adf\n");
MWBase::WindowManager *windowManager = MWBase::Environment::get().getWindowManager();
windowManager->removeDialog(mInputBox);

@ -22,6 +22,7 @@
#include <apps/openmw/mwworld/inventorystore.hpp>
#include <apps/openmw/mwmechanics/spellcasting.hpp>
#include <apps/openmw/mwgui/inventorywindow.hpp>
#include <components/openmw-mp/Log.hpp>
#include "LocalPlayer.hpp"
#include "Main.hpp"
@ -228,7 +229,6 @@ void LocalPlayer::updateAttackState(bool forceUpdate)
//player.getClass().onHit(player, 0.5, true, weapon, 0, 1);
if (state == MWMechanics::DrawState_Spell)
{
//cout << "getAttackingOrSpell" << endl;
const string &spell = MWBase::Environment::get().getWindowManager()->getSelectedSpell();
GetAttack()->attacker = guid;
@ -383,11 +383,9 @@ void LocalPlayer::updateCell(bool forceUpdate)
if (shouldUpdate)
{
// tes3mp debug start
printf("Telling server I moved from %s to %s\n",
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Telling server I moved from %s to %s\n",
GetCell()->getDescription().c_str(),
_cell->getDescription().c_str());
// tes3mp debug end
(*GetCell()) = *_cell;
isExterior = _cell->isExterior();
@ -486,7 +484,7 @@ bool LocalPlayer::CharGenThread() // ToDo: need fix
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr();
(*Npc()) = *player.get<ESM::NPC>()->mBase;
printf("Sending ID_GAME_BASE_INFO to server with my CharGen info\n");
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Sending ID_GAME_BASE_INFO to server with my CharGen info\n");
GetNetworking()->GetPacket(ID_GAME_BASE_INFO)->Send(this);
if (CharGenStage()->end != 1)

@ -16,6 +16,7 @@
#include <SDL_messagebox.h>
#include "Networking.hpp"
#include "../mwstate/statemanagerimp.hpp"
#include <components/openmw-mp/Log.hpp>
#include "DedicatedPlayer.hpp"
#include "Main.hpp"
@ -49,35 +50,35 @@ void Networking::Update()
switch (packet->data[0])
{
case ID_REMOTE_DISCONNECTION_NOTIFICATION:
printf("Another client has disconnected.\n");
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Another client has disconnected.\n");
break;
case ID_REMOTE_CONNECTION_LOST:
printf("Another client has lost connection.\n");
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Another client has lost connection.\n");
break;
case ID_REMOTE_NEW_INCOMING_CONNECTION:
printf("Another client has connected.\n");
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Another client has connected.\n");
break;
case ID_CONNECTION_REQUEST_ACCEPTED:
printf("Our connection request has been accepted.\n");
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Our connection request has been accepted.\n");
break;
case ID_NEW_INCOMING_CONNECTION:
printf("A connection is incoming.\n");
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "A connection is incoming.\n");
break;
case ID_NO_FREE_INCOMING_CONNECTIONS:
printf("The server is full.\n");
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "The server is full.\n");
MWBase::Environment::get().getStateManager()->requestQuit();
break;
case ID_DISCONNECTION_NOTIFICATION:
printf("We have been disconnected.\n");
MWBase::Environment::get().getStateManager()->requestQuit();
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "We have been disconnected.\n");
MWBase::Environment::get().getStateManager()->requestQuit();
break;
case ID_CONNECTION_LOST:
printf("Connection lost.\n");
MWBase::Environment::get().getStateManager()->requestQuit();
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Connection lost.\n");
MWBase::Environment::get().getStateManager()->requestQuit();
break;
default:
ReceiveMessage(packet);
//printf("Message with identifier %i has arrived.\n", packet->data[0]);
//LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Message with identifier %i has arrived.\n", packet->data[0]);
break;
}
}
@ -140,7 +141,7 @@ void Networking::Connect(const std::string &ip, unsigned short port)
case ID_CONNECTION_LOST:
throw runtime_error("ID_CONNECTION_LOST.\n");
default:
printf("Connection message with identifier %i has arrived in initialization.\n", packet->data[0]);
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Connection message with identifier %i has arrived in initialization.\n", packet->data[0]);
}
}
}
@ -180,31 +181,31 @@ void Networking::ReceiveMessage(RakNet::Packet *packet)
}
case ID_GAME_BASE_INFO:
{
printf("Received ID_GAME_BASE_INFO from server\n");
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Received ID_GAME_BASE_INFO from server\n");
if (id == myid)
{
printf("- Packet was about my id\n");
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "- Packet was about my id\n");
if (packet->length == myPacket->headerSize())
{
cout << "ID_GAME_BASE_INFO request only" << endl;
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "- Requesting info");
myPacket->Send(getLocalPlayer(), serverAddr);
}
else
{
myPacket->Packet(&bsIn, getLocalPlayer(), false);
cout << "- Updating LocalPlayer" << endl;
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "- Updating LocalPlayer\n");
getLocalPlayer()->updateChar();
}
}
else
{
printf("- Packet was about %s\n", pl == 0 ? "new player" : pl->Npc()->mName.c_str());
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "- Packet was about %s\n", pl == 0 ? "new player" : pl->Npc()->mName.c_str());
if (pl == 0) {
printf("- Exchanging data with new player\n");
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "- Exchanging data with new player\n");
pl = Players::NewPlayer(id);
}
@ -219,7 +220,7 @@ void Networking::ReceiveMessage(RakNet::Packet *packet)
{
if (packet->length != myPacket->headerSize())
{
cout << "ID_GAME_UPDATE_POS changed by server" << endl;
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "ID_GAME_UPDATE_POS changed by server\n");
myPacket->Packet(&bsIn, getLocalPlayer(), false);
getLocalPlayer()->setPosition();
}
@ -232,7 +233,7 @@ void Networking::ReceiveMessage(RakNet::Packet *packet)
}
case ID_USER_MYID:
{
cout << "ID_USER_MYID" << endl;
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Received ID_USER_MYID from server");
myid = id;
getLocalPlayer()->guid = id;
break;
@ -261,19 +262,13 @@ void Networking::ReceiveMessage(RakNet::Packet *packet)
}
case ID_GAME_UPDATE_SKILLS:
{
printf("Received ID_GAME_UPDATE_SKILLS from server\n");
if (id == myid)
{
printf("- Packet was about my id\n");
getLocalPlayer()->updateAttributesAndSkills(true);
myPacket->Send(getLocalPlayer(), serverAddr);
}
else if (pl != 0)
{
printf("- Packet was about %s\n", pl->Npc()->mName.c_str());
myPacket->Packet(&bsIn, pl, false);
MWMechanics::SkillValue skillValue;
@ -302,10 +297,14 @@ void Networking::ReceiveMessage(RakNet::Packet *packet)
//cout << "Player: " << pl->Npc()->mName << " pressed: " << (pl->GetAttack()->pressed == 1) << endl;
if (pl->GetAttack()->pressed == 0)
{
cout << "success: " << (pl->GetAttack()->success == 1);
LOG_MESSAGE_SIMPLE(Log::LOG_VERBOSE, "Attack success: %s\n",
pl->GetAttack()->success ? "true" : "false");
if (pl->GetAttack()->success == 1)
cout << " damage: " << pl->GetAttack()->damage;
cout << endl;
{
LOG_MESSAGE_SIMPLE(Log::LOG_VERBOSE, "Damage: %f\n",
pl->GetAttack()->damage);
}
}
MWMechanics::CreatureStats &stats = pl->getPtr().getClass().getNpcStats(pl->getPtr());
@ -349,7 +348,8 @@ void Networking::ReceiveMessage(RakNet::Packet *packet)
}
else
{
cout << "SpellId: " << pl->GetAttack()->refid << endl;
LOG_MESSAGE_SIMPLE(Log::LOG_VERBOSE, "SpellId: %s\n",
pl->GetAttack()->refid.c_str());
}
}
break;
@ -377,7 +377,7 @@ void Networking::ReceiveMessage(RakNet::Packet *packet)
}
case ID_GAME_DIE:
{
printf("ID_GAME_DIE\n");
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Received ID_GAME_DIE from server\n");
if (id == myid)
{
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr();
@ -388,7 +388,7 @@ void Networking::ReceiveMessage(RakNet::Packet *packet)
}
else if (pl != 0)
{
printf("Attempt to kill %s\n", pl->Npc()->mName.c_str());
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "- Packet was about %s\n", pl->Npc()->mName.c_str());
MWMechanics::DynamicStat<float> health;
pl->CreatureStats()->mDead = true;
health.readState(pl->CreatureStats()->mDynamic[0]);
@ -538,7 +538,7 @@ void Networking::ReceiveMessage(RakNet::Packet *packet)
{
skillValue.readState(__pl->NpcStats()->mSkills[i]);
__pl_ptr.getClass().getNpcStats(__pl_ptr).setSkill(i, skillValue);
//printf("skill %d, value %d\n", i, skillValue.getBase());
//LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "skill %d, value %d\n", i, skillValue.getBase());
}
break;
@ -549,7 +549,9 @@ void Networking::ReceiveMessage(RakNet::Packet *packet)
{
myPacket->Packet(&bsIn, getLocalPlayer(), false);
printf("ID_GUI_MESSAGEBOX, Type %d, MSG %s\n", getLocalPlayer()->guiMessageBox.type, getLocalPlayer()->guiMessageBox.label.c_str());
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "ID_GUI_MESSAGEBOX, Type %d, MSG %s\n",
getLocalPlayer()->guiMessageBox.type,
getLocalPlayer()->guiMessageBox.label.c_str());
if (getLocalPlayer()->guiMessageBox.type == BasePlayer::GUIMessageBox::MessageBox)
Main::get().getGUIConroller()->ShowMessageBox(getLocalPlayer()->guiMessageBox);
@ -561,7 +563,7 @@ void Networking::ReceiveMessage(RakNet::Packet *packet)
break;
}
default:
printf("Custom message with identifier %i has arrived in initialization.\n", packet->data[0]);
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Custom message with identifier %i has arrived in initialization.\n", packet->data[0]);
}
}

Loading…
Cancel
Save