diff options
author | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2006-05-13 18:12:22 +0000 |
---|---|---|
committer | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2006-05-13 18:12:22 +0000 |
commit | 87be1a8a52a5485d1cf90240cbf628004cbd5350 (patch) | |
tree | 5b165cc291021acdca249b040b47656093d7fea7 | |
parent | c01baa046b6cfdfe8da438d3e60d6cfa141a674f (diff) | |
download | manaserv-87be1a8a52a5485d1cf90240cbf628004cbd5350.tar.gz manaserv-87be1a8a52a5485d1cf90240cbf628004cbd5350.tar.bz2 manaserv-87be1a8a52a5485d1cf90240cbf628004cbd5350.tar.xz manaserv-87be1a8a52a5485d1cf90240cbf628004cbd5350.zip |
Applied patch by Guillaume Melquiond which adds ENet check and adds timer.cpp/h
to the Makefile.am. Also fixed some compilation warnings.
-rw-r--r-- | ChangeLog | 37 | ||||
-rw-r--r-- | configure.ac | 3 | ||||
-rw-r--r-- | src/Makefile.am | 4 | ||||
-rw-r--r-- | src/client.cpp | 4 | ||||
-rw-r--r-- | src/connectionhandler.cpp | 24 | ||||
-rw-r--r-- | src/dalstorage.cpp | 10 | ||||
-rw-r--r-- | src/defines.h | 2 | ||||
-rw-r--r-- | src/netcomputer.h | 34 |
8 files changed, 73 insertions, 45 deletions
@@ -1,19 +1,28 @@ +2006-05-13 Bjørn Lindeijer <bjorn@lindeijer.nl> + + * src/Makefile.am, configure.ac: Applied patch by Guillaume Melquiond + which adds ENet check and adds timer.cpp/h to the Makefile.am. + * src/connectionhandler.cpp, src/client.cpp, src/defines.h: Fixed some + compilation warnings. + 2006-05-03 Philipp Sehmisch <tmw@crushnet.org> - * src/main.cpp: only yield main thread when there isn't anything - to do. - -2006-04-30 Philipp Sehmisch <tmw@crushnet.org> - * src/util/timer.h, src/util/timer.cpp: added a timer class. - * src/main.cpp: replced SDL timing with the new timer class. - * src/util/timer.h, src/util/timer.cpp: replaced clock with gettimeofday. - * src/util/wingettimeofday.h, src/util/wingettimeofday.h windows + + * src/main.cpp: only yield main thread when there isn't anything to + do. + +2006-04-30 Philipp Sehmisch <tmw@crushnet.org> + * src/util/timer.h, src/util/timer.cpp: Added a timer class. + * src/main.cpp: Replaced SDL timing with the new timer class. + * src/util/timer.h, src/util/timer.cpp: Replaced clock with + gettimeofday. + * src/util/wingettimeofday.h, src/util/wingettimeofday.h: Windows implementation of the UNIX gettimeofday function. - * src/main.cpp: world time doesn't get async anymore when world ticks are - skipped. added a warning when tick skip occurs. - * src/util/timer.h, src/util/timer.cpp: made sure every compiler uses a - 64bit unsigned integer for getTimeInMillisec. - * src/main.cpp, src/connectionhandler.cpp, src/netsession.cpp, - src/SDL-win32_main.c: removed the last remains of SDL + * src/main.cpp: World time doesn't get async anymore when world ticks + are skipped. Added a warning when tick skip occurs. + * src/util/timer.h, src/util/timer.cpp: Made sure every compiler uses + a 64 bit unsigned integer for getTimeInMillisec. + * src/main.cpp, src/connectionhandler.cpp, src/netsession.cpp, + src/SDL-win32_main.c: Removed the last remains of SDL. 2006-04-28 Eugenio Favalli <elvenprogrammer@gmail.com> diff --git a/configure.ac b/configure.ac index 8fce7423..13504d55 100644 --- a/configure.ac +++ b/configure.ac @@ -26,6 +26,9 @@ AC_MSG_ERROR([ *** Unable to find PhysFS library (icculus.org/physfs/)])) AC_CHECK_LIB([SDL_net], [SDLNet_Init], , AC_MSG_ERROR([ *** Unable to find SDL_net library])) +AC_CHECK_LIB([enet], [enet_initialize], , +AC_MSG_ERROR([ *** Unable to find enet library (enet.bespin.org)])) + PKG_CHECK_MODULES(XML2, [libxml-2.0 >= 2.4]) CXXFLAGS="$CXXFLAGS $XML2_CFLAGS" LIBS="$LIBS $XML2_LIBS" diff --git a/src/Makefile.am b/src/Makefile.am index 90baf8b9..070d6f00 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -82,7 +82,9 @@ tmwserv_SOURCES = main.cpp \ utils/logger.h \ utils/logger.cpp \ utils/stringfilter.h \ - utils/stringfilter.cpp + utils/stringfilter.cpp \ + utils/timer.h \ + utils/timer.cpp if BUILD_MYSQL tmwserv_SOURCES += dal/mysqldataprovider.h \ diff --git a/src/client.cpp b/src/client.cpp index 81f023c7..d99690ca 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -437,7 +437,7 @@ void parsePacket(char *data, int recvLength) { // Register switch (msg.readByte()) { case LOGIN_OK: - char charNumber; + unsigned char charNumber; charNumber = msg.readByte(); std::cout << "Account has " << int(charNumber) << " characters." << std::endl; for (unsigned int i = 0; i < charNumber; i++) { @@ -654,7 +654,7 @@ void parsePacket(char *data, int recvLength) { { switch (msg.readByte()) { case CHAR_LIST_OK: - char charNumber; + unsigned char charNumber; charNumber = msg.readByte(); std::cout << "Character List:" << std::endl << "---------------" << std::endl; diff --git a/src/connectionhandler.cpp b/src/connectionhandler.cpp index b0a85f71..b7d1b1ba 100644 --- a/src/connectionhandler.cpp +++ b/src/connectionhandler.cpp @@ -103,7 +103,7 @@ ConnectionHandler::startListen(ListenThreadData *ltd) while (ltd->running) { ENetEvent event; - + // Wait up to 1000 milliseconds for an event. while (enet_host_service(ltd->host, &event, 1000) > 0) { @@ -119,19 +119,19 @@ ConnectionHandler::startListen(ListenThreadData *ltd) computerConnected(comp); /*LOG_INFO(ltd->host->peerCount << " client(s) connected", 0);*/ - + // Store any relevant client information here. event.peer->data = (void *)comp; } break; - + case ENET_EVENT_TYPE_RECEIVE: { LOG_INFO("A packet of length " << event.packet->dataLength << " was received from " << event.peer->address.host, 2); - + NetComputer *comp = (NetComputer *)event.peer->data; - + #ifdef SCRIPT_SUPPORT // This could be good if you wanted to extend the // server protocol using a scripting language. This @@ -171,11 +171,11 @@ ConnectionHandler::startListen(ListenThreadData *ltd) else { LOG_ERROR("Message too short from " << ipaddr, 0); } - + /* Clean up the packet now that we're done using it. */ enet_packet_destroy(event.packet); } break; - + case ENET_EVENT_TYPE_DISCONNECT: { NetComputer *comp = (NetComputer *)event.peer->data; @@ -186,12 +186,14 @@ ConnectionHandler::startListen(ListenThreadData *ltd) delete comp; event.peer->data = NULL; } break; + + default: break; } } } - + // - Disconnect all clients (close sockets) - + // TODO: probably there's a better way. ENetPeer *currentPeer; @@ -265,9 +267,9 @@ void ConnectionHandler::sendAround(tmwserv::BeingPtr beingPtr, MessageOut &msg) i != clients.end(); i++) { // See if the other being is near enough, then send the message - if (abs((*i)->getCharacter().get()->getX() - beingPtr.get()->getX()) <= AROUND_AREA_IN_TILES ) + if (abs((*i)->getCharacter().get()->getX() - beingPtr.get()->getX()) <= (int)AROUND_AREA_IN_TILES ) { - if (abs((*i)->getCharacter().get()->getY() - beingPtr.get()->getY()) <= AROUND_AREA_IN_TILES ) + if (abs((*i)->getCharacter().get()->getY() - beingPtr.get()->getY()) <= (int)AROUND_AREA_IN_TILES ) { (*i)->send(msg.getPacket()); break; diff --git a/src/dalstorage.cpp b/src/dalstorage.cpp index 5d4f96a6..cb0f87dc 100644 --- a/src/dalstorage.cpp +++ b/src/dalstorage.cpp @@ -231,10 +231,10 @@ DALStorage::getAccount(const std::string& userName) LOG_INFO(userName << "'s account has " << charInfo.rows() << " character(s) in database.", 1) - // As the recordset functions are set to be able to get one recordset - // at a time, we store charInfo in a temp array of strings - // To avoid the problem where values of charInfo were erased by the - // values of mapInfo. + // As the recordset functions are set to be able to get one + // recordset at a time, we store charInfo in a temp array of + // strings. To avoid the problem where values of charInfo were + // erased by the values of mapInfo. std::string strCharInfo[charInfo.rows()][charInfo.cols()]; for (unsigned int i = 0; i < charInfo.rows(); ++i) { @@ -247,7 +247,7 @@ DALStorage::getAccount(const std::string& userName) for (unsigned int k = 0; k < charRows; ++k) { RawStatistics stats = { - toUshort(strCharInfo[k][11]), // strength + toUshort(strCharInfo[k][11]), // strength toUshort(strCharInfo[k][12]), // agility toUshort(strCharInfo[k][13]), // vitality toUshort(strCharInfo[k][14]), // intelligence diff --git a/src/defines.h b/src/defines.h index c4d00bb5..faab7073 100644 --- a/src/defines.h +++ b/src/defines.h @@ -182,7 +182,7 @@ enum { SMSG_QUIT_CHANNEL_RESPONSE = 0x0422, // Other - SMSG_LOAD_MAP = 0x0500, + SMSG_LOAD_MAP = 0x0500 // NOTE: We will need more messages for in-game control (eg. moving a client to a new map/position etc.). Currently the protocol only caters for the bare basics. }; diff --git a/src/netcomputer.h b/src/netcomputer.h index 2e74c960..de3e822d 100644 --- a/src/netcomputer.h +++ b/src/netcomputer.h @@ -56,12 +56,14 @@ class NetComputer /** * Returns <code>true</code> if this computer is disconnected. */ - //bool isDisconnected(); + //bool + //isDisconnected(); /** * Disconnects the computer from the server. */ - void disconnect(const std::string &reason); + void + disconnect(const std::string &reason); /** * Queues (FIFO) a packet for sending to a client. @@ -70,7 +72,8 @@ class NetComputer * introduce the reliable argument, which would cause a UDP message * to be sent when set to false. */ - void send(const Packet *p); + void + send(const Packet *p); //void send(Packet *p, bool reliable = true); /** @@ -81,33 +84,39 @@ class NetComputer /** * Set the account associated with the connection */ - void setAccount(tmwserv::AccountPtr acc); + void + setAccount(tmwserv::AccountPtr acc); /** * Unset the account associated with the connection */ - void unsetAccount(); + void + unsetAccount(); /** * Get account associated with the connection */ - tmwserv::AccountPtr getAccount() { return mAccountPtr; } + tmwserv::AccountPtr + getAccount() { return mAccountPtr; } /** * Set the selected character associated with connection */ - void setCharacter(tmwserv::BeingPtr ch); + void + setCharacter(tmwserv::BeingPtr ch); /** * Deselect the character associated with connection * and remove it from the world */ - void unsetCharacter(); + void + unsetCharacter(); /** * Get character associated with the connection */ - tmwserv::BeingPtr getCharacter() { return mCharacterPtr; } + tmwserv::BeingPtr + getCharacter() { return mCharacterPtr; } private: ConnectionHandler *handler; @@ -115,8 +124,11 @@ class NetComputer std::queue<Packet*> queue; /**< Message Queue (FIFO) */ ENetPeer *peer; /**< Client peer */ - tmwserv::AccountPtr mAccountPtr; /**< Account associated with connection */ - tmwserv::BeingPtr mCharacterPtr; /**< Selected character */ + /** Account associated with connection */ + tmwserv::AccountPtr mAccountPtr; + + /** Selected character */ + tmwserv::BeingPtr mCharacterPtr; }; #endif |