diff options
-rw-r--r-- | src/game.cpp | 4 | ||||
-rw-r--r-- | src/gui/npc.cpp | 19 | ||||
-rw-r--r-- | src/gui/npc.h | 2 |
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 |