register paks
This commit is contained in:
parent
cc46e0fc32
commit
bc6340588e
2 changed files with 20 additions and 3 deletions
|
|
@ -34,8 +34,13 @@ GBEngine GBEngineCreate(GBEngineParam* param) {
|
|||
|
||||
sh_new_strdup(engine->resource);
|
||||
|
||||
resource = GBResourceOpen(engine, "base.pak");
|
||||
shput(engine->resource, "base", resource);
|
||||
if((resource = GBResourceOpen(engine, "base.pak")) != NULL) {
|
||||
shput(engine->resource, "base", resource);
|
||||
}
|
||||
|
||||
if((resource = GBResourceOpen(engine, "game.pak")) != NULL) {
|
||||
shput(engine->resource, "game", resource);
|
||||
}
|
||||
|
||||
if(engine != NULL && param->client && (engine->client = GBClientCreate(engine)) == NULL) {
|
||||
GBLog(GBLogError, "Failed to create client");
|
||||
|
|
@ -61,6 +66,10 @@ GBEngine GBEngineCreate(GBEngineParam* param) {
|
|||
}
|
||||
|
||||
void GBEngineDestroy(GBEngine engine) {
|
||||
int i;
|
||||
for(i = 0; i < shlen(engine->resource); i++) {
|
||||
GBResourceClose(engine->resource[i].value);
|
||||
}
|
||||
shfree(engine->resource);
|
||||
|
||||
if(engine->server != NULL) GBServerDestroy(engine->server);
|
||||
|
|
|
|||
|
|
@ -13,7 +13,9 @@ typedef struct kv {
|
|||
|
||||
} kv_t;
|
||||
|
||||
static FILE* out;
|
||||
static FILE* out;
|
||||
static unsigned int total = 0;
|
||||
static unsigned int totalact = 0, totalcmp = 0;
|
||||
|
||||
static void scan(const char* path, const char* pre);
|
||||
|
||||
|
|
@ -72,6 +74,10 @@ static void pack(const char* fullpath, const char* path) {
|
|||
fwrite(output, 1, outsz, out);
|
||||
|
||||
printf("done (%6d -> %6d)\n", insz, outsz);
|
||||
|
||||
total++;
|
||||
totalact += insz;
|
||||
totalcmp += outsz;
|
||||
} else {
|
||||
printf("failed\n");
|
||||
}
|
||||
|
|
@ -188,5 +194,7 @@ int main(int argc, char** argv) {
|
|||
memset(dat, 0, 128);
|
||||
fwrite(dat, 1, 128, out);
|
||||
|
||||
printf("total %u files added, compressed %u -> %u bytes\n", total, totalact, totalcmp);
|
||||
|
||||
fclose(out);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue