From: Manuel A. F. M. <ma...@us...> - 2005-11-28 17:36:43
|
Update of /cvsroot/once/oncecode/src/server/world In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2236/src/server/world Modified Files: octimemgr.h octimemgr.cpp ocsubscription.cpp Log Message: Changes for the new logging system Index: octimemgr.h =================================================================== RCS file: /cvsroot/once/oncecode/src/server/world/octimemgr.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** octimemgr.h 17 Jul 2005 13:51:07 -0000 1.4 --- octimemgr.h 28 Nov 2005 17:36:20 -0000 1.5 *************** *** 30,38 **** { private: ! /// Game time variable, stored in the DB between executions. The ! /// unit of time is 1 minute in game, with a day being 2h of ! /// realtime a minute is 60/12 = 5 seconds -- this is the minimal ! /// resolution of the game. ! uint32 gametime; /// Auxiliar variable to increase gametime every 5 seconds --- 30,39 ---- { private: ! /** Game time variable, stored in the DB between executions. The ! * unit of time is 1 minute in game, with a day being 2h of ! * realtime a minute is 60/12 = 5 seconds -- this is the minimal ! * resolution of the game. ! */ ! unsigned int gametime; /// Auxiliar variable to increase gametime every 5 seconds Index: ocsubscription.cpp =================================================================== RCS file: /cvsroot/once/oncecode/src/server/world/ocsubscription.cpp,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** ocsubscription.cpp 15 Oct 2005 01:31:52 -0000 1.9 --- ocsubscription.cpp 28 Nov 2005 17:36:20 -0000 1.10 *************** *** 19,23 **** #include "config.h" - #include "common/oclogger.h" #include <physicallayer/entity.h> --- 19,22 ---- *************** *** 35,40 **** const char* _mesh_type, const char* _mesh_subtype) { - OCTRACE("ocSubscribable::SetBasicData"); - this->id = _id; this->name = _name; --- 34,37 ---- *************** *** 47,52 **** void ocSubscribable::SetSubscribablePosition(ocEntityChangeMsg* _position) { - OCTRACE("ocSubscribable::SetPosition"); - this->position = *_position; } --- 44,47 ---- *************** *** 54,60 **** void ocSubscribable::AddSubscriber(ocPlayerBehaviour* player) { ! OCTRACE("ocSubscribable::AddSubscriber"); ! ! printf(" + Subscribing player '%s' to entity: name='%s', id='%d'\n", player->GetPlayerName(), this->name.c_str(), this->id); --- 49,53 ---- void ocSubscribable::AddSubscriber(ocPlayerBehaviour* player) { ! LogDBG(" + Subscribing player '%s' to entity: name='%s', id='%d'", player->GetPlayerName(), this->name.c_str(), this->id); *************** *** 69,73 **** msg.position = this->position.position; msg.yrot = this->position.yrot; ! serversys->GetNetworkMgr()->SendToPlayer(&msg, player->GetNetLink(), true, false); subscribers.push_back(player); --- 62,66 ---- msg.position = this->position.position; msg.yrot = this->position.yrot; ! Server->GetNetworkMgr()->SendToPlayer(&msg, player->GetLoginData(), true, false); subscribers.push_back(player); *************** *** 76,82 **** void ocSubscribable::RemoveSubscriber(ocPlayerBehaviour* player) { ! OCTRACE("ocSubscribable::RemoveSubscriber"); ! ! printf(" + Unsubscribing player '%s' from entity: name='%s', id='%d'\n", player->GetPlayerName(), this->name.c_str(), this->id); --- 69,73 ---- void ocSubscribable::RemoveSubscriber(ocPlayerBehaviour* player) { ! LogDBG(" + Unsubscribing player '%s' from entity: name='%s', id='%d'", player->GetPlayerName(), this->name.c_str(), this->id); *************** *** 98,102 **** if (!success) { ! printf(" ! Could not remove player '%s' subscribed to entity: name='%s', id='%d'\n", player->GetPlayerName(), this->name.c_str(), this->id); return; --- 89,93 ---- if (!success) { ! LogERR("Could not remove player '%s' subscribed to entity: name='%s', id='%d'", player->GetPlayerName(), this->name.c_str(), this->id); return; *************** *** 106,117 **** msg.entity_id = this->id; msg.entity_name = this->name; ! serversys->GetNetworkMgr()->SendToPlayer(&msg, player->GetNetLink(), true, false); } void ocSubscribable::RemoveAllSubscribers() { ! OCTRACE("ocSubscribable::RemoveAllSubscribers"); ! ! printf(" + Unsubscribing ALL from entity: name='%s', id='%d'\n", this->name.c_str(), this->id); --- 97,106 ---- msg.entity_id = this->id; msg.entity_name = this->name; ! Server->GetNetworkMgr()->SendToPlayer(&msg, player->GetLoginData(), true, false); } void ocSubscribable::RemoveAllSubscribers() { ! LogDBG(" + Unsubscribing ALL from entity: name='%s', id='%d'", this->name.c_str(), this->id); *************** *** 124,130 **** void ocSubscribable::PrintSubscribers() { ! OCTRACE("ocSubscribable::PrintSubscribers"); ! ! printf(" - Printing subscribers of entity: name='%s', id='%d'\n", this->name.c_str(), this->id); for (size_t i = 0; i < subscribers.size(); i++) --- 113,117 ---- void ocSubscribable::PrintSubscribers() { ! LogDBG(" - Printing subscribers of entity: name='%s', id='%d'", this->name.c_str(), this->id); for (size_t i = 0; i < subscribers.size(); i++) *************** *** 132,136 **** int player_eid = subscribers[i]->GetEntity()->GetID(); const char* player_name = subscribers[i]->GetPlayerName(); ! printf(" [ name='%s', id='%d' ]\n", player_name, player_eid); } } --- 119,123 ---- int player_eid = subscribers[i]->GetEntity()->GetID(); const char* player_name = subscribers[i]->GetPlayerName(); ! LogDBG(" [ name='%s', id='%d' ]\n", player_name, player_eid); } } *************** *** 138,154 **** void ocSubscribable::SendToSubscribers(iSerial* msg) { - OCTRACE("ocSubscribable::SendToSubscribers"); - for (size_t i = 0; i < subscribers.size(); i++) ! serversys->GetNetworkMgr()->SendToPlayer(msg, ! subscribers[i]->GetNetLink(), ! true, false); } void ocSubscribable::AddToInventory(ocPlayerBehaviour* player) { ! OCTRACE("ocSubscribable::AddToInventory"); ! ! printf(" + Player '%s' adding to the inventory entity: name='%s', id='%d'\n", player->GetPlayerName(), this->name.c_str(), this->id); --- 125,137 ---- void ocSubscribable::SendToSubscribers(iSerial* msg) { for (size_t i = 0; i < subscribers.size(); i++) ! Server->GetNetworkMgr()->SendToPlayer(msg, ! subscribers[i]->GetLoginData(), ! true, false); } void ocSubscribable::AddToInventory(ocPlayerBehaviour* player) { ! LogDBG(" + Player '%s' adding to the inventory entity: name='%s', id='%d'", player->GetPlayerName(), this->name.c_str(), this->id); *************** *** 188,194 **** void ocSubscribable::RemoveFromInventory(ocPlayerBehaviour* player) { ! OCTRACE("ocSubscribable::RemoveFromInventory"); ! ! printf(" + Player '%s' removing from the inventory entity: name='%s', id='%d'\n", player->GetPlayerName(), this->name.c_str(), this->id); --- 171,175 ---- void ocSubscribable::RemoveFromInventory(ocPlayerBehaviour* player) { ! LogDBG(" + Player '%s' removing from the inventory entity: name='%s', id='%d'", player->GetPlayerName(), this->name.c_str(), this->id); Index: octimemgr.cpp =================================================================== RCS file: /cvsroot/once/oncecode/src/server/world/octimemgr.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** octimemgr.cpp 25 Jul 2005 00:34:34 -0000 1.6 --- octimemgr.cpp 28 Nov 2005 17:36:20 -0000 1.7 *************** *** 19,23 **** #include "config.h" - #include "common/oclogger.h" #include <csutil/csstring.h> --- 19,22 ---- *************** *** 33,42 **** #include <string> - using namespace std; ocTimeMgr::ocTimeMgr() { - OCTRACE("ocTimeMgr"); - gametime = 0; ticks = 0; --- 32,38 ---- *************** *** 47,52 **** ocTimeMgr::~ocTimeMgr() { - OCTRACE("~ocTimeMgr"); - SaveToDB(); } --- 43,46 ---- *************** *** 54,63 **** bool ocTimeMgr::LoadFromDB() { - OCTRACE("ocTimeMgr::LoadFromDB"); - ocDBQuery query; query.SetTables("world"); query.AddColumnWithoutValue("time"); ! int numresults = serversys->GetDBMgr()->Select(&query); string time; --- 48,55 ---- bool ocTimeMgr::LoadFromDB() { ocDBQuery query; query.SetTables("world"); query.AddColumnWithoutValue("time"); ! int numresults = Server->GetDBMgr()->Select(&query); string time; *************** *** 65,70 **** if (!success) { ! serversys->PrintMessage("ERROR: Couldn't get the game time from the DB (nresults: %d)\n", ! numresults); return false; } --- 57,62 ---- if (!success) { ! LogERR("Couldn't get the game time from the DB (nresults: %d)", ! numresults); return false; } *************** *** 72,76 **** { gametime = atoi(time.c_str()); ! printf("Info: Time loaded: %d\n", gametime); return true; } --- 64,68 ---- { gametime = atoi(time.c_str()); ! LogNTC("Time loaded: %d", gametime); return true; } *************** *** 79,84 **** bool ocTimeMgr::SaveToDB() { - OCTRACE("ocTimeMgr::SaveToDB"); - csString time; time.Format("%d", gametime); --- 71,74 ---- *************** *** 87,96 **** query.SetTables("world"); query.AddColumnWithValue("time", time.GetData()); ! bool success = serversys->GetDBMgr()->Update(&query); if (!success) { ! serversys->PrintMessage("ERROR: Couldn't save the game time to the DB (%s)\n", ! time.GetData()); return false; } --- 77,86 ---- query.SetTables("world"); query.AddColumnWithValue("time", time.GetData()); ! bool success = Server->GetDBMgr()->Update(&query); if (!success) { ! LogERR("Couldn't save the game time to the DB (%s)", ! time.GetData()); return false; } *************** *** 101,106 **** void ocTimeMgr::SendTick(unsigned int _ticks) { - OCTRACE("ocTimeMgr::SendTick"); - ticks += _ticks; --- 91,94 ---- *************** *** 114,118 **** msg.gametime = gametime; SaveToDB(); ! serversys->GetNetworkMgr()->SendToAllPlayers(&msg, true, false); } } --- 102,106 ---- msg.gametime = gametime; SaveToDB(); ! Server->GetNetworkMgr()->SendToAllPlayers(&msg, true, false); } } *************** *** 120,125 **** void ocTimeMgr::ChangeTime(int minutes) { - OCTRACE("ocTimeMgr::ChangeTime"); - gametime += minutes; } --- 108,111 ---- |