diff --git a/game/console.c b/game/console.c index d308ff6..cbc6fa6 100644 --- a/game/console.c +++ b/game/console.c @@ -6,6 +6,7 @@ #define console_max_characters 120 #define console_max_lines 16 +void macro_drop_item(int sector,int smer,short item); /****/ @@ -454,6 +455,25 @@ static PARSED_COMMAND parse_command(const char *cmd) { extern int ghost_walls; extern int nofloors; +static int add_file_to_console(const char *name, LIST_FILE_TYPE , size_t, void *ctx) { + int *cnt = (void *)ctx; + char buff[20] = ""; + for (int i = 0; i < 19; ++i) buff[i] = ' '; + buff[19] = 0; + int l = strlen(name); + if (l > 3 && stricmp(name+l-4,".MAP") == 0) { + if (l>19) l = 19; + memcpy(buff, name, l); + wzprintf("%s", buff); + if (++(*cnt) == 6) { + wzprintf("\n"); + *cnt = 0; + } + } + return 0; + +} + static int process_on_off_command(const char *cmd, char on) { if (stricmp(cmd, "inner-eye") == 0) { show_debug = on; @@ -538,6 +558,46 @@ static int process_actions(const char *command) { play_fx_at(FX_MAP); return 1; } + if (stricmp(command, "rise-and-shine") == 0) { + int r = 0; + for (int i = 0; i < POCET_POSTAV; ++i) { + THUMAN *p = postavy+i; + if (p->used && p->inmaphash == current_map_hash) { + p->lives=p->vlastnosti[VLS_MAXHIT]; + p->mana=p->vlastnosti[VLS_MAXMANA]; + p->kondice=p->vlastnosti[VLS_KONDIC]; + p->sektor = viewsector; + r = 1; + } + } + bott_draw(0); + return r; + + } + if (stricmp(command, "ascent") == 0) { + int lev = postavy[0].exp; + for (int i = 0; i < POCET_POSTAV; ++i) { + THUMAN *p = postavy+i; + if (p->used) lev = MAX(lev,p->level); + } + for (int i = 0; i < POCET_POSTAV; ++i) { + THUMAN *p = postavy+i; + p->exp = level_map[lev-1]; + check_player_new_level(p); + } + return 1; + } + if (stricmp(command, "by-the-power-of-grayskull") == 0) { + memset(runes,0xFF, sizeof(runes)); + play_fx_at(FX_MAGIC); + return 1; + } + if (stricmp(command, "world-list") == 0) { + int cnt = 0; + list_files(gpathtable[SR_MAP], file_type_normal|file_type_just_name, add_file_to_console, &cnt); + printf("\n"); + return 1; + } return 0; } @@ -572,6 +632,20 @@ static int process_with_params(const char *cmd, const char *args) { console_add_line(""); return 1; } + if (stricmp(cmd, "summon") == 0) { + if (args[0] == 'i') { + char *end; + unsigned long id = strtoul(args+1, &end, 10); + if (*end == 0) { + if (id < (unsigned long)item_count) { + macro_drop_item(viewsector,viewdir,id); + return 1; + } + } + + } + return 0; + } if (stricmp(cmd, "say") == 0) { console_add_line(args); return 1; @@ -581,6 +655,16 @@ static int process_with_params(const char *cmd, const char *args) { if (v > 0) timerspeed_val = v; return v > 0; } + if (stricmp(cmd, "portal-jump") == 0) { + if (check_file_exists(build_pathname(2,gpathtable[SR_MAP], args))) { + TMA_LOADLEV lev; + strncpy(lev.name,args,12); + lev.start_pos = 0; + macro_load_another_map(&lev); + return 1; + } + return 0; + } return 0; } diff --git a/game/kouzla.c b/game/kouzla.c index fac0cf2..5ebda3f 100644 --- a/game/kouzla.c +++ b/game/kouzla.c @@ -538,6 +538,7 @@ void zmen_vlastnost(int num,int cil,int what,int how) if (p->lives>p->vlastnosti[VLS_MAXHIT]) p->lives=p->vlastnosti[VLS_MAXHIT]; //if (p->mana>p->vlastnosti[VLS_MAXMANA]) p->lives=p->vlastnosti[VLS_MAXMANA]; if (p->kondice>p->vlastnosti[VLS_KONDIC]) p->lives=p->vlastnosti[VLS_KONDIC]; + } } @@ -752,8 +753,14 @@ void spell_hit(int cil,int min,int max,int owner) vysl=min+rnd(max-min+1); if (vysl<0) { - h->lives-=vysl>h->vlastnosti[VLS_MAXHIT]?h->vlastnosti[VLS_MAXHIT]:vysl; - if (h->groupnum==0) h->groupnum=cur_group; + if (vysl < 0 && h->lives == 0 && h->sektor == 0) { + h->sektor = viewsector; + h->inmaphash = current_map_hash; + } + h->lives-=vysl; + if (h->lives < 0) h->lives = 0; + if (h->lives > h->vlastnosti[VLS_MAXHIT]) h->lives = h->vlastnosti[VLS_MAXHIT]; + if (h->groupnum==0) h->groupnum=cur_group; } else player_hit(h,vysl,1); @@ -898,7 +905,7 @@ void spell_pripojenia(int owner) THUMAN *h=NULL; char more=0; destroy_player_map(); - for(i=0;isektor].x-map_coord[p->sektor].x)>5) || - (abs(map_coord[h1->sektor].y-map_coord[p->sektor].y)>5) ) + if ((h1->lives) + && ((abs(map_coord[h1->sektor].x-map_coord[p->sektor].x)>5) || + (abs(map_coord[h1->sektor].y-map_coord[p->sektor].y)>5) )) { sprintf(s,texty[37+(h1->female==1)],h1->jmeno,p->jmeno); bott_disp_text(s); diff --git a/platform/file_access.cpp b/platform/file_access.cpp index 7cbfebd..462d046 100644 --- a/platform/file_access.cpp +++ b/platform/file_access.cpp @@ -111,17 +111,21 @@ int list_files(const char *directory, int type, LIST_FILES_CALLBACK cb, void *ct while (iter != std::filesystem::directory_iterator()) { int r = 0; const auto &entry = *iter; + const char *name; + if (type & file_type_just_name) name = entry.path().filename().c_str(); + else name = entry.path().filename().c_str(); if (entry.is_regular_file(ec) && (type & file_type_normal)) { - r = cb(entry.path().c_str(), file_type_normal, entry.file_size(ec), ctx); + r = cb(name, file_type_normal, entry.file_size(ec), ctx); } else if (entry.is_directory(ec)) { int dot = entry.path().filename() == "." || entry.path().filename() == ".."; if (!dot && (type & file_type_directory)) { - r = cb(entry.path().c_str(), file_type_directory, 0, ctx); + r = cb(name, file_type_directory, 0, ctx); } else if (dot & (type & file_type_dot)) { - r = cb(entry.path().c_str(), file_type_dot, 0, ctx); + r = cb(name, file_type_dot, 0, ctx); } } if (r) return r; + ++iter; } } return 0; diff --git a/platform/platform.h b/platform/platform.h index 8f993c8..64f10a2 100644 --- a/platform/platform.h +++ b/platform/platform.h @@ -86,7 +86,8 @@ void sleep_ms(uint32_t); typedef enum { file_type_normal = 1, file_type_directory = 2, - file_type_dot = 4 + file_type_dot = 4, + file_type_just_name = 8 } LIST_FILE_TYPE; typedef int (*LIST_FILES_CALLBACK)(const char *, LIST_FILE_TYPE , size_t, void *);