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 /src/commands.c | |
| parent | 72d67bf117250fe5695d122597b3cd103a7aada6 (diff) | |
added setskinbyid
Diffstat (limited to 'src/commands.c')
| -rw-r--r-- | src/commands.c | 29 |
1 files changed, 29 insertions, 0 deletions
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); |
