mirror of
https://github.com/ondra-novak/gates_of_skeldal.git
synced 2025-07-27 01:24:51 -04:00
added console and a few commands
This commit is contained in:
parent
e717badc45
commit
73b949fb2e
28 changed files with 807 additions and 87 deletions
|
@ -32,6 +32,7 @@ setup.c
|
|||
chargen.c
|
||||
sndandmus.c
|
||||
specproc.c
|
||||
console.c
|
||||
advconfig.c
|
||||
temp_storage.cpp
|
||||
${CMAKE_BINARY_DIR}/default_font.cpp
|
||||
|
|
|
@ -859,10 +859,23 @@ T_CLK_MAP clk_kniha[]=
|
|||
};
|
||||
|
||||
|
||||
static void kniha_keyboard_proc(EVENT_MSG *msg, void **) {
|
||||
if (msg->msg == E_KEYBOARD) {
|
||||
int c = quit_request_as_escape(va_arg(msg->data,int));
|
||||
switch(c>>8) {
|
||||
case 1: exit_kniha(1, 0, 0, 0, 0);break;
|
||||
case 0x4d: page_change(2, 0, 0, 0, 0);break;
|
||||
case 0x4b: page_change(-2, 0, 0, 0, 0);break;
|
||||
default:break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void unwire_kniha(void)
|
||||
{
|
||||
hold_timer(TM_FAST_TIMER,0);
|
||||
GlobEvent(MAGLOB_AFTERBOOK,viewsector,viewdir);
|
||||
send_message(E_DONE,E_KEYBOARD, kniha_keyboard_proc);
|
||||
}
|
||||
|
||||
|
||||
|
@ -882,6 +895,7 @@ void wire_kniha(void)
|
|||
schovej_mysku();
|
||||
put_picture(0,0,ablock(H_KNIHA));
|
||||
change_click_map(clk_kniha,CLK_KNIHA);
|
||||
send_message(E_ADD,E_KEYBOARD, kniha_keyboard_proc);
|
||||
unwire_proc=unwire_kniha;
|
||||
set_font(H_FONT6,AUTOMAP_FONT_COLOR);
|
||||
write_book(cur_page);
|
||||
|
|
|
@ -603,6 +603,7 @@ void other_draw()
|
|||
show_money();
|
||||
anim_sipky(0,-1);
|
||||
draw_fx();
|
||||
draw_console_window();
|
||||
int32_t scr_linelen2 = GetScreenPitch();
|
||||
|
||||
memset(GetScreenAdr()+(SCREEN_OFFLINE-1)*scr_linelen2,0,1280);
|
||||
|
|
|
@ -456,6 +456,7 @@ T_CLK_MAP clk_main_view[]=
|
|||
{H_SIPKY_J,560,446,598,474,clk_step,2,H_MS_DEFAULT},
|
||||
{H_SIPKY_SV,599,387,628,418,clk_step,2,H_MS_DEFAULT},
|
||||
{H_SIPKY_V,605,420,632,454,clk_step,2,H_MS_DEFAULT},
|
||||
{-1,565,408,593,447,clk_enter,2,H_MS_DEFAULT},
|
||||
{MS_GAME_WIN,0,17,639,377,clk_fly_cursor,8,-1},
|
||||
{1,320,303,639,376,pick_item_,2,-1},//344
|
||||
{0,0,303,320,376,pick_item_,2,-1},//344
|
||||
|
|
593
game/console.c
Normal file
593
game/console.c
Normal file
|
@ -0,0 +1,593 @@
|
|||
#include <libs/bgraph.h>
|
||||
#include <libs/event.h>
|
||||
#include "globals.h"
|
||||
|
||||
#include <ctype.h>
|
||||
#define console_max_characters 120
|
||||
#define console_max_lines 16
|
||||
|
||||
|
||||
/****/
|
||||
|
||||
|
||||
static void wzprintf(const char *text,...);
|
||||
static void wzputs(const char *text);
|
||||
|
||||
char *side_flags[]=
|
||||
{
|
||||
"AUTOMAP",
|
||||
"!PLR",
|
||||
"!MONST",
|
||||
"!THING",
|
||||
"!SOUND",
|
||||
"ALARM",
|
||||
"PASS",
|
||||
"TRANSPARENT",
|
||||
"P_ANIM",
|
||||
"P_VIS",
|
||||
"P_PING",
|
||||
"P_FORW",
|
||||
"S_ANIM",
|
||||
"S_VIS",
|
||||
"S_PING",
|
||||
"S_FORW",
|
||||
"LEFT_A",
|
||||
"RIGHT_A",
|
||||
"ALT_SIDES",
|
||||
"SPEC",
|
||||
"COPY",
|
||||
"SEND",
|
||||
"APLY2ND",
|
||||
"AUTOANIM",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"SECRET",
|
||||
"TRUESEE",
|
||||
"INVIS"
|
||||
};
|
||||
|
||||
char *obl_flags[]=
|
||||
{
|
||||
"RECESS",
|
||||
"UP_SIDE",
|
||||
"DOWN_SIDE",
|
||||
"ITPUSH"
|
||||
};
|
||||
|
||||
char *mc_flags[]=
|
||||
{
|
||||
"MAPPED",
|
||||
"FLY_OBJECT",
|
||||
"PLAYER",
|
||||
"DEAD_PLAYER",
|
||||
"SPECTXTR",
|
||||
"SAFEPLACE",
|
||||
"UNUSED",
|
||||
"MARKED!",
|
||||
"SHADED",
|
||||
"STAIRS",
|
||||
"DOWN",
|
||||
"!AUTOMAP",
|
||||
"!SUMMON"
|
||||
};
|
||||
|
||||
void mman_scan(int )
|
||||
{
|
||||
}
|
||||
|
||||
void show_flags(int number,char **flags,char nums)
|
||||
{
|
||||
int i=0;
|
||||
while (nums--)
|
||||
{
|
||||
if (number & 1) wzprintf("%s ",flags[i]);
|
||||
i++;
|
||||
number>>=1;
|
||||
}
|
||||
}
|
||||
|
||||
void spell_group_invis()
|
||||
{
|
||||
int i;
|
||||
char ok=1;
|
||||
|
||||
for(i=0;i<POCET_POSTAV;i++) if (postavy[i].sektor==viewsector && !(postavy[i].stare_vls[VLS_KOUZLA] & SPL_INVIS))
|
||||
{
|
||||
postavy[i].stare_vls[VLS_KOUZLA]|=SPL_INVIS;
|
||||
ok=0;
|
||||
}
|
||||
if (ok)
|
||||
for(i=0;i<POCET_POSTAV;i++) if (postavy[i].sektor==viewsector)
|
||||
{
|
||||
postavy[i].stare_vls[VLS_KOUZLA]&=~SPL_INVIS;
|
||||
}
|
||||
for(i=0;i<POCET_POSTAV;i++) prepocitat_postavu(postavy+i);
|
||||
build_all_players();
|
||||
}
|
||||
|
||||
|
||||
#if 0
|
||||
static void advence_player(int player,int level,char auto_advance)
|
||||
{
|
||||
THUMAN *h;
|
||||
float mh,mv;
|
||||
|
||||
if (level<2) return;
|
||||
h=postavy+player;
|
||||
mh=(float)human_selected->jidlo/MAX_HLAD(human_selected);
|
||||
mv=(float)human_selected->voda/MAX_ZIZEN(human_selected);
|
||||
human_selected=h;
|
||||
h->exp=level_map[level-2];
|
||||
check_player_new_level(h);
|
||||
if (auto_advance)
|
||||
{
|
||||
int vlssuma=h->vlastnosti[VLS_SILA]+
|
||||
h->vlastnosti[VLS_OBRAT]+
|
||||
h->vlastnosti[VLS_POHYB]+
|
||||
h->vlastnosti[VLS_SMAGIE];
|
||||
int b,i;
|
||||
|
||||
for(i=0;i<4;i++)
|
||||
{
|
||||
b=h->vlastnosti[i]*h->bonus/vlssuma;
|
||||
h->bonus-=b;vlssuma-=h->vlastnosti[i];
|
||||
while (b--) advance_vls(i);
|
||||
}
|
||||
prepocitat_postavu(human_selected);
|
||||
}
|
||||
human_selected->jidlo=(int)(mh*MAX_HLAD(human_selected));
|
||||
human_selected->voda=(int)(mv*MAX_ZIZEN(human_selected));
|
||||
wzprintf("%s ziskal%s uroven cislo %d\r\n",h->jmeno,h->female?"a":"",level);
|
||||
}
|
||||
|
||||
|
||||
extern char folow_mode;
|
||||
extern char folow_mob;
|
||||
void macro_drop_item();
|
||||
|
||||
static char take_money()
|
||||
{
|
||||
int i;
|
||||
if (!wzscanf("Kolik: (0 - zrusit):","%d",&i)) return 0;
|
||||
money+=i;
|
||||
if (i)
|
||||
{
|
||||
SEND_LOG("(WIZARD) Take Money %d, total %d",i,money);
|
||||
}
|
||||
return (i!=0);
|
||||
}
|
||||
|
||||
#define ALL "ALL"
|
||||
static char purge_map()
|
||||
{
|
||||
char buffer[200];
|
||||
char *c;
|
||||
|
||||
STOP();
|
||||
/* struct find_t rc;
|
||||
int rs;
|
||||
|
||||
concat(c,pathtable[SR_TEMP],"*.TMP");
|
||||
rs=_dos_findfirst(c,_A_NORMAL,&rc);
|
||||
while (rs==0)
|
||||
{
|
||||
if (rc.name[0]!='~') wzputs(rc.name);
|
||||
rs=_dos_findnext(&rc);
|
||||
}
|
||||
_dos_findclose(&rc);*/
|
||||
wzprintf("\r\n Zadej jmeno tempu (all - vse):");gets(buffer);
|
||||
if (buffer[0]==0) return 0;
|
||||
strupr(buffer);
|
||||
concat(c,pathtable[SR_TEMP],buffer);
|
||||
if (strcmp(buffer,ALL) && check_file_exists_ex(c))
|
||||
{
|
||||
wzputs("Soubor nenalezen!");
|
||||
return 0;
|
||||
}
|
||||
SEND_LOG("(WIZARD) Purge Map: '%s'",buffer,0);
|
||||
if (!strcmp(buffer,ALL)) purge_temps(0);
|
||||
else remove(c);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static char heal_meditate(void)
|
||||
{
|
||||
int a,b,i;
|
||||
THUMAN *p;
|
||||
|
||||
if (!wzscanf("Obnovit postavu c: (0 - vsechny, -1 - zrusit):","%d",&b)) return 0;
|
||||
if (b==-1) return 0;
|
||||
if (b) a=b-1;else a=0,b=POCET_POSTAV;
|
||||
p=postavy+a;
|
||||
for(i=a;i<b;i++,p++) if (p->used && p->lives)
|
||||
{
|
||||
p->lives=p->vlastnosti[VLS_MAXHIT];
|
||||
p->mana=p->vlastnosti[VLS_MAXMANA];
|
||||
p->kondice=p->vlastnosti[VLS_KONDIC];
|
||||
p->jidlo=MAX_HLAD(p);
|
||||
p->voda=MAX_ZIZEN(p);
|
||||
SEND_LOG("(WIZARD) Restoring character '%s'",p->jmeno,0);
|
||||
bott_draw(1);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
static char raise_death(void)
|
||||
{
|
||||
int b;
|
||||
THUMAN *p;
|
||||
char *c,*d;
|
||||
|
||||
if (!wzscanf("Obzivit postavu c: (0 a -1 - zrusit):","%d",&b)) return 0;
|
||||
b--;
|
||||
if (b<0) return 0;
|
||||
p=postavy+b;
|
||||
p->lives=p->vlastnosti[VLS_MAXHIT];
|
||||
p->mana=p->vlastnosti[VLS_MAXMANA];
|
||||
p->kondice=p->vlastnosti[VLS_KONDIC];
|
||||
c="(WIZARD) '%s' has been returned to game by gods power!";d=strchr(c,'\'');
|
||||
wzprintf(d,p->jmeno);putchar('\r\n');
|
||||
bott_draw(1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
static char raise_killed_monster(HWND hDlg)
|
||||
{
|
||||
HWND listdlg=PrepareListWindow(hDlg);
|
||||
HWND list=GetDlgItem(listdlg,IDC_LIST);
|
||||
char buff[256];
|
||||
int i;
|
||||
int res;
|
||||
|
||||
for (i=0;i<MAX_MOBS;i++) if (~mobs[i].vlajky & MOB_LIVE && mobs[i].cislo_vzoru!=0)
|
||||
{
|
||||
int p;
|
||||
_snprintf(buff,sizeof(buff),"%4d. %s (sector: %d home %d)",i,mobs[i].name,mobs[i].sector,mobs[i].home_pos);
|
||||
kamenik2windows(buff,strlen(buff),buff);
|
||||
p=ListBox_AddString(list,buff);
|
||||
ListBox_SetItemData(list,p,i);
|
||||
}
|
||||
res=PumpDialogMessages(listdlg);
|
||||
while (res==IDOK)
|
||||
{
|
||||
int cnt;
|
||||
for (i=0,cnt=ListBox_GetCount(list);i<cnt;i++) if (ListBox_GetSel(list,i))
|
||||
{
|
||||
int idx=ListBox_GetItemData(list,i);
|
||||
mobs[idx].vlajky|=MOB_LIVE;
|
||||
mobs[idx].lives=mobs[idx].vlastnosti[VLS_MAXHIT];
|
||||
wzprintf("%s znovu povstal(a)\r\n",mobs[idx].name);
|
||||
SEND_LOG("(WIZARD) '%s' has been raised",mobs[idx].name,0);
|
||||
}
|
||||
res=PumpDialogMessages(listdlg);
|
||||
}
|
||||
CloseListWindow(listdlg);
|
||||
return 1;
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
|
||||
static char advance_weapon()
|
||||
{
|
||||
int p,i;
|
||||
char buff[128];
|
||||
THUMAN *h;
|
||||
if (!wzscanf("Cislo postavy: (0 = Zpet)","%d",&p)) return 0;
|
||||
if (p==0) return 0;
|
||||
h=postavy+p-1;
|
||||
do
|
||||
{
|
||||
int bonus, value;
|
||||
for(i=0;i<TPW_MAX;i++) wzprintf("%d. %-15s: %2d Exp %5d\r\n",i+1,texty[91+i],h->bonus_zbrani[i],h->weapon_expy[i]);
|
||||
if (!wzscanf("<Zbran> <Hodnota>","%[^\n]",buff)) return 0;
|
||||
if (buff[0]==0) return 0;
|
||||
if (sscanf(buff,"%d %d",&bonus,&value)!=2) wzputs("Huh?!");
|
||||
else
|
||||
{
|
||||
bonus--;
|
||||
if (bonus<0 || bonus>=TPW_MAX) wzputs("Spatna zbran");
|
||||
else
|
||||
if (value<0 || value>=10) wzputs("Spatna hodnota");
|
||||
else
|
||||
h->bonus_zbrani[bonus]=value;
|
||||
}
|
||||
}
|
||||
while(1);
|
||||
}
|
||||
|
||||
static reload_mobs()
|
||||
{
|
||||
extern char reset_mobiles;
|
||||
reset_mobiles=1;
|
||||
strncpy(loadlevel.name,level_fname,12);
|
||||
loadlevel.start_pos=viewsector;
|
||||
loadlevel.name[12]=0;
|
||||
loadlevel.dir=viewdir;
|
||||
send_message(E_CLOSE_MAP);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
static char display_game_status(void)
|
||||
{
|
||||
short *v;
|
||||
THUMAN *p;
|
||||
TSTENA *s;
|
||||
TSECTOR *ss;
|
||||
int i,cn,astr;
|
||||
|
||||
SEND_LOG("(WIZARD) Starting wizard window at Sect %d Side %d",viewsector,viewdir);
|
||||
wzprintf("Sektor: %5d Smer: %d Skupina %d \r\n",viewsector,viewdir,cur_group);
|
||||
for(i=0,p=postavy;i<POCET_POSTAV;i++,p++)
|
||||
if (p->used)
|
||||
wzprintf("%d.%-14s (%d) Sek:%5d Smr:%d HPReg:%d MPReg:%d VPReg:%d %04X%s\r\n",i+1,p->jmeno,p->groupnum,p->sektor,p->direction,p->vlastnosti[VLS_HPREG],
|
||||
p->vlastnosti[VLS_MPREG], p->vlastnosti[VLS_VPREG], p->vlastnosti[VLS_KOUZLA], p->lives?"":"(smrt)");
|
||||
else
|
||||
wzprintf("%d. (nepouzito)\r\n",i);
|
||||
wzputs("");
|
||||
wzprintf("Predmet(y) v mysi: ");
|
||||
v=picked_item;
|
||||
if (v==NULL) wzprintf("<zadne>");else while(*v) wzprintf("%d ",abs(*v++)-1);
|
||||
wzputs("\r\n");
|
||||
for(i=0,cn=0,astr=0;i<MAX_MOBS;i++)
|
||||
{
|
||||
if (mobs[i].vlajky & MOB_LIVE) cn++;
|
||||
if (mobs[i].vlajky & MOB_MOBILE) astr++;
|
||||
}
|
||||
wzprintf("Celkem potvor ve hre: %5d (+%d) astral mobiles\r\n"
|
||||
"Celkem predmetu ve hre:%5d\r\n"
|
||||
" .. z toho klonu: %5d\r\n",cn-astr,astr,item_count,item_count-it_count_orgn);
|
||||
|
||||
wzputs("");
|
||||
ss=map_sectors+viewsector;
|
||||
s=map_sides+viewsector*4+viewdir;
|
||||
wzprintf("Sector: (%d) Podlaha %d Strop %d Cil akce %d Smer akce %d Akce %d\r\n",
|
||||
ss->sector_type, ss->floor,ss->ceil,ss->sector_tag,ss->side_tag,ss->action);
|
||||
wzprintf(" Vychody: Sev %d Vych %d Jih %d Z<>p %d\r\n",ss->step_next[0],ss->step_next[1],ss->step_next[2],ss->step_next[3]);
|
||||
wzprintf(" Vlajky: %02X %02X ",ss->flags,map_coord[viewsector].flags);show_flags(map_coord[viewsector].flags,mc_flags,12);
|
||||
wzputs("\r\n");
|
||||
wzprintf("Stena: Prim %d Sec %d Obl %d Anim_prim %d/%d Anim_sec %d/%d\r\n",
|
||||
s->prim,s->sec,s->oblouk & 0xf,s->prim_anim>>4,s->prim_anim & 0xf,s->sec_anim>>4,s->sec_anim & 0xf);
|
||||
wzprintf(" Cil akce %d Smer akce %d Akce %d\r\n",s->action,s->sector_tag,s->side_tag & 0x3);
|
||||
wzprintf(" Multiakce: %s\r\n",macros[viewsector*4+viewdir].action_list==NULL?"<zadna>":"Existuje");
|
||||
wzprintf(" Vlajky: %04X %02X %02X ",s->flags,s->oblouk>>4,s->side_tag>>2);
|
||||
wzputs("");
|
||||
show_flags(s->flags,side_flags,32);
|
||||
show_flags(s->oblouk>>4,obl_flags,4);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*****/
|
||||
|
||||
void unaffect();
|
||||
extern char immortality;
|
||||
extern char nohassle;
|
||||
|
||||
|
||||
static char console_input_line[console_max_characters+1] = "";
|
||||
static char *console_output_lines[console_max_lines] = {};
|
||||
|
||||
static const int console_x = 0;
|
||||
static const int console_y = 20;
|
||||
static const int console_width = 640;
|
||||
static const int console_height = 160;
|
||||
static const int console_padding = 3;
|
||||
static int console_blink = 0;
|
||||
static char console_visible = 0;
|
||||
|
||||
|
||||
void draw_console_window() {
|
||||
if (!console_visible) return;
|
||||
trans_bar(console_x, console_y, console_width, console_height, 0);
|
||||
|
||||
set_font(H_FLITT5, RGB888(255,255,128));
|
||||
int y = console_y+console_height-text_height("X")-console_padding;
|
||||
position(console_x+console_padding, y);
|
||||
outtext("$ ");
|
||||
outtext(console_input_line);
|
||||
if ((console_blink>>1) & 1) {
|
||||
outtext("_");
|
||||
}
|
||||
++console_blink;
|
||||
|
||||
set_font(H_FLITT5, RGB888(255,255,255));
|
||||
|
||||
|
||||
y-=3*text_height("X")/2;
|
||||
|
||||
for (int i = 0; i < console_max_lines;++i) {
|
||||
position(console_x+console_padding,y);
|
||||
if (console_output_lines[i]) outtext(console_output_lines[i]);
|
||||
y-=text_height("X");
|
||||
if (y < console_y+console_padding) break;
|
||||
}
|
||||
}
|
||||
|
||||
char console_is_visible() {
|
||||
return console_visible;
|
||||
}
|
||||
|
||||
static void console_add_line(const char *line) {
|
||||
free(console_output_lines[console_max_lines-1]);
|
||||
memmove(console_output_lines+1,console_output_lines, (console_max_lines-1)*sizeof(char *));
|
||||
console_output_lines[0] = strdup(line);
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
char *cmd_buffer;
|
||||
const char *command;
|
||||
const char *args;
|
||||
} PARSED_COMMAND;
|
||||
|
||||
static PARSED_COMMAND parse_command(const char *cmd) {
|
||||
PARSED_COMMAND ret;
|
||||
ret.command = 0;
|
||||
ret.args = 0;
|
||||
ret.cmd_buffer = strdup(cmd);
|
||||
char *c =ret.cmd_buffer;
|
||||
while (*c && isspace(*c)) ++c;
|
||||
if (!*c) return ret;
|
||||
ret.command = c;
|
||||
ret.args = NULL;
|
||||
char *sep = strrchr(c, ' ');
|
||||
if (sep!= NULL) {
|
||||
*sep = 0;
|
||||
++sep;
|
||||
while (*sep && isspace(*sep)) ++sep;
|
||||
if (*sep) {
|
||||
ret.args = sep;
|
||||
char *end = strrchr(sep,0);
|
||||
end--;
|
||||
while (end > sep && isspace(*end)) end--;
|
||||
end++;
|
||||
*end = 0;
|
||||
}
|
||||
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int process_on_off_command(const char *cmd, char on) {
|
||||
if (stricmp(cmd, "inner-eye") == 0) {
|
||||
show_debug = on;
|
||||
return 1;
|
||||
}
|
||||
if (stricmp(cmd, "hunter-instinct") == 0) {
|
||||
show_lives = on;
|
||||
return 1;
|
||||
}
|
||||
if (stricmp(cmd, "no-hassle") == 0) {
|
||||
nohassle=on;
|
||||
return 1;
|
||||
}
|
||||
if (stricmp(cmd, "iron-skin") == 0) {
|
||||
immortality=on;
|
||||
return 1;
|
||||
}
|
||||
if (stricmp(cmd, "spirit-wander") == 0) {
|
||||
cur_group=on?10:postavy[0].groupnum;
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int process_actions(const char *command) {
|
||||
if (stricmp(command, "flute") == 0) {
|
||||
bott_draw_fletna();
|
||||
return 1;
|
||||
}
|
||||
if (stricmp(command, "global-map") == 0) {
|
||||
wire_global_map();
|
||||
return 1;
|
||||
}
|
||||
if (stricmp(command, "status") == 0) {
|
||||
display_game_status();
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int process_command(PARSED_COMMAND cmd) {
|
||||
int onoff = -1;
|
||||
if (cmd.args) {
|
||||
if (stricmp(cmd.args, "on") == 0) onoff = 1;
|
||||
else if (stricmp(cmd.args, "off") == 0) onoff = 0;
|
||||
} else {
|
||||
return process_actions(cmd.command);
|
||||
}
|
||||
if (onoff != -1) {
|
||||
return process_on_off_command(cmd.command, onoff);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void console_keyboard(EVENT_MSG *msg, void **) {
|
||||
if (msg->msg == E_KEYBOARD) {
|
||||
int c = va_arg(msg->data, int) & 0xFF;
|
||||
if (c == E_QUIT_GAME_KEY) return;
|
||||
if (c) {
|
||||
int len = strlen(console_input_line);
|
||||
if (c == 0x1B) {
|
||||
console_show(0);
|
||||
msg->msg = -1;
|
||||
return;
|
||||
}
|
||||
if (c == '\b') {
|
||||
if (len) {
|
||||
console_input_line[len-1] = 0;
|
||||
}
|
||||
msg->msg = -1;
|
||||
} else if (c == '\r') {
|
||||
PARSED_COMMAND cmd = parse_command(console_input_line);
|
||||
char ok = process_command(cmd);
|
||||
if (ok) {
|
||||
console_add_line(console_input_line);
|
||||
console_input_line[0] = 0;
|
||||
}
|
||||
free(cmd.cmd_buffer);
|
||||
msg->msg = -1;
|
||||
} else if (c >=32 && len < console_max_characters) {
|
||||
console_input_line[len] = c;
|
||||
console_input_line[len+1] = 0;
|
||||
msg->msg = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void wire_console(void) {
|
||||
send_message(E_ADD,E_KEYBOARD, console_keyboard);
|
||||
}
|
||||
|
||||
|
||||
static void unwire_console(void) {
|
||||
send_message(E_DONE,E_KEYBOARD, console_keyboard);
|
||||
}
|
||||
|
||||
void console_show(char show) {
|
||||
if (console_visible != show) {
|
||||
console_visible = show;
|
||||
if (show) wire_console();
|
||||
else unwire_console();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static void wzprintf(const char *text,...)
|
||||
{
|
||||
char buff[console_max_characters+1];
|
||||
static char wzprint_line[console_max_characters+1];
|
||||
va_list lst;
|
||||
va_start(lst, text);
|
||||
vsnprintf(buff,console_max_characters, text, lst);
|
||||
char *c = buff;
|
||||
char *d = strchr(c, '\n');
|
||||
while (d != NULL) {
|
||||
*d = 0;
|
||||
strncat(wzprint_line,c, console_max_characters);
|
||||
console_add_line(wzprint_line);
|
||||
c = d+1;
|
||||
d = strchr(c, '\n');
|
||||
wzprint_line[0] = 0;
|
||||
}
|
||||
strncat(wzprint_line, c, console_max_characters);
|
||||
|
||||
}
|
||||
|
||||
|
||||
static void wzputs(const char *text)
|
||||
{
|
||||
console_add_line(text);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -134,7 +134,7 @@ void small_anm_buff(void *target,const void *buff,const void *paleta);
|
|||
void small_anm_delta(void *target,const void *buff,const void *paleta);
|
||||
//#pragma aux small_anm_delta parm[edi][esi][ebx] modify [eax ecx]
|
||||
|
||||
static void animace_kouzla(int act,const void *data,int csize)
|
||||
static void animace_kouzla(MGIF_HEADER_T *_,int act,const void *data,int csize)
|
||||
{
|
||||
word *p=GetScreenAdr()+loc_anim_render_buffer;
|
||||
switch (act)
|
||||
|
@ -169,7 +169,8 @@ static void dialog_anim(va_list args)
|
|||
do
|
||||
{
|
||||
anm=open_mgif(aptr);
|
||||
while (anm!=NULL && task_quitmsg())
|
||||
char f = anm != NULL;
|
||||
while (f && task_quitmsg())
|
||||
{
|
||||
task_sleep();
|
||||
if (!spdc)
|
||||
|
@ -179,7 +180,7 @@ static void dialog_anim(va_list args)
|
|||
hid=1;schovej_mysku();
|
||||
}
|
||||
else hid=0;
|
||||
anm=mgif_play(anm);
|
||||
f=mgif_play(anm);
|
||||
spdc=speed;
|
||||
if (hid) ukaz_mysku();
|
||||
showview(PIC_X,PIC_Y,320,180);
|
||||
|
@ -191,7 +192,7 @@ static void dialog_anim(va_list args)
|
|||
}
|
||||
}
|
||||
rep--;
|
||||
close_mgif();
|
||||
close_mgif(anm);
|
||||
}
|
||||
while (!cntr && rep && !task_quitmsg());
|
||||
free(aptr);
|
||||
|
|
|
@ -1013,7 +1013,7 @@ static void read_story_task(va_list args)
|
|||
{
|
||||
int xs,ys;
|
||||
d=c;
|
||||
while (size && *d!='\r' && *d!='\n') {d++;size--;};
|
||||
while (size>0 && *d!='\r' && *d!='\n') {d++;size--;};
|
||||
if (!size) break;
|
||||
*d=0;
|
||||
{
|
||||
|
@ -1027,7 +1027,7 @@ static void read_story_task(va_list args)
|
|||
e=strchr(e,0)+1;
|
||||
}
|
||||
c=d+1;size--;
|
||||
if (*c=='\n' || *c=='\r') {c++;size--;};
|
||||
if (size > 0 &&(*c=='\n' || *c=='\r')) {c++;size--;};
|
||||
free(or);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1724,7 +1724,7 @@ int count_pages(void);
|
|||
void save_book(void);
|
||||
void load_book(void);
|
||||
void prekodovat(char *c);
|
||||
|
||||
char clk_enter(int id,int xa,int ya,int xr,int yr);
|
||||
|
||||
//menu
|
||||
int enter_menu(char open); //task!
|
||||
|
@ -1787,5 +1787,9 @@ static __inline int quit_request_as_escape(int c) {
|
|||
if (c == E_QUIT_GAME_KEY) return 0x011B;else return c;
|
||||
}
|
||||
|
||||
void draw_console_window(void);
|
||||
void console_show(char show);
|
||||
char console_is_visible(void);
|
||||
|
||||
//extras
|
||||
#include "extras.h"
|
||||
|
|
|
@ -22,14 +22,15 @@
|
|||
#include <unistd.h>
|
||||
#define GLOBMAP "GLOBMAP.DAT"
|
||||
|
||||
#define ODDELOVACE ";:=,\n{}"
|
||||
#define ODDELOVACE ";:=,\n\r{}"
|
||||
#define OD_COMMAND oddelovace[0]
|
||||
#define OD_CRIT oddelovace[1]
|
||||
#define OD_SET oddelovace[2]
|
||||
#define OD_COMMA oddelovace[3]
|
||||
#define OD_NEWLINE oddelovace[4]
|
||||
#define OD_IN oddelovace[5]
|
||||
#define OD_OUT oddelovace[6]
|
||||
#define OD_CR oddelovace[5]
|
||||
#define OD_IN oddelovace[6]
|
||||
#define OD_OUT oddelovace[7]
|
||||
#define OD_COMMENT '`'
|
||||
|
||||
#define INDEXU 256
|
||||
|
@ -247,7 +248,7 @@ static char test_kriterii(void)
|
|||
break;
|
||||
default:
|
||||
{
|
||||
hodn=temp_storage_find(text);
|
||||
hodn=temp_storage_find(text)>=0;
|
||||
/* char c[200];
|
||||
sprintf(c,"%s.TMP",text);
|
||||
hodn=!check_file_exists(c);*/
|
||||
|
@ -269,11 +270,11 @@ static char proved_prikaz()
|
|||
char op;
|
||||
|
||||
ODD=cti_oddelovac();
|
||||
while (ODD==OD_NEWLINE) ODD=cti_oddelovac(); //preskoc prazdne radky
|
||||
while (ODD==OD_NEWLINE || ODD==OD_CR) ODD=cti_oddelovac(); //preskoc prazdne radky
|
||||
if (ODD==OD_IN) return 0; //cti znak {
|
||||
do
|
||||
{
|
||||
while (ODD==OD_NEWLINE || ODD==OD_COMMAND) ODD=cti_oddelovac();
|
||||
while (ODD==OD_NEWLINE || ODD==OD_CR || ODD==OD_COMMAND) ODD=cti_oddelovac();
|
||||
if (ODD!=0) error("O<EFBFBD>ek<EFBFBD>v<EFBFBD> se jm<6A>no definice (p<><70>klad: INDX=)");
|
||||
cti_retezec(20,prikaz,1,1);
|
||||
op=get_symbol(prikaz);
|
||||
|
@ -335,9 +336,9 @@ static char proved_prikaz()
|
|||
default:error(prikaz);
|
||||
}
|
||||
ODD=cti_oddelovac();
|
||||
if (ODD!=OD_COMMAND && ODD!=OD_NEWLINE && ODD!=EOF) ex_error(OD_COMMAND);
|
||||
if (ODD!=OD_COMMAND && ODD!=OD_NEWLINE && ODD!=OD_CR && ODD!=EOF) ex_error(OD_COMMAND);
|
||||
}
|
||||
while (ODD!=OD_NEWLINE && ODD!=EOF);
|
||||
while (ODD!=OD_NEWLINE && ODD !=OD_CR && ODD!=EOF);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -1360,6 +1360,7 @@ TMPFILE_RD *enc_open(const char *filename)
|
|||
encdata[i] = last;
|
||||
}
|
||||
temp_storage_store("__enc_temp", encdata, size);
|
||||
free(encdata);
|
||||
return temp_storage_open("__enc_temp");
|
||||
}
|
||||
|
||||
|
|
21
game/inv.c
21
game/inv.c
|
@ -65,7 +65,6 @@ TSHOP **shop_list=NULL;
|
|||
int max_shops=0; //shop_list=prima spojeni s obchody
|
||||
void *shop_hacek=NULL; //hacek za ktery visi cely shop strom (free(shop_hacek) - odalokuje shopy)
|
||||
//hacek lze ulozit do savegame -> ulozi se cely stav obchodu
|
||||
int32_t shop_hacek_size=0; //toto je jeho delka
|
||||
static TSHOP_ALL_STATE shop_all_state;
|
||||
|
||||
#define ico_extract(icnnum) (((char*)ablock(ikon_libs+(icnnum)/IT_LIB_SIZE))+IT_ICONE_SIZE*((icnnum)%IT_LIB_SIZE))
|
||||
|
@ -207,6 +206,7 @@ void load_items()
|
|||
hs=hl_ptr;
|
||||
prepare_graphics(&hl_ptr,(char *)p,size,wav_load,SR_ZVUKY);
|
||||
sound_handle=hs-1;
|
||||
free(p);
|
||||
break;
|
||||
default:
|
||||
free(p);
|
||||
|
@ -853,12 +853,17 @@ char exit_inv(int id,int xa,int ya,int xr,int yr)
|
|||
void definuj_postavy()
|
||||
{
|
||||
int i,num1,r,inv=0,z;
|
||||
const char *c,*end;
|
||||
char *c,*end;
|
||||
const char *tmpptr;
|
||||
char cc;
|
||||
int tmp;
|
||||
|
||||
c=ablock(H_POSTAVY_DAT);
|
||||
end=c+get_handle(H_POSTAVY_DAT)->size;
|
||||
tmpptr=ablock(H_POSTAVY_DAT);
|
||||
size_t sz = get_handle(H_POSTAVY_DAT)->size;
|
||||
c = alloca(sz+1);
|
||||
memcpy(c, tmpptr, sz);
|
||||
c[sz] = 0;
|
||||
end=c + sz;
|
||||
for(i=0;c<end && i<20;i++)
|
||||
{
|
||||
THUMAN *p=&postavy_2[i];
|
||||
|
@ -2222,7 +2227,9 @@ void draw_fly_items(int celx,int cely,int sector,int side)
|
|||
xpos+=64;
|
||||
ypos+=64;
|
||||
if (p->items==NULL) it=glob_items+p->item-1;else it=&glob_items[*(p->items)-1];
|
||||
if (p->flags & FLY_DESTROY_SEQ) smr=3;
|
||||
if (p->flags & FLY_DESTROY_SEQ) {
|
||||
smr=3;
|
||||
}
|
||||
else if (smr==3) smr=1;
|
||||
picnum=it->v_letu[(smr<<2)+p->anim_pos];
|
||||
if (!picnum)
|
||||
|
@ -2445,9 +2452,7 @@ static void rebuild_shops(const void *shop_ptr)
|
|||
int i;
|
||||
|
||||
SEND_LOG("(SHOP) Rebuilding shops....");
|
||||
if (shop_list!=NULL) free(shop_list);
|
||||
max_shops = *(const int32_t *)c;
|
||||
shop_list=NewArr(TSHOP *,max_shops);
|
||||
c+=4;
|
||||
const char *d = c;
|
||||
size_t reqsize = 0;
|
||||
|
@ -2499,8 +2504,10 @@ void load_shops(void)
|
|||
shop_list=NULL;
|
||||
return;
|
||||
}
|
||||
int32_t shop_hacek_size=0; //toto je jeho delka
|
||||
const void *sh=afile(SHOP_NAME,SR_MAP,&shop_hacek_size);
|
||||
rebuild_shops(sh);
|
||||
ablock_free(sh);
|
||||
}
|
||||
|
||||
static int32_t *get_product_count(const TPRODUCT *p) {
|
||||
|
|
|
@ -173,7 +173,7 @@ void call_spell(int i);
|
|||
int calculatePhaseDoor(int sector, int dir, int um);
|
||||
|
||||
|
||||
static void animace_kouzla(int act,const void *data, int ssize)
|
||||
static void animace_kouzla(MGIF_HEADER_T *_,int act,const void *data, int ssize)
|
||||
{
|
||||
switch (act)
|
||||
{
|
||||
|
@ -236,16 +236,17 @@ static void play_anim(va_list args) //tasked animation
|
|||
anm=open_mgif(ablock(block));
|
||||
c=0;
|
||||
SEND_LOG("(ANIM) Buffer is now ready...");
|
||||
while (anm!=NULL)
|
||||
char f = 1;
|
||||
while (f)
|
||||
{
|
||||
task_wait_event(E_KOUZLO_ANM);
|
||||
c++;
|
||||
SEND_LOG("(ANIM) Rendering frame %d in animation %xh",c,block);
|
||||
anm=mgif_play(anm);
|
||||
f=mgif_play(anm);
|
||||
neco_v_pohybu=1;
|
||||
}
|
||||
task_wait_event(E_KOUZLO_ANM);
|
||||
close_mgif();
|
||||
close_mgif(anm);
|
||||
running_anm=0;
|
||||
free(anim_render_buffer);
|
||||
|
||||
|
|
|
@ -1575,8 +1575,7 @@ void step_zoom(char smer)
|
|||
sort_groups();
|
||||
bott_draw(0);
|
||||
other_draw();
|
||||
shift_zoom(smer);
|
||||
if (smer==0 && nopass) shift_zoom(smer+2);
|
||||
if (!nopass) shift_zoom(smer);
|
||||
if (battle || (game_extras & EX_ALWAYS_MINIMAP)) draw_medium_map();
|
||||
sort_groups();
|
||||
bott_draw(0);
|
||||
|
@ -1858,6 +1857,10 @@ void *game_keyboard(EVENT_MSG *msg,void **usr)
|
|||
{unwire_proc();cancel_render=1;wire_save_load(1);}break;
|
||||
case '=':unwire_proc();cancel_render=1;wire_save_load(0);break;
|
||||
case '>':game_setup(0,0,0,0,0);break;
|
||||
case 0x2E: if (get_control_key_state() && get_shift_key_state()) {
|
||||
console_show(!console_is_visible());
|
||||
}
|
||||
break;
|
||||
CASE_KEY_1_6:c=group_sort[c-2];
|
||||
if (postavy[c].sektor==viewsector && postavy[c].used)
|
||||
add_to_group(c);
|
||||
|
|
|
@ -474,7 +474,7 @@ void set_font(int font,int c1,...)
|
|||
if (c1 & BGSWITCHBIT)
|
||||
{
|
||||
charcolors[0]=0xFFFF;
|
||||
for (i=1;i<5;i++) charcolors[i]=c1 & ~0x20;
|
||||
for (i=1;i<5;i++) charcolors[i]=c1 & ~BGSWITCHBIT;
|
||||
}
|
||||
else if (c1 & FONT_TSHADOW) {
|
||||
if ((c1 & FONT_TSHADOW_GRAY) == FONT_TSHADOW_GRAY)
|
||||
|
@ -998,6 +998,7 @@ void unwire_main_functs(void)
|
|||
delete_from_timer(TM_REGEN);
|
||||
send_message(E_DONE,E_KEYBOARD,game_keyboard);
|
||||
send_message(E_DONE,E_KROK,real_krok);
|
||||
console_show(0);
|
||||
disable_click_map();
|
||||
cancel_render=1;
|
||||
wire_proc=wire_main_functs;
|
||||
|
@ -1439,6 +1440,16 @@ static void load_saved_game(void)
|
|||
}
|
||||
}
|
||||
|
||||
static int any_save_callback(const char *c, LIST_FILE_TYPE _, size_t __, void *___) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
static char any_save() {
|
||||
int c = list_files(gpathtable[SR_SAVES],file_type_normal,any_save_callback,0);
|
||||
return c;
|
||||
}
|
||||
|
||||
|
||||
static void start(va_list args)
|
||||
{
|
||||
int volba;
|
||||
|
@ -1448,7 +1459,7 @@ static void start(va_list args)
|
|||
openning=0;
|
||||
update_mysky();
|
||||
schovej_mysku();
|
||||
if (!skip_intro)
|
||||
if (!any_save())
|
||||
{
|
||||
show_jrc_logo("LOGO.PCX");
|
||||
play_anim(7);
|
||||
|
|
|
@ -384,6 +384,7 @@ static void build_dungeon_sound_map(int sector, int side) {
|
|||
if (mapsize != (int)current_sound_sector_map_size) {
|
||||
free(current_sound_sector_map);
|
||||
current_sound_sector_map = NewArr(TSOUND_SIDE_MAP, mapsize);
|
||||
memset(current_sound_sector_map,0,sizeof(TSOUND_SIDE_MAP)*mapsize);
|
||||
current_sound_sector_map_size = mapsize;
|
||||
}
|
||||
int32_t counter = ++current_sound_sector_map_counter;
|
||||
|
|
|
@ -1947,6 +1947,10 @@ void programming_keyboard(EVENT_MSG *msg,void **unused)
|
|||
wire_inv_mode(human_selected);
|
||||
break;
|
||||
case 82:group_all();break;
|
||||
case 0x2E: if (get_control_key_state() && get_shift_key_state()) {
|
||||
console_show(!console_is_visible());
|
||||
}
|
||||
break;
|
||||
CASE_KEY_1_6:c=group_sort[c-2];
|
||||
if (postavy[c].used)
|
||||
{
|
||||
|
|
|
@ -450,6 +450,8 @@ void wizard_kbd(EVENT_MSG *msg,void **usr)
|
|||
return;
|
||||
}
|
||||
|
||||
c
|
||||
|
||||
void install_wizard()
|
||||
{
|
||||
send_message(E_ADD,E_KEYBOARD,wizard_kbd);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue