summaryrefslogtreecommitdiff
path: root/src/gui/chat.cpp
diff options
context:
space:
mode:
authorAlexander Baldeck <alexander@archlinux.org>2004-09-27 23:43:58 +0000
committerAlexander Baldeck <alexander@archlinux.org>2004-09-27 23:43:58 +0000
commitaf4096ec7148eea52352a4711f8586e6b52fe32f (patch)
tree01daf611e4aa78d280769c903d2000e86050faaf /src/gui/chat.cpp
parent2a9fade8224417d29074bd124f3f00092df2015d (diff)
downloadmana-client-af4096ec7148eea52352a4711f8586e6b52fe32f.tar.gz
mana-client-af4096ec7148eea52352a4711f8586e6b52fe32f.tar.bz2
mana-client-af4096ec7148eea52352a4711f8586e6b52fe32f.tar.xz
mana-client-af4096ec7148eea52352a4711f8586e6b52fe32f.zip
fix for mapserver segfault (broken pipe for all on screen users)
Diffstat (limited to 'src/gui/chat.cpp')
-rw-r--r--src/gui/chat.cpp46
1 files changed, 20 insertions, 26 deletions
diff --git a/src/gui/chat.cpp b/src/gui/chat.cpp
index 2f0385c9..c6967a08 100644
--- a/src/gui/chat.cpp
+++ b/src/gui/chat.cpp
@@ -76,23 +76,23 @@ void Chat::chat_log(string line, int own, ALFONT_FONT * font) {
pos = 0;
pos = (int)line.find(" : ", 0);
if(pos > 0) {
- tmp.nick = line.substr(0,pos);
- switch(own) {
- case ACT_IS :
- tmp.nick += CAT_IS;
- break;
- case ACT_WHISPER :
- tmp.nick += CAT_WHISPER;
- break;
- default :
- tmp.nick += CAT_NORMAL;
- }
- tmp.width = TEXT_GETWIDTH(tmp.nick.c_str())+2;
- line.erase(0,pos+3);
+ tmp.nick = line.substr(0,pos);
+ switch(own) {
+ case ACT_IS :
+ tmp.nick += CAT_IS;
+ break;
+ case ACT_WHISPER :
+ tmp.nick += CAT_WHISPER;
+ break;
+ default :
+ tmp.nick += CAT_NORMAL;
+ }
+ tmp.width = TEXT_GETWIDTH(tmp.nick.c_str())+2;
+ line.erase(0,pos+3);
}else {
tmp.nick = "";
tmp.width = 1;
- }
+ }
tmp.own = own;
tmp.text = line;
@@ -174,8 +174,7 @@ void Chat::chat_draw(BITMAP * bmp, int n, ALFONT_FONT * font) {
chatlog.chat_send("Zaeiru", "Hello to all users on the screen!");
*/
char * Chat::chat_send(string nick, string msg) {
- short len = 0, packid;
- char *temp = NULL;
+ short packid;
// prepare command
if(msg.substr(0,1)=="/") {
@@ -185,9 +184,7 @@ char * Chat::chat_send(string nick, string msg) {
packid = 0x0099;
} else {
packid = 0x008c;
- len = (short)msg.length()+4;
}
- len = (short)msg.length()+4;
// prepare ordinary message
} else {
// temporary hack to make messed-up-keyboard-ppl able to send GM commands
@@ -198,17 +195,15 @@ char * Chat::chat_send(string nick, string msg) {
nick += msg;
msg = nick;
packid = 0x008c;
- len = (short)(nick.length()+msg.length()+3);
}
+ msg += "\0";
+
// send processed message
- temp = new char[len];
- memcpy(temp, msg.c_str(), len);
WFIFOW(0) = net_w_value(packid);
- WFIFOW(2) = net_w_value(len+4);
- memcpy(WFIFOP(4), temp, len);
- WFIFOSET(len+4);
- delete temp;
+ WFIFOW(2) = net_w_value(msg.length()+4);
+ memcpy(WFIFOP(4), msg.c_str(), msg.length());
+ WFIFOSET(msg.length()+4);
nick = msg = "";
return "";
}
@@ -300,4 +295,3 @@ string const_msg(int own) {
string msg;
return msg;
}
-