diff options
| author | johannes <johannes.herman@gmail.com> | 2024-02-10 19:54:19 +0100 |
|---|---|---|
| committer | johannes <johannes.herman@gmail.com> | 2024-02-10 19:54:19 +0100 |
| commit | ed4d43d281e92b28bbed5c730440b428fe0b171e (patch) | |
| tree | ce8671969e3e4c86a691dd75b141ecc6db43d67f | |
| parent | 72d67bf117250fe5695d122597b3cd103a7aada6 (diff) | |
added setskinbyid
| -rw-r--r-- | inc/commands.h | 1 | ||||
| -rw-r--r-- | src/commands.c | 29 | ||||
| -rw-r--r-- | src/main.c | 1 |
3 files changed, 31 insertions, 0 deletions
diff --git a/inc/commands.h b/inc/commands.h index a08fabd..53d17f7 100644 --- a/inc/commands.h +++ b/inc/commands.h @@ -6,6 +6,7 @@ int setnamebyid(int id, char *newname, demo *demo); int setnamebyname(char *oldname, char *newname, demo *demo); +int setskinbyid(int id, char *skin, demo *demo); int setskinbyname(char *name, char *skin, demo *demo); int changemap(FILE *map, char *mapname, demo *demo); diff --git a/src/commands.c b/src/commands.c index f919a0d..180f4e1 100644 --- a/src/commands.c +++ b/src/commands.c @@ -69,6 +69,35 @@ int setnamebyname(char *old, char *new, demo *demo) return found; } +int setskinbyid(int id, char *skin, demo *demo) +{ + int skinlen = strlen(skin); + if (skinlen >= 23) + return -1; + + int intskin[5] = {0x80808080, 0x80808080, 0x80808080, 0x80808080, 0x80808000}; + strtoint(skin, skinlen + 1, intskin); + char found = 0; + + for (int i = 0; i < demo->data.numchunks; i++) + { + if (demo->data.chunks[i].type != DEMOSNAP) + continue; + demosnap *snap = demo->data.chunks[i].data.snap; + + for (int y = 0; y < snap->numitems; y++) + { + demosnapitem *item = &snap->items[y]; + if (item->type == 11 && item->id == id) + { + memcpy(&item->data[8], intskin, 5 * sizeof(int)); + found++; + } + } + } + return found; +} + int setskinbyname(char *name, char *skin, demo *demo) { int skinlen = strlen(skin); @@ -139,6 +139,7 @@ int main() // TODO quirk, when doing further edits keep previous ones in mind int retskin = setskinbyname("New Santa", "santa_coala", &d); + setskinbyid(9, "bomb", &d); int retmap = changemap(mp, "pepeg", &d); |
