diff --git a/Makefile b/Makefile index 0436a3b..265b53f 100644 --- a/Makefile +++ b/Makefile @@ -44,11 +44,11 @@ gzip-menus: _include-menus: sed -i "s/0,\/\/menuscrc/0x$(shell crc32 data/p1xbraten/menus.cfg),/" src/fpsgame/p1xbraten_menus.cpp - sed -i "s/0,\/\/menuslen/$(shell stat --printf="%s" data/p1xbraten/menus.cfg.gz),/" src/fpsgame/p1xbraten_menus.cpp + sed -i "s/embeddedfile<0> menuscfg/embeddedfile<$(shell stat --printf="%s" data/p1xbraten/menus.cfg.gz)> menuscfg/" src/fpsgame/p1xbraten_menus.cpp sed -i "s/0,\/\/mastercrc/0x$(shell crc32 data/p1xbraten/master.cfg),/" src/fpsgame/p1xbraten_menus.cpp - sed -i "s/0,\/\/masterlen/$(shell stat --printf="%s" data/p1xbraten/master.cfg.gz),/" src/fpsgame/p1xbraten_menus.cpp + sed -i "s/embeddedfile<0> mastercfg/embeddedfile<$(shell stat --printf="%s" data/p1xbraten/master.cfg.gz)> mastercfg/" src/fpsgame/p1xbraten_menus.cpp sed -i "s/0,\/\/gamehudcrc/0x$(shell crc32 data/p1xbraten/gamehud.cfg),/" src/fpsgame/p1xbraten_menus.cpp - sed -i "s/0,\/\/gamehudlen/$(shell stat --printf="%s" data/p1xbraten/gamehud.cfg.gz),/" src/fpsgame/p1xbraten_menus.cpp + sed -i "s/embeddedfile<0> gamehudcfg/embeddedfile<$(shell stat --printf="%s" data/p1xbraten/gamehud.cfg.gz)> gamehudcfg/" src/fpsgame/p1xbraten_menus.cpp clean-sauer: check-env cd $(SAUER_DIR) && \ diff --git a/patches/include_p1xbraten_menus.patch b/patches/include_p1xbraten_menus.patch index af1b824..28d8d83 100644 --- a/patches/include_p1xbraten_menus.patch +++ b/patches/include_p1xbraten_menus.patch @@ -25,39 +25,37 @@ Index: src/fpsgame/p1xbraten_menus.cpp =================================================================== --- src/fpsgame/p1xbraten_menus.cpp (nonexistent) +++ src/fpsgame/p1xbraten_menus.cpp (working copy) -@@ -0,0 +1,81 @@ +@@ -0,0 +1,79 @@ +#include "cube.h" +#include "p1xbraten_menus.h" + +namespace game { -+ struct embeddedfile menuscfg = { ++ struct embeddedfile<0> menuscfg = { + "data/p1xbraten/menus.cfg.gz", + 0,//menuscrc -+ 0,//menuslen + { + #include "../../data/p1xbraten/menus.cfg.gz.xxd" + } + }; + -+ struct embeddedfile mastercfg = { ++ struct embeddedfile<0> mastercfg = { + "data/p1xbraten/master.cfg.gz", + 0,//mastercrc -+ 0,//masterlen + { + #include "../../data/p1xbraten/master.cfg.gz.xxd" + } + }; + -+ struct embeddedfile gamehudcfg = { ++ struct embeddedfile<0> gamehudcfg = { + "data/p1xbraten/gamehud.cfg.gz", + 0,//gamehudcrc -+ 0,//gamehudlen + { + #include "../../data/p1xbraten/gamehud.cfg.gz.xxd" + } + }; + -+ int update(embeddedfile *i) ++ template ++ int update(embeddedfile *i) + { + stream *f = opengzfile(path(i->name), "rb"); + if(f) @@ -69,7 +67,7 @@ Index: src/fpsgame/p1xbraten_menus.cpp + + f = openrawfile(path(i->name), "wb"); + if(!f) return 2; -+ f->write(i->contents, i->len); ++ f->write(i->contents, N); + delete f; + conoutf("updated %s", i->name); + return 0; @@ -115,11 +113,11 @@ Index: src/fpsgame/p1xbraten_menus.h +#include "cube.h" + +namespace game { ++ template + struct embeddedfile { + string name; + const uint crc; -+ const size_t len; -+ const uchar contents[]; ++ const uchar contents[N]; + }; +} \ No newline at end of file diff --git a/src/fpsgame/p1xbraten_menus.cpp b/src/fpsgame/p1xbraten_menus.cpp index 055308f..498d6e9 100644 --- a/src/fpsgame/p1xbraten_menus.cpp +++ b/src/fpsgame/p1xbraten_menus.cpp @@ -2,34 +2,32 @@ #include "p1xbraten_menus.h" namespace game { - struct embeddedfile menuscfg = { + struct embeddedfile<16060> menuscfg = { "data/p1xbraten/menus.cfg.gz", 0x1607c7ba, - 16060, { #include "../../data/p1xbraten/menus.cfg.gz.xxd" } }; - struct embeddedfile mastercfg = { + struct embeddedfile<1029> mastercfg = { "data/p1xbraten/master.cfg.gz", 0xe6bf7248, - 1029, { #include "../../data/p1xbraten/master.cfg.gz.xxd" } }; - struct embeddedfile gamehudcfg = { + struct embeddedfile<222> gamehudcfg = { "data/p1xbraten/gamehud.cfg.gz", 0xac5cc9fd, - 222, { #include "../../data/p1xbraten/gamehud.cfg.gz.xxd" } }; - int update(embeddedfile *i) + template + int update(embeddedfile *i) { stream *f = opengzfile(path(i->name), "rb"); if(f) @@ -41,7 +39,7 @@ namespace game { f = openrawfile(path(i->name), "wb"); if(!f) return 2; - f->write(i->contents, i->len); + f->write(i->contents, N); delete f; conoutf("updated %s", i->name); return 0; diff --git a/src/fpsgame/p1xbraten_menus.h b/src/fpsgame/p1xbraten_menus.h index bd14f69..c0f193b 100644 --- a/src/fpsgame/p1xbraten_menus.h +++ b/src/fpsgame/p1xbraten_menus.h @@ -1,10 +1,10 @@ #include "cube.h" namespace game { + template struct embeddedfile { string name; const uint crc; - const size_t len; - const uchar contents[]; + const uchar contents[N]; }; } \ No newline at end of file