Exemple #1
0
void ServerInterface::update() {
	if (!m_portBound) {
		return;
	}
	// chat messages
	while (hasChatMsg()) {
		Console *c = g_userInterface.getDialogConsole();
		c->addDialog(getChatSender() + ": ", factionColours[getChatColourIndex()],
			getChatText(), true);
		popChatMsg();
	}

	// update all slots
	for (int i=0; i < GameConstants::maxPlayers; ++i) {
		if (slots[i]) {
			try {
				slots[i]->update();
			} catch (DataSyncError &e) {
				LOG_NETWORK( e.what() );
				throw runtime_error("DataSync Fail : " + slots[i]->getName()
					+ "\n" + e.what());
			} catch (GameSyncError &e) {
				LOG_NETWORK( e.what() );
				removeSlot(i);
				throw runtime_error(e.what());
			} catch (NetworkError &e) {
				LOG_NETWORK( e.what() );
				string playerName = slots[i]->getName();
				removeSlot(i);
				sendTextMessage("Player " + intToStr(i) + " [" + playerName + "] diconnected.", -1);
			}
		}
	}
}