本文整理汇总了C++中MapComposite::setVariableFromDbserver方法的典型用法代码示例。如果您正苦于以下问题:C++ MapComposite::setVariableFromDbserver方法的具体用法?C++ MapComposite::setVariableFromDbserver怎么用?C++ MapComposite::setVariableFromDbserver使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MapComposite
的用法示例。
在下文中一共展示了MapComposite::setVariableFromDbserver方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: processMessage
void AccountConnection::processMessage(MessageIn &msg)
{
LOG_DEBUG("Received message " << msg << " from account server");
switch (msg.getId())
{
case AGMSG_REGISTER_RESPONSE:
{
if (msg.readInt16() != DATA_VERSION_OK)
{
LOG_ERROR("Item database is outdated! Please update to "
"prevent inconsistencies");
stop(); // Disconnect gracefully from account server.
// Stop gameserver to prevent inconsistencies.
exit(EXIT_DB_EXCEPTION);
}
else
{
LOG_DEBUG("Local item database is "
"in sync with account server.");
}
if (msg.readInt16() != PASSWORD_OK)
{
LOG_ERROR("This game server sent a invalid password");
stop();
exit(EXIT_BAD_CONFIG_PARAMETER);
}
// read world state variables
while (msg.getUnreadLength())
{
std::string key = msg.readString();
std::string value = msg.readString();
if (!key.empty() && !value.empty())
{
GameState::setVariableFromDbserver(key, value);
}
}
} break;
case AGMSG_PLAYER_ENTER:
{
std::string token = msg.readString(MAGIC_TOKEN_LENGTH);
Character *ptr = new Character(msg);
gameHandler->addPendingCharacter(token, ptr);
} break;
case AGMSG_ACTIVE_MAP:
{
int mapId = msg.readInt16();
if (MapManager::activateMap(mapId))
{
// Set map variables
MapComposite *m = MapManager::getMap(mapId);
int mapVarsNumber = msg.readInt16();
for(int i = 0; i < mapVarsNumber; ++i)
{
std::string key = msg.readString();
std::string value = msg.readString();
if (!key.empty() && !value.empty())
m->setVariableFromDbserver(key, value);
}
// Recreate potential persistent floor items
LOG_DEBUG("Recreate persistant items on map " << mapId);
int floorItemsNumber = msg.readInt16();
for (int i = 0; i < floorItemsNumber; ++i)
{
int itemId = msg.readInt32();
int amount = msg.readInt16();
int posX = msg.readInt16();
int posY = msg.readInt16();
if (ItemClass *ic = itemManager->getItem(itemId))
{
Item *item = new Item(ic, amount);
item->setMap(m);
Point dst(posX, posY);
item->setPosition(dst);
if (!GameState::insertOrDelete(item))
{
// The map is full.
LOG_WARN("Couldn't add floor item(s) " << itemId
<< " into map " << mapId);
return;
}
}
}
}
} break;
case AGMSG_SET_VAR_WORLD:
{
std::string key = msg.readString();
std::string value = msg.readString();
GameState::setVariableFromDbserver(key, value);
LOG_DEBUG("Global variable \"" << key << "\" has changed to \""
//.........这里部分代码省略.........