From 5ddcd71116dff918005211adda6a987c42851c2c Mon Sep 17 00:00:00 2001 From: g-cont Date: Fri, 14 Sep 2007 00:00:00 +0400 Subject: [PATCH] 14 Sep 2007 --- changelog.log | 12 +- {platform => common}/basemem.c | 0 {platform => common}/basemem.h | 0 {platform => common}/baseutils.c | 12 - {platform => common}/baseutils.h | 4 +- {platform => common}/blankframe.h | 0 {platform => common}/bsplib/brushbsp.c | 0 {platform => common}/bsplib/bspfile.c | 0 {platform => common}/bsplib/bsplib.h | 0 {platform => common}/bsplib/csg.c | 0 {platform => common}/bsplib/faces.c | 0 {platform => common}/bsplib/flow.c | 0 {platform => common}/bsplib/leakfile.c | 0 {platform => common}/bsplib/lightmap.c | 0 {platform => common}/bsplib/map.c | 0 {platform => common}/bsplib/patches.c | 0 {platform => common}/bsplib/portals.c | 0 {platform => common}/bsplib/prtfile.c | 0 {platform => common}/bsplib/qbsp3.c | 0 {platform => common}/bsplib/qrad3.c | 0 {platform => common}/bsplib/qvis3.c | 0 {platform => common}/bsplib/shaders.c | 0 {platform => common}/bsplib/textures.c | 0 {platform => common}/bsplib/trace.c | 0 {platform => common}/bsplib/tree.c | 0 {platform => common}/bsplib/winding.c | 0 {platform => common}/bsplib/writebsp.c | 0 platform/platform.dsp => common/common.dsp | 58 +- {platform/mdllib => common/common}/mdllib.h | 0 {platform/mdllib => common/common}/studio.c | 0 .../mdllib => common/common}/studio_utils.c | 0 {platform => common}/filesystem.c | 0 {platform => common}/image.h | 0 {platform => common}/imglib.c | 0 {platform => common}/platform.c | 39 +- {platform => common}/platform.h | 0 {platform => common}/qcclib/pr_comp.c | 0 {platform => common}/qcclib/pr_lex.c | 0 {platform => common}/qcclib/qcc_utils.c | 47 +- {platform => common}/qcclib/qcclib.h | 0 {platform => common}/qcclib/qccmain.c | 33 +- {platform => common}/spritegen.c | 0 {platform => common}/zip32.h | 215 +- common/ziplib.c | 2967 +++++++++++++++++ debug.bat | 12 +- editor/editor.c | 4 +- editor/editor.dsp | 20 +- editor/editor.h | 6 +- editor/guiforms.c | 82 +- engine/client/cl_ents.c | 2 +- engine/client/cl_main.c | 2 +- engine/client/cl_view.c | 2 +- engine/client/client.h | 2 +- engine/common.h | 3 - engine/common/cmodel.c | 4 +- engine/common/common.c | 61 +- engine/common/menu.c | 13 +- engine/common/qmenu.c | 4 +- engine/common/vid.h | 4 +- engine/engine.dsp | 4 +- engine/engine.h | 68 +- engine/engine.plg | 78 - engine/host.c | 59 +- engine/server/sv_save.c | 12 +- engine/snd_win.c | 7 +- engine/system.c | 4 +- engine/vid_dll.c | 46 +- launcher/bsplib/makefile.nmake | 5 +- launcher/console.c | 33 +- launcher/credits/makefile.nmake | 5 +- launcher/dedicated/makefile.nmake | 5 +- launcher/editor/makefile.nmake | 5 +- launcher/getlib.h | 67 +- launcher/launcher.c | 100 +- launcher/launcher.dsp | 12 +- launcher/launcher.h | 19 +- launcher/qcclib/makefile.nmake | 5 +- launcher/sprite/makefile.nmake | 5 +- launcher/stdlib.c | 75 + launcher/studio/makefile.nmake | 5 +- launcher/utils.c | 22 +- launcher/xash/makefile.nmake | 5 +- launchers.bat | 34 + platform/ziplib.c | 1308 -------- progs/qcclib.exe | Bin 39424 -> 0 bytes progs/server.dat | Bin 62888 -> 0 bytes public/basemath.h | 1 - public/basetypes.h | 2 + public/ref_system.h | 62 +- public/version.h | 4 +- release.bat | 12 +- {renderer => render}/anormtab.h | 0 {renderer => render}/gl_draw.c | 0 {renderer => render}/gl_light.c | 0 {renderer => render}/gl_local.h | 2 +- {renderer => render}/gl_mesh.c | 0 {renderer => render}/gl_model.c | 0 {renderer => render}/gl_model.h | 0 {renderer => render}/gl_rmain.c | 12 +- {renderer => render}/gl_rmisc.c | 0 {renderer => render}/gl_rsurf.c | 0 {renderer => render}/gl_warp.c | 0 {renderer => render}/gl_widnt.c | 0 {renderer => render}/glw_imp.c | 0 {renderer => render}/lhfont.h | 0 {renderer => render}/palette.h | 0 {renderer => render}/r_backend.c | 0 {renderer => render}/r_bloom.c | 0 {renderer => render}/r_bspmod.c | 0 {renderer => render}/r_opengl.h | 0 {renderer => render}/r_sprite.c | 0 {renderer => render}/r_studio.c | 16 +- {renderer => render}/r_texture.c | 4 +- {renderer => render}/r_utils.c | 0 renderer/renderer.dsp => render/render.dsp | 62 +- {renderer => render}/warpsin.h | 0 upx_pack.bat | 7 + {progs => vprogs}/PROGS.SRC | 0 {progs => vprogs}/client.c | 0 {progs => vprogs}/damage.c | 0 {progs => vprogs}/defs.c | 0 {progs => vprogs}/dummys.c | 0 {progs => vprogs}/ents/ambient.c | 0 {progs => vprogs}/ents/ccam.c | 0 {progs => vprogs}/ents/funcs/func_button.c | 0 {progs => vprogs}/ents/funcs/func_door.c | 0 {progs => vprogs}/ents/funcs/func_mover.c | 0 .../ents/funcs/func_path_corner.c | 0 {progs => vprogs}/ents/funcs/func_train.c | 0 {progs => vprogs}/ents/funcs/funcs.c | 0 {progs => vprogs}/ents/internal.c | 0 {progs => vprogs}/ents/items/items.c | 0 {progs => vprogs}/ents/lights.c | 0 .../ents/triggers/trigger_changelevel.c | 0 .../ents/triggers/trigger_counter.c | 0 .../ents/triggers/trigger_generic.c | 0 .../ents/triggers/trigger_hurt.c | 0 .../ents/triggers/trigger_message.c | 0 .../ents/triggers/trigger_once.c | 0 .../ents/triggers/trigger_push.c | 0 .../ents/triggers/trigger_secret.c | 0 .../ents/triggers/trigger_sequence.c | 0 .../ents/triggers/trigger_setskill.c | 0 .../ents/triggers/trigger_setviewpoint.c | 0 .../ents/triggers/trigger_teleport.c | 0 {progs => vprogs}/ents/triggers/triggers.c | 0 {progs => vprogs}/impulses.c | 0 {progs => vprogs}/main.c | 0 {progs => vprogs}/player.c | 0 {progs => vprogs}/progdefs.h | 0 vprogs/qcclib.exe | Bin 0 -> 6144 bytes xash.dsw | 4 +- 152 files changed, 3834 insertions(+), 1950 deletions(-) rename {platform => common}/basemem.c (100%) rename {platform => common}/basemem.h (100%) rename {platform => common}/baseutils.c (94%) rename {platform => common}/baseutils.h (95%) rename {platform => common}/blankframe.h (100%) rename {platform => common}/bsplib/brushbsp.c (100%) rename {platform => common}/bsplib/bspfile.c (100%) rename {platform => common}/bsplib/bsplib.h (100%) rename {platform => common}/bsplib/csg.c (100%) rename {platform => common}/bsplib/faces.c (100%) rename {platform => common}/bsplib/flow.c (100%) rename {platform => common}/bsplib/leakfile.c (100%) rename {platform => common}/bsplib/lightmap.c (100%) rename {platform => common}/bsplib/map.c (100%) rename {platform => common}/bsplib/patches.c (100%) rename {platform => common}/bsplib/portals.c (100%) rename {platform => common}/bsplib/prtfile.c (100%) rename {platform => common}/bsplib/qbsp3.c (100%) rename {platform => common}/bsplib/qrad3.c (100%) rename {platform => common}/bsplib/qvis3.c (100%) rename {platform => common}/bsplib/shaders.c (100%) rename {platform => common}/bsplib/textures.c (100%) rename {platform => common}/bsplib/trace.c (100%) rename {platform => common}/bsplib/tree.c (100%) rename {platform => common}/bsplib/winding.c (100%) rename {platform => common}/bsplib/writebsp.c (100%) rename platform/platform.dsp => common/common.dsp (72%) rename {platform/mdllib => common/common}/mdllib.h (100%) rename {platform/mdllib => common/common}/studio.c (100%) rename {platform/mdllib => common/common}/studio_utils.c (100%) rename {platform => common}/filesystem.c (100%) rename {platform => common}/image.h (100%) rename {platform => common}/imglib.c (100%) rename {platform => common}/platform.c (55%) rename {platform => common}/platform.h (100%) rename {platform => common}/qcclib/pr_comp.c (100%) rename {platform => common}/qcclib/pr_lex.c (100%) rename {platform => common}/qcclib/qcc_utils.c (78%) rename {platform => common}/qcclib/qcclib.h (100%) rename {platform => common}/qcclib/qccmain.c (95%) rename {platform => common}/spritegen.c (100%) rename {platform => common}/zip32.h (53%) create mode 100644 common/ziplib.c delete mode 100644 engine/engine.plg create mode 100644 launcher/stdlib.c create mode 100644 launchers.bat delete mode 100644 platform/ziplib.c delete mode 100644 progs/qcclib.exe delete mode 100644 progs/server.dat rename {renderer => render}/anormtab.h (100%) rename {renderer => render}/gl_draw.c (100%) rename {renderer => render}/gl_light.c (100%) rename {renderer => render}/gl_local.h (96%) rename {renderer => render}/gl_mesh.c (100%) rename {renderer => render}/gl_model.c (100%) rename {renderer => render}/gl_model.h (100%) rename {renderer => render}/gl_rmain.c (95%) rename {renderer => render}/gl_rmisc.c (100%) rename {renderer => render}/gl_rsurf.c (100%) rename {renderer => render}/gl_warp.c (100%) rename {renderer => render}/gl_widnt.c (100%) rename {renderer => render}/glw_imp.c (100%) rename {renderer => render}/lhfont.h (100%) rename {renderer => render}/palette.h (100%) rename {renderer => render}/r_backend.c (100%) rename {renderer => render}/r_bloom.c (100%) rename {renderer => render}/r_bspmod.c (100%) rename {renderer => render}/r_opengl.h (100%) rename {renderer => render}/r_sprite.c (100%) rename {renderer => render}/r_studio.c (95%) rename {renderer => render}/r_texture.c (96%) rename {renderer => render}/r_utils.c (100%) rename renderer/renderer.dsp => render/render.dsp (67%) rename {renderer => render}/warpsin.h (100%) create mode 100644 upx_pack.bat rename {progs => vprogs}/PROGS.SRC (100%) rename {progs => vprogs}/client.c (100%) rename {progs => vprogs}/damage.c (100%) rename {progs => vprogs}/defs.c (100%) rename {progs => vprogs}/dummys.c (100%) rename {progs => vprogs}/ents/ambient.c (100%) rename {progs => vprogs}/ents/ccam.c (100%) rename {progs => vprogs}/ents/funcs/func_button.c (100%) rename {progs => vprogs}/ents/funcs/func_door.c (100%) rename {progs => vprogs}/ents/funcs/func_mover.c (100%) rename {progs => vprogs}/ents/funcs/func_path_corner.c (100%) rename {progs => vprogs}/ents/funcs/func_train.c (100%) rename {progs => vprogs}/ents/funcs/funcs.c (100%) rename {progs => vprogs}/ents/internal.c (100%) rename {progs => vprogs}/ents/items/items.c (100%) rename {progs => vprogs}/ents/lights.c (100%) rename {progs => vprogs}/ents/triggers/trigger_changelevel.c (100%) rename {progs => vprogs}/ents/triggers/trigger_counter.c (100%) rename {progs => vprogs}/ents/triggers/trigger_generic.c (100%) rename {progs => vprogs}/ents/triggers/trigger_hurt.c (100%) rename {progs => vprogs}/ents/triggers/trigger_message.c (100%) rename {progs => vprogs}/ents/triggers/trigger_once.c (100%) rename {progs => vprogs}/ents/triggers/trigger_push.c (100%) rename {progs => vprogs}/ents/triggers/trigger_secret.c (100%) rename {progs => vprogs}/ents/triggers/trigger_sequence.c (100%) rename {progs => vprogs}/ents/triggers/trigger_setskill.c (100%) rename {progs => vprogs}/ents/triggers/trigger_setviewpoint.c (100%) rename {progs => vprogs}/ents/triggers/trigger_teleport.c (100%) rename {progs => vprogs}/ents/triggers/triggers.c (100%) rename {progs => vprogs}/impulses.c (100%) rename {progs => vprogs}/main.c (100%) rename {progs => vprogs}/player.c (100%) rename {progs => vprogs}/progdefs.h (100%) create mode 100644 vprogs/qcclib.exe diff --git a/changelog.log b/changelog.log index 9e894ea4..5d41128f 100644 --- a/changelog.log +++ b/changelog.log @@ -1,4 +1,5 @@ Разработать концепцию языка VirtualC\VirtualC++ (базируется на QuakeC) +Придумать новые имена (6 символов) для launcher.dll Quake1 Quake2 SV_MoveBounds SV_TraceBounds @@ -14,12 +15,21 @@ SV_ClipToLinks SV_ClipMoveToEntities 6. Перевести сервер на float OK 7. Имплементация загрузки дллок (в лаунчер) OK 8. Перенести в лаунчер большинство Sys_ вызовов OK -9. Присоеденить msvcrt.dll ко всем проектам +9. Присоеденить msvcrt.dll ко всем проектам OK +10. Имплементировать GetProcAddress в stdinout_t OK +11. Имплементация второй части zlib в platform.dll OK +12. Подключить advapi динамически OK +13. Переименовать platform.dll в common.dll OK +14. Переименовать renderer.dll в render.dll OK +15. Упорядочить файлы и код в common.dll + //================================================== // то, что уже готово //================================================== ++исправлен баг с флагом RF_FULLBRIGHT для studio models в режиме RDF_NOWORLDMODEL ++существенно уменьшен размер всех лаунчеров +новая система загрузки дллок (поддержка нативных библиотек) +добавлены кастомные названия окна для различных инстанций (studiomdl, bsplib итд) +исправлен баг с кодом возвращаемой ошибки diff --git a/platform/basemem.c b/common/basemem.c similarity index 100% rename from platform/basemem.c rename to common/basemem.c diff --git a/platform/basemem.h b/common/basemem.h similarity index 100% rename from platform/basemem.h rename to common/basemem.h diff --git a/platform/baseutils.c b/common/baseutils.c similarity index 94% rename from platform/baseutils.c rename to common/baseutils.c index 124710c0..8fb740be 100644 --- a/platform/baseutils.c +++ b/common/baseutils.c @@ -28,18 +28,6 @@ void Plat_LinkDlls( void ) //Sys_LoadLibrary( &winmm_dll ); } -char *strupr (char *start) -{ - char *in; - in = start; - while (*in) - { - *in = toupper(*in); - in++; - } - return start; -} - char *strlower (char *start) { char *in; diff --git a/platform/baseutils.h b/common/baseutils.h similarity index 95% rename from platform/baseutils.h rename to common/baseutils.h index 7e84da49..2ddb5e88 100644 --- a/platform/baseutils.h +++ b/common/baseutils.h @@ -91,7 +91,7 @@ void FS_Shutdown (void); #define Mem_Move(dest, src, size ) _Mem_Move (dest, src, size, __FILE__, __LINE__) #define Mem_Copy(dest, src, size ) _Mem_Copy (dest, src, size, __FILE__, __LINE__) -stdinout_api_t std; +extern stdlib_api_t std; extern gameinfo_t GI; #define Msg std.printf @@ -123,9 +123,7 @@ extern byte *studiopool; //misc common functions char *copystring(char *s); -char *strupr (char *start); char *strlower (char *start); -char* FlipSlashes(char* string); char *va(const char *format, ...); char *stristr( const char *string, const char *string2 ); void ExtractFilePath(const char* const path, char* dest); diff --git a/platform/blankframe.h b/common/blankframe.h similarity index 100% rename from platform/blankframe.h rename to common/blankframe.h diff --git a/platform/bsplib/brushbsp.c b/common/bsplib/brushbsp.c similarity index 100% rename from platform/bsplib/brushbsp.c rename to common/bsplib/brushbsp.c diff --git a/platform/bsplib/bspfile.c b/common/bsplib/bspfile.c similarity index 100% rename from platform/bsplib/bspfile.c rename to common/bsplib/bspfile.c diff --git a/platform/bsplib/bsplib.h b/common/bsplib/bsplib.h similarity index 100% rename from platform/bsplib/bsplib.h rename to common/bsplib/bsplib.h diff --git a/platform/bsplib/csg.c b/common/bsplib/csg.c similarity index 100% rename from platform/bsplib/csg.c rename to common/bsplib/csg.c diff --git a/platform/bsplib/faces.c b/common/bsplib/faces.c similarity index 100% rename from platform/bsplib/faces.c rename to common/bsplib/faces.c diff --git a/platform/bsplib/flow.c b/common/bsplib/flow.c similarity index 100% rename from platform/bsplib/flow.c rename to common/bsplib/flow.c diff --git a/platform/bsplib/leakfile.c b/common/bsplib/leakfile.c similarity index 100% rename from platform/bsplib/leakfile.c rename to common/bsplib/leakfile.c diff --git a/platform/bsplib/lightmap.c b/common/bsplib/lightmap.c similarity index 100% rename from platform/bsplib/lightmap.c rename to common/bsplib/lightmap.c diff --git a/platform/bsplib/map.c b/common/bsplib/map.c similarity index 100% rename from platform/bsplib/map.c rename to common/bsplib/map.c diff --git a/platform/bsplib/patches.c b/common/bsplib/patches.c similarity index 100% rename from platform/bsplib/patches.c rename to common/bsplib/patches.c diff --git a/platform/bsplib/portals.c b/common/bsplib/portals.c similarity index 100% rename from platform/bsplib/portals.c rename to common/bsplib/portals.c diff --git a/platform/bsplib/prtfile.c b/common/bsplib/prtfile.c similarity index 100% rename from platform/bsplib/prtfile.c rename to common/bsplib/prtfile.c diff --git a/platform/bsplib/qbsp3.c b/common/bsplib/qbsp3.c similarity index 100% rename from platform/bsplib/qbsp3.c rename to common/bsplib/qbsp3.c diff --git a/platform/bsplib/qrad3.c b/common/bsplib/qrad3.c similarity index 100% rename from platform/bsplib/qrad3.c rename to common/bsplib/qrad3.c diff --git a/platform/bsplib/qvis3.c b/common/bsplib/qvis3.c similarity index 100% rename from platform/bsplib/qvis3.c rename to common/bsplib/qvis3.c diff --git a/platform/bsplib/shaders.c b/common/bsplib/shaders.c similarity index 100% rename from platform/bsplib/shaders.c rename to common/bsplib/shaders.c diff --git a/platform/bsplib/textures.c b/common/bsplib/textures.c similarity index 100% rename from platform/bsplib/textures.c rename to common/bsplib/textures.c diff --git a/platform/bsplib/trace.c b/common/bsplib/trace.c similarity index 100% rename from platform/bsplib/trace.c rename to common/bsplib/trace.c diff --git a/platform/bsplib/tree.c b/common/bsplib/tree.c similarity index 100% rename from platform/bsplib/tree.c rename to common/bsplib/tree.c diff --git a/platform/bsplib/winding.c b/common/bsplib/winding.c similarity index 100% rename from platform/bsplib/winding.c rename to common/bsplib/winding.c diff --git a/platform/bsplib/writebsp.c b/common/bsplib/writebsp.c similarity index 100% rename from platform/bsplib/writebsp.c rename to common/bsplib/writebsp.c diff --git a/platform/platform.dsp b/common/common.dsp similarity index 72% rename from platform/platform.dsp rename to common/common.dsp index 86b277a8..36a2f45a 100644 --- a/platform/platform.dsp +++ b/common/common.dsp @@ -1,24 +1,24 @@ -# Microsoft Developer Studio Project File - Name="platform" - Package Owner=<4> +# Microsoft Developer Studio Project File - Name="common" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 -CFG=platform - Win32 Debug +CFG=common - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE -!MESSAGE NMAKE /f "platform.mak". +!MESSAGE NMAKE /f "common.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE -!MESSAGE NMAKE /f "platform.mak" CFG="platform - Win32 Debug" +!MESSAGE NMAKE /f "common.mak" CFG="common - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE -!MESSAGE "platform - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE "platform - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE "common - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE "common - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE # Begin Project @@ -29,7 +29,7 @@ CPP=cl.exe MTL=midl.exe RSC=rc.exe -!IF "$(CFG)" == "platform - Win32 Release" +!IF "$(CFG)" == "common - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 @@ -38,12 +38,12 @@ RSC=rc.exe # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 -# PROP Output_Dir "..\temp\platform\!release" -# PROP Intermediate_Dir "..\temp\platform\!release" +# PROP Output_Dir "..\temp\common\!release" +# PROP Intermediate_Dir "..\temp\common\!release" # PROP Ignore_Export_Lib 1 # PROP Target_Dir "" # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "PLATFORM_EXPORTS" /YX /FD /c -# ADD CPP /nologo /W3 /GX /O2 /Ob0 /I "./" /I "../public" /I "./bsplib/" /I "./qcclib" /I "./mdllib" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /FD /c +# ADD CPP /nologo /MD /W3 /GX /O2 /Ob0 /I "./" /I "../public" /I "./bsplib/" /I "./qcclib" /I "./mdllib" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /FD /c # SUBTRACT CPP /YX # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 @@ -54,18 +54,18 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 /opt:nowin98 -# ADD LINK32 kernel32.lib winmm.lib /nologo /dll /pdb:none /machine:I386 /opt:nowin98 +# ADD LINK32 msvcrt.lib winmm.lib /nologo /dll /pdb:none /machine:I386 /nodefaultlib:"libc.lib" /opt:nowin98 # Begin Custom Build -TargetDir=\XASH3D\src_main\!source\temp\platform\!release -InputPath=\XASH3D\src_main\!source\temp\platform\!release\platform.dll +TargetDir=\XASH3D\src_main\!source\temp\common\!release +InputPath=\XASH3D\src_main\!source\temp\common\!release\common.dll SOURCE="$(InputPath)" -"D:\Xash3D\bin\platform.dll" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" - copy $(TargetDir)\platform.dll "D:\Xash3D\bin\platform.dll" +"D:\Xash3D\bin\common.dll" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" + copy $(TargetDir)\common.dll "D:\Xash3D\bin\common.dll" # End Custom Build -!ELSEIF "$(CFG)" == "platform - Win32 Debug" +!ELSEIF "$(CFG)" == "common - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 @@ -74,12 +74,12 @@ SOURCE="$(InputPath)" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 -# PROP Output_Dir "..\temp\platform\!debug" -# PROP Intermediate_Dir "..\temp\platform\!debug" +# PROP Output_Dir "..\temp\common\!debug" +# PROP Intermediate_Dir "..\temp\common\!debug" # PROP Ignore_Export_Lib 1 # PROP Target_Dir "" # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "PLATFORM_EXPORTS" /YX /FD /GZ /c -# ADD CPP /nologo /MTd /W3 /Gm /Gi /GX /ZI /Od /I "./" /I "../public" /I "./bsplib/" /I "./qcclib" /I "./mdllib" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /FR /FD /GZ /c +# ADD CPP /nologo /MDd /W3 /Gm /Gi /GX /ZI /Od /I "./" /I "../public" /I "./bsplib/" /I "./qcclib" /I "./common" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /FR /FD /GZ /c # SUBTRACT CPP /YX # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 @@ -90,15 +90,15 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept -# ADD LINK32 kernel32.lib winmm.lib /nologo /dll /debug /machine:I386 /nodefaultlib:"libc.lib" /pdbtype:sept +# ADD LINK32 msvcrt.lib winmm.lib /nologo /dll /debug /machine:I386 /nodefaultlib:"msvcrtd.lib" /pdbtype:sept # SUBTRACT LINK32 /incremental:no /nodefaultlib # Begin Custom Build -TargetDir=\XASH3D\src_main\!source\temp\platform\!debug -InputPath=\XASH3D\src_main\!source\temp\platform\!debug\platform.dll +TargetDir=\XASH3D\src_main\!source\temp\common\!debug +InputPath=\XASH3D\src_main\!source\temp\common\!debug\common.dll SOURCE="$(InputPath)" -"D:\Xash3D\bin\platform.dll" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" - copy $(TargetDir)\platform.dll "D:\Xash3D\bin\platform.dll" +"D:\Xash3D\bin\common.dll" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" + copy $(TargetDir)\common.dll "D:\Xash3D\bin\common.dll" # End Custom Build @@ -106,8 +106,8 @@ SOURCE="$(InputPath)" # Begin Target -# Name "platform - Win32 Release" -# Name "platform - Win32 Debug" +# Name "common - Win32 Release" +# Name "common - Win32 Debug" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" @@ -213,11 +213,11 @@ SOURCE=.\spritegen.c # End Source File # Begin Source File -SOURCE=.\mdllib\studio.c +SOURCE=.\common\studio.c # End Source File # Begin Source File -SOURCE=.\mdllib\studio_utils.c +SOURCE=.\common\studio_utils.c # End Source File # Begin Source File @@ -269,7 +269,7 @@ SOURCE=.\image.h # End Source File # Begin Source File -SOURCE=.\mdllib\mdllib.h +SOURCE=.\common\mdllib.h # End Source File # Begin Source File diff --git a/platform/mdllib/mdllib.h b/common/common/mdllib.h similarity index 100% rename from platform/mdllib/mdllib.h rename to common/common/mdllib.h diff --git a/platform/mdllib/studio.c b/common/common/studio.c similarity index 100% rename from platform/mdllib/studio.c rename to common/common/studio.c diff --git a/platform/mdllib/studio_utils.c b/common/common/studio_utils.c similarity index 100% rename from platform/mdllib/studio_utils.c rename to common/common/studio_utils.c diff --git a/platform/filesystem.c b/common/filesystem.c similarity index 100% rename from platform/filesystem.c rename to common/filesystem.c diff --git a/platform/image.h b/common/image.h similarity index 100% rename from platform/image.h rename to common/image.h diff --git a/platform/imglib.c b/common/imglib.c similarity index 100% rename from platform/imglib.c rename to common/imglib.c diff --git a/platform/platform.c b/common/platform.c similarity index 55% rename from platform/platform.c rename to common/platform.c index f9f6bee6..c0794f89 100644 --- a/platform/platform.c +++ b/common/platform.c @@ -10,6 +10,7 @@ #include "qcclib.h" bool host_debug = false; +stdlib_api_t std; gameinfo_t Plat_GameInfo( void ) { @@ -18,7 +19,7 @@ gameinfo_t Plat_GameInfo( void ) bool InitPlatform ( int argc, char **argv ) { - MsgDev(D_INFO, "------- Loading bin/platform.dll [%g] -------\n", PLATFORM_VERSION ); + MsgDev(D_INFO, "------- Loading bin/common.dll [%g] -------\n", COMMON_VERSION ); InitMemory(); Plat_InitCPU(); @@ -39,9 +40,9 @@ void ClosePlatform ( void ) FreeMemory(); } -platform_exp_t DLLEXPORT *CreateAPI ( stdinout_api_t *input ) +common_exp_t DLLEXPORT *CreateAPI ( stdlib_api_t *input ) { - static platform_exp_t pi; + static common_exp_t Com; // Sys_LoadLibrary can create fake instance, to check // api version and api size, but first argument will be 0 @@ -49,27 +50,27 @@ platform_exp_t DLLEXPORT *CreateAPI ( stdinout_api_t *input ) if(input) std = *input; //generic functions - pi.apiversion = PLATFORM_API_VERSION; - pi.api_size = sizeof(platform_exp_t); + Com.apiversion = COMMON_API_VERSION; + Com.api_size = sizeof(common_exp_t); - pi.Init = InitPlatform; - pi.Shutdown = ClosePlatform; + Com.Init = InitPlatform; + Com.Shutdown = ClosePlatform; //get interfaces - pi.Fs = FS_GetAPI(); - pi.VFs = VFS_GetAPI(); - pi.Mem = Mem_GetAPI(); - pi.Script = Sc_GetAPI(); - pi.Compile = Comp_GetAPI(); - pi.Info = Info_GetAPI(); + Com.Fs = FS_GetAPI(); + Com.VFs = VFS_GetAPI(); + Com.Mem = Mem_GetAPI(); + Com.Script = Sc_GetAPI(); + Com.Compile = Comp_GetAPI(); + Com.Info = Info_GetAPI(); - pi.InitRootDir = FS_InitRootDir; - pi.LoadGameInfo = FS_LoadGameInfo; - pi.AddGameHierarchy = FS_AddGameHierarchy; + Com.InitRootDir = FS_InitRootDir; + Com.LoadGameInfo = FS_LoadGameInfo; + Com.AddGameHierarchy = FS_AddGameHierarchy; //timer - pi.DoubleTime = Plat_DoubleTime; - pi.GameInfo = Plat_GameInfo; + Com.DoubleTime = Plat_DoubleTime; + Com.GameInfo = Plat_GameInfo; - return π + return &Com; } \ No newline at end of file diff --git a/platform/platform.h b/common/platform.h similarity index 100% rename from platform/platform.h rename to common/platform.h diff --git a/platform/qcclib/pr_comp.c b/common/qcclib/pr_comp.c similarity index 100% rename from platform/qcclib/pr_comp.c rename to common/qcclib/pr_comp.c diff --git a/platform/qcclib/pr_lex.c b/common/qcclib/pr_lex.c similarity index 100% rename from platform/qcclib/pr_lex.c rename to common/qcclib/pr_lex.c diff --git a/platform/qcclib/qcc_utils.c b/common/qcclib/qcc_utils.c similarity index 78% rename from platform/qcclib/qcc_utils.c rename to common/qcclib/qcc_utils.c index 5f9b15cf..aa0c3cdd 100644 --- a/platform/qcclib/qcc_utils.c +++ b/common/qcclib/qcc_utils.c @@ -4,6 +4,7 @@ //======================================================================= #include "qcclib.h" +#include "zip32.h" void Hash_InitTable(hashtable_t *table, int numbucks, void *mem) { @@ -265,18 +266,27 @@ PR_decode char *PR_decode(int complen, int len, int method, char *info, char *buffer) { int i; - if (method == 0) //copy + if (method == 0) // copy { if (complen != len) Sys_Error("lengths do not match"); memcpy(buffer, info, len); } - else if (method == 1)//encryption + else if (method == 1)// encryption { if (complen != len) Sys_Error("lengths do not match"); for (i = 0; i < len; i++) buffer[i] = info[i] ^ 0xA5; } - else Sys_Error("Bad file encryption routine\n"); + else if (method == 2)// compression (ZLIB) + { + z_stream strm = {info, complen, 0, buffer, len, 0, NULL, NULL, NULL, NULL, NULL, Z_BINARY, 0, 0 }; + inflateInit( &strm ); + // decompress it in one go. + if (Z_STREAM_END != inflate( &strm, Z_FINISH )) + Sys_Error("Failed block decompression\n"); + inflateEnd( &strm ); + } + else Sys_Error("PR_decode: Bad file encryption routine\n"); return buffer; } @@ -288,21 +298,44 @@ PR_encode */ int PR_encode(int len, int method, char *in, vfile_t *handle) { - int i; - if (method == 0) //copy + int i = 0; + if (method == 0) // copy { VFS_Write(handle, in, len); return len; } - else if (method == 1)//encryption + else if (method == 1)// encryption { for (i = 0; i < len; i++) in[i] = in[i] ^ 0xA5; VFS_Write(handle, in, len); return len; } + else if (method == 2)// compression (ZLIB) + { + char out[8192]; + z_stream strm = {in, len, 0, out, sizeof(out), 0, NULL, NULL, NULL, NULL, NULL, Z_BINARY, 0, 0 }; + + deflateInit( &strm, Z_BEST_COMPRESSION); + + while(deflate( &strm, Z_FINISH) == Z_OK) + { + // compress in chunks of 8192. Saves having to allocate a huge-mega-big buffer + VFS_Write( handle, out, sizeof(out) - strm.avail_out); + i += sizeof(out) - strm.avail_out; + + Msg("Zlib statuc %s\n", strm.msg ); + strm.next_out = out; + strm.avail_out = sizeof(out); + } + VFS_Write( handle, out, sizeof(out) - strm.avail_out ); + i += sizeof(out) - strm.avail_out; + + deflateEnd( &strm ); + return i; + } else { - Sys_Error("Wierd method"); + Sys_Error("PR_encode: Bad encryption method\n"); return 0; } } diff --git a/platform/qcclib/qcclib.h b/common/qcclib/qcclib.h similarity index 100% rename from platform/qcclib/qcclib.h rename to common/qcclib/qcclib.h diff --git a/platform/qcclib/qccmain.c b/common/qcclib/qccmain.c similarity index 95% rename from platform/qcclib/qccmain.c rename to common/qcclib/qccmain.c index aaf41372..06b0f693 100644 --- a/platform/qcclib/qccmain.c +++ b/common/qcclib/qccmain.c @@ -38,7 +38,7 @@ int numtemps; void PR_ResetErrorScope(void); -bool compressoutput; +bool compressoutput = false; bool newstylesource; char destfile[1024]; @@ -337,7 +337,6 @@ void PR_PrintGlobals (void) } } -int encode(int len, int method, char *in, int handle); int WriteSourceFiles(vfile_t *h, dprograms_t *progs, bool sourceaswell) { includeddatafile_t *idf; @@ -345,26 +344,6 @@ int WriteSourceFiles(vfile_t *h, dprograms_t *progs, bool sourceaswell) int num=0; int ofs; - /* - for (f = sourcefile; f ; f=f->next) - { - if (f->type == FT_CODE && !sourceaswell) - continue; - - VFS_Write(h, f->filename, strlen(f->filename)+1); - i = LittleLong(f->size); - VFS_Write(h, &i, sizeof(int)); - - i = LittleLong(encrpytmode); - VFS_Write(h, &i, sizeof(int)); - - if (encrpytmode) - for (i = 0; i < f->size; i++) - f->file[i] ^= 0xA5; - - VFS_Write(h, f->file, f->size); - }*/ - for (f = sourcefile,num=0; f ; f=f->next) { if (f->type == FT_CODE && !sourceaswell) @@ -372,8 +351,7 @@ int WriteSourceFiles(vfile_t *h, dprograms_t *progs, bool sourceaswell) num++; } - if (!num) - return 0; + if (!num) return 0; idf = Qalloc(sizeof(includeddatafile_t)*num); for (f = sourcefile,num=0; f ; f=f->next) { @@ -2078,6 +2056,7 @@ void PR_SetDefaultProperties (void) PR_DefineName("OP_COMP_GLOBALS"); PR_DefineName("OP_COMP_LINES"); PR_DefineName("OP_COMP_TYPES"); + compressoutput = true; //enable compression } if (FS_CheckParm("/O0") || FS_CheckParm("-O0")) @@ -2088,8 +2067,7 @@ void PR_SetDefaultProperties (void) level = 2; else if (FS_CheckParm("/O3") || FS_CheckParm("-O3")) level = 3; - else - level = -1; + else level = -1; if (level == -1) { @@ -2112,7 +2090,7 @@ void PR_SetDefaultProperties (void) } } - targetformat = QCF_STANDARD; + //targetformat = QCF_STANDARD; //enable all warnings @@ -2172,7 +2150,6 @@ void PR_main ( void ) //as part of the quake engine maxtypeinfos = 16384; MAX_CONSTANTS = 2048; - compressoutput = 0; strcpy(v_copyright, "This file was created with ForeThought's modified QuakeC compiler\nThanks to ID Software"); for (p = 0; compiler_flag[p].enabled; p++) diff --git a/platform/spritegen.c b/common/spritegen.c similarity index 100% rename from platform/spritegen.c rename to common/spritegen.c diff --git a/platform/zip32.h b/common/zip32.h similarity index 53% rename from platform/zip32.h rename to common/zip32.h index fb28f149..835e2910 100644 --- a/platform/zip32.h +++ b/common/zip32.h @@ -8,11 +8,45 @@ #define ZLIB_VERSION "1.2.3" -#define MAX_WBITS 15 +#define MAX_WBITS 15 #define PUP(a) *(a)++ +#define DEF_MEM_LEVEL 8 -typedef byte* (*alloc_func)(); -typedef void (*free_func) (); +// compression levels +#define Z_DEFAULT_COMPRESSION (-1) +#define Z_NO_COMPRESSION 0 +#define Z_BEST_SPEED 1 +#define Z_BEST_COMPRESSION 9 + +// compression strategy; see deflateInit2() below for details +#define Z_DEFAULT_STRATEGY 0 +#define Z_FILTERED 1 +#define Z_HUFFMAN_ONLY 2 + +// Possible values of the data_type field +#define Z_BINARY 0 +#define Z_ASCII 1 +#define Z_UNKNOWN 2 + +// tree types +#define STORED_BLOCK 0 +#define STATIC_TREES 1 +#define DYN_TREES 2 + +//zflags +#define PRESET_DICT 0x20 // preset dictionary flag in zlib header + +#define MIN_LOOKAHEAD (258+3+1)// MAX_MATCH+MIN_MATCH+1 +#define MAX_DIST(s) ((s)->w_size-MIN_LOOKAHEAD) +#define LENGTH_CODES 29 +#define LITERALS 256 +#define L_CODES (LITERALS+1+LENGTH_CODES) +#define D_CODES 30 +#define BL_CODES 19 +#define HEAP_SIZE (2*L_CODES+1) + +#define ZipAlloc(strm, items, size) (*((strm)->zalloc))((strm)->opaque, (items), (size)) +#define ZipFree(strm, addr) (*((strm)->zfree))((strm)->opaque, (void*)(addr)) typedef struct { @@ -28,6 +62,41 @@ typedef enum DISTS } codetype; +typedef enum +{ + need_more, // block not completed, need more input or more output + block_done, // block flush performed + finish_started, // finish started, need only more output at next deflate + finish_done // finish done, accept no more input or output +} block_state; + +typedef struct ct_data_s +{ + union + { + word freq; // frequency count + word code; // bit string + } fc; + union + { + word dad; // father node in Huffman tree + word len; // length of bit string + } dl; +} ct_data; + +typedef struct static_tree_desc_s static_tree_desc; + +typedef struct tree_desc_s +{ + ct_data *dyn_tree; // the dynamic tree + int max_code; // largest code with non zero frequency + static_tree_desc *stat_desc; // the corresponding static tree +} tree_desc; + +typedef byte* (*alloc_func)(); +typedef void (*free_func)(); +typedef block_state (*compress_func)(); + // Possible inflate modes between inflate() calls typedef enum { @@ -82,6 +151,26 @@ typedef struct gz_header_s typedef gz_header *gz_headerp; +typedef struct z_stream_s +{ + byte *next_in; // next input byte + dword avail_in; // number of bytes available at next_in + dword total_in; // total nb of input bytes read so far + byte *next_out; // next output byte should be put there + dword avail_out; // remaining free space at next_out + dword total_out; // total nb of bytes output so far + char *msg; // last error message, NULL if no error + struct int_state *state; // not visible by applications + alloc_func zalloc; // used to allocate the internal state + free_func zfree; // used to free the internal state + byte* opaque; // private data object passed to zalloc and zfree + int data_type; // best guess about the data type: binary or text + dword adler; // adler32 value of the uncompressed data + dword reserved; // reserved for future use +}z_stream; + +typedef z_stream *z_streamp; + struct inflate_state { inflate_mode mode; // current inflate mode @@ -123,26 +212,86 @@ struct inflate_state code codes[2048]; // space for code tables }; - -typedef struct z_stream_s +typedef struct int_state { - byte *next_in; // next input byte - dword avail_in; // number of bytes available at next_in - dword total_in; // total nb of input bytes read so far - byte *next_out; // next output byte should be put there - dword avail_out; // remaining free space at next_out - dword total_out; // total nb of bytes output so far - char *msg; // last error message, NULL if no error - struct int_state *state; // not visible by applications - alloc_func zalloc; // used to allocate the internal state - free_func zfree; // used to free the internal state - byte* opaque; // private data object passed to zalloc and zfree - int data_type; // best guess about the data type: binary or text - dword adler; // adler32 value of the uncompressed data - dword reserved; // reserved for future use -}z_stream; + z_streamp strm; /* pointer back to this zlib stream */ + int status; /* as the name implies */ + byte *pending_buf; /* output still pending */ + dword pending_buf_size; /* size of pending_buf */ + byte *pending_out; /* next pending byte to output to the stream */ + int pending; /* nb of bytes in the pending buffer */ + int noheader; /* suppress zlib header and adler32 */ + byte data_type; /* UNKNOWN, BINARY or ASCII */ + byte method; /* STORED (for zip only) or DEFLATED */ + int last_flush; /* value of flush param for previous deflate call */ -typedef z_stream *z_streamp; + uint w_size; /* LZ77 window size (32K by default) */ + uint w_bits; /* log2(w_size) (8..16) */ + uint w_mask; /* w_size - 1 */ + + byte *window; + dword window_size; + + word *prev; + word *head; /* Heads of the hash chains or NIL. */ + + uint ins_h; /* hash index of string to be inserted */ + uint hash_size; /* number of elements in hash table */ + uint hash_bits; /* log2(hash_size) */ + uint hash_mask; /* hash_size-1 */ + + uint hash_shift; + + long block_start; + + uint match_length; /* length of best match */ + uint prev_match; /* previous match */ + int match_available; /* set if previous match exists */ + uint strstart; /* start of string to insert */ + uint match_start; /* start of matching string */ + uint lookahead; /* number of valid bytes ahead in window */ + + uint prev_length; + uint max_chain_length; + + uint max_lazy_match; + + int level; // compression level (1..9) + int strategy; // favor or force Huffman coding + + uint good_match; + int nice_match; // Stop searching when current match exceeds this + + byte *l_buf; // buffer for literals or lengths + uint lit_bufsize; + uint last_lit; // running index in l_buf + word *d_buf; + + ct_data dyn_ltree[HEAP_SIZE]; // literal and length tree + ct_data dyn_dtree[2*D_CODES+1]; // distance tree + ct_data bl_tree[2*BL_CODES+1]; // Huffman tree for bit lengths + + tree_desc l_desc; // desc. for literal tree + tree_desc d_desc; // desc. for distance tree + tree_desc bl_desc; // desc. for bit length tree + + word bl_count[MAX_WBITS+1]; + + int heap[2*L_CODES+1]; // heap used to build the Huffman trees + int heap_len; // number of elements in the heap + int heap_max; // element of largest frequency + + byte depth[2*L_CODES+1]; + + dword opt_len; // bit length of current block with optimal trees + dword static_len; // bit length of current block with static trees + uint matches; // number of string matches in current block + int last_eob_len; // bit length of EOB code for last block + + word bi_buf; + int bi_valid; + +} deflate_state; //zlib errors #define Z_OK 0 @@ -162,16 +311,34 @@ typedef z_stream *z_streamp; #define Z_BLOCK 5 #define Z_DEFLATED 8 -//exported functions -unsigned long crc32(dword crc, const byte *buf, uint len);// crc32 -unsigned long adler32(dword adler, const byte *buf, dword len); +// zlib states +#define INIT_STATE 42 +#define BUSY_STATE 113 +#define FINISH_STATE 666 + +#define put_byte(s, c) { s->pending_buf[s->pending++] = (c); } +#define put_short(s, w) { put_byte(s, (byte)((w) & 0xff)); put_byte(s, (byte)((byte)(w) >> 8)); } +_inline void putShortMSB (deflate_state *s, uint b){ put_byte(s, (byte)(b >> 8)); put_byte(s, (byte)(b & 0xff)); } + +// exported functions +dword adler32(dword adler, const byte *buf, dword len); + extern int inflate(z_streamp strm, int flush); extern int inflateEnd(z_streamp strm); extern int inflateInit_(z_streamp strm, const char *version, int stream_size); extern int inflateInit2_(z_streamp strm, int windowBits, const char *version, int stream_size); extern int inflateReset(z_streamp strm); +extern int deflate (z_streamp strm, int flush); +extern int deflateEnd (z_streamp strm); +extern int deflateInit_(z_streamp strm, int level, const char *version, int stream_size); +extern int deflateInit2_(z_streamp strm, int level, int windowBits, const char *version, int stream_size); +extern int deflateReset (z_streamp strm); + #define inflateInit(strm) inflateInit_((strm), ZLIB_VERSION, sizeof(z_stream)) #define inflateInit2(strm, windowBits) inflateInit2_((strm), (windowBits), ZLIB_VERSION, sizeof(z_stream)) +#define deflateInit(strm, level) deflateInit_((strm), (level), ZLIB_VERSION, sizeof(z_stream)) +#define deflateInit2(strm, level, windowBits) deflateInit2_((strm),(level),(windowBits), ZLIB_VERSION, sizeof(z_stream)) + #endif//COM_ZLIB_H \ No newline at end of file diff --git a/common/ziplib.c b/common/ziplib.c new file mode 100644 index 00000000..17e35198 --- /dev/null +++ b/common/ziplib.c @@ -0,0 +1,2967 @@ +//======================================================================= +// Copyright (C) XashXT Group 2006 +// All Rights Reserved +//======================================================================= + +#include "platform.h" +#include "baseutils.h" +#include "zip32.h" + +#define BASE 65521UL // largest prime smaller than 65536 +#define NMAX 5552 + +//crc 32 +#define DO1 crc = crc_table[0][((int)crc ^ (*buf++)) & 0xff] ^ (crc >> 8) +#define DO8 DO1; DO1; DO1; DO1; DO1; DO1; DO1; DO1 + +//adler 32 +#define BASE 65521UL /* largest prime smaller than 65536 */ +#define ADO1(buf,i) {adler += (buf)[i]; sum2 += adler;} +#define ADO2(buf,i) ADO1(buf,i); ADO1(buf,i+1); +#define ADO4(buf,i) ADO2(buf,i); ADO2(buf,i+2); +#define ADO8(buf,i) ADO4(buf,i); ADO4(buf,i+4); +#define ADO16(buf) ADO8(buf,0); ADO8(buf,8); +#define MOD(a) a %= BASE +#define MOD4(a) a %= BASE + +//memory opertions +byte* zcalloc (byte* opaque, uint items, uint size) +{ + return (byte *)Malloc( items * size ); +} + +void zcfree (byte* opaque, byte* ptr) +{ + Free( ptr ); +} + +static const code lenfix[512] = { + {96,7,0},{0,8,80},{0,8,16},{20,8,115},{18,7,31},{0,8,112},{0,8,48}, + {0,9,192},{16,7,10},{0,8,96},{0,8,32},{0,9,160},{0,8,0},{0,8,128}, + {0,8,64},{0,9,224},{16,7,6},{0,8,88},{0,8,24},{0,9,144},{19,7,59}, + {0,8,120},{0,8,56},{0,9,208},{17,7,17},{0,8,104},{0,8,40},{0,9,176}, + {0,8,8},{0,8,136},{0,8,72},{0,9,240},{16,7,4},{0,8,84},{0,8,20}, + {21,8,227},{19,7,43},{0,8,116},{0,8,52},{0,9,200},{17,7,13},{0,8,100}, + {0,8,36},{0,9,168},{0,8,4},{0,8,132},{0,8,68},{0,9,232},{16,7,8}, + {0,8,92},{0,8,28},{0,9,152},{20,7,83},{0,8,124},{0,8,60},{0,9,216}, + {18,7,23},{0,8,108},{0,8,44},{0,9,184},{0,8,12},{0,8,140},{0,8,76}, + {0,9,248},{16,7,3},{0,8,82},{0,8,18},{21,8,163},{19,7,35},{0,8,114}, + {0,8,50},{0,9,196},{17,7,11},{0,8,98},{0,8,34},{0,9,164},{0,8,2}, + {0,8,130},{0,8,66},{0,9,228},{16,7,7},{0,8,90},{0,8,26},{0,9,148}, + {20,7,67},{0,8,122},{0,8,58},{0,9,212},{18,7,19},{0,8,106},{0,8,42}, + {0,9,180},{0,8,10},{0,8,138},{0,8,74},{0,9,244},{16,7,5},{0,8,86}, + {0,8,22},{64,8,0},{19,7,51},{0,8,118},{0,8,54},{0,9,204},{17,7,15}, + {0,8,102},{0,8,38},{0,9,172},{0,8,6},{0,8,134},{0,8,70},{0,9,236}, + {16,7,9},{0,8,94},{0,8,30},{0,9,156},{20,7,99},{0,8,126},{0,8,62}, + {0,9,220},{18,7,27},{0,8,110},{0,8,46},{0,9,188},{0,8,14},{0,8,142}, + {0,8,78},{0,9,252},{96,7,0},{0,8,81},{0,8,17},{21,8,131},{18,7,31}, + {0,8,113},{0,8,49},{0,9,194},{16,7,10},{0,8,97},{0,8,33},{0,9,162}, + {0,8,1},{0,8,129},{0,8,65},{0,9,226},{16,7,6},{0,8,89},{0,8,25}, + {0,9,146},{19,7,59},{0,8,121},{0,8,57},{0,9,210},{17,7,17},{0,8,105}, + {0,8,41},{0,9,178},{0,8,9},{0,8,137},{0,8,73},{0,9,242},{16,7,4}, + {0,8,85},{0,8,21},{16,8,258},{19,7,43},{0,8,117},{0,8,53},{0,9,202}, + {17,7,13},{0,8,101},{0,8,37},{0,9,170},{0,8,5},{0,8,133},{0,8,69}, + {0,9,234},{16,7,8},{0,8,93},{0,8,29},{0,9,154},{20,7,83},{0,8,125}, + {0,8,61},{0,9,218},{18,7,23},{0,8,109},{0,8,45},{0,9,186},{0,8,13}, + {0,8,141},{0,8,77},{0,9,250},{16,7,3},{0,8,83},{0,8,19},{21,8,195}, + {19,7,35},{0,8,115},{0,8,51},{0,9,198},{17,7,11},{0,8,99},{0,8,35}, + {0,9,166},{0,8,3},{0,8,131},{0,8,67},{0,9,230},{16,7,7},{0,8,91}, + {0,8,27},{0,9,150},{20,7,67},{0,8,123},{0,8,59},{0,9,214},{18,7,19}, + {0,8,107},{0,8,43},{0,9,182},{0,8,11},{0,8,139},{0,8,75},{0,9,246}, + {16,7,5},{0,8,87},{0,8,23},{64,8,0},{19,7,51},{0,8,119},{0,8,55}, + {0,9,206},{17,7,15},{0,8,103},{0,8,39},{0,9,174},{0,8,7},{0,8,135}, + {0,8,71},{0,9,238},{16,7,9},{0,8,95},{0,8,31},{0,9,158},{20,7,99}, + {0,8,127},{0,8,63},{0,9,222},{18,7,27},{0,8,111},{0,8,47},{0,9,190}, + {0,8,15},{0,8,143},{0,8,79},{0,9,254},{96,7,0},{0,8,80},{0,8,16}, + {20,8,115},{18,7,31},{0,8,112},{0,8,48},{0,9,193},{16,7,10},{0,8,96}, + {0,8,32},{0,9,161},{0,8,0},{0,8,128},{0,8,64},{0,9,225},{16,7,6}, + {0,8,88},{0,8,24},{0,9,145},{19,7,59},{0,8,120},{0,8,56},{0,9,209}, + {17,7,17},{0,8,104},{0,8,40},{0,9,177},{0,8,8},{0,8,136},{0,8,72}, + {0,9,241},{16,7,4},{0,8,84},{0,8,20},{21,8,227},{19,7,43},{0,8,116}, + {0,8,52},{0,9,201},{17,7,13},{0,8,100},{0,8,36},{0,9,169},{0,8,4}, + {0,8,132},{0,8,68},{0,9,233},{16,7,8},{0,8,92},{0,8,28},{0,9,153}, + {20,7,83},{0,8,124},{0,8,60},{0,9,217},{18,7,23},{0,8,108},{0,8,44}, + {0,9,185},{0,8,12},{0,8,140},{0,8,76},{0,9,249},{16,7,3},{0,8,82}, + {0,8,18},{21,8,163},{19,7,35},{0,8,114},{0,8,50},{0,9,197},{17,7,11}, + {0,8,98},{0,8,34},{0,9,165},{0,8,2},{0,8,130},{0,8,66},{0,9,229}, + {16,7,7},{0,8,90},{0,8,26},{0,9,149},{20,7,67},{0,8,122},{0,8,58}, + {0,9,213},{18,7,19},{0,8,106},{0,8,42},{0,9,181},{0,8,10},{0,8,138}, + {0,8,74},{0,9,245},{16,7,5},{0,8,86},{0,8,22},{64,8,0},{19,7,51}, + {0,8,118},{0,8,54},{0,9,205},{17,7,15},{0,8,102},{0,8,38},{0,9,173}, + {0,8,6},{0,8,134},{0,8,70},{0,9,237},{16,7,9},{0,8,94},{0,8,30}, + {0,9,157},{20,7,99},{0,8,126},{0,8,62},{0,9,221},{18,7,27},{0,8,110}, + {0,8,46},{0,9,189},{0,8,14},{0,8,142},{0,8,78},{0,9,253},{96,7,0}, + {0,8,81},{0,8,17},{21,8,131},{18,7,31},{0,8,113},{0,8,49},{0,9,195}, + {16,7,10},{0,8,97},{0,8,33},{0,9,163},{0,8,1},{0,8,129},{0,8,65}, + {0,9,227},{16,7,6},{0,8,89},{0,8,25},{0,9,147},{19,7,59},{0,8,121}, + {0,8,57},{0,9,211},{17,7,17},{0,8,105},{0,8,41},{0,9,179},{0,8,9}, + {0,8,137},{0,8,73},{0,9,243},{16,7,4},{0,8,85},{0,8,21},{16,8,258}, + {19,7,43},{0,8,117},{0,8,53},{0,9,203},{17,7,13},{0,8,101},{0,8,37}, + {0,9,171},{0,8,5},{0,8,133},{0,8,69},{0,9,235},{16,7,8},{0,8,93}, + {0,8,29},{0,9,155},{20,7,83},{0,8,125},{0,8,61},{0,9,219},{18,7,23}, + {0,8,109},{0,8,45},{0,9,187},{0,8,13},{0,8,141},{0,8,77},{0,9,251}, + {16,7,3},{0,8,83},{0,8,19},{21,8,195},{19,7,35},{0,8,115},{0,8,51}, + {0,9,199},{17,7,11},{0,8,99},{0,8,35},{0,9,167},{0,8,3},{0,8,131}, + {0,8,67},{0,9,231},{16,7,7},{0,8,91},{0,8,27},{0,9,151},{20,7,67}, + {0,8,123},{0,8,59},{0,9,215},{18,7,19},{0,8,107},{0,8,43},{0,9,183}, + {0,8,11},{0,8,139},{0,8,75},{0,9,247},{16,7,5},{0,8,87},{0,8,23}, + {64,8,0},{19,7,51},{0,8,119},{0,8,55},{0,9,207},{17,7,15},{0,8,103}, + {0,8,39},{0,9,175},{0,8,7},{0,8,135},{0,8,71},{0,9,239},{16,7,9}, + {0,8,95},{0,8,31},{0,9,159},{20,7,99},{0,8,127},{0,8,63},{0,9,223}, + {18,7,27},{0,8,111},{0,8,47},{0,9,191},{0,8,15},{0,8,143},{0,8,79}, + {0,9,255} +}; + +static const code distfix[32] = { + {16,5,1},{23,5,257},{19,5,17},{27,5,4097},{17,5,5},{25,5,1025}, + {21,5,65},{29,5,16385},{16,5,3},{24,5,513},{20,5,33},{28,5,8193}, + {18,5,9},{26,5,2049},{22,5,129},{64,5,0},{16,5,2},{23,5,385}, + {19,5,25},{27,5,6145},{17,5,7},{25,5,1537},{21,5,97},{29,5,24577}, + {16,5,4},{24,5,769},{20,5,49},{28,5,12289},{18,5,13},{26,5,3073}, + {22,5,193},{64,5,0} +}; + +dword adler32(dword adler, const byte *buf, dword len) +{ + dword sum2; + uint n; + + // split Adler-32 into component sums + sum2 = (adler >> 16) & 0xffff; + adler &= 0xffff; + + /* in case user likes doing a byte at a time, keep it fast */ + if (len == 1) + { + adler += buf[0]; + if (adler >= BASE) adler -= BASE; + sum2 += adler; + if (sum2 >= BASE) sum2 -= BASE; + return adler | (sum2 << 16); + } + + /* initial Adler-32 value (deferred check for len == 1 speed) */ + if (buf == NULL) return 1L; + + /* in case short lengths are provided, keep it somewhat fast */ + if (len < 16) + { + while (len--) + { + adler += *buf++; + sum2 += adler; + } + + if (adler >= BASE) adler -= BASE; + MOD4(sum2); // only added so many BASE's + return adler | (sum2 << 16); + } + + // do length NMAX blocks -- requires just one modulo operation + while (len >= NMAX) + { + len -= NMAX; + n = NMAX / 16; // NMAX is divisible by 16 + do + { + ADO16(buf); // 16 sums unrolled + buf += 16; + } while (--n); + MOD(adler); + MOD(sum2); + } + + // do remaining bytes (less than NMAX, still just one modulo) + if (len) // avoid modulos if none remaining + { + while (len >= 16) + { + len -= 16; + ADO16(buf); + buf += 16; + } + while (len--) + { + adler += *buf++; + sum2 += adler; + } + MOD(adler); + MOD(sum2); + } + + // return recombined sums + return adler | (sum2 << 16); +} + +//======================================================================= +// INFALTE STUFF +//======================================================================= + +int inflateInit_(z_streamp strm, const char *version, int stream_size ) +{ + //internal checking + return inflateInit2_(strm, MAX_WBITS, version, stream_size); +} + +int inflateInit2_(z_streamp strm, int windowBits, const char *version, int stream_size) +{ + struct inflate_state *state; + + if (version == NULL || version[0] != ZLIB_VERSION[0] || stream_size != (int)(sizeof(z_stream))) + return Z_VERSION_ERROR; + + if (strm == NULL) return Z_STREAM_ERROR; + strm->msg = NULL; //in case we return an error + if (strm->zalloc == NULL) + { + strm->zalloc = zcalloc; + strm->opaque = NULL; + } + + if (strm->zfree == NULL) strm->zfree = zcfree; + state = (struct inflate_state *) ZipAlloc(strm, 1, sizeof(struct inflate_state)); + if (state == NULL) return Z_MEM_ERROR; + strm->state = (struct int_state *)state; + if (windowBits < 0) + { + state->wrap = 0; + windowBits = -windowBits; + } + else state->wrap = (windowBits >> 4) + 1; + if (windowBits < 8 || windowBits > 15) + { + ZipFree(strm, (byte*)state ); + strm->state = NULL; + return Z_STREAM_ERROR; + } + + state->wbits = (uint)windowBits; + state->window = NULL; + return inflateReset(strm); +} + +int inflate_table(codetype type, unsigned short *lens, unsigned codes, code **table, unsigned *bits, unsigned short *work) +{ + unsigned len; /* a code's length in bits */ + unsigned sym; /* index of code symbols */ + unsigned min, max; /* minimum and maximum code lengths */ + unsigned root; /* number of index bits for root table */ + unsigned curr; /* number of index bits for current table */ + unsigned drop; /* code bits to drop for sub-table */ + int left; /* number of prefix codes available */ + unsigned used; /* code entries in table used */ + unsigned huff; /* Huffman code */ + unsigned incr; /* for incrementing code, index */ + unsigned fill; /* index for replicating entries */ + unsigned low; /* low bits for current root entry */ + unsigned mask; /* mask for low root bits */ + code this; /* table entry for duplication */ + code *next; /* next available space in table */ + const unsigned short *base; /* base value table to use */ + const unsigned short *extra;/* extra bits table to use */ + int end; /* use base and extra for symbol > end */ + unsigned short count[MAX_WBITS+1]; /* number of codes of each length */ + unsigned short offs[MAX_WBITS+1]; /* offsets in table for each length */ + static const unsigned short lbase[31] = { /* Length codes 257..285 base */ + 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, + 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0}; + static const unsigned short lext[31] = { /* Length codes 257..285 extra */ + 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18, + 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 201, 196}; + static const unsigned short dbase[32] = { /* Distance codes 0..29 base */ + 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, + 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, + 8193, 12289, 16385, 24577, 0, 0}; + static const unsigned short dext[32] = { /* Distance codes 0..29 extra */ + 16, 16, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, + 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, + 28, 28, 29, 29, 64, 64}; + + /* accumulate lengths for codes (assumes lens[] all in 0..MAXBITS) */ + for (len = 0; len <= MAX_WBITS; len++) count[len] = 0; + for (sym = 0; sym < codes; sym++) count[lens[sym]]++; + + /* bound code lengths, force root to be within code lengths */ + root = *bits; + for (max = MAX_WBITS; max >= 1; max--) if (count[max] != 0) break; + if (root > max) root = max; + if (max == 0) /* no symbols to code at all */ + { + this.op = (unsigned char)64; /* invalid code marker */ + this.bits = (unsigned char)1; + this.val = (unsigned short)0; + *(*table)++ = this; /* make a table to force an error */ + *(*table)++ = this; + *bits = 1; + return 0; /* no symbols, but wait for decoding to report error */ + } + for (min = 1; min <= MAX_WBITS; min++) if (count[min] != 0) break; + if (root < min) root = min; + + /* check for an over-subscribed or incomplete set of lengths */ + left = 1; + for (len = 1; len <= MAX_WBITS; len++) + { + left <<= 1; + left -= count[len]; + if (left < 0) return -1; /* over-subscribed */ + } + if (left > 0 && (type == CODES || max != 1)) return -1; /* incomplete set */ + + /* generate offsets into symbol table for each length for sorting */ + offs[1] = 0; + for (len = 1; len < MAX_WBITS; len++) offs[len + 1] = offs[len] + count[len]; + + /* sort symbols by length, by symbol order within each length */ + for (sym = 0; sym < codes; sym++) if (lens[sym] != 0) work[offs[lens[sym]]++] = (unsigned short)sym; + + + /* set up for code type */ + switch (type) + { + case CODES: + base = extra = work; /* dummy value--not used */ + end = 19; + break; + case LENS: + base = lbase; + base -= 257; + extra = lext; + extra -= 257; + end = 256; + break; + default: /* DISTS */ + base = dbase; + extra = dext; + end = -1; + } + + /* initialize state for loop */ + huff = 0; /* starting code */ + sym = 0; /* starting code symbol */ + len = min; /* starting code length */ + next = *table; /* current table to fill in */ + curr = root; /* current table index bits */ + drop = 0; /* current bits to drop from code for index */ + low = (unsigned)(-1); /* trigger new sub-table when len > root */ + used = 1U << root; /* use root table entries */ + mask = used - 1; /* mask for comparing low */ + + /* check available table space */ + if (type == LENS && used >= 2048 - 592) return 1; + + /* process all codes and make table entries */ + for (;;) + { + /* create table entry */ + this.bits = (unsigned char)(len - drop); + if ((int)(work[sym]) < end) + { + this.op = (unsigned char)0; + this.val = work[sym]; + } + else if ((int)(work[sym]) > end) + { + this.op = (unsigned char)(extra[work[sym]]); + this.val = base[work[sym]]; + } + else + { + this.op = (unsigned char)(32 + 64); /* end of block */ + this.val = 0; + } + + /* replicate for those indices with low len bits equal to huff */ + incr = 1U << (len - drop); + fill = 1U << curr; + min = fill; /* save offset to next table */ + do{ + fill -= incr; + next[(huff >> drop) + fill] = this; + }while (fill != 0); + + /* backwards increment the len-bit code huff */ + incr = 1U << (len - 1); + while (huff & incr) incr >>= 1; + if (incr != 0) + { + huff &= incr - 1; + huff += incr; + } + else huff = 0; + + /* go to next symbol, update count, len */ + sym++; + if (--(count[len]) == 0) + { + if (len == max) break; + len = lens[work[sym]]; + } + + /* create new sub-table if needed */ + if (len > root && (huff & mask) != low) + { + /* if first time, transition to sub-tables */ + if (drop == 0) drop = root; + /* increment past last table */ + next += min; /* here min is 1 << curr */ + + /* determine length of next table */ + curr = len - drop; + left = (int)(1 << curr); + while (curr + drop < max) + { + left -= count[curr + drop]; + if (left <= 0) break; + curr++; + left <<= 1; + } + + /* check for enough space */ + used += 1U << curr; + if (type == LENS && used >= 2048 - 592) return 1; + + /* point entry in root table to sub-table */ + low = huff & mask; + (*table)[low].op = (unsigned char)curr; + (*table)[low].bits = (unsigned char)root; + (*table)[low].val = (unsigned short)(next - *table); + } + } + + this.op = (unsigned char)64; /* invalid code marker */ + this.bits = (unsigned char)(len - drop); + this.val = (unsigned short)0; + while (huff != 0) + { + /* when done with sub-table, drop back to root table */ + if (drop != 0 && (huff & mask) != low) + { + drop = 0; + len = root; + next = *table; + this.bits = (unsigned char)len; + } + + /* put invalid code marker in table */ + next[huff >> drop] = this; + + /* backwards increment the len-bit code huff */ + incr = 1U << (len - 1); + while (huff & incr) incr >>= 1; + if (incr != 0) + { + huff &= incr - 1; + huff += incr; + } + else huff = 0; + } + + // set return parameters + *table += used; + *bits = root; + return 0; +} + +void inflate_fast(z_streamp strm, unsigned start) +{ + struct inflate_state *state; + byte *in; /* local strm->next_in */ + byte *last; /* while in < last, enough input available */ + unsigned char *out; /* local strm->next_out */ + unsigned char *beg; /* inflate()'s initial strm->next_out */ + unsigned char *end; /* while out < end, enough space available */ + unsigned wsize; /* window size or zero if not using window */ + unsigned whave; /* valid bytes in the window */ + unsigned write; /* window write index */ + unsigned char *window; /* allocated sliding window, if wsize != 0 */ + unsigned long hold; /* local strm->hold */ + unsigned bits; /* local strm->bits */ + code const *lcode; /* local strm->lencode */ + code const *dcode; /* local strm->distcode */ + unsigned lmask; /* mask for first level of length codes */ + unsigned dmask; /* mask for first level of distance codes */ + code this; /* retrieved table entry */ + unsigned op; /* code bits, operation, extra bits, or */ + /* window position, window bytes to copy */ + unsigned len; /* match length, unused bytes */ + unsigned dist; /* match distance */ + unsigned char *from; /* where to copy match from */ + + /* copy state to local variables */ + state = (struct inflate_state *)strm->state; + in = strm->next_in; + last = in + (strm->avail_in - 5); + out = strm->next_out; + beg = out - (start - strm->avail_out); + end = out + (strm->avail_out - 257); + wsize = state->wsize; + whave = state->whave; + write = state->write; + window = state->window; + hold = state->hold; + bits = state->bits; + lcode = state->lencode; + dcode = state->distcode; + lmask = (1U << state->lenbits) - 1; + dmask = (1U << state->distbits) - 1; + + /* decode literals and length/distances until end-of-block or not enough + input data or output space */ + do { + if (bits < 15) + { + hold += (unsigned long)(PUP(in)) << bits; + bits += 8; + hold += (unsigned long)(PUP(in)) << bits; + bits += 8; + } + this = lcode[hold & lmask]; +dolen: + op = (unsigned)(this.bits); + hold >>= op; + bits -= op; + op = (unsigned)(this.op); + if (op == 0) PUP(out) = (byte)(this.val); + else if (op & 16) /* length base */ + { + len = (unsigned)(this.val); + op &= 15; /* number of extra bits */ + if (op) + { + if (bits < op) + { + hold += (unsigned long)(PUP(in)) << bits; + bits += 8; + } + len += (unsigned)hold & ((1U << op) - 1); + hold >>= op; + bits -= op; + } + if (bits < 15) + { + hold += (dword)(PUP(in)) << bits; + bits += 8; + hold += (dword)(PUP(in)) << bits; + bits += 8; + } + this = dcode[hold & dmask]; +dodist: + op = (unsigned)(this.bits); + hold >>= op; + bits -= op; + op = (unsigned)(this.op); + if (op & 16) /* distance base */ + { + dist = (unsigned)(this.val); + op &= 15; /* number of extra bits */ + if (bits < op) + { + hold += (unsigned long)(PUP(in)) << bits; + bits += 8; + if (bits < op) + { + hold += (unsigned long)(PUP(in)) << bits; + bits += 8; + } + } + dist += (unsigned)hold & ((1U << op) - 1); + hold >>= op; + bits -= op; + op = (unsigned)(out - beg); /* max distance in output */ + if (dist > op) /* see if copy from window */ + { + op = dist - op; /* distance back in window */ + if (op > whave) + { + strm->msg = (char *)"invalid distance too far back"; + state->mode = BAD; + break; + } + from = window; + if (write == 0) // very common case + { + from += wsize - op; + if (op < len) // some from window + { + len -= op; + do{ + PUP(out) = PUP(from); + }while (--op); + from = out - dist; // rest from output + } + } + else if (write < op) // wrap around window + { + from += wsize + write - op; + op -= write; + if (op < len) /* some from end of window */ + { + len -= op; + do{ + PUP(out) = PUP(from); + }while (--op); + from = window; + if (write < len) /* some from start of window */ + { + op = write; + len -= op; + do{ + PUP(out) = PUP(from); + }while (--op); + from = out - dist; /* rest from output */ + } + } + } + else /* contiguous in window */ + { + from += write - op; + if (op < len) /* some from window */ + { + len -= op; + do{ + PUP(out) = PUP(from); + }while (--op); + from = out - dist; /* rest from output */ + } + } + while (len > 2) + { + PUP(out) = PUP(from); + PUP(out) = PUP(from); + PUP(out) = PUP(from); + len -= 3; + } + if (len) + { + PUP(out) = PUP(from); + if (len > 1) PUP(out) = PUP(from); + } + } + else + { + from = out - dist; // copy direct from output + do // minimum length is three + { + PUP(out) = PUP(from); + PUP(out) = PUP(from); + PUP(out) = PUP(from); + len -= 3; + }while (len > 2); + if (len) + { + PUP(out) = PUP(from); + if (len > 1) PUP(out) = PUP(from); + } + } + } + else if ((op & 64) == 0) // 2nd level distance code + { + this = dcode[this.val + (hold & ((1U << op) - 1))]; + goto dodist; + } + else + { + strm->msg = (char *)"invalid distance code"; + state->mode = BAD; + break; + } + } + else if ((op & 64) == 0) //2nd level length code + { + this = lcode[this.val + (hold & ((1U << op) - 1))]; + goto dolen; + } + else if (op & 32) /* end-of-block */ + { + state->mode = TYPE; + break; + } + else + { + strm->msg = (char *)"invalid literal/length code"; + state->mode = BAD; + break; + } + }while (in < last && out < end); + + // return unused bytes (on entry, bits < 8, so in won't go too far back) + len = bits >> 3; + in -= len; + bits -= len << 3; + hold &= (1U << bits) - 1; + + // update state and return + strm->next_in = in; + strm->next_out = out; + strm->avail_in = (unsigned)(in < last ? 5 + (last - in) : 5 - (in - last)); + strm->avail_out = (unsigned)(out < end ? 257 + (end - out) : 257 - (out - end)); + state->hold = hold; + state->bits = bits; + return; //??? +} + +void fixedtables(struct inflate_state *state) +{ + state->lencode = lenfix; + state->lenbits = 9; + state->distcode = distfix; + state->distbits = 5; +} + +int updatewindow(z_streamp strm, unsigned out) +{ + struct inflate_state *state; + unsigned copy, dist; + + state = (struct inflate_state *)strm->state; + + /* if it hasn't been done already, allocate space for the window */ + if (state->window == NULL) + { + state->window = (unsigned char *) + ZipAlloc(strm, 1U << state->wbits, (sizeof(byte))); + if (state->window == NULL) return 1; + } + + /* if window not in use yet, initialize */ + if (state->wsize == 0) + { + state->wsize = 1U << state->wbits; + state->write = 0; + state->whave = 0; + } + + /* copy state->wsize or less output bytes into the circular window */ + copy = out - strm->avail_out; + if (copy >= state->wsize) + { + Mem_Copy(state->window, strm->next_out - state->wsize, state->wsize); + state->write = 0; + state->whave = state->wsize; + } + else + { + dist = state->wsize - state->write; + if (dist > copy) dist = copy; + memcpy(state->window + state->write, strm->next_out - copy, dist); + copy -= dist; + + if (copy) + { + memcpy(state->window, strm->next_out - copy, copy); + state->write = copy; + state->whave = state->wsize; + } + else + { + state->write += dist; + if (state->write == state->wsize) state->write = 0; + if (state->whave < state->wsize) state->whave += dist; + } + } + return 0; +} + +// Macros for inflate(): + +// check function to use adler32() for zlib or crc32() for gzip +#define UPDATE(check, buf, len) adler32(check, buf, len) + +// Load registers with state in inflate() for speed +#define LOAD() \ + do { \ + put = strm->next_out; \ + left = strm->avail_out; \ + next = strm->next_in; \ + have = strm->avail_in; \ + hold = state->hold; \ + bits = state->bits; \ + } while (0) + +// Restore state from registers in inflate() +#define RESTORE() \ + do { \ + strm->next_out = put; \ + strm->avail_out = left; \ + strm->next_in = next; \ + strm->avail_in = have; \ + state->hold = hold; \ + state->bits = bits; \ + } while (0) + +// Clear the input bit accumulator +#define INITBITS() \ + do { \ + hold = 0; \ + bits = 0; \ + } while (0) + +// Get a byte of input into the bit accumulator, or return from inflate() +// if there is no input available. +#define PULLBYTE() \ + do { \ + if (have == 0) goto inf_leave; \ + have--; \ + hold += (unsigned long)(*next++) << bits; \ + bits += 8; \ + } while (0) + +// Assure that there are at least n bits in the bit accumulator. If there is +// not enough available input to do that, then return from inflate(). +#define NEEDBITS(n) \ + do { \ + while (bits < (unsigned)(n)) \ + PULLBYTE(); \ + } while (0) + +// Return the low n bits of the bit accumulator (n < 16) +#define BITS(n) \ + ((unsigned)hold & ((1U << (n)) - 1)) + +// Remove n bits from the bit accumulator +#define DROPBITS(n) \ + do { \ + hold >>= (n); \ + bits -= (unsigned)(n); \ + } while (0) + +// Remove zero to seven bits as needed to go to a byte boundary +#define BYTEBITS() \ + do { \ + hold >>= bits & 7; \ + bits -= bits & 7; \ + } while (0) + +// Reverse the bytes in a 32-bit value +#define REVERSE(q) \ + ((((q) >> 24) & 0xff) + (((q) >> 8) & 0xff00) + \ + (((q) & 0xff00) << 8) + (((q) & 0xff) << 24)) + +int inflate(z_streamp strm, int flush) +{ + struct inflate_state *state; + unsigned char *next; /* next input */ + unsigned char *put; /* next output */ + unsigned have, left; /* available input and output */ + unsigned long hold; /* bit buffer */ + unsigned bits; /* bits in bit buffer */ + unsigned in, out; /* save starting available input and output */ + unsigned copy; /* number of stored or match bytes to copy */ + unsigned char *from; /* where to copy match bytes from */ + code this; /* current decoding table entry */ + code last; /* parent table entry */ + unsigned len; /* length to copy for repeats, bits to drop */ + int ret; /* return code */ + + // permutation of code lengths + static const unsigned short order[19] ={16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15}; + + if (strm == NULL || strm->state == NULL || strm->next_out == NULL || (strm->next_in == NULL && strm->avail_in != 0)) + return Z_STREAM_ERROR; + + state = (struct inflate_state *)strm->state; + if (state->mode == TYPE) state->mode = TYPEDO; /* skip check */ + LOAD(); + in = have; + out = left; + ret = Z_OK; + + for (;;) + switch (state->mode) + { + case HEAD: + if (state->wrap == 0) + { + state->mode = TYPEDO; + break; + } + NEEDBITS(16); + + if (((BITS(8) << 8) + (hold >> 8)) % 31) // check if zlib header allowed + { + strm->msg = (char *)"incorrect header check"; + state->mode = BAD; + break; + } + if (BITS(4) != Z_DEFLATED) + { + strm->msg = (char *)"unknown compression method"; + state->mode = BAD; + break; + } + DROPBITS(4); + len = BITS(4) + 8; + if (len > state->wbits) + { + strm->msg = (char *)"invalid window size"; + state->mode = BAD; + break; + } + state->dmax = 1U << len; + strm->adler = state->check = adler32(0L, NULL, 0); + state->mode = hold & 0x200 ? DICTID : TYPE; + INITBITS(); + break; + case DICTID: + NEEDBITS(32); + strm->adler = state->check = REVERSE(hold); + INITBITS(); + state->mode = DICT; + case DICT: + if (state->havedict == 0) + { + RESTORE(); + return Z_NEED_DICT; + } + strm->adler = state->check = adler32(0L, NULL, 0); + state->mode = TYPE; + case TYPE: + if (flush == Z_BLOCK) goto inf_leave; + case TYPEDO: + if (state->last) + { + BYTEBITS(); + state->mode = CHECK; + break; + } + NEEDBITS(3); + state->last = BITS(1); + DROPBITS(1); + switch (BITS(2)) + { + case 0: /* stored block */ + state->mode = STORED; + break; + case 1: /* fixed block */ + fixedtables(state); + state->mode = LEN; /* decode codes */ + break; + case 2: /* dynamic block */ + state->mode = TABLE; + break; + case 3: + strm->msg = (char *)"invalid block type"; + state->mode = BAD; + } + DROPBITS(2); + break; + case STORED: + BYTEBITS(); /* go to byte boundary */ + NEEDBITS(32); + if ((hold & 0xffff) != ((hold >> 16) ^ 0xffff)) + { + strm->msg = (char *)"invalid stored block lengths"; + state->mode = BAD; + break; + } + state->length = (unsigned)hold & 0xffff; + INITBITS(); + state->mode = COPY; + case COPY: + copy = state->length; + if (copy) + { + if (copy > have) copy = have; + if (copy > left) copy = left; + if (copy == 0) goto inf_leave; + memcpy(put, next, copy); + have -= copy; + next += copy; + left -= copy; + put += copy; + state->length -= copy; + break; + } + state->mode = TYPE; + break; + case TABLE: + NEEDBITS(14); + state->nlen = BITS(5) + 257; + DROPBITS(5); + state->ndist = BITS(5) + 1; + DROPBITS(5); + state->ncode = BITS(4) + 4; + DROPBITS(4); + if (state->nlen > 286 || state->ndist > 30) + { + strm->msg = (char *)"too many length or distance symbols"; + state->mode = BAD; + break; + } + state->have = 0; + state->mode = LENLENS; + case LENLENS: + while (state->have < state->ncode) + { + NEEDBITS(3); + state->lens[order[state->have++]] = (unsigned short)BITS(3); + DROPBITS(3); + } + while (state->have < 19) state->lens[order[state->have++]] = 0; + state->next = state->codes; + state->lencode = (code const *)(state->next); + state->lenbits = 7; + ret = inflate_table(CODES, state->lens, 19, &(state->next), &(state->lenbits), state->work); + if (ret) + { + strm->msg = (char *)"invalid code lengths set"; + state->mode = BAD; + break; + } + state->have = 0; + state->mode = CODELENS; + case CODELENS: + while (state->have < state->nlen + state->ndist) + { + for (;;) + { + this = state->lencode[BITS(state->lenbits)]; + if ((unsigned)(this.bits) <= bits) break; + PULLBYTE(); + } + if (this.val < 16) + { + NEEDBITS(this.bits); + DROPBITS(this.bits); + state->lens[state->have++] = this.val; + } + else + { + if (this.val == 16) + { + NEEDBITS(this.bits + 2); + DROPBITS(this.bits); + if (state->have == 0) + { + strm->msg = (char *)"invalid bit length repeat"; + state->mode = BAD; + break; + } + len = state->lens[state->have - 1]; + copy = 3 + BITS(2); + DROPBITS(2); + } + else if (this.val == 17) + { + NEEDBITS(this.bits + 3); + DROPBITS(this.bits); + len = 0; + copy = 3 + BITS(3); + DROPBITS(3); + } + else + { + NEEDBITS(this.bits + 7); + DROPBITS(this.bits); + len = 0; + copy = 11 + BITS(7); + DROPBITS(7); + } + if (state->have + copy > state->nlen + state->ndist) + { + strm->msg = (char *)"invalid bit length repeat"; + state->mode = BAD; + break; + } + while (copy--) state->lens[state->have++] = (unsigned short)len; + } + } + + // handle error breaks in while + if (state->mode == BAD) break; + + // build code tables + state->next = state->codes; + state->lencode = (code const *)(state->next); + state->lenbits = 9; + ret = inflate_table(LENS, state->lens, state->nlen, &(state->next), &(state->lenbits), state->work); + if (ret) + { + strm->msg = (char *)"invalid literal/lengths set"; + state->mode = BAD; + break; + } + state->distcode = (code const *)(state->next); + state->distbits = 6; + ret = inflate_table(DISTS, state->lens + state->nlen, state->ndist, &(state->next), &(state->distbits), state->work); + if (ret) + { + strm->msg = (char *)"invalid distances set"; + state->mode = BAD; + break; + } + state->mode = LEN; + case LEN: + if (have >= 6 && left >= 258) + { + RESTORE(); + inflate_fast(strm, out); + LOAD(); + break; + } + for (;;) + { + this = state->lencode[BITS(state->lenbits)]; + if ((unsigned)(this.bits) <= bits) break; + PULLBYTE(); + } + if (this.op && (this.op & 0xf0) == 0) + { + last = this; + for (;;) + { + this = state->lencode[last.val + (BITS(last.bits + last.op) >> last.bits)]; + if ((unsigned)(last.bits + this.bits) <= bits) break; + PULLBYTE(); + } + DROPBITS(last.bits); + } + DROPBITS(this.bits); + state->length = (unsigned)this.val; + if ((int)(this.op) == 0) + { + state->mode = LIT; + break; + } + if (this.op & 32) + { + state->mode = TYPE; + break; + } + if (this.op & 64) + { + strm->msg = (char *)"invalid literal/length code"; + state->mode = BAD; + break; + } + state->extra = (unsigned)(this.op) & 15; + state->mode = LENEXT; + case LENEXT: + if (state->extra) + { + NEEDBITS(state->extra); + state->length += BITS(state->extra); + DROPBITS(state->extra); + } + state->mode = DIST; + case DIST: + for (;;) + { + this = state->distcode[BITS(state->distbits)]; + if ((unsigned)(this.bits) <= bits) break; + PULLBYTE(); + } + if ((this.op & 0xf0) == 0) + { + last = this; + for (;;) + { + this = state->distcode[last.val + (BITS(last.bits + last.op) >> last.bits)]; + if ((unsigned)(last.bits + this.bits) <= bits) break; + PULLBYTE(); + } + DROPBITS(last.bits); + } + DROPBITS(this.bits); + if (this.op & 64) + { + strm->msg = (char *)"invalid distance code"; + state->mode = BAD; + break; + } + state->offset = (unsigned)this.val; + state->extra = (unsigned)(this.op) & 15; + state->mode = DISTEXT; + case DISTEXT: + if (state->extra) + { + NEEDBITS(state->extra); + state->offset += BITS(state->extra); + DROPBITS(state->extra); + } + if (state->offset > state->whave + out - left) + { + strm->msg = (char *)"invalid distance too far back"; + state->mode = BAD; + break; + } + state->mode = MATCH; + case MATCH: + if (left == 0) goto inf_leave; + copy = out - left; + if (state->offset > copy) /* copy from window */ + { + copy = state->offset - copy; + if (copy > state->write) + { + copy -= state->write; + from = state->window + (state->wsize - copy); + } + else from = state->window + (state->write - copy); + if (copy > state->length) copy = state->length; + } + else /* copy from output */ + { + from = put - state->offset; + copy = state->length; + } + if (copy > left) copy = left; + left -= copy; + state->length -= copy; + do{ + *put++ = *from++; + }while (--copy); + if (state->length == 0) state->mode = LEN; + break; + case LIT: + if (left == 0) goto inf_leave; + *put++ = (unsigned char)(state->length); + left--; + state->mode = LEN; + break; + case CHECK: + if (state->wrap) + { + NEEDBITS(32); + out -= left; + strm->total_out += out; + state->total += out; + if (out) strm->adler = state->check = + UPDATE(state->check, put - out, out); + out = left; + if ((REVERSE(hold)) != state->check) + { + strm->msg = (char *)"incorrect data check"; + state->mode = BAD; + break; + } + INITBITS(); + } + state->mode = DONE; + case DONE: + ret = Z_STREAM_END; + goto inf_leave; + case BAD: + ret = Z_DATA_ERROR; + goto inf_leave; + case MEM: + return Z_MEM_ERROR; + case SYNC: + default: return Z_STREAM_ERROR; + } + + //Return from inflate(), updating the total counts and the check value. + //If there was no progress during the inflate() call, return a buffer + //error. Call updatewindow() to create and/or update the window state. + //Note: a memory error from inflate() is non-recoverable. + +inf_leave: + RESTORE(); + if (state->wsize || (state->mode < CHECK && out != strm->avail_out)) + if (updatewindow(strm, out)) + { + state->mode = MEM; + return Z_MEM_ERROR; + } + in -= strm->avail_in; + out -= strm->avail_out; + strm->total_in += in; + strm->total_out += out; + state->total += out; + if (state->wrap && out) strm->adler = state->check = UPDATE(state->check, strm->next_out - out, out); + strm->data_type = state->bits + (state->last ? 64 : 0) + (state->mode == TYPE ? 128 : 0); + if (((in == 0 && out == 0) || flush == Z_FINISH) && ret == Z_OK) ret = Z_BUF_ERROR; + return ret; +} + +int inflateEnd(z_streamp strm) +{ + struct inflate_state *state; + if (strm == NULL || strm->state == NULL || strm->zfree == NULL) + return Z_STREAM_ERROR; + state = (struct inflate_state *)strm->state; + if (state->window != NULL) ZipFree(strm, (byte*)state->window); + ZipFree(strm, (byte*)strm->state); + strm->state = NULL; + return Z_OK; +} + +int inflateReset(z_streamp strm) +{ + struct inflate_state *state; + + if (strm == NULL || strm->state == NULL) return Z_STREAM_ERROR; + state = (struct inflate_state *)strm->state; + strm->total_in = strm->total_out = state->total = 0; + strm->msg = (char *)"Ok"; // no errors + strm->adler = 1; // to support ill-conceived Java test suite + state->mode = HEAD; + state->last = 0; + state->havedict = 0; + state->dmax = 32768U; + state->head = NULL; + state->wsize = 0; + state->whave = 0; + state->write = 0; + state->hold = 0; + state->bits = 0; + state->lencode = state->distcode = state->next = state->codes; + return Z_OK; +} + +//======================================================================= +// DEFALTE STUFF +//======================================================================= +#define CLEAR_HASH(s) s->head[s->hash_size-1] = 0; memset((byte *)s->head, 0, (uint)(s->hash_size - 1) * sizeof(*s->head)); +#define UPDATE_HASH(s,h,c) (h = (((h)<hash_shift) ^ (c)) & s->hash_mask) +#define INSERT_STRING(s, str, match_head) (UPDATE_HASH(s, s->ins_h, s->window[(str) + (3-1)]), s->prev[(str) & s->w_mask] = match_head = s->head[s->ins_h], s->head[s->ins_h] = (word)(str)) + +typedef struct config_s +{ + word good_length; // reduce lazy search above this match length + word max_lazy; // do not perform lazy search above this match length + word nice_length; // quit search above this match length + word max_chain; + compress_func func; +} config; + +/* +========================================================================= +Flush as much pending output as possible. All deflate() output goes +through this function so some applications may wish to modify it +to avoid allocating a large strm->next_out buffer and copying into it. +(See also read_buf()). +========================================================================= +*/ +void flush_pending(z_streamp strm) +{ + uint len = strm->state->pending; + + if (len > strm->avail_out) len = strm->avail_out; + if (len == 0) return; + + Mem_Copy(strm->next_out, strm->state->pending_out, len); + strm->next_out += len; + strm->state->pending_out += len; + strm->total_out += len; + strm->avail_out -= len; + strm->state->pending -= len; + + if (strm->state->pending == 0) strm->state->pending_out = strm->state->pending_buf; +} + +/* +=========================================================================== +Read a new buffer from the current input stream, update the adler32 +and total number of bytes read. All deflate() input goes through +this function so some applications may wish to modify it to avoid +allocating a large strm->next_in buffer and copying from it. +(See also flush_pending()). +=========================================================================== +*/ +int read_buf(z_streamp strm, byte *buf, uint size) +{ + uint len = strm->avail_in; + + if(len > size) len = size; + if(len == 0) return 0; + + strm->avail_in -= len; + + if (!strm->state->noheader) + { + strm->adler = adler32(strm->adler, strm->next_in, len); + } + Mem_Copy(buf, strm->next_in, len); + strm->next_in += len; + strm->total_in += len; + + return (int)len; +} + +/* +=========================================================================== +Set match_start to the longest match starting at the given string and +return its length. Matches shorter or equal to prev_length are discarded, +in which case the result is equal to prev_length and match_start is +garbage. +IN assertions: cur_match is the head of the hash chain for the current +string (strstart) and its distance is <= MAX_DIST, and prev_length >= 1 +OUT assertion: the match length is not greater than s->lookahead. +=========================================================================== +*/ +uint longest_match(deflate_state *s, uint cur_match) +{ + uint chain_length = s->max_chain_length; // max hash chain length + register byte *scan = s->window + s->strstart; // current string + register byte *match; // matched string + register int len; // length of current match + int best_len = s->prev_length; // best match length so far + int nice_match = s->nice_match; // stop if match long enough + uint limit = s->strstart > (uint)MAX_DIST(s) ? s->strstart - (uint)MAX_DIST(s) : 0; + + // Stop when cur_match becomes <= limit. To simplify the code, + // we prevent matches with the string of window index 0. + word *prev = s->prev; + uint wmask = s->w_mask; + register byte *strend = s->window + s->strstart + 258; + register byte scan_end1 = scan[best_len-1]; + register byte scan_end = scan[best_len]; + + // The code is optimized for HASH_BITS >= 8 and MAX_MATCH-2 multiple of 16. + // It is easy to get rid of this optimization if necessary. + + // Do not waste too much time if we already have a good match: + if (s->prev_length >= s->good_match) + { + chain_length >>= 2; + } + + // Do not look for matches beyond the end of the input. This is necessary + // to make deflate deterministic. + if ((uint)nice_match > s->lookahead) nice_match = s->lookahead; + + do + { + match = s->window + cur_match; + // Skip to next match if the match length cannot increase + // or if the match length is less than 2: + + if(match[best_len] != scan_end || match[best_len-1] != scan_end1 || *match != *scan || *++match != scan[1]) + continue; + + // The check at best_len-1 can be removed because it will be made + // again later. (This heuristic is not always a win.) + // It is not necessary to compare scan[2] and match[2] since they + // are always equal when the other bytes match, given that + // the hash keys are equal and that HASH_BITS >= 8. + scan += 2, match++; + + // We check for insufficient lookahead only every 8th comparison; + // the 256th check will be made at strstart+258. + while (*++scan == *++match && *++scan == *++match && *++scan == *++match && *++scan == *++match && *++scan == *++match && *++scan == *++match && *++scan == *++match && *++scan == *++match && scan < strend); + len = 258 - (int)(strend - scan); + scan = strend - 258; + + if (len > best_len) + { + s->match_start = cur_match; + best_len = len; + if (len >= nice_match) break; + scan_end1 = scan[best_len-1]; + scan_end = scan[best_len]; + } + } while ((cur_match = prev[cur_match & wmask]) > limit && --chain_length != 0); + + if ((uint)best_len <= s->lookahead) return (uint)best_len; + return s->lookahead; +} + +/* +=========================================================================== +Fill the window when the lookahead becomes insufficient. +Updates strstart and lookahead. + +IN assertion: lookahead < MIN_LOOKAHEAD +OUT assertions: strstart <= window_size-MIN_LOOKAHEAD +At least one byte has been read, or avail_in == 0; reads are +performed for at least two bytes (required for the zip translate_eol +option -- not supported here). +=========================================================================== +*/ + +void fill_window(deflate_state *s) +{ + register uint n, m; + register word *p; + uint more; // Amount of free space at the end of the window. + uint wsize = s->w_size; + + do + { + more = (uint)(s->window_size -(dword)s->lookahead -(dword)s->strstart); + + // Deal with !@#$% 64K limit: + if (more == 0 && s->strstart == 0 && s->lookahead == 0) + { + more = wsize; + } + else if (more == (uint)(-1)) + { + // Very unlikely, but possible on 16 bit machine if strstart == 0 + // and lookahead == 1 (input done one byte at time) + more--; + // If the window is almost full and there is insufficient lookahead, + // move the upper half to the lower one to make room in the upper half. + } + else if (s->strstart >= wsize + MAX_DIST(s)) + { + Mem_Copy(s->window, s->window+wsize, (uint)wsize); + s->match_start -= wsize; + s->strstart -= wsize; // we now have strstart >= MAX_DIST + s->block_start -= (long) wsize; + + // Slide the hash table (could be avoided with 32 bit values + // at the expense of memory usage). We slide even when level == 0 + // to keep the hash table consistent if we switch back to level > 0 + // later. (Using level 0 permanently is not an optimal usage of + // zlib, so we don't care about this pathological case.) + n = s->hash_size; + p = &s->head[n]; + + do + { + m = *--p; + *p = (word)(m >= wsize ? m - wsize : 0); + } while (--n); + n = wsize; + p = &s->prev[n]; + + do + { + m = *--p; + *p = (word)(m >= wsize ? m-wsize : 0); + + // If n is not on any hash chain, prev[n] is garbage but + // its value will never be used. + } while (--n); + more += wsize; + } + if (s->strm->avail_in == 0) return; + + n = read_buf(s->strm, s->window + s->strstart + s->lookahead, more); + s->lookahead += n; + + // Initialize the hash value now that we have some input: + if (s->lookahead >= 3) + { + s->ins_h = s->window[s->strstart]; + UPDATE_HASH(s, s->ins_h, s->window[s->strstart+1]); + } + } while (s->lookahead < MIN_LOOKAHEAD && s->strm->avail_in != 0); +} + +//================= +// Huffman trees +//================= +struct static_tree_desc_s +{ + const ct_data *static_tree; // static tree or NULL + const int *extra_bits; // extra bits for each code or NULL + int extra_base; // base index for extra_bits + int elems; // max number of elements in the tree + int max_length; // max bit length for the codes +}; + +const int extra_lbits[LENGTH_CODES] = {0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0}; +const int extra_dbits[D_CODES] = {0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13}; +const int extra_blbits[BL_CODES] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7}; +const byte bl_order[BL_CODES] = {16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15}; + +const byte _length_code[258-3+1] = +{ + 0, 1, 2, 3, 4, 5, 6, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 12, 12, +13, 13, 13, 13, 14, 14, 14, 14, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16, +17, 17, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19, +19, 19, 19, 19, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, +21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 22, 22, 22, 22, +22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 23, 23, 23, 23, 23, 23, 23, 23, +23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, +24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, +25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, +25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 26, 26, 26, 26, 26, 26, 26, 26, +26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, +26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, +27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 28 +}; + +const byte _dist_code[512] = +{ + 0, 1, 2, 3, 4, 4, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, + 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, +10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, +11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, +12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13, +13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, +13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, +14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, +14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, +14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15, +15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, +15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, +15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 0, 0, 16, 17, +18, 18, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 22, 22, 22, 22, 22, 22, 22, 22, +23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, +24, 24, 24, 24, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, +26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, +26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27, +27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, +27, 27, 27, 27, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, +28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, +28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, +28, 28, 28, 28, 28, 28, 28, 28, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, +29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, +29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, +29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29 +}; + +const int base_length[LENGTH_CODES] = +{ +0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 12, 14, 16, 20, 24, 28, 32, 40, 48, 56, +64, 80, 96, 112, 128, 160, 192, 224, 0 +}; + +const int base_dist[D_CODES] = +{ + 0, 1, 2, 3, 4, 6, 8, 12, 16, 24, + 32, 48, 64, 96, 128, 192, 256, 384, 512, 768, + 1024, 1536, 2048, 3072, 4096, 6144, 8192, 12288, 16384, 24576 +}; + +ct_data static_ltree[L_CODES+2]; +ct_data static_dtree[D_CODES]; + +static_tree_desc static_l_desc = { static_ltree, extra_lbits, LITERALS+1, L_CODES, MAX_WBITS }; +static_tree_desc static_d_desc = { static_dtree, extra_dbits, 0, D_CODES, MAX_WBITS}; +static_tree_desc static_bl_desc ={(const ct_data *)0, extra_blbits, 0, BL_CODES, 7 }; + +#define Freq fc.freq +#define Code fc.code +#define Dad dl.dad +#define Len dl.len +#define Buf_size (8 * 2 * sizeof(char)) +#define d_code(dist) ((dist) < 256 ? _dist_code[dist] : _dist_code[256+((dist)>>7)]) + +#define _tr_tally_lit(s, c, flush) \ + { byte cc = (c); \ + s->d_buf[s->last_lit] = 0; \ + s->l_buf[s->last_lit++] = cc; \ + s->dyn_ltree[cc].Freq++; \ + flush = (s->last_lit == s->lit_bufsize-1); \ + } + +#define _tr_tally_dist(s, distance, length, flush) \ + { byte len = (length); \ + word dist = (distance); \ + s->d_buf[s->last_lit] = dist; \ + s->l_buf[s->last_lit++] = len; \ + dist--; \ + s->dyn_ltree[_length_code[len]+LITERALS+1].Freq++; \ + s->dyn_dtree[d_code(dist)].Freq++; \ + flush = (s->last_lit == s->lit_bufsize-1); \ + } + +#define send_bits(s, value, length) \ + { int len = length; \ + if (s->bi_valid > (int)Buf_size - len) \ + { int val = value; \ + s->bi_buf |= (val << s->bi_valid); \ + put_short(s, s->bi_buf); \ + s->bi_buf = (word)val >> (Buf_size - s->bi_valid); \ + s->bi_valid += len - Buf_size; \ + } else { \ + s->bi_buf |= (value) << s->bi_valid; \ + s->bi_valid += len; \ + } \ +} + +#define send_code(s, c, tree) send_bits(s, tree[c].Code, tree[c].Len) + +// Flush the bit buffer and align the output on a byte boundary +void bi_windup(deflate_state *s) +{ + if (s->bi_valid > 8) + { + put_short(s, s->bi_buf); + } + else if (s->bi_valid > 0) + { + put_byte(s, (byte)s->bi_buf); + } + s->bi_buf = 0; + s->bi_valid = 0; +} + +// Flush the bit buffer, keeping at most 7 bits in it. +void bi_flush(deflate_state *s) +{ + if (s->bi_valid == 16) + { + put_short(s, s->bi_buf); + s->bi_buf = 0; + s->bi_valid = 0; + } + else if (s->bi_valid >= 8) + { + put_byte(s, (byte)s->bi_buf); + s->bi_buf >>= 8; + s->bi_valid -= 8; + } +} + +/* +=========================================================================== +Reverse the first len bits of a code, using straightforward code (a faster +method would use a table) +IN assertion: 1 <= len <= 15 +=========================================================================== +*/ +uint bi_reverse(uint code, int len) +{ + register uint res = 0; + + do + { + res |= code & 1; + code >>= 1, res <<= 1; + } while (--len > 0); + + return res >> 1; +} + +// Initialize a new block. +void init_block(deflate_state *s) +{ + int n; // iterates over tree elements + + // Initialize the trees. + for (n = 0; n < L_CODES; n++) s->dyn_ltree[n].Freq = 0; + for (n = 0; n < D_CODES; n++) s->dyn_dtree[n].Freq = 0; + for (n = 0; n < BL_CODES; n++) s->bl_tree[n].Freq = 0; + + s->dyn_ltree[256].Freq = 1; + s->opt_len = s->static_len = 0L; + s->last_lit = s->matches = 0; +} + +// Copy a stored block, storing first the length and its +// one's complement if requested. +void copy_block(deflate_state *s, char *buf, uint len, int header) +{ + bi_windup(s); /* align on byte boundary */ + s->last_eob_len = 8; /* enough lookahead for inflate */ + + if (header) + { + put_short(s, (word)len); + put_short(s, (word)~len); + } + while (len--){ put_byte(s, *buf++); } +} + + +// Initialize the various 'constant' tables. +void _tr_init(deflate_state *s) +{ + s->l_desc.dyn_tree = s->dyn_ltree; + s->l_desc.stat_desc = &static_l_desc; + s->d_desc.dyn_tree = s->dyn_dtree; + s->d_desc.stat_desc = &static_d_desc; + + s->bl_desc.dyn_tree = s->bl_tree; + s->bl_desc.stat_desc = &static_bl_desc; + + s->bi_buf = 0; + s->bi_valid = 0; + s->last_eob_len = 8; /* enough lookahead for inflate */ + + // Initialize the first block of the first file: + init_block(s); +} + +/* +=========================================================================== +Send a literal or distance tree in compressed form, using the codes in +bl_tree. +=========================================================================== +*/ +void send_tree(deflate_state *s, ct_data *tree,int max_code) +{ + int n; // iterates over all tree elements + int prevlen = -1; // last emitted length + int curlen; // length of current code + int nextlen = tree[0].Len; // length of next code + int count = 0; // repeat count of the current code + int max_count = 7; // max repeat count + int min_count = 4; // min repeat count + + if (nextlen == 0) max_count = 138, min_count = 3; + + for (n = 0; n <= max_code; n++) + { + curlen = nextlen; nextlen = tree[n+1].Len; + if (++count < max_count && curlen == nextlen) + continue; + else if (count < min_count) + { + do { send_code(s, curlen, s->bl_tree); } while (--count != 0); + } + else if (curlen != 0) + { + if (curlen != prevlen) + { + send_code(s, curlen, s->bl_tree); + count--; + } + send_code(s, 16, s->bl_tree); send_bits(s, count-3, 2); + } + else if (count <= 10) + { + send_code(s, 17, s->bl_tree); send_bits(s, count-3, 3); + } + else + { + send_code(s, 18, s->bl_tree); send_bits(s, count-11, 7); + } + count = 0; + prevlen = curlen; + + if (nextlen == 0) + { + max_count = 138, min_count = 3; + } + else if (curlen == nextlen) + { + max_count = 6, min_count = 3; + } + else + { + max_count = 7, min_count = 4; + } + } +} + + +/* +=========================================================================== +Send the header for a block using dynamic Huffman trees: the counts, the +lengths of the bit length codes, the literal tree and the distance tree. +IN assertion: lcodes >= 257, dcodes >= 1, blcodes >= 4. +=========================================================================== +*/ +void send_all_trees(deflate_state *s, int lcodes, int dcodes, int blcodes) +{ + int rank;// index in bl_order + + send_bits(s, lcodes-257, 5); // not +255 as stated in appnote.txt + send_bits(s, dcodes-1, 5); + send_bits(s, blcodes-4, 4); // not -3 as stated in appnote.txt + + for (rank = 0; rank < blcodes; rank++) + { + send_bits(s, s->bl_tree[bl_order[rank]].Len, 3); + } + send_tree(s, (ct_data *)s->dyn_ltree, lcodes-1); /* literal tree */ + send_tree(s, (ct_data *)s->dyn_dtree, dcodes-1); /* distance tree */ +} + +void _tr_stored_block(deflate_state *s, char *buf, dword stored_len, int eof) +{ + send_bits(s, (STORED_BLOCK<<1)+eof, 3); // send block type + copy_block(s, buf, (uint)stored_len, 1); // with header +} + +void _tr_align(deflate_state *s) +{ + send_bits(s, STATIC_TREES<<1, 3); + send_code(s, 256, static_ltree); + bi_flush(s); + if (1 + s->last_eob_len + 10 - s->bi_valid < 9) + { + send_bits(s, STATIC_TREES<<1, 3); + send_code(s, 256, static_ltree); + bi_flush(s); + } + s->last_eob_len = 7; +} + +/* +=========================================================================== +Remove the smallest element from the heap and recreate the heap with +one less element. Updates heap and heap_len. +=========================================================================== +*/ +#define pqremove(s, tree, top) \ + { top = s->heap[1]; \ + s->heap[1] = s->heap[s->heap_len--]; \ + pqdownheap(s, tree, 1); \ + } + +/* +=========================================================================== +Compares to subtrees, using the tree depth as tie breaker when +the subtrees have equal frequency. This minimizes the worst case length. +=========================================================================== +*/ +#define smaller(tree, n, m, depth) (tree[n].Freq < tree[m].Freq || (tree[n].Freq == tree[m].Freq && depth[n] <= depth[m])) + +/* +=========================================================================== +Restore the heap property by moving down the tree starting at node k, +exchanging a node with the smallest of its two sons if necessary, stopping +when the heap property is re-established (each father smaller than its +two sons). +=========================================================================== +*/ +void pqdownheap(deflate_state *s, ct_data *tree, int k) +{ + int v = s->heap[k]; + int j = k << 1; // left son of k + + while (j <= s->heap_len) + { + // Set j to the smallest of the two sons: + if (j < s->heap_len && smaller(tree, s->heap[j+1], s->heap[j], s->depth)) j++; + + // Exit if v is smaller than both sons + if (smaller(tree, v, s->heap[j], s->depth)) break; + + // Exchange v with the smallest son + s->heap[k] = s->heap[j]; + k = j; + + // And continue down the tree, setting j to the left son of k + j <<= 1; + } + s->heap[k] = v; +} + +/* +=========================================================================== +Compute the optimal bit lengths for a tree and update the total bit length +for the current block. +IN assertion: the fields freq and dad are set, heap[heap_max] and +above are the tree nodes sorted by increasing frequency. +OUT assertions: the field len is set to the optimal bit length, the +array bl_count contains the frequencies for each bit length. +The length opt_len is updated; static_len is also updated if stree is +not null. +=========================================================================== +*/ +void gen_bitlen(deflate_state *s, tree_desc *desc) +{ + ct_data *tree = desc->dyn_tree; + int max_code = desc->max_code; + const ct_data *stree = desc->stat_desc->static_tree; + const int *extra = desc->stat_desc->extra_bits; + int base = desc->stat_desc->extra_base; + int max_length = desc->stat_desc->max_length; + int h; // heap index + int n, m; // iterate over the tree elements + int bits; // bit length + int xbits; // extra bits + word f; // frequency + int overflow = 0; // number of elements with bit length too large + + for (bits = 0; bits <= MAX_WBITS; bits++) s->bl_count[bits] = 0; + + // In a first pass, compute the optimal bit lengths (which may + // overflow in the case of the bit length tree). + tree[s->heap[s->heap_max]].Len = 0; // root of the heap + + for (h = s->heap_max+1; h < HEAP_SIZE; h++) + { + n = s->heap[h]; + bits = tree[tree[n].Dad].Len + 1; + if (bits > max_length) bits = max_length, overflow++; + tree[n].Len = (word)bits; + + // We overwrite tree[n].Dad which is no longer needed + if (n > max_code) continue; // not a leaf node + + s->bl_count[bits]++; + xbits = 0; + if (n >= base) xbits = extra[n-base]; + f = tree[n].Freq; + s->opt_len += (dword)f * (bits + xbits); + if (stree) s->static_len += (dword)f * (stree[n].Len + xbits); + } + if (overflow == 0) return; + + // Find the first bit length which could increase: + do + { + bits = max_length-1; + while (s->bl_count[bits] == 0) bits--; + s->bl_count[bits]--; // move one leaf down the tree + s->bl_count[bits+1] += 2; // move one overflow item as its brother + s->bl_count[max_length]--; + + // The brother of the overflow item also moves one step up, + // but this does not affect bl_count[max_length] + overflow -= 2; + } while (overflow > 0); + + // Now recompute all bit lengths, scanning in increasing frequency. + // h is still equal to HEAP_SIZE. (It is simpler to reconstruct all + // lengths instead of fixing only the wrong ones. This idea is taken + // from 'ar' written by Haruhiko Okumura.) + + for (bits = max_length; bits != 0; bits--) + { + n = s->bl_count[bits]; + while (n != 0) + { + m = s->heap[--h]; + if (m > max_code) continue; + if (tree[m].Len != (uint) bits) + { + s->opt_len += ((long)bits - (long)tree[m].Len) * (long)tree[m].Freq; + tree[m].Len = (word)bits; + } + n--; + } + } +} + +/* +=========================================================================== +Generate the codes for a given tree and bit counts (which need not be +optimal). +IN assertion: the array bl_count contains the bit length statistics for +the given tree and the field len is set for all tree elements. +OUT assertion: the field code is set for all tree elements of non +zero code length. +=========================================================================== +*/ + +void gen_codes (ct_data *tree, int max_code, word *bl_count) +{ + word next_code[MAX_WBITS+1]; // next code value for each bit length + word code = 0; // running code value + int bits; // bit index + int n; // code index + + // The distribution counts are first used to generate the code values + // without bit reversal. + for (bits = 1; bits <= MAX_WBITS; bits++) + { + next_code[bits] = code = (code + bl_count[bits-1]) << 1; + } + + // Check that the bit counts in bl_count are consistent. The last code + // must be all ones. + for (n = 0; n <= max_code; n++) + { + int len = tree[n].Len; + + if (len == 0) continue; + // Now reverse the bits + tree[n].Code = bi_reverse(next_code[len]++, len); + } +} + +/* +=========================================================================== +Construct one Huffman tree and assigns the code bit strings and lengths. +Update the total bit length for the current block. +IN assertion: the field freq is set for all tree elements. +OUT assertions: the fields len and code are set to the optimal bit length +and corresponding code. The length opt_len is updated; static_len is +also updated if stree is not null. The field max_code is set. +=========================================================================== +*/ +void build_tree(deflate_state *s, tree_desc *desc) +{ + ct_data *tree = desc->dyn_tree; + const ct_data *stree = desc->stat_desc->static_tree; + int elems = desc->stat_desc->elems; + int n, m; // iterate over heap elements + int max_code = -1; // largest code with non zero frequency + int node; // new node being created + + // Construct the initial heap, with least frequent element in + // heap[SMALLEST]. The sons of heap[n] are heap[2*n] and heap[2*n+1]. + // heap[0] is not used. + s->heap_len = 0, s->heap_max = HEAP_SIZE; + + for (n = 0; n < elems; n++) + { + if (tree[n].Freq != 0) + { + s->heap[++(s->heap_len)] = max_code = n; + s->depth[n] = 0; + } + else tree[n].Len = 0; + } + + // The pkzip format requires that at least one distance code exists, + // and that at least one bit should be sent even if there is only one + // possible code. So to avoid special checks later on we force at least + // two codes of non zero frequency. + + while (s->heap_len < 2) + { + node = s->heap[++(s->heap_len)] = (max_code < 2 ? ++max_code : 0); + tree[node].Freq = 1; + s->depth[node] = 0; + s->opt_len--; if (stree) s->static_len -= stree[node].Len; + // node is 0 or 1 so it does not have extra bits + } + desc->max_code = max_code; + + // The elements heap[heap_len/2+1 .. heap_len] are leaves of the tree, + // establish sub-heaps of increasing lengths: + + for (n = s->heap_len/2; n >= 1; n--) pqdownheap(s, tree, n); + + // Construct the Huffman tree by repeatedly combining the least two + // frequent nodes. + + node = elems; // next internal node of the tree + + do + { + pqremove(s, tree, n); // n = node of least frequency + m = s->heap[1]; // m = node of next least frequency + + s->heap[--(s->heap_max)] = n; // keep the nodes sorted by frequency + s->heap[--(s->heap_max)] = m; + + // Create a new node father of n and m + tree[node].Freq = tree[n].Freq + tree[m].Freq; + s->depth[node] = (byte) (max(s->depth[n], s->depth[m]) + 1); + tree[n].Dad = tree[m].Dad = (word)node; + // and insert the new node in the heap + s->heap[1] = node++; + pqdownheap(s, tree, 1); + } while (s->heap_len >= 2); + + s->heap[--(s->heap_max)] = s->heap[1]; + + // At this point, the fields freq and dad are set. We can now + // generate the bit lengths. + gen_bitlen(s, (tree_desc *)desc); + + //The field len is now set, we can generate the bit codes + gen_codes ((ct_data *)tree, max_code, s->bl_count); +} + +/* +=========================================================================== +Scan a literal or distance tree to determine the frequencies of the codes +in the bit length tree. +=========================================================================== +*/ +void scan_tree (deflate_state *s, ct_data *tree, int max_code) +{ + int n; // iterates over all tree elements + int prevlen = -1; // last emitted length + int curlen; // length of current code + int nextlen = tree[0].Len; // length of next code + int count = 0; // repeat count of the current code + int max_count = 7; // max repeat count + int min_count = 4; // min repeat count + + if (nextlen == 0) max_count = 138, min_count = 3; + tree[max_code+1].Len = (word)0xffff; // guard + + for (n = 0; n <= max_code; n++) + { + curlen = nextlen; nextlen = tree[n+1].Len; + if (++count < max_count && curlen == nextlen) + continue; + else if (count < min_count) + { + s->bl_tree[curlen].Freq += count; + } + else if (curlen != 0) + { + if (curlen != prevlen) + s->bl_tree[curlen].Freq++; + s->bl_tree[16].Freq++; + } + else if (count <= 10) + { + s->bl_tree[17].Freq++; + } + else + { + s->bl_tree[18].Freq++; + } + count = 0; + prevlen = curlen; + + if (nextlen == 0) + { + max_count = 138, min_count = 3; + } + else if (curlen == nextlen) + { + max_count = 6, min_count = 3; + } + else + { + max_count = 7, min_count = 4; + } + } +} + +/* +=========================================================================== +Construct the Huffman tree for the bit lengths and return the index in +bl_order of the last bit length code to send. +=========================================================================== +*/ +int build_bl_tree(deflate_state *s) +{ + int max_blindex; // index of last bit length code of non zero freq + + // Determine the bit length frequencies for literal and distance trees + scan_tree(s, (ct_data *)s->dyn_ltree, s->l_desc.max_code); + scan_tree(s, (ct_data *)s->dyn_dtree, s->d_desc.max_code); + + // Build the bit length tree: + build_tree(s, (tree_desc *)(&(s->bl_desc))); + for (max_blindex = BL_CODES-1; max_blindex >= 3; max_blindex--) + { + if (s->bl_tree[bl_order[max_blindex]].Len != 0) break; + } + + // Update opt_len to include the bit length tree and counts + s->opt_len += 3*(max_blindex+1) + 5+5+4; + + return max_blindex; +} + +/* +=========================================================================== +Set the data type to ASCII or BINARY, using a crude approximation: +binary if more than 20% of the bytes are <= 6 or >= 128, ascii otherwise. +IN assertion: the fields freq of dyn_ltree are set and the total of all +frequencies does not exceed 64K (to fit in an int on 16 bit machines). +=========================================================================== +*/ +void set_data_type(deflate_state *s) +{ + int n = 0; + uint ascii_freq = 0; + uint bin_freq = 0; + + while (n < 7) bin_freq += s->dyn_ltree[n++].Freq; + while (n < 128) ascii_freq += s->dyn_ltree[n++].Freq; + while (n < LITERALS) bin_freq += s->dyn_ltree[n++].Freq; + s->data_type = (byte)(bin_freq > (ascii_freq >> 2) ? Z_BINARY : Z_ASCII); +} + +/* +=========================================================================== +Send the block data compressed using the given Huffman trees +=========================================================================== +*/ +void compress_block(deflate_state *s, ct_data *ltree, ct_data *dtree) +{ + uint dist; // distance of matched string + int lc; // match length or unmatched char (if dist == 0) + uint lx = 0; // running index in l_buf + uint code; // the code to send + int extra; // number of extra bits to send + + if (s->last_lit != 0) + { + do + { + dist = s->d_buf[lx]; + lc = s->l_buf[lx++]; + if (dist == 0) + { + send_code(s, lc, ltree); // send a literal byte + } + else + { + // Here, lc is the match length - MIN_MATCH + code = _length_code[lc]; + send_code(s, code+LITERALS+1, ltree); // send the length code + extra = extra_lbits[code]; + if (extra != 0) + { + lc -= base_length[code]; + send_bits(s, lc, extra); // send the extra length bits + } + + dist--; // dist is now the match distance - 1 + code = d_code(dist); + send_code(s, code, dtree); // send the distance code + extra = extra_dbits[code]; + + if (extra != 0) + { + dist -= base_dist[code]; + send_bits(s, dist, extra); // send the extra distance bits + } + } // literal or match pair ? + + // Check that the overlay between pending_buf and d_buf+l_buf is ok: + } while (lx < s->last_lit); + } + + send_code(s, 256, ltree); + s->last_eob_len = ltree[256].Len; +} + +/* +=========================================================================== +Determine the best encoding for the current block: dynamic trees, static +trees or store, and output the encoded block to the zip file. +=========================================================================== +*/ +void _tr_flush_block(deflate_state *s, char *buf, dword stored_len, int eof) +{ + dword opt_lenb, static_lenb; // opt_len and static_len in bytes + int max_blindex = 0; // index of last bit length code of non zero freq + + // Build the Huffman trees unless a stored block is forced + if (s->level > 0) + { + // Check if the file is ascii or binary + if (s->data_type == Z_UNKNOWN) set_data_type(s); + + // Construct the literal and distance trees + build_tree(s, (tree_desc *)(&(s->l_desc))); + build_tree(s, (tree_desc *)(&(s->d_desc))); + max_blindex = build_bl_tree(s); + opt_lenb = (s->opt_len+3+7)>>3; + static_lenb = (s->static_len+3+7)>>3; + + if (static_lenb <= opt_lenb) opt_lenb = static_lenb; + } + else + { + opt_lenb = static_lenb = stored_len + 5; /* force a stored block */ + } + + if (stored_len+4 <= opt_lenb && buf != NULL) + { + _tr_stored_block(s, buf, stored_len, eof); + } + else if (static_lenb == opt_lenb) + { + send_bits(s, (STATIC_TREES<<1)+eof, 3); + compress_block(s, (ct_data *)static_ltree, (ct_data *)static_dtree); + } + else + { + send_bits(s, (DYN_TREES<<1)+eof, 3); + send_all_trees(s, s->l_desc.max_code+1, s->d_desc.max_code+1, max_blindex+1); + compress_block(s, (ct_data *)s->dyn_ltree, (ct_data *)s->dyn_dtree); + } + + init_block(s); + + if (eof) + { + bi_windup(s); + } +} + +int deflateInit_(z_streamp strm, int level, const char *version, int stream_size) +{ + return deflateInit2_(strm, level, MAX_WBITS, version, stream_size); +} + +/* ========================================================================= */ +int deflateInit2_(z_streamp strm, int level, int windowBits, const char *version, int stream_size) +{ + deflate_state *s; + int noheader = 0; + word *overlay; + + // defalte settings + int method = Z_DEFLATED; + int memLevel = DEF_MEM_LEVEL; + int strategy = Z_DEFAULT_STRATEGY; + + if (version == NULL || version[0] != ZLIB_VERSION[0] || stream_size != sizeof(z_stream)) + return Z_VERSION_ERROR; + + if (strm == NULL) return Z_STREAM_ERROR; + strm->msg = NULL; + + if(strm->zalloc == NULL) + { + strm->zalloc = zcalloc; + strm->opaque = NULL; + } + if(strm->zfree == NULL) strm->zfree = zcfree; + + if (level == Z_DEFAULT_COMPRESSION) level = 6; + + if (windowBits < 0) + { + // undocumented feature: suppress zlib header + noheader = 1; + windowBits = -windowBits; + } + + // bound some parms + level = bound( 0, level, 9 ); + windowBits = bound( 8, windowBits, 15 ); + strategy = bound( 0, strategy, Z_HUFFMAN_ONLY ); + + if (method != Z_DEFLATED) return Z_STREAM_ERROR; + + s = (deflate_state *) ZipAlloc(strm, 1, sizeof(deflate_state)); + if (s ==NULL) return Z_MEM_ERROR; + strm->state = (struct int_state *)s; + s->strm = strm; + + s->noheader = noheader; + s->w_bits = windowBits; + s->w_size = 1 << s->w_bits; + s->w_mask = s->w_size - 1; + + s->hash_bits = memLevel + 7; + s->hash_size = 1 << s->hash_bits; + s->hash_mask = s->hash_size - 1; + s->hash_shift = ((s->hash_bits + 3 - 1)/3); // align 3 + + s->window = (byte *) ZipAlloc(strm, s->w_size, 2 * sizeof(byte)); + s->prev = (word *)ZipAlloc(strm, s->w_size, sizeof(word)); + s->head = (word *)ZipAlloc(strm, s->hash_size, sizeof(word)); + + s->lit_bufsize = 1 << (memLevel + 6); // 16K elements by default + + overlay = (word *)ZipAlloc(strm, s->lit_bufsize, sizeof(word) + 2); + s->pending_buf = (byte *)overlay; + s->pending_buf_size = (dword)s->lit_bufsize * (sizeof(word) + 2L); + + if (s->window == NULL || s->prev == NULL || s->head == NULL || s->pending_buf == NULL) + { + strm->msg = (char*)"insufficient memory"; + deflateEnd (strm); + return Z_MEM_ERROR; + } + + s->d_buf = overlay + s->lit_bufsize/sizeof(word); + s->l_buf = s->pending_buf + (1+sizeof(word))*s->lit_bufsize; + + s->level = level; + s->strategy = strategy; + s->method = (byte)method; + + return deflateReset(strm); +} + +/* =========================================================================== + * Flush the current block, with given end-of-file flag. + * IN assertion: strstart is set to the end of the current match. + */ +#define FLUSH_BLOCK_ONLY(s, eof) \ + { \ + _tr_flush_block(s, (s->block_start >= 0L ? \ + (char *)&s->window[(uint)s->block_start] : \ + (char *)NULL), \ + (dword)((long)s->strstart - s->block_start), \ + (eof)); \ + s->block_start = s->strstart; \ + flush_pending(s->strm); \ + } \ + +/* Same but force premature exit if necessary. */ +#define FLUSH_BLOCK(s, eof) \ + { \ + FLUSH_BLOCK_ONLY(s, eof); \ + if (s->strm->avail_out == 0) return (eof) ? finish_started : need_more; \ + } \ + +block_state deflate_copy(deflate_state *s, int flush) +{ + /* Stored blocks are limited to 0xffff bytes, pending_buf is limited + * to pending_buf_size, and each stored block has a 5 byte header: + */ + dword max_block_size = 0xffff; + dword max_start; + + if (max_block_size > s->pending_buf_size - 5) + { + max_block_size = s->pending_buf_size - 5; + } + + // Copy as much as possible from input to output: + while ( 1 ) + { + // Fill the window as much as possible: + if (s->lookahead <= 1) + { + fill_window(s); + if (s->lookahead == 0 && flush == Z_NO_FLUSH) return need_more; + if (s->lookahead == 0) break; // flush the current block + } + s->strstart += s->lookahead; + s->lookahead = 0; + + // Emit a stored block if pending_buf will be full: + max_start = s->block_start + max_block_size; + if (s->strstart == 0 || (dword)s->strstart >= max_start) + { + // strstart == 0 is possible when wraparound on 16-bit machine + s->lookahead = (uint)(s->strstart - max_start); + s->strstart = (uint)max_start; + FLUSH_BLOCK(s, 0); + } + // Flush if we may have to slide, otherwise block_start may become + // negative and the data will be gone: + if (s->strstart - (uint)s->block_start >= MAX_DIST(s)) + { + FLUSH_BLOCK(s, 0); + } + } + + FLUSH_BLOCK(s, flush == Z_FINISH); + return flush == Z_FINISH ? finish_done : block_done; +} + +/* +=========================================================================== + Compress as much as possible from the input stream, return the current + block state. + This function does not perform lazy evaluation of matches and inserts + new strings in the dictionary only for unmatched strings or for short + matches. It is used only for the fast compression options. +=========================================================================== +*/ +block_state deflate_fast(deflate_state *s, int flush) +{ + uint hash_head = 0; // head of the hash chain + int bflush; // set if current block must be flushed + + while ( 1 ) + { + // Make sure that we always have enough lookahead, except + // at the end of the input file. We need MAX_MATCH bytes + // for the next match, plus MIN_MATCH bytes to insert the + // string following the next match. + if (s->lookahead < MIN_LOOKAHEAD) + { + fill_window(s); + if (s->lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH) + return need_more; + } + if (s->lookahead == 0) break; // flush the current block + + // Insert the string window[strstart .. strstart+2] in the + // dictionary, and set hash_head to the head of the hash chain: + if(s->lookahead >= 3) + { + INSERT_STRING(s, s->strstart, hash_head); + } + + // Find the longest match, discarding those <= prev_length. + // At this point we have always match_length < MIN_MATCH + + if (hash_head && s->strstart - hash_head <= MAX_DIST(s)) + { + // To simplify the code, we prevent matches with the string + // of window index 0 (in particular we have to avoid a match + // of the string with itself at the start of the input file). + if (s->strategy != Z_HUFFMAN_ONLY) + { + s->match_length = longest_match (s, hash_head); + } + // longest_match() sets match_start + } + if (s->match_length >= 3) + { + _tr_tally_dist(s, s->strstart - s->match_start, s->match_length - 3, bflush); + s->lookahead -= s->match_length; + + // Insert new strings in the hash table only if the match length + // is not too large. This saves time but degrades compression. + if (s->match_length <= s->max_lazy_match && s->lookahead >= 3) + { + s->match_length--; // string at strstart already in hash table + do { + s->strstart++; + INSERT_STRING(s, s->strstart, hash_head); + // strstart never exceeds WSIZE-MAX_MATCH, so there are + // always MIN_MATCH bytes ahead. + } while (--s->match_length != 0); + s->strstart++; + } + else + { + s->strstart += s->match_length; + s->match_length = 0; + s->ins_h = s->window[s->strstart]; + UPDATE_HASH(s, s->ins_h, s->window[s->strstart+1]); + // If lookahead < MIN_MATCH, ins_h is garbage, but it does not + // matter since it will be recomputed at next deflate call. + } + } + else + { + // No match, output a literal byte + _tr_tally_lit (s, s->window[s->strstart], bflush); + s->lookahead--; + s->strstart++; + } + if (bflush) FLUSH_BLOCK(s, 0); + } + + FLUSH_BLOCK(s, flush == Z_FINISH); + return flush == Z_FINISH ? finish_done : block_done; +} + +/* +=========================================================================== + Same as above, but achieves better compression. We use a lazy + evaluation for matches: a match is finally adopted only if there is + no better match at the next window position. +=========================================================================== +*/ +block_state deflate_slow(deflate_state *s, int flush) +{ + uint hash_head = 0; // head of hash chain + int bflush; // set if current block must be flushed + + // Process the input block. + + while( 1 ) + { + // Make sure that we always have enough lookahead, except + // at the end of the input file. We need MAX_MATCH bytes + // for the next match, plus MIN_MATCH bytes to insert the + // string following the next match. + + if (s->lookahead < MIN_LOOKAHEAD) + { + fill_window(s); + if (s->lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH) + { + return need_more; + } + if (s->lookahead == 0) break; // flush the current block + } + + // Insert the string window[strstart .. strstart+2] in the + // dictionary, and set hash_head to the head of the hash chain: + + if (s->lookahead >= 3) + { + INSERT_STRING(s, s->strstart, hash_head); + } + + // Find the longest match, discarding those <= prev_length. + s->prev_length = s->match_length, s->prev_match = s->match_start; + s->match_length = 3-1; + + if (hash_head && s->prev_length < s->max_lazy_match && s->strstart - hash_head <= MAX_DIST(s)) + { + // To simplify the code, we prevent matches with the string + // of window index 0 (in particular we have to avoid a match + // of the string with itself at the start of the input file). + if (s->strategy != Z_HUFFMAN_ONLY) + { + s->match_length = longest_match (s, hash_head); + } + // longest_match() sets match_start + if (s->match_length <= 5 && (s->strategy == Z_FILTERED || (s->match_length == 3 && s->strstart - s->match_start > 4096))) + { + // If prev_match is also MIN_MATCH, match_start is garbage + // but we will ignore the current match anyway. + s->match_length = 3 - 1; + } + } + // If there was a match at the previous step and the current + // match is not better, output the previous match: + if (s->prev_length >= 3 && s->match_length <= s->prev_length) + { + uint max_insert = s->strstart + s->lookahead - 3; + // Do not insert strings in hash table beyond this. + _tr_tally_dist(s, s->strstart -1 - s->prev_match, s->prev_length - 3, bflush); + + // Insert in hash table all strings up to the end of the match. + // strstart-1 and strstart are already inserted. If there is not + // enough lookahead, the last two strings are not inserted in + // the hash table. + s->lookahead -= s->prev_length-1; + s->prev_length -= 2; + + do + { + if (++s->strstart <= max_insert) + { + INSERT_STRING(s, s->strstart, hash_head); + } + } while (--s->prev_length != 0); + + s->match_available = 0; + s->match_length = 3 - 1; + s->strstart++; + if (bflush) FLUSH_BLOCK(s, 0); + + } + else if (s->match_available) + { + // If there was no match at the previous position, output a + // single literal. If there was a match but the current match + // is longer, truncate the previous match to a single literal. + _tr_tally_lit(s, s->window[s->strstart-1], bflush); + if (bflush) + { + FLUSH_BLOCK_ONLY(s, 0); + } + s->strstart++; + s->lookahead--; + if (s->strm->avail_out == 0) return need_more; + } + else + { + // There is no previous match to compare with, wait for + // the next step to decide. + s->match_available = 1; + s->strstart++; + s->lookahead--; + } + } + + if (s->match_available) + { + _tr_tally_lit(s, s->window[s->strstart-1], bflush); + s->match_available = 0; + } + + FLUSH_BLOCK(s, flush == Z_FINISH); + return flush == Z_FINISH ? finish_done : block_done; +} + +const config configuration_table[10] = +{ +{0, 0, 0, 0, deflate_copy}, // store only +{4, 4, 8, 4, deflate_fast}, // maximum speed, no lazy matches +{4, 5, 16, 8, deflate_fast}, +{4, 6, 32, 32, deflate_fast}, +{4, 4, 16, 16, deflate_slow}, // lazy matches +{8, 16, 32, 32, deflate_slow}, +{8, 16, 128,128, deflate_slow}, +{8, 32, 128,256, deflate_slow}, +{32,128,258,1024, deflate_slow}, +{32,258,258,4096, deflate_slow} // maximum compression +}; + +/* +=========================================================================== +Initialize the "longest match" routines for a new zlib stream +=========================================================================== +*/ +void lm_init (deflate_state *s) +{ + s->window_size = (dword)2L * s->w_size; + CLEAR_HASH(s); + + // Set the default configuration parameters: + + s->max_lazy_match = configuration_table[s->level].max_lazy; + s->good_match = configuration_table[s->level].good_length; + s->nice_match = configuration_table[s->level].nice_length; + s->max_chain_length = configuration_table[s->level].max_chain; + + s->strstart = 0; + s->block_start = 0L; + s->lookahead = 0; + s->match_length = s->prev_length = 3 - 1; + s->match_available = 0; + s->ins_h = 0; +} + +int deflate (z_streamp strm, int flush) +{ + int old_flush; // value of flush param for previous deflate call + deflate_state *s; + + if (strm == NULL || strm->state == NULL || flush > Z_FINISH || flush < 0) + return Z_STREAM_ERROR; + s = strm->state; + + if (strm->next_out == NULL || (strm->next_in == NULL && strm->avail_in != 0) || (s->status == FINISH_STATE && flush != Z_FINISH)) + { + strm->msg = (char*)"stream error"; + return Z_STREAM_ERROR; + } + if (strm->avail_out == 0) + { + strm->msg = (char*)"buffer error"; + return Z_BUF_ERROR; + } + + s->strm = strm; // just in case + old_flush = s->last_flush; + s->last_flush = flush; + + // Write the zlib header + if (s->status == INIT_STATE) + { + uint header = (Z_DEFLATED + ((s->w_bits-8)<<4)) << 8; + uint level_flags = (s->level-1) >> 1; + + if (level_flags > 3) level_flags = 3; + header |= (level_flags << 6); + if (s->strstart != 0) header |= PRESET_DICT; + header += 31 - (header % 31); + + s->status = BUSY_STATE; + putShortMSB(s, header); + + // Save the adler32 of the preset dictionary: + if (s->strstart != 0) + { + putShortMSB(s, (uint)(strm->adler >> 16)); + putShortMSB(s, (uint)(strm->adler & 0xffff)); + } + strm->adler = 1L; + } + + // Flush as much pending output as possible + if (s->pending != 0) + { + flush_pending(strm); + if (strm->avail_out == 0) + { + /* Since avail_out is 0, deflate will be called again with + * more output space, but possibly with both pending and + * avail_in equal to zero. There won't be anything to do, + * but this is not an error situation so make sure we + * return OK instead of BUF_ERROR at next call of deflate: + */ + s->last_flush = -1; + return Z_OK; + } + + /* Make sure there is something to do and avoid duplicate consecutive + * flushes. For repeated and useless calls with Z_FINISH, we keep + * returning Z_STREAM_END instead of Z_BUFF_ERROR. + */ + } + else if (strm->avail_in == 0 && flush <= old_flush && flush != Z_FINISH) + { + strm->msg = (char*)"buffer error"; + return Z_BUF_ERROR; + } + + // User must not provide more input after the first FINISH: + if (s->status == FINISH_STATE && strm->avail_in != 0) + { + strm->msg = (char*)"buffer error"; + return Z_BUF_ERROR; + } + + // Start a new block or continue the current one. + if (strm->avail_in != 0 || s->lookahead != 0 || (flush != Z_NO_FLUSH && s->status != FINISH_STATE)) + { + block_state bstate; + bstate = (*(configuration_table[s->level].func))(s, flush); + + if (bstate == finish_started || bstate == finish_done) + { + s->status = FINISH_STATE; + } + if (bstate == need_more || bstate == finish_started) + { + if (strm->avail_out == 0) + { + s->last_flush = -1; // avoid BUF_ERROR next call, see above + } + return Z_OK; + + // If flush != Z_NO_FLUSH && avail_out == 0, the next call + // of deflate should use the same flush parameter to make sure + // that the flush is complete. So we don't have to output an + // empty block here, this will be done at next call. This also + // ensures that for a very small output buffer, we emit at most + // one empty block. + } + if (bstate == block_done) + { + if (flush == Z_PARTIAL_FLUSH) + { + _tr_align(s); + } + else + { + // FULL_FLUSH or SYNC_FLUSH + _tr_stored_block(s, (char*)0, 0L, 0); + /* For a full flush, this empty block will be recognized + * as a special marker by inflate_sync(). + */ + if (flush == Z_FULL_FLUSH) + { + CLEAR_HASH(s); // forget history + } + } + flush_pending(strm); + if (strm->avail_out == 0) + { + s->last_flush = -1; /* avoid BUF_ERROR at next call, see above */ + return Z_OK; + } + } + } + + if (flush != Z_FINISH) return Z_OK; + if (s->noheader) return Z_STREAM_END; + + // Write the zlib trailer (adler32) + putShortMSB(s, (uint)(strm->adler >> 16)); + putShortMSB(s, (uint)(strm->adler & 0xffff)); + flush_pending(strm); + + // If avail_out is zero, the application will call deflate again + // to flush the rest. + s->noheader = -1; // write the trailer only once! + return s->pending != 0 ? Z_OK : Z_STREAM_END; +} + +/* ========================================================================= */ +int deflateEnd (z_streamp strm) +{ + int status; + + if (strm == NULL || strm->state == NULL) return Z_STREAM_ERROR; + + status = strm->state->status; + if (status != INIT_STATE && status != BUSY_STATE && status != FINISH_STATE) + return Z_STREAM_ERROR; + + // Deallocate in reverse order of allocations: + ZipFree(strm, strm->state->pending_buf); + ZipFree(strm, strm->state->head); + ZipFree(strm, strm->state->prev); + ZipFree(strm, strm->state->window); + + ZipFree(strm, strm->state); + strm->state = NULL; + + return status == BUSY_STATE ? Z_DATA_ERROR : Z_OK; +} + +int deflateReset (z_streamp strm) +{ + deflate_state *s; + + if (strm == NULL || strm->state == NULL || strm->zalloc == NULL || strm->zfree == NULL) + return Z_STREAM_ERROR; + + strm->total_in = strm->total_out = 0; + strm->msg = (char *)"Ok"; + strm->data_type = Z_UNKNOWN; + + s = (deflate_state *)strm->state; + s->pending = 0; + s->pending_out = s->pending_buf; + + if (s->noheader < 0) + { + // was set to -1 by deflate(..., Z_FINISH); + s->noheader = 0; + } + + s->status = s->noheader ? BUSY_STATE : INIT_STATE; + strm->adler = 1; + s->last_flush = Z_NO_FLUSH; + + _tr_init(s); + lm_init(s); + + return Z_OK; +} \ No newline at end of file diff --git a/debug.bat b/debug.bat index 79712401..5639f31c 100644 --- a/debug.bat +++ b/debug.bat @@ -17,13 +17,13 @@ if errorlevel 1 set BUILD_ERROR=1 %MSDEV% launcher/launcher.dsp %CONFIG%"launcher - Win32 Debug" %build_target% if errorlevel 1 set BUILD_ERROR=1 -%MSDEV% platform/platform.dsp %CONFIG%"platform - Win32 Debug" %build_target% +%MSDEV% common/common.dsp %CONFIG%"common - Win32 Debug" %build_target% if errorlevel 1 set BUILD_ERROR=1 -%MSDEV% renderer/renderer.dsp %CONFIG%"renderer - Win32 Debug" %build_target% +%MSDEV% render/render.dsp %CONFIG%"render - Win32 Debug" %build_target% if errorlevel 1 set BUILD_ERROR=1 -progs\qcclib.exe +vprogs\qcclib.exe if errorlevel 1 set BUILD_ERROR=1 if "%BUILD_ERROR%"=="" goto build_ok @@ -48,9 +48,9 @@ rem //delete log files if exist editor\editor.plg del /f /q editor\editor.plg if exist engine\engine.plg del /f /q engine\engine.plg if exist launcher\launcher.plg del /f /q launcher\launcher.plg -if exist platform\platform.plg del /f /q platform\platform.plg -if exist renderer\renderer.plg del /f /q renderer\renderer.plg -if exist progs\server.dat copy progs\server.dat D:\Xash3D\xash\server.dat +if exist common\common.plg del /f /q common\common.plg +if exist render\render.plg del /f /q render\render.plg +if exist vprogs\server.dat move vprogs\server.dat D:\Xash3D\xash\server.dat echo Build succeeded! echo Please wait. Xash is now loading diff --git a/editor/editor.c b/editor/editor.c index 2a9ff1bc..66cd07b0 100644 --- a/editor/editor.c +++ b/editor/editor.c @@ -5,7 +5,7 @@ #include "editor.h" -stdinout_api_t std; +stdlib_api_t std; /* ================== @@ -13,7 +13,7 @@ DllMain ================== */ -launcher_exp_t DLLEXPORT *CreateAPI( stdinout_api_t *input ) +launcher_exp_t DLLEXPORT *CreateAPI( stdlib_api_t *input ) { static launcher_exp_t Editor; diff --git a/editor/editor.dsp b/editor/editor.dsp index e95187c1..58f2d7d8 100644 --- a/editor/editor.dsp +++ b/editor/editor.dsp @@ -43,7 +43,7 @@ RSC=rc.exe # PROP Ignore_Export_Lib 1 # PROP Target_Dir "" # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EDITOR_EXPORTS" /YX /FD /c -# ADD CPP /nologo /W3 /GX /O2 /Ob0 /I "../public" /I "../platform/formats" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /FD /c +# ADD CPP /nologo /MD /W3 /GX /O2 /Ob0 /I "../public" /I "../platform/formats" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /FD /c # SUBTRACT CPP /YX # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 @@ -54,10 +54,10 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 -# ADD LINK32 kernel32.lib user32.lib gdi32.lib comctl32.lib comdlg32.lib /nologo /dll /machine:I386 +# ADD LINK32 msvcrt.lib user32.lib gdi32.lib comctl32.lib comdlg32.lib /nologo /dll /machine:I386 /nodefaultlib:"libc.lib" # Begin Custom Build -TargetDir=\Xash3D\src_main\!source\temp\editor\!release -InputPath=\Xash3D\src_main\!source\temp\editor\!release\editor.dll +TargetDir=\XASH3D\src_main\!source\temp\editor\!release +InputPath=\XASH3D\src_main\!source\temp\editor\!release\editor.dll SOURCE="$(InputPath)" "D:\Xash3D\bin\editor.dll" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" @@ -79,7 +79,7 @@ SOURCE="$(InputPath)" # PROP Ignore_Export_Lib 1 # PROP Target_Dir "" # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EDITOR_EXPORTS" /YX /FD /GZ /c -# ADD CPP /nologo /MTd /W3 /Gm /Gi /GX /ZI /Od /I "../public" /I "../platform/formats" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /FR /FD /GZ /c +# ADD CPP /nologo /MDd /W3 /Gm /Gi /GX /ZI /Od /I "../public" /I "../platform/formats" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /FR /FD /GZ /c # SUBTRACT CPP /YX # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 @@ -90,10 +90,10 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept -# ADD LINK32 kernel32.lib user32.lib gdi32.lib comctl32.lib comdlg32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept +# ADD LINK32 msvcrt.lib user32.lib gdi32.lib comctl32.lib comdlg32.lib /nologo /dll /debug /machine:I386 /nodefaultlib:"msvcrtd.lib" /pdbtype:sept # Begin Custom Build -TargetDir=\Xash3D\src_main\!source\temp\editor\!debug -InputPath=\Xash3D\src_main\!source\temp\editor\!debug\editor.dll +TargetDir=\XASH3D\src_main\!source\temp\editor\!debug +InputPath=\XASH3D\src_main\!source\temp\editor\!debug\editor.dll SOURCE="$(InputPath)" "D:\Xash3D\bin\editor.dll" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" @@ -120,11 +120,11 @@ SOURCE=.\editor.rc # End Source File # Begin Source File -SOURCE=.\guiutils.c +SOURCE=.\guiforms.c # End Source File # Begin Source File -SOURCE=.\guiforms.c +SOURCE=.\guiutils.c # End Source File # End Group # Begin Group "Header Files" diff --git a/editor/editor.h b/editor/editor.h index d30c83f2..36abb4a1 100644 --- a/editor/editor.h +++ b/editor/editor.h @@ -1,6 +1,6 @@ //======================================================================= // Copyright XashXT Group 2007 © -// platform.h - game platform dll +// editor.h - recource editor //======================================================================= #ifndef GENERICEDIT_H #define GENERICEDIT_H @@ -29,7 +29,7 @@ void FreeEditor ( void ); extern int com_argc; extern int dev_mode; extern bool debug_mode; -extern platform_exp_t *pi; +extern common_exp_t *com; extern char *com_argv[MAX_NUM_ARGVS]; int CheckParm (const char *parm); bool _GetParmFromCmdLine( char *parm, char *out, size_t size ); @@ -44,7 +44,7 @@ void GUI_Msg( const char *pMsg, ... ); void GUI_MsgDev( int level, const char *pMsg, ... ); void GUI_MsgWarn( const char *pMsg, ... ); -extern stdinout_api_t std; +extern stdlib_api_t std; #define Msg GUI_Msg #define MsgDev GUI_MsgDev #define MsgWarn GUI_MsgWarn diff --git a/editor/guiforms.c b/editor/guiforms.c index a87ddcb6..d01e317a 100644 --- a/editor/guiforms.c +++ b/editor/guiforms.c @@ -31,10 +31,12 @@ typedef struct tag_dlghdr GUI_Form s_gui; wnd_options_t w_opts; //window options -platform_exp_t *pi;//platform utils +common_exp_t *com; //common utils static bool editor_init = false; static char textbuffer[MAX_INPUTLINE]; -dll_info_t platform_dll = { "platform.dll", NULL, "CreateAPI", NULL, NULL, false, PLATFORM_API_VERSION, sizeof(platform_exp_t) }; +dll_info_t common_dll = { "common.dll", NULL, "CreateAPI", NULL, NULL, false, COMMON_API_VERSION, sizeof(common_exp_t) }; +dll_info_t richedit_dll = { "riched32.dll", NULL, NULL, NULL, NULL, false, 0, 0 }; + /* ============================================================================= @@ -454,36 +456,37 @@ void GUI_LoadWndOptions( wnd_options_t *settings ) bool GUI_LoadPlatfrom( char *funcname, int argc, char **argv ) { - stdinout_api_t pistd;//platform callback - platform_t CreatePlat; + stdlib_api_t io; //common callback + common_t CreatePlat; - //create callbacks for platform.dll - pistd.printf = GUI_Msg; - pistd.dprintf = GUI_MsgDev; - pistd.wprintf = GUI_MsgWarn; - pistd.error = GUI_Error; - pistd.exit = std.exit; - pistd.print = GUI_Print; - pistd.input = std.input; - pistd.sleep = std.sleep; + // create callbacks for common.dll + io.printf = GUI_Msg; + io.dprintf = GUI_MsgDev; + io.wprintf = GUI_MsgWarn; + io.error = GUI_Error; + io.exit = std.exit; + io.print = GUI_Print; + io.input = std.input; + io.sleep = std.sleep; - pistd.LoadLibrary = std.LoadLibrary; - pistd.FreeLibrary = std.FreeLibrary; - - //loading platform.dll - if (!Sys_LoadLibrary( &platform_dll )) + io.LoadLibrary = std.LoadLibrary; + io.FreeLibrary = std.FreeLibrary; + io.GetProcAddress = std.GetProcAddress; + + // loading common.dll + if (!Sys_LoadLibrary( &common_dll )) { - GUI_Error("couldn't find platform.dll\n"); + GUI_Error("couldn't find common.dll\n"); return false; } - CreatePlat = (void *)platform_dll.main; - pi = CreatePlat( &pistd );//make links + CreatePlat = (void *)common_dll.main; + com = CreatePlat( &io );//make links - //initialziing platform.dll - pi->Init( argc, argv ); + //initialziing common.dll + com->Init( argc, argv ); - pi->Fs.ClearSearchPath(); - pi->AddGameHierarchy( "bin" ); + com->Fs.ClearSearchPath(); + com->AddGameHierarchy( "bin" ); return true; } @@ -495,30 +498,29 @@ HWND GUI_CreateConsole( bool readonly ) WS_VSCROLL | ES_LEFT | ES_WANTRETURN | ES_MULTILINE | ES_AUTOVSCROLL; if (readonly) dwStyle |= ES_READONLY; - if (!s_gui.richedit) s_gui.richedit = LoadLibrary("riched32.dll"); + Sys_LoadLibrary( &richedit_dll ); - newwnd = CreateWindowEx(WS_EX_CLIENTEDGE, s_gui.richedit ? RICHEDIT_CLASS:"EDIT", "", + newwnd = CreateWindowEx(WS_EX_CLIENTEDGE, richedit_dll.link ? RICHEDIT_CLASS : "EDIT", "", dwStyle, 0, 0, 0, 0, s_gui.hWnd, NULL, s_gui.gHinst, NULL); if (!newwnd) { //fall back to the earlier version - newwnd = CreateWindowEx(WS_EX_CLIENTEDGE, s_gui.richedit ? RICHEDIT_CLASS10A : "EDIT", "", + newwnd = CreateWindowEx(WS_EX_CLIENTEDGE, richedit_dll.link ? RICHEDIT_CLASS10A : "EDIT", "", dwStyle, 0, 0, 0, 0, s_gui.hWnd, NULL, s_gui.gHinst, NULL); } if (!newwnd) { - //we don't have RICHEDIT installed properly - FreeLibrary(s_gui.richedit); - s_gui.richedit = NULL; + // we don't have RICHEDIT installed properly + Sys_FreeLibrary( &richedit_dll ); newwnd = CreateWindowEx(WS_EX_CLIENTEDGE, "EDIT", "", dwStyle, 0, 0, 0, 0, s_gui.hWnd, NULL, s_gui.gHinst, NULL); } GUI_SetFont( newwnd ); - if (s_gui.richedit) SendMessage(newwnd, EM_EXLIMITTEXT, 0, 1<<20); + if (richedit_dll.link) SendMessage(newwnd, EM_EXLIMITTEXT, 0, 1<<20); return newwnd; } @@ -992,7 +994,7 @@ void InitEditor ( char *funcname, int argc, char **argv ) wnd_options_t *config_dat; int config_size; - config_dat = (wnd_options_t *)pi->Fs.LoadFile( "editor.dat", &config_size ); + config_dat = (wnd_options_t *)com->Fs.LoadFile( "editor.dat", &config_size ); if(config_dat) //verify our config before read { @@ -1048,23 +1050,23 @@ void EditorMain ( void ) } } - if(platform_dll.link) + if(common_dll.link) { // save our settings - pi->Fs.WriteFile("editor.dat", &w_opts, w_opts.csize ); + com->Fs.WriteFile("editor.dat", &w_opts, w_opts.csize ); } } void FreeEditor ( void ) { // free richedit32 - if (s_gui.richedit) FreeLibrary( s_gui.richedit ); + Sys_FreeLibrary( &richedit_dll ); - // free platform - if(platform_dll.link) + // free common + if(common_dll.link) { - pi->Shutdown(); - Sys_FreeLibrary(&platform_dll); + com->Shutdown(); + Sys_FreeLibrary(&common_dll); } GUI_RemoveAccelTable(); diff --git a/engine/client/cl_ents.c b/engine/client/cl_ents.c index 9dfd0ecd..e63e5542 100644 --- a/engine/client/cl_ents.c +++ b/engine/client/cl_ents.c @@ -863,7 +863,7 @@ void CL_AddPacketEntities (frame_t *frame) renderfx |= RF_SHELL_BLUE; } - //copy state to renderer + //copy state to render ent.prev.frame = cent->prev.frame; ent.backlerp = 1.0 - cl.lerpfrac; ent.alpha = s1->alpha; diff --git a/engine/client/cl_main.c b/engine/client/cl_main.c index 6c7a8a38..d718e6a7 100644 --- a/engine/client/cl_main.c +++ b/engine/client/cl_main.c @@ -1824,7 +1824,7 @@ void CL_Shutdown(void) S_Shutdown(); IN_Shutdown (); - VID_FreeRenderer(); + VID_FreeRender(); } diff --git a/engine/client/cl_view.c b/engine/client/cl_view.c index bed4af74..18f36281 100644 --- a/engine/client/cl_view.c +++ b/engine/client/cl_view.c @@ -339,7 +339,7 @@ void CL_PrepRefresh (void) re->SetSky (cl.configstrings[CS_SKY], rotate, axis); Msg (" \r"); - // the renderer can now free unneeded stuff + // the render can now free unneeded stuff re->EndRegistration (); // clear any lines of console text diff --git a/engine/client/client.h b/engine/client/client.h index 83f36c32..a635c18e 100644 --- a/engine/client/client.h +++ b/engine/client/client.h @@ -421,7 +421,7 @@ void CL_ParseLayout (void); // // cl_main // -extern renderer_exp_t *re; +extern render_exp_t *re; void CL_Init (void); diff --git a/engine/common.h b/engine/common.h index 2f3e7536..e8458401 100644 --- a/engine/common.h +++ b/engine/common.h @@ -44,9 +44,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define RAD_TO_STUDIO (32768.0/M_PI) #define STUDIO_TO_RAD (M_PI/32768.0) -size_t strlcpy(char *dst, const char *src, size_t siz); -size_t strlcat(char *dst, const char *src, size_t siz); - //============================================================================ typedef struct sizebuf_s diff --git a/engine/common/cmodel.c b/engine/common/cmodel.c index a8eac028..5167ea58 100644 --- a/engine/common/cmodel.c +++ b/engine/common/cmodel.c @@ -1768,7 +1768,7 @@ cmodel_t *CM_StudioModel (char *name, byte *buffer) out = &map_cmodels[max_models]; out->extradata = buffer; out->numframes = 0;//reset sprite info - strlcpy(out->name, modname, sizeof(out->name)); + strncpy(out->name, modname, sizeof(out->name)); if(SV_StudioExtractBbox( phdr, 0, out->mins, out->maxs )) { @@ -1818,7 +1818,7 @@ cmodel_t *CM_SpriteModel (char *name, byte *buffer) out = &map_cmodels[max_models]; out->numframes = phdr->numframes; - strlcpy(out->name, modname, sizeof(out->name)); + strncpy(out->name, modname, sizeof(out->name)); out->mins[0] = out->mins[1] = -phdr->width / 2; out->maxs[0] = out->maxs[1] = phdr->width / 2; diff --git a/engine/common/common.c b/engine/common/common.c index aeb2e145..66eef918 100644 --- a/engine/common/common.c +++ b/engine/common/common.c @@ -24,8 +24,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define MAXPRINTMSG 4096 -jmp_buf abortframe; - int com_argc; char *com_argv[MAX_NUM_ARGVS+1]; @@ -289,61 +287,4 @@ void Com_PageInMemory (byte *buffer, int size) for (i = size - 1; i > 0; i -= 4096) paged_total += buffer[i]; -} - -#ifndef HAVE_STRLCAT -size_t strlcat(char *dst, const char *src, size_t siz) -{ - register char *d = dst; - register const char *s = src; - register size_t n = siz; - size_t dlen; - - // Find the end of dst and adjust bytes left but don't go past end - while (n-- != 0 && *d != '\0') d++; - dlen = d - dst; - n = siz - dlen; - - if (n == 0) return(dlen + strlen(s)); - while (*s != '\0') - { - if (n != 1) - { - *d++ = *s; - n--; - } - s++; - } - - *d = '\0'; - return(dlen + (s - src)); //count does not include NUL -} -#endif - - -#ifndef HAVE_STRLCPY -size_t strlcpy(char *dst, const char *src, size_t siz) -{ - register char *d = dst; - register const char *s = src; - register size_t n = siz; - - // Copy as many bytes as will fit - if (n != 0 && --n != 0) - { - do - { - if ((*d++ = *s++) == 0) - break; - } while (--n != 0); - } - - // Not enough room in dst, add NUL and traverse rest of src - if (n == 0) - { - if (siz != 0) *d = '\0'; //NUL-terminate dst - while (*s++); - } - return(s - src - 1); //count does not include NUL -} -#endif \ No newline at end of file +} \ No newline at end of file diff --git a/engine/common/menu.c b/engine/common/menu.c index 152b8bc9..87dda95c 100644 --- a/engine/common/menu.c +++ b/engine/common/menu.c @@ -422,7 +422,7 @@ void M_Main_Draw (void) re->DrawPic( xoffset, ystart + i * 40 + 13, names[i] ); } strcpy( litname, names[m_main_cursor] ); - strlcat( litname, "_sel", 80 ); + strncat( litname, "_sel", 80 ); re->DrawPic( xoffset, ystart + m_main_cursor * 40 + 13, litname ); M_DrawCursor( xoffset - 25, ystart + m_main_cursor * 40 + 11, (int)(cls.realtime * 8.0f) % NUM_CURSOR_FRAMES ); @@ -2140,7 +2140,7 @@ bool Menu_CreateMapsList( void ) fp = FS_Open(t->filenames[i], "rb"); FS_FileBase( t->filenames[i], mapname ); - strlcpy(message, "No Title", 64); + strncpy(message, "No Title", 64); if(fp) { @@ -2189,7 +2189,7 @@ bool Menu_CreateMapsList( void ) if (!strcmp(keyname, "message") && !have_title) { // get the message contents - strlcpy(message, com_token, sizeof(message)); + strncpy(message, com_token, sizeof(message)); have_title = true;//get title once only } else if(!strcmp(keyname, "classname")) @@ -3017,7 +3017,7 @@ static bool IconOfSkinExists( char *skin, char **pcxfiles, int npcxfiles ) strcpy( scratch, skin ); *strrchr( scratch, '.' ) = 0; - strlcat( scratch, "_i.pcx", 1024 ); + strncat( scratch, "_i.pcx", 1024 ); for ( i = 0; i < npcxfiles; i++ ) { @@ -3066,13 +3066,13 @@ static bool PlayerConfig_ScanDirectories( void ) // verify the existence of tris.md2 strcpy( scratch, dirnames[i] ); - strlcat( scratch, "/tris.md2", 1024 ); + strncat( scratch, "/tris.md2", 1024 ); if(!FS_FileExists( scratch )) continue; // verify the existence of at least one pcx skin strcpy( scratch, dirnames[i] ); - strlcat( scratch, "/*.pcx", 1024 ); + strncat( scratch, "/*.pcx", 1024 ); search2 = FS_Search( scratch ); @@ -3349,7 +3349,6 @@ void PlayerConfig_MenuDraw( void ) if ( s_pmi[s_player_model_box.curvalue].skindisplaynames ) { static int yaw; - int maxframe = 29; entity_t entity; memset( &entity, 0, sizeof( entity ) ); diff --git a/engine/common/qmenu.c b/engine/common/qmenu.c index 95896df0..0ee1f02f 100644 --- a/engine/common/qmenu.c +++ b/engine/common/qmenu.c @@ -38,8 +38,8 @@ static void SpinControl_DoSlide( menulist_s *s, int dir ); #define RCOLUMN_OFFSET 16 #define LCOLUMN_OFFSET -16 -extern renderer_exp_t *re; -extern viddef_t viddef; +extern render_exp_t *re; +extern viddef_t viddef; #define VID_WIDTH viddef.width #define VID_HEIGHT viddef.height diff --git a/engine/common/vid.h b/engine/common/vid.h index 02376409..29f314d8 100644 --- a/engine/common/vid.h +++ b/engine/common/vid.h @@ -35,8 +35,8 @@ extern viddef_t viddef; // global video state // Video module initialisation etc void VID_Init (void); -void VID_InitRenderer(void); -void VID_FreeRenderer(void); +void VID_InitRender(void); +void VID_FreeRender(void); void VID_CheckChanges(void); void VID_MenuInit( void ); diff --git a/engine/engine.dsp b/engine/engine.dsp index 1f903cb7..0d6e75bc 100644 --- a/engine/engine.dsp +++ b/engine/engine.dsp @@ -53,8 +53,8 @@ BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386 -# ADD LINK32 winmm.lib user32.lib msvcrt.lib /nologo /subsystem:windows /dll /pdb:none /machine:I386 /nodefaultlib:"libc.lib" +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386 /opt:nowin98 +# ADD LINK32 winmm.lib user32.lib msvcrt.lib /nologo /subsystem:windows /dll /pdb:none /machine:I386 /nodefaultlib:"libc.lib" /opt:nowin98 # SUBTRACT LINK32 /debug /nodefaultlib # Begin Custom Build TargetDir=\XASH3D\src_main\!source\temp\engine\!release diff --git a/engine/engine.h b/engine/engine.h index a1158274..da535e59 100644 --- a/engine/engine.h +++ b/engine/engine.h @@ -27,8 +27,8 @@ #include "cvar.h" #include "console.h" -extern stdinout_api_t std; -extern platform_exp_t *pi; +extern stdlib_api_t std; +extern common_exp_t *Com; extern byte *zonepool; typedef enum @@ -95,39 +95,39 @@ memory manager #define Z_Free(data) Mem_Free(data) //malloc-free -#define Mem_Alloc(pool,size) pi->Mem.Alloc(pool, size, __FILE__, __LINE__) -#define Mem_Free(mem) pi->Mem.Free(mem, __FILE__, __LINE__) +#define Mem_Alloc(pool,size) Com->Mem.Alloc(pool, size, __FILE__, __LINE__) +#define Mem_Free(mem) Com->Mem.Free(mem, __FILE__, __LINE__) //Hunk_AllocName -#define Mem_AllocPool(name) pi->Mem.AllocPool(name, __FILE__, __LINE__) -#define Mem_FreePool(pool) pi->Mem.FreePool(pool, __FILE__, __LINE__) -#define Mem_EmptyPool(pool) pi->Mem.EmptyPool(pool, __FILE__, __LINE__) +#define Mem_AllocPool(name) Com->Mem.AllocPool(name, __FILE__, __LINE__) +#define Mem_FreePool(pool) Com->Mem.FreePool(pool, __FILE__, __LINE__) +#define Mem_EmptyPool(pool) Com->Mem.EmptyPool(pool, __FILE__, __LINE__) -#define Mem_Copy(dest, src, size) pi->Mem.Copy(dest, src, size, __FILE__, __LINE__) +#define Mem_Copy(dest, src, size) Com->Mem.Copy(dest, src, size, __FILE__, __LINE__) /* =========================================== filesystem manager =========================================== */ -#define FS_LoadFile(name, size) pi->Fs.LoadFile(name, size) -#define FS_LoadImage(name, data, size) pi->Fs.LoadImage(name, data, size) -#define FS_Search(path) pi->Fs.Search( path, true ) -#define FS_WriteFile(name, data, size) pi->Fs.WriteFile(name, data, size ) -#define FS_Open( path, mode ) pi->Fs.Open( path, mode ) -#define FS_Read( file, buffer, size ) pi->Fs.Read( file, buffer, size ) -#define FS_Write( file, buffer, size ) pi->Fs.Write( file, buffer, size ) -#define FS_StripExtension( path ) pi->Fs.StripExtension( path ) -#define FS_DefaultExtension( path, ext ) pi->Fs.DefaultExtension( path, ext ) -#define FS_FileExtension( ext ) pi->Fs.FileExtension( ext ) -#define FS_FileExists( file ) pi->Fs.FileExists( file ) -#define FS_Close( file ) pi->Fs.Close( file ) -#define FS_FileBase( x, y ) pi->Fs.FileBase( x, y ) -#define FS_Find( x ) pi->Fs.Search( x, false ) -#define FS_Printf pi->Fs.Printf -#define FS_Seek pi->Fs.Seek -#define FS_Tell pi->Fs.Tell -#define FS_Gets pi->Fs.Gets +#define FS_LoadFile(name, size) Com->Fs.LoadFile(name, size) +#define FS_LoadImage(name, data, size) Com->Fs.LoadImage(name, data, size) +#define FS_Search(path) Com->Fs.Search( path, true ) +#define FS_WriteFile(name, data, size) Com->Fs.WriteFile(name, data, size ) +#define FS_Open( path, mode ) Com->Fs.Open( path, mode ) +#define FS_Read( file, buffer, size ) Com->Fs.Read( file, buffer, size ) +#define FS_Write( file, buffer, size ) Com->Fs.Write( file, buffer, size ) +#define FS_StripExtension( path ) Com->Fs.StripExtension( path ) +#define FS_DefaultExtension( path, ext ) Com->Fs.DefaultExtension( path, ext ) +#define FS_FileExtension( ext ) Com->Fs.FileExtension( ext ) +#define FS_FileExists( file ) Com->Fs.FileExists( file ) +#define FS_Close( file ) Com->Fs.Close( file ) +#define FS_FileBase( x, y ) Com->Fs.FileBase( x, y ) +#define FS_Find( x ) Com->Fs.Search( x, false ) +#define FS_Printf Com->Fs.Printf +#define FS_Seek Com->Fs.Seek +#define FS_Tell Com->Fs.Tell +#define FS_Gets Com->Fs.Gets char *FS_Gamedir( void ); /* @@ -135,19 +135,19 @@ char *FS_Gamedir( void ); scriptsystem manager =========================================== */ -#define COM_Parse(data) pi->Script.ParseToken(data) -#define COM_Token pi->Script.Token +#define COM_Parse(data) Com->Script.ParseToken(data) +#define COM_Token Com->Script.Token /* =========================================== infostring manager =========================================== */ -#define Info_Print(x) pi->Info.Print -#define Info_Validate(x) pi->Info.Validate(x) -#define Info_RemoveKey(x, y) pi->Info.RemoveKey(x,y) -#define Info_ValueForKey(x,y) pi->Info.ValueForKey(x,y) -#define Info_SetValueForKey(x,y,z) pi->Info.SetValueForKey(x,y,z) +#define Info_Print(x) Com->Info.Print +#define Info_Validate(x) Com->Info.Validate(x) +#define Info_RemoveKey(x, y) Com->Info.RemoveKey(x,y) +#define Info_ValueForKey(x,y) Com->Info.ValueForKey(x,y) +#define Info_SetValueForKey(x,y,z) Com->Info.SetValueForKey(x,y,z) /* =========================================== @@ -155,7 +155,7 @@ System Timer =========================================== */ double Sys_DoubleTime( void ); -#define GI pi->GameInfo() +#define GI Com->GameInfo() /* =========================================== diff --git a/engine/engine.plg b/engine/engine.plg deleted file mode 100644 index 0eb1f46e..00000000 --- a/engine/engine.plg +++ /dev/null @@ -1,78 +0,0 @@ - - -
-

