summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog8
-rw-r--r--src/accounthandler.cpp15
-rw-r--r--src/client.cpp9
-rw-r--r--src/dalstorage.cpp7
-rw-r--r--src/defines.h2
-rw-r--r--src/messageout.cpp2
6 files changed, 23 insertions, 20 deletions
diff --git a/ChangeLog b/ChangeLog
index 507c148..4072692 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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 636c2b9..6aa6601 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 bac385b..d5e7f1f 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 17ed5e2..6a8159c 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 cfeda39..f76dba4 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 95e55a8..63c69db 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())