diff --git a/.gitignore b/.gitignore index 089a689..e18aa05 100644 --- a/.gitignore +++ b/.gitignore @@ -9,4 +9,5 @@ _UpgradeReport_Files /.cproject /.project /.settings +/.vscode /skeldal.local.ini diff --git a/AdvMan/DlgDialogy.cpp b/AdvMan/DlgDialogy.cpp index 52f9899..e226f8e 100644 --- a/AdvMan/DlgDialogy.cpp +++ b/AdvMan/DlgDialogy.cpp @@ -78,7 +78,7 @@ int DlgDialogy::GetDialogID(const char *name) char dialog[40]; if (fscanf(f," %40[^\r\n\t (] ( %d )",dialog,&id)==2) { - if (stricmp(dialog,"DIALOG")==0) + if (istrcmp(dialog,"DIALOG")==0) { fclose(f); return id; @@ -204,13 +204,13 @@ int DlgDialogy::CompareItems(int item1, int item2) { CString a=wList.GetItemText(item1,0); CString b=wList.GetItemText(item2,0); - return stricmp(a,b); + return istrcmp(a,b); } case 1: { CString a=wList.GetItemText(item1,1); CString b=wList.GetItemText(item2,1); - return stricmp(a,b); + return istrcmp(a,b); } case 2: { diff --git a/AdvMan/Pathname.h b/AdvMan/Pathname.h index 8b4c999..da57e63 100644 --- a/AdvMan/Pathname.h +++ b/AdvMan/Pathname.h @@ -24,10 +24,10 @@ enum PathNameNullEnum {PathNull}; #define PathNameCompare(op) bool operator op (const Pathname &other) const \ -{if (IsNull() || other.IsNull()) return false;else return stricmp(_fullpath,other._fullpath) op 0;}\ +{if (IsNull() || other.IsNull()) return false;else return istrcmp(_fullpath,other._fullpath) op 0;}\ bool operator op (const char *other) const \ {ASSERT(other[0]!=0);\ - if (IsNull() || other==NULL) return false;else return stricmp(_fullpath,other) op 0;} + if (IsNull() || other==NULL) return false;else return istrcmp(_fullpath,other) op 0;} #ifndef _UNICODE diff --git a/CMakeLists.txt b/CMakeLists.txt index fad32ea..cdd5e12 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,14 +1,14 @@ -cmake_minimum_required(VERSION 3.28) +cmake_minimum_required(VERSION 3.24) project(skeldal) # Najít SDL2 knihovnu find_package(SDL2 REQUIRED) if (MSVC) - add_compile_options(/W4 /EHsc /DNOMINMAX) + add_compile_options(/W4 /EHsc /DNOMINMAX /J) set(STANDARD_LIBRARIES "") else() - add_compile_options(-Wall -Wextra -Werror -Wno-unused-parameter -Wno-unused-value -Wno-extern-c-compat) + add_compile_options(-Wall -Wextra -Werror -Wno-unused-parameter -Wno-unused-value -Wno-extern-c-compat -funsigned-char) set(STANDARD_LIBRARIES "pthread") endif() @@ -19,7 +19,6 @@ set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib/) set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib/) include_directories( ${SDL2_INCLUDE_DIRS}) -SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -funsigned-char") enable_testing() add_subdirectory(libs) add_subdirectory(platform) diff --git a/INST/SETUP.C b/INST/SETUP.C index a3fb442..d27dfc8 100644 --- a/INST/SETUP.C +++ b/INST/SETUP.C @@ -929,7 +929,7 @@ static void start_install() char error=0,autostart; get_value(0,60,target_path); if (find_object(waktual,70)!=NULL) autostart=f_get_value(0,70); else autostart=1; - strupr(target_path); + strupper(target_path); if (validate_path(target_path)==0) { msg_box("Cesta je �patn�",'\x1',"Cesta s c�lov�m adres��em je chybn� zad�na. Nepou��vejte dlouh� n�zvy z WINDOWS 95!","OK",NULL); diff --git a/INST/SETUPLIB.C b/INST/SETUPLIB.C index 334acaa..658a586 100644 --- a/INST/SETUPLIB.C +++ b/INST/SETUPLIB.C @@ -200,7 +200,7 @@ long check_size(int gr) for(i=0;i -#include -#include -#include -#include - - - -#define getmem(s) malloc(s) -#define New(typ) (typ *)getmem(sizeof(typ)) -#define NewArr(typ,pocet) (typ *)getmem(sizeof(typ)*pocet); -#define ClrArr(p,typ,pocet) memset(p,0,sizeof(typ)*pocet); - -#define LZW_MAX_CODES 4096 - -typedef struct double_s - { - short group,chr,first,next; - }DOUBLE_S; - -typedef DOUBLE_S CODE_TABLE[LZW_MAX_CODES]; - -DOUBLE_S *compress_dic; -int clear_code; -int end_code; -int free_code; -int nextgroup; -int bitsize,init_bitsize; -unsigned char old_value=0; - -void do_clear_code() //funkce maze slovni (clear code) - { - int i; - - old_value=0; - nextgroup=free_code; - bitsize=init_bitsize; - for(i=0;igroup=i;p->chr=-1;p->next=-1;p->first=-1; - } - } - -void reinit_lzw() - { - do_clear_code(); - } - -char init_lzw_compressor(int dic_size) - //dic size je velikost slovniku(bitova) - //pro 8 bitove hodnoty zde vloz 8. - { - compress_dic=(DOUBLE_S *)getmem(sizeof(CODE_TABLE)); - if (compress_dic==NULL) return -1; - clear_code=1<>3; - data<<=bitepos & 7; - c[0]|=data; - c[1]=data>>8; - c[2]=data>>16; - return bitepos+bitesize; - } - -/*int input_code(void *source,long *bitepos,int bitsize,int mask); -#pragma aux input_code parm [esi][edi][ebx][edx]=\ - "mov ecx,[edi]"\ - "mov eax,ecx"\ - "shr eax,3"\ - "mov eax,[esi+eax]"\ - "and cl,7"\ - "shr eax,cl"\ - "and eax,edx"\ - "add [edi],ebx"\ - value[eax] modify [ecx]; -*/ -int input_code_c(unsigned char *source,long *bitepos,int bitsize,int mask) - { - unsigned char *c;int x; - c=source; - c+=*bitepos>>3; - x=c[0]+(c[1]<<8)+(c[2]<<16); - x>>=*bitepos & 7; - x &= mask; - *bitepos=*bitepos+bitsize; - return x; - } - - -int find_code(DOUBLE_S *p) - //hleda skupinu ve slovniku. Pokud neexistuje vraci -1; - { - int ps; - - ps=p->group; - ps=compress_dic[ps].first; - while (ps!=-1) - { - if (compress_dic[ps].chr==p->chr) return ps; - ps=compress_dic[ps].next; - } - return -1; - } - - -void add_code(DOUBLE_S *p) - //vklada novou dvojici - { - p->first=-1;p->next=compress_dic[p->group].first; - memcpy(&compress_dic[nextgroup],p,sizeof(DOUBLE_S)); - compress_dic[p->group].first=nextgroup; - nextgroup++; - } - - -long lzw_encode(unsigned char *source,void *target,int size) - //Encode LZW. zdroj, cil a velikost dat. Vraci velikost komprimovano. - { - long bitpos=0; - long maxbpos=size*8; - DOUBLE_S p; - int f; - - clear: - old_value=(unsigned char)(p.group=*source++);size--; - while (size-->0) - { - if (bitpos>maxbpos) return -1; - p.chr=(int)((unsigned char)(*source++));old_value+=p.chr; - f=find_code(&p); - if (f<0) - { - bitpos=output_code_c(target,bitpos,bitsize,p.group); - add_code(&p); - if (nextgroup==(1<=LZW_MAX_CODES) - { - bitpos=output_code_c(target,bitpos,bitsize,p.group); - bitpos=output_code_c(target,bitpos,bitsize,clear_code); - do_clear_code(); - goto clear; - } - } - else - p.group=f; - } - bitpos=output_code_c(target,bitpos,bitsize,p.group); - bitpos=output_code_c(target,bitpos,bitsize,end_code); - if (bitpos>maxbpos) return -1; - return (bitpos+8)>>3; - } - - -void de_add_code(DOUBLE_S *p,int *mask) - { - DOUBLE_S *q; - - q=&compress_dic[nextgroup];q->group=p->group;q->chr=p->chr;q->first=compress_dic[p->group].first+1; - nextgroup++; - if (nextgroup==*mask) - { - *mask=(*mask<<1)+1; - bitsize++; - } - } - - - -int expand_code(int code,unsigned char **target) - { - static int first; - - if (code>end_code) - { - assert(compress_dic[code].groupsound; if (s[0])it->sound=add_sound_to_table(s);else it->sound=0; delete_unused_sound(z); diff --git a/MAPS/MAPEDIT.C b/MAPS/MAPEDIT.C index 64b3741..b7a00b1 100644 --- a/MAPS/MAPEDIT.C +++ b/MAPS/MAPEDIT.C @@ -874,7 +874,7 @@ int main(int argc,char *argv[]) puts("...nemohu najit WSKELDAL.INI\n"); return 1; } - if (strlen(filename)>3 && stricmp(filename+strlen(filename)-3,"adv")==0) + if (strlen(filename)>3 && istrcmp(filename+strlen(filename)-3,"adv")==0) { TSTR_LIST adv_cfg=read_config(filename); config_file=merge_configs(config_file,adv_cfg); diff --git a/MAPS/MOB_EDIT.C b/MAPS/MOB_EDIT.C index 26285cd..58a8092 100644 --- a/MAPS/MOB_EDIT.C +++ b/MAPS/MOB_EDIT.C @@ -460,7 +460,7 @@ void check_mobs_name() for(i=0;i<6 && s[i];i++) if (s[i]==32) s[i]='_'; for(;i<6;i++) s[i]='_'; s[i]=0; - strupr(s); + strupper(s); set_value(0,100,s); c_set_value(0,180,0); c_set_value(0,185,0); @@ -674,7 +674,7 @@ void mob_sound_call(int mob) for(j=0;j12) { MessageBox(hDlg,"Jmeno mapy je prilis dlouhe (max 8 znaku bez pripony nebo 12 znaku s priponou)",0,MB_OK|MB_ICONEXCLAMATION); diff --git a/POKUSSCR.C b/POKUSSCR.C deleted file mode 100644 index 51b4e7f..0000000 --- a/POKUSSCR.C +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Nahodi SVGA - */ -#include -#include -#include -#include -#include - -#define SCREEN_AREA 0xa000 -#define SCREEN_LIN_ADDR ((SCREEN_AREA) << 4) -#define SCREEN_SIZE 65537 - - unsigned char pomoc[256]; -void main() - { - unsigned short *pscreen; - unsigned int sizegran; - int i,err; - int col; - int g; - union REGPACK regs; -//------------------------------------------------------------- - //pomoc = (unsigned char *)malloc(512); - memset( ®s, 0, sizeof(union REGPACK) ); - regs.w.ax = 0x4f02; - regs.w.bx = 0x0111; - intr( 0x10, ®s);//nastaveni videomodu - //regs.w.ax = 0x4f01; - //regs.w.cx = 0x0101; - //regs.w.es = FP_SEG (pomoc); - //regs.w.di = FP_OFF (pomoc); - //intr( 0x10, ®s);//zjisteni granularity v KB - //err = regs.w.ax; - //sizegran = pomoc[4]; - //sizegran = sizegran*1024; - //if (sizegran<=65536) -//---------------------------- - for( col = 0; col < 100; col++ ) { - trace:if (!(inp( 0x03da )&8 )) goto trace;// cekani na raytrace - for( g = 0; g < 10; g++ ) { - regs.w.ax = 0x4f05; - regs.w.bx = 0; - regs.w.dx = g; - intr( 0x10, ®s);//prepnuti videostranky - pscreen = (unsigned short *)SCREEN_LIN_ADDR; - for( i = 0; i < SCREEN_SIZE; i+=sizeof(*pscreen) ) { - *pscreen = i+col*g; - pscreen+=1; - } - } - } -regs.w.ax = 0x0003; -intr (0x10,®s); -//for( g = 0; g < 15; g++ ) printf("%X...%X\n",g,pomoc[g]*1024); -//free (pomoc); -//printf("err %X\n",err); -} diff --git a/Skeldal.sln b/Skeldal.sln deleted file mode 100644 index 045702f..0000000 --- a/Skeldal.sln +++ /dev/null @@ -1,43 +0,0 @@ -Microsoft Visual Studio Solution File, Format Version 10.00 -# Visual Studio 2008 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MapEdit", "mapedit\MapEdit.vcproj", "{F2CA5BB1-C021-4708-AED7-7290F7255537}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Skeldal", "Skeldal.vcproj", "{AE3E864A-642C-4280-93EC-77A551CF495C}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Lex_Lib", "mapedit\Lex_Lib\Lex_Lib.vcproj", "{E8075868-DD7C-4F22-8751-4847A3F33F55}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CSpells", "mapedit\CSpells\CSpells.vcproj", "{9C3ABECA-90BA-4D59-BE93-BABE53117B89}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CDialogy", "mapedit\CDialogy\CDialogy.vcproj", "{CA0202C1-2629-45BC-ACBF-1063EA1F4285}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Release|Win32 = Release|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {F2CA5BB1-C021-4708-AED7-7290F7255537}.Debug|Win32.ActiveCfg = Debug|Win32 - {F2CA5BB1-C021-4708-AED7-7290F7255537}.Debug|Win32.Build.0 = Debug|Win32 - {F2CA5BB1-C021-4708-AED7-7290F7255537}.Release|Win32.ActiveCfg = Release|Win32 - {F2CA5BB1-C021-4708-AED7-7290F7255537}.Release|Win32.Build.0 = Release|Win32 - {AE3E864A-642C-4280-93EC-77A551CF495C}.Debug|Win32.ActiveCfg = Debug|Win32 - {AE3E864A-642C-4280-93EC-77A551CF495C}.Debug|Win32.Build.0 = Debug|Win32 - {AE3E864A-642C-4280-93EC-77A551CF495C}.Release|Win32.ActiveCfg = Release|Win32 - {AE3E864A-642C-4280-93EC-77A551CF495C}.Release|Win32.Build.0 = Release|Win32 - {E8075868-DD7C-4F22-8751-4847A3F33F55}.Debug|Win32.ActiveCfg = Debug|Win32 - {E8075868-DD7C-4F22-8751-4847A3F33F55}.Debug|Win32.Build.0 = Debug|Win32 - {E8075868-DD7C-4F22-8751-4847A3F33F55}.Release|Win32.ActiveCfg = Release|Win32 - {E8075868-DD7C-4F22-8751-4847A3F33F55}.Release|Win32.Build.0 = Release|Win32 - {9C3ABECA-90BA-4D59-BE93-BABE53117B89}.Debug|Win32.ActiveCfg = Debug|Win32 - {9C3ABECA-90BA-4D59-BE93-BABE53117B89}.Debug|Win32.Build.0 = Debug|Win32 - {9C3ABECA-90BA-4D59-BE93-BABE53117B89}.Release|Win32.ActiveCfg = Release|Win32 - {9C3ABECA-90BA-4D59-BE93-BABE53117B89}.Release|Win32.Build.0 = Release|Win32 - {CA0202C1-2629-45BC-ACBF-1063EA1F4285}.Debug|Win32.ActiveCfg = Debug|Win32 - {CA0202C1-2629-45BC-ACBF-1063EA1F4285}.Debug|Win32.Build.0 = Debug|Win32 - {CA0202C1-2629-45BC-ACBF-1063EA1F4285}.Release|Win32.ActiveCfg = Release|Win32 - {CA0202C1-2629-45BC-ACBF-1063EA1F4285}.Release|Win32.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/Skeldal.suo b/Skeldal.suo deleted file mode 100644 index 369497b..0000000 Binary files a/Skeldal.suo and /dev/null differ diff --git a/Skeldal.vcproj b/Skeldal.vcproj deleted file mode 100644 index d094fcf..0000000 --- a/Skeldal.vcproj +++ /dev/null @@ -1,1917 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/StdAfx.cpp b/StdAfx.cpp deleted file mode 100644 index 1a12dd9..0000000 --- a/StdAfx.cpp +++ /dev/null @@ -1,8 +0,0 @@ -// stdafx.cpp : source file that includes just the standard includes -// mapedit.pch will be the pre-compiled header -// stdafx.obj will contain the pre-compiled type information - -#include "stdafx.h" - -// TODO: reference any additional headers you need in STDAFX.H -// and not in this file diff --git a/StdAfx.h b/StdAfx.h deleted file mode 100644 index a9a914f..0000000 --- a/StdAfx.h +++ /dev/null @@ -1,19 +0,0 @@ -// stdafx.h : include file for standard system include files, -// or project specific include files that are used frequently, but -// are changed infrequently -// - -#if !defined(AFX_STDAFX_H__A63322C2_6786_488F_BB36_15C84AEB5478__INCLUDED_) -#define AFX_STDAFX_H__A63322C2_6786_488F_BB36_15C84AEB5478__INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 - - -// TODO: reference additional headers your program requires here - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_STDAFX_H__A63322C2_6786_488F_BB36_15C84AEB5478__INCLUDED_) diff --git a/VIDEO/MGFSOUND.C b/VIDEO/MGFSOUND.C index 5709892..851b3be 100644 --- a/VIDEO/MGFSOUND.C +++ b/VIDEO/MGFSOUND.C @@ -419,7 +419,7 @@ void interpret_line(FILE *f) c++; sscanf(c,"%23s",command);c=strchr(c,32); - strupr(command); + strupper(command); if (!strcmp(command,"ID")) { get_num(c,num); diff --git a/VIDEO/MGIFEDIT.C b/VIDEO/MGIFEDIT.C index ce62348..9314a74 100644 --- a/VIDEO/MGIFEDIT.C +++ b/VIDEO/MGIFEDIT.C @@ -450,7 +450,7 @@ static void change_dir() c_set_value(0,9,0); send_message(E_GUI,9,E_CONTROL,2); i=strlen(last_path); - strupr(last_path); + strupper(last_path); if (i!=0 && last_path[i-1]!='\\') { strcat(last_path,"\\"); diff --git a/VIDEO/PCX2MGIF.C b/VIDEO/PCX2MGIF.C index 216ab83..b087ff1 100644 --- a/VIDEO/PCX2MGIF.C +++ b/VIDEO/PCX2MGIF.C @@ -676,7 +676,7 @@ char *get_pcx_name(char *name,int x) sprintf(s,"%s%05d.pcx",s,x); } else sprintf(s,"%s%04d.pcx",s,x); - strupr(s); + strupper(s); } else { @@ -805,7 +805,7 @@ void script_compress(char *script_name) int j=lowq; ungetc(i,scr); i=fscanf(scr,"%s %d %d %d %d",s,&j,&min_fr,&max_fr,&colorq); - strupr(s); + strupper(s); if (!strcmp(s,"FRAMESTEP")) frame_step=j; else if (!strcmp(s,"STATIC")) statpic=j; diff --git a/ZVUK/zvuk_dx.cpp b/ZVUK/zvuk_dx.cpp index d44ce79..c74cab6 100644 --- a/ZVUK/zvuk_dx.cpp +++ b/ZVUK/zvuk_dx.cpp @@ -722,7 +722,7 @@ void change_music(const char *mus_filename) else { const char *c=strrchr(mus_filename,'.'); - if (c!=0 && stricmp(c,".mus")==0) + if (c!=0 && istrcmp(c,".mus")==0) GCurrentDecoder=&GMusDecoder; else GCurrentDecoder=&GWinAmpPlayer; diff --git a/addonKouzla.odt b/addonKouzla.odt deleted file mode 100644 index 0c96aa0..0000000 Binary files a/addonKouzla.odt and /dev/null differ diff --git a/crashdump.cpp b/crashdump.cpp deleted file mode 100644 index 39eaa70..0000000 --- a/crashdump.cpp +++ /dev/null @@ -1,276 +0,0 @@ -#define WINVER 0x0500 -#include -#include -#include -#include - - -#ifndef __specstrings -#define __specstrings - -#define PSTR char * -#define PCSTR const char * -#define PULONG_PTR DWORD * -#define ULONG_PTR DWORD - #define __in - #define __out - #define __inout - #define __in_opt - #define __out_opt - #define __inout_opt - #define __in_ecount(x) - #define __out_ecount(x) - #define __inout_ecount(x) - #define __in_bcount(x) - #define __out_bcount(x) - #define __inout_bcount(x) - #define __deref_opt_out - #define __deref_out - #define __out_xcount(x) -#endif - - -#include -typedef BOOL (WINAPI *MiniDumpWriteDump_Type)( - HANDLE hProcess, - DWORD ProcessId, - HANDLE hFile, - MINIDUMP_TYPE DumpType, - PMINIDUMP_EXCEPTION_INFORMATION ExceptionParam, - PMINIDUMP_USER_STREAM_INFORMATION UserStreamParam, - PMINIDUMP_CALLBACK_INFORMATION CallbackParam -); - -static MiniDumpWriteDump_Type MiniDumpWriteDumpFn; - -static DWORD WINAPI SafeMsgBox(LPVOID text) -{ - MessageBox(NULL,(LPCTSTR)text,NULL,MB_OK|MB_SYSTEMMODAL); - return 0; -} - - -static bool GenerateMinidump(MINIDUMP_EXCEPTION_INFORMATION *ExceptionInfo, MINIDUMP_TYPE flags,const char *sufix) -{ - char buff[MAX_PATH+50]; - HANDLE hFile; - GetModuleFileName(NULL,buff,MAX_PATH); - strcat(buff,sufix); - hFile=CreateFile(buff,GENERIC_WRITE,0,NULL,CREATE_ALWAYS,0,NULL); - if (hFile==NULL) - { - char *text=(char *)alloca(strlen(buff)+200); - sprintf(text,"Nemohu vytvorit soubor zaznamu '%s', zkontroluje prava zapisu do adresare hry",buff); - MessageBox(0,text,0,MB_SYSTEMMODAL); - return false; - } - else - { - if (MiniDumpWriteDumpFn(GetCurrentProcess(),GetCurrentProcessId(),hFile,flags,ExceptionInfo,NULL,NULL)!=TRUE) - { - char *text=(char *)alloca(strlen(buff)+200); - sprintf(text,"Selhalo volani MiniDumpWriteDump. Nelze vygenerovat zaznam do souboru '%s'",buff); - MessageBox(0,text,0,MB_SYSTEMMODAL); - return false; - } - CloseHandle(hFile); - } - return true; -} - -static BOOL WINAPI CloseOneWindow(HWND hWnd, LPARAM lParam) -{ - CloseWindow(hWnd); - return TRUE; -} - -static void CloseAllWindows() -{ - EnumThreadWindows(GetCurrentThreadId(),CloseOneWindow,NULL); -} - - -extern "C" { int GetExeVersion();} - -static DWORD WINAPI PostError(LPVOID p) -{ - char buff[MAX_PATH+50]; - char dmp[MAX_PATH+50]; - char product[MAX_PATH]; - char *tmp; - GetModuleFileName(NULL,buff,MAX_PATH); - tmp=strrchr(buff,'\\'); - if (tmp==0) tmp=buff;else tmp++; - strcpy(product,tmp); - strcpy(dmp,buff); - strcpy(strrchr(buff,'\\')+1,"poslichybu.html"); - strcat(dmp,".short.dmp"); - DeleteFile(buff); - HANDLE h=CreateFile(buff,GENERIC_WRITE,0,0,CREATE_ALWAYS,0,0); - if (h!=INVALID_HANDLE_VALUE) - { - DWORD wrt; - DWORD rd; - const char *form1= - "" - "" - "" - "" - "" - "Br�ny Skeldalu - formul�� k odesl�n� chyby" - "" - "" - "" - "
\"logo\"
" - "
" - "

Br�ny Skeldalu - formul�� k odesl�n� chyby

" - "

Autor programu se omlouv� za chybu a pros� V�s, abyste pomohl p�i odhalov�n� chyb.
" - "Sta�� kdy� pravdiv� vypln�te ode�lete n�sleduj�c� formul��.
" - "Pokuste se pros�m napsat co nejv�ce informac�.
" - "K formul��i je p�ilo�en soubor obsahuj�c� z�znam o chyb�.

" - "D�kujeme za spolupr�ci

" - "
" - "
" - "
V� e-mail pro p��pad, �e bysme v�s cht�li kontaktovat: (nepovinn�)
" - "" - "
Napi�te pros�m dal�� informace o tom, za jak�ch podm�nek chyba vznikla, pop��pad� jak chybu znovu vyvolat
" - "" - "
P��padn� p�ilo�te ulo�enou pozici nebo jin� soubory souvisej�c� s chybou
" - "" - "
" - "Pozor: Formul�� tak� obsahuje informace o posledn� chyb�.
" - "Nepou��vejte tento formul�� k odesl�n� jin�ch chybov�ch hl�en�.
" - "

Prohl�en� o ochran� soukrom�ch �daj�

" - "
" - "
" - "=0;i--) - { - char tmp[3]; - sprintf(tmp,"%02X",buff[i]); - buff[i*2]=tmp[0]; - buff[i*2+1]=tmp[1]; - } - WriteFile(h,buff,rd*2,&wrt,0); - }while (rd); - CloseHandle(v); - const char *form2="\" />

" - "

"; - WriteFile(h,(void *)(form4),strlen(form4),&wrt,0); - CloseHandle(h); - } - - int i=MessageBox(NULL,"Zaznam o chybe dokoncen. Soubory se zaznamy byly ulozeny do slozky hry. " - "Prosim nemazte tyto soubory, je mozne, ze budou potrebne k hlubsi analyze chyby. " - "Hlaseni o chybe je nyni mozne odeslat po internetu k dalsimu prozkoumani. " - "Pokud neni pocitac pripojen k internetu trvale, bude nutne jej pripojit nyni.\r\n\r\n" - "Chcete zaznam o chybe odeslat?",0,MB_YESNO|MB_SYSTEMMODAL); - if (i==IDYES) - { - if (h==INVALID_HANDLE_VALUE || (UINT)ShellExecute(0,0,buff,0,0,SW_NORMAL)<32) - MessageBox(0,"Nastala chyba pri otevirani formulare. Formular prosim otevrete rucne - soubor 'poslichybu.html'",0,MB_OK|MB_SYSTEMMODAL); - } - else - { - MessageBox(0,"Informace o chybe lze odeslat pozdeji pomoci formulare 'poslichybu.html', jenz byl vytvoren ve slozce hry",0,MB_OK|MB_SYSTEMMODAL); - } - return 0; -} - -static DWORD WINAPI CrashReportGenerateThread(LPVOID data) -{ - MINIDUMP_EXCEPTION_INFORMATION *ExceptionInfo=(MINIDUMP_EXCEPTION_INFORMATION *)data; - HWND hwnd; - int res; - - if (MiniDumpWriteDumpFn!=NULL) - { - hwnd=CreateWindowEx(WS_EX_TOPMOST,"STATIC","V programu nastala chyba\r\n\r\nSystem Windows nyni sbira informace o chybe a generuje potrebne soubory.\r\nProsim cekejte, tato operace muze trvat trochu dele...",WS_POPUP| - WS_DLGFRAME|WS_VISIBLE|SS_CENTER,0,0,640,80,NULL,NULL,GetModuleHandle(NULL),NULL); - UpdateWindow(hwnd); - if (GenerateMinidump(ExceptionInfo,MiniDumpNormal,".short.dmp")==false) return 0; - GenerateMinidump(ExceptionInfo,MiniDumpWithDataSegs,".int32_t.dmp"); - GenerateMinidump(ExceptionInfo,MiniDumpWithFullMemory,".full.dmp"); - PostError(0); - DestroyWindow(hwnd); - } - else - { - res=MessageBox(0,"V programu nastala chyba. Bohuzel neni pritomen soubor DbgHelp.dll v adresari hry, " - "neni tedy mozne vytvorit zaznam o chybe. Ze stranek http://skeldal.jinak.cz je mozne" - "tento soubor stahnout a tim pomoci autorovi odhalit a opravit tyto zaludne pady.\r\n\r\n" - "Chcete prejit na stranky obsahujici posledni verze potrebnych souboru?",0,MB_YESNO|MB_SYSTEMMODAL); - if (res==IDYES) - ShellExecute(0,0,"http://skeldal.jinak.cz/main.php?page=download",0,0,SW_NORMAL); - } - return 0; -} - - -static LONG WINAPI CrashReportGenerate(EXCEPTION_POINTERS *ExceptionInfo) -{ - HANDLE msg; - - MINIDUMP_EXCEPTION_INFORMATION nfo; - nfo.ThreadId=GetCurrentThreadId(); - nfo.ExceptionPointers=ExceptionInfo; - nfo.ClientPointers=FALSE; - -// CloseAllWindows(); - - msg=CreateThread(NULL,0,CrashReportGenerateThread,(void *)&nfo,0,NULL); - WaitForSingleObject(msg,INFINITE); - ExitProcess(1); - return 0; -} - -extern "C" -{ - void CrashReportOnBuffOverrun() - { - __try - { - RaiseException(EXCEPTION_ARRAY_BOUNDS_EXCEEDED,EXCEPTION_NONCONTINUABLE,0,0); - } - __except(CrashReportGenerate(GetExceptionInformation())) - { - } - } - - -extern char __report_gsfailure(); -void InitCrashDump() -{ - char *p=(char *)(&__report_gsfailure); - DWORD oldProtect; - ::VirtualProtect(p,150,PAGE_EXECUTE_WRITECOPY,&oldProtect); - *p=0xCC; - ::VirtualProtect(p,150,PAGE_EXECUTE_READ,&oldProtect); - SetUnhandledExceptionFilter(CrashReportGenerate); - - HMODULE lib=LoadLibrary("DbgHelp.dll"); - MiniDumpWriteDumpFn=(MiniDumpWriteDump_Type)GetProcAddress(lib,"MiniDumpWriteDump"); -} -} \ No newline at end of file diff --git a/crashdump.h b/crashdump.h deleted file mode 100644 index 285930a..0000000 --- a/crashdump.h +++ /dev/null @@ -1 +0,0 @@ -void InitCrashDump(); diff --git a/game/CMakeLists.txt b/game/CMakeLists.txt index 54a2e39..54b0ca4 100644 --- a/game/CMakeLists.txt +++ b/game/CMakeLists.txt @@ -41,3 +41,4 @@ ${CMAKE_BINARY_DIR}/default_font.cpp ) add_library(skeldal_main ${files}) +set_property(TARGET skeldal_main PROPERTY CXX_STANDARD 20) \ No newline at end of file diff --git a/game/advconfig.c b/game/advconfig.c index d51ee12..85d18c3 100644 --- a/game/advconfig.c +++ b/game/advconfig.c @@ -2,7 +2,7 @@ #include "advconfig.h" -#include +#include #include @@ -17,25 +17,25 @@ static void process_row(INI_CONFIG_SECTION *sec, const char *row) { const char *value = sep+1; - if (stricmp(key,"CESTA_GRAFIKA") == 0) { + if (istrcmp(key,"CESTA_GRAFIKA") == 0) { ini_replace_key(sec, "graphics", value); - } else if (stricmp(key, "CESTA_ZVUKY") == 0) { + } else if (istrcmp(key, "CESTA_ZVUKY") == 0) { ini_replace_key(sec, "sounds", value); - } else if (stricmp(key, "CESTA_FONTY") == 0) { + } else if (istrcmp(key, "CESTA_FONTY") == 0) { ini_replace_key(sec, "fonts", value); - } else if (stricmp(key, "CESTA_MAPY") == 0) { + } else if (istrcmp(key, "CESTA_MAPY") == 0) { ini_replace_key(sec, "maps", value); - } else if (stricmp(key, "CESTA_MUSIC") == 0) { + } else if (istrcmp(key, "CESTA_MUSIC") == 0) { ini_replace_key(sec, "music_adv", value); - } else if (stricmp(key, "CESTA_BGRAFIKA") == 0) { + } else if (istrcmp(key, "CESTA_BGRAFIKA") == 0) { ini_replace_key(sec, "gui", value); - } else if (stricmp(key, "CESTA_ITEMY") == 0) { + } else if (istrcmp(key, "CESTA_ITEMY") == 0) { ini_replace_key(sec, "items", value); - } else if (stricmp(key, "CESTA_ENEMY") == 0) { + } else if (istrcmp(key, "CESTA_ENEMY") == 0) { ini_replace_key(sec, "enemy", value); - } else if (stricmp(key, "CESTA_VIDEO") == 0) { + } else if (istrcmp(key, "CESTA_VIDEO") == 0) { ini_replace_key(sec, "video", value); - } else if (stricmp(key, "CESTA_DIALOGY") == 0) { + } else if (istrcmp(key, "CESTA_DIALOGY") == 0) { ini_replace_key(sec, "dialogs", value); } } diff --git a/game/automap.c b/game/automap.c index f5fe943..1b84221 100644 --- a/game/automap.c +++ b/game/automap.c @@ -254,7 +254,7 @@ void psani_poznamek_event(EVENT_MSG *msg,void **data) { case 8:if (index) index--; text[index]=0;break; case 27:strcpy(text,save); - [[fallthrough]]; + CASE_FALLTHROUGH; case 13:save_text_to_map(x,y,cur_depth,text); send_message(E_DONE,E_MOUSE,psani_poznamek_event); msg->msg=-2; diff --git a/game/builder.c b/game/builder.c index 2fbe372..a2810a5 100644 --- a/game/builder.c +++ b/game/builder.c @@ -1329,7 +1329,7 @@ void redraw_scene() send_message(E_KOUZLO_ANM); } -void refresh_scene() +void refresh_scene(THE_TIMER *t) { redraw_scene(); if (!cancel_render && !norefresh) diff --git a/game/chargen.c b/game/chargen.c index 85f6050..897219c 100644 --- a/game/chargen.c +++ b/game/chargen.c @@ -695,7 +695,7 @@ static char validate_character(THUMAN *h) return 1; } */ -static void empty_proc() +static void empty_proc(void) { } diff --git a/game/console.c b/game/console.c index 5f313a6..a5be67b 100644 --- a/game/console.c +++ b/game/console.c @@ -177,7 +177,7 @@ static char purge_map() _dos_findclose(&rc);*/ wzprintf("\r\n Zadej jmeno tempu (all - vse):");gets(buffer); if (buffer[0]==0) return 0; - strupr(buffer); + strupper(buffer); concat(c,pathtable[SR_TEMP],buffer); if (strcmp(buffer,ALL) && check_file_exists_ex(c)) { @@ -461,7 +461,7 @@ static int add_file_to_console(const char *name, LIST_FILE_TYPE _, size_t __, vo 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 > 3 && istrcmp(name+l-4,".MAP") == 0) { if (l>19) l = 19; memcpy(buff, name, l); wzprintf("%s", buff); @@ -475,51 +475,51 @@ static int add_file_to_console(const char *name, LIST_FILE_TYPE _, size_t __, vo } static int process_on_off_command(const char *cmd, char on) { - if (stricmp(cmd, "inner-eye") == 0) { + if (istrcmp(cmd, "inner-eye") == 0) { show_debug = on; return 1; } - if (stricmp(cmd, "hunter-instinct") == 0) { + if (istrcmp(cmd, "hunter-instinct") == 0) { show_lives = on; return 1; } - if (stricmp(cmd, "no-hassle") == 0) { + if (istrcmp(cmd, "no-hassle") == 0) { nohassle=on; return 1; } - if (stricmp(cmd, "iron-skin") == 0) { + if (istrcmp(cmd, "iron-skin") == 0) { immortality=on; return 1; } - if (stricmp(cmd, "spirit-wander") == 0) { + if (istrcmp(cmd, "spirit-wander") == 0) { cur_group=on?10:postavy[0].groupnum; return 1; } - if (stricmp(cmd, "ghost-walls") == 0) { + if (istrcmp(cmd, "ghost-walls") == 0) { ghost_walls = on; return 1; } - if (stricmp(cmd, "true-seeing") == 0) { + if (istrcmp(cmd, "true-seeing") == 0) { true_seeing = on; return 1; } - if (stricmp(cmd, "walking-in-air") == 0) { + if (istrcmp(cmd, "walking-in-air") == 0) { nofloors = on; return 1; } - if (stricmp(cmd, "enemy-insight") == 0) { + if (istrcmp(cmd, "enemy-insight") == 0) { show_mob_info = on; return 1; } - if (stricmp(cmd, "enemy-walk-diagonal") == 0) { + if (istrcmp(cmd, "enemy-walk-diagonal") == 0) { game_extras = on?(game_extras | EX_WALKDIAGONAL):(game_extras & ~EX_WALKDIAGONAL); return 1; } - if (stricmp(cmd, "ghost-form") == 0) { + if (istrcmp(cmd, "ghost-form") == 0) { pass_all_mobs = on; return 1; } - if (stricmp(cmd, "dead-food") == 0) { + if (istrcmp(cmd, "dead-food") == 0) { dead_food = on; return 1; } @@ -529,41 +529,41 @@ static int process_on_off_command(const char *cmd, char on) { void postavy_teleport_effect(int sector,int dir,int postava,char effect); static int process_actions(const char *command) { - if (stricmp(command, "flute") == 0) { + if (istrcmp(command, "flute") == 0) { bott_draw_fletna(); return 1; } - if (stricmp(command, "global-map") == 0) { + if (istrcmp(command, "global-map") == 0) { wire_global_map(); return 1; } - if (stricmp(command, "status") == 0) { + if (istrcmp(command, "status") == 0) { display_game_status(); return 1; } - if (stricmp(command, "offlers-blessing") == 0) { + if (istrcmp(command, "offlers-blessing") == 0) { money=150000; play_fx_at(FX_MONEY); return 1; } - if (stricmp(command, "i-require-gold") == 0) { + if (istrcmp(command, "i-require-gold") == 0) { money+=1; play_fx_at(FX_MONEY); return 1; } - if (stricmp(command, "to-the-moon") == 0) { + if (istrcmp(command, "to-the-moon") == 0) { money+=100000; play_fx_at(FX_MONEY); return 1; } - if (stricmp(command, "echo-location") == 0) { + if (istrcmp(command, "echo-location") == 0) { for (int i = 1; i < mapsize; ++i) { map_coord[i].flags |= MC_AUTOMAP; } play_fx_at(FX_MAP); return 1; } - if (stricmp(command, "rise-and-shine") == 0) { + if (istrcmp(command, "rise-and-shine") == 0) { int r = 0; for (int i = 0; i < POCET_POSTAV; ++i) { THUMAN *p = postavy+i; @@ -579,7 +579,7 @@ static int process_actions(const char *command) { return r; } - if (stricmp(command, "ascent") == 0) { + if (istrcmp(command, "ascent") == 0) { int lev = postavy[0].exp; for (int i = 0; i < POCET_POSTAV; ++i) { THUMAN *p = postavy+i; @@ -592,18 +592,18 @@ static int process_actions(const char *command) { } return 1; } - if (stricmp(command, "by-the-power-of-grayskull") == 0) { + if (istrcmp(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) { + if (istrcmp(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; } - if (stricmp(command, "beam-me-up") == 0) { + if (istrcmp(command, "beam-me-up") == 0) { for (int i = 1; i < mapsize; ++i) { map_coord[i].flags |= MC_AUTOMAP; } @@ -652,14 +652,14 @@ static void wiz_find_monster(const char *name) { } static int process_with_params(const char *cmd, const char *args) { - if (stricmp(cmd, "locate") == 0) { + if (istrcmp(cmd, "locate") == 0) { if (args[0] == 0) return 0; wiz_find_item(args); wiz_find_monster(args); console_add_line(""); return 1; } - if (stricmp(cmd, "summon") == 0) { + if (istrcmp(cmd, "summon") == 0) { if (args[0] == 'i') { char *end; unsigned long id = strtoul(args+1, &end, 10); @@ -673,16 +673,16 @@ static int process_with_params(const char *cmd, const char *args) { } return 0; } - if (stricmp(cmd, "say") == 0) { + if (istrcmp(cmd, "say") == 0) { console_add_line(args); return 1; } - if (stricmp(cmd, "speed") == 0) { + if (istrcmp(cmd, "speed") == 0) { long v = strtol(args, NULL, 10); if (v > 0) timerspeed_val = v; return v > 0; } - if (stricmp(cmd, "portal-jump") == 0) { + if (istrcmp(cmd, "portal-jump") == 0) { if (check_file_exists(build_pathname(2,gpathtable[SR_MAP], args))) { TMA_LOADLEV lev; strncpy(lev.name,args,12); @@ -702,8 +702,8 @@ 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; + if (istrcmp(cmd.args, "on") == 0) onoff = 1; + else if (istrcmp(cmd.args, "off") == 0) onoff = 0; } else { return process_actions(cmd.command); } diff --git a/game/dialogy.c b/game/dialogy.c index c10d65d..c0eb7b3 100644 --- a/game/dialogy.c +++ b/game/dialogy.c @@ -731,7 +731,7 @@ void wire_dialog_drw() ukaz_mysku(); showview(0,0,0,0); } -void unwire_dialog() +void unwire_dialog(void) { send_message(E_DONE,E_KEYBOARD,key_check); disable_click_map(); @@ -1230,7 +1230,7 @@ static void cast_spell(int spell) add_spell(spell,cil,cil,1); } -static void free_dialog_stringtable() { +static void free_dialog_stringtable(void) { stringtable_free(dialogy_strtable); } diff --git a/game/dlglib.c b/game/dlglib.c index 496a87a..ce524a2 100644 --- a/game/dlglib.c +++ b/game/dlglib.c @@ -191,7 +191,7 @@ void proved_d(char *code,char *text) if (*code!=0xff)fscanf(dlg,"%[^\n]",text); if (*code==0) { - strupr(text); + strupper(text); if (!strncmp(text,"GOTO",4)) { int n; diff --git a/game/engine1.c b/game/engine1.c index d10030f..4211fb8 100644 --- a/game/engine1.c +++ b/game/engine1.c @@ -2,6 +2,7 @@ #include #include #include +#include #include diff --git a/game/gamesave.c b/game/gamesave.c index 081f05b..714dd75 100644 --- a/game/gamesave.c +++ b/game/gamesave.c @@ -839,7 +839,7 @@ typedef struct load_specific_file_callback_data_t { static ENUM_ALL_STATUS_CALLBACK_RESULT load_specific_file_callback(FILE *f, const char *name, size_t datasize, void *ctx) { LOAD_SPECIFIC_FILE_CALLBACK_DATA *me = ctx; - if (stricmp(name, me->name) == 0) { + if (istrcmp(name, me->name) == 0) { void *d = getmem(datasize); if (fread(d, 1, datasize, f) != datasize) { free(d); @@ -1377,7 +1377,7 @@ static void saveload_keyboard(EVENT_MSG *msg,void **_) } } -void unwire_save_load() +void unwire_save_load(void) { term_task_wait(clk_ask_name[0].id); if (back_texture!=NULL) free(back_texture); diff --git a/game/gen_stringtable.c b/game/gen_stringtable.c index 4853316..43f6349 100644 --- a/game/gen_stringtable.c +++ b/game/gen_stringtable.c @@ -58,7 +58,7 @@ void cti_texty(void); static int convert_map_strings_1(const char *source_name, LIST_FILE_TYPE type, size_t sz, void *context) { int l = strlen(source_name); - if (stricmp(source_name+l-4,".map")) return 0; + if (istrcmp(source_name+l-4,".map")) return 0; source_name = set_file_extension(source_name, ".txt"); const char *target_name = set_file_extension(concat2("map_", source_name),".csv"); const char *target_path = *(const char **)context; diff --git a/game/globals.h b/game/globals.h index b067a55..fc13cb8 100644 --- a/game/globals.h +++ b/game/globals.h @@ -6,6 +6,7 @@ #include #include #include +#include #include #define POCET_POSTAV 6 @@ -645,11 +646,11 @@ extern char marker; //tato promenna je 0, jen v pripade ze je 1 probehne assert //builder - skeldal -void *game_keyboard(EVENT_MSG *msg,void **usr); +void game_keyboard(EVENT_MSG *msg,void **usr); void calc_animations(void); int load_map(char *filename); void other_draw(void); -void refresh_scene(void); +void refresh_scene(THE_TIMER *t); const void *pcx_fade_decomp(const void *p, int32_t *s); const void *pcx_15bit_decomp(const void *p, int32_t *s); const void *pcx_15bit_autofade(const void *p, int32_t *s); @@ -663,10 +664,11 @@ const void *load_mob_legacy_format(const void *p, int32_t *s); const void *load_spells_legacy_format(const void *p, int32_t *s); void wire_main_functs(void); void ukaz_kompas(char mode); -void *timming(EVENT_MSG *msg,void **data); +void timming(EVENT_MSG *msg,void **data); void do_timer(void); void hold_timer(int id,char hld); -THE_TIMER *add_to_timer(int id,int delay,int maxcall,void *proc); +typedef void (*TIMER_PROC)(THE_TIMER *t); +THE_TIMER *add_to_timer(int id,int delay,int maxcall,TIMER_PROC proc); void delete_from_timer(int id); THE_TIMER *find_timer(int id); void objekty_mimo(void); @@ -999,7 +1001,7 @@ int count_items_inside(short *place); int count_items_total(short *place); char put_item_to_inv(THUMAN *p,short *picked_items); //funkce vklada predmet(y) do batohu postavy void pick_set_cursor(void); //nastavuje kurzor podle vlozeneho predmetu; -void calc_fly(void); +void calc_fly(THE_TIMER *t); void zmen_skupinu(THUMAN *p); void add_to_group(int num); void group_all(void); diff --git a/game/globmap.c b/game/globmap.c index 95f6cb6..eca4396 100644 --- a/game/globmap.c +++ b/game/globmap.c @@ -19,7 +19,6 @@ #include "globals.h" #include -#include #define GLOBMAP "GLOBMAP.DAT" #define ODDELOVACE ";:=,\n\r{}" diff --git a/game/interfac.c b/game/interfac.c index 95e1c7d..ef9688f 100644 --- a/game/interfac.c +++ b/game/interfac.c @@ -25,7 +25,7 @@ #include "globals.h" #include "engine1.h" #include -#include + #define MES_MAXSIZE 500 #define CHECK_BOX_ANIM 6 @@ -1555,7 +1555,7 @@ void show_jrc_logo(char *filename) word palette[256],*palw; int cntr,cdiff,cpalf,ccc; - change_music("?"); + change_music(NULL); curcolor=0;bar32(0,0,639,479); showview(0,0,0,0);sleep_ms(1000); const char *s = build_pathname(2, gpathtable[SR_VIDEO],filename); diff --git a/game/kniha.c b/game/kniha.c index 902ff7e..af51f86 100644 --- a/game/kniha.c +++ b/game/kniha.c @@ -303,8 +303,8 @@ static char read_set(TMPFILE_RD *txt,char *var,char *set) } } *cc=0; - strupr(set); - strupr(var); + strupper(set); + strupper(var); return c; } @@ -370,7 +370,7 @@ static char read_tag(TMPFILE_RD *txt) i=temp_storage_scanf(txt,"%[^> ] %c",var,&c); while(c<33 && i!=EOF) c=i=temp_storage_getc(txt); if (c!='>') temp_storage_ungetc(txt); - strupr(var); + strupper(var); if (!strcmp(var,PARAGRAPH)) { break_line(); diff --git a/game/kouzla.c b/game/kouzla.c index 62e7f84..808a290 100644 --- a/game/kouzla.c +++ b/game/kouzla.c @@ -1023,7 +1023,7 @@ void spell_teleport_sector(int cil,int owner) if (TelepLocation.map) { destroy_player_map(); - if (stricmp(TelepLocation.map,level_fname)!=0) + if (istrcmp(TelepLocation.map,level_fname)!=0) { diff --git a/game/menu.c b/game/menu.c index 40d300a..de27d2f 100644 --- a/game/menu.c +++ b/game/menu.c @@ -368,8 +368,8 @@ int enter_menu(char open) } static const char *end_titles_path(const char *fname) { - if (stricmp(fname,"TITULKY.TXT") == 0) fname = "end_titles.txt"; - else if (stricmp(fname,"ENDTEXT.TXT") == 0) fname = "epilog.txt"; + if (istrcmp(fname,"TITULKY.TXT") == 0) fname = "end_titles.txt"; + else if (istrcmp(fname,"ENDTEXT.TXT") == 0) fname = "epilog.txt"; return lang_replace_path_if_exists(fname); } @@ -430,7 +430,7 @@ static int insert_next_line(int ztrata) if (title_mode!=TITLE_KONEC) c=get_next_title(0,NULL);else c[0]=0; if (c[0]=='*') { - strupr(c); + strupper(c); if (!strcmp(c+1,"HEAD")) { title_mode=TITLE_HEAD; @@ -633,7 +633,7 @@ void konec_hry() task_id=add_task(8196,titles,0,"TITULKY.TXT"); task_wait_event(E_KEYBOARD); if (is_running(task_id)) term_task(task_id); - change_music("?"); + change_music(NULL); curcolor=0; bar32(0,0,639,479); ukaz_mysku(); diff --git a/game/realgame.c b/game/realgame.c index 08d482f..c499db1 100644 --- a/game/realgame.c +++ b/game/realgame.c @@ -114,7 +114,7 @@ int32_t load_section(FILE *f,void **section, int *sct_type,int32_t *sect_size) } -void prepare_graphics(int *ofs,char *names,int32_t size,void *decomp,int class) +void prepare_graphics(int *ofs,char *names,int32_t size,ABLOCK_DECODEPROC decomp,int class) { char *p,*end; @@ -210,7 +210,7 @@ int load_map(char *filename) level_fname=(char *)getmem(strlen(filename)+1); strcpy(level_fname,filename); SEND_LOG("(GAME) Loading map: '%s'",level_fname); - strupr(level_fname); + strupper(level_fname); mob_template=NULL; mob_size=0; if (f==NULL) return -1; @@ -406,7 +406,7 @@ void leave_current_map() destroy_fly_map(); p=letici_veci; while (p!=NULL) {stop_fly(p,0);p=p->next;} - calc_fly(); + calc_fly(0); save_map=1; free(map_sides); free(map_sectors); @@ -560,7 +560,7 @@ TFLY *duplic_fly(TFLY *p) return q; } -void calc_fly() +void calc_fly(THE_TIMER *t) { LETICI_VEC *p,*q; short ss; @@ -1393,7 +1393,7 @@ void sector0(void) } } -static void tele_redraw() +static void tele_redraw(THE_TIMER *_) { if (!running_anm) return; redraw_scene(); @@ -1442,7 +1442,7 @@ void postavy_teleport_effect(int sector,int dir,int postava,char effect) if (zavora) return; if (effect) { - void *c; + void (*c)(void); zavora=1; c=wire_proc; @@ -1851,13 +1851,13 @@ void sleep_players(va_list args) } -void *game_keyboard(EVENT_MSG *msg,void **usr) +void game_keyboard(EVENT_MSG *msg,void **usr) { int c; usr; - if (pass_zavora) return NULL; - if (cur_mode==MD_END_GAME) return NULL; + if (pass_zavora) return ; + if (cur_mode==MD_END_GAME) return ; if (msg->msg==E_KEYBOARD) { c=quit_request_as_escape(va_arg(msg->data, int)); @@ -1917,7 +1917,6 @@ void *game_keyboard(EVENT_MSG *msg,void **usr) }*/ } } - return &game_keyboard; } diff --git a/game/setup.c b/game/setup.c index cc99a40..49dd0f4 100644 --- a/game/setup.c +++ b/game/setup.c @@ -28,7 +28,7 @@ char q_runsetup(char *parm) char c[6]; strncpy(c,parm,6); - strupr(c); + strupper(c); return !strncmp(c,"/SETUP",6); } @@ -46,7 +46,7 @@ static void checkbox_animator(THE_TIMER *t) static int effects[]={SND_GVOLUME,SND_MUSIC,SND_GFX,SND_TREBL,SND_BASS,SND_XBASS}; -static void do_setup_change() +static void do_setup_change(void) { char c; @@ -59,7 +59,7 @@ static void do_setup_change() } } -static void change_zoom() +static void change_zoom(void) { int id=o_aktual->id; int i; @@ -68,7 +68,7 @@ static void change_zoom() zoom_speed((id-30)/10); } -static void change_turn() +static void change_turn(void) { int id=o_aktual->id; int i; @@ -77,7 +77,7 @@ static void change_turn() turn_speed((id-60)/10); } -static void unwire_setup(); +static void unwire_setup(void); static void setup_keyboard(EVENT_MSG *msg,void **_) { @@ -91,7 +91,7 @@ static void setup_keyboard(EVENT_MSG *msg,void **_) } } -static void wire_setup() +static void wire_setup(void) { unwire_proc(); unwire_proc=unwire_setup; @@ -101,7 +101,7 @@ static void wire_setup() SEND_LOG("(GAME) Starting setup"); } -static void unwire_setup() +static void unwire_setup(void) { show_names=f_get_value(0,90) & 1; enable_sort=f_get_value(0,100) & 1; @@ -200,7 +200,7 @@ void new_setup() add_to_timer(TM_CHECKBOX,4,-1,checkbox_animator); } -void game_setup_() +void game_setup_(void) { wire_setup(); new_setup(); diff --git a/game/skeldal.c b/game/skeldal.c index cbe9ddd..7695d03 100644 --- a/game/skeldal.c +++ b/game/skeldal.c @@ -524,13 +524,13 @@ void back_music(void) puts("\x7"); } */ -void *timming(EVENT_MSG *msg,void **data) +void timming(EVENT_MSG *msg,void **data) { THE_TIMER *p,*q; int i,j; data; - if (msg->msg==E_INIT) return &timming; + if (msg->msg==E_INIT) return ; *otevri_zavoru=1; j=va_arg(msg->data,int); for (i=0;i #include -#include + #define PL_RANDOM 1 #define PL_FORWARD 2 #define PL_FIRST 3 @@ -463,7 +463,7 @@ void create_playlist(char *playlist) c=playlist; while (*c && *c==32) c++; sscanf(c,"%s",mode); - strupr(mode); + strupper(mode); shift=1; if (!strcmp(mode,"RANDOM")) play_list_mode=PL_RANDOM; else if (!strcmp(mode,"FORWARD")) play_list_mode=PL_FORWARD; diff --git a/game/souboje.c b/game/souboje.c index af1026f..d87f0e9 100644 --- a/game/souboje.c +++ b/game/souboje.c @@ -114,10 +114,10 @@ void (*after_spell_wire)(); short *poradi=NULL; short *prave_hraje; -void wire_programming(); -void unwire_programming(); -void wire_jadro_souboje(); -void unwire_jadro_souboje(); +void wire_programming(void); +void unwire_programming(void); +void wire_jadro_souboje(void); +void unwire_jadro_souboje(void); uint8_t sel_zivel=0; static char prekvapeni=0; @@ -443,7 +443,7 @@ void rozhodni_o_poradi() *r++=0; prave_hraje=poradi; } -void hrat_souboj() +void hrat_souboj(THE_TIMER *_) { static int counter=0; char cond=ms_last_event.y>378 && ms_last_event.x>510 && cur_mode!=MD_PRESUN; @@ -459,7 +459,7 @@ void hrat_souboj() } showview(0,0,0,0); if (neco_v_pohybu==2) neco_v_pohybu=0; else neco_v_pohybu=2; - calc_fly();mob_animuj(); + calc_fly(NULL);mob_animuj(); if (d_action!=NULL) do_delay_actions(); } if (cond) ukaz_mysku(); @@ -768,8 +768,8 @@ void konec_presunu(EVENT_MSG *msg,void **unused) } } -void wire_presun_postavy(); -void unwire_presun_postavy() +void wire_presun_postavy(void); +void unwire_presun_postavy(void) { disable_click_map(); send_message(E_DONE,E_KEYBOARD,game_keyboard); @@ -782,7 +782,7 @@ void unwire_presun_postavy() hromadny_utek=0; } -void wire_presun_postavy() +void wire_presun_postavy(void) { unwire_proc(); @@ -1370,7 +1370,7 @@ void jadro_souboje(EVENT_MSG *msg,void **unused) //!!!! Jadro souboje } } -void wire_jadro_souboje() +void wire_jadro_souboje(void) { int battlespeed=gamespeed-gamespeed*gamespeedbattle/5; recalc_volumes(viewsector,viewdir); @@ -1383,7 +1383,7 @@ void wire_jadro_souboje() pgm_help=10; } -void unwire_jadro_souboje() +void unwire_jadro_souboje(void) { delete_from_timer(TM_SCENE); send_message(E_DONE,E_IDLE,jadro_souboje); @@ -1411,7 +1411,7 @@ void fill_rune(char *d,int i) static void *runebar; static char *rune_name=NULL; -void display_rune_bar() +void display_rune_bar(THE_TIMER *_) { short coords[][2]={{3,26},{32,26},{61,26},{90,26},{18,64},{47,64},{76,64}}; char c; @@ -1437,14 +1437,14 @@ void display_rune_bar() -void rune_bar_redrawing() +void rune_bar_redrawing(THE_TIMER *_) { redraw_scene(); if (!norefresh && !cancel_render) { schovej_mysku(); program_draw(); - display_rune_bar(); + display_rune_bar(NULL); ukaz_mysku(); showview(0,0,0,0); } @@ -1471,9 +1471,9 @@ void display_power_bar_tm(THE_TIMER *tm) display_power_bar(1); } -void wire_select_rune(); -void unwire_select_rune(); -void wire_select_power(); +void wire_select_rune(void); +void unwire_select_rune(void); +void wire_select_power(void); char cancel_power(int id,int xa,int ya,int xr,int yr) { @@ -1598,7 +1598,7 @@ char runes_mask(int id,int xa,int ya,int xr,int yr) } if (cc<0) rune_name=NULL; free(runebar);runebar=NULL; - display_rune_bar(); + display_rune_bar(NULL); return 1; } @@ -1614,7 +1614,7 @@ char cancel_runes(int id,int xa,int ya,int xr,int yr) return 1; } -void unwire_select_rune() +void unwire_select_rune(void) { wire_proc=wire_select_rune; delete_from_timer(TM_DELAIER); @@ -1623,7 +1623,7 @@ void unwire_select_rune() free(runebar);runebar=NULL; } -void wire_select_rune() +void wire_select_rune(void) { THUMAN *p; HUM_ACTION *c; @@ -1653,13 +1653,13 @@ void wire_select_rune_fly() cancel_render=1; } -void unwire_select_power() +void unwire_select_power(void) { rune_name=NULL; delete_from_timer(TM_DELAIER); } -void wire_select_power() +void wire_select_power(void) { THUMAN *p; int i; @@ -1727,7 +1727,7 @@ void program_draw() } -void souboje_redrawing() +void souboje_redrawing(THE_TIMER *_) { if (neco_v_pohybu) calc_mobs(); calc_animations(); @@ -1926,7 +1926,7 @@ char mask_click(int id,int xa,int ya,int xr,int yr) switch(d) { case AC_RUN: postavy[select_player].utek=5+postavy[select_player].actions; - [[fallthrough]]; + CASE_FALLTHROUGH; case AC_ATTACK: case AC_STAND: case AC_ARMOR: @@ -2042,7 +2042,7 @@ void programming_keyboard(EVENT_MSG *msg,void **unused) } -void unwire_programming() +void unwire_programming(void) { disable_click_map(); send_message(E_DONE,E_KEYBOARD,programming_keyboard); @@ -2053,7 +2053,7 @@ void unwire_programming() -void wire_programming() +void wire_programming(void) { schovej_mysku(); after_spell_wire=wire_programming; @@ -2080,7 +2080,7 @@ void wait_to_stop(EVENT_MSG *msg,void **unused) unwire_proc(); calc_mobs(); mouse_set_default(H_MS_DEFAULT); - refresh_scene(); + refresh_scene(0); cancel_render=1; if (prekvapeni) zahajit_kolo(1);else wire_programming(); msg->msg=-2; diff --git a/game/temp_storage.cpp b/game/temp_storage.cpp index c9d5b92..9537687 100644 --- a/game/temp_storage.cpp +++ b/game/temp_storage.cpp @@ -43,8 +43,7 @@ void temp_storage_store(const char *name, const void *data, int32_t size) { v.resize(size+1); v[size] = 0; v.resize(size); - std::copy(b,e, v.begin()); - v[size] = 0; + std::copy(b,e, v.begin()); } int32_t temp_storage_find(const char *name) { diff --git a/game/temp_storage.h b/game/temp_storage.h index f9c2d11..bf0d289 100644 --- a/game/temp_storage.h +++ b/game/temp_storage.h @@ -27,6 +27,10 @@ void temp_storage_write(const void *data, uint32_t size, TMPFILE_WR *f); uint32_t temp_storage_read(void *data, uint32_t size, TMPFILE_RD *f); void temp_storage_skip(TMPFILE_RD *f, int bytes); +#ifdef _MSC_VER +#define __attribute__(__VA_ARG__) +#endif + int *temp_storage_internal_skip_ptr(TMPFILE_RD *f); int temp_storage_internal_begin_scanf(TMPFILE_RD *f, const char *format, ... ) __attribute__((format(scanf, 2, 3))); int temp_storage_internal_end_scanf(TMPFILE_RD *f, int r); diff --git a/game/wizard.c b/game/wizard.c index 185549e..d894151 100644 --- a/game/wizard.c +++ b/game/wizard.c @@ -217,7 +217,7 @@ static char purge_map() _dos_findclose(&rc);*/ wzprintf("\r\n Zadej jmeno tempu (all - vse):");gets(buffer); if (buffer[0]==0) return 0; - strupr(buffer); + strupper(buffer); concat(c,pathtable[SR_TEMP],buffer); if (strcmp(buffer,ALL) && check_file_exists_ex(c)) { diff --git a/history.txt b/history.txt deleted file mode 100644 index 30d74d2..0000000 --- a/history.txt +++ /dev/null @@ -1 +0,0 @@ -test \ No newline at end of file diff --git a/insteng/SETUP.C b/insteng/SETUP.C index e15408c..3249d9d 100644 --- a/insteng/SETUP.C +++ b/insteng/SETUP.C @@ -956,7 +956,7 @@ static void start_install() char error=0,autostart; get_value(0,60,target_path); if (find_object(waktual,70)!=NULL) autostart=f_get_value(0,70); else autostart=1; - strupr(target_path); + strupper(target_path); if (validate_path(target_path)==0) { msg_box("Incorrect path",'\x1',"The path is incorrect. Don't use long filenames!","OK",NULL); diff --git a/insteng/SETUPLIB.C b/insteng/SETUPLIB.C index e8e56c6..d53d4f6 100644 --- a/insteng/SETUPLIB.C +++ b/insteng/SETUPLIB.C @@ -200,7 +200,7 @@ long check_size(int gr) for(i=0;i +#include class base64_t { diff --git a/libs/basicobj.c b/libs/basicobj.c index 09dcafc..26697b8 100644 --- a/libs/basicobj.c +++ b/libs/basicobj.c @@ -241,16 +241,16 @@ void draw_status_line(char *c) showview(0,y-2,SCR_WIDTH_X-1,ysize+5); } -void *status_mem_info(EVENT_MSG *msg) +void status_mem_info(EVENT_MSG *msg) { - return NULL; + } -void *status_idle(EVENT_MSG *msg) +void status_idle(EVENT_MSG *msg) { - if (msg->msg==E_INIT) return &status_idle; + if (msg->msg==E_INIT) return; send_message(E_STATUS_LINE,msg->msg); - return NULL; + return; } static int enter_event_msg_to(EVENT_MSG *msg, void *ctx) { @@ -299,29 +299,29 @@ void status_line(EVENT_MSG *msg, T_EVENT_ROOT **user_data) { return; } -void *mouse_xy(EVENT_MSG *msg) +void mouse_xy(EVENT_MSG *msg) { char **c = va_arg(msg->data, char **); - if (msg->msg==E_INIT) return &mouse_xy; + if (msg->msg==E_INIT) return; sprintf(*c," X: %d Y: %d",ms_last_event.x,ms_last_event.y); *c=strchr(*c,'\0'); - return NULL; + return ; } -void *show_time(EVENT_MSG *msg) +void show_time(EVENT_MSG *msg) { char **c = va_arg(msg->data, char **); time_t t; struct tm cas; - if (msg->msg==E_INIT) return &show_time; + if (msg->msg==E_INIT) return; t=time(NULL); cas=*localtime(&t); sprintf(*c,"%02d:%02d:%02d ",cas.tm_hour,cas.tm_min,cas.tm_sec); *c=strchr(*c,'\0'); - return NULL; + return ; } //------------------------------------------ @@ -684,7 +684,7 @@ void input_line_init(OBJREC *o,va_list len) void input_line_draw(int x1,int y1, int x2, int y2, OBJREC *o) { - char d[2]=" \0"; + char d[2]=" "; int x; char *c; int len; diff --git a/libs/basicobj.h b/libs/basicobj.h index eeed509..0d5a52e 100644 --- a/libs/basicobj.h +++ b/libs/basicobj.h @@ -13,9 +13,9 @@ void xor_rectangle(int x,int y,int xs,int ys); // status lines void status_line(EVENT_MSG *msg,T_EVENT_ROOT **user_data); -void *status_mem_info(EVENT_MSG *msg); -void *mouse_xy(EVENT_MSG *msg); -void *show_time(EVENT_MSG *msg); +void status_mem_info(EVENT_MSG *msg); +void mouse_xy(EVENT_MSG *msg); +void show_time(EVENT_MSG *msg); // objects //void sample(OBJREC *o); diff --git a/libs/event.c b/libs/event.c index b9760c0..a88c5a2 100644 --- a/libs/event.c +++ b/libs/event.c @@ -293,9 +293,11 @@ void deinstall_event(T_EVENT_ROOT **tree,int32_t ev_num,EV_PROC proc,void *procd if (!p->calls) force_delete_curr(tree,r,p); } +typedef void (*initproc)(); + void tree_basics(T_EVENT_ROOT **ev_tree,EVENT_MSG *msg) { - void (*q)(); + initproc q; if (msg->msg==E_ADD || msg->msg==E_ADDEND) { @@ -308,9 +310,10 @@ void tree_basics(T_EVENT_ROOT **ev_tree,EVENT_MSG *msg) install_event(ev_tree,msg,proc,msg->msg==E_ADDEND); return; } + if (msg->msg==E_INIT) - { - q = va_arg(msg->data, void (*)()); + { + q = va_arg(msg->data, initproc); q(); return; } diff --git a/libs/extract.c b/libs/extract.c index 6f71968..acb2570 100644 --- a/libs/extract.c +++ b/libs/extract.c @@ -16,7 +16,7 @@ main(int argc,char **argv) if (argc==3) help(); init_manager(argv[1],NULL); - z=afile(strupr(argv[2]),read_group(0),&s); + z=afile(strupper(argv[2]),read_group(0),&s); if (z==NULL) { puts("File not found"); diff --git a/libs/gui.c b/libs/gui.c index d84d837..552d88e 100644 --- a/libs/gui.c +++ b/libs/gui.c @@ -26,7 +26,7 @@ word desktop_y_size; char force_redraw_desktop=0; static char change_flag=0,f_cancel_event=0; const word *default_font; -void empty() +void empty(void) { } @@ -339,7 +339,7 @@ void define(int id,int x,int y,int xs,int ys,char align,void (*initproc)(OBJREC o->call_done=empty1; o->autoresizex=0; o->autoresizey=0; - o->on_event=empty; + o->on_event=empty3; o->on_enter=empty; o->on_exit=empty; o->on_change=empty; @@ -767,16 +767,16 @@ void uninstall_gui(void) //send_message(E_GUI,cislo,E_UDALOST,data....) -void on_control_change(void (*proc)()) +void on_control_change(void (*proc)(void)) { o_end->on_change=proc; } -void on_control_enter(void (*proc)()) +void on_control_enter(void (*proc)(void)) { o_end->on_enter=proc; } -void on_control_exit(void (*proc)()) +void on_control_exit(void (*proc)(void)) { o_end->on_exit=proc; } @@ -920,28 +920,29 @@ void close_current() close_window(waktual); } +typedef void (*PROG)(void); + void background_runner(EVENT_MSG *msg,void **prog) { - void (*p)(); + PROG *prog_ptr = (PROG *)(prog); if (msg->msg==E_INIT) { - *prog = va_arg(msg->data, void (*)()); + *prog_ptr = va_arg(msg->data, PROG); return; } if (msg->msg==E_DONE) { - *prog=NULL; + *prog_ptr=NULL; return; - } - p=*prog; - p(); + } + (*prog_ptr)(); msg->msg=-2; } -void run_background(void (*p)()) +void run_background(PROG p) { send_message(E_ADD,E_IDLE,background_runner,p); } diff --git a/libs/memman.c b/libs/memman.c index 5dcd299..4903bbc 100644 --- a/libs/memman.c +++ b/libs/memman.c @@ -10,7 +10,7 @@ #include #include #include -#include + #define DPMI_INT 0x31 #define LOAD_BUFFER 4096 @@ -42,7 +42,7 @@ void standard_mem_error(size_t size) { char buff[256]; SEND_LOG("(ERROR) Memory allocation error detected, %lu bytes missing",size); - sprintf(buff,"Memory allocation error\n Application can't allocate %lu bytes of memory (%xh)\n",size,memman_handle); + sprintf(buff,"Memory allocation error\n Application can't allocate %lu bytes of memory (%xh)\n",(unsigned long)size,memman_handle); display_error(buff); exit(1); } @@ -271,7 +271,7 @@ THANDLE_DATA *zneplatnit_block(int handle) return h; } -static void heap_error() { +static void heap_error(size_t s) { display_error("out of memory"); abort(); } @@ -315,7 +315,7 @@ void *load_swaped_block(THANDLE_DATA *h) } -int find_same(const char *name,void *decomp) +int find_same(const char *name,ABLOCK_DECODEPROC decomp) { THANDLE_DATA *p; int i,j; @@ -332,7 +332,7 @@ int find_same(const char *name,void *decomp) return -1; } -int find_handle(const char *name,void *decomp) +int find_handle(const char *name,ABLOCK_DECODEPROC decomp) { return find_same(name,decomp); } @@ -364,7 +364,7 @@ THANDLE_DATA *def_handle(int handle,const char *filename,ABLOCK_DECODEPROC decom } memcpy(h->src_file,filename,12); h->seekpos=0; - strupr(h->src_file); + strupper(h->src_file); h->loadproc=decompress; if (filename[0]) h->seekpos=get_file_entry(path,h->src_file); @@ -385,7 +385,7 @@ const void *afile(char *filename,int group,int32_t *blocksize) d=alloca(strlen(filename)+1); strcpy(d,filename); - strupr(d); + strupper(d); if (mman_patch && test_file_exist_DOS(group,d)) entr=0; else entr=get_file_entry(group,d); if (entr!=0) @@ -669,7 +669,7 @@ void display_status() if (h->src_file[0]) strncpy(nname,h->src_file,12);else strcpy(nname,""); printf("%04Xh ... %12s %s %s %08lXh %6d %10d %6d \n",i*BK_MINOR_HANDLES+j, nname,names[h->status-1], - copys,(uintptr_t)h->blockdata,h->size,h->counter,h->lockcount); + copys,(unsigned long)h->blockdata,h->size,h->counter,h->lockcount); ln++; total_data+=h->size; if(h->status==BK_PRESENT)total_mem+=h->size; diff --git a/libs/memman.h b/libs/memman.h index b7d159c..e1a0cc9 100644 --- a/libs/memman.h +++ b/libs/memman.h @@ -96,7 +96,7 @@ void close_manager(void); //uzavre manager a uvolni veskerou pam void undef_handle(int handle); //uvolni hadle k dalsimu pouziti THANDLE_DATA *zneplatnit_block(int handle); //zneplatni data bloku THANDLE_DATA *get_handle(int handle); //vraci informace o rukojeti -int find_handle(const char *name,void *decomp); //hleda mezi rukojeti stejnou definici +int find_handle(const char *name,ABLOCK_DECODEPROC decomp); //hleda mezi rukojeti stejnou definici int test_file_exist(int group,char *filename); //testuje zda soubor existuje v ramci mmanageru const void *afile(char *filename,int group,int32_t *blocksize); //nahraje do pameti soubor registrovany v ramci mmanageru void *afile_copy(char *filename,int group,int32_t *blocksize); //nahraje do pameti soubor registrovany v ramci mmanageru diff --git a/libs/mgfplay.c b/libs/mgfplay.c index 81b66ea..0c38e31 100644 --- a/libs/mgfplay.c +++ b/libs/mgfplay.c @@ -335,7 +335,7 @@ static void done_mgif_player() free(f); free(temp); mix_back_sound(3); - change_music("?"); + change_music(NULL); } static void init_load_buffer(int size) diff --git a/libs/music.cpp b/libs/music.cpp index 9443aab..724aa2e 100644 --- a/libs/music.cpp +++ b/libs/music.cpp @@ -1,3 +1,5 @@ +#include + #include "music.h" #include diff --git a/libs/music.h b/libs/music.h index 56f62de..b0ae927 100644 --- a/libs/music.h +++ b/libs/music.h @@ -5,7 +5,9 @@ extern "C" { #endif -typedef struct music_stream_t {} TMUSIC_STREAM; +typedef struct music_stream_t { + char dummy; +} TMUSIC_STREAM; typedef struct music_stream_info_t { int freq; diff --git a/libs/wav_mem.h b/libs/wav_mem.h index 7652734..c4083b1 100644 --- a/libs/wav_mem.h +++ b/libs/wav_mem.h @@ -1,6 +1,9 @@ #ifndef _WAV_H #define _WAV_H + +#include + #define WAV_RIFF "RIFF" #define WAV_WAVE "WAVE" #define WAV_FMT "fmt " diff --git a/mapedit.cpp b/mapedit.cpp deleted file mode 100644 index 890f739..0000000 --- a/mapedit.cpp +++ /dev/null @@ -1,10 +0,0 @@ -// mapedit.cpp : Defines the entry point for the console application. -// - -#include "stdafx.h" - - -int main(int argc, char* argv[]) -{ - return 0; -} diff --git a/mapedit.vcproj b/mapedit.vcproj deleted file mode 100644 index 96b7ed1..0000000 --- a/mapedit.vcproj +++ /dev/null @@ -1,852 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/platform/CMakeLists.txt b/platform/CMakeLists.txt index a6827e4..c87bba7 100644 --- a/platform/CMakeLists.txt +++ b/platform/CMakeLists.txt @@ -19,6 +19,10 @@ target_sources(skeldal_platform PRIVATE if(WIN32) target_sources(skeldal_platform PRIVATE windows/save_folder.cpp + windows/map_file.cpp + ) + target_sources(skeldal PRIVATE + windows/app_start.cpp ) target_compile_definitions(skeldal_platform PRIVATE PLATFORM_WINDOWS) message(STATUS "Building for Windows") @@ -57,4 +61,5 @@ target_link_libraries(skeldal skeldal_platform skeldal_sdl skeldal_libs - ${SDL2_LIBRARIES} pthread) + ${SDL2_LIBRARIES} + ${STANDARD_LIBRARIES}) diff --git a/platform/config.cpp b/platform/config.cpp index d020716..8f76c80 100644 --- a/platform/config.cpp +++ b/platform/config.cpp @@ -121,15 +121,15 @@ double ini_get_value_double(const char *value, int *conv_ok) { int ini_get_value_boolean(const char *value) { int r = -1; if (value != NULL) { - if (stricmp(value, "true") == 0 - || stricmp(value, "1") == 0 - || stricmp(value, "on") == 0 - || stricmp(value, "yes") == 0) { + if (istrcmp(value, "true") == 0 + || istrcmp(value, "1") == 0 + || istrcmp(value, "on") == 0 + || istrcmp(value, "yes") == 0) { r = 1; - } else if (stricmp(value, "false") == 0 - || stricmp(value, "0") == 0 - || stricmp(value, "off") == 0 - || stricmp(value, "no") == 0) { + } else if (istrcmp(value, "false") == 0 + || istrcmp(value, "0") == 0 + || istrcmp(value, "off") == 0 + || istrcmp(value, "no") == 0) { r = 0; } else { r = -1; diff --git a/platform/file_access.cpp b/platform/file_access.cpp index 462d046..266a532 100644 --- a/platform/file_access.cpp +++ b/platform/file_access.cpp @@ -1,5 +1,6 @@ #include "platform.h" - +#include +#include #include #include #include "../libs/logfile.h" @@ -8,11 +9,15 @@ std::filesystem::path break_and_compose_path(const std::string_view &pathname, char sep) { auto p = pathname.rfind(sep); if (p == pathname.npos) { - if (pathname == "." || pathname == "..") return std::filesystem::canonical("."); - else if (pathname.empty()) return std::filesystem::current_path().root_path(); - else if (pathname == std::filesystem::current_path().root_name()) - return pathname; - else return std::filesystem::current_path()/pathname; + if (pathname == "." || pathname == "..") { + return std::filesystem::canonical("."); + } else if (pathname.empty()) { + return std::filesystem::current_path().root_path(); + } else if (pathname == std::filesystem::current_path().root_name()) { + return std::filesystem::current_path().root_path(); + } else { + return std::filesystem::current_path()/pathname; + } } return break_and_compose_path(pathname.substr(0,p), sep) / pathname.substr(p+1); @@ -44,7 +49,11 @@ std::filesystem::path try_to_find_file(const std::filesystem::path &p) { while (iter != end) { const std::filesystem::directory_entry &e = *iter; auto fn = e.path().filename(); - if (stricmp(n.c_str(), fn.c_str()) == 0) { + #ifdef _WIN32 + if (_wcsicmp(n.c_str(), fn.c_str()) == 0) { + #else + if (istrcmp(n.c_str(), fn.c_str()) == 0) { + #endif return e.path(); } ++iter; @@ -65,13 +74,13 @@ char check_file_exists(const char *pathname) { const char *file_icase_find(const char *pathname) { static std::string p; std::filesystem::path path = try_to_find_file(convert_pathname_to_path(pathname)); - p = path; + p = path.string(); return p.c_str(); } FILE *fopen_icase(const char *pathname, const char *mode) { std::filesystem::path path = try_to_find_file(convert_pathname_to_path(pathname)); - return fopen(path.c_str(), mode); + return fopen(path.string().c_str(), mode); } static thread_local std::string build_pathname_buffer; @@ -86,7 +95,7 @@ const char * build_pathname(size_t nparts, const char *part1, ...) { for (size_t i = 1; i < nparts; ++i) { p = p / va_arg(lst, const char *); } - build_pathname_buffer = p; + build_pathname_buffer = p.string(); SEND_LOG("(BUILD_PATHNAME) %s", build_pathname_buffer.c_str()); return build_pathname_buffer.c_str(); } @@ -112,8 +121,13 @@ int list_files(const char *directory, int type, LIST_FILES_CALLBACK cb, void *ct 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(); + std::string tmp; + if (type & file_type_just_name) { + tmp = entry.path().filename().string(); + } else { + tmp = entry.path().string(); + } + name = tmp.c_str(); if (entry.is_regular_file(ec) && (type & file_type_normal)) { r = cb(name, file_type_normal, entry.file_size(ec), ctx); } else if (entry.is_directory(ec)) { diff --git a/platform/istr.c b/platform/istr.c index 042e2c6..65e155c 100644 --- a/platform/istr.c +++ b/platform/istr.c @@ -1,7 +1,7 @@ #include "platform.h" #include -int stricmp(const char *a, const char *b) { +int istrcmp(const char *a, const char *b) { while (*a && *b) { char ca = toupper(*a); char cb = toupper(*b); @@ -15,7 +15,7 @@ int stricmp(const char *a, const char *b) { return 0; } -void strupr(char *c) { +void strupper(char *c) { while (*c) { *c = toupper(*c); ++c; diff --git a/platform/platform.h b/platform/platform.h index 6434934..db75203 100644 --- a/platform/platform.h +++ b/platform/platform.h @@ -7,6 +7,18 @@ #define BGSWITCHBIT 0x8000 +#ifdef _MSC_VER +#pragma warning(disable: 4244) +#pragma warning(disable: 4996) +#pragma warning(disable: 4459) +#pragma warning(disable: 4267) +#pragma warning(disable: 4100) +#pragma warning(disable: 4456) +#define CASE_FALLTHROUGH +#else +#define CASE_FALLTHROUGH [[fallthrough]] +#endif + #define SKELDALINI "skeldal.ini" @@ -72,11 +84,11 @@ char check_file_exists(const char *pathname); FILE *fopen_icase(const char *pathname, const char *mode); const char *file_icase_find(const char *pathname); -int stricmp(const char *a, const char *b); +int istrcmp(const char *a, const char *b); int imatch(const char *haystack, const char *needle); #define MIN(a, b) ((a)<(b)?(a):(b)) #define MAX(a, b) ((a)>(b)?(a):(b)) -void strupr(char *c); +void strupper(char *c); const char * int2ascii(int i, char *c, int radix); int get_timer_value(void); diff --git a/platform/save_folder.h b/platform/save_folder.h index 5cacad7..a7545ca 100644 --- a/platform/save_folder.h +++ b/platform/save_folder.h @@ -4,7 +4,7 @@ extern "C" { #endif -#define SAVEGAME_FOLDERNAME "Skeldal"; +#define SAVEGAME_FOLDERNAME "Skeldal" const char *get_default_savegame_directory(void); diff --git a/platform/sdl/BGraph2.cpp b/platform/sdl/BGraph2.cpp index 542dda5..8656819 100644 --- a/platform/sdl/BGraph2.cpp +++ b/platform/sdl/BGraph2.cpp @@ -21,9 +21,9 @@ char game_display_init(const INI_CONFIG_SECTION *display_section, const char *ti } cfg.fullscreen = ini_get_boolean(display_section, "fullscreen", 1) == 1; const char *comp = ini_get_string(display_section, "composer", "auto"); - if (stricmp(comp, "hardware") == 0 || stricmp(comp, "hw") == 0) { + if (istrcmp(comp, "hardware") == 0 || istrcmp(comp, "hw") == 0) { cfg.composer = SDL_RENDERER_ACCELERATED; - } else if (stricmp(comp, "software") == 0 || stricmp(comp, "sw") == 0) { + } else if (istrcmp(comp, "software") == 0 || istrcmp(comp, "sw") == 0) { cfg.composer = SDL_RENDERER_SOFTWARE; } else { cfg.composer = 0; @@ -33,11 +33,11 @@ char game_display_init(const INI_CONFIG_SECTION *display_section, const char *ti cfg.window_width = ini_get_int(display_section, "window_width", 640); const char *filter = ini_get_string(display_section, "crt_filter", "auto"); - if (stricmp(filter,"none") == 0) cfg.crt_filter = SDLContext::CrtFilterType::none; - else if (stricmp(filter,"scanlines") == 0) cfg.crt_filter = SDLContext::CrtFilterType::scanlines; - else if (stricmp(filter,"scanlines_2") == 0) cfg.crt_filter = SDLContext::CrtFilterType::scanlines_2; - else if (stricmp(filter,"rgbmatrix_2") == 0) cfg.crt_filter = SDLContext::CrtFilterType::rgb_matrix_2; - else if (stricmp(filter,"rgbmatrix_3") == 0) cfg.crt_filter = SDLContext::CrtFilterType::rgb_matrix_3; + if (istrcmp(filter,"none") == 0) cfg.crt_filter = SDLContext::CrtFilterType::none; + else if (istrcmp(filter,"scanlines") == 0) cfg.crt_filter = SDLContext::CrtFilterType::scanlines; + else if (istrcmp(filter,"scanlines_2") == 0) cfg.crt_filter = SDLContext::CrtFilterType::scanlines_2; + else if (istrcmp(filter,"rgbmatrix_2") == 0) cfg.crt_filter = SDLContext::CrtFilterType::rgb_matrix_2; + else if (istrcmp(filter,"rgbmatrix_3") == 0) cfg.crt_filter = SDLContext::CrtFilterType::rgb_matrix_3; else cfg.crt_filter = SDLContext::CrtFilterType::autoselect; diff --git a/platform/sdl/CMakeLists.txt b/platform/sdl/CMakeLists.txt index da07b3a..ed2cb06 100644 --- a/platform/sdl/CMakeLists.txt +++ b/platform/sdl/CMakeLists.txt @@ -1,4 +1,4 @@ -add_subdirectory(tests) +#add_subdirectory(tests) add_library(skeldal_sdl sdl_context.cpp diff --git a/platform/sdl/sdl_context.cpp b/platform/sdl/sdl_context.cpp index 58e178e..67e8191 100644 --- a/platform/sdl/sdl_context.cpp +++ b/platform/sdl/sdl_context.cpp @@ -184,7 +184,7 @@ void SDLContext::init_video(const VideoConfig &config, const char *title) { SDL_RendererInfo rinfo; SDL_GetRendererInfo(renderer, &rinfo); - if (stricmp(config.scale_quality, "auto") == 0) { + if (istrcmp(config.scale_quality, "auto") == 0) { if (rinfo.flags & SDL_RENDERER_ACCELERATED) { SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "best"); } diff --git a/platform/sdl/sdl_context.h b/platform/sdl/sdl_context.h index 16980a2..396d670 100644 --- a/platform/sdl/sdl_context.h +++ b/platform/sdl/sdl_context.h @@ -2,8 +2,9 @@ #include #include -#include +#include #include +#include #include #include #include diff --git a/platform/sdl/sound.cpp b/platform/sdl/sound.cpp index 97f1300..6b1df9c 100644 --- a/platform/sdl/sound.cpp +++ b/platform/sdl/sound.cpp @@ -7,7 +7,7 @@ #include #include - +#include #include #define countof(array) (sizeof(array)/sizeof(array[0])) @@ -96,7 +96,7 @@ void set_channel_volume(int channel,int left,int right) { vp.left = l; vp.right = r; sound_mixer.visit_track(channel, [&](WaveMixer<2> &mx){ - mx.set_channel_volumes_fade(make_channel_volume(vp.left, vp.right), {2e-4,2e-4}); + mx.set_channel_volumes_fade(make_channel_volume(vp.left, vp.right), {2e-4f,2e-4f}); }); } diff --git a/platform/windows/app_start.cpp b/platform/windows/app_start.cpp new file mode 100644 index 0000000..531819a --- /dev/null +++ b/platform/windows/app_start.cpp @@ -0,0 +1,73 @@ +#include "../../game/skeldal.h" +#include "../getopt.h" +#include "../platform.h" +#include +#include + +void show_help(const char *arg0) { + printf( + "Brany Skeldalu (Gates of Skeldal) portable game player\n" + "Copyright (c) 2025 Ondrej Novak. All rights reserved.\n\n" + "This work is licensed under the terms of the MIT license.\n" + "For a copy, see .\n" + "\n" + "Usage:" + ); + printf("%s [-f ] [-a ] [-l ] [-s ] [-h]\n\n", arg0); + + printf("-f path to configuration file\n" + "-a path for adventure file (.adv)\n" + "-l set language (cz|en)" + "-s generate string-tables (for localization) and exit\n" + "-h this help\n"); + exit(0); +} + +void show_help_short() { + printf("Use -h for help\n"); +} + + +int main(int argc, char **argv) { + std::string config_name = SKELDALINI; + std::string adv_config_file; + std::string gen_stringtable_path; + std::string lang; + for (int optchr = -1; (optchr = getopt(argc, argv, "hf:a:s:l:")) != -1; ) { + switch (optchr) { + case 'f': config_name = optarg;break; + case 'a': adv_config_file = optarg;break; + case 'h': show_help(argv[0]);break; + case 'l': lang = optarg;break; + case 's': gen_stringtable_path = optarg;break; + default: show_help_short(); + return 1; + } + } + + SKELDAL_CONFIG cfg; + cfg.short_help = show_help_short; + cfg.show_error = [](const char *txt) { + std::cerr << "ERROR: " << txt << std::endl; + }; + cfg.adventure_path = adv_config_file.empty()?NULL:adv_config_file.c_str(); + cfg.config_path = config_name.c_str(); + cfg.lang_path = lang.empty()?NULL:lang.c_str(); + try { + + if (!gen_stringtable_path.empty()) { + skeldal_gen_string_table_entry_point(&cfg, gen_stringtable_path.c_str()); + return 0; + } else { + return skeldal_entry_point(&cfg); + } + + } catch (const std::exception &e) { + std::cerr << "ERROR: " << e.what() << std::endl; + return 1; + } + + return 0; + +} + diff --git a/platform/windows/map_file.cpp b/platform/windows/map_file.cpp new file mode 100644 index 0000000..a2e8e03 --- /dev/null +++ b/platform/windows/map_file.cpp @@ -0,0 +1,55 @@ + +extern "C" { +#include "map_file.h" +} + +#define WIN32_LEAN_AND_MEAN +#include +#include +#include +#include +#include +#include + +// Funkce pro mapování souboru do paměti +void* map_file_to_memory_cpp(const char *name, size_t *sz) { + if (!name || !sz) { + return NULL; + } + + HANDLE h = CreateFileA(name, GENERIC_READ, FILE_SHARE_READ,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL); + if (h == INVALID_HANDLE_VALUE) throw std::runtime_error(std::string("Failed to open file for mapping: ").append(name)); + + LARGE_INTEGER fsize; + if (!GetFileSizeEx(h, &fsize)) { + CloseHandle(h); + throw std::runtime_error(std::string("failed to get size of file:").append(name)); + } + + + + HANDLE hMapping = CreateFileMapping(h,NULL,PAGE_READONLY,0,0,NULL); + if (hMapping == NULL || hMapping == INVALID_HANDLE_VALUE) { + CloseHandle(h); + throw std::runtime_error(std::string("Failed to create mapping of file:").append(name)); + } + + void *mappedData = MapViewOfFile(hMapping,FILE_MAP_READ,0,0,0); + CloseHandle(h); + CloseHandle(hMapping); + if (mappedData == NULL) { + throw std::runtime_error(std::string("Failed to map file:").append(name)); + } + + *sz = fsize.LowPart; + return mappedData; +} + +void* map_file_to_memory(const char *name, size_t *sz) { + return map_file_to_memory_cpp(name, sz); +} + +// Funkce pro zrušení mapování +void unmap_file(void *ptr, size_t) { + UnmapViewOfFile(ptr); +} diff --git a/platform/windows/map_file.h b/platform/windows/map_file.h new file mode 100644 index 0000000..e4495ed --- /dev/null +++ b/platform/windows/map_file.h @@ -0,0 +1,4 @@ +#include +#include +void *map_file_to_memory(const char *name, size_t *sz); +void unmap_file(void *ptr, size_t sz); diff --git a/platform/windows/save_folder.cpp b/platform/windows/save_folder.cpp index 851b9f1..c0b53c9 100644 --- a/platform/windows/save_folder.cpp +++ b/platform/windows/save_folder.cpp @@ -1,23 +1,22 @@ +#include "../platform.h" #include "../save_folder.h" #include "../error.h" #include #include #include +#include #pragma comment(lib, "shell32.lib") #pragma comment(lib, "ole32.lib") -// Pro získání uživatelské složky namespace fs = std::filesystem; -// Funkce pro získání složky "Saved Games" std::string getSavedGamesDirectory() { PWSTR path = nullptr; - // Použití identifikátoru složky FOLDERID_SavedGames - if (SUCCEEDED(SHGetKnownFolderPathA(FOLDERID_SavedGames, 0, NULL, &path))) { + if (SUCCEEDED(SHGetKnownFolderPath(FOLDERID_SavedGames, 0, NULL, &path))) { fs::path savedGamesPath(path); - CoTaskMemFree(path); // Uvolnění paměti - return savedGamesPath / SAVEGAME_FOLDERNAME + CoTaskMemFree(path); + return (savedGamesPath / SAVEGAME_FOLDERNAME).string(); } else { display_error("Failed to retrieve FOLDEROD_SavedGames"); abort(); @@ -25,7 +24,7 @@ std::string getSavedGamesDirectory() { } const char *get_default_savegame_directory() { - static std::string dir = get_default_savgetSavedGamesDirectoryegame_dir(); + static std::string dir = getSavedGamesDirectory(); return dir.c_str(); }