Build Log

-

---------------------Configuration: engine - Win32 Debug-------------------- -

-

Command Lines

-Creating temporary file "C:\Temp\RSP159C.tmp" with contents -[ -winmm.lib user32.lib msvcrt.lib /nologo /subsystem:windows /dll /incremental:yes /pdb:"..\temp\engine\!debug/engine.pdb" /debug /machine:I386 /nodefaultlib:"msvcrtd.lib" /out:"..\temp\engine\!debug/engine.dll" /implib:"..\temp\engine\!debug/engine.lib" /pdbtype:sept -"\XASH3D\src_main\!source\temp\engine\!debug\cl_cin.obj" -"\XASH3D\src_main\!source\temp\engine\!debug\cl_ents.obj" -"\XASH3D\src_main\!source\temp\engine\!debug\cl_fx.obj" -"\XASH3D\src_main\!source\temp\engine\!debug\cl_input.obj" -"\XASH3D\src_main\!source\temp\engine\!debug\cl_inv.obj" -"\XASH3D\src_main\!source\temp\engine\!debug\cl_main.obj" -"\XASH3D\src_main\!source\temp\engine\!debug\cl_newfx.obj" -"\XASH3D\src_main\!source\temp\engine\!debug\cl_parse.obj" -"\XASH3D\src_main\!source\temp\engine\!debug\cl_pred.obj" -"\XASH3D\src_main\!source\temp\engine\!debug\cl_scrn.obj" -"\XASH3D\src_main\!source\temp\engine\!debug\cl_tent.obj" -"\XASH3D\src_main\!source\temp\engine\!debug\cl_view.obj" -"\XASH3D\src_main\!source\temp\engine\!debug\cmd.obj" -"\XASH3D\src_main\!source\temp\engine\!debug\cmodel.obj" -"\XASH3D\src_main\!source\temp\engine\!debug\common.obj" -"\XASH3D\src_main\!source\temp\engine\!debug\console.obj" -"\XASH3D\src_main\!source\temp\engine\!debug\crc.obj" -"\XASH3D\src_main\!source\temp\engine\!debug\cvar.obj" -"\XASH3D\src_main\!source\temp\engine\!debug\host.obj" -"\XASH3D\src_main\!source\temp\engine\!debug\in_win.obj" -"\XASH3D\src_main\!source\temp\engine\!debug\keys.obj" -"\XASH3D\src_main\!source\temp\engine\!debug\md4.obj" -"\XASH3D\src_main\!source\temp\engine\!debug\menu.obj" -"\XASH3D\src_main\!source\temp\engine\!debug\net_chan.obj" -"\XASH3D\src_main\!source\temp\engine\!debug\net_msg.obj" -"\XASH3D\src_main\!source\temp\engine\!debug\net_wins.obj" -"\XASH3D\src_main\!source\temp\engine\!debug\pmove.obj" -"\XASH3D\src_main\!source\temp\engine\!debug\qmenu.obj" -"\XASH3D\src_main\!source\temp\engine\!debug\snd_dma.obj" -"\XASH3D\src_main\!source\temp\engine\!debug\snd_mem.obj" -"\XASH3D\src_main\!source\temp\engine\!debug\snd_mix.obj" -"\XASH3D\src_main\!source\temp\engine\!debug\snd_win.obj" -"\XASH3D\src_main\!source\temp\engine\!debug\sv_ccmds.obj" -"\XASH3D\src_main\!source\temp\engine\!debug\sv_ents.obj" -"\XASH3D\src_main\!source\temp\engine\!debug\sv_game.obj" -"\XASH3D\src_main\!source\temp\engine\!debug\sv_init.obj" -"\XASH3D\src_main\!source\temp\engine\!debug\sv_main.obj" -"\XASH3D\src_main\!source\temp\engine\!debug\sv_phys.obj" -"\XASH3D\src_main\!source\temp\engine\!debug\sv_save.obj" -"\XASH3D\src_main\!source\temp\engine\!debug\sv_send.obj" -"\XASH3D\src_main\!source\temp\engine\!debug\sv_spawn.obj" -"\XASH3D\src_main\!source\temp\engine\!debug\sv_studio.obj" -"\XASH3D\src_main\!source\temp\engine\!debug\sv_user.obj" -"\XASH3D\src_main\!source\temp\engine\!debug\sv_world.obj" -"\XASH3D\src_main\!source\temp\engine\!debug\system.obj" -"\XASH3D\src_main\!source\temp\engine\!debug\vid_dll.obj" -"\XASH3D\src_main\!source\temp\engine\!debug\vid_menu.obj" -] -Creating command line "link.exe @C:\Temp\RSP159C.tmp" -Creating temporary file "C:\Temp\RSP159D.bat" with contents -[ -@echo off -copy \XASH3D\src_main\!source\temp\engine\!debug\engine.dll "D:\Xash3D\bin\engine.dll" -] -Creating command line "C:\Temp\RSP159D.bat" -Linking... -

