From fc342cc8deacdf826e343b1ce796b47bbd918f61 Mon Sep 17 00:00:00 2001 From: Björn Steinbrink Date: Sat, 27 Aug 2005 20:13:45 +0000 Subject: Fix the bug where sometimes the last entry in the npc list windows is missing. --- src/gui/npc.cpp | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'src/gui/npc.cpp') diff --git a/src/gui/npc.cpp b/src/gui/npc.cpp index 084f2f6a..99d3b3a5 100644 --- a/src/gui/npc.cpp +++ b/src/gui/npc.cpp @@ -80,23 +80,21 @@ std::string NpcListDialog::getElementAt(int i) return items[i]; } -void NpcListDialog::parseItems(const char *string) { - char *copy = new char[strlen(string) + 1]; - strcpy(copy, string); +void NpcListDialog::parseItems(const char *string, unsigned short len) { + char *copy = new char[len + 1]; + strncpy(copy, string, len); + copy[len] = 0; char *token = strtok(copy, ":"); - while (token != NULL) { + while (token) { char *temp = (char*)malloc(strlen(token) + 1); strcpy(temp, token); items.push_back(std::string(temp)); token = strtok(NULL, ":"); } - - // TEMP: remove the last item insrted (fixes an athena bug probably) - items.pop_back(); - + delete[] copy; -} +} void NpcListDialog::reset() { items.clear(); -- cgit v1.2.3-70-g09d2