diff options
Diffstat (limited to 'src/tool')
-rw-r--r-- | src/tool/itemsearch.cpp | 60 |
1 files changed, 43 insertions, 17 deletions
diff --git a/src/tool/itemsearch.cpp b/src/tool/itemsearch.cpp index cf399e5..986e9b5 100644 --- a/src/tool/itemsearch.cpp +++ b/src/tool/itemsearch.cpp @@ -7,6 +7,7 @@ using namespace std; +bool useStorage; int itemID; int itemCount(string itemData) @@ -57,24 +58,38 @@ void parseLine(string &line) do { - if (counter == 1 || counter == 2 || counter == 15) + if (!useStorage) { - - int ending = line.find('\t', pointer + 1); - if (ending == string::npos) - ending = line.size(); - switch (counter) - { - case 1: - AccountId = line.substr(pointer,ending - pointer); - break; - case 2: - Name = line.substr(pointer, ending - pointer); - break; - case 15: - Items = line.substr(pointer, ending - pointer); - } + if (counter == 1 || counter == 2 || counter == 15) + { + int ending = line.find('\t', pointer + 1); + if (ending == string::npos) + ending = line.size(); + switch (counter) + { + case 1: + AccountId = line.substr(pointer,ending - pointer); + break; + case 2: + Name = line.substr(pointer, ending - pointer); + break; + case 15: + Items = line.substr(pointer, ending - pointer); + } + } } + else if (useStorage) + { + int ending = line.find('\t', pointer + 1); + if (ending == string::npos) + ending = line.size(); + + if (counter == 0) + AccountId = line.substr(pointer,ending - pointer); + else if (counter == 1) + Items = line.substr(pointer,ending - pointer); + } + counter++; } while ((pointer = line.find('\t',pointer) + 1) != string::npos + 1 && counter < 16); @@ -96,11 +111,22 @@ int main(int argc,char *argv[]) if(argc < 2) { printf("Usage: %s <item ID>\n", argv[0]); + printf("Usage2: %s -s <item ID>\n", argv[0]); printf("e.g., %s 701\n", argv[0]); printf("Will return all users who own that item\n"); + printf("Option \"-s\" will expect storage files\n"); exit(0); } - itemID = atoi(argv[1]); + if (strcmp(argv[1],"-s") == 0) + { + useStorage = true; + itemID = atoi(argv[2]); + } + else + { + useStorage = false; + itemID = atoi(argv[1]); + } parseInput(); return 0; |