summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--inc/commands.h1
-rw-r--r--src/commands.c29
-rw-r--r--src/main.c1
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);
diff --git a/src/main.c b/src/main.c
index 4619495..482bc3c 100644
--- a/src/main.c
+++ b/src/main.c
@@ -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);