Output Window

-Performing Custom Build Step on \XASH3D\src_main\!source\temp\engine\!debug\engine.dll -‘Є®ЇЁа®ў ­® д ©«®ў: 1. - - - -

Results

-engine.dll - 0 error(s), 0 warning(s) -
- - diff --git a/engine/host.c b/engine/host.c index a93cc6c6..4a6ba0a4 100644 --- a/engine/host.c +++ b/engine/host.c @@ -8,9 +8,9 @@ #include #include "engine.h" -platform_exp_t *pi; // fundamental callbacks +common_exp_t *Com; // fundamental callbacks host_parm_t host; // host parms -stdinout_api_t std; +stdlib_api_t std; byte *zonepool; int ActiveApp; @@ -21,44 +21,51 @@ void Key_Init (void); void SCR_EndLoadingPlaque (void); HINSTANCE global_hInstance; -dll_info_t platform_dll = { "platform.dll", NULL, "CreateAPI", NULL, NULL, true, PLATFORM_API_VERSION, sizeof(platform_exp_t) }; +dll_info_t common_dll = { "common.dll", NULL, "CreateAPI", NULL, NULL, true, COMMON_API_VERSION, sizeof(common_exp_t) }; cvar_t *timescale; cvar_t *fixedtime; cvar_t *showtrace; -void Host_InitPlatform( char *funcname, int argc, char **argv ) +void Host_InitCommon( char *funcname, int argc, char **argv ) { - static stdinout_api_t pistd; - platform_t CreatePlat; + static stdlib_api_t io; + common_t CreateCom; //make callbacks - pistd.printf = Msg; - pistd.dprintf = MsgDev; - pistd.wprintf = MsgWarn; - pistd.error = Sys_Error; - - Sys_LoadLibrary( &platform_dll ); + io.printf = Msg; + io.dprintf = MsgDev; + io.wprintf = MsgWarn; + io.error = Sys_Error; + io.exit = std.exit; + io.print = Con_Print; + io.input = std.input; + io.sleep = std.sleep; - CreatePlat = (void *)platform_dll.main; - pi = CreatePlat( &pistd ); + io.LoadLibrary = Sys_LoadLibrary; + io.FreeLibrary = Sys_FreeLibrary; + io.GetProcAddress = std.GetProcAddress; - // initialize our platform :) - pi->Init( argc, argv ); + Sys_LoadLibrary( &common_dll ); - //TODO: init basedir here - pi->LoadGameInfo("gameinfo.txt"); + CreateCom = (void *)common_dll.main; + Com = CreateCom( &io ); + + Com->Init( argc, argv ); + + // TODO: init basedir here + Com->LoadGameInfo("gameinfo.txt"); zonepool = Mem_AllocPool("Zone Engine"); } -void Host_FreePlatform( void ) +void Host_FreeCommon( void ) { - if(platform_dll.link) + if(common_dll.link) { Mem_FreePool( &zonepool ); - pi->Shutdown(); - Sys_FreeLibrary( &platform_dll ); + Com->Shutdown(); } + Sys_FreeLibrary( &common_dll ); } /* @@ -91,7 +98,7 @@ void Host_Init (char *funcname, int argc, char **argv) else host.type = HOST_OFFLINE; // launcher can loading engine for some reasons COM_InitArgv (argc, argv); // init host.debug & host.developer here - Host_InitPlatform( funcname, argc, argv ); + Host_InitCommon( funcname, argc, argv ); MsgDev(D_INFO, "------- Loading bin/engine.dll [%g] -------\n", ENGINE_VERSION ); @@ -251,7 +258,7 @@ void Host_Main( void ) // if at a full screen console, don't update unless needed if (Minimized || (dedicated && dedicated->value) ) { - Sleep (1); + Sys_Sleep (1); } while (PeekMessage (&msg, NULL, 0, 0, PM_NOREMOVE)) @@ -289,7 +296,7 @@ void Host_Free (void) SV_Shutdown ("Server shutdown\n", false); CL_Shutdown (); } - Host_FreePlatform (); + Host_FreeCommon (); } /* @@ -318,7 +325,7 @@ void Host_Error( const char *error, ... ) Sys_Error ("%s", hosterror1); } recursive = true; - strlcpy(hosterror2, hosterror1, sizeof(hosterror2)); + strncpy(hosterror2, hosterror1, sizeof(hosterror2)); SV_Shutdown (va("Server crashed: %s", hosterror1), false); CL_Drop(); // drop clients diff --git a/engine/server/sv_save.c b/engine/server/sv_save.c index 2bbdf004..28bbeb60 100644 --- a/engine/server/sv_save.c +++ b/engine/server/sv_save.c @@ -53,7 +53,7 @@ size_t COM_PackString( byte *buffer, int pos, char *string ) if(strsize > MAX_QPATH) strsize = MAX_QPATH; //critical stuff strsize++; // get space for terminator - strlcpy(buffer + pos, string, strsize ); + strncpy(buffer + pos, string, strsize ); return pos + strsize; } @@ -67,7 +67,7 @@ size_t COM_UnpackString( byte *buffer, int pos, char *string ) do { in++, strsize++; } while(*in != '\0' && in != NULL ); - strlcpy( string, in - (strsize - 1), strsize ); + strncpy( string, in - (strsize - 1), strsize ); return pos + strsize; } @@ -181,7 +181,7 @@ void Sav_LoadComment( lump_t *l ) if (l->filelen % sizeof(*in)) Host_Error("Sav_LoadComment: funny lump size\n" ); size = l->filelen / sizeof(*in); - strlcpy(svs.comment, in, size ); + strncpy(svs.comment, in, size ); } void Sav_LoadCvars( lump_t *l ) @@ -327,7 +327,7 @@ bool Menu_ReadComment( char *comment, int savenum ) if(!savfile) { - strlcpy( comment, "", 32 ); + strncpy( comment, "", 32 ); return false; } @@ -337,13 +337,13 @@ bool Menu_ReadComment( char *comment, int savenum ) if(id != IDSAVEHEADER || i != SAVE_VERSION) { - strlcpy( comment, "", 32 ); + strncpy( comment, "", 32 ); return false; } sav_base = (byte *)header; Sav_LoadComment(&header->lumps[LUMP_COMMENTS]); - strlcpy( comment, svs.comment, 32 ); + strncpy( comment, svs.comment, 32 ); return true; } \ No newline at end of file diff --git a/engine/snd_win.c b/engine/snd_win.c index 05aa3174..d7ea3871 100644 --- a/engine/snd_win.c +++ b/engine/snd_win.c @@ -325,12 +325,7 @@ void FreeSound (void) pDS->lpVtbl->Release( pDS ); } - if ( hInstDS ) - { - MsgDev(D_INFO, "...freeing DSOUND.DLL\n" ); - FreeLibrary( hInstDS ); - hInstDS = NULL; - } + Sys_FreeLibrary( &dsound_dll ); pDS = NULL; pDSBuf = NULL; diff --git a/engine/system.c b/engine/system.c index 2740f536..bc07063f 100644 --- a/engine/system.c +++ b/engine/system.c @@ -49,7 +49,7 @@ void Sys_Error( const char *error, ... ) double Sys_DoubleTime( void ) { // precision timer - host.realtime = pi->DoubleTime(); + host.realtime = Com->DoubleTime(); return host.realtime; } @@ -112,7 +112,7 @@ DllMain ================== */ -launcher_exp_t DLLEXPORT *CreateAPI( stdinout_api_t *input ) +launcher_exp_t DLLEXPORT *CreateAPI( stdlib_api_t *input ) { static launcher_exp_t Host; diff --git a/engine/vid_dll.c b/engine/vid_dll.c index 6a91916b..09585bc1 100644 --- a/engine/vid_dll.c +++ b/engine/vid_dll.c @@ -25,7 +25,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include ".\client\client.h" // Structure containing functions exported from refresh DLL -renderer_exp_t *re; +render_exp_t *re; extern HWND cl_hwnd; extern bool ActiveApp, Minimized; @@ -46,7 +46,7 @@ cvar_t *vid_fullscreen; // Global variables used internally by this module viddef_t viddef; // global video state; used by other modules -dll_info_t renderer_dll = { "renderer.dll", NULL, "CreateAPI", NULL, NULL, true, RENDERER_API_VERSION, sizeof(renderer_exp_t) }; +dll_info_t render_dll = { "render.dll", NULL, "CreateAPI", NULL, NULL, true, RENDER_API_VERSION, sizeof(render_exp_t) }; bool reflib_active = 0; HWND cl_hwnd; // Main window handle for life of program @@ -63,11 +63,11 @@ DLL GLUE ========================================================================== */ -stdinout_api_t VID_GetStdio( void ) +stdlib_api_t VID_GetStdio( void ) { - static stdinout_api_t io; + static stdlib_api_t io; - io.api_size = sizeof(stdinout_api_t); + io.api_size = sizeof(stdlib_api_t); io.print = Sys_Print; io.printf = Msg; @@ -76,8 +76,10 @@ stdinout_api_t VID_GetStdio( void ) io.exit = Sys_Quit; io.input = Sys_ConsoleInput; io.sleep = Sys_Sleep; + io.LoadLibrary = Sys_LoadLibrary; io.FreeLibrary = Sys_FreeLibrary; + io.GetProcAddress = std.GetProcAddress; return io; } @@ -442,7 +444,7 @@ void VID_NewWindow ( int width, int height) void VID_FreeReflib (void) { - Sys_FreeLibrary( &renderer_dll ); + Sys_FreeLibrary( &render_dll ); memset (&re, 0, sizeof(re)); reflib_active = false; @@ -460,21 +462,21 @@ char *FS_Title( void ) /* ============== -VID_InitRenderer +VID_InitRender ============== */ -void VID_InitRenderer( void ) +void VID_InitRender( void ) { - static renderer_imp_t ri; - renderer_t CreateRender; + static render_imp_t ri; + render_t CreateRender; - VID_FreeRenderer(); + VID_FreeRender(); - ri.Fs = pi->Fs; - ri.VFs = pi->VFs; - ri.Mem = pi->Mem; - ri.Script = pi->Script; - ri.Compile = pi->Compile; + ri.Fs = Com->Fs; + ri.VFs = Com->VFs; + ri.Mem = Com->Mem; + ri.Script = Com->Script; + ri.Compile = Com->Compile; ri.Stdio = VID_GetStdio(); ri.Cmd_AddCommand = Cmd_AddCommand; @@ -495,12 +497,12 @@ void VID_InitRenderer( void ) // studio callbacks ri.StudioEvent = CL_StudioEvent; - Sys_LoadLibrary( &renderer_dll ); + Sys_LoadLibrary( &render_dll ); - CreateRender = (void *)renderer_dll.main; + CreateRender = (void *)render_dll.main; re = CreateRender( &ri ); - if(!re->Init( global_hInstance, MainWndProc )) Sys_Error("can't init renderer.dll\n"); + if(!re->Init( global_hInstance, MainWndProc )) Sys_Error("can't init render.dll\n"); reflib_active = true; } @@ -531,7 +533,7 @@ void VID_CheckChanges (void) cl.refresh_prepped = false; cls.disable_screen = true; - VID_InitRenderer(); + VID_InitRender(); cls.disable_screen = false; } @@ -570,10 +572,10 @@ void VID_Init (void) /* ============ -VID_FreeRenderer +VID_FreeRender ============ */ -void VID_FreeRenderer (void) +void VID_FreeRender (void) { if ( reflib_active ) { diff --git a/launcher/bsplib/makefile.nmake b/launcher/bsplib/makefile.nmake index 5ddf004c..0e2fea64 100644 --- a/launcher/bsplib/makefile.nmake +++ b/launcher/bsplib/makefile.nmake @@ -8,18 +8,17 @@ !include MAINTARGET = bsplib -LLDLIBS = advapi32.lib user32.lib OBJS = $(MAINTARGET).obj RES = $(MAINTARGET).rc default: $(MAINTARGET).exe $(MAINTARGET).exe: $(MAINTARGET).obj bsplib.res - $(link) $(OBJS) $(LLDLIBS) bsplib.res /out:"bsplib.exe" /subsystem:windows /opt:nowin98 + $(link) $(OBJS) bsplib.res /out:"bsplib.exe" /subsystem:windows /opt:nowin98 /nodefaultlib:"libc.lib" @del $(MAINTARGET).obj $(MAINTARGET).lib $(MAINTARGET).exp $(MAINTARGET).res > nul @copy $(MAINTARGET).exe D:\Xash3D\bin\$(MAINTARGET).exe @del $(MAINTARGET).exe - @echo !!! Done !!! + @echo ‘Є®ЇЁа®ў ­® д ©«®ў: 1. clean: .cpp.obj: diff --git a/launcher/console.c b/launcher/console.c index 176fe2d8..2fde8041 100644 --- a/launcher/console.c +++ b/launcher/console.c @@ -45,9 +45,34 @@ typedef struct int status; int windowWidth, windowHeight; WNDPROC SysInputLineWndProc; -}WinConData; +} WinConData; static WinConData s_wcd; +// gdi32 export table +static HDC (_stdcall *pGetDC)(HWND); +static int (_stdcall *pReleaseDC)(HWND,HDC); +static bool (_stdcall *pDeleteObject)(HGDIOBJ); +static int (_stdcall *pGetDeviceCaps)(HDC,int); +static HBRUSH(_stdcall *pCreateSolidBrush)(COLORREF); +static COLORREF (_stdcall *pSetBkColor)(HDC,COLORREF); +static COLORREF (_stdcall *pSetTextColor)(HDC,COLORREF); +static HFONT (_stdcall *pCreateFont)(int,int,int,int,int,dword,dword,dword,dword,dword,dword,dword,dword,LPCSTR); + +static dllfunc_t gdi32_funcs[] = +{ + {"GetDC", (void **) &pGetDC }, + {"ReleaseDC", (void **) &pReleaseDC }, + {"SetBkColor", (void **) &pSetBkColor }, + {"CreateFontA", (void **) &pCreateFont }, + {"DeleteObject", (void **) &pDeleteObject }, + {"SetTextColor", (void **) &pSetTextColor }, + {"GetDeviceCaps", (void **) &pGetDeviceCaps }, + {"CreateSolidBrush", (void **) &pCreateSolidBrush }, + { NULL, NULL } +}; + +dll_info_t gdi32_dll = { /*"gdi32.dll"*/NULL, gdi32_funcs, NULL, NULL, NULL, true, 0, 0 }; + void Sys_ShowConsoleW( bool show ) { if ( show == s_wcd.status ) return; @@ -342,8 +367,9 @@ void Sys_CreateConsoleW( const char *caption ) wc.lpszMenuName = 0; wc.lpszClassName = SYSCONSOLE; - if (!RegisterClass (&wc) ) return; - + Sys_LoadLibrary( &gdi32_dll ); + if (!RegisterClass (&wc)) return; + if(about_mode) { CONSTYLE &= ~WS_VSCROLL; @@ -460,6 +486,7 @@ void Sys_DestroyConsoleW( void ) } UnregisterClass (SYSCONSOLE, base_hInstance); + Sys_FreeLibrary( &gdi32_dll ); } /* diff --git a/launcher/credits/makefile.nmake b/launcher/credits/makefile.nmake index 45061f39..00f227e0 100644 --- a/launcher/credits/makefile.nmake +++ b/launcher/credits/makefile.nmake @@ -8,17 +8,16 @@ !include MAINTARGET = credits -LLDLIBS = advapi32.lib user32.lib OBJS = $(MAINTARGET).obj default: $(MAINTARGET).exe $(MAINTARGET).exe: $(MAINTARGET).obj - $(link) $(OBJS) $(LLDLIBS) /out:"credits.exe" /subsystem:windows + $(link) $(OBJS) /out:"credits.exe" /subsystem:windows /opt:nowin98 /nodefaultlib:"libc.lib" @del $(MAINTARGET).obj $(MAINTARGET).lib $(MAINTARGET).exp > nul @copy $(MAINTARGET).exe D:\Xash3D\$(MAINTARGET).exe @del $(MAINTARGET).exe - @echo !!! Done !!! + @echo ‘Є®ЇЁа®ў ­® д ©«®ў: 1. clean: .cpp.obj: diff --git a/launcher/dedicated/makefile.nmake b/launcher/dedicated/makefile.nmake index 640f89c2..681727fb 100644 --- a/launcher/dedicated/makefile.nmake +++ b/launcher/dedicated/makefile.nmake @@ -8,18 +8,17 @@ !include MAINTARGET = xash -LLDLIBS = advapi32.lib user32.lib OBJS = $(MAINTARGET).obj RES = $(MAINTARGET).rc default: $(MAINTARGET).exe $(MAINTARGET).exe: $(MAINTARGET).obj xash.res - $(link) $(OBJS) $(LLDLIBS) xash.res /out:"xash.exe" /subsystem:windows + $(link) $(OBJS) xash.res /out:"xash.exe" /subsystem:windows /opt:nowin98 /nodefaultlib:"libc.lib" @del $(MAINTARGET).obj $(MAINTARGET).lib $(MAINTARGET).exp $(MAINTARGET).res > nul @copy $(MAINTARGET).exe D:\Xash3D\#xash.exe @del $(MAINTARGET).exe - @echo !!! Done !!! + @echo ‘Є®ЇЁа®ў ­® д ©«®ў: 1. clean: .cpp.obj: diff --git a/launcher/editor/makefile.nmake b/launcher/editor/makefile.nmake index 260bd282..57d0916b 100644 --- a/launcher/editor/makefile.nmake +++ b/launcher/editor/makefile.nmake @@ -8,18 +8,17 @@ !include MAINTARGET = editor -LLDLIBS = advapi32.lib user32.lib OBJS = $(MAINTARGET).obj RES = $(MAINTARGET).rc default: $(MAINTARGET).exe $(MAINTARGET).exe: $(MAINTARGET).obj editor.res - $(link) $(OBJS) $(LLDLIBS) editor.res /out:"editor.exe" /subsystem:windows + $(link) $(OBJS) editor.res /out:"editor.exe" /subsystem:windows /opt:nowin98 /nodefaultlib:"libc.lib" @del $(MAINTARGET).obj $(MAINTARGET).lib $(MAINTARGET).exp $(MAINTARGET).res > nul @copy $(MAINTARGET).exe D:\Xash3D\$(MAINTARGET).exe @del $(MAINTARGET).exe - @echo !!! Done !!! + @echo ‘Є®ЇЁа®ў ­® д ©«®ў: 1. clean: .cpp.obj: diff --git a/launcher/getlib.h b/launcher/getlib.h index 10cf27d3..8d0dacee 100644 --- a/launcher/getlib.h +++ b/launcher/getlib.h @@ -14,20 +14,33 @@ #include #include -#pragma comment(lib, "advapi32") -#pragma comment(lib, "user32") +#pragma comment(lib, "msvcrt") #pragma comment(linker,"/MERGE:.rdata=.text") #pragma comment(linker,"/FILEALIGN:512 /SECTION:.text, EWRX /IGNORE:4078") -#define Run32( prog ) return CreateMain32()( #prog, lpCmdLine ) +#define Run32( prog ) return CreateMain32()( #prog ) //console format -typedef int (*winmain_t)( char *funcname, LPSTR lpCmdLine ); +typedef int (*winmain_t)( char *funcname ); char szSearch[ 5 ][ 1024 ]; char szFsPath[ 4096 ]; HINSTANCE hmain; +void GetError( const char *errorstring ) +{ + HINSTANCE user32_dll = LoadLibrary( "user32.dll" ); + static int (*pMessageBoxA)(HWND hWnd, LPCSTR lpText, LPCSTR lpCaption, UINT uType); + + if(!errorstring) exit( 0 ); + + if( user32_dll ) pMessageBoxA = (void *)GetProcAddress( user32_dll, "MessageBoxA" ); + if(pMessageBoxA) pMessageBoxA( 0, errorstring, "Error", MB_OK ); + if( user32_dll ) FreeLibrary( user32_dll ); // no need anymore... + + exit( 1 ); +} + BOOL GetBin( void ) { //grab direct path? @@ -45,17 +58,37 @@ BOOL GetEnv( void ) BOOL GetReg( void ) { + HINSTANCE advapi32_dll = LoadLibrary( "advapi32.dll" ); + static long(_stdcall *pRegOpenKeyEx)(HKEY,LPCSTR,DWORD,REGSAM,PHKEY); + static long(_stdcall *pRegQueryValueEx)(HKEY,LPCSTR,LPDWORD,LPDWORD,LPBYTE,LPDWORD); + static long(_stdcall *pRegCloseKey)(HKEY); + DWORD dwBufLen = 4096; // max env length HKEY hKey; - DWORD dwBufLen = 4096; //max env length long lRet; - lRet = RegOpenKeyEx( HKEY_LOCAL_MACHINE, "System\\CurrentControlSet\\Control\\Session Manager\\Environment", 0, KEY_READ, &hKey); - if(lRet != ERROR_SUCCESS) return FALSE; - lRet = RegQueryValueEx( hKey, "Xash3D", NULL, NULL, (byte *)szFsPath, &dwBufLen); - if(lRet != ERROR_SUCCESS) return FALSE; - RegCloseKey( hKey ); - + if(advapi32_dll) + { + pRegCloseKey = (void *)GetProcAddress( advapi32_dll, "RegCloseKey" ); + pRegOpenKeyEx = (void *)GetProcAddress( advapi32_dll, "RegOpenKeyExA" ); + pRegQueryValueEx = (void *)GetProcAddress( advapi32_dll, "RegQueryValueExA" ); + } + else goto failure; + + if(pRegCloseKey && pRegOpenKeyEx && pRegQueryValueEx) + { + lRet = pRegOpenKeyEx( HKEY_LOCAL_MACHINE, "System\\CurrentControlSet\\Control\\Session Manager\\Environment", 0, KEY_READ, &hKey); + if(lRet != ERROR_SUCCESS) goto failure; + lRet = pRegQueryValueEx( hKey, "Xash3D", NULL, NULL, (byte *)szFsPath, &dwBufLen); + if(lRet != ERROR_SUCCESS) goto failure; + pRegCloseKey( hKey ); + } + else goto failure; + return TRUE; +failure: + if( advapi32_dll ) FreeLibrary( advapi32_dll ); //don't forget freeing + + return FALSE; } void GetLibrary ( void ) @@ -91,24 +124,18 @@ void GetLibrary ( void ) winmain_t CreateMain32( void ) { - winmain_t main; + winmain_t main; GetLibrary(); if (hmain) { main = (winmain_t)GetProcAddress( hmain, "CreateAPI" ); - if(!main) - { - MessageBox( 0, "Unable to load the launcher.dll", "Error", MB_OK ); - exit( 1 ); - } + if(!main) GetError("Unable to load the launcher.dll" ); return main; } - MessageBox( 0, "Unable to load the launcher.dll", "Error", MB_OK ); - exit( 1 ); - + GetError("Unable to load the launcher.dll" ); return 0; //make compiller happy } diff --git a/launcher/launcher.c b/launcher/launcher.c index f354a235..faa02230 100644 --- a/launcher/launcher.c +++ b/launcher/launcher.c @@ -4,7 +4,6 @@ //======================================================================= #include "launcher.h" -#include static int app_name; bool hooked_out = false; @@ -16,7 +15,7 @@ char caption[64]; const char *show_credits = "\n\n\n\n\tCopyright XashXT Group 2007 ©\n\t All Rights Reserved\n\n\t Visit www.xash.ru\n"; -dll_info_t platform_dll = { "platform.dll", NULL, "CreateAPI", NULL, NULL, true, PLATFORM_API_VERSION, sizeof(platform_exp_t) }; +dll_info_t common_dll = { "common.dll", NULL, "CreateAPI", NULL, NULL, true, COMMON_API_VERSION, sizeof(common_exp_t) }; dll_info_t engine_dll = { "engine.dll", NULL, "CreateAPI", NULL, NULL, true, LAUNCHER_API_VERSION, sizeof(launcher_exp_t) }; dll_info_t editor_dll = { "editor.dll", NULL, "CreateAPI", NULL, NULL, true, LAUNCHER_API_VERSION, sizeof(launcher_exp_t) }; dll_info_t *linked_dll; // generic hinstance @@ -35,12 +34,12 @@ typedef enum CREDITS, // misc }; -int com_argc; -char *com_argv[MAX_NUM_ARGVS]; -char progname[32]; // limit of funcname -platform_exp_t *pi; // callback to utilities -static double start, end; -byte *mempool; // generic mempoolptr +int com_argc; +char *com_argv[MAX_NUM_ARGVS]; +char progname[32]; // limit of funcname +common_exp_t *Com; // callback to utilities +static double start, end; +byte *mempool; // generic mempoolptr /* @@ -98,28 +97,28 @@ void LookupInstance( const char *funcname ) else if(!strcmp(progname, "bsplib")) { app_name = BSPLIB; - linked_dll = &platform_dll; // pointer to platform.dll info + linked_dll = &common_dll; // pointer to common.dll info strcpy(log_path, "bsplib.log" ); // xash3d root directory strcpy(caption, "Xash3D BSP Compiler"); } else if(!strcmp(progname, "qcclib")) { app_name = QCCLIB; - linked_dll = &platform_dll; // pointer to platform.dll info + linked_dll = &common_dll; // pointer to common.dll info sprintf(log_path, "%s/compile.log", sys_rootdir ); // same as .exe file strcpy(caption, "Xash3D QuakeC Compiler"); } else if(!strcmp(progname, "sprite")) { app_name = SPRITE; - linked_dll = &platform_dll; // pointer to platform.dll info + linked_dll = &common_dll; // pointer to common.dll info sprintf(log_path, "%s/spritegen.log", sys_rootdir ); // same as .exe file strcpy(caption, "Xash3D Sprite Compiler"); } else if(!strcmp(progname, "studio")) { app_name = STUDIO; - linked_dll = &platform_dll; // pointer to platform.dll info + linked_dll = &common_dll; // pointer to common.dll info sprintf(log_path, "%s/studiomdl.log", sys_rootdir ); // same as .exe file strcpy(caption, "Xash3D Studio Models Compiler"); } @@ -133,9 +132,9 @@ void LookupInstance( const char *funcname ) else app_name = DEFAULT; } -stdinout_api_t *Get_StdAPI( void ) +stdlib_api_t *Get_StdAPI( void ) { - static stdinout_api_t std; + static stdlib_api_t std; // setup sysfuncs std.printf = Msg; @@ -149,24 +148,25 @@ stdinout_api_t *Get_StdAPI( void ) std.LoadLibrary = Sys_LoadLibrary; std.FreeLibrary = Sys_FreeLibrary; + std.GetProcAddress = Sys_GetProcAddress; return &std; } /* ================== -PlatformInit +CommonInit platform.dll needs for some setup operations so do it manually ================== */ -void PlatformInit ( char *funcname, int argc, char **argv ) +void CommonInit ( char *funcname, int argc, char **argv ) { byte bspflags = 0, qccflags = 0; char source[64], gamedir[64]; - pi->Init( argc, argv ); + Com->Init( argc, argv ); switch(app_name) { @@ -180,7 +180,7 @@ void PlatformInit ( char *funcname, int argc, char **argv ) if(CheckParm("-full")) bspflags |= BSP_FULLCOMPILE; if(CheckParm("-onlyents")) bspflags |= BSP_ONLYENTS; - pi->Compile.PrepareBSP( gamedir, source, bspflags ); + Com->Compile.PrepareBSP( gamedir, source, bspflags ); break; case QCCLIB: if(!GetParmFromCmdLine("+dat", source )) @@ -191,22 +191,22 @@ void PlatformInit ( char *funcname, int argc, char **argv ) if(CheckParm("/O2")) qccflags |= QCC_OPT_LEVEL_2; if(CheckParm("/O2")) qccflags |= QCC_OPT_LEVEL_3; - pi->Compile.PrepareDAT( gamedir, source, qccflags ); + Com->Compile.PrepareDAT( gamedir, source, qccflags ); break; case SPRITE: - pi->InitRootDir("."); - start = pi->DoubleTime(); + Com->InitRootDir("."); + start = Com->DoubleTime(); break; case STUDIO: - pi->InitRootDir("."); - start = pi->DoubleTime(); + Com->InitRootDir("."); + start = Com->DoubleTime(); break; case DEFAULT: break; } } -void PlatformMain ( void ) +void CommonMain ( void ) { search_t *search; char qcfilename[64], typemod[16]; @@ -217,19 +217,19 @@ void PlatformMain ( void ) switch(app_name) { case SPRITE: - CompileMod = pi->Compile.Sprite; + CompileMod = Com->Compile.Sprite; strcpy(typemod, "sprites" ); break; case STUDIO: - CompileMod = pi->Compile.Studio; + CompileMod = Com->Compile.Studio; strcpy(typemod, "models" ); break; case BSPLIB: - pi->Compile.BSP(); + Com->Compile.BSP(); strcpy(typemod, "maps" ); break; case QCCLIB: - pi->Compile.DAT(); + Com->Compile.DAT(); strcpy(typemod, "progs" ); break; case DEFAULT: @@ -242,7 +242,7 @@ void PlatformMain ( void ) if(!GetParmFromCmdLine("-qcfile", qcfilename )) { //search for all .ac files in folder - search = pi->Fs.Search("*.qc", true ); + search = Com->Fs.Search("*.qc", true ); if(!search) Sys_Error("no qcfiles found in this folder!\n"); for( i = 0; i < search->numfilenames; i++ ) @@ -253,16 +253,16 @@ void PlatformMain ( void ) } else CompileMod( mempool, qcfilename, parms ); - end = pi->DoubleTime(); + end = Com->DoubleTime(); Msg ("%5.1f seconds elapsed\n", end - start); if(numCompiledMods > 1) Msg("total %d %s compiled\n", numCompiledMods, typemod ); } -void PlatformShutdown ( void ) +void CommonShutdown ( void ) { Mem_Check(); //check for leaks Mem_FreePool( &mempool ); - pi->Shutdown(); + Com->Shutdown(); } @@ -274,7 +274,7 @@ Find needed library, setup and run it void CreateInstance( void ) { // export - platform_t CreatePlat; + common_t CreateCom; launcher_t CreateHost; launcher_exp_t *Host; @@ -300,13 +300,13 @@ void CreateInstance( void ) case QCCLIB: case SPRITE: case STUDIO: - CreatePlat = (void *)linked_dll->main; + CreateCom = (void *)linked_dll->main; // set callback - pi = CreatePlat(Get_StdAPI()); - Host_Init = PlatformInit; - Host_Main = PlatformMain; - Host_Free = PlatformShutdown; + Com = CreateCom(Get_StdAPI()); + Host_Init = CommonInit; + Host_Main = CommonMain; + Host_Free = CommonShutdown; break; case CREDITS: Sys_Print( show_credits ); @@ -374,13 +374,20 @@ void API_SetConsole( void ) } -void InitLauncher( char *funcname ) +void RunLauncher( char *funcname ) { HANDLE hStdout; - char dev_level[4]; OSVERSIONINFO vinfo; + MEMORYSTATUS lpBuffer; + char dev_level[4]; + + lpBuffer.dwLength = sizeof(MEMORYSTATUS); + GlobalMemoryStatus (&lpBuffer); + + // parse and copy args into local array + ParseCommandLine(GetCommandLine()); - API_Reset();// fill stdinout api + API_Reset();// fill stdlib api // get current hInstance first base_hInstance = (HINSTANCE)GetModuleHandle( NULL ); @@ -421,16 +428,9 @@ Base Entry Point ================= */ -DLLEXPORT int CreateAPI( char *funcname, LPSTR lpCmdLine ) +DLLEXPORT int CreateAPI( char *funcname ) { - MEMORYSTATUS lpBuffer; - - lpBuffer.dwLength = sizeof(MEMORYSTATUS); - GlobalMemoryStatus (&lpBuffer); - - // parse and copy args into local array - ParseCommandLine( lpCmdLine ); - InitLauncher( funcname ); + RunLauncher( funcname ); return 0; } \ No newline at end of file diff --git a/launcher/launcher.dsp b/launcher/launcher.dsp index a8db1ec6..ae3321f5 100644 --- a/launcher/launcher.dsp +++ b/launcher/launcher.dsp @@ -43,7 +43,7 @@ RSC=rc.exe # PROP Ignore_Export_Lib 1 # PROP Target_Dir "" # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LAUNCHER_EXPORTS" /YX /FD /c -# ADD CPP /nologo /W3 /GX /O2 /Ob0 /I "./" /I "../public" /I "../platform/formats" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /FD /c +# ADD CPP /nologo /MD /W3 /GX /O2 /Ob0 /I "./" /I "../public" /I "../platform/formats" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /FD /c # SUBTRACT CPP /YX # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 @@ -54,7 +54,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 /opt:nowin98 -# ADD LINK32 kernel32.lib user32.lib gdi32.lib advapi32.lib /nologo /dll /pdb:none /machine:I386 /opt:nowin98 +# ADD LINK32 msvcrt.lib user32.lib gdi32.lib advapi32.lib /nologo /dll /pdb:none /machine:I386 /nodefaultlib:"libc.lib" /opt:nowin98 # Begin Custom Build TargetDir=\XASH3D\src_main\!source\temp\launcher\!release InputPath=\XASH3D\src_main\!source\temp\launcher\!release\launcher.dll @@ -79,7 +79,7 @@ SOURCE="$(InputPath)" # PROP Ignore_Export_Lib 1 # PROP Target_Dir "" # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LAUNCHER_EXPORTS" /YX /FD /GZ /c -# ADD CPP /nologo /MTd /W3 /Gm /Gi /GX /ZI /Od /I "./" /I "../public" /I "../platform/formats" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /FR /FD /GZ /c +# ADD CPP /nologo /MDd /W3 /Gm /Gi /GX /ZI /Od /I "./" /I "../public" /I "../platform/formats" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /FR /FD /GZ /c # SUBTRACT CPP /YX # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 @@ -90,7 +90,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept -# ADD LINK32 kernel32.lib user32.lib gdi32.lib advapi32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept +# ADD LINK32 msvcrt.lib user32.lib gdi32.lib advapi32.lib /nologo /dll /debug /machine:I386 /nodefaultlib:"msvcrtd.lib" /pdbtype:sept # Begin Custom Build TargetDir=\XASH3D\src_main\!source\temp\launcher\!debug InputPath=\XASH3D\src_main\!source\temp\launcher\!debug\launcher.dll @@ -120,6 +120,10 @@ SOURCE=.\launcher.c # End Source File # Begin Source File +SOURCE=.\stdlib.c +# End Source File +# Begin Source File + SOURCE=.\utils.c # End Source File # End Group diff --git a/launcher/launcher.h b/launcher/launcher.h index 80d1915e..c4ebeeae 100644 --- a/launcher/launcher.h +++ b/launcher/launcher.h @@ -29,6 +29,7 @@ void Sys_Exit( void ); // static void Sys_Sleep( int msec); bool Sys_LoadLibrary ( dll_info_t *dll ); // load library bool Sys_FreeLibrary ( dll_info_t *dll ); // free library +void* Sys_GetProcAddress ( dll_info_t *dll, const char* name ); void Sys_WaitForQuit( void ); // waiting for 'ESC' or close command // export variables @@ -88,14 +89,14 @@ __inline void NullVoidWithName( const char *caption ) {} __inline void NullInit ( char *funcname, int argc, char **argv ) {} //memory manager -#define Mem_Alloc(pool, size) pi->Mem.Alloc(pool, size, __FILE__, __LINE__) -#define Mem_Realloc(pool, ptr, size) pi->Mem.Realloc(pool, ptr, size, __FILE__, __LINE__) -#define Mem_Free(mem) pi->Mem.Free(mem, __FILE__, __LINE__) -#define Mem_AllocPool(name) pi->Mem.AllocPool(name, __FILE__, __LINE__) -#define Mem_FreePool(pool) pi->Mem.FreePool(pool, __FILE__, __LINE__) -#define Mem_EmptyPool(pool) pi->Mem.EmptyPool(pool, __FILE__, __LINE__) -#define Mem_Move(dest, src, size ) pi->Mem.Move (dest, src, size, __FILE__, __LINE__) -#define Mem_Copy(dest, src, size ) pi->Mem.Copy (dest, src, size, __FILE__, __LINE__) -#define Mem_Check() pi->Mem.CheckSentinelsGlobal(__FILE__, __LINE__) +#define Mem_Alloc(pool, size) Com->Mem.Alloc(pool, size, __FILE__, __LINE__) +#define Mem_Realloc(pool, ptr, size) Com->Mem.Realloc(pool, ptr, size, __FILE__, __LINE__) +#define Mem_Free(mem) Com->Mem.Free(mem, __FILE__, __LINE__) +#define Mem_AllocPool(name) Com->Mem.AllocPool(name, __FILE__, __LINE__) +#define Mem_FreePool(pool) Com->Mem.FreePool(pool, __FILE__, __LINE__) +#define Mem_EmptyPool(pool) Com->Mem.EmptyPool(pool, __FILE__, __LINE__) +#define Mem_Move(dest, src, size ) Com->Mem.Move (dest, src, size, __FILE__, __LINE__) +#define Mem_Copy(dest, src, size ) Com->Mem.Copy (dest, src, size, __FILE__, __LINE__) +#define Mem_Check() Com->Mem.CheckSentinelsGlobal(__FILE__, __LINE__) #endif//LAUNCHER_H \ No newline at end of file diff --git a/launcher/qcclib/makefile.nmake b/launcher/qcclib/makefile.nmake index afa3bd9f..30c2750a 100644 --- a/launcher/qcclib/makefile.nmake +++ b/launcher/qcclib/makefile.nmake @@ -8,18 +8,17 @@ !include MAINTARGET = qcclib -LLDLIBS = advapi32.lib user32.lib OBJS = $(MAINTARGET).obj RES = $(MAINTARGET).rc default: $(MAINTARGET).exe $(MAINTARGET).exe: $(MAINTARGET).obj qcclib.res - $(link) $(OBJS) $(LLDLIBS) qcclib.res /out:"qcclib.exe" /subsystem:windows + $(link) $(OBJS) qcclib.res /out:"qcclib.exe" /subsystem:windows /opt:nowin98 /nodefaultlib:"libc.lib" @del $(MAINTARGET).obj $(MAINTARGET).lib $(MAINTARGET).exp $(MAINTARGET).res > nul @copy $(MAINTARGET).exe D:\Xash3D\bin\$(MAINTARGET).exe @del $(MAINTARGET).exe - @echo !!! Done !!! + @echo ‘Є®ЇЁа®ў ­® д ©«®ў: 1. clean: .cpp.obj: diff --git a/launcher/sprite/makefile.nmake b/launcher/sprite/makefile.nmake index c4cb9e5f..f56b0be5 100644 --- a/launcher/sprite/makefile.nmake +++ b/launcher/sprite/makefile.nmake @@ -8,17 +8,16 @@ !include MAINTARGET = spritegen -LLDLIBS = advapi32.lib user32.lib OBJS = $(MAINTARGET).obj default: $(MAINTARGET).exe $(MAINTARGET).exe: $(MAINTARGET).obj - $(link) $(OBJS) $(LLDLIBS) /out:"spritegen.exe" /subsystem:windows + $(link) $(OBJS) /out:"spritegen.exe" /subsystem:windows /opt:nowin98 /nodefaultlib:"libc.lib" @del $(MAINTARGET).obj $(MAINTARGET).lib $(MAINTARGET).exp > nul @copy $(MAINTARGET).exe D:\Xash3D\bin\$(MAINTARGET).exe @del $(MAINTARGET).exe - @echo !!! Done !!! + @echo ‘Є®ЇЁа®ў ­® д ©«®ў: 1. clean: .cpp.obj: diff --git a/launcher/stdlib.c b/launcher/stdlib.c new file mode 100644 index 00000000..232e6e9f --- /dev/null +++ b/launcher/stdlib.c @@ -0,0 +1,75 @@ +//======================================================================= +// Copyright XashXT Group 2007 © +// stdlib.c - std lib portable utils +//======================================================================= + +#include "launcher.h" + +char *strupper(char *start) +{ + char *in; + in = start; + while (*in) + { + *in = toupper(*in); + in++; + } + return start; +} + +#ifndef HAVE_STRLCAT +size_t strlcat(char *dst, const char *src, size_t siz) +{ + register char *d = dst; + register const char *s = src; + register size_t n = siz; + size_t dlen; + + // Find the end of dst and adjust bytes left but don't go past end + while (n-- != 0 && *d != '\0') d++; + dlen = d - dst; + n = siz - dlen; + + if (n == 0) return(dlen + strlen(s)); + while (*s != '\0') + { + if (n != 1) + { + *d++ = *s; + n--; + } + s++; + } + + *d = '\0'; + return(dlen + (s - src)); //count does not include NUL +} +#endif + + +#ifndef HAVE_STRLCPY +size_t strlcpy(char *dst, const char *src, size_t siz) +{ + register char *d = dst; + register const char *s = src; + register size_t n = siz; + + // Copy as many bytes as will fit + if (n != 0 && --n != 0) + { + do + { + if ((*d++ = *s++) == 0) + break; + } while (--n != 0); + } + + // Not enough room in dst, add NUL and traverse rest of src + if (n == 0) + { + if (siz != 0) *d = '\0'; //NUL-terminate dst + while (*s++); + } + return(s - src - 1); //count does not include NUL +} +#endif \ No newline at end of file diff --git a/launcher/studio/makefile.nmake b/launcher/studio/makefile.nmake index 6943481b..6f6b4824 100644 --- a/launcher/studio/makefile.nmake +++ b/launcher/studio/makefile.nmake @@ -8,17 +8,16 @@ !include MAINTARGET = studiomdl -LLDLIBS = advapi32.lib user32.lib OBJS = $(MAINTARGET).obj default: $(MAINTARGET).exe $(MAINTARGET).exe: $(MAINTARGET).obj - $(link) $(OBJS) $(LLDLIBS) /pdb:none /nologo /out:"studiomdl.exe" /subsystem:windows + $(link) $(OBJS) /out:"studiomdl.exe" /subsystem:windows /opt:nowin98 /nodefaultlib:"libc.lib" @del $(MAINTARGET).obj $(MAINTARGET).lib $(MAINTARGET).exp > nul @copy $(MAINTARGET).exe D:\Xash3D\bin\$(MAINTARGET).exe @del $(MAINTARGET).exe - @echo !!! Done !!! + @echo ‘Є®ЇЁа®ў ­® д ©«®ў: 1. clean: .cpp.obj: diff --git a/launcher/utils.c b/launcher/utils.c index ee185d77..8f423354 100644 --- a/launcher/utils.c +++ b/launcher/utils.c @@ -35,12 +35,12 @@ const char* Log_Timestamp( void ) float CalcEngineVersion( void ) { - return LAUNCHER_VERSION + PLATFORM_VERSION + RENDERER_VERSION + ENGINE_VERSION; + return LAUNCHER_VERSION + COMMON_VERSION + RENDER_VERSION + ENGINE_VERSION; } float CalcEditorVersion( void ) { - return LAUNCHER_VERSION + PLATFORM_VERSION + RENDERER_VERSION + EDITOR_VERSION; + return LAUNCHER_VERSION + COMMON_VERSION + RENDER_VERSION + EDITOR_VERSION; } /* @@ -147,7 +147,7 @@ void Sys_Exit (void) bool Sys_LoadLibrary ( dll_info_t *dll ) { const dllfunc_t *func; - bool native_lib; + bool native_lib = false; char errorstring[MAX_QPATH]; // check errors @@ -162,9 +162,8 @@ bool Sys_LoadLibrary ( dll_info_t *dll ) // lookup export table for (func = dll->fcts; func && func->name != NULL; func++) *func->func = NULL; - native_lib = false; } - else native_lib = true; + else if( dll->entry) native_lib = true; if(!dll->link) dll->link = LoadLibrary ( va("bin/%s", dll->name)); if(!dll->link) dll->link = LoadLibrary ( dll->name ); // environment pathes @@ -178,7 +177,7 @@ bool Sys_LoadLibrary ( dll_info_t *dll ) if(native_lib) { - if((dll->main = (void *)GetProcAddress(dll->link, dll->entry )) == 0) + if((dll->main = Sys_GetProcAddress(dll, dll->entry )) == 0) { sprintf(errorstring, "Sys_LoadLibrary: %s has no valid entry point\n", dll->name ); goto error; @@ -189,7 +188,7 @@ bool Sys_LoadLibrary ( dll_info_t *dll ) // Get the function adresses for(func = dll->fcts; func && func->name != NULL; func++) { - if (!(*func->func = (void *)GetProcAddress(dll->link, func->name))) + if (!(*func->func = Sys_GetProcAddress(dll, func->name))) { sprintf(errorstring, "Sys_LoadLibrary: %s missing or invalid function (%s)\n", dll->name, func->name ); goto error; @@ -234,11 +233,20 @@ error: return false; } +void* Sys_GetProcAddress ( dll_info_t *dll, const char* name ) +{ + if(!dll || !dll->link) // invalid desc + return NULL; + + return (void *)GetProcAddress (dll->link, name); +} + bool Sys_FreeLibrary ( dll_info_t *dll ) { if(!dll || !dll->link) // invalid desc or alredy freed return false; + MsgDev(D_ERROR, "Sys_FreeLibrary: Unloading %s\n", dll->name ); FreeLibrary (dll->link); dll->link = NULL; diff --git a/launcher/xash/makefile.nmake b/launcher/xash/makefile.nmake index a89f5fe3..d283db8e 100644 --- a/launcher/xash/makefile.nmake +++ b/launcher/xash/makefile.nmake @@ -8,18 +8,17 @@ !include MAINTARGET = xash -LLDLIBS = advapi32.lib user32.lib OBJS = $(MAINTARGET).obj RES = $(MAINTARGET).rc default: $(MAINTARGET).exe $(MAINTARGET).exe: $(MAINTARGET).obj xash.res - $(link) $(OBJS) $(LLDLIBS) xash.res /out:"xash.exe" /subsystem:windows + $(link) $(OBJS) xash.res /out:"xash.exe" /subsystem:windows /opt:nowin98 /nodefaultlib:"libc.lib" @del $(MAINTARGET).obj $(MAINTARGET).lib $(MAINTARGET).exp $(MAINTARGET).res > nul @copy $(MAINTARGET).exe D:\Xash3D\$(MAINTARGET).exe @del $(MAINTARGET).exe - @echo !!! Done !!! + @echo ‘Є®ЇЁа®ў ­® д ©«®ў: 1. clean: .cpp.obj: diff --git a/launchers.bat b/launchers.bat new file mode 100644 index 00000000..00f37a66 --- /dev/null +++ b/launchers.bat @@ -0,0 +1,34 @@ +@echo off + +cd launcher +cd bsplib +makefile.nmake + +cd .. +cd credits +makefile.nmake + +cd .. +cd dedicated +makefile.nmake + +cd .. +cd editor +makefile.nmake + +cd .. +cd qcclib +makefile.nmake + +cd .. +cd sprite +makefile.nmake + +cd .. +cd studio +makefile.nmake + +cd .. +cd xash +makefile.nmake +pause \ No newline at end of file diff --git a/platform/ziplib.c b/platform/ziplib.c deleted file mode 100644 index 66d5ad4c..00000000 --- a/platform/ziplib.c +++ /dev/null @@ -1,1308 +0,0 @@ -//======================================================================= -// Copyright (C) XashXT Group 2006 -// All Rights Reserved -//======================================================================= - -#include "platform.h" -#include "baseutils.h" -#include "zip32.h" - -#define BASE 65521UL // largest prime smaller than 65536 -#define NMAX 5552 - -//crc 32 -#define DO1 crc = crc_table[0][((int)crc ^ (*buf++)) & 0xff] ^ (crc >> 8) -#define DO8 DO1; DO1; DO1; DO1; DO1; DO1; DO1; DO1 - -//adler 32 -#define BASE 65521UL /* largest prime smaller than 65536 */ -#define ADO1(buf,i) {adler += (buf)[i]; sum2 += adler;} -#define ADO2(buf,i) ADO1(buf,i); ADO1(buf,i+1); -#define ADO4(buf,i) ADO2(buf,i); ADO2(buf,i+2); -#define ADO8(buf,i) ADO4(buf,i); ADO4(buf,i+4); -#define ADO16(buf) ADO8(buf,0); ADO8(buf,8); -#define MOD(a) a %= BASE -#define MOD4(a) a %= BASE - -//memory opertions -byte* zcalloc (byte* opaque, uint items, uint size) -{ - return (byte *)Malloc( items * size ); -} - -void zcfree (byte* opaque, byte* ptr) -{ - Free( ptr ); -} - -static const code lenfix[512] = { - {96,7,0},{0,8,80},{0,8,16},{20,8,115},{18,7,31},{0,8,112},{0,8,48}, - {0,9,192},{16,7,10},{0,8,96},{0,8,32},{0,9,160},{0,8,0},{0,8,128}, - {0,8,64},{0,9,224},{16,7,6},{0,8,88},{0,8,24},{0,9,144},{19,7,59}, - {0,8,120},{0,8,56},{0,9,208},{17,7,17},{0,8,104},{0,8,40},{0,9,176}, - {0,8,8},{0,8,136},{0,8,72},{0,9,240},{16,7,4},{0,8,84},{0,8,20}, - {21,8,227},{19,7,43},{0,8,116},{0,8,52},{0,9,200},{17,7,13},{0,8,100}, - {0,8,36},{0,9,168},{0,8,4},{0,8,132},{0,8,68},{0,9,232},{16,7,8}, - {0,8,92},{0,8,28},{0,9,152},{20,7,83},{0,8,124},{0,8,60},{0,9,216}, - {18,7,23},{0,8,108},{0,8,44},{0,9,184},{0,8,12},{0,8,140},{0,8,76}, - {0,9,248},{16,7,3},{0,8,82},{0,8,18},{21,8,163},{19,7,35},{0,8,114}, - {0,8,50},{0,9,196},{17,7,11},{0,8,98},{0,8,34},{0,9,164},{0,8,2}, - {0,8,130},{0,8,66},{0,9,228},{16,7,7},{0,8,90},{0,8,26},{0,9,148}, - {20,7,67},{0,8,122},{0,8,58},{0,9,212},{18,7,19},{0,8,106},{0,8,42}, - {0,9,180},{0,8,10},{0,8,138},{0,8,74},{0,9,244},{16,7,5},{0,8,86}, - {0,8,22},{64,8,0},{19,7,51},{0,8,118},{0,8,54},{0,9,204},{17,7,15}, - {0,8,102},{0,8,38},{0,9,172},{0,8,6},{0,8,134},{0,8,70},{0,9,236}, - {16,7,9},{0,8,94},{0,8,30},{0,9,156},{20,7,99},{0,8,126},{0,8,62}, - {0,9,220},{18,7,27},{0,8,110},{0,8,46},{0,9,188},{0,8,14},{0,8,142}, - {0,8,78},{0,9,252},{96,7,0},{0,8,81},{0,8,17},{21,8,131},{18,7,31}, - {0,8,113},{0,8,49},{0,9,194},{16,7,10},{0,8,97},{0,8,33},{0,9,162}, - {0,8,1},{0,8,129},{0,8,65},{0,9,226},{16,7,6},{0,8,89},{0,8,25}, - {0,9,146},{19,7,59},{0,8,121},{0,8,57},{0,9,210},{17,7,17},{0,8,105}, - {0,8,41},{0,9,178},{0,8,9},{0,8,137},{0,8,73},{0,9,242},{16,7,4}, - {0,8,85},{0,8,21},{16,8,258},{19,7,43},{0,8,117},{0,8,53},{0,9,202}, - {17,7,13},{0,8,101},{0,8,37},{0,9,170},{0,8,5},{0,8,133},{0,8,69}, - {0,9,234},{16,7,8},{0,8,93},{0,8,29},{0,9,154},{20,7,83},{0,8,125}, - {0,8,61},{0,9,218},{18,7,23},{0,8,109},{0,8,45},{0,9,186},{0,8,13}, - {0,8,141},{0,8,77},{0,9,250},{16,7,3},{0,8,83},{0,8,19},{21,8,195}, - {19,7,35},{0,8,115},{0,8,51},{0,9,198},{17,7,11},{0,8,99},{0,8,35}, - {0,9,166},{0,8,3},{0,8,131},{0,8,67},{0,9,230},{16,7,7},{0,8,91}, - {0,8,27},{0,9,150},{20,7,67},{0,8,123},{0,8,59},{0,9,214},{18,7,19}, - {0,8,107},{0,8,43},{0,9,182},{0,8,11},{0,8,139},{0,8,75},{0,9,246}, - {16,7,5},{0,8,87},{0,8,23},{64,8,0},{19,7,51},{0,8,119},{0,8,55}, - {0,9,206},{17,7,15},{0,8,103},{0,8,39},{0,9,174},{0,8,7},{0,8,135}, - {0,8,71},{0,9,238},{16,7,9},{0,8,95},{0,8,31},{0,9,158},{20,7,99}, - {0,8,127},{0,8,63},{0,9,222},{18,7,27},{0,8,111},{0,8,47},{0,9,190}, - {0,8,15},{0,8,143},{0,8,79},{0,9,254},{96,7,0},{0,8,80},{0,8,16}, - {20,8,115},{18,7,31},{0,8,112},{0,8,48},{0,9,193},{16,7,10},{0,8,96}, - {0,8,32},{0,9,161},{0,8,0},{0,8,128},{0,8,64},{0,9,225},{16,7,6}, - {0,8,88},{0,8,24},{0,9,145},{19,7,59},{0,8,120},{0,8,56},{0,9,209}, - {17,7,17},{0,8,104},{0,8,40},{0,9,177},{0,8,8},{0,8,136},{0,8,72}, - {0,9,241},{16,7,4},{0,8,84},{0,8,20},{21,8,227},{19,7,43},{0,8,116}, - {0,8,52},{0,9,201},{17,7,13},{0,8,100},{0,8,36},{0,9,169},{0,8,4}, - {0,8,132},{0,8,68},{0,9,233},{16,7,8},{0,8,92},{0,8,28},{0,9,153}, - {20,7,83},{0,8,124},{0,8,60},{0,9,217},{18,7,23},{0,8,108},{0,8,44}, - {0,9,185},{0,8,12},{0,8,140},{0,8,76},{0,9,249},{16,7,3},{0,8,82}, - {0,8,18},{21,8,163},{19,7,35},{0,8,114},{0,8,50},{0,9,197},{17,7,11}, - {0,8,98},{0,8,34},{0,9,165},{0,8,2},{0,8,130},{0,8,66},{0,9,229}, - {16,7,7},{0,8,90},{0,8,26},{0,9,149},{20,7,67},{0,8,122},{0,8,58}, - {0,9,213},{18,7,19},{0,8,106},{0,8,42},{0,9,181},{0,8,10},{0,8,138}, - {0,8,74},{0,9,245},{16,7,5},{0,8,86},{0,8,22},{64,8,0},{19,7,51}, - {0,8,118},{0,8,54},{0,9,205},{17,7,15},{0,8,102},{0,8,38},{0,9,173}, - {0,8,6},{0,8,134},{0,8,70},{0,9,237},{16,7,9},{0,8,94},{0,8,30}, - {0,9,157},{20,7,99},{0,8,126},{0,8,62},{0,9,221},{18,7,27},{0,8,110}, - {0,8,46},{0,9,189},{0,8,14},{0,8,142},{0,8,78},{0,9,253},{96,7,0}, - {0,8,81},{0,8,17},{21,8,131},{18,7,31},{0,8,113},{0,8,49},{0,9,195}, - {16,7,10},{0,8,97},{0,8,33},{0,9,163},{0,8,1},{0,8,129},{0,8,65}, - {0,9,227},{16,7,6},{0,8,89},{0,8,25},{0,9,147},{19,7,59},{0,8,121}, - {0,8,57},{0,9,211},{17,7,17},{0,8,105},{0,8,41},{0,9,179},{0,8,9}, - {0,8,137},{0,8,73},{0,9,243},{16,7,4},{0,8,85},{0,8,21},{16,8,258}, - {19,7,43},{0,8,117},{0,8,53},{0,9,203},{17,7,13},{0,8,101},{0,8,37}, - {0,9,171},{0,8,5},{0,8,133},{0,8,69},{0,9,235},{16,7,8},{0,8,93}, - {0,8,29},{0,9,155},{20,7,83},{0,8,125},{0,8,61},{0,9,219},{18,7,23}, - {0,8,109},{0,8,45},{0,9,187},{0,8,13},{0,8,141},{0,8,77},{0,9,251}, - {16,7,3},{0,8,83},{0,8,19},{21,8,195},{19,7,35},{0,8,115},{0,8,51}, - {0,9,199},{17,7,11},{0,8,99},{0,8,35},{0,9,167},{0,8,3},{0,8,131}, - {0,8,67},{0,9,231},{16,7,7},{0,8,91},{0,8,27},{0,9,151},{20,7,67}, - {0,8,123},{0,8,59},{0,9,215},{18,7,19},{0,8,107},{0,8,43},{0,9,183}, - {0,8,11},{0,8,139},{0,8,75},{0,9,247},{16,7,5},{0,8,87},{0,8,23}, - {64,8,0},{19,7,51},{0,8,119},{0,8,55},{0,9,207},{17,7,15},{0,8,103}, - {0,8,39},{0,9,175},{0,8,7},{0,8,135},{0,8,71},{0,9,239},{16,7,9}, - {0,8,95},{0,8,31},{0,9,159},{20,7,99},{0,8,127},{0,8,63},{0,9,223}, - {18,7,27},{0,8,111},{0,8,47},{0,9,191},{0,8,15},{0,8,143},{0,8,79}, - {0,9,255} -}; - -static const code distfix[32] = { - {16,5,1},{23,5,257},{19,5,17},{27,5,4097},{17,5,5},{25,5,1025}, - {21,5,65},{29,5,16385},{16,5,3},{24,5,513},{20,5,33},{28,5,8193}, - {18,5,9},{26,5,2049},{22,5,129},{64,5,0},{16,5,2},{23,5,385}, - {19,5,25},{27,5,6145},{17,5,7},{25,5,1537},{21,5,97},{29,5,24577}, - {16,5,4},{24,5,769},{20,5,49},{28,5,12289},{18,5,13},{26,5,3073}, - {22,5,193},{64,5,0} -}; - -dword adler32(dword adler, const byte *buf, dword len) -{ - dword sum2; - uint n; - - // split Adler-32 into component sums - sum2 = (adler >> 16) & 0xffff; - adler &= 0xffff; - - /* in case user likes doing a byte at a time, keep it fast */ - if (len == 1) - { - adler += buf[0]; - if (adler >= BASE) adler -= BASE; - sum2 += adler; - if (sum2 >= BASE) sum2 -= BASE; - return adler | (sum2 << 16); - } - - /* initial Adler-32 value (deferred check for len == 1 speed) */ - if (buf == NULL) return 1L; - - /* in case short lengths are provided, keep it somewhat fast */ - if (len < 16) - { - while (len--) - { - adler += *buf++; - sum2 += adler; - } - - if (adler >= BASE) adler -= BASE; - MOD4(sum2); // only added so many BASE's - return adler | (sum2 << 16); - } - - // do length NMAX blocks -- requires just one modulo operation - while (len >= NMAX) - { - len -= NMAX; - n = NMAX / 16; // NMAX is divisible by 16 - do - { - ADO16(buf); // 16 sums unrolled - buf += 16; - } while (--n); - MOD(adler); - MOD(sum2); - } - - // do remaining bytes (less than NMAX, still just one modulo) - if (len) // avoid modulos if none remaining - { - while (len >= 16) - { - len -= 16; - ADO16(buf); - buf += 16; - } - while (len--) - { - adler += *buf++; - sum2 += adler; - } - MOD(adler); - MOD(sum2); - } - - // return recombined sums - return adler | (sum2 << 16); -} - -int inflateInit_(z_streamp strm, const char *version, int stream_size ) -{ - //internal checking - return inflateInit2_(strm, MAX_WBITS, version, stream_size); -} - -int inflateInit2_(z_streamp strm, int windowBits, const char *version, int stream_size) -{ - struct inflate_state *state; - - if (version == NULL || version[0] != ZLIB_VERSION[0] || stream_size != (int)(sizeof(z_stream))) - return Z_VERSION_ERROR; - - if (strm == NULL) return Z_STREAM_ERROR; - strm->msg = NULL; //in case we return an error - if (strm->zalloc == (alloc_func)0) - { - strm->zalloc = zcalloc; - strm->opaque = (byte*)0; - } - - if (strm->zfree == (free_func)0) strm->zfree = zcfree; - state = (struct inflate_state *) - (*((strm)->zalloc))((strm)->opaque, (1), (sizeof(struct inflate_state))); - if (state == NULL) return Z_MEM_ERROR; - strm->state = (struct int_state *)state; - if (windowBits < 0) - { - state->wrap = 0; - windowBits = -windowBits; - } - else state->wrap = (windowBits >> 4) + 1; - if (windowBits < 8 || windowBits > 15) - { - (*((strm)->zfree))((strm)->opaque, (byte*)(state)); - strm->state = NULL; - return Z_STREAM_ERROR; - } - - state->wbits = (unsigned)windowBits; - state->window = NULL; - return inflateReset(strm); -} - -int inflate_table(codetype type, unsigned short *lens, unsigned codes, code **table, unsigned *bits, unsigned short *work) -{ - unsigned len; /* a code's length in bits */ - unsigned sym; /* index of code symbols */ - unsigned min, max; /* minimum and maximum code lengths */ - unsigned root; /* number of index bits for root table */ - unsigned curr; /* number of index bits for current table */ - unsigned drop; /* code bits to drop for sub-table */ - int left; /* number of prefix codes available */ - unsigned used; /* code entries in table used */ - unsigned huff; /* Huffman code */ - unsigned incr; /* for incrementing code, index */ - unsigned fill; /* index for replicating entries */ - unsigned low; /* low bits for current root entry */ - unsigned mask; /* mask for low root bits */ - code this; /* table entry for duplication */ - code *next; /* next available space in table */ - const unsigned short *base; /* base value table to use */ - const unsigned short *extra;/* extra bits table to use */ - int end; /* use base and extra for symbol > end */ - unsigned short count[MAX_WBITS+1]; /* number of codes of each length */ - unsigned short offs[MAX_WBITS+1]; /* offsets in table for each length */ - static const unsigned short lbase[31] = { /* Length codes 257..285 base */ - 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, - 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0}; - static const unsigned short lext[31] = { /* Length codes 257..285 extra */ - 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18, - 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 201, 196}; - static const unsigned short dbase[32] = { /* Distance codes 0..29 base */ - 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, - 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, - 8193, 12289, 16385, 24577, 0, 0}; - static const unsigned short dext[32] = { /* Distance codes 0..29 extra */ - 16, 16, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, - 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, - 28, 28, 29, 29, 64, 64}; - - /* accumulate lengths for codes (assumes lens[] all in 0..MAXBITS) */ - for (len = 0; len <= MAX_WBITS; len++) count[len] = 0; - for (sym = 0; sym < codes; sym++) count[lens[sym]]++; - - /* bound code lengths, force root to be within code lengths */ - root = *bits; - for (max = MAX_WBITS; max >= 1; max--) if (count[max] != 0) break; - if (root > max) root = max; - if (max == 0) /* no symbols to code at all */ - { - this.op = (unsigned char)64; /* invalid code marker */ - this.bits = (unsigned char)1; - this.val = (unsigned short)0; - *(*table)++ = this; /* make a table to force an error */ - *(*table)++ = this; - *bits = 1; - return 0; /* no symbols, but wait for decoding to report error */ - } - for (min = 1; min <= MAX_WBITS; min++) if (count[min] != 0) break; - if (root < min) root = min; - - /* check for an over-subscribed or incomplete set of lengths */ - left = 1; - for (len = 1; len <= MAX_WBITS; len++) - { - left <<= 1; - left -= count[len]; - if (left < 0) return -1; /* over-subscribed */ - } - if (left > 0 && (type == CODES || max != 1)) return -1; /* incomplete set */ - - /* generate offsets into symbol table for each length for sorting */ - offs[1] = 0; - for (len = 1; len < MAX_WBITS; len++) offs[len + 1] = offs[len] + count[len]; - - /* sort symbols by length, by symbol order within each length */ - for (sym = 0; sym < codes; sym++) if (lens[sym] != 0) work[offs[lens[sym]]++] = (unsigned short)sym; - - - /* set up for code type */ - switch (type) - { - case CODES: - base = extra = work; /* dummy value--not used */ - end = 19; - break; - case LENS: - base = lbase; - base -= 257; - extra = lext; - extra -= 257; - end = 256; - break; - default: /* DISTS */ - base = dbase; - extra = dext; - end = -1; - } - - /* initialize state for loop */ - huff = 0; /* starting code */ - sym = 0; /* starting code symbol */ - len = min; /* starting code length */ - next = *table; /* current table to fill in */ - curr = root; /* current table index bits */ - drop = 0; /* current bits to drop from code for index */ - low = (unsigned)(-1); /* trigger new sub-table when len > root */ - used = 1U << root; /* use root table entries */ - mask = used - 1; /* mask for comparing low */ - - /* check available table space */ - if (type == LENS && used >= 2048 - 592) return 1; - - /* process all codes and make table entries */ - for (;;) - { - /* create table entry */ - this.bits = (unsigned char)(len - drop); - if ((int)(work[sym]) < end) - { - this.op = (unsigned char)0; - this.val = work[sym]; - } - else if ((int)(work[sym]) > end) - { - this.op = (unsigned char)(extra[work[sym]]); - this.val = base[work[sym]]; - } - else - { - this.op = (unsigned char)(32 + 64); /* end of block */ - this.val = 0; - } - - /* replicate for those indices with low len bits equal to huff */ - incr = 1U << (len - drop); - fill = 1U << curr; - min = fill; /* save offset to next table */ - do{ - fill -= incr; - next[(huff >> drop) + fill] = this; - }while (fill != 0); - - /* backwards increment the len-bit code huff */ - incr = 1U << (len - 1); - while (huff & incr) incr >>= 1; - if (incr != 0) - { - huff &= incr - 1; - huff += incr; - } - else huff = 0; - - /* go to next symbol, update count, len */ - sym++; - if (--(count[len]) == 0) - { - if (len == max) break; - len = lens[work[sym]]; - } - - /* create new sub-table if needed */ - if (len > root && (huff & mask) != low) - { - /* if first time, transition to sub-tables */ - if (drop == 0) drop = root; - /* increment past last table */ - next += min; /* here min is 1 << curr */ - - /* determine length of next table */ - curr = len - drop; - left = (int)(1 << curr); - while (curr + drop < max) - { - left -= count[curr + drop]; - if (left <= 0) break; - curr++; - left <<= 1; - } - - /* check for enough space */ - used += 1U << curr; - if (type == LENS && used >= 2048 - 592) return 1; - - /* point entry in root table to sub-table */ - low = huff & mask; - (*table)[low].op = (unsigned char)curr; - (*table)[low].bits = (unsigned char)root; - (*table)[low].val = (unsigned short)(next - *table); - } - } - - this.op = (unsigned char)64; /* invalid code marker */ - this.bits = (unsigned char)(len - drop); - this.val = (unsigned short)0; - while (huff != 0) - { - /* when done with sub-table, drop back to root table */ - if (drop != 0 && (huff & mask) != low) - { - drop = 0; - len = root; - next = *table; - this.bits = (unsigned char)len; - } - - /* put invalid code marker in table */ - next[huff >> drop] = this; - - /* backwards increment the len-bit code huff */ - incr = 1U << (len - 1); - while (huff & incr) incr >>= 1; - if (incr != 0) - { - huff &= incr - 1; - huff += incr; - } - else huff = 0; - } - - // set return parameters - *table += used; - *bits = root; - return 0; -} - -void inflate_fast(z_streamp strm, unsigned start) -{ - struct inflate_state *state; - byte *in; /* local strm->next_in */ - byte *last; /* while in < last, enough input available */ - unsigned char *out; /* local strm->next_out */ - unsigned char *beg; /* inflate()'s initial strm->next_out */ - unsigned char *end; /* while out < end, enough space available */ - unsigned wsize; /* window size or zero if not using window */ - unsigned whave; /* valid bytes in the window */ - unsigned write; /* window write index */ - unsigned char *window; /* allocated sliding window, if wsize != 0 */ - unsigned long hold; /* local strm->hold */ - unsigned bits; /* local strm->bits */ - code const *lcode; /* local strm->lencode */ - code const *dcode; /* local strm->distcode */ - unsigned lmask; /* mask for first level of length codes */ - unsigned dmask; /* mask for first level of distance codes */ - code this; /* retrieved table entry */ - unsigned op; /* code bits, operation, extra bits, or */ - /* window position, window bytes to copy */ - unsigned len; /* match length, unused bytes */ - unsigned dist; /* match distance */ - unsigned char *from; /* where to copy match from */ - - /* copy state to local variables */ - state = (struct inflate_state *)strm->state; - in = strm->next_in; - last = in + (strm->avail_in - 5); - out = strm->next_out; - beg = out - (start - strm->avail_out); - end = out + (strm->avail_out - 257); - wsize = state->wsize; - whave = state->whave; - write = state->write; - window = state->window; - hold = state->hold; - bits = state->bits; - lcode = state->lencode; - dcode = state->distcode; - lmask = (1U << state->lenbits) - 1; - dmask = (1U << state->distbits) - 1; - - /* decode literals and length/distances until end-of-block or not enough - input data or output space */ - do { - if (bits < 15) - { - hold += (unsigned long)(PUP(in)) << bits; - bits += 8; - hold += (unsigned long)(PUP(in)) << bits; - bits += 8; - } - this = lcode[hold & lmask]; -dolen: - op = (unsigned)(this.bits); - hold >>= op; - bits -= op; - op = (unsigned)(this.op); - if (op == 0) PUP(out) = (byte)(this.val); - else if (op & 16) /* length base */ - { - len = (unsigned)(this.val); - op &= 15; /* number of extra bits */ - if (op) - { - if (bits < op) - { - hold += (unsigned long)(PUP(in)) << bits; - bits += 8; - } - len += (unsigned)hold & ((1U << op) - 1); - hold >>= op; - bits -= op; - } - if (bits < 15) - { - hold += (dword)(PUP(in)) << bits; - bits += 8; - hold += (dword)(PUP(in)) << bits; - bits += 8; - } - this = dcode[hold & dmask]; -dodist: - op = (unsigned)(this.bits); - hold >>= op; - bits -= op; - op = (unsigned)(this.op); - if (op & 16) /* distance base */ - { - dist = (unsigned)(this.val); - op &= 15; /* number of extra bits */ - if (bits < op) - { - hold += (unsigned long)(PUP(in)) << bits; - bits += 8; - if (bits < op) - { - hold += (unsigned long)(PUP(in)) << bits; - bits += 8; - } - } - dist += (unsigned)hold & ((1U << op) - 1); - hold >>= op; - bits -= op; - op = (unsigned)(out - beg); /* max distance in output */ - if (dist > op) /* see if copy from window */ - { - op = dist - op; /* distance back in window */ - if (op > whave) - { - strm->msg = (char *)"invalid distance too far back"; - state->mode = BAD; - break; - } - from = window; - if (write == 0) // very common case - { - from += wsize - op; - if (op < len) // some from window - { - len -= op; - do{ - PUP(out) = PUP(from); - }while (--op); - from = out - dist; // rest from output - } - } - else if (write < op) // wrap around window - { - from += wsize + write - op; - op -= write; - if (op < len) /* some from end of window */ - { - len -= op; - do{ - PUP(out) = PUP(from); - }while (--op); - from = window; - if (write < len) /* some from start of window */ - { - op = write; - len -= op; - do{ - PUP(out) = PUP(from); - }while (--op); - from = out - dist; /* rest from output */ - } - } - } - else /* contiguous in window */ - { - from += write - op; - if (op < len) /* some from window */ - { - len -= op; - do{ - PUP(out) = PUP(from); - }while (--op); - from = out - dist; /* rest from output */ - } - } - while (len > 2) - { - PUP(out) = PUP(from); - PUP(out) = PUP(from); - PUP(out) = PUP(from); - len -= 3; - } - if (len) - { - PUP(out) = PUP(from); - if (len > 1) PUP(out) = PUP(from); - } - } - else - { - from = out - dist; // copy direct from output - do // minimum length is three - { - PUP(out) = PUP(from); - PUP(out) = PUP(from); - PUP(out) = PUP(from); - len -= 3; - }while (len > 2); - if (len) - { - PUP(out) = PUP(from); - if (len > 1) PUP(out) = PUP(from); - } - } - } - else if ((op & 64) == 0) // 2nd level distance code - { - this = dcode[this.val + (hold & ((1U << op) - 1))]; - goto dodist; - } - else - { - strm->msg = (char *)"invalid distance code"; - state->mode = BAD; - break; - } - } - else if ((op & 64) == 0) //2nd level length code - { - this = lcode[this.val + (hold & ((1U << op) - 1))]; - goto dolen; - } - else if (op & 32) /* end-of-block */ - { - state->mode = TYPE; - break; - } - else - { - strm->msg = (char *)"invalid literal/length code"; - state->mode = BAD; - break; - } - }while (in < last && out < end); - - // return unused bytes (on entry, bits < 8, so in won't go too far back) - len = bits >> 3; - in -= len; - bits -= len << 3; - hold &= (1U << bits) - 1; - - // update state and return - strm->next_in = in; - strm->next_out = out; - strm->avail_in = (unsigned)(in < last ? 5 + (last - in) : 5 - (in - last)); - strm->avail_out = (unsigned)(out < end ? 257 + (end - out) : 257 - (out - end)); - state->hold = hold; - state->bits = bits; - return; //??? -} - -void fixedtables(struct inflate_state *state) -{ - state->lencode = lenfix; - state->lenbits = 9; - state->distcode = distfix; - state->distbits = 5; -} - -int updatewindow(z_streamp strm, unsigned out) -{ - struct inflate_state *state; - unsigned copy, dist; - - state = (struct inflate_state *)strm->state; - - /* if it hasn't been done already, allocate space for the window */ - if (state->window == NULL) - { - state->window = (unsigned char *) - (*((strm)->zalloc))((strm)->opaque, (1U << state->wbits), (sizeof(unsigned char))); - if (state->window == NULL) return 1; - } - - /* if window not in use yet, initialize */ - if (state->wsize == 0) - { - state->wsize = 1U << state->wbits; - state->write = 0; - state->whave = 0; - } - - /* copy state->wsize or less output bytes into the circular window */ - copy = out - strm->avail_out; - if (copy >= state->wsize) - { - memcpy(state->window, strm->next_out - state->wsize, state->wsize); - state->write = 0; - state->whave = state->wsize; - } - else - { - dist = state->wsize - state->write; - if (dist > copy) dist = copy; - memcpy(state->window + state->write, strm->next_out - copy, dist); - copy -= dist; - - if (copy) - { - memcpy(state->window, strm->next_out - copy, copy); - state->write = copy; - state->whave = state->wsize; - } - else - { - state->write += dist; - if (state->write == state->wsize) state->write = 0; - if (state->whave < state->wsize) state->whave += dist; - } - } - return 0; -} - -// Macros for inflate(): - -// check function to use adler32() for zlib or crc32() for gzip -#define UPDATE(check, buf, len) adler32(check, buf, len) - -// Load registers with state in inflate() for speed -#define LOAD() \ - do { \ - put = strm->next_out; \ - left = strm->avail_out; \ - next = strm->next_in; \ - have = strm->avail_in; \ - hold = state->hold; \ - bits = state->bits; \ - } while (0) - -// Restore state from registers in inflate() -#define RESTORE() \ - do { \ - strm->next_out = put; \ - strm->avail_out = left; \ - strm->next_in = next; \ - strm->avail_in = have; \ - state->hold = hold; \ - state->bits = bits; \ - } while (0) - -// Clear the input bit accumulator -#define INITBITS() \ - do { \ - hold = 0; \ - bits = 0; \ - } while (0) - -// Get a byte of input into the bit accumulator, or return from inflate() -// if there is no input available. -#define PULLBYTE() \ - do { \ - if (have == 0) goto inf_leave; \ - have--; \ - hold += (unsigned long)(*next++) << bits; \ - bits += 8; \ - } while (0) - -// Assure that there are at least n bits in the bit accumulator. If there is -// not enough available input to do that, then return from inflate(). -#define NEEDBITS(n) \ - do { \ - while (bits < (unsigned)(n)) \ - PULLBYTE(); \ - } while (0) - -// Return the low n bits of the bit accumulator (n < 16) -#define BITS(n) \ - ((unsigned)hold & ((1U << (n)) - 1)) - -// Remove n bits from the bit accumulator -#define DROPBITS(n) \ - do { \ - hold >>= (n); \ - bits -= (unsigned)(n); \ - } while (0) - -// Remove zero to seven bits as needed to go to a byte boundary -#define BYTEBITS() \ - do { \ - hold >>= bits & 7; \ - bits -= bits & 7; \ - } while (0) - -// Reverse the bytes in a 32-bit value -#define REVERSE(q) \ - ((((q) >> 24) & 0xff) + (((q) >> 8) & 0xff00) + \ - (((q) & 0xff00) << 8) + (((q) & 0xff) << 24)) - -int inflate(z_streamp strm, int flush) -{ - struct inflate_state *state; - unsigned char *next; /* next input */ - unsigned char *put; /* next output */ - unsigned have, left; /* available input and output */ - unsigned long hold; /* bit buffer */ - unsigned bits; /* bits in bit buffer */ - unsigned in, out; /* save starting available input and output */ - unsigned copy; /* number of stored or match bytes to copy */ - unsigned char *from; /* where to copy match bytes from */ - code this; /* current decoding table entry */ - code last; /* parent table entry */ - unsigned len; /* length to copy for repeats, bits to drop */ - int ret; /* return code */ - - // permutation of code lengths - static const unsigned short order[19] ={16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15}; - - if (strm == NULL || strm->state == NULL || strm->next_out == NULL || (strm->next_in == NULL && strm->avail_in != 0)) - return Z_STREAM_ERROR; - - state = (struct inflate_state *)strm->state; - if (state->mode == TYPE) state->mode = TYPEDO; /* skip check */ - LOAD(); - in = have; - out = left; - ret = Z_OK; - - for (;;) - switch (state->mode) - { - case HEAD: - if (state->wrap == 0) - { - state->mode = TYPEDO; - break; - } - NEEDBITS(16); - - if (((BITS(8) << 8) + (hold >> 8)) % 31) // check if zlib header allowed - { - strm->msg = (char *)"incorrect header check"; - state->mode = BAD; - break; - } - if (BITS(4) != Z_DEFLATED) - { - strm->msg = (char *)"unknown compression method"; - state->mode = BAD; - break; - } - DROPBITS(4); - len = BITS(4) + 8; - if (len > state->wbits) - { - strm->msg = (char *)"invalid window size"; - state->mode = BAD; - break; - } - state->dmax = 1U << len; - strm->adler = state->check = adler32(0L, NULL, 0); - state->mode = hold & 0x200 ? DICTID : TYPE; - INITBITS(); - break; - case DICTID: - NEEDBITS(32); - strm->adler = state->check = REVERSE(hold); - INITBITS(); - state->mode = DICT; - case DICT: - if (state->havedict == 0) - { - RESTORE(); - return Z_NEED_DICT; - } - strm->adler = state->check = adler32(0L, NULL, 0); - state->mode = TYPE; - case TYPE: - if (flush == Z_BLOCK) goto inf_leave; - case TYPEDO: - if (state->last) - { - BYTEBITS(); - state->mode = CHECK; - break; - } - NEEDBITS(3); - state->last = BITS(1); - DROPBITS(1); - switch (BITS(2)) - { - case 0: /* stored block */ - state->mode = STORED; - break; - case 1: /* fixed block */ - fixedtables(state); - state->mode = LEN; /* decode codes */ - break; - case 2: /* dynamic block */ - state->mode = TABLE; - break; - case 3: - strm->msg = (char *)"invalid block type"; - state->mode = BAD; - } - DROPBITS(2); - break; - case STORED: - BYTEBITS(); /* go to byte boundary */ - NEEDBITS(32); - if ((hold & 0xffff) != ((hold >> 16) ^ 0xffff)) - { - strm->msg = (char *)"invalid stored block lengths"; - state->mode = BAD; - break; - } - state->length = (unsigned)hold & 0xffff; - INITBITS(); - state->mode = COPY; - case COPY: - copy = state->length; - if (copy) - { - if (copy > have) copy = have; - if (copy > left) copy = left; - if (copy == 0) goto inf_leave; - memcpy(put, next, copy); - have -= copy; - next += copy; - left -= copy; - put += copy; - state->length -= copy; - break; - } - state->mode = TYPE; - break; - case TABLE: - NEEDBITS(14); - state->nlen = BITS(5) + 257; - DROPBITS(5); - state->ndist = BITS(5) + 1; - DROPBITS(5); - state->ncode = BITS(4) + 4; - DROPBITS(4); - if (state->nlen > 286 || state->ndist > 30) - { - strm->msg = (char *)"too many length or distance symbols"; - state->mode = BAD; - break; - } - state->have = 0; - state->mode = LENLENS; - case LENLENS: - while (state->have < state->ncode) - { - NEEDBITS(3); - state->lens[order[state->have++]] = (unsigned short)BITS(3); - DROPBITS(3); - } - while (state->have < 19) state->lens[order[state->have++]] = 0; - state->next = state->codes; - state->lencode = (code const *)(state->next); - state->lenbits = 7; - ret = inflate_table(CODES, state->lens, 19, &(state->next), &(state->lenbits), state->work); - if (ret) - { - strm->msg = (char *)"invalid code lengths set"; - state->mode = BAD; - break; - } - state->have = 0; - state->mode = CODELENS; - case CODELENS: - while (state->have < state->nlen + state->ndist) - { - for (;;) - { - this = state->lencode[BITS(state->lenbits)]; - if ((unsigned)(this.bits) <= bits) break; - PULLBYTE(); - } - if (this.val < 16) - { - NEEDBITS(this.bits); - DROPBITS(this.bits); - state->lens[state->have++] = this.val; - } - else - { - if (this.val == 16) - { - NEEDBITS(this.bits + 2); - DROPBITS(this.bits); - if (state->have == 0) - { - strm->msg = (char *)"invalid bit length repeat"; - state->mode = BAD; - break; - } - len = state->lens[state->have - 1]; - copy = 3 + BITS(2); - DROPBITS(2); - } - else if (this.val == 17) - { - NEEDBITS(this.bits + 3); - DROPBITS(this.bits); - len = 0; - copy = 3 + BITS(3); - DROPBITS(3); - } - else - { - NEEDBITS(this.bits + 7); - DROPBITS(this.bits); - len = 0; - copy = 11 + BITS(7); - DROPBITS(7); - } - if (state->have + copy > state->nlen + state->ndist) - { - strm->msg = (char *)"invalid bit length repeat"; - state->mode = BAD; - break; - } - while (copy--) state->lens[state->have++] = (unsigned short)len; - } - } - - /* handle error breaks in while */ - if (state->mode == BAD) break; - - /* build code tables */ - state->next = state->codes; - state->lencode = (code const *)(state->next); - state->lenbits = 9; - ret = inflate_table(LENS, state->lens, state->nlen, &(state->next), &(state->lenbits), state->work); - if (ret) - { - strm->msg = (char *)"invalid literal/lengths set"; - state->mode = BAD; - break; - } - state->distcode = (code const *)(state->next); - state->distbits = 6; - ret = inflate_table(DISTS, state->lens + state->nlen, state->ndist, &(state->next), &(state->distbits), state->work); - if (ret) - { - strm->msg = (char *)"invalid distances set"; - state->mode = BAD; - break; - } - state->mode = LEN; - case LEN: - if (have >= 6 && left >= 258) - { - RESTORE(); - inflate_fast(strm, out); - LOAD(); - break; - } - for (;;) - { - this = state->lencode[BITS(state->lenbits)]; - if ((unsigned)(this.bits) <= bits) break; - PULLBYTE(); - } - if (this.op && (this.op & 0xf0) == 0) - { - last = this; - for (;;) - { - this = state->lencode[last.val + (BITS(last.bits + last.op) >> last.bits)]; - if ((unsigned)(last.bits + this.bits) <= bits) break; - PULLBYTE(); - } - DROPBITS(last.bits); - } - DROPBITS(this.bits); - state->length = (unsigned)this.val; - if ((int)(this.op) == 0) - { - state->mode = LIT; - break; - } - if (this.op & 32) - { - state->mode = TYPE; - break; - } - if (this.op & 64) - { - strm->msg = (char *)"invalid literal/length code"; - state->mode = BAD; - break; - } - state->extra = (unsigned)(this.op) & 15; - state->mode = LENEXT; - case LENEXT: - if (state->extra) - { - NEEDBITS(state->extra); - state->length += BITS(state->extra); - DROPBITS(state->extra); - } - state->mode = DIST; - case DIST: - for (;;) - { - this = state->distcode[BITS(state->distbits)]; - if ((unsigned)(this.bits) <= bits) break; - PULLBYTE(); - } - if ((this.op & 0xf0) == 0) - { - last = this; - for (;;) - { - this = state->distcode[last.val + (BITS(last.bits + last.op) >> last.bits)]; - if ((unsigned)(last.bits + this.bits) <= bits) break; - PULLBYTE(); - } - DROPBITS(last.bits); - } - DROPBITS(this.bits); - if (this.op & 64) - { - strm->msg = (char *)"invalid distance code"; - state->mode = BAD; - break; - } - state->offset = (unsigned)this.val; - state->extra = (unsigned)(this.op) & 15; - state->mode = DISTEXT; - case DISTEXT: - if (state->extra) - { - NEEDBITS(state->extra); - state->offset += BITS(state->extra); - DROPBITS(state->extra); - } - if (state->offset > state->whave + out - left) - { - strm->msg = (char *)"invalid distance too far back"; - state->mode = BAD; - break; - } - state->mode = MATCH; - case MATCH: - if (left == 0) goto inf_leave; - copy = out - left; - if (state->offset > copy) /* copy from window */ - { - copy = state->offset - copy; - if (copy > state->write) - { - copy -= state->write; - from = state->window + (state->wsize - copy); - } - else from = state->window + (state->write - copy); - if (copy > state->length) copy = state->length; - } - else /* copy from output */ - { - from = put - state->offset; - copy = state->length; - } - if (copy > left) copy = left; - left -= copy; - state->length -= copy; - do{ - *put++ = *from++; - }while (--copy); - if (state->length == 0) state->mode = LEN; - break; - case LIT: - if (left == 0) goto inf_leave; - *put++ = (unsigned char)(state->length); - left--; - state->mode = LEN; - break; - case CHECK: - if (state->wrap) - { - NEEDBITS(32); - out -= left; - strm->total_out += out; - state->total += out; - if (out) strm->adler = state->check = - UPDATE(state->check, put - out, out); - out = left; - if ((REVERSE(hold)) != state->check) - { - strm->msg = (char *)"incorrect data check"; - state->mode = BAD; - break; - } - INITBITS(); - } - state->mode = DONE; - case DONE: - ret = Z_STREAM_END; - goto inf_leave; - case BAD: - ret = Z_DATA_ERROR; - goto inf_leave; - case MEM: - return Z_MEM_ERROR; - case SYNC: - default: return Z_STREAM_ERROR; - } - - //Return from inflate(), updating the total counts and the check value. - //If there was no progress during the inflate() call, return a buffer - //error. Call updatewindow() to create and/or update the window state. - //Note: a memory error from inflate() is non-recoverable. - -inf_leave: - RESTORE(); - if (state->wsize || (state->mode < CHECK && out != strm->avail_out)) - if (updatewindow(strm, out)) - { - state->mode = MEM; - return Z_MEM_ERROR; - } - in -= strm->avail_in; - out -= strm->avail_out; - strm->total_in += in; - strm->total_out += out; - state->total += out; - if (state->wrap && out) strm->adler = state->check = UPDATE(state->check, strm->next_out - out, out); - strm->data_type = state->bits + (state->last ? 64 : 0) + (state->mode == TYPE ? 128 : 0); - if (((in == 0 && out == 0) || flush == Z_FINISH) && ret == Z_OK) ret = Z_BUF_ERROR; - return ret; -} - -int inflateEnd(z_streamp strm) -{ - struct inflate_state *state; - if (strm == NULL || strm->state == NULL || strm->zfree == (free_func)0) - return Z_STREAM_ERROR; - state = (struct inflate_state *)strm->state; - if (state->window != NULL) (*((strm)->zfree))((strm)->opaque, (byte*)(state->window)); - (*((strm)->zfree))((strm)->opaque, (byte*)(strm->state)); - strm->state = NULL; - return Z_OK; -} - -int inflateReset(z_streamp strm) -{ - struct inflate_state *state; - - if (strm == NULL || strm->state == NULL) return Z_STREAM_ERROR; - state = (struct inflate_state *)strm->state; - strm->total_in = strm->total_out = state->total = 0; - strm->msg = NULL; - strm->adler = 1; // to support ill-conceived Java test suite - state->mode = HEAD; - state->last = 0; - state->havedict = 0; - state->dmax = 32768U; - state->head = NULL; - state->wsize = 0; - state->whave = 0; - state->write = 0; - state->hold = 0; - state->bits = 0; - state->lencode = state->distcode = state->next = state->codes; - return Z_OK; -} \ No newline at end of file diff --git a/progs/qcclib.exe b/progs/qcclib.exe deleted file mode 100644 index ac59ee14978716a813bcd5b3427d0178fd428450..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 39424 zcmeIb4|o(sx;NUB=_H*nVFpMbK#)O#ib0G7G;s({NG1d&Ffn9?CR7_tbMbo0lP z;KWWeowk)dyWf89UDuVx-DTH3=lJa(WOrRn2%7+Mls~SE!m~zY-HweK1(QKW`u^VP z84~=nXP@uxeeS*I(s^pC>aDlls(P#Ht*W=)?v&oOgR^rS$HSQ>$L)nrkC*-a{ht#^ z9zFGUqq$!v{pYm3wk7{LZF$|gM)#(MjrTTG-{)Ray5fMXj!@Y zzKv^ZW~ZbiXGTfOchCAs@2v|zjk(=37Ju4K!JbKgEC+HJEUfdHCsib zFR#WA)sNab+z3QC&dqW6%wAh963YBF_zA&X4_6B};_-4^=j?{Y28KdyKwG$ExE*jK z9`8RkTt?)$68wJ)2VS|4b@@5zamlKZpqFL`V%oh+-$}Q_tf2khvPPF+KNX22A9YQ0z3hK6y>giAd$HB z_?yW}zHWoGem#P#S1($!Y+=EY)g`_H|LStz5?|qRUlGAe%L9dXE*}Y}j1ZCHy8CL} zH4P0L8{8b1f_b)l$+Gft3qnz@eDTsnBcfch0}_3Iv}ao5#UZ(?LP!n=j=NIchU*eKmw=Wg6oy{5)pi?Y{m+_G*&#%gih z#tp;yZvNVQjpEwBlW!j7+axvAxHqqB5T)w%?pkTX8lsJLV*Pqn0M%>m*V13TaYN14 zb>fZHkZ|inw@6LARIi)zDBp0qH*Tr{;f)&_H-ZmqYc{W2GXgitqnfRoYSxG~YZ+&T zxyTWJZeskAP+}D4K54zUPONLFsa^{Xt@-8`@xPug(M%+7QQef}>Thh=*l-^h5L+k3 znuhz0h?yK1#f*$Ic&D!&oxYZ5!N`%-L<8SsH;#2MVjVNxz zz3xpL*KH8lFaTt2&033}rR&x-Y;4?EE4l;g8mX%av$EWGMhEDUb>C>HZrDa+HW`C5 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`o!#OZ>{qdt99>jnHNiZ#_`cb3c2XX;qHRSbCwS@bHka|c8(g2wU zX@r1#H$GOwAEX6x0c17AeOlJQ4YHaMX|U;_d%%LQUYg(-xIs1tCkEl2^C-wv$U%?> z2=9(hft&-m0CG9xTF5Ps)sTlEPe6D#{5s@)$mfvnA$bUU!!foU+Z3i@$UvGP^C1f$ z3n9&rMUaCbhd>U690oZY(gHaGvKVqCWC`Rb$kC8+|9}d!Fj5XV4stx?1jtgziI9^Z zCqu4-aDPD_kWP}n@XB{=>ml5iE<$6!2C^FRG~`XlH;@h5VT^(702vOM42eS;AV)w> zgIo-`8S*gXWymLx-yjtTm-}b#^T0i9=ROxn};Z$sLgUA&)^`g`lO3cnkPB0RK$LS&*|K=Rp1j`8#A8WI5zq$a#?SAs0X{ zghW04H^H0;L2n*A0eF!^YKHwp$ocHvvRjE8@5P39iNSwl{mGbTZL6(8W6Rx_<|@Q? zS%mId=x&Ex4p{*y>VOsroB_N7*bKZ9csB4d$W<^u2fP}14Ww{W%=wVfkbNO1Lav3} z33(0j1!U9B(9R%xLMkBF!{18a4Zu~9w_v^z=xY+Ak3yCqE!P6CgRF%-2KguC zaY*OC=<<95<|iRZ*bjxA2DuD!2jnT}pM^XPc?RM>L$|^@2=W}1&qFSP`2~mYBAcg< z9siP}%Qf=cuH|Lpuzg3Of5H3;{S}SCFqEfA;wn9>0Tp5BUM|BjnaD`1m)TpWycmgz+=*7s$x25*RmEE2Ci+`3;6& u#Tnxg^OUym_tZSd+tA$#6@T9>&$t;nwSzt1=w@`o`~tzQVXSp${Qm%domuAq diff --git a/public/basemath.h b/public/basemath.h index 48f86a02..aee920e6 100644 --- a/public/basemath.h +++ b/public/basemath.h @@ -22,7 +22,6 @@ #define RANDOM_LONG(MIN,MAX) ((rand() & 32767) * (((MAX)-(MIN)) * (1.0f / 32767.0f)) + (MIN)) #define RANDOM_FLOAT(MIN,MAX) (((float)rand() / RAND_MAX) * ((MAX)-(MIN)) + (MIN)) -#define bound(min,num,max) ((num) >= (min) ? ((num) < (max) ? (num) : (max)) : (min)) #define DotProduct(x,y) (x[0]*y[0]+x[1]*y[1]+x[2]*y[2]) #define VectorSubtract(a,b,c){c[0]=a[0]-b[0];c[1]=a[1]-b[1];c[2]=a[2]-b[2];} diff --git a/public/basetypes.h b/public/basetypes.h index bd33da0c..8f747e04 100644 --- a/public/basetypes.h +++ b/public/basetypes.h @@ -99,4 +99,6 @@ _inline char *va(const char *format, ...) return s; } +#define bound(min, num, max) ((num) >= (min) ? ((num) < (max) ? (num) : (max)) : (min)) + #endif//BASETYPES_H \ No newline at end of file diff --git a/public/ref_system.h b/public/ref_system.h index 7f1629eb..d297b4a1 100644 --- a/public/ref_system.h +++ b/public/ref_system.h @@ -11,8 +11,8 @@ #include "version.h" -#define RENDERER_API_VERSION 4 -#define PLATFORM_API_VERSION 2 +#define RENDER_API_VERSION 4 +#define COMMON_API_VERSION 2 #define LAUNCHER_API_VERSION 2 @@ -86,9 +86,10 @@ typedef enum enum dev_level { - D_INFO = 1, // "-developer 1", shows various system messages - D_WARN, // "-developer 2", shows not critical system warnings, same as MsgWarn - D_ERROR, // "-developer 3", shows critical warnings + D_INFO = 1, // "-dev 1", shows various system messages + D_WARN, // "-dev 2", shows not critical system warnings, same as MsgWarn + D_ERROR, // "-dev 3", shows critical warnings + D_LOAD, // "-dev 4", display info about loading recources }; // format info table @@ -188,7 +189,7 @@ typedef struct dll_info_s void *link; // hinstance of loading library // xash dlls entrypoint - void *(*main)( void* ); // point type (e.g. platform_t) + void *(*main)( void* ); // point type (e.g. common_t) bool crash; // crash if dll not found // xash dlls validator @@ -500,10 +501,10 @@ typedef struct compilers_api_s STDIO SYSTEM INTERFACE ============================================================================== */ -typedef struct stdinout_api_s +typedef struct stdilib_api_s { //interface validator - size_t api_size; // must matched with sizeof(stdinout_api_t) + size_t api_size; // must matched with sizeof(stdlib_api_t) // base events void (*print)( char *msg ); // basic text message @@ -518,8 +519,9 @@ typedef struct stdinout_api_s // xash dll loading system bool (*LoadLibrary)( dll_info_t *dll ); // load library bool (*FreeLibrary)( dll_info_t *dll ); // free library + void*(*GetProcAddress)( dll_info_t *dll, const char* name ); // gpa -} stdinout_api_t; +} stdlib_api_t; /* ============================================================================== @@ -559,21 +561,21 @@ typedef struct launcher_exp_s /* ============================================================================== -PLATFORM.DLL INTERFACE +COMMON.DLL INTERFACE ============================================================================== */ -typedef struct platform_exp_s +typedef struct common_exp_s { //interface validator - int apiversion; // must matched with PLATFORM_API_VERSION - size_t api_size; // must matched with sizeof(platform_api_t) + int apiversion; // must matched with COMMON_API_VERSION + size_t api_size; // must matched with sizeof(common_api_t) // initialize - bool (*Init)( int argc, char **argv ); // init all platform systems - void (*Shutdown)( void ); // shutdown all platform systems + bool (*Init)( int argc, char **argv ); // init all common systems + void (*Shutdown)( void ); // shutdown all common systems - //platform systems + //common systems filesystem_api_t Fs; vfilesystem_api_t VFs; memsystem_api_t Mem; @@ -590,24 +592,24 @@ typedef struct platform_exp_s double (*DoubleTime)( void ); gameinfo_t (*GameInfo)( void ); -} platform_exp_t; +} common_exp_t; /* ============================================================================== -RENDERER.DLL INTERFACE +RENDER.DLL INTERFACE ============================================================================== */ -typedef struct renderer_exp_s +typedef struct render_exp_s { //interface validator - int apiversion; // must matched with RENDERER_API_VERSION - size_t api_size; // must matched with sizeof(renderer_exp_t) + int apiversion; // must matched with RENDER_API_VERSION + size_t api_size; // must matched with sizeof(render_exp_t) // initialize - bool (*Init)( void *hInstance, void *WndProc ); // init all renderer systems - void (*Shutdown)( void ); // shutdown all renderer systems + bool (*Init)( void *hInstance, void *WndProc ); // init all render systems + void (*Shutdown)( void ); // shutdown all render systems void (*BeginRegistration) (char *map); model_t *(*RegisterModel) (char *name); @@ -637,9 +639,9 @@ typedef struct renderer_exp_s void (*AppActivate)( bool activate ); // ?? -} renderer_exp_t; +} render_exp_t; -typedef struct renderer_imp_s +typedef struct render_imp_s { //shared xash systems filesystem_api_t Fs; @@ -647,7 +649,7 @@ typedef struct renderer_imp_s memsystem_api_t Mem; scriptsystem_api_t Script; compilers_api_t Compile; - stdinout_api_t Stdio; + stdlib_api_t Stdio; void (*Cmd_AddCommand) (char *name, void(*cmd)(void)); void (*Cmd_RemoveCommand) (char *name); @@ -671,12 +673,12 @@ typedef struct renderer_imp_s void (*Vid_MenuInit)( void ); void (*Vid_NewWindow)( int width, int height ); -} renderer_imp_t; +} render_imp_t; // this is the only function actually exported at the linker level -typedef renderer_exp_t *(*renderer_t)( renderer_imp_t* ); -typedef platform_exp_t *(*platform_t)( stdinout_api_t* ); -typedef launcher_exp_t *(*launcher_t)( stdinout_api_t* ); +typedef render_exp_t *(*render_t)( render_imp_t* ); +typedef common_exp_t *(*common_t)( stdlib_api_t* ); +typedef launcher_exp_t *(*launcher_t)( stdlib_api_t* ); #endif//REF_SYSTEM_H \ No newline at end of file diff --git a/public/version.h b/public/version.h index d3dbaa3a..c5d50504 100644 --- a/public/version.h +++ b/public/version.h @@ -6,8 +6,8 @@ #define VERSION_H #define LAUNCHER_VERSION 0.6 -#define PLATFORM_VERSION 1.3 -#define RENDERER_VERSION 3.1 +#define COMMON_VERSION 1.3 +#define RENDER_VERSION 3.1 #define ENGINE_VERSION 1.8 #define EDITOR_VERSION 0.2 #define SERVER_VERSION 0.5 diff --git a/release.bat b/release.bat index f68ee0f5..aa9e1ce6 100644 --- a/release.bat +++ b/release.bat @@ -18,13 +18,13 @@ if errorlevel 1 set BUILD_ERROR=1 %MSDEV% launcher/launcher.dsp %CONFIG%"launcher - Win32 Release" %build_target% if errorlevel 1 set BUILD_ERROR=1 -%MSDEV% platform/platform.dsp %CONFIG%"platform - Win32 Release" %build_target% +%MSDEV% common/common.dsp %CONFIG%"common - Win32 Release" %build_target% if errorlevel 1 set BUILD_ERROR=1 -%MSDEV% renderer/renderer.dsp %CONFIG%"renderer - Win32 Release" %build_target% +%MSDEV% render/render.dsp %CONFIG%"render - Win32 Release" %build_target% if errorlevel 1 set BUILD_ERROR=1 -progs\qcclib.exe +vprogs\qcclib.exe if errorlevel 1 set BUILD_ERROR=1 if "%BUILD_ERROR%"=="" goto build_ok @@ -49,9 +49,9 @@ rem //delete log files if exist editor\editor.plg del /f /q editor\editor.plg if exist engine\engine.plg del /f /q engine\engine.plg if exist launcher\launcher.plg del /f /q launcher\launcher.plg -if exist platform\platform.plg del /f /q platform\platform.plg -if exist renderer\renderer.plg del /f /q renderer\renderer.plg -if exist progs\server.dat copy progs\server.dat D:\Xash3D\xash\server.dat +if exist common\common.plg del /f /q common\common.plg +if exist render\render.plg del /f /q render\render.plg +if exist vprogs\server.dat move vprogs\server.dat D:\Xash3D\xash\server.dat echo Build succeeded! echo Please wait. Xash is now loading diff --git a/renderer/anormtab.h b/render/anormtab.h similarity index 100% rename from renderer/anormtab.h rename to render/anormtab.h diff --git a/renderer/gl_draw.c b/render/gl_draw.c similarity index 100% rename from renderer/gl_draw.c rename to render/gl_draw.c diff --git a/renderer/gl_light.c b/render/gl_light.c similarity index 100% rename from renderer/gl_light.c rename to render/gl_light.c diff --git a/renderer/gl_local.h b/render/gl_local.h similarity index 96% rename from renderer/gl_local.h rename to render/gl_local.h index 64ac10a2..b3643384 100644 --- a/renderer/gl_local.h +++ b/render/gl_local.h @@ -554,7 +554,7 @@ IMPORTED FUNCTIONS ==================================================================== */ -extern renderer_imp_t ri; +extern render_imp_t ri; /* ==================================================================== diff --git a/renderer/gl_mesh.c b/render/gl_mesh.c similarity index 100% rename from renderer/gl_mesh.c rename to render/gl_mesh.c diff --git a/renderer/gl_model.c b/render/gl_model.c similarity index 100% rename from renderer/gl_model.c rename to render/gl_model.c diff --git a/renderer/gl_model.h b/render/gl_model.h similarity index 100% rename from renderer/gl_model.h rename to render/gl_model.h diff --git a/renderer/gl_rmain.c b/render/gl_rmain.c similarity index 95% rename from renderer/gl_rmain.c rename to render/gl_rmain.c index a18032dc..17f7cffa 100644 --- a/renderer/gl_rmain.c +++ b/render/gl_rmain.c @@ -24,7 +24,7 @@ void R_Clear (void); viddef_t vid; -renderer_imp_t ri; +render_imp_t ri; byte *r_temppool; @@ -1091,7 +1091,7 @@ int R_Init( void *hinstance, void *hWnd ) return false; } - MsgDev(D_INFO, "------- Loading bin/renderer.dll [%g] -------\n", RENDERER_VERSION ); + MsgDev(D_INFO, "------- Loading bin/render.dll [%g] -------\n", RENDER_VERSION ); ri.Vid_MenuInit(); //get our various GL strings @@ -1519,17 +1519,17 @@ CreateAPI @@@@@@@@@@@@@@@@@@@@@ */ -renderer_exp_t DLLEXPORT *CreateAPI(renderer_imp_t *rimp ) +render_exp_t DLLEXPORT *CreateAPI(render_imp_t *rimp ) { - static renderer_exp_t re; + static render_exp_t re; // Sys_LoadLibrary can create fake instance, to check // api version and api size, but first argument will be 0 // and always make exception, run simply check for avoid it if(rimp) ri = *rimp; - re.apiversion = RENDERER_API_VERSION; - re.api_size = sizeof(renderer_exp_t); + re.apiversion = RENDER_API_VERSION; + re.api_size = sizeof(render_exp_t); re.BeginRegistration = R_BeginRegistration; re.RegisterModel = R_RegisterModel; diff --git a/renderer/gl_rmisc.c b/render/gl_rmisc.c similarity index 100% rename from renderer/gl_rmisc.c rename to render/gl_rmisc.c diff --git a/renderer/gl_rsurf.c b/render/gl_rsurf.c similarity index 100% rename from renderer/gl_rsurf.c rename to render/gl_rsurf.c diff --git a/renderer/gl_warp.c b/render/gl_warp.c similarity index 100% rename from renderer/gl_warp.c rename to render/gl_warp.c diff --git a/renderer/gl_widnt.c b/render/gl_widnt.c similarity index 100% rename from renderer/gl_widnt.c rename to render/gl_widnt.c diff --git a/renderer/glw_imp.c b/render/glw_imp.c similarity index 100% rename from renderer/glw_imp.c rename to render/glw_imp.c diff --git a/renderer/lhfont.h b/render/lhfont.h similarity index 100% rename from renderer/lhfont.h rename to render/lhfont.h diff --git a/renderer/palette.h b/render/palette.h similarity index 100% rename from renderer/palette.h rename to render/palette.h diff --git a/renderer/r_backend.c b/render/r_backend.c similarity index 100% rename from renderer/r_backend.c rename to render/r_backend.c diff --git a/renderer/r_bloom.c b/render/r_bloom.c similarity index 100% rename from renderer/r_bloom.c rename to render/r_bloom.c diff --git a/renderer/r_bspmod.c b/render/r_bspmod.c similarity index 100% rename from renderer/r_bspmod.c rename to render/r_bspmod.c diff --git a/renderer/r_opengl.h b/render/r_opengl.h similarity index 100% rename from renderer/r_opengl.h rename to render/r_opengl.h diff --git a/renderer/r_sprite.c b/render/r_sprite.c similarity index 100% rename from renderer/r_sprite.c rename to render/r_sprite.c diff --git a/renderer/r_studio.c b/render/r_studio.c similarity index 95% rename from renderer/r_studio.c rename to render/r_studio.c index 4aef08a6..b155cf62 100644 --- a/renderer/r_studio.c +++ b/render/r_studio.c @@ -1082,10 +1082,19 @@ void R_StudioSetupLighting( void ) m_plightvec[1] = 0.0f; m_plightvec[2] = -1.0f; - R_LightPoint (m_pCurrentEntity->origin, m_plightcolor ); + if(currententity->flags & RF_FULLBRIGHT) + { + for (i = 0; i < 3; i++) + m_plightcolor[i] = 1.0f; + } + else + { + R_LightPoint (m_pCurrentEntity->origin, m_plightcolor ); - if ( m_pCurrentEntity->flags & RF_WEAPONMODEL ) - r_lightlevel->value = bound(0, VectorLength(m_plightcolor) * 75.0f, 255); + if ( m_pCurrentEntity->flags & RF_WEAPONMODEL ) + r_lightlevel->value = bound(0, VectorLength(m_plightcolor) * 75.0f, 255); + + } // TODO: only do it for bones that actually have textures for (i = 0; i < m_pStudioHeader->numbones; i++) @@ -1096,7 +1105,6 @@ void R_StudioSetupLighting( void ) VectorIRotate( m_plightvec, m_pbonestransform[i], m_blightvec[i] ); } } - } void R_StudioLighting (float *lv, int bone, int flags, vec3_t normal) diff --git a/renderer/r_texture.c b/render/r_texture.c similarity index 96% rename from renderer/r_texture.c rename to render/r_texture.c index c58d4f6f..7a3ecc1c 100644 --- a/renderer/r_texture.c +++ b/render/r_texture.c @@ -1635,7 +1635,7 @@ image_t *R_LoadImage(char *name, rgbdata_t *pic, imagetype_t type ) image->paletted = pic->palette ? true : false; buf = pic->buffer; - //fill image_desc + // fill image_desc R_GetPixelFormat( pic, type ); for(i = 0; i < numsides; i++, buf += offset ) @@ -1646,7 +1646,7 @@ image_t *R_LoadImage(char *name, rgbdata_t *pic, imagetype_t type ) R_SetPixelFormat( image_desc.width, image_desc.height, image_desc.numLayers ); offset = image_desc.SizeOfFile;// move pointer - MsgDev(D_INFO, "loading %s [%s] \n", name, PixelFormatDescription[image_desc.format].name ); + MsgDev(D_LOAD, "loading %s [%s] \n", name, PixelFormatDescription[image_desc.format].name ); switch(pic->type) { diff --git a/renderer/r_utils.c b/render/r_utils.c similarity index 100% rename from renderer/r_utils.c rename to render/r_utils.c diff --git a/renderer/renderer.dsp b/render/render.dsp similarity index 67% rename from renderer/renderer.dsp rename to render/render.dsp index 184f84ed..6d5f8f43 100644 --- a/renderer/renderer.dsp +++ b/render/render.dsp @@ -1,24 +1,24 @@ -# Microsoft Developer Studio Project File - Name="renderer" - Package Owner=<4> +# Microsoft Developer Studio Project File - Name="render" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 -CFG=renderer - Win32 Release +CFG=render - Win32 Release !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE -!MESSAGE NMAKE /f "renderer.mak". +!MESSAGE NMAKE /f "render.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE -!MESSAGE NMAKE /f "renderer.mak" CFG="renderer - Win32 Release" +!MESSAGE NMAKE /f "render.mak" CFG="render - Win32 Release" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE -!MESSAGE "renderer - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE "renderer - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE "render - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE "render - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE # Begin Project @@ -29,21 +29,21 @@ CPP=cl.exe MTL=midl.exe RSC=rc.exe -!IF "$(CFG)" == "renderer - Win32 Release" +!IF "$(CFG)" == "render - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir ".\renderer__" -# PROP BASE Intermediate_Dir ".\renderer__" +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" # PROP BASE Target_Dir "." # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 -# PROP Output_Dir "..\temp\renderer\!release" -# PROP Intermediate_Dir "..\temp\renderer\!release" +# PROP Output_Dir "..\temp\render\!release" +# PROP Intermediate_Dir "..\temp\render\!release" # PROP Ignore_Export_Lib 1 # PROP Target_Dir "." # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /c -# ADD CPP /nologo /W3 /GX /O2 /Ob0 /I "../public" /I "../platform/formats" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /FD /c +# ADD CPP /nologo /MD /W3 /GX /O2 /Ob0 /I "../public" /I "../platform/formats" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /FD /c # SUBTRACT CPP /YX # ADD BASE MTL /nologo /D "NDEBUG" /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 @@ -54,33 +54,33 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386 -# ADD LINK32 kernel32.lib user32.lib gdi32.lib /nologo /subsystem:windows /dll /pdb:none /machine:I386 /libpath:"../public/libs/" +# ADD LINK32 msvcrt.lib user32.lib gdi32.lib /nologo /subsystem:windows /dll /pdb:none /machine:I386 /nodefaultlib:"libc.lib" /libpath:"../public/libs/" # SUBTRACT LINK32 /debug # Begin Custom Build -TargetDir=\XASH3D\src_main\!source\temp\renderer\!release -InputPath=\XASH3D\src_main\!source\temp\renderer\!release\renderer.dll +TargetDir=\XASH3D\src_main\!source\temp\render\!release +InputPath=\XASH3D\src_main\!source\temp\render\!release\render.dll SOURCE="$(InputPath)" -"D:\Xash3D\bin\renderer.dll" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" - copy $(TargetDir)\renderer.dll "D:\Xash3D\bin\renderer.dll" +"D:\Xash3D\bin\render.dll" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" + copy $(TargetDir)\render.dll "D:\Xash3D\bin\render.dll" # End Custom Build -!ELSEIF "$(CFG)" == "renderer - Win32 Debug" +!ELSEIF "$(CFG)" == "render - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir ".\renderer__" -# PROP BASE Intermediate_Dir ".\renderer__" +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" # PROP BASE Target_Dir "." # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 -# PROP Output_Dir "..\temp\renderer\!debug" -# PROP Intermediate_Dir "..\temp\renderer\!debug" +# PROP Output_Dir "..\temp\render\!debug" +# PROP Intermediate_Dir "..\temp\render\!debug" # PROP Ignore_Export_Lib 1 # PROP Target_Dir "." # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /c -# ADD CPP /nologo /MTd /W3 /Gm /Gi /GX /ZI /Od /I "../public" /I "../platform/formats" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /FR /FD /c +# ADD CPP /nologo /MDd /W3 /Gm /Gi /GX /ZI /Od /I "../public" /I "../platform/formats" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /FR /FD /c # SUBTRACT CPP /YX # ADD BASE MTL /nologo /D "_DEBUG" /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 @@ -91,15 +91,15 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 -# ADD LINK32 kernel32.lib user32.lib gdi32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /nodefaultlib:"libc.lib" /pdbtype:sept /libpath:"../public/libs/" +# ADD LINK32 msvcrt.lib user32.lib gdi32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /nodefaultlib:"msvcrtd.lib" /pdbtype:sept /libpath:"../public/libs/" # SUBTRACT LINK32 /profile /incremental:no /map # Begin Custom Build -TargetDir=\XASH3D\src_main\!source\temp\renderer\!debug -InputPath=\XASH3D\src_main\!source\temp\renderer\!debug\renderer.dll +TargetDir=\XASH3D\src_main\!source\temp\render\!debug +InputPath=\XASH3D\src_main\!source\temp\render\!debug\render.dll SOURCE="$(InputPath)" -"D:\Xash3D\bin\renderer.dll" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" - copy $(TargetDir)\renderer.dll "D:\Xash3D\bin\renderer.dll" +"D:\Xash3D\bin\render.dll" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" + copy $(TargetDir)\render.dll "D:\Xash3D\bin\render.dll" # End Custom Build @@ -107,8 +107,8 @@ SOURCE="$(InputPath)" # Begin Target -# Name "renderer - Win32 Release" -# Name "renderer - Win32 Debug" +# Name "render - Win32 Release" +# Name "render - Win32 Debug" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;hpj;bat;for;f90" @@ -226,7 +226,7 @@ SOURCE=..\client\ref.h # End Source File # Begin Source File -SOURCE=.\renderer.h +SOURCE=.\render.h # End Source File # Begin Source File diff --git a/renderer/warpsin.h b/render/warpsin.h similarity index 100% rename from renderer/warpsin.h rename to render/warpsin.h diff --git a/upx_pack.bat b/upx_pack.bat new file mode 100644 index 00000000..5bfb22aa --- /dev/null +++ b/upx_pack.bat @@ -0,0 +1,7 @@ +@echo off +upx.exe -5 D:\Xash3D\bin\editor.dll +upx.exe -5 D:\Xash3D\bin\engine.dll +upx.exe -5 D:\Xash3D\bin\launcher.dll +upx.exe -5 D:\Xash3D\bin\common.dll +upx.exe -5 D:\Xash3D\bin\render.dll +pause \ No newline at end of file diff --git a/progs/PROGS.SRC b/vprogs/PROGS.SRC similarity index 100% rename from progs/PROGS.SRC rename to vprogs/PROGS.SRC diff --git a/progs/client.c b/vprogs/client.c similarity index 100% rename from progs/client.c rename to vprogs/client.c diff --git a/progs/damage.c b/vprogs/damage.c similarity index 100% rename from progs/damage.c rename to vprogs/damage.c diff --git a/progs/defs.c b/vprogs/defs.c similarity index 100% rename from progs/defs.c rename to vprogs/defs.c diff --git a/progs/dummys.c b/vprogs/dummys.c similarity index 100% rename from progs/dummys.c rename to vprogs/dummys.c diff --git a/progs/ents/ambient.c b/vprogs/ents/ambient.c similarity index 100% rename from progs/ents/ambient.c rename to vprogs/ents/ambient.c diff --git a/progs/ents/ccam.c b/vprogs/ents/ccam.c similarity index 100% rename from progs/ents/ccam.c rename to vprogs/ents/ccam.c diff --git a/progs/ents/funcs/func_button.c b/vprogs/ents/funcs/func_button.c similarity index 100% rename from progs/ents/funcs/func_button.c rename to vprogs/ents/funcs/func_button.c diff --git a/progs/ents/funcs/func_door.c b/vprogs/ents/funcs/func_door.c similarity index 100% rename from progs/ents/funcs/func_door.c rename to vprogs/ents/funcs/func_door.c diff --git a/progs/ents/funcs/func_mover.c b/vprogs/ents/funcs/func_mover.c similarity index 100% rename from progs/ents/funcs/func_mover.c rename to vprogs/ents/funcs/func_mover.c diff --git a/progs/ents/funcs/func_path_corner.c b/vprogs/ents/funcs/func_path_corner.c similarity index 100% rename from progs/ents/funcs/func_path_corner.c rename to vprogs/ents/funcs/func_path_corner.c diff --git a/progs/ents/funcs/func_train.c b/vprogs/ents/funcs/func_train.c similarity index 100% rename from progs/ents/funcs/func_train.c rename to vprogs/ents/funcs/func_train.c diff --git a/progs/ents/funcs/funcs.c b/vprogs/ents/funcs/funcs.c similarity index 100% rename from progs/ents/funcs/funcs.c rename to vprogs/ents/funcs/funcs.c diff --git a/progs/ents/internal.c b/vprogs/ents/internal.c similarity index 100% rename from progs/ents/internal.c rename to vprogs/ents/internal.c diff --git a/progs/ents/items/items.c b/vprogs/ents/items/items.c similarity index 100% rename from progs/ents/items/items.c rename to vprogs/ents/items/items.c diff --git a/progs/ents/lights.c b/vprogs/ents/lights.c similarity index 100% rename from progs/ents/lights.c rename to vprogs/ents/lights.c diff --git a/progs/ents/triggers/trigger_changelevel.c b/vprogs/ents/triggers/trigger_changelevel.c similarity index 100% rename from progs/ents/triggers/trigger_changelevel.c rename to vprogs/ents/triggers/trigger_changelevel.c diff --git a/progs/ents/triggers/trigger_counter.c b/vprogs/ents/triggers/trigger_counter.c similarity index 100% rename from progs/ents/triggers/trigger_counter.c rename to vprogs/ents/triggers/trigger_counter.c diff --git a/progs/ents/triggers/trigger_generic.c b/vprogs/ents/triggers/trigger_generic.c similarity index 100% rename from progs/ents/triggers/trigger_generic.c rename to vprogs/ents/triggers/trigger_generic.c diff --git a/progs/ents/triggers/trigger_hurt.c b/vprogs/ents/triggers/trigger_hurt.c similarity index 100% rename from progs/ents/triggers/trigger_hurt.c rename to vprogs/ents/triggers/trigger_hurt.c diff --git a/progs/ents/triggers/trigger_message.c b/vprogs/ents/triggers/trigger_message.c similarity index 100% rename from progs/ents/triggers/trigger_message.c rename to vprogs/ents/triggers/trigger_message.c diff --git a/progs/ents/triggers/trigger_once.c b/vprogs/ents/triggers/trigger_once.c similarity index 100% rename from progs/ents/triggers/trigger_once.c rename to vprogs/ents/triggers/trigger_once.c diff --git a/progs/ents/triggers/trigger_push.c b/vprogs/ents/triggers/trigger_push.c similarity index 100% rename from progs/ents/triggers/trigger_push.c rename to vprogs/ents/triggers/trigger_push.c diff --git a/progs/ents/triggers/trigger_secret.c b/vprogs/ents/triggers/trigger_secret.c similarity index 100% rename from progs/ents/triggers/trigger_secret.c rename to vprogs/ents/triggers/trigger_secret.c diff --git a/progs/ents/triggers/trigger_sequence.c b/vprogs/ents/triggers/trigger_sequence.c similarity index 100% rename from progs/ents/triggers/trigger_sequence.c rename to vprogs/ents/triggers/trigger_sequence.c diff --git a/progs/ents/triggers/trigger_setskill.c b/vprogs/ents/triggers/trigger_setskill.c similarity index 100% rename from progs/ents/triggers/trigger_setskill.c rename to vprogs/ents/triggers/trigger_setskill.c diff --git a/progs/ents/triggers/trigger_setviewpoint.c b/vprogs/ents/triggers/trigger_setviewpoint.c similarity index 100% rename from progs/ents/triggers/trigger_setviewpoint.c rename to vprogs/ents/triggers/trigger_setviewpoint.c diff --git a/progs/ents/triggers/trigger_teleport.c b/vprogs/ents/triggers/trigger_teleport.c similarity index 100% rename from progs/ents/triggers/trigger_teleport.c rename to vprogs/ents/triggers/trigger_teleport.c diff --git a/progs/ents/triggers/triggers.c b/vprogs/ents/triggers/triggers.c similarity index 100% rename from progs/ents/triggers/triggers.c rename to vprogs/ents/triggers/triggers.c diff --git a/progs/impulses.c b/vprogs/impulses.c similarity index 100% rename from progs/impulses.c rename to vprogs/impulses.c diff --git a/progs/main.c b/vprogs/main.c similarity index 100% rename from progs/main.c rename to vprogs/main.c diff --git a/progs/player.c b/vprogs/player.c similarity index 100% rename from progs/player.c rename to vprogs/player.c diff --git a/progs/progdefs.h b/vprogs/progdefs.h similarity index 100% rename from progs/progdefs.h rename to vprogs/progdefs.h diff --git a/vprogs/qcclib.exe b/vprogs/qcclib.exe new file mode 100644 index 0000000000000000000000000000000000000000..d47d818e06147fbe283e971a7a39ffe43265fbcc GIT binary patch literal 6144 zcmeHLe{2)?6@LzH6VimF8%A_u!Z5O-jYTP;8fAc-CKt#WgA*rdn8M7(zU1sVXLCN2 zL>iirw_(pjrBeS`t8EISe{|A1RS2!9+Ozn zN9UCdJ!&}Nj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Q%FOoFxBRT;e%i)A`8(4khrvO@sx-sgY{j?8s2ikUw8GhsZ z;4aVStAe6ZkFQ1XX~eF}!V9gNE7-zM2I&+gjfUYZOi|RN1Jn?1L82QdgaaR&+kj7t z{u%M&LGG$k(JZ2*zjR6@vqCP&@$0&q32NA8jwjWiOMp2ig_RFhNUYmQ@SVG;19Q zFm-&CVb5IU;X5ZWNF9HkzgBLyS=Qt0E$dE!o{wAB@w$&oBb|7iMMeFE3}wbJgAzTO z866$V%$Mjp79xMQvP4@Mq%c34D#puLob)2i8Cna=={qHTTb@};3ubXXfnE%;Y0Y;EAUS)OC{I< literal 0 HcmV?d00001 diff --git a/xash.dsw b/xash.dsw index e943a78d..7915ac21 100644 --- a/xash.dsw +++ b/xash.dsw @@ -39,7 +39,7 @@ Package=<4> ############################################################################### -Project: "platform"=".\platform\platform.dsp" - Package Owner=<4> +Project: "common"=".\common\common.dsp" - Package Owner=<4> Package=<5> {{{ @@ -51,7 +51,7 @@ Package=<4> ############################################################################### -Project: "renderer"=".\renderer\renderer.dsp" - Package Owner=<4> +Project: "render"=".\render\render.dsp" - Package Owner=<4> Package=<5> {{{