summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2004-12-25 20:53:56 +0000
committerBjørn Lindeijer <bjorn@lindeijer.nl>2004-12-25 20:53:56 +0000
commit18db3b8f930d711fab34897f7be303c430d0cf41 (patch)
treeafd94ecf1991ea84e86e4ba630259e4c9ede9d4c /src
parent587275709eb11a036ed474bf6a61f1fd34fc069f (diff)
downloadmana-18db3b8f930d711fab34897f7be303c430d0cf41.tar.gz
mana-18db3b8f930d711fab34897f7be303c430d0cf41.tar.bz2
mana-18db3b8f930d711fab34897f7be303c430d0cf41.tar.xz
mana-18db3b8f930d711fab34897f7be303c430d0cf41.zip
Some corrections made to parse_items. Something still seems to go wrong at the
server side though.
Diffstat (limited to 'src')
-rw-r--r--src/game.cpp4
-rw-r--r--src/gui/npc.cpp19
-rw-r--r--src/gui/npc.h2
3 files changed, 14 insertions, 11 deletions
diff --git a/src/game.cpp b/src/game.cpp
index d3d34fbd..c5cc2a48 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -832,7 +832,9 @@ void do_parse() {
case 0x00b7:
current_npc = RFIFOL(4);
//alert(RFIFOP(8),"","","","",0,0);
- parse_items(RFIFOP(8), RFIFOW(2));
+ //parse_items(RFIFOP(8), RFIFOW(2));
+ parse_items(RFIFOP(8));
+ RFIFOW(2);
show_npc_dialog = 5;
break;
// Look change
diff --git a/src/gui/npc.cpp b/src/gui/npc.cpp
index a5089123..29dc12d2 100644
--- a/src/gui/npc.cpp
+++ b/src/gui/npc.cpp
@@ -45,29 +45,30 @@ void add_item(char *name) {
}
void remove_tail() {
- //free(items.back()->name);
+ free(items.back()->name);
free(items.back());
items.pop_back();
}
-void parse_items(char *string, short len) {
- char *token = strtok(string, ":");
+void parse_items(const char *string) {
+ char *copy = new char[strlen(string) + 1];
+ strcpy(copy, string);
+
+ char *token = strtok(copy, ":");
while (token != NULL) {
- // temp fix for the barber script
- //if (strcmp(token, "you prefer?") != 0) {
- char *temp = (char*)malloc(strlen(token));
+ char *temp = (char*)malloc(strlen(token) + 1);
strcpy(temp, token);
add_item(temp);
- //}
token = strtok(NULL, ":");
}
- remove_tail();
+
+ delete[] copy;
}
void remove_all_items() {
int i;
for (i = 0; i < items.size(); i++) {
- //free(items[i]->name);
+ free(items[i]->name);
free(items[i]);
}
items.clear();
diff --git a/src/gui/npc.h b/src/gui/npc.h
index a0828a9a..02cc7eb1 100644
--- a/src/gui/npc.h
+++ b/src/gui/npc.h
@@ -27,7 +27,7 @@ struct ITEM {
};
char *item_list(int index, int *list_size);
-void parse_items(char *string, short len);
+void parse_items(const char *string);
void remove_all_items();
#endif