diff options
author | Eugenio Favalli <elvenprogrammer@gmail.com> | 2006-01-14 17:08:44 +0000 |
---|---|---|
committer | Eugenio Favalli <elvenprogrammer@gmail.com> | 2006-01-14 17:08:44 +0000 |
commit | b61fc25de4bb543582bbb7c49e093007f5ca0f0e (patch) | |
tree | c1aa97fc116ce9a069ae6c39f9111063b5ae1930 | |
parent | a6f2542ebfa3e7cb4573a394578ffbd00fe8e0cf (diff) | |
download | manaserv-b61fc25de4bb543582bbb7c49e093007f5ca0f0e.tar.gz manaserv-b61fc25de4bb543582bbb7c49e093007f5ca0f0e.tar.bz2 manaserv-b61fc25de4bb543582bbb7c49e093007f5ca0f0e.tar.xz manaserv-b61fc25de4bb543582bbb7c49e093007f5ca0f0e.zip |
Sever returns infos about position of the selected character (map name, coordinates).
-rw-r--r-- | ChangeLog | 8 | ||||
-rw-r--r-- | src/accounthandler.cpp | 15 | ||||
-rw-r--r-- | src/client.cpp | 9 | ||||
-rw-r--r-- | src/dalstorage.cpp | 7 | ||||
-rw-r--r-- | src/defines.h | 2 | ||||
-rw-r--r-- | src/messageout.cpp | 2 |
6 files changed, 23 insertions, 20 deletions
@@ -20,14 +20,6 @@ definition for a new created character, enabled loading of map when a character is on it, fixed inconsistency in getter/setter for map id. -2006-01-12 Eugenio Favalli <elvenprogrammer@gmail.com> - - * src/accounthandler.cpp, src/client.cpp, src/dalstorage.cpp, - src/main.cpp, src/mapmanager.cpp, src/mapmanager.h, src/netcomputer.cpp, - src/object.cpp, src/object.h, src/state.cpp, tmwserv.dev: Fixed default map - definition for a new created character, enabled loading of map when a - character is on it, fixed inconsistency in getter/setter for map id. - 2006-01-09 Eugenio Favalli <elvenprogrammer@gmail.com> * src/dalstorage.cpp: Fixed some sql query issues. diff --git a/src/accounthandler.cpp b/src/accounthandler.cpp index 636c2b9f..6aa66018 100644 --- a/src/accounthandler.cpp +++ b/src/accounthandler.cpp @@ -503,6 +503,8 @@ void AccountHandler::receiveMessage(NetComputer &computer, MessageIn &message) tmwserv::BeingPtr newCharacter(new tmwserv::Being(name, gender, hairStyle, hairColor, 1 /* level */, 0 /* Money */, stats)); newCharacter->setMapId((int)config.getValue("defaultMap", 1)); + newCharacter->setXY((int)config.getValue("startX", 0), + (int)config.getValue("startY", 0)); computer.getAccount()->addCharacter(newCharacter); LOG_INFO("Character " << name << " was created for " @@ -527,9 +529,9 @@ void AccountHandler::receiveMessage(NetComputer &computer, MessageIn &message) unsigned char charNum = message.readByte(); tmwserv::Beings &chars = computer.getAccount()->getCharacters(); - if ( chars.size() == 0 ) + if (chars.size() == 0 ) { - result.writeByte(SELECT_NOT_YET_CHARACTERS); + result.writeByte(SELECT_NO_CHARACTERS); LOG_INFO("Character Selection : Yet no characters created.", 1) break; } @@ -543,11 +545,16 @@ void AccountHandler::receiveMessage(NetComputer &computer, MessageIn &message) // set character computer.setCharacter(chars[charNum]); - + tmwserv::BeingPtr selectedChar = computer.getCharacter(); + int mapId = selectedChar->getMapId(); result.writeByte(SELECT_OK); + std::string mapName = store.getMapNameFromId(mapId); + result.writeString(mapName); + result.writeShort(selectedChar->getX()); + result.writeShort(selectedChar->getY()); LOG_INFO("Selected Character " << int(charNum) << " : " << - computer.getCharacter()->getName(), 1) + selectedChar->getName(), 1); } break; diff --git a/src/client.cpp b/src/client.cpp index bac385b5..d5e7f1fe 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -581,7 +581,12 @@ int main(int argc, char *argv[]) switch (msg.readByte()) { case SELECT_OK: - std::cout << "Character selected." << std::endl; + { + std::cout << "Character selected: "; + std::cout << msg.readString() << " ("; + std::cout << (int)msg.readShort() << ","; + std::cout << (int)msg.readShort() << ")" << std::endl; + } break; case SELECT_INVALID: std::cout << "Character Selection: invalid ID." @@ -590,7 +595,7 @@ int main(int argc, char *argv[]) case SELECT_NOLOGIN: std::cout << "Character Selection: Not logged in." << std::endl; break; - case SELECT_NOT_YET_CHARACTERS: + case SELECT_NO_CHARACTERS: std::cout << "Character Selection: No character to select." << std::endl; break; default: diff --git a/src/dalstorage.cpp b/src/dalstorage.cpp index 17ed5e27..6a8159cf 100644 --- a/src/dalstorage.cpp +++ b/src/dalstorage.cpp @@ -265,9 +265,7 @@ DALStorage::getAccount(const std::string& userName) stats )); - unsigned int mapId; - std::stringstream ssMapId(strCharInfo[k][10]); - ssMapId >> mapId; + unsigned int mapId = toUint(strCharInfo[k][10]); if ( mapId > 0 ) { being->setMapId(mapId); @@ -278,6 +276,9 @@ DALStorage::getAccount(const std::string& userName) // Default map is to be 1, as not found return value will be 0. being->setMapId((int)config.getValue("defaultMap", 1)); } + + being->setXY(toUshort(strCharInfo[k][8]), + toUshort(strCharInfo[k][9])); mCharacters.push_back(being); beings.push_back(being); diff --git a/src/defines.h b/src/defines.h index cfeda39a..f76dba41 100644 --- a/src/defines.h +++ b/src/defines.h @@ -236,7 +236,7 @@ enum { enum { SELECT_OK = 0, SELECT_INVALID, - SELECT_NOT_YET_CHARACTERS, + SELECT_NO_CHARACTERS, SELECT_NOLOGIN, SELECT_UNKNOWN }; diff --git a/src/messageout.cpp b/src/messageout.cpp index 95e55a86..63c69db4 100644 --- a/src/messageout.cpp +++ b/src/messageout.cpp @@ -83,8 +83,6 @@ MessageOut::writeString(const std::string &string, int length) { // Write the length at the start if not fixed writeShort(string.length()); - std::string toWrite = string; - expand(mPos + string.length()); } else if (length < (int)string.length()) |