From: TimePath Date: Wed, 13 May 2015 00:54:31 +0000 (+1000) Subject: Add an item dumping command X-Git-Tag: xonotic-v0.8.1~53^2~5 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=7ac9ebe0d7ea2238a58288af1c8891103455b5f3;p=xonotic%2Fxonotic-data.pk3dir.git Add an item dumping command --- diff --git a/qcsrc/common/command/generic.qc b/qcsrc/common/command/generic.qc index f0b6d0de5..6aa93a024 100644 --- a/qcsrc/common/command/generic.qc +++ b/qcsrc/common/command/generic.qc @@ -241,6 +241,25 @@ void GenericCommand_dumpcommands(float request) } } +void GenericCommand_dumpitems(float request) +{ + switch(request) + { + case CMD_REQUEST_COMMAND: + { + Dump_Items(); + return; + } + + default: + case CMD_REQUEST_USAGE: + { + printf("\nUsage:^3 %s dumpitems", GetProgramCommandPrefix()); + return; + } + } +} + void GenericCommand_dumpnotifs(float request) { switch(request) @@ -651,6 +670,7 @@ void GenericCommand_(float request) #define GENERIC_COMMANDS(request,arguments,command) \ GENERIC_COMMAND("addtolist", GenericCommand_addtolist(request, arguments), "Add a string to a cvar") \ GENERIC_COMMAND("dumpcommands", GenericCommand_dumpcommands(request), "Dump all commands on the program to *_cmd_dump.txt") \ + GENERIC_COMMAND("dumpitems", GenericCommand_dumpitems(request), "Dump all items to the console") \ GENERIC_COMMAND("dumpnotifs", GenericCommand_dumpnotifs(request), "Dump all notifications into notifications_dump.txt") \ GENERIC_COMMAND("dumpweapons", GenericCommand_dumpweapons(request), "Dump all weapons into weapons_dump.txt") \ GENERIC_COMMAND("maplist", GenericCommand_maplist(request, arguments), "Automatic control of maplist") \ diff --git a/qcsrc/common/items/all.qc b/qcsrc/common/items/all.qc index 37cd93b3f..fa198bb83 100644 --- a/qcsrc/common/items/all.qc +++ b/qcsrc/common/items/all.qc @@ -4,10 +4,9 @@ #include "all.inc" -void ItemTest() +void Dump_Items() { - ITEMS_FOREACH(it != NULL, LAMBDA({ - print(strcat(etos(it), "\n")); + ITEMS_FOREACH(true, LAMBDA({ ITEM_HANDLE(Show, it); })); } diff --git a/qcsrc/common/items/all.qh b/qcsrc/common/items/all.qh index 74ca110ef..7290b95a9 100644 --- a/qcsrc/common/items/all.qh +++ b/qcsrc/common/items/all.qh @@ -12,7 +12,7 @@ entity ITEMS[MAX_ITEMS]; } while(0) void RegisterItems(); -void ItemTest(); +void Dump_Items(); #ifdef CSQC void ReadItems() diff --git a/qcsrc/common/items/item/buff.qh b/qcsrc/common/items/item/buff.qh index 458b35e3c..4ad93cb5f 100644 --- a/qcsrc/common/items/item/buff.qh +++ b/qcsrc/common/items/item/buff.qh @@ -1,8 +1,7 @@ #ifndef BUFF_H #define BUFF_H -#include "../item.qh" -CLASS(Buff, GameItem) - METHOD(Buff, show, void(entity this)) - void Buff_show(entity this) { print("%s\n", "Buff"); } +#include "pickup.qh" +CLASS(Buff, Pickup) + ATTRIB(Buff, m_name, string, "Buff") ENDCLASS(Buff) #endif diff --git a/qcsrc/common/items/item/pickup.qh b/qcsrc/common/items/item/pickup.qh index a391d6861..47788f3aa 100644 --- a/qcsrc/common/items/item/pickup.qh +++ b/qcsrc/common/items/item/pickup.qh @@ -6,7 +6,7 @@ CLASS(Pickup, GameItem) ATTRIB(Pickup, m_sound, string, "misc/itempickup.wav") ATTRIB(Pickup, m_name, string, string_null) METHOD(Pickup, show, void(entity this)) - void Pickup_show(entity this) { printf("%s\n", this.m_name); } + void Pickup_show(entity this) { printf("%s: %s\n", etos(this), this.m_name); } #ifdef SVQC ATTRIB(Pickup, m_botvalue, int, 0) ATTRIB(Pickup, m_itemflags, int, 0)