├── .clang-format ├── .gitignore ├── .gitmodules ├── .travis.yml ├── CMakeLists.txt ├── LICENSE ├── README.md ├── appveyor.yml ├── cmake ├── modules │ ├── CheckIntrinsics.cmake │ ├── FindDirectX.cmake │ ├── FindLZO.cmake │ ├── FindSDL2.cmake │ └── FindWindowsSDK.cmake └── toolchains │ ├── i686-w64-mingw32.cmake │ └── x86_64-w64-mingw32.cmake ├── libs └── minilzo │ ├── COPYING │ ├── README.LZO │ ├── lzoconf.h │ ├── lzodefs.h │ ├── minilzo.c │ ├── minilzo.h │ └── testmini.c └── src ├── CMakeLists.txt ├── game ├── audio │ ├── adpcm.cpp │ ├── adpcm.h │ ├── audio.cpp │ └── audio.h ├── common │ ├── base64.cpp │ ├── base64.h │ ├── bench.cpp │ ├── bench.h │ ├── bitarray.cpp │ ├── bitarray.h │ ├── buffer.cpp │ ├── buffer.h │ ├── cpudetect.cpp │ ├── cpudetect.h │ ├── crc.cpp │ ├── crc.h │ ├── critsection.cpp │ ├── critsection.h │ ├── dipthong.cpp │ ├── dipthong.h │ ├── fixed.cpp │ ├── fixed.h │ ├── fixedmult.h │ ├── globals.cpp │ ├── globals.h │ ├── index.h │ ├── ini.cpp │ ├── ini.h │ ├── language.cpp │ ├── language.h │ ├── lcw.cpp │ ├── lcw.h │ ├── listnode.h │ ├── memrev.h │ ├── noinit.h │ ├── nstrdup.h │ ├── ostimer.cpp │ ├── ostimer.h │ ├── pcxrle.cpp │ ├── pcxrle.h │ ├── random.cpp │ ├── random.h │ ├── readline.cpp │ ├── readline.h │ ├── remap.cpp │ ├── remap.h │ ├── timer.cpp │ ├── timer.h │ ├── tpoint.h │ ├── trect.h │ ├── ttimer.cpp │ ├── ttimer.h │ ├── vector.cpp │ ├── vector.h │ ├── xordelta.cpp │ └── xordelta.h ├── crypto │ ├── blowfish.cpp │ ├── blowfish.h │ ├── int.h │ ├── mpmath.cpp │ ├── mpmath.h │ ├── pk.cpp │ ├── pk.h │ ├── sha.cpp │ └── sha.h ├── engine │ ├── abstract.cpp │ ├── abstract.h │ ├── abstracttype.cpp │ ├── abstracttype.h │ ├── action.cpp │ ├── action.h │ ├── aircraft.cpp │ ├── aircraft.h │ ├── aircraftdata.cpp │ ├── aircraftdata.h │ ├── aircrafttype.cpp │ ├── aircrafttype.h │ ├── anim.cpp │ ├── anim.h │ ├── animdata.cpp │ ├── animdata.h │ ├── animtype.cpp │ ├── animtype.h │ ├── armor.cpp │ ├── armor.h │ ├── attract.cpp │ ├── attract.h │ ├── basec.cpp │ ├── basec.h │ ├── building.cpp │ ├── building.h │ ├── buildingdata.cpp │ ├── buildingdata.h │ ├── buildingtype.cpp │ ├── buildingtype.h │ ├── bullet.cpp │ ├── bullet.h │ ├── bulletdata.cpp │ ├── bulletdata.h │ ├── bullettype.cpp │ ├── bullettype.h │ ├── callback.cpp │ ├── callback.h │ ├── cargo.cpp │ ├── cargo.h │ ├── carryover.cpp │ ├── carryover.h │ ├── cell.cpp │ ├── cell.h │ ├── cmdline.cpp │ ├── cmdline.h │ ├── combat.cpp │ ├── combat.h │ ├── coord.cpp │ ├── coord.h │ ├── crate.cpp │ ├── crate.h │ ├── crew.h │ ├── difficulty.cpp │ ├── difficulty.h │ ├── display.cpp │ ├── display.h │ ├── door.cpp │ ├── door.h │ ├── drive.cpp │ ├── drive.h │ ├── egos.cpp │ ├── egos.h │ ├── expansion.cpp │ ├── expansion.h │ ├── facing.cpp │ ├── facing.h │ ├── factory.cpp │ ├── factory.h │ ├── fetchtechtype.cpp │ ├── fetchtechtype.h │ ├── flasher.cpp │ ├── flasher.h │ ├── fly.cpp │ ├── fly.h │ ├── focus.cpp │ ├── focus.h │ ├── foot.cpp │ ├── foot.h │ ├── fuse.cpp │ ├── fuse.h │ ├── gameevent.cpp │ ├── gameevent.h │ ├── gameini.cpp │ ├── gameini.h │ ├── gamekeyboard.cpp │ ├── gamekeyboard.h │ ├── gameloop.cpp │ ├── gameloop.h │ ├── gamemain.cpp │ ├── gamemain.h │ ├── gameoptions.cpp │ ├── gameoptions.h │ ├── gameptr.cpp │ ├── gameptr.h │ ├── gametypes.h │ ├── getcd.cpp │ ├── getcd.h │ ├── gmouse.cpp │ ├── gmouse.h │ ├── ground.cpp │ ├── ground.h │ ├── gscreen.cpp │ ├── gscreen.h │ ├── heap.cpp │ ├── heap.h │ ├── help.cpp │ ├── help.h │ ├── house.cpp │ ├── house.h │ ├── housedata.cpp │ ├── housedata.h │ ├── housestatic.cpp │ ├── housestatic.h │ ├── housetype.cpp │ ├── housetype.h │ ├── infantry.cpp │ ├── infantry.h │ ├── infantrydata.cpp │ ├── infantrydata.h │ ├── infantrytype.cpp │ ├── infantrytype.h │ ├── init.cpp │ ├── init.h │ ├── iomap.cpp │ ├── iomap.h │ ├── land.cpp │ ├── land.h │ ├── layer.cpp │ ├── layer.h │ ├── lists.cpp │ ├── lists.h │ ├── loaddialog.cpp │ ├── loaddialog.h │ ├── logic.cpp │ ├── logic.h │ ├── mainmenu.cpp │ ├── mainmenu.h │ ├── map.cpp │ ├── map.h │ ├── mapedit.cpp │ ├── mapedit.h │ ├── mission.cpp │ ├── mission.h │ ├── missioncontrol.cpp │ ├── missioncontrol.h │ ├── movie.cpp │ ├── movie.h │ ├── msglist.cpp │ ├── msglist.h │ ├── multimission.cpp │ ├── multimission.h │ ├── mzone.cpp │ ├── mzone.h │ ├── object.cpp │ ├── object.h │ ├── objecttype.cpp │ ├── objecttype.h │ ├── options.cpp │ ├── options.h │ ├── overlay.cpp │ ├── overlay.h │ ├── overlaydata.cpp │ ├── overlaydata.h │ ├── overlaytype.cpp │ ├── overlaytype.h │ ├── picture.cpp │ ├── picture.h │ ├── power.cpp │ ├── power.h │ ├── quarry.cpp │ ├── quarry.h │ ├── queue.cpp │ ├── queue.h │ ├── radar.cpp │ ├── radar.h │ ├── radio.cpp │ ├── radio.h │ ├── region.h │ ├── rtti.cpp │ ├── rtti.h │ ├── rules.cpp │ ├── rules.h │ ├── saveload.cpp │ ├── saveload.h │ ├── scenario.cpp │ ├── scenario.h │ ├── scroll.cpp │ ├── scroll.h │ ├── session.cpp │ ├── session.h │ ├── sidebar.cpp │ ├── sidebar.h │ ├── smudge.cpp │ ├── smudge.h │ ├── smudgedata.cpp │ ├── smudgedata.h │ ├── smudgetype.cpp │ ├── smudgetype.h │ ├── sndctrl.cpp │ ├── sndctrl.h │ ├── source.cpp │ ├── source.h │ ├── special.cpp │ ├── special.h │ ├── stage.h │ ├── super.cpp │ ├── super.h │ ├── tab.cpp │ ├── tab.h │ ├── taction.cpp │ ├── taction.h │ ├── target.cpp │ ├── target.h │ ├── team.cpp │ ├── team.h │ ├── teamtype.cpp │ ├── teamtype.h │ ├── techno.cpp │ ├── techno.h │ ├── technotype.cpp │ ├── technotype.h │ ├── template.cpp │ ├── template.h │ ├── templatedata.cpp │ ├── templatedata.h │ ├── templatetype.cpp │ ├── templatetype.h │ ├── terrain.cpp │ ├── terrain.h │ ├── terraindata.cpp │ ├── terraindata.h │ ├── terraintype.cpp │ ├── terraintype.h │ ├── tevent.cpp │ ├── tevent.h │ ├── theater.cpp │ ├── theater.h │ ├── theme.cpp │ ├── theme.h │ ├── tracker.cpp │ ├── tracker.h │ ├── trigger.cpp │ ├── trigger.h │ ├── triggertype.cpp │ ├── triggertype.h │ ├── unit.cpp │ ├── unit.h │ ├── unitdata.cpp │ ├── unitdata.h │ ├── unittype.cpp │ ├── unittype.h │ ├── utracker.cpp │ ├── utracker.h │ ├── version.cpp │ ├── version.h │ ├── vessel.cpp │ ├── vessel.h │ ├── vesseldata.cpp │ ├── vesseldata.h │ ├── vesseltype.cpp │ ├── vesseltype.h │ ├── voc.cpp │ ├── voc.h │ ├── vortex.cpp │ ├── vortex.h │ ├── vox.cpp │ ├── vox.h │ ├── warheaddata.cpp │ ├── warheaddata.h │ ├── warheadtype.cpp │ ├── warheadtype.h │ ├── weapondata.cpp │ ├── weapondata.h │ ├── weapontype.cpp │ └── weapontype.h ├── gfx │ ├── blitters.cpp │ ├── blitters.h │ ├── drawshape.cpp │ ├── drawshape.h │ ├── fading.cpp │ ├── fading.h │ ├── gbuffer.cpp │ ├── gbuffer.h │ ├── hsv.cpp │ ├── hsv.h │ ├── interpolate.cpp │ ├── interpolate.h │ ├── mouseshape.cpp │ ├── mouseshape.h │ ├── pal.cpp │ ├── pal.h │ ├── palette.cpp │ ├── palette.h │ ├── pcx.cpp │ ├── pcx.h │ ├── rgb.cpp │ ├── rgb.h │ ├── shape.cpp │ ├── shape.h │ ├── surfacemonitor.cpp │ ├── surfacemonitor.h │ ├── textprint.cpp │ ├── textprint.h │ ├── tileset.cpp │ ├── tileset.h │ ├── wsa.cpp │ └── wsa.h ├── io │ ├── b64pipe.cpp │ ├── b64pipe.h │ ├── b64straw.cpp │ ├── b64straw.h │ ├── basefile.cpp │ ├── basefile.h │ ├── bfiofile.cpp │ ├── bfiofile.h │ ├── blowpipe.cpp │ ├── blowpipe.h │ ├── blowstraw.cpp │ ├── blowstraw.h │ ├── buffpipe.cpp │ ├── buffpipe.h │ ├── buffstraw.cpp │ ├── buffstraw.h │ ├── cd.cpp │ ├── cd.h │ ├── cdfile.cpp │ ├── cdfile.h │ ├── filepipe.cpp │ ├── filepipe.h │ ├── filestraw.cpp │ ├── filestraw.h │ ├── gamefile.cpp │ ├── gamefile.h │ ├── lcwpipe.cpp │ ├── lcwpipe.h │ ├── lcwstraw.cpp │ ├── lcwstraw.h │ ├── lzopipe.cpp │ ├── lzopipe.h │ ├── lzostraw.cpp │ ├── lzostraw.h │ ├── mixfile.cpp │ ├── mixfile.h │ ├── pcxpipe.cpp │ ├── pcxpipe.h │ ├── pcxstraw.cpp │ ├── pcxstraw.h │ ├── pipe.cpp │ ├── pipe.h │ ├── pkpipe.cpp │ ├── pkpipe.h │ ├── pkstraw.cpp │ ├── pkstraw.h │ ├── ramfile.cpp │ ├── ramfile.h │ ├── rawfile.cpp │ ├── rawfile.h │ ├── rndstraw.cpp │ ├── rndstraw.h │ ├── shapipe.cpp │ ├── shapipe.h │ ├── shastraw.cpp │ ├── shastraw.h │ ├── straw.cpp │ └── straw.h ├── main.cpp ├── main.h ├── memory │ ├── alloc.cpp │ ├── alloc.h │ ├── newdel.cpp │ └── newdel.h ├── net │ ├── commbuff.cpp │ ├── commbuff.h │ ├── connection.cpp │ ├── connection.h │ ├── connman.h │ ├── field.cpp │ ├── field.h │ ├── ipx.cpp │ ├── ipx.h │ ├── ipxaddress.cpp │ ├── ipxaddress.h │ ├── packet.cpp │ ├── packet.h │ ├── udp.cpp │ ├── udp.h │ ├── wsock.cpp │ └── wsock.h ├── platform │ ├── eventhandler.cpp │ ├── eventhandler.h │ ├── excepthandler.cpp │ ├── excepthandler.h │ ├── initvideo.cpp │ ├── initvideo.h │ ├── keyboard.cpp │ ├── keyboard.h │ ├── mouse.cpp │ ├── mouse.h │ ├── stackdump.cpp │ └── stackdump.h ├── startup.cpp ├── startup.h └── ui │ ├── bigcheck.cpp │ ├── bigcheck.h │ ├── checkbox.cpp │ ├── checkbox.h │ ├── checklist.cpp │ ├── checklist.h │ ├── colrlist.cpp │ ├── colrlist.h │ ├── controlc.cpp │ ├── controlc.h │ ├── dial8.cpp │ ├── dial8.h │ ├── dialog.cpp │ ├── dialog.h │ ├── droplist.cpp │ ├── droplist.h │ ├── edit.cpp │ ├── edit.h │ ├── gadget.cpp │ ├── gadget.h │ ├── gauge.cpp │ ├── gauge.h │ ├── link.cpp │ ├── link.h │ ├── list.cpp │ ├── list.h │ ├── msgbox.cpp │ ├── msgbox.h │ ├── musiclist.cpp │ ├── musiclist.h │ ├── shapebtn.cpp │ ├── shapebtn.h │ ├── slider.cpp │ ├── slider.h │ ├── staticbtn.cpp │ ├── staticbtn.h │ ├── tdroplist.h │ ├── textbtn.cpp │ ├── textbtn.h │ ├── tlist.h │ ├── toggle.cpp │ ├── toggle.h │ ├── trigauge.cpp │ ├── trigauge.h │ ├── txtlabel.cpp │ └── txtlabel.h └── hooker ├── dllmain.cpp ├── hookcrt.h ├── hooker.cpp ├── hooker.h ├── setupglobals.cpp ├── setuphooks.cpp └── setuphooks.h /.gitignore: -------------------------------------------------------------------------------- 1 | *.user 2 | *.ncb 3 | /build* 4 | nbproject/ 5 | project/ 6 | doxygen/ 7 | *.a 8 | *.o 9 | CMakeCache.txt 10 | CMakeFiles 11 | Makefile 12 | cmake_install.cmake 13 | install_manifest.txt 14 | compile_commands.json 15 | *.so* 16 | CPackConfig.cmake 17 | CPackSourceConfig.cmake 18 | *.spec 19 | *.ncb 20 | *.sdf 21 | *.suo 22 | *.sln 23 | *.vcxproj* 24 | *.vcproj 25 | .cproject 26 | .project 27 | *~ 28 | !*.exe 29 | *.lastbuildstate 30 | *.unsuccessfulbuild 31 | *.tlog 32 | *.idb 33 | *.cd 34 | *.tmp 35 | *.bak 36 | thumbs.db 37 | /.vscode/ 38 | /.vs/ 39 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "libs/baseconfig"] 2 | path = libs/baseconfig 3 | url = https://github.com/TheAssemblyArmada/BaseConfig.git 4 | [submodule "launcher"] 5 | path = launcher 6 | url = https://github.com/TheAssemblyArmada/SetSail.git 7 | [submodule "libs/captnlog"] 8 | path = libs/captnlog 9 | url = https://github.com/TheAssemblyArmada/CaptainsLog.git 10 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: cpp 2 | 3 | compiler: 4 | - clang 5 | - gcc 6 | 7 | env: 8 | - 'BUILD_TYPE=Release' 9 | - 'BUILD_TYPE=Debug' 10 | 11 | before_install: 12 | - sudo apt-get install -y libgtk-3-dev 13 | 14 | before_script: 15 | - mkdir build 16 | - cd build 17 | - cmake -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DSTANDALONE=TRUE .. 18 | 19 | script: make -j2 20 | -------------------------------------------------------------------------------- /cmake/toolchains/i686-w64-mingw32.cmake: -------------------------------------------------------------------------------- 1 | # Sample toolchain file for building for Windows from an Ubuntu Linux system. 2 | # 3 | # Typical usage: 4 | # *) install cross compiler: `sudo apt-get install mingw-w64 g++-mingw-w64` 5 | # *) mkdir build 6 | # *) cd build 7 | # *) cmake -DCMAKE_TOOLCHAIN_FILE=../cmake/toolchains/i686-w64-mingw32.cmake .. 8 | 9 | set(CMAKE_SYSTEM_NAME Windows) 10 | set(TOOLCHAIN_PREFIX i686-w64-mingw32) 11 | 12 | # cross compilers to use for C and C++ 13 | set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}-gcc) 14 | set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}-g++) 15 | set(CMAKE_RC_COMPILER ${TOOLCHAIN_PREFIX}-windres) 16 | 17 | # target environment on the build host system 18 | # set 1st to dir with the cross compiler's C/C++ headers/libs 19 | set(CMAKE_FIND_ROOT_PATH /usr/${TOOLCHAIN_PREFIX} /usr/${TOOLCHAIN_PREFIX}/sys-root/mingw) 20 | 21 | # modify default behavior of FIND_XXX() commands to 22 | # search for headers/libs in the target environment and 23 | # search for programs in the build host environment 24 | set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) 25 | set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) 26 | set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) 27 | -------------------------------------------------------------------------------- /cmake/toolchains/x86_64-w64-mingw32.cmake: -------------------------------------------------------------------------------- 1 | # Sample toolchain file for building for Windows from an Ubuntu Linux system. 2 | # 3 | # Typical usage: 4 | # *) install cross compiler: `sudo apt-get install mingw-w64 g++-mingw-w64` 5 | # *) mkdir build 6 | # *) cd build 7 | # *) cmake -DCMAKE_TOOLCHAIN_FILE=../cmake/toolchains/x86_64-w64-mingw32.cmake .. 8 | 9 | set(CMAKE_SYSTEM_NAME Windows) 10 | set(TOOLCHAIN_PREFIX x86_64-w64-mingw32) 11 | 12 | # cross compilers to use for C and C++ 13 | set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}-gcc) 14 | set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}-g++) 15 | set(CMAKE_RC_COMPILER ${TOOLCHAIN_PREFIX}-windres) 16 | 17 | # target environment on the build host system 18 | # set 1st to dir with the cross compiler's C/C++ headers/libs 19 | set(CMAKE_FIND_ROOT_PATH /usr/${TOOLCHAIN_PREFIX} /usr/${TOOLCHAIN_PREFIX}/sys-root/mingw) 20 | 21 | # modify default behavior of FIND_XXX() commands to 22 | # search for headers/libs in the target environment and 23 | # search for programs in the build host environment 24 | set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) 25 | set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) 26 | set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) 27 | -------------------------------------------------------------------------------- /src/game/common/base64.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author CCHyper 5 | * @author OmniBlade 6 | * 7 | * @brief Functions for base64 encoding and decoding. 8 | * 9 | * @copyright Chronoshift is free software: you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation, either version 12 | * 2 of the License, or (at your option) any later version. 13 | * A full copy of the GNU General Public License can be found in 14 | * LICENSE 15 | */ 16 | #ifndef BASE64_H 17 | #define BASE64_H 18 | 19 | #include "always.h" 20 | 21 | #define BASE64_OK 0 22 | #define BASE64_ERROR -1 23 | #define BASE64_BUFFER_OVERFLOW -2 24 | 25 | /** 26 | * @brief Get the worst case size of Base64 encoded data given an initial size in bytes. 27 | */ 28 | inline int Base64_Enc_Size(int bytes) 29 | { 30 | return ((bytes + 2) / 3) * 4; 31 | } 32 | 33 | /** 34 | * @brief Get number of bytes in the decoded stream given the encoded size. 35 | */ 36 | inline int Base64_Dec_Size(int bytes) 37 | { 38 | int len = (bytes / 4) * 3; 39 | 40 | if ((bytes % 4) == 3) { 41 | len += 2; 42 | } 43 | 44 | if ((bytes % 4) == 2) { 45 | len += 1; 46 | } 47 | 48 | return len; 49 | } 50 | 51 | int Base64_Encode(const void *src, int slen, void *dst, int dlen); 52 | int Base64_Decode(const void *src, int slen, void *dst, int dlen); 53 | 54 | #endif // BASE64_H 55 | -------------------------------------------------------------------------------- /src/game/common/bitarray.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author OmniBlade 5 | * @author CCHyper 6 | * 7 | * @brief Functions for getting and setting bits in an array of bytes. 8 | * 9 | * @copyright Chronoshift is free software: you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation, either version 12 | * 2 of the License, or (at your option) any later version. 13 | * A full copy of the GNU General Public License can be found in 14 | * LICENSE 15 | */ 16 | #pragma once 17 | 18 | #ifndef BITARRAY_H 19 | #define BITARRAY_H 20 | 21 | #include "always.h" 22 | 23 | void Set_Bit(void *array, int bit, BOOL value); 24 | BOOL Get_Bit(const void *array, int bit); 25 | int First_True_Bit(const void *array, int size); 26 | int First_False_Bit(const void *array, int size); 27 | 28 | #endif // BITARRAY_H 29 | -------------------------------------------------------------------------------- /src/game/common/buffer.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author CCHyper 5 | * @author OmniBlade 6 | * 7 | * @brief Wrapper around memory allocation for simple buffers. 8 | * 9 | * @copyright Chronoshift is free software: you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation, either version 12 | * 2 of the License, or (at your option) any later version. 13 | * A full copy of the GNU General Public License can be found in 14 | * LICENSE 15 | */ 16 | #pragma once 17 | 18 | #ifndef BUFFER_H 19 | #define BUFFER_H 20 | 21 | #include "always.h" 22 | 23 | class BufferClass 24 | { 25 | public: 26 | BufferClass(); 27 | BufferClass(int size); 28 | BufferClass(void *buff, int size = 0); 29 | BufferClass(BufferClass const &that); 30 | ~BufferClass() { Reset(); } 31 | 32 | BufferClass &operator=(BufferClass const &that); 33 | bool operator==(BufferClass const &that); 34 | bool operator!=(BufferClass const &that); 35 | 36 | uint8_t *Get_Buffer() const; 37 | int Get_Size() const; 38 | void Set_Size(int size) { m_size = size; } 39 | void Set_Buffer(void *buffer) { m_buffer = static_cast(buffer); } 40 | void Set_Allocated(BOOL allocated) { m_allocated = allocated; } 41 | BOOL Is_Allocated() { return m_allocated; } 42 | bool Is_Valid() { return m_buffer != nullptr && m_size > 0; } 43 | void Reset() { Free(); Clear(); } 44 | void Resize(int size = 0); 45 | void Resize(void *buff, int size = 0); 46 | 47 | private: 48 | // These should only be called internally to control the buffer state 49 | void Clear(); 50 | void Free(); 51 | 52 | protected: 53 | uint8_t *m_buffer; 54 | int m_size; 55 | BOOL m_allocated; 56 | }; 57 | 58 | #endif // BUFFER_H 59 | -------------------------------------------------------------------------------- /src/game/common/crc.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author CCHyper 5 | * @author OmniBlade 6 | * 7 | * @brief CRC calculating classes. 8 | * 9 | * @copyright Chronoshift is free software: you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation, either version 12 | * 2 of the License, or (at your option) any later version. 13 | * A full copy of the GNU General Public License can be found in 14 | * LICENSE 15 | */ 16 | #pragma once 17 | 18 | #ifndef CRC_H 19 | #define CRC_H 20 | 21 | #include "always.h" 22 | 23 | /** 24 | * @brief Generates simple 32bit hashes of data. 25 | * 26 | * Generates simple 32bit hashes of data. Unlike the TS equivalent, this appears to be something Westwood rolled themselves 27 | * rather than being a standard CRC32. 28 | */ 29 | class CRCEngine 30 | { 31 | public: 32 | CRCEngine(int32_t initial = 0) : m_crc(initial), m_index(0) { m_buffer.integer = 0; } 33 | 34 | int32_t operator()(const void *buffer, unsigned int length = 0); 35 | operator int32_t() { return Value(); } 36 | 37 | private: 38 | void operator()(char datnum); 39 | int32_t Value(); 40 | BOOL Buffer_Needs_Data() { return m_index != 0; } 41 | 42 | private: 43 | int32_t m_crc; 44 | int m_index; 45 | 46 | union 47 | { 48 | int32_t integer; 49 | int8_t bytes[4]; 50 | } m_buffer; 51 | }; 52 | 53 | int32_t __cdecl Calculate_CRC(const void *buffer, unsigned int length); 54 | 55 | #endif // CRC_H 56 | -------------------------------------------------------------------------------- /src/game/common/dipthong.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author CCHyper 5 | * @author OmniBlade 6 | * 7 | * @brief String table and text obfuscation functions. 8 | * 9 | * @copyright Chronoshift is free software: you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation, either version 12 | * 2 of the License, or (at your option) any later version. 13 | * A full copy of the GNU General Public License can be found in 14 | * LICENSE 15 | */ 16 | #pragma once 17 | 18 | #ifndef DIPTHONG_H 19 | #define DIPTHONG_H 20 | 21 | #include "always.h" 22 | 23 | extern const char TXT_STRING_ERROR[]; 24 | 25 | void Fixup_Text(const char *source, char *dest); 26 | int Dip_Text(const char *source, char *dest); 27 | int UnDip_Text(const char *source, char *dest); 28 | const char *Extract_String(char *file, int str_id); 29 | 30 | #endif // DIPTHONG_H 31 | -------------------------------------------------------------------------------- /src/game/common/fixedmult.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author tomsons26 5 | * 6 | * @brief Fixed point multiplication implementation found in TD and still occasionally used in RA. 7 | * 8 | * @copyright Chronoshift is free software: you can redistribute it and/or 9 | * modify it under the terms of the GNU General Public License 10 | * as published by the Free Software Foundation, either version 11 | * 2 of the License, or (at your option) any later version. 12 | * A full copy of the GNU General Public License can be found in 13 | * LICENSE 14 | */ 15 | #pragma once 16 | 17 | #ifndef FIXEDMULT_H 18 | #define FIXEDMULT_H 19 | 20 | inline static int fixed_mult(int a, int b) 21 | { 22 | int res = (a * b) + 128; 23 | 24 | if ( res & 0xFF000000 ){ 25 | res = 0xFFFFFF; 26 | } 27 | 28 | return res >> 8; 29 | } 30 | 31 | #endif //FIXEDMULT_H 32 | -------------------------------------------------------------------------------- /src/game/common/lcw.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author OmniBlade 5 | * 6 | * @brief Implementation of LCW, a custom compression format used in many Westwood games. 7 | * 8 | * @copyright Chronoshift is free software: you can redistribute it and/or 9 | * modify it under the terms of the GNU General Public License 10 | * as published by the Free Software Foundation, either version 11 | * 2 of the License, or (at your option) any later version. 12 | * A full copy of the GNU General Public License can be found in 13 | * LICENSE 14 | */ 15 | #pragma once 16 | 17 | #ifndef LCW_H 18 | #define LCW_H 19 | 20 | #include "always.h" 21 | 22 | /** 23 | * @brief Get the worst case for LCW compression given the starting size. 24 | */ 25 | inline int LCW_Worst_Case(int bytes) 26 | { 27 | return bytes + (bytes / 128) + 1; 28 | } 29 | 30 | int __cdecl LCW_Uncomp(const void *src, void *dst, unsigned int bytes = 0); 31 | int __cdecl LCW_Comp(const void *src, void *dst, unsigned int bytes = 0); 32 | 33 | #endif // LCW_H 34 | -------------------------------------------------------------------------------- /src/game/common/memrev.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author CCHyper 5 | * @author OmniBlade 6 | * 7 | * @brief Function for reversing bytes in memory. 8 | * 9 | * @copyright Chronoshift is free software: you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation, either version 12 | * 2 of the License, or (at your option) any later version. 13 | * A full copy of the GNU General Public License can be found in 14 | * LICENSE 15 | */ 16 | #pragma once 17 | 18 | #ifndef MEMREV_H 19 | #define MEMREV_H 20 | 21 | #include "always.h" 22 | 23 | inline void *memrev(void *dest, void *src, size_t length) 24 | { 25 | char *d = (char *)dest; 26 | char *s = (char *)src; 27 | 28 | if (length > 0) { 29 | char *src_sz = s + length; 30 | char *dest_sz = d + length; 31 | 32 | while (src_sz > src) { 33 | char t = *--src_sz; 34 | *--dest_sz = *s++; 35 | *d++ = t; 36 | } 37 | } 38 | 39 | return dest; 40 | } 41 | 42 | #endif // MEMREV_H 43 | -------------------------------------------------------------------------------- /src/game/common/noinit.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author CCHyper 5 | * @author OmniBlade 6 | * 7 | * @brief Dummy class to act as parameter to select constructors that do no initialisation. 8 | * 9 | * @copyright Chronoshift is free software: you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation, either version 12 | * 2 of the License, or (at your option) any later version. 13 | * A full copy of the GNU General Public License can be found in 14 | * LICENSE 15 | */ 16 | #pragma once 17 | 18 | #ifndef NOINIT_H 19 | #define NOINIT_H 20 | 21 | #include "always.h" 22 | 23 | class NoInitClass 24 | { 25 | public: 26 | void operator()() const {}; 27 | }; 28 | 29 | class InitClass 30 | { 31 | public: 32 | void operator()() const {}; 33 | }; 34 | 35 | #endif // NOINIT_H 36 | -------------------------------------------------------------------------------- /src/game/common/nstrdup.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author OmniBlade 5 | * 6 | * @brief strdup using operator new[] rather than malloc. 7 | * 8 | * @copyright Chronoshift is free software: you can redistribute it and/or 9 | * modify it under the terms of the GNU General Public License 10 | * as published by the Free Software Foundation, either version 11 | * 2 of the License, or (at your option) any later version. 12 | * A full copy of the GNU General Public License can be found in 13 | * LICENSE 14 | */ 15 | #pragma once 16 | 17 | #ifndef NSTRDUP_H 18 | #define NSTRDUP_H 19 | 20 | #include "always.h" 21 | #include 22 | 23 | inline char *nstrdup(const char *str) 24 | { 25 | char *nstr = nullptr; 26 | 27 | if (str != nullptr) { 28 | nstr = new char[std::strlen(str) + 1]; 29 | 30 | if (nstr != nullptr) { 31 | std::strcpy(nstr, str); 32 | } 33 | } 34 | 35 | return nstr; 36 | } 37 | 38 | #endif // NSTRDUP_H 39 | -------------------------------------------------------------------------------- /src/game/common/pcxrle.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author OmniBlade 5 | * 6 | * @brief PCX RLE algorithm specialised for pipe/straw stream system. 7 | * 8 | * @copyright Chronoshift is free software: you can redistribute it and/or 9 | * modify it under the terms of the GNU General Public License 10 | * as published by the Free Software Foundation, either version 11 | * 2 of the License, or (at your option) any later version. 12 | * A full copy of the GNU General Public License can be found in 13 | * LICENSE 14 | */ 15 | #pragma once 16 | 17 | #ifndef PCXRLE_H 18 | #define PCXRLE_H 19 | 20 | #include "always.h" 21 | 22 | int PCX_Encode(void const **source, int srclength, void *dest, int destlength); 23 | int PCX_Decode(void const **source, int srclength, void *dest, int destlength); 24 | 25 | #endif // PCXRLE_H 26 | -------------------------------------------------------------------------------- /src/game/common/random.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author CCHyper 5 | * @author OmniBlade 6 | * 7 | * @brief Random number generator. 8 | * 9 | * @copyright Chronoshift is free software: you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation, either version 12 | * 2 of the License, or (at your option) any later version. 13 | * A full copy of the GNU General Public License can be found in 14 | * LICENSE 15 | */ 16 | #pragma once 17 | 18 | #ifndef RANDOM_H 19 | #define RANDOM_H 20 | 21 | #include "always.h" 22 | 23 | /** 24 | * @brief Provides a linear congruential random number generator with 15 bits of significance. 25 | */ 26 | class RandomClass 27 | { 28 | public: 29 | enum 30 | { 31 | SIGNIFICANT_BITS = 15 // Random number bit significance. 32 | }; 33 | 34 | public: 35 | RandomClass(int seed = 0) : m_Seed(seed) {} 36 | 37 | int operator()(); 38 | int operator()(int minval, int maxval); 39 | 40 | uint32_t Get_Seed() { return m_Seed; } 41 | 42 | private: 43 | enum 44 | { 45 | THROW_AWAY_BITS = 10, // Low bits to throw away. 46 | MAXIMUM = 32767 47 | }; 48 | 49 | uint32_t m_Seed; 50 | static const int s_Multiplier; 51 | static const int s_Adder; 52 | }; 53 | 54 | #ifdef GAME_DLL 55 | extern RandomClass &g_NonCriticalRandom; 56 | #else 57 | extern RandomClass g_NonCriticalRandom; 58 | #endif 59 | 60 | #endif // RANDOM_H 61 | -------------------------------------------------------------------------------- /src/game/common/readline.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author CCHyper 5 | * @author OmniBlade 6 | * 7 | * @brief Reads a line of text from a file or straw. 8 | * 9 | * @copyright Chronoshift is free software: you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation, either version 12 | * 2 of the License, or (at your option) any later version. 13 | * A full copy of the GNU General Public License can be found in 14 | * LICENSE 15 | */ 16 | #include "readline.h" 17 | #include "filestraw.h" 18 | #include 19 | #include 20 | 21 | using std::strlen; 22 | 23 | int Read_Line(FileClass &file, char *line, int length, BOOL &eof) 24 | { 25 | FileStraw fstraw(&file); 26 | return Read_Line(fstraw, line, length, eof); 27 | } 28 | 29 | int Read_Line(Straw &straw, char *buffer, int length, BOOL &eof) 30 | { 31 | captainslog_assert(buffer != nullptr); 32 | captainslog_assert(length > 0); 33 | 34 | if (buffer && length > 0) { 35 | int i = 0; 36 | char c; 37 | 38 | while (true) { 39 | if (straw.Get(&c, sizeof(c)) != sizeof(c)) { 40 | eof = true; 41 | break; 42 | } 43 | 44 | if (c == '\n') { 45 | break; 46 | } 47 | 48 | if (c != '\r' && i + 1 < length) { 49 | buffer[i++] = c; 50 | } 51 | } 52 | 53 | // insert null char at the end of the line. 54 | buffer[i] = '\0'; 55 | 56 | // trim trailing white space. 57 | strtrim(buffer); 58 | 59 | // return the length of the line read. 60 | return strlen(buffer); 61 | } 62 | 63 | return 0; 64 | } 65 | -------------------------------------------------------------------------------- /src/game/common/readline.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author CCHyper 5 | * @author OmniBlade 6 | * 7 | * @brief Reads a line of text from a file or straw. 8 | * 9 | * @copyright Chronoshift is free software: you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation, either version 12 | * 2 of the License, or (at your option) any later version. 13 | * A full copy of the GNU General Public License can be found in 14 | * LICENSE 15 | */ 16 | #pragma once 17 | 18 | #ifndef READLINE_H 19 | #define READLINE_H 20 | 21 | #include "always.h" 22 | 23 | class FileClass; 24 | class Straw; 25 | 26 | int Read_Line(FileClass &file, char *buffer, int length, BOOL &eof); 27 | int Read_Line(Straw &straw, char *buffer, int length, BOOL &eof); 28 | 29 | #endif // READLINE_H 30 | -------------------------------------------------------------------------------- /src/game/common/remap.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author CCHyper 5 | * @author OmniBlade 6 | * 7 | * @brief Structure containing color info for remaps. 8 | * 9 | * @copyright Chronoshift is free software: you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation, either version 12 | * 2 of the License, or (at your option) any later version. 13 | * A full copy of the GNU General Public License can be found in 14 | * LICENSE 15 | */ 16 | #include "remap.h" 17 | 18 | #ifndef GAME_DLL 19 | RemapControlType g_ColorRemaps[REMAP_COUNT]; 20 | RemapControlType g_MetalScheme; 21 | RemapControlType g_GreyScheme; 22 | RemapControlType g_SidebarScheme; 23 | #endif 24 | -------------------------------------------------------------------------------- /src/game/common/tpoint.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author CCHyper 5 | * @author OmniBlade 6 | * 7 | * @brief Wrapper class for platform drawing engine. 8 | * 9 | * @copyright Chronoshift is free software: you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation, either version 12 | * 2 of the License, or (at your option) any later version. 13 | * A full copy of the GNU General Public License can be found in 14 | * LICENSE 15 | */ 16 | #pragma once 17 | 18 | #ifndef TPOINT_H 19 | #define TPOINT_H 20 | 21 | #include "always.h" 22 | 23 | template 24 | class TPoint2D 25 | { 26 | public: 27 | TPoint2D() {} 28 | TPoint2D(T x, T y) : x(x), y(y) {} 29 | TPoint2D(TPoint2D const &that) : x(that.x), y(that.y) {} 30 | 31 | TPoint2D &operator=(TPoint2D const &that) 32 | { 33 | if (this != &that) { 34 | x = that.x; 35 | y = that.y; 36 | } 37 | 38 | return *this; 39 | } 40 | 41 | bool operator==(TPoint2D const &that) const { return x == that.x && y == that.y; } 42 | bool operator!=(TPoint2D const &that) const { return x != that.x && y != that.y; } 43 | TPoint2D operator-(TPoint2D const &that) const { return TPoint2D(x - that.x, y - that.y); } 44 | TPoint2D operator+(TPoint2D const &that) const { return TPoint2D(x + that.x, y + that.y); } 45 | TPoint2D &operator-=(TPoint2D const &that) const { return TPoint2D(x - that.x, y - that.y); } 46 | TPoint2D &operator+=(TPoint2D const &that) const { return TPoint2D(x + that.x, y + that.y); } 47 | 48 | bool Is_Valid() const { return x > 0 || y > 0; } 49 | 50 | T x; 51 | T y; 52 | }; 53 | 54 | #endif // TPOINT_H 55 | -------------------------------------------------------------------------------- /src/game/common/ttimer.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author CCHyper 5 | * @author OmniBlade 6 | * 7 | * @brief Templated timers intended to tick on either the system timer or a frame. 8 | * 9 | * @copyright Chronoshift is free software: you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation, either version 12 | * 2 of the License, or (at your option) any later version. 13 | * A full copy of the GNU General Public License can be found in 14 | * LICENSE 15 | */ 16 | #include "ttimer.h" 17 | #include "globals.h" 18 | #include "ostimer.h" 19 | 20 | #ifndef GAME_DLL 21 | TTimerClass g_TickCountTimer; 22 | TCountDownTimerClass g_FrameTimer; 23 | #endif 24 | 25 | uint32_t SystemTimerClass::operator()() const 26 | { 27 | if (g_PlatformTimer != nullptr) { 28 | return g_PlatformTimer->Get_System_Tick_Count(); 29 | } 30 | 31 | return 0; 32 | } 33 | 34 | uint32_t FrameTimerClass::operator()() const 35 | { 36 | return g_GameFrame; 37 | } 38 | -------------------------------------------------------------------------------- /src/game/common/xordelta.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author OmniBlade 5 | * 6 | * @brief Implementation of XORDelta, a custom binary diff format used in many Westwood games. 7 | * 8 | * @copyright Chronoshift is free software: you can redistribute it and/or 9 | * modify it under the terms of the GNU General Public License 10 | * as published by the Free Software Foundation, either version 11 | * 2 of the License, or (at your option) any later version. 12 | * A full copy of the GNU General Public License can be found in 13 | * LICENSE 14 | */ 15 | #pragma once 16 | 17 | #ifndef XORDELTA_H 18 | #define XORDELTA_H 19 | 20 | #include "always.h" 21 | 22 | /** 23 | * @brief Get the worst case for XORDelta encoding given the starting size. 24 | */ 25 | inline int XOR_Worst_Case(int bytes) 26 | { 27 | return bytes + ((bytes / 63) * 3) + 4; 28 | } 29 | 30 | void __cdecl Apply_XOR_Delta(void *dst, void *src); 31 | void __cdecl Apply_XOR_Delta_To_Page_Or_Viewport(void *offset, void *delta, int width, int pitch, BOOL copy); 32 | int Generate_XOR_Delta(void *dst, void *src, void *base, int size); 33 | 34 | #endif // XORDELTA_H 35 | -------------------------------------------------------------------------------- /src/game/crypto/blowfish.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author CCHyper 5 | * @author OmniBlade 6 | * @author tomsons26 7 | * 8 | * @brief Blowfish encryption engine. 9 | * 10 | * @copyright Chronoshift is free software: you can redistribute it and/or 11 | * modify it under the terms of the GNU General Public License 12 | * as published by the Free Software Foundation, either version 13 | * 2 of the License, or (at your option) any later version. 14 | * A full copy of the GNU General Public License can be found in 15 | * LICENSE 16 | */ 17 | #ifndef BLOWFISH_H 18 | #define BLOWFISH_H 19 | 20 | #include "always.h" 21 | 22 | #define BF_BLOCKSIZE 8 // Size of encryption block. 23 | #define BF_ROUNDS 16 24 | #define BF_DEF_KEY_LENGTH 16 25 | #define BF_MIN_KEY_LENGTH 4 26 | #define BF_MAX_KEY_LENGTH 56 // 448 bits, Maximum key length allowed. 27 | 28 | class BlowfishEngine 29 | { 30 | public: 31 | BlowfishEngine(); 32 | BlowfishEngine(void *key, int length); 33 | ~BlowfishEngine(); 34 | 35 | void Submit_Key(void *key, int length); 36 | int Encrypt(void *plaintext, int length, void *cyphertext); 37 | int Decrypt(void *cyphertext, int length, void *plaintext); 38 | 39 | private: 40 | void Process_Block(void *input, void *output, uint32_t *pbox); 41 | void Sub_Key_Encrypt(uint32_t &input, uint32_t &output); 42 | int Process(bool encrypt, void *in_text, int length, void *out_text); 43 | 44 | #ifdef GAME_DLL 45 | friend void Setup_Hooks(); 46 | #endif 47 | 48 | private: 49 | BOOL m_HasKey; 50 | uint32_t m_PBoxEnc[BF_ROUNDS + 2]; 51 | uint32_t m_PBoxDec[BF_ROUNDS + 2]; 52 | uint32_t m_SBox[4][256]; 53 | }; 54 | 55 | #endif // BLOWFISH_H 56 | -------------------------------------------------------------------------------- /src/game/crypto/sha.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author CCHyper 5 | * @author OmniBlade 6 | * 7 | * @brief SHA1 Hashing engine. 8 | * 9 | * @copyright Chronoshift is free software: you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation, either version 12 | * 2 of the License, or (at your option) any later version. 13 | * A full copy of the GNU General Public License can be found in 14 | * LICENSE 15 | */ 16 | #pragma once 17 | 18 | #ifndef SHA_H 19 | #define SHA_H 20 | 21 | #include "always.h" 22 | 23 | #define SHA_DIGEST_LENGTH 20 24 | #define SHA_BLOCK_LENGTH 64 25 | 26 | class SHAEngine 27 | { 28 | public: 29 | struct SHADigest 30 | { 31 | uint32_t H0; 32 | uint32_t H1; 33 | uint32_t H2; 34 | uint32_t H3; 35 | uint32_t H4; 36 | }; 37 | 38 | SHAEngine(); 39 | ~SHAEngine(); 40 | 41 | void Hash(const void *input, int length); 42 | int Result(void *output); 43 | int Print_Result(char *output); 44 | 45 | private: 46 | void Process_Partial(const void *&data, int &length); 47 | void Process_Block(const void *data, SHADigest &digest) const; 48 | void Print(const void *buffer, char *stringbuff); 49 | 50 | private: 51 | BOOL m_computed; 52 | SHADigest m_finalDigest; 53 | SHADigest m_digest; 54 | uint32_t m_processedBytes; 55 | uint32_t m_unprocessedBytes; 56 | char m_messageBlock[SHA_BLOCK_LENGTH]; // this is also knows as 'bytes' in other implimentions 57 | }; 58 | 59 | #endif // SHA_H 60 | -------------------------------------------------------------------------------- /src/game/engine/abstracttype.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author CCHyper 5 | * @author OmniBlade 6 | * 7 | * @brief Base class for most in game type objects. 8 | * 9 | * @copyright Chronoshift is free software: you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation, either version 12 | * 2 of the License, or (at your option) any later version. 13 | * A full copy of the GNU General Public License can be found in 14 | * LICENSE 15 | */ 16 | #include "abstracttype.h" 17 | 18 | AbstractTypeClass::AbstractTypeClass(RTTIType type, int heap_id, int ui_name, const char *name) : 19 | m_RTTI(type), 20 | m_HeapID(heap_id), 21 | m_UIName(ui_name) 22 | { 23 | strlcpy(m_Name, name, sizeof(m_Name)); 24 | } 25 | 26 | AbstractTypeClass::AbstractTypeClass(const AbstractTypeClass &that) : 27 | m_RTTI(that.m_RTTI), 28 | m_HeapID(that.m_HeapID), 29 | m_UIName(that.m_UIName) 30 | { 31 | strlcpy(m_Name, that.m_Name, sizeof(m_Name)); 32 | } 33 | 34 | int AbstractTypeClass::Full_Name() const 35 | { 36 | for (int i = 0; i < 25; ++i) { 37 | if (100 * (m_RTTI + 1) + m_HeapID == g_NameIDOverride[i]) { 38 | return -(i + 1); 39 | } 40 | } 41 | 42 | return m_UIName; 43 | } -------------------------------------------------------------------------------- /src/game/engine/action.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author CCHyper 5 | * @author OmniBlade 6 | * 7 | * @brief Functions for using the action enum. 8 | * 9 | * @copyright Chronoshift is free software: you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation, either version 12 | * 2 of the License, or (at your option) any later version. 13 | * A full copy of the GNU General Public License can be found in 14 | * LICENSE 15 | */ 16 | #pragma once 17 | 18 | #ifndef ACTION_H 19 | #define ACTION_H 20 | 21 | #include "always.h" 22 | 23 | enum ActionType 24 | { 25 | ACTION_NONE, 26 | ACTION_MOVE, 27 | ACTION_NO_MOVE, 28 | ACTION_ENTER, 29 | ACTION_SELF, 30 | ACTION_ATTACK, 31 | ACTION_HARVEST, 32 | ACTION_SELECT, 33 | ACTION_TOGGLE_SELECT, 34 | ACTION_CAPTURE, 35 | ACTION_REPAIR, 36 | ACTION_SELL, 37 | ACTION_SELL_UNIT, 38 | ACTION_NO_SELL, 39 | ACTION_NO_REPAIR, 40 | ACTION_SABOTAGE, 41 | ACTION_PARA_BOMB, 42 | ACTION_PARA_SABOTEUR, 43 | ACTION_ION_CANNON, 44 | ACTION_NUKE, 45 | ACTION_AIR_STRIKE, 46 | ACTION_CHRONOSPHERE, //WarpIn 47 | ACTION_CHRONOWARP, //WarpOut 48 | ACTION_IRON_CURTAIN, 49 | ACTION_SPY_MISSION, 50 | ACTION_GUARD_AREA, 51 | ACTION_HEAL, 52 | ACTION_DAMAGE, 53 | ACTION_GREPAIR, 54 | ACTION_NO_DEPLOY, 55 | ACTION_NO_ENTER, 56 | ACTION_NO_GREPAIR, 57 | ACTION_COUNT, 58 | }; 59 | 60 | DEFINE_ENUMERATION_OPERATORS(ActionType); 61 | 62 | ActionType Action_From_Name(const char *name); 63 | const char *Name_From_Action(ActionType action); 64 | 65 | #endif // _TEMPLATE_HH_ 66 | -------------------------------------------------------------------------------- /src/game/engine/aircraftdata.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author CCHyper 5 | * @author OmniBlade 6 | * 7 | * @brief Static instances of aircraft type objects. 8 | * 9 | * @copyright Chronoshift is free software: you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation, either version 12 | * 2 of the License, or (at your option) any later version. 13 | * A full copy of the GNU General Public License can be found in 14 | * LICENSE 15 | */ 16 | #pragma once 17 | 18 | #ifndef AIRCRAFTDATA_H 19 | #define AIRCRAFTDATA_H 20 | 21 | #include "always.h" 22 | #include "aircrafttype.h" 23 | 24 | extern const AircraftTypeClass AircraftBadgerPlane; 25 | extern const AircraftTypeClass AircraftU2Plane; 26 | extern const AircraftTypeClass AircraftMigPlane; 27 | extern const AircraftTypeClass AircraftYakPlane; 28 | extern const AircraftTypeClass AircraftTransportHeli; 29 | extern const AircraftTypeClass AircraftAttackHeli; 30 | extern const AircraftTypeClass AircraftHindHeli; 31 | 32 | #endif // AIRCRAFTDATA_H 33 | -------------------------------------------------------------------------------- /src/game/engine/armor.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author CCHyper 5 | * @author OmniBlade 6 | * 7 | * @brief Armor enum and functions. 8 | * 9 | * @copyright Chronoshift is free software: you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation, either version 12 | * 2 of the License, or (at your option) any later version. 13 | * A full copy of the GNU General Public License can be found in 14 | * LICENSE 15 | */ 16 | #include "armor.h" 17 | #include 18 | 19 | #ifdef HAVE_STRINGS_H 20 | #include 21 | #endif 22 | 23 | const char *ArmorName[ARMOR_COUNT] = { 24 | "none", 25 | "wood", 26 | "light", 27 | "heavy", 28 | "concrete" 29 | }; 30 | 31 | ArmorType Armor_From_Name(const char *name) 32 | { 33 | if (name != nullptr) { 34 | for (ArmorType armor = ARMOR_NONE; armor < ARMOR_COUNT; ++armor) { 35 | if (strcasecmp(name, ArmorName[armor]) == 0) { 36 | return armor; 37 | } 38 | } 39 | } 40 | 41 | return ARMOR_NONE; 42 | } 43 | 44 | const char *Name_From_Armor(ArmorType armor) 45 | { 46 | if (armor >= ARMOR_NONE && armor < ARMOR_COUNT) { 47 | return ArmorName[armor]; 48 | } 49 | 50 | return "none"; 51 | } 52 | -------------------------------------------------------------------------------- /src/game/engine/armor.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author CCHyper 5 | * @author OmniBlade 6 | * 7 | * @brief Armor enum and functions. 8 | * 9 | * @copyright Chronoshift is free software: you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation, either version 12 | * 2 of the License, or (at your option) any later version. 13 | * A full copy of the GNU General Public License can be found in 14 | * LICENSE 15 | */ 16 | #pragma once 17 | 18 | #ifndef ARMOR_H 19 | #define ARMOR_H 20 | 21 | #include "always.h" 22 | 23 | enum ArmorType 24 | { 25 | ARMOR_NONE, 26 | ARMOR_WOOD, 27 | ARMOR_LIGHT, 28 | ARMOR_HEAVY, 29 | ARMOR_CONCRETE, 30 | 31 | ARMOR_COUNT, 32 | 33 | ARMOR_INVALID = -1, 34 | ARMOR_FIRST = ARMOR_NONE, 35 | }; 36 | 37 | DEFINE_ENUMERATION_OPERATORS(ArmorType); 38 | 39 | ArmorType Armor_From_Name(const char *name); 40 | const char *Name_From_Armor(ArmorType armor); 41 | 42 | #endif // ARMOR_H 43 | -------------------------------------------------------------------------------- /src/game/engine/attract.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author OmniBlade 5 | * @author CCHyper 6 | * 7 | * @brief Functions for handling the "attract" demo mode. 8 | * 9 | * @copyright Chronoshift is free software: you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation, either version 12 | * 2 of the License, or (at your option) any later version. 13 | * A full copy of the GNU General Public License can be found in 14 | * LICENSE 15 | */ 16 | #pragma once 17 | 18 | #ifndef ATTRACT_H 19 | #define ATTRACT_H 20 | 21 | #include "always.h" 22 | 23 | class GameFileClass; 24 | 25 | void Do_Record_Playback(); 26 | BOOL Save_Recording_Values(GameFileClass &file); 27 | BOOL Load_Recording_Values(GameFileClass &file); 28 | 29 | #endif // ATTRACT_H 30 | -------------------------------------------------------------------------------- /src/game/engine/bulletdata.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author CCHyper 5 | * @author OmniBlade 6 | * 7 | * @brief Static instances of bullet type objects. 8 | * 9 | * @copyright Chronoshift is free software: you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation, either version 12 | * 2 of the License, or (at your option) any later version. 13 | * A full copy of the GNU General Public License can be found in 14 | * LICENSE 15 | */ 16 | #pragma once 17 | 18 | #ifndef BULLETDATA_H 19 | #define BULLETDATA_H 20 | 21 | #include "always.h" 22 | #include "bullettype.h" 23 | 24 | extern const BulletTypeClass BulletInvisible; 25 | extern const BulletTypeClass BulletCannon; 26 | extern const BulletTypeClass BulletAck; 27 | extern const BulletTypeClass BulletTorpedo; 28 | extern const BulletTypeClass BulletFROG; 29 | extern const BulletTypeClass BulletHeatSeeker; 30 | extern const BulletTypeClass BulletLaserGuided; 31 | extern const BulletTypeClass BulletLobbed; 32 | extern const BulletTypeClass BulletBomblet; 33 | extern const BulletTypeClass BulletBallistic; 34 | extern const BulletTypeClass BulletParachute; 35 | extern const BulletTypeClass BulletFireball; 36 | extern const BulletTypeClass BulletLeapDog; 37 | extern const BulletTypeClass BulletCatapult; 38 | extern const BulletTypeClass BulletAAMissile; 39 | extern const BulletTypeClass BulletGPSSatellite; 40 | extern const BulletTypeClass BulletNukeUp; 41 | extern const BulletTypeClass BulletNukeDown; 42 | 43 | #endif // BULLETDATA_H 44 | -------------------------------------------------------------------------------- /src/game/engine/callback.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author OmniBlade 5 | * 6 | * @brief Callback handler to do per loop callback processing. 7 | * 8 | * @copyright Chronoshift is free software: you can redistribute it and/or 9 | * modify it under the terms of the GNU General Public License 10 | * as published by the Free Software Foundation, either version 11 | * 2 of the License, or (at your option) any later version. 12 | * A full copy of the GNU General Public License can be found in 13 | * LICENSE 14 | */ 15 | #include "callback.h" 16 | #include "theme.h" 17 | #include "vox.h" 18 | #include "session.h" 19 | #include "globals.h" 20 | 21 | void IPX_Call_Back() 22 | { 23 | #ifdef GAME_DLL 24 | void (*func)() = reinterpret_cast(0x004A7800); 25 | func(); 26 | #endif 27 | } 28 | 29 | void Call_Back() 30 | { 31 | g_Theme.AI(); 32 | Speak_AI(); 33 | 34 | if (g_InMapEditor) { 35 | return; 36 | } 37 | 38 | if (g_Session.Game_To_Play() == GAME_LAN || g_Session.Game_To_Play() == GAME_INTERNET) { 39 | IPX_Call_Back(); 40 | } 41 | 42 | if ((g_Session.Game_To_Play() == GAME_MODEM || g_Session.Game_To_Play() == GAME_NULL_MODEM) && g_Session.Modem_Service()) { 43 | // NullModem.Service(); 44 | } 45 | 46 | /*if (g_pWolapi != nullptr) { 47 | // We won't be supporting WolAPI. 48 | }*/ 49 | } 50 | -------------------------------------------------------------------------------- /src/game/engine/callback.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author OmniBlade 5 | * 6 | * @brief Callback handler to do per loop callback processing. 7 | * 8 | * @copyright Chronoshift is free software: you can redistribute it and/or 9 | * modify it under the terms of the GNU General Public License 10 | * as published by the Free Software Foundation, either version 11 | * 2 of the License, or (at your option) any later version. 12 | * A full copy of the GNU General Public License can be found in 13 | * LICENSE 14 | */ 15 | #pragma once 16 | 17 | #ifndef CALLBACK_H 18 | #define CALLBACK_H 19 | 20 | class PaletteClass; 21 | 22 | void Call_Back(); 23 | void Call_Back_Delay(int a1); 24 | void Cycle_Call_Back_Delay(int a1, PaletteClass &pal); 25 | void IPX_Call_Back(); 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /src/game/engine/cargo.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author CCHyper 5 | * @author OmniBlade 6 | * 7 | * @brief Handles tracking units currently stored as cargo. 8 | * 9 | * @copyright Chronoshift is free software: you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation, either version 12 | * 2 of the License, or (at your option) any later version. 13 | * A full copy of the GNU General Public License can be found in 14 | * LICENSE 15 | */ 16 | #pragma once 17 | 18 | #ifndef CARGO_H 19 | #define CARGO_H 20 | 21 | #include "always.h" 22 | 23 | class NoInitClass; 24 | class FootClass; 25 | 26 | class CargoClass 27 | { 28 | public: 29 | CargoClass() : m_Count(0), m_Object(nullptr) {} 30 | CargoClass(const NoInitClass &noinit) {} 31 | ~CargoClass() { m_Object = nullptr; } 32 | 33 | void AI() {} 34 | void Attach(FootClass *object); 35 | FootClass *Attached_Object() const; 36 | FootClass *Detach_Object(); 37 | void Code_Pointers(); 38 | void Decode_Pointers(); 39 | int Cargo_Count() const { return m_Count; } 40 | BOOL Has_Cargo() const { return m_Object != nullptr; } 41 | 42 | private: 43 | uint8_t m_Count; 44 | FootClass *m_Object; 45 | }; 46 | 47 | #endif // CARGO_H 48 | -------------------------------------------------------------------------------- /src/game/engine/carryover.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author tomsons26 5 | * 6 | * @brief 7 | * 8 | * @copyright Chronoshift is free software: you can redistribute it and/or 9 | * modify it under the terms of the GNU General Public License 10 | * as published by the Free Software Foundation, either version 11 | * 2 of the License, or (at your option) any later version. 12 | * A full copy of the GNU General Public License can be found in 13 | * LICENSE 14 | */ 15 | 16 | #pragma once 17 | 18 | #ifndef CARRYOVER_H 19 | #define CARRYOVER_H 20 | 21 | #include "always.h" 22 | #include "link.h" 23 | #include "house.h" 24 | 25 | class TechnoClass; 26 | 27 | class CarryoverClass : public LinkClass 28 | { 29 | public: 30 | CarryoverClass(TechnoClass *techno); 31 | ~CarryoverClass() {} 32 | 33 | BOOL Create(); 34 | 35 | #ifdef GAME_DLL 36 | public: 37 | CarryoverClass *Hook_Ctor(TechnoClass *techno) { return new(this)CarryoverClass(techno); } 38 | #endif 39 | 40 | private: 41 | RTTIType m_RTTI; 42 | uint8_t m_Type; 43 | cell_t m_Cell; 44 | int16_t m_Health; 45 | HousesType m_Owner; 46 | }; 47 | 48 | #ifdef GAME_DLL 49 | extern CarryoverClass *&g_Carryover; 50 | #else 51 | extern CarryoverClass *g_Carryover; 52 | #endif 53 | 54 | #endif // CARRYOVER_H 55 | -------------------------------------------------------------------------------- /src/game/engine/cmdline.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author CCHyper 5 | * @author OmniBlade 6 | * 7 | * @brief Command line parser. 8 | * 9 | * @copyright Chronoshift is free software: you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation, either version 12 | * 2 of the License, or (at your option) any later version. 13 | * A full copy of the GNU General Public License can be found in 14 | * LICENSE 15 | */ 16 | #pragma once 17 | 18 | #ifndef CMDLINE_H 19 | #define CMDLINE_H 20 | 21 | #include "always.h" 22 | 23 | BOOL Parse_Command_Line(int argc, char **argv); 24 | 25 | #endif // CMDLINE_H 26 | -------------------------------------------------------------------------------- /src/game/engine/combat.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author tomsons26 5 | * 6 | * @brief 7 | * 8 | * @copyright Chronoshift is free software: you can redistribute it and/or 9 | * modify it under the terms of the GNU General Public License 10 | * as published by the Free Software Foundation, either version 11 | * 2 of the License, or (at your option) any later version. 12 | * A full copy of the GNU General Public License can be found in 13 | * LICENSE 14 | */ 15 | #include "combat.h" 16 | #ifdef GAME_DLL 17 | #include "hooker.h" 18 | #endif 19 | 20 | int Modify_Damage(int damage, WarheadType warhead, ArmorType armor, int distance) 21 | { 22 | #ifdef GAME_DLL 23 | DEFINE_CALL(func, 0x004A31F0, int, int, WarheadType, ArmorType, int); 24 | return func(damage, warhead, armor, distance); 25 | #else 26 | return 0; 27 | #endif 28 | } 29 | 30 | void Explosion_Damage(coord_t coord, int intval, TechnoClass *object, WarheadType warhead) 31 | { 32 | #ifdef GAME_DLL 33 | DEFINE_CALL(func, 0x004A32D8, void, coord_t, int, TechnoClass *, WarheadType); 34 | func(coord, intval, object, warhead); 35 | #endif 36 | } 37 | 38 | AnimType Combat_Anim(int damage, WarheadType warhead, LandType land) 39 | { 40 | #ifdef GAME_DLL 41 | DEFINE_CALL(func, 0x004A35D4, AnimType, int, WarheadType, LandType); 42 | return func(damage, warhead, land); 43 | #else 44 | return AnimType(); 45 | #endif 46 | } 47 | 48 | void Wide_Area_Damage(coord_t coord, uint16_t radius, int damage, TechnoClass *object, WarheadType warhead) 49 | { 50 | #ifdef GAME_DLL 51 | DEFINE_CALL(func, 0x004A37D4, void, coord_t, uint16_t, int, TechnoClass *, WarheadType); 52 | func(coord, radius, damage, object, warhead); 53 | #endif 54 | } 55 | 56 | void Shake_The_Screen(int shakes) 57 | { 58 | #ifdef GAME_DLL 59 | DEFINE_CALL(func, 0x004AB678, void, int); 60 | func(shakes); 61 | #endif 62 | } 63 | -------------------------------------------------------------------------------- /src/game/engine/combat.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author tomsons26 5 | * 6 | * @brief 7 | * 8 | * @copyright Chronoshift is free software: you can redistribute it and/or 9 | * modify it under the terms of the GNU General Public License 10 | * as published by the Free Software Foundation, either version 11 | * 2 of the License, or (at your option) any later version. 12 | * A full copy of the GNU General Public License can be found in 13 | * LICENSE 14 | */ 15 | #pragma once 16 | 17 | #ifndef COMBAT_H 18 | #define COMBAT_H 19 | 20 | #include "always.h" 21 | #include "armor.h" 22 | #include "gametypes.h" 23 | #include "land.h" 24 | #include "warheadtype.h" 25 | 26 | class TechnoClass; 27 | 28 | int Modify_Damage(int damage, WarheadType warhead, ArmorType armor, int distance); 29 | void Explosion_Damage(coord_t coord, int intval, TechnoClass *object, WarheadType warhead); 30 | AnimType Combat_Anim(int damage, WarheadType warhead, LandType land); 31 | void Wide_Area_Damage(coord_t coord, uint16_t radius, int damage, TechnoClass *object, WarheadType warhead); 32 | 33 | void Shake_The_Screen(int shakes); 34 | 35 | #endif //COMBAT_H 36 | -------------------------------------------------------------------------------- /src/game/engine/crew.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author tomsons26 5 | * 6 | * @brief Possibly meant to handle experience, veterancy, and kill count tracking. 7 | * 8 | * @copyright Chronoshift is free software: you can redistribute it and/or 9 | * modify it under the terms of the GNU General Public License 10 | * as published by the Free Software Foundation, either version 11 | * 2 of the License, or (at your option) any later version. 12 | * A full copy of the GNU General Public License can be found in 13 | * LICENSE 14 | */ 15 | 16 | #pragma once 17 | 18 | #ifndef CREW_H 19 | #define CREW_H 20 | 21 | #include "noinit.h" 22 | 23 | class CrewClass 24 | { 25 | public: 26 | CrewClass() : m_Kills(0) {} 27 | CrewClass(const NoInitClass &init) {} 28 | ~CrewClass() {} 29 | 30 | unsigned short Register_Kill() { return ++m_Kills; } 31 | 32 | private: 33 | unsigned short m_Kills; 34 | }; 35 | 36 | #endif // CREW_H 37 | -------------------------------------------------------------------------------- /src/game/engine/egos.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author tomsons26 5 | * 6 | * @brief Class and set of functions that handle and draw developer credits. 7 | * 8 | * @copyright Chronoshift is free software: you can redistribute it and/or 9 | * modify it under the terms of the GNU General Public License 10 | * as published by the Free Software Foundation, either version 11 | * 2 of the License, or (at your option) any later version. 12 | * A full copy of the GNU General Public License can be found in 13 | * LICENSE 14 | */ 15 | #pragma once 16 | 17 | #ifndef EGOS_H 18 | #define EGOS_H 19 | #include "always.h" 20 | #include "dialog.h" 21 | #include "vector.h" 22 | 23 | #ifdef GAME_DLL 24 | #include "hooker.h" 25 | #endif 26 | 27 | class GraphicBufferClass; 28 | 29 | class EgoClass 30 | { 31 | public: 32 | EgoClass(int xpos, int ypos, char *string, TextPrintType style); 33 | ~EgoClass(); 34 | 35 | BOOL Scroll(int amount); 36 | void Render(); 37 | void Wipe(GraphicBufferClass *buffer); 38 | 39 | private: 40 | char *m_String; 41 | int m_XPos; 42 | int m_YPos; 43 | TextPrintType m_TextStyle; 44 | }; 45 | 46 | #ifdef GAME_DLL 47 | extern DynamicVectorClass &g_EgoList; 48 | #else 49 | extern DynamicVectorClass g_EgoList; 50 | #endif 51 | 52 | void Slide_Show(int slide, int value); 53 | void Show_Who_Was_Responsible(); 54 | 55 | #endif //EGOS_H 56 | -------------------------------------------------------------------------------- /src/game/engine/expansion.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author CCHyper 5 | * @author OmniBlade 6 | * 7 | * @brief Functions for handling things relating to expansion packs. 8 | * 9 | * @copyright Chronoshift is free software: you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation, either version 12 | * 2 of the License, or (at your option) any later version. 13 | * A full copy of the GNU General Public License can be found in 14 | * LICENSE 15 | */ 16 | #pragma once 17 | 18 | #ifndef EXPANSION_H 19 | #define EXPANSION_H 20 | 21 | #include "always.h" 22 | 23 | enum ExpansionType 24 | { 25 | EXPANSION_NONE = -1, 26 | EXPANSION_AFTERMATH, 27 | EXPANSION_COUNTERSTRIKE, 28 | EXPANSION_COUNT, 29 | }; 30 | 31 | BOOL Is_Counterstrike_Installed(); 32 | BOOL Is_Aftermath_Installed(); 33 | 34 | #endif // EXPANSION_H 35 | -------------------------------------------------------------------------------- /src/game/engine/fetchtechtype.cpp: -------------------------------------------------------------------------------- 1 | #include "aircrafttype.h" 2 | #include "buildingtype.h" 3 | #include "infantrytype.h" 4 | #include "technotype.h" 5 | #include "unittype.h" 6 | #include "vesseltype.h" 7 | 8 | TechnoTypeClass *Fetch_Techno_Type(RTTIType type, int id) 9 | { 10 | switch (type) { 11 | case RTTI_AIRCRAFTTYPE: 12 | return AircraftTypeClass::As_Pointer(AircraftType(id)); 13 | case RTTI_INFANTRYTYPE: 14 | return InfantryTypeClass::As_Pointer(InfantryType(id)); 15 | case RTTI_UNITTYPE: 16 | return UnitTypeClass::As_Pointer(UnitType(id)); 17 | case RTTI_VESSELTYPE: 18 | return VesselTypeClass::As_Pointer(VesselType(id)); 19 | case RTTI_BUILDINGTYPE: 20 | return BuildingTypeClass::As_Pointer(BuildingType(id)); 21 | default: 22 | return nullptr; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/game/engine/fetchtechtype.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author tomsons26 5 | * 6 | * @brief 7 | * 8 | * @copyright Chronoshift is free software: you can redistribute it and/or 9 | * modify it under the terms of the GNU General Public License 10 | * as published by the Free Software Foundation, either version 11 | * 2 of the License, or (at your option) any later version. 12 | * A full copy of the GNU General Public License can be found in 13 | * LICENSE 14 | */ 15 | 16 | #pragma once 17 | 18 | #ifndef FETCHTECHTYPE_H 19 | #define FETCHTECHTYPE_H 20 | 21 | #include "always.h" 22 | #include "rtti.h" 23 | 24 | class TechnoTypeClass; 25 | 26 | TechnoTypeClass *Fetch_Techno_Type(RTTIType type, int id); 27 | 28 | #endif // FETCHTECHTYPE_H 29 | -------------------------------------------------------------------------------- /src/game/engine/flasher.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author OmniBlade 5 | * @author CCHyper 6 | * 7 | * @brief Handles the processing for a flashing object. 8 | * 9 | * @copyright Chronoshift is free software: you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation, either version 12 | * 2 of the License, or (at your option) any later version. 13 | * A full copy of the GNU General Public License can be found in 14 | * LICENSE 15 | */ 16 | #include "flasher.h" 17 | 18 | /** 19 | * @brief Processes the flash logic and returns true if the flasher is currently active. 20 | */ 21 | BOOL FlasherClass::Process() 22 | { 23 | if (m_Frames > 0) { 24 | --m_Frames; 25 | m_Flashed = false; 26 | 27 | // Check if we are on an odd frame and if so, set the status to flashed. 28 | if ((unsigned)m_Frames % 2) { 29 | m_Flashed = true; 30 | } 31 | 32 | return true; 33 | } 34 | 35 | return false; 36 | } 37 | -------------------------------------------------------------------------------- /src/game/engine/flasher.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author OmniBlade 5 | * @author CCHyper 6 | * 7 | * @brief Handles the processing for a flashing object. 8 | * 9 | * @copyright Chronoshift is free software: you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation, either version 12 | * 2 of the License, or (at your option) any later version. 13 | * A full copy of the GNU General Public License can be found in 14 | * LICENSE 15 | */ 16 | #pragma once 17 | 18 | #ifndef FLASHER_H 19 | #define FLASHER_H 20 | 21 | #include "always.h" 22 | 23 | class NoInitClass; 24 | 25 | class FlasherClass 26 | { 27 | public: 28 | FlasherClass() : m_Frames(0), m_Flashed(false) {} 29 | FlasherClass(const FlasherClass &that) : m_Frames(that.m_Frames), m_Flashed(that.m_Flashed) {} 30 | FlasherClass(const NoInitClass &noinit) {} 31 | 32 | void Flash(int flash_frames, bool flash); 33 | BOOL Get_Flashed() const { return m_Flashed; } 34 | BOOL Process(); 35 | void Code_Pointers() {} 36 | void Decode_Pointers() {} 37 | 38 | private: 39 | #ifndef CHRONOSHIFT_NO_BITFIELDS 40 | unsigned int m_Frames : 7; 41 | BOOL m_Flashed : 1; 42 | #else 43 | unsigned int m_Frames; // Number of frames to flash for. 44 | bool m_Flashed; // Is current frame a flash frame? 45 | #endif 46 | }; 47 | 48 | inline void FlasherClass::Flash(int flash_frames, bool flash) 49 | { 50 | m_Frames = flash_frames; 51 | m_Flashed = flash; 52 | } 53 | 54 | #endif // FLASHER_H 55 | -------------------------------------------------------------------------------- /src/game/engine/fly.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author tomsons26 5 | * 6 | * @brief 7 | * 8 | * @copyright Chronoshift is free software: you can redistribute it and/or 9 | * modify it under the terms of the GNU General Public License 10 | * as published by the Free Software Foundation, either version 11 | * 2 of the License, or (at your option) any later version. 12 | * A full copy of the GNU General Public License can be found in 13 | * LICENSE 14 | */ 15 | #include "fly.h" 16 | #include "coord.h" 17 | #include "fixed.h" 18 | 19 | /** 20 | * 21 | * 22 | */ 23 | ImpactType FlyClass::Physics(coord_t &coord, DirType dir) 24 | { 25 | if (m_Speed != MPH_MIN) { 26 | int numer = m_Speed + m_field_0; 27 | div_t divval = div(numer, 10); 28 | m_field_0 = divval.rem; 29 | numer -= divval.rem; 30 | coord_t org_coord = coord; 31 | if (divval.quot != 0) { 32 | //speed check above changes on 0xffff :/ 33 | coord_t moved_coord = Coord_Move(coord, dir, numer & 0xffff); 34 | if (moved_coord == coord) { 35 | return IMPACT_0; 36 | } 37 | coord = moved_coord; 38 | if (moved_coord & 0x80008000) { 39 | coord = org_coord; 40 | return IMPACT_2; 41 | } 42 | return IMPACT_1; 43 | } 44 | } 45 | return IMPACT_0; 46 | } 47 | 48 | /** 49 | * 50 | * 51 | */ 52 | void FlyClass::Fly_Speed(int speed, MPHType mph) 53 | { 54 | m_Speed = mph * fixed_t(speed, 256); 55 | } 56 | -------------------------------------------------------------------------------- /src/game/engine/fly.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author tomsons26 5 | * 6 | * @brief 7 | * 8 | * @copyright Chronoshift is free software: you can redistribute it and/or 9 | * modify it under the terms of the GNU General Public License 10 | * as published by the Free Software Foundation, either version 11 | * 2 of the License, or (at your option) any later version. 12 | * A full copy of the GNU General Public License can be found in 13 | * LICENSE 14 | */ 15 | #pragma once 16 | 17 | #ifndef FLY_H 18 | #define FLY_H 19 | 20 | #include "always.h" 21 | #include "facing.h" 22 | #include "gametypes.h" 23 | 24 | class NoInitClass; 25 | 26 | enum ImpactType 27 | { 28 | IMPACT_NONE = -1, 29 | 30 | IMPACT_0 = 0, // hit? 31 | IMPACT_1 = 1, // missed? 32 | IMPACT_2 = 2, // nullified? 33 | 34 | IMPACT_COUNT = 3 35 | }; 36 | 37 | class FlyClass 38 | { 39 | public: 40 | FlyClass() : m_field_0(0), m_Speed(0) {} 41 | FlyClass(const NoInitClass &noinit) {} 42 | 43 | ImpactType Physics(coord_t &coord, DirType dir); 44 | void Fly_Speed(int speed, MPHType mph); 45 | 46 | uint8_t Get_Speed() const { return m_Speed; } 47 | 48 | void Code_Pointers(){} 49 | void Decode_Pointers(){} 50 | 51 | private: 52 | int m_field_0; 53 | uint8_t m_Speed; 54 | }; 55 | 56 | #endif // FLY_H 57 | -------------------------------------------------------------------------------- /src/game/engine/focus.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author OmniBlade 5 | * 6 | * @brief Focus change handling functions. 7 | * 8 | * @copyright Chronoshift is free software: you can redistribute it and/or 9 | * modify it under the terms of the GNU General Public License 10 | * as published by the Free Software Foundation, either version 11 | * 2 of the License, or (at your option) any later version. 12 | * A full copy of the GNU General Public License can be found in 13 | * LICENSE 14 | */ 15 | #include "focus.h" 16 | #include "audio.h" 17 | #include "gbuffer.h" 18 | #include "iomap.h" 19 | #include "mouse.h" 20 | #include "theme.h" 21 | 22 | /** 23 | * Handler for loss of application focus. 24 | * 25 | * 0x005B3488 26 | */ 27 | void Focus_Loss() 28 | { 29 | g_Theme.Suspend(); 30 | Stop_Primary_Sound_Buffer(); 31 | 32 | if (g_Mouse != nullptr) { 33 | g_Mouse->Clear_Cursor_Clip(); 34 | } 35 | } 36 | 37 | /** 38 | * Handler for gain of application focus. 39 | * 40 | * 0x005B34B4 41 | */ 42 | void Focus_Restore() 43 | { 44 | g_Map.Flag_To_Redraw(true); 45 | Start_Primary_Sound_Buffer(true); 46 | 47 | if (g_Mouse != nullptr) { 48 | g_Mouse->Set_Cursor_Clip(); 49 | } 50 | 51 | g_VisiblePage.Clear(); 52 | g_HiddenPage.Clear(); 53 | } 54 | -------------------------------------------------------------------------------- /src/game/engine/focus.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author OmniBlade 5 | * 6 | * @brief Focus change handling functions. 7 | * 8 | * @copyright Chronoshift is free software: you can redistribute it and/or 9 | * modify it under the terms of the GNU General Public License 10 | * as published by the Free Software Foundation, either version 11 | * 2 of the License, or (at your option) any later version. 12 | * A full copy of the GNU General Public License can be found in 13 | * LICENSE 14 | */ 15 | #pragma once 16 | 17 | #ifndef FOCUS_H 18 | #define FOCUS_H 19 | 20 | #include "always.h" 21 | 22 | void Focus_Loss(); 23 | void Focus_Restore(); 24 | 25 | #endif // FOCUS_H 26 | -------------------------------------------------------------------------------- /src/game/engine/fuse.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author OmniBlade 5 | * @author CCHyper 6 | * @author tomsons26 7 | * 8 | * @brief Class providing a fuse function for weapons that need some time to arm. 9 | * 10 | * @copyright Chronoshift is free software: you can redistribute it and/or 11 | * modify it under the terms of the GNU General Public License 12 | * as published by the Free Software Foundation, either version 13 | * 2 of the License, or (at your option) any later version. 14 | * A full copy of the GNU General Public License can be found in 15 | * LICENSE 16 | */ 17 | #pragma once 18 | 19 | #ifndef FUSE_H 20 | #define FUSE_H 21 | 22 | #include "always.h" 23 | #include "gametypes.h" 24 | 25 | // forward decs 26 | class NoInitClass; 27 | class FileClass; 28 | 29 | enum FuseResultType 30 | { 31 | FUSE_WAIT = 0, 32 | FUSE_EXPLODE = 1, 33 | FUSE_2 = 2, 34 | }; 35 | 36 | class FuseClass 37 | { 38 | public: 39 | FuseClass() : m_Duration(0), m_ArmDelay(0), m_Target(0), m_Proximity(0) {} 40 | FuseClass(const NoInitClass &noinit) {} 41 | 42 | void Arm_Fuse(coord_t pos, coord_t target, int duration, int arm_delay); 43 | FuseResultType Fuse_Checkup(coord_t pos); 44 | 45 | coord_t Get_Target() const { return m_Target; } 46 | 47 | void Code_Pointers() {} 48 | void Decode_Pointers() {} 49 | 50 | void Fuse_Write(FileClass &file); 51 | void Fuse_Read(FileClass &file); 52 | 53 | private: 54 | uint8_t m_Duration; // Total life span of the fuse. 55 | uint8_t m_ArmDelay; // Delay until fuse is armed. 56 | coord_t m_Target; // Position where the fuse should ignite. 57 | int16_t m_Proximity; // Last registered distance to target position. 58 | }; 59 | 60 | #endif // FUSE_H 61 | -------------------------------------------------------------------------------- /src/game/engine/gamekeyboard.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author CCHyper 5 | * @author OmniBlade 6 | * 7 | * @brief 8 | * 9 | * @copyright Chronoshift is free software: you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation, either version 12 | * 2 of the License, or (at your option) any later version. 13 | * A full copy of the GNU General Public License can be found in 14 | * LICENSE 15 | */ 16 | #pragma once 17 | 18 | #ifndef GAMEKEYBOARD_H 19 | #define GAMEKEYBOARD_H 20 | 21 | #include "always.h" 22 | #include "keyboard.h" 23 | 24 | void Keyboard_Process(KeyNumType &key); 25 | 26 | #endif // GAMEKEYBOARD_H 27 | -------------------------------------------------------------------------------- /src/game/engine/gameloop.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author OmniBlade 5 | * @author CCHyper 6 | * 7 | * @brief Main game loop for the game engine. 8 | * 9 | * @copyright Chronoshift is free software: you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation, either version 12 | * 2 of the License, or (at your option) any later version. 13 | * A full copy of the GNU General Public License can be found in 14 | * LICENSE 15 | */ 16 | #pragma once 17 | 18 | #ifndef GAMELOOP_H 19 | #define GAMELOOP_H 20 | 21 | #include "always.h" 22 | 23 | BOOL Main_Loop(); 24 | 25 | #endif // GAMELOOP_H 26 | -------------------------------------------------------------------------------- /src/game/engine/gamemain.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author OmniBlade 5 | * 6 | * @brief The game engines main routine to be called from the user entry point. 7 | * 8 | * @copyright Chronoshift is free software: you can redistribute it and/or 9 | * modify it under the terms of the GNU General Public License 10 | * as published by the Free Software Foundation, either version 11 | * 2 of the License, or (at your option) any later version. 12 | * A full copy of the GNU General Public License can be found in 13 | * LICENSE 14 | */ 15 | #pragma once 16 | 17 | #ifndef GAMEMAIN_H 18 | #define GAMEMAIN_H 19 | 20 | #include "always.h" 21 | 22 | void Main_Game(int argc, char **argv); 23 | 24 | #endif // GAMEMAIN_H 25 | -------------------------------------------------------------------------------- /src/game/engine/gameoptions.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author CCHyper 5 | * @author OmniBlade 6 | * 7 | * @brief GUI for settings options in OptionsClass. 8 | * 9 | * @copyright Chronoshift is free software: you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation, either version 12 | * 2 of the License, or (at your option) any later version. 13 | * A full copy of the GNU General Public License can be found in 14 | * LICENSE 15 | */ 16 | #include "gameoptions.h" 17 | #include "gbuffer.h" 18 | 19 | #ifndef GAME_DLL 20 | GameOptionsClass g_Options; 21 | #endif 22 | 23 | /** 24 | * @brief Performs processing for this object per frame. 25 | * 26 | * 0x004C9EE0 27 | */ 28 | void GameOptionsClass::Process() 29 | { 30 | // TODO 31 | #ifdef GAME_DLL 32 | void (*process)(const GameOptionsClass *) = reinterpret_cast(0x004C9EE0); 33 | process(this); 34 | #endif 35 | } 36 | 37 | /** 38 | * @brief Adjusts the values of variables based on current resolution. 39 | * 40 | * 0x004CAC6C 41 | */ 42 | void GameOptionsClass::Adjust_Vars_For_Resolution() 43 | { 44 | // TODO work out what these are all used for if anything. 45 | m_OptionsDialogWidth = 448; 46 | m_OptionsDialogHeight = 222; 47 | m_OptionsDialogCenterX = (g_SeenBuff.Get_Width() - m_OptionsDialogWidth) / 2; 48 | m_OptionsDialogCenterY = (g_SeenBuff.Get_Height() - m_OptionsDialogHeight) / 2; 49 | m_field_8C = 260; 50 | m_OptionsDialogButtonYSpacing = 18; 51 | m_field_94 = 10; 52 | m_OptionsDialogButtonOffsetFromTop = 42; 53 | m_field_9C = 144; 54 | m_field_A0 = 32; 55 | m_OptionsDialogBottomButtonOffsetTop = m_OptionsDialogHeight - 38; 56 | } 57 | -------------------------------------------------------------------------------- /src/game/engine/gameoptions.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author CCHyper 5 | * @author OmniBlade 6 | * 7 | * @brief GUI for settings options in OptionsClass. 8 | * 9 | * @copyright Chronoshift is free software: you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation, either version 12 | * 2 of the License, or (at your option) any later version. 13 | * A full copy of the GNU General Public License can be found in 14 | * LICENSE 15 | */ 16 | #pragma once 17 | 18 | #ifndef GAMEOPTIONS_H 19 | #define GAMEOPTIONS_H 20 | 21 | #include "always.h" 22 | #include "options.h" 23 | 24 | class GameOptionsClass : public OptionsClass 25 | { 26 | public: 27 | void Process(); 28 | void Adjust_Vars_For_Resolution(); 29 | 30 | private: 31 | int m_OptionsDialogWidth; 32 | int m_OptionsDialogHeight; 33 | int m_OptionsDialogCenterX; 34 | int m_OptionsDialogCenterY; 35 | int m_field_8C; 36 | int m_OptionsDialogButtonYSpacing; 37 | int m_field_94; 38 | int m_OptionsDialogButtonOffsetFromTop; 39 | int m_field_9C; 40 | int m_field_A0; 41 | int m_OptionsDialogBottomButtonOffsetTop; 42 | }; 43 | 44 | #ifdef GAME_DLL 45 | #include "hooker.h" 46 | 47 | extern GameOptionsClass &g_Options; 48 | #else 49 | extern GameOptionsClass g_Options; 50 | #endif 51 | 52 | #endif // GAMEOPTIONS_H 53 | -------------------------------------------------------------------------------- /src/game/engine/getcd.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author tomsons26 5 | * 6 | * @brief Class for finding the CD drive. 7 | * 8 | * @copyright Chronoshift is free software: you can redistribute it and/or 9 | * modify it under the terms of the GNU General Public License 10 | * as published by the Free Software Foundation, either version 11 | * 2 of the License, or (at your option) any later version. 12 | * A full copy of the GNU General Public License can be found in 13 | * LICENSE 14 | */ 15 | #include "getcd.h" 16 | #include 17 | 18 | #ifdef PLATFORM_WINDOWS 19 | #ifdef __WATCOMC__ 20 | #include 21 | #else 22 | #include 23 | #include 24 | #endif 25 | #endif 26 | 27 | using std::memset; 28 | 29 | #ifndef GAME_DLL 30 | GetCDClass g_CDList; 31 | #endif 32 | 33 | GetCDClass::GetCDClass() 34 | { 35 | #ifdef PLATFORM_WINDOWS 36 | char drive_name[20]; 37 | 38 | strcpy(drive_name, "a:\\"); 39 | Set_Drive_Count(0); 40 | Set_Current_Drive(0); 41 | memset(m_drivelist, INVALID_CD_DRIVE, sizeof(m_drivelist)); 42 | 43 | for (char driveletter = 'a'; driveletter <= 'z'; ++driveletter) { 44 | drive_name[0] = driveletter; 45 | 46 | if(GetDriveTypeA(drive_name) == DRIVE_CDROM) { 47 | m_drivelist[m_driveCount++] = driveletter - 'a'; 48 | } 49 | } 50 | #else 51 | Set_Drive_Count(0); 52 | Set_Current_Drive(0); 53 | memset(m_drivelist, INVALID_CD_DRIVE, sizeof(m_drivelist)); 54 | #endif 55 | } 56 | 57 | int GetCDClass::Get_CD_Drive() 58 | { 59 | if (Get_Drive_Count()) { 60 | if (m_currentDrive == Get_Drive_Count()) { 61 | Set_Current_Drive(0); 62 | } 63 | 64 | return m_drivelist[m_currentDrive++]; 65 | } 66 | 67 | return INVALID_CD_DRIVE; 68 | } 69 | 70 | int GetCDClass::Reset_And_Get_CD_Drive() 71 | { 72 | Set_Current_Drive(0); 73 | return Get_CD_Drive(); 74 | } 75 | -------------------------------------------------------------------------------- /src/game/engine/getcd.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author tomsons26 5 | * 6 | * @brief Class for finding the CD drive. 7 | * 8 | * @copyright Chronoshift is free software: you can redistribute it and/or 9 | * modify it under the terms of the GNU General Public License 10 | * as published by the Free Software Foundation, either version 11 | * 2 of the License, or (at your option) any later version. 12 | * A full copy of the GNU General Public License can be found in 13 | * LICENSE 14 | */ 15 | 16 | #pragma once 17 | 18 | #ifndef GETCD_H 19 | #define GETCD_H 20 | 21 | #include "always.h" 22 | 23 | class GetCDClass 24 | { 25 | enum 26 | { 27 | INVALID_CD_DRIVE = -1, 28 | }; 29 | public: 30 | GetCDClass(); 31 | ~GetCDClass(){}; 32 | 33 | int Get_Drive_Count() { return m_driveCount; } 34 | void Set_Drive_Count(int count) { m_driveCount = count; } 35 | int Get_CD_Drive(); 36 | int Reset_And_Get_CD_Drive(); 37 | void Set_Current_Drive(int drive) { m_currentDrive = drive; } 38 | 39 | private: 40 | int m_drivelist[26]; 41 | int m_driveCount; 42 | int m_currentDrive; 43 | }; 44 | 45 | #ifdef GAME_DLL 46 | extern GetCDClass &g_CDList; 47 | #else 48 | extern GetCDClass g_CDList; 49 | #endif 50 | 51 | #endif // GETCD_H 52 | -------------------------------------------------------------------------------- /src/game/engine/housedata.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author CCHyper 5 | * @author OmniBlade 6 | * 7 | * @brief Static instances of house type objects. 8 | * 9 | * @copyright Chronoshift is free software: you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation, either version 12 | * 2 of the License, or (at your option) any later version. 13 | * A full copy of the GNU General Public License can be found in 14 | * LICENSE 15 | */ 16 | #pragma once 17 | 18 | #ifndef HOUSEDATA_H 19 | #define HOUSEDATA_H 20 | 21 | #include "always.h" 22 | #include "housetype.h" 23 | 24 | extern const HouseTypeClass HouseEngland; 25 | extern const HouseTypeClass HouseGermany; 26 | extern const HouseTypeClass HouseFrance; 27 | extern const HouseTypeClass HouseUkraine; 28 | extern const HouseTypeClass HouseUSSR; 29 | extern const HouseTypeClass HouseGreece; 30 | extern const HouseTypeClass HouseTurkey; 31 | extern const HouseTypeClass HouseSpain; 32 | extern const HouseTypeClass HouseGood; 33 | extern const HouseTypeClass HouseBad; 34 | extern const HouseTypeClass HouseCivilian; 35 | extern const HouseTypeClass HouseJP; 36 | extern const HouseTypeClass HouseMulti1; 37 | extern const HouseTypeClass HouseMulti2; 38 | extern const HouseTypeClass HouseMulti3; 39 | extern const HouseTypeClass HouseMulti4; 40 | extern const HouseTypeClass HouseMulti5; 41 | extern const HouseTypeClass HouseMulti6; 42 | extern const HouseTypeClass HouseMulti7; 43 | extern const HouseTypeClass HouseMulti8; 44 | 45 | #endif // HOUSEDATA_H 46 | -------------------------------------------------------------------------------- /src/game/engine/init.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author CCHyper 5 | * @author OmniBlade 6 | * @author tomsons26 7 | * 8 | * @brief Engine initialisation functions. 9 | * 10 | * @copyright Chronoshift is free software: you can redistribute it and/or 11 | * modify it under the terms of the GNU General Public License 12 | * as published by the Free Software Foundation, either version 13 | * 2 of the License, or (at your option) any later version. 14 | * A full copy of the GNU General Public License can be found in 15 | * LICENSE 16 | */ 17 | #pragma once 18 | 19 | #ifndef INIT_H 20 | #define INIT_H 21 | 22 | #include "always.h" 23 | 24 | class GraphicViewPortClass; 25 | class PaletteClass; 26 | 27 | void Init_Expansion_Files(); 28 | void Init_Bootstrap_Mixfiles(); 29 | void Init_Secondary_Mixfiles(); 30 | void Reinit_Secondary_Mixfiles(); 31 | void Init_Bulk_Data(); 32 | void Init_One_Time_Systems(); 33 | void Init_Keys(); 34 | void Init_Fonts(); 35 | void Init_Random(); 36 | void Init_Color_Remaps(); 37 | void Init_Mouse(); 38 | void Bootstrap(); 39 | void Init_CDROM_Access(); 40 | void Load_Title_Screen(const char *filename, GraphicViewPortClass *vp, PaletteClass *pal); 41 | void Load_Prolog_Page(); 42 | BOOL Init_Game(int argc, char **argv); 43 | 44 | #endif // INIT_H 45 | -------------------------------------------------------------------------------- /src/game/engine/iomap.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author OmniBlade 5 | * @author CCHyper 6 | * 7 | * @brief Implements global instance of the final IOMap object. 8 | * 9 | * @copyright Chronoshift is free software: you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation, either version 12 | * 2 of the License, or (at your option) any later version. 13 | * A full copy of the GNU General Public License can be found in 14 | * LICENSE 15 | */ 16 | #include "iomap.h" 17 | 18 | // NOTE: Update this as additional layers of the hierachy are added. 19 | #ifndef GAME_DLL 20 | MapEditClass g_Map; 21 | #endif 22 | -------------------------------------------------------------------------------- /src/game/engine/iomap.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author OmniBlade 5 | * @author CCHyper 6 | * 7 | * @brief Implements global instance of the final IOMap object. 8 | * 9 | * @copyright Chronoshift is free software: you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation, either version 12 | * 2 of the License, or (at your option) any later version. 13 | * A full copy of the GNU General Public License can be found in 14 | * LICENSE 15 | */ 16 | #pragma once 17 | 18 | #ifndef IOMAP_H 19 | #define IOMAP_H 20 | 21 | #include "always.h" 22 | #include "mapedit.h" 23 | 24 | // NOTE: Update this as additional layers of the hierachy are added. 25 | #ifdef GAME_DLL 26 | extern MapEditClass &g_Map; 27 | #else 28 | extern MapEditClass g_Map; 29 | #endif 30 | 31 | #endif // IOMAP_H 32 | -------------------------------------------------------------------------------- /src/game/engine/land.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author OmniBlade 5 | * @author CCHyper 6 | * 7 | * @brief Land conversion between string and enum. 8 | * 9 | * @copyright Chronoshift is free software: you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation, either version 12 | * 2 of the License, or (at your option) any later version. 13 | * A full copy of the GNU General Public License can be found in 14 | * LICENSE 15 | */ 16 | #include "land.h" 17 | #include "gameini.h" 18 | #include 19 | 20 | const char *LandName[LAND_COUNT] = { 21 | "Clear", 22 | "Road", 23 | "Water", 24 | "Rock", 25 | "Wall", 26 | "Ore", 27 | "Beach", 28 | "Rough", 29 | "River" 30 | }; 31 | 32 | LandType Land_From_Name(const char *name) 33 | { 34 | captainslog_assert(name != nullptr); 35 | 36 | if (strcasecmp(name, "") == 0 || strcasecmp(name, "none") == 0) { 37 | return LAND_NONE; 38 | } 39 | 40 | if (name != nullptr) { 41 | for (LandType land = LAND_FIRST; land < LAND_COUNT; ++land) { 42 | if (strcasecmp(name, LandName[land]) == 0) { 43 | return land; 44 | } 45 | } 46 | } 47 | 48 | return LAND_NONE; 49 | } 50 | 51 | const char *Name_From_Land(LandType land) 52 | { 53 | if (land < LAND_COUNT) { 54 | return LandName[land]; 55 | } 56 | 57 | return ""; 58 | } 59 | -------------------------------------------------------------------------------- /src/game/engine/land.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author OmniBlade 5 | * @author CCHyper 6 | * 7 | * @brief Land conversion between string and enum. 8 | * 9 | * @copyright Chronoshift is free software: you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation, either version 12 | * 2 of the License, or (at your option) any later version. 13 | * A full copy of the GNU General Public License can be found in 14 | * LICENSE 15 | */ 16 | #pragma once 17 | 18 | #ifndef LAND_H 19 | #define LAND_H 20 | 21 | #include "always.h" 22 | #include "fixed.h" 23 | #include "gametypes.h" 24 | 25 | class GameINIClass; 26 | 27 | enum LandType 28 | { 29 | LAND_CLEAR, // Clear grassy terrain 30 | LAND_ROAD, // Roads 31 | LAND_WATER, // Open water 32 | LAND_ROCK, // Cliffs 33 | LAND_WALL, // Walls and other man made obstacles 34 | LAND_ORE, // Ore and Gems 35 | LAND_BEACH, // Sandy beach 36 | LAND_ROUGH, // Rocky terrain 37 | LAND_RIVER, // Rivers and streams 38 | 39 | LAND_COUNT, 40 | 41 | LAND_NONE = -1, 42 | LAND_FIRST = LAND_CLEAR, 43 | }; 44 | 45 | DEFINE_ENUMERATION_OPERATORS(LandType); 46 | 47 | LandType Land_From_Name(const char *name); 48 | const char *Name_From_Land(LandType land); 49 | 50 | #endif // LAND_H 51 | -------------------------------------------------------------------------------- /src/game/engine/layer.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author CCHyper 5 | * @author OmniBlade 6 | * 7 | * @brief Class for handling layer placement. 8 | * 9 | * @copyright Chronoshift is free software: you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation, either version 12 | * 2 of the License, or (at your option) any later version. 13 | * A full copy of the GNU General Public License can be found in 14 | * LICENSE 15 | */ 16 | #pragma once 17 | 18 | #ifndef LAYER_H 19 | #define LAYER_H 20 | 21 | #include "always.h" 22 | #include "gametypes.h" 23 | #include "vector.h" 24 | 25 | class Pipe; 26 | class Straw; 27 | class ObjectClass; 28 | 29 | enum LayerType 30 | { 31 | LAYER_SURFACE, 32 | LAYER_GROUND, 33 | LAYER_AIR, 34 | LAYER_TOP, 35 | 36 | LAYER_COUNT, 37 | 38 | LAYER_NONE = -1, 39 | LAYER_FIRST = LAYER_SURFACE, 40 | }; 41 | 42 | DEFINE_ENUMERATION_OPERATORS(LayerType); 43 | 44 | class LayerClass : public DynamicVectorClass 45 | { 46 | public: 47 | LayerClass(); 48 | virtual ~LayerClass(); 49 | 50 | virtual void Init(); 51 | virtual void One_Time() {} 52 | 53 | virtual void Code_Pointers(); 54 | virtual void Decode_Pointers(); 55 | 56 | void Remove(ObjectClass *object) { Delete(object); } 57 | BOOL Submit(ObjectClass *object, BOOL sort = false); 58 | 59 | void Sort(); 60 | BOOL Sorted_Add(ObjectClass *const object); 61 | 62 | void Mark_All(MarkType mark); 63 | void Render_All(BOOL force_redraw = false); 64 | 65 | BOOL Load(Straw &straw); 66 | BOOL Save(Pipe &pipe) const; 67 | 68 | #ifdef GAME_DLL 69 | public: 70 | BOOL Hook_Save(Pipe &pipe) 71 | { 72 | return LayerClass::Save(pipe); 73 | } 74 | #endif 75 | }; 76 | 77 | #endif // LAYER_H 78 | -------------------------------------------------------------------------------- /src/game/engine/logic.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author CCHyper 5 | * 6 | * @brief Class handling all objects that need per tick logic applying. 7 | * 8 | * @copyright Chronoshift is free software: you can redistribute it and/or 9 | * modify it under the terms of the GNU General Public License 10 | * as published by the Free Software Foundation, either version 11 | * 2 of the License, or (at your option) any later version. 12 | * A full copy of the GNU General Public License can be found in 13 | * LICENSE 14 | */ 15 | #pragma once 16 | 17 | #ifndef LOGIC_H 18 | #define LOGIC_H 19 | 20 | #include "always.h" 21 | #include "layer.h" 22 | 23 | class ObjectClass; 24 | class TriggerClass; 25 | 26 | class LogicClass : public LayerClass 27 | { 28 | public: 29 | LogicClass() : LayerClass() {} 30 | virtual ~LogicClass(); 31 | 32 | void AI(); 33 | 34 | void Init(); 35 | 36 | void Remove(ObjectClass *const object); 37 | BOOL Submit(ObjectClass *object, BOOL sort = false); 38 | 39 | void Detach(target_t target, BOOL a2 = true); 40 | }; 41 | 42 | #ifdef GAME_DLL 43 | extern LogicClass &g_Logic; 44 | extern DynamicVectorClass &g_LogicTriggers; 45 | extern DynamicVectorClass &g_MapTriggers; 46 | extern DynamicVectorClass *g_HouseTriggers; 47 | #else 48 | extern LogicClass g_Logic; 49 | extern DynamicVectorClass g_LogicTriggers; 50 | extern DynamicVectorClass g_MapTriggers; 51 | extern DynamicVectorClass g_HouseTriggers[HOUSES_COUNT]; 52 | #endif 53 | 54 | #endif // LOGIC_H 55 | -------------------------------------------------------------------------------- /src/game/engine/mainmenu.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author CCHyper 5 | * 6 | * @brief Main menu. 7 | * 8 | * @copyright Chronoshift is free software: you can redistribute it and/or 9 | * modify it under the terms of the GNU General Public License 10 | * as published by the Free Software Foundation, either version 11 | * 2 of the License, or (at your option) any later version. 12 | * A full copy of the GNU General Public License can be found in 13 | * LICENSE 14 | */ 15 | #pragma once 16 | 17 | #ifndef MAINMENU_H 18 | #define MAINMENU_H 19 | 20 | #include "always.h" 21 | 22 | enum MenuButtonType 23 | { 24 | MENU_COUNTERSTRIKE, 25 | MENU_AFTERMATH, 26 | MENU_NEW_GAME, 27 | MENU_LOAD_GAME, 28 | MENU_MPLAYER_GAME, 29 | //MENU_SNEAK_PEAK, 30 | MENU_MOVIES, 31 | MENU_MAP_EDITOR, 32 | MENU_OPTIONS, 33 | MENU_EXIT, 34 | 35 | MENU_COUNT, 36 | 37 | MENU_RESET = -2, // Special flag to indicate a full reset of the main menu. 38 | MENU_NONE = -1, 39 | }; 40 | 41 | DEFINE_ENUMERATION_OPERATORS(MenuButtonType); 42 | 43 | enum { 44 | DEFAULT_ATTRACTION_DELAY = 3600 45 | }; 46 | 47 | class GraphicViewPortClass; 48 | class PaletteClass; 49 | 50 | void Load_Title_Page(); 51 | void Load_Standby_Page(); 52 | void Load_Prolog_Page(); 53 | void Load_Title_Screen(const char *filename, GraphicViewPortClass *vp, PaletteClass *pal); 54 | 55 | BOOL Select_Game(BOOL fade = false); 56 | MenuButtonType Main_Menu(int attract_delay = DEFAULT_ATTRACTION_DELAY); 57 | 58 | #endif // MAINMENU_H 59 | -------------------------------------------------------------------------------- /src/game/engine/multimission.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author tomsons26 5 | * 6 | * @brief Class for storing basic mission map information. 7 | * 8 | * @copyright Chronoshift is free software: you can redistribute it and/or 9 | * modify it under the terms of the GNU General Public License 10 | * as published by the Free Software Foundation, either version 11 | * 2 of the License, or (at your option) any later version. 12 | * A full copy of the GNU General Public License can be found in 13 | * LICENSE 14 | */ 15 | #include "multimission.h" 16 | #include 17 | 18 | using std::strlen; 19 | using std::strncpy; 20 | 21 | MultiMission::MultiMission(const char *filename, const char *description, const char *digest, int isofficial, int isexpansion) 22 | { 23 | Set_Filename(filename); 24 | Set_Description(description); 25 | Set_Digest(digest); 26 | Set_Official(isofficial); 27 | Set_Expansion(isexpansion); 28 | } 29 | 30 | void MultiMission::Draw_It(int index, int xpos, int ypos, int xmax, int ymax, BOOL redraw_entry, TextPrintType style) 31 | { 32 | // empty 33 | } 34 | 35 | void MultiMission::Set_Description(const char *desc) 36 | { 37 | if (desc != nullptr){ 38 | strlcpy(m_Description, desc, sizeof(m_Description)); 39 | } 40 | } 41 | 42 | void MultiMission::Set_Filename(const char *filename) 43 | { 44 | if (filename != nullptr){ 45 | strlcpy(m_Filename, filename, sizeof(m_Filename)); 46 | } 47 | } 48 | 49 | void MultiMission::Set_Digest(const char *digest) 50 | { 51 | if (digest != nullptr) { 52 | strlcpy(m_Digest, digest, sizeof(m_Digest)); 53 | } else { 54 | strcpy(m_Digest, "NODIGEST"); 55 | } 56 | } 57 | 58 | 59 | void MultiMission::Set_Official(int official) 60 | { 61 | m_IsOfficial = official; 62 | } 63 | 64 | void MultiMission::Set_Expansion(int expansion) 65 | { 66 | m_IsExpansion = expansion; 67 | } 68 | -------------------------------------------------------------------------------- /src/game/engine/multimission.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author tomsons26 5 | * 6 | * @brief Class for storing basic mission map information. 7 | * 8 | * @copyright Chronoshift is free software: you can redistribute it and/or 9 | * modify it under the terms of the GNU General Public License 10 | * as published by the Free Software Foundation, either version 11 | * 2 of the License, or (at your option) any later version. 12 | * A full copy of the GNU General Public License can be found in 13 | * LICENSE 14 | */ 15 | #pragma once 16 | 17 | #ifndef MULTIMISSION_H 18 | #define MULTIMISSION_H 19 | 20 | #include "always.h" 21 | #include "dialog.h" 22 | 23 | class MultiMission 24 | { 25 | public: 26 | MultiMission(const char *filename, const char *description, const char *digest, int isofficial, int isexpansion); 27 | void Draw_It(int index, int xpos, int ypos, int xmax, int ymax, BOOL redraw_entry, TextPrintType style); 28 | void Set_Description(const char *desc); 29 | void Set_Filename(const char *filename); 30 | void Set_Digest(const char *digest); 31 | void Set_Official(int official); 32 | void Set_Expansion(int expansion); 33 | int Official() const { return m_IsOfficial; } 34 | 35 | private: 36 | char m_Description[44]; 37 | char m_Filename[512]; 38 | char m_Digest[32]; 39 | int m_IsOfficial; 40 | int m_IsExpansion; 41 | }; 42 | 43 | #endif //MULTIMISSION_H 44 | -------------------------------------------------------------------------------- /src/game/engine/mzone.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author OmniBlade 5 | * @author CCHyper 6 | * 7 | * @brief Translates between string and enum for movement zones. 8 | * 9 | * @copyright Chronoshift is free software: you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation, either version 12 | * 2 of the License, or (at your option) any later version. 13 | * A full copy of the GNU General Public License can be found in 14 | * LICENSE 15 | */ 16 | #include "mzone.h" 17 | #include 18 | 19 | #ifdef HAVE_STRINGS_H 20 | #include 21 | #endif 22 | 23 | const char *MZoneName[MZONE_COUNT] = { 24 | "Normal", 25 | "Crusher", 26 | "Destroyer", 27 | "AmphibiousDestroyer" 28 | }; 29 | 30 | MZoneType MZone_From_Name(const char *name) 31 | { 32 | captainslog_assert(name != nullptr); 33 | 34 | if (strcasecmp(name, "") == 0 || strcasecmp(name, "none") == 0) { 35 | return MZONE_NONE; 36 | } 37 | 38 | if (name != nullptr) { 39 | for (MZoneType mzone = MZONE_FIRST; mzone < MZONE_COUNT; ++mzone) { 40 | if (strcasecmp(name, MZoneName[mzone]) == 0) { 41 | return mzone; 42 | } 43 | } 44 | } 45 | return MZONE_NONE; 46 | } 47 | 48 | const char *Name_From_MZone(MZoneType mzone) 49 | { 50 | captainslog_assert(mzone < MZONE_COUNT); 51 | captainslog_assert(mzone != MZONE_NONE); 52 | 53 | if (mzone != MZONE_NONE && mzone < MZONE_COUNT) { 54 | return MZoneName[mzone]; 55 | } 56 | return ""; 57 | } 58 | -------------------------------------------------------------------------------- /src/game/engine/mzone.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author OmniBlade 5 | * @author CCHyper 6 | * 7 | * @brief Translates between string and enum for movement zones. 8 | * 9 | * @copyright Chronoshift is free software: you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation, either version 12 | * 2 of the License, or (at your option) any later version. 13 | * A full copy of the GNU General Public License can be found in 14 | * LICENSE 15 | */ 16 | #pragma once 17 | 18 | #ifndef MZONE_H 19 | #define MZONE_H 20 | 21 | #include "always.h" 22 | 23 | enum MZoneType 24 | { 25 | MZONE_NORMAL, 26 | MZONE_CRUSHER, 27 | MZONE_DESTROYER, 28 | MZONE_AMPHIBIOUS_DESTROYER, // used by Vessels only. 29 | 30 | MZONE_COUNT, 31 | 32 | MZONE_NONE = -1, 33 | MZONE_FIRST = MZONE_NORMAL, 34 | }; 35 | 36 | DEFINE_ENUMERATION_OPERATORS(MZoneType); 37 | 38 | MZoneType MZone_From_Name(const char *name); 39 | const char *Name_From_MZone(MZoneType land); 40 | 41 | #endif // MZONE_H 42 | -------------------------------------------------------------------------------- /src/game/engine/overlay.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author tomsons26 5 | * 6 | * @brief 7 | * 8 | * @copyright Chronoshift is free software: you can redistribute it and/or 9 | * modify it under the terms of the GNU General Public License 10 | * as published by the Free Software Foundation, either version 11 | * 2 of the License, or (at your option) any later version. 12 | * A full copy of the GNU General Public License can be found in 13 | * LICENSE 14 | */ 15 | #pragma once 16 | 17 | #ifndef OVERLAY_H 18 | #define OVERLAY_H 19 | 20 | #include "always.h" 21 | #include "object.h" 22 | #include "overlaytype.h" 23 | 24 | class OverlayClass : public ObjectClass 25 | { 26 | public: 27 | OverlayClass(OverlayType type, cell_t cell = -1, HousesType house = HOUSES_NONE); 28 | OverlayClass(const OverlayClass &that); 29 | OverlayClass(const NoInitClass &noinit); 30 | virtual ~OverlayClass(); 31 | 32 | void *operator new(size_t size); 33 | void *operator new(size_t size, void *ptr) { return ptr; } 34 | void operator delete(void *ptr); 35 | #ifndef COMPILER_WATCOM // Watcom doesn't like this, MSVC/GCC does. 36 | void operator delete(void *ptr, void *place) {} 37 | #endif 38 | 39 | // ObjectClass 40 | virtual const OverlayTypeClass &Class_Of() const final { return *m_Class; } 41 | virtual void Draw_It(int x, int y, WindowNumberType window) const final; 42 | virtual BOOL Mark(MarkType mark) final; 43 | 44 | static void Read_INI(GameINIClass &ini); 45 | static void Write_INI(GameINIClass &ini); 46 | 47 | OverlayType What_Type() const { return m_Class->What_Type(); } 48 | 49 | static void Init(); 50 | 51 | private: 52 | GamePtr m_Class; 53 | 54 | static HousesType s_ToOwn; 55 | }; 56 | 57 | #ifdef GAME_DLL 58 | extern TFixedIHeapClass &g_Overlays; 59 | #else 60 | extern TFixedIHeapClass g_Overlays; 61 | #endif 62 | 63 | #endif //OVERLAY_H 64 | -------------------------------------------------------------------------------- /src/game/engine/overlaydata.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author CCHyper 5 | * @author OmniBlade 6 | * 7 | * @brief Static instances of overlay type objects. 8 | * 9 | * @copyright Chronoshift is free software: you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation, either version 12 | * 2 of the License, or (at your option) any later version. 13 | * A full copy of the GNU General Public License can be found in 14 | * LICENSE 15 | */ 16 | #pragma once 17 | 18 | #ifndef OVERLAYDATA_H 19 | #define OVERLAYDATA_H 20 | 21 | #include "always.h" 22 | #include "overlaytype.h" 23 | 24 | extern const OverlayTypeClass OverlaySandbag; 25 | extern const OverlayTypeClass OverlayCyclone; 26 | extern const OverlayTypeClass OverlayBrick; 27 | extern const OverlayTypeClass OverlayBarbwire; 28 | extern const OverlayTypeClass OverlayWood; 29 | extern const OverlayTypeClass OverlayFence; 30 | extern const OverlayTypeClass OverlayGold1; 31 | extern const OverlayTypeClass OverlayGold2; 32 | extern const OverlayTypeClass OverlayGold3; 33 | extern const OverlayTypeClass OverlayGold4; 34 | extern const OverlayTypeClass OverlayGems1; 35 | extern const OverlayTypeClass OverlayGems2; 36 | extern const OverlayTypeClass OverlayGems3; 37 | extern const OverlayTypeClass OverlayGems4; 38 | extern const OverlayTypeClass OverlayV12; 39 | extern const OverlayTypeClass OverlayV13; 40 | extern const OverlayTypeClass OverlayV14; 41 | extern const OverlayTypeClass OverlayV15; 42 | extern const OverlayTypeClass OverlayV16; 43 | extern const OverlayTypeClass OverlayV17; 44 | extern const OverlayTypeClass OverlayV18; 45 | extern const OverlayTypeClass OverlayFlagSpot; 46 | extern const OverlayTypeClass OverlayWoodCrate; 47 | extern const OverlayTypeClass OverlayWaterCrate; 48 | extern const OverlayTypeClass OverlaySteelCrate; 49 | 50 | #endif // OVERLAYDATA_H 51 | -------------------------------------------------------------------------------- /src/game/engine/quarry.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author CCHyper 5 | * @author OmniBlade 6 | * 7 | * @brief Holds quarry type enum and conversion functions to/from strings. 8 | * 9 | * @copyright Chronoshift is free software: you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation, either version 12 | * 2 of the License, or (at your option) any later version. 13 | * A full copy of the GNU General Public License can be found in 14 | * LICENSE 15 | */ 16 | #include "quarry.h" 17 | #include 18 | 19 | #ifdef HAVE_STRINGS_H 20 | #include 21 | #endif 22 | 23 | const char *g_QuarryName[QUARRY_COUNT] = { "N/A", 24 | "Anything", 25 | "Buildings - any", 26 | "Harvesters", 27 | "Infantry", 28 | "Vehicles - any", 29 | "Ships - any", 30 | "Factories", 31 | "Base Defenses", 32 | "Base Threats", 33 | "Power Facilities", 34 | "Fake Buildings" }; 35 | 36 | QuarryType Quarry_From_Name(const char *name) 37 | { 38 | captainslog_assert(name != nullptr); 39 | 40 | if (strcasecmp(name, "") == 0 || strcasecmp(name, "none") == 0) { 41 | return QUARRY_NONE; 42 | } 43 | 44 | if (name != nullptr) { 45 | for (QuarryType type = QUARRY_FIRST; type < QUARRY_COUNT; ++type) { 46 | if (strcasecmp(name, g_QuarryName[type]) == 0) { 47 | return type; 48 | } 49 | } 50 | } 51 | 52 | return QUARRY_NONE; 53 | } 54 | 55 | const char *Name_From_Quarry(QuarryType type) 56 | { 57 | captainslog_assert(type != QUARRY_NONE); 58 | captainslog_assert(type < QUARRY_COUNT); 59 | 60 | if (type != QUARRY_NONE && type < QUARRY_COUNT) { 61 | return g_QuarryName[type]; 62 | } 63 | 64 | return "None"; 65 | } 66 | -------------------------------------------------------------------------------- /src/game/engine/quarry.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author CCHyper 5 | * @author OmniBlade 6 | * 7 | * @brief Holds quarry type enum and conversion functions to/from strings. 8 | * 9 | * @copyright Chronoshift is free software: you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation, either version 12 | * 2 of the License, or (at your option) any later version. 13 | * A full copy of the GNU General Public License can be found in 14 | * LICENSE 15 | */ 16 | #pragma once 17 | 18 | #ifndef QUARRY_H 19 | #define QUARRY_H 20 | 21 | #include "always.h" 22 | 23 | enum QuarryType 24 | { 25 | QUARRY_NA, 26 | QUARRY_ANYTHING, 27 | QUARRY_ANY_BUILDING, 28 | QUARRY_HARVESTERS, 29 | QUARRY_INFANTRY, 30 | QUARRY_ANY_VEHICLES, 31 | QUARRY_ANY_VESSEL, 32 | QUARRY_FACTORIES, 33 | QUARRY_BASE_DEFENSES, 34 | QUARRY_BASE_THREATS, 35 | QUARRY_POWER_FACILITIES, 36 | QUARRY_FAKE_BUILDINGS, 37 | QUARRY_COUNT, 38 | QUARRY_NONE = -1, 39 | QUARRY_FIRST = 0, 40 | }; 41 | 42 | DEFINE_ENUMERATION_OPERATORS(QuarryType); 43 | 44 | QuarryType Quarry_From_Name(const char *name); 45 | const char *Name_From_Quarry(QuarryType type); 46 | 47 | #endif // QUARRY_H 48 | -------------------------------------------------------------------------------- /src/game/engine/region.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author CCHyper 5 | * 6 | * @brief Class holding regional threat information on the map. 7 | * 8 | * @copyright Chronoshift is free software: you can redistribute it and/or 9 | * modify it under the terms of the GNU General Public License 10 | * as published by the Free Software Foundation, either version 11 | * 2 of the License, or (at your option) any later version. 12 | * A full copy of the GNU General Public License can be found in 13 | * LICENSE 14 | */ 15 | #if !defined(REGION_H) 16 | #define REGION_H 17 | 18 | #include "always.h" 19 | 20 | class NoInitClass; 21 | 22 | class RegionClass 23 | { 24 | public: 25 | RegionClass() : m_Value(0) {} 26 | RegionClass(const RegionClass &that) {} 27 | RegionClass(const NoInitClass &noinit) {} 28 | ~RegionClass() {} 29 | 30 | int Get_Value() const { return m_Value; } 31 | 32 | void Adjust_Value(int value, bool a2) 33 | { 34 | if ( a2 ) { 35 | m_Value -= value; 36 | } else { 37 | m_Value += value; 38 | } 39 | } 40 | 41 | private: 42 | int m_Value; 43 | }; 44 | 45 | #endif // REGION_H 46 | -------------------------------------------------------------------------------- /src/game/engine/saveload.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author tomsons26 5 | * 6 | * @brief Functions used for Saving and Loading savegames. 7 | * 8 | * @copyright Chronoshift is free software: you can redistribute it and/or 9 | * modify it under the terms of the GNU General Public License 10 | * as published by the Free Software Foundation, either version 11 | * 2 of the License, or (at your option) any later version. 12 | * A full copy of the GNU General Public License can be found in 13 | * LICENSE 14 | */ 15 | #pragma once 16 | 17 | #ifndef SAVELOAD_H 18 | #define SAVELOAD_H 19 | 20 | #include "always.h" 21 | #include "gametypes.h" 22 | 23 | class Pipe; 24 | class Straw; 25 | 26 | enum 27 | { 28 | //DOS 29 | RADOS_10X_MAGIC_ID = 0x10054DA, // 1.0X DOS, Retail 30 | RADOS_20X_MAGIC_ID = 0x10054DB, // 2.0X DOS 31 | 32 | //Windows 95 33 | RA95_10X_MAGIC_ID = 0x100616D, // 1.0X, Retail 34 | RA95_20X_MAGIC_ID = 0x100616E, // 2.0X, RA DEMO 1.19 35 | RA95_105_MAGIC_ID = 0x1006175, // 1.05, Special build for TEN MP Network 36 | RA95_2XX_MAGIC_ID = 0x100618A, // unknown, RA 3.0X checks for it 37 | RA95_30X_MAGIC_ID = 0x100618B, // 3.0X 38 | }; 39 | 40 | void Put_All(Pipe &pipe, int skip_callback); 41 | int Save_Game(int number, char *savename, int unknown); 42 | int Load_Game(int unknown); 43 | int Save_Misc_Values(Pipe &pipe); 44 | int Load_Misc_Values(Straw &straw); 45 | int Save_MPlayer_Values(Pipe &pipe); 46 | int Load_MPlayer_Values(Straw &straw); 47 | void Code_All_Pointers(); 48 | void Decode_All_Pointers(); 49 | int Get_Savefile_Info(int number, char *savename, unsigned *scenarioidx, HousesType *house); 50 | int Reconcile_Players(); 51 | void MPlayer_Save_Message(); 52 | 53 | #endif // SAVELOAD_H 54 | -------------------------------------------------------------------------------- /src/game/engine/scroll.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author CCHyper 5 | * @author OmniBlade 6 | * 7 | * @brief Part of IOMap stack handling scrolling the viewport. 8 | * 9 | * @copyright Chronoshift is free software: you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation, either version 12 | * 2 of the License, or (at your option) any later version. 13 | * A full copy of the GNU General Public License can be found in 14 | * LICENSE 15 | */ 16 | #pragma once 17 | 18 | #ifndef SCROLL_H 19 | #define SCROLL_H 20 | 21 | #include "always.h" 22 | #include "help.h" 23 | 24 | enum ScrollMode 25 | { 26 | SCROLLMODE_TOGGLE = -1, 27 | SCROLLMODE_MANUAL = 0, 28 | SCROLLMODE_AUTO = 1, 29 | }; 30 | 31 | class ScrollClass : public HelpClass 32 | { 33 | public: 34 | ScrollClass(); 35 | ScrollClass(const NoInitClass &noinit) : HelpClass(noinit) {} 36 | 37 | virtual void Init_IO() override; 38 | virtual void AI(KeyNumType &key, int mouse_x, int mouse_y) override; 39 | 40 | BOOL Set_Autoscroll(int mode); 41 | 42 | protected: 43 | #ifndef CHRONOSHIFT_NO_BITFIELDS 44 | BOOL m_Autoscroll : 1; // 1 45 | #else 46 | bool m_Autoscroll; 47 | #endif 48 | int m_ScrollUnkInt; // is this a rate of sorts? 49 | 50 | private: 51 | #ifdef GAME_DLL 52 | static TCountDownTimerClass &s_ScrollingCounter; 53 | #else 54 | static TCountDownTimerClass s_ScrollingCounter; 55 | #endif 56 | }; 57 | 58 | #endif // SCROLL_H 59 | -------------------------------------------------------------------------------- /src/game/engine/smudgedata.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author CCHyper 5 | * @author OmniBlade 6 | * 7 | * @brief Static instances of smudge type objects. 8 | * 9 | * @copyright Chronoshift is free software: you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation, either version 12 | * 2 of the License, or (at your option) any later version. 13 | * A full copy of the GNU General Public License can be found in 14 | * LICENSE 15 | */ 16 | #pragma once 17 | 18 | #ifndef SMUDGEDATA_H 19 | #define SMUDGEDATA_H 20 | 21 | #include "always.h" 22 | #include "smudgetype.h" 23 | 24 | extern const SmudgeTypeClass SmudgeCrater1; 25 | extern const SmudgeTypeClass SmudgeCrater2; 26 | extern const SmudgeTypeClass SmudgeCrater3; 27 | extern const SmudgeTypeClass SmudgeCrater4; 28 | extern const SmudgeTypeClass SmudgeCrater5; 29 | extern const SmudgeTypeClass SmudgeCrater6; 30 | extern const SmudgeTypeClass SmudgeScorch1; 31 | extern const SmudgeTypeClass SmudgeScorch2; 32 | extern const SmudgeTypeClass SmudgeScorch3; 33 | extern const SmudgeTypeClass SmudgeScorch4; 34 | extern const SmudgeTypeClass SmudgeScorch5; 35 | extern const SmudgeTypeClass SmudgeScorch6; 36 | extern const SmudgeTypeClass SmudgeBibx1; 37 | extern const SmudgeTypeClass SmudgeBibx2; 38 | extern const SmudgeTypeClass SmudgeBibx3; 39 | 40 | #endif // SMUDGEDATA_H 41 | -------------------------------------------------------------------------------- /src/game/engine/sndctrl.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author tomsons26 5 | * 6 | * @brief 7 | * 8 | * @copyright Chronoshift is free software: you can redistribute it and/or 9 | * modify it under the terms of the GNU General Public License 10 | * as published by the Free Software Foundation, either version 11 | * 2 of the License, or (at your option) any later version. 12 | * A full copy of the GNU General Public License can be found in 13 | * LICENSE 14 | */ 15 | #pragma once 16 | 17 | #ifndef SNDCTRL_H 18 | #define SNDCTRL_H 19 | 20 | class SoundControlsClass 21 | { 22 | public: 23 | SoundControlsClass() {} 24 | void Adjust_Variables_For_Resolution(); 25 | void Process(); 26 | }; 27 | #endif //SNDCTRL_H 28 | -------------------------------------------------------------------------------- /src/game/engine/source.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author CCHyper 5 | * 6 | * @brief Source type enum and conversion to and from strings. 7 | * 8 | * @copyright Chronoshift is free software: you can redistribute it and/or 9 | * modify it under the terms of the GNU General Public License 10 | * as published by the Free Software Foundation, either version 11 | * 2 of the License, or (at your option) any later version. 12 | * A full copy of the GNU General Public License can be found in 13 | * LICENSE 14 | */ 15 | #include "source.h" 16 | 17 | #ifdef HAVE_STRINGS_H 18 | #include 19 | #endif 20 | 21 | const char *SourceName[SOURCE_COUNT] = { 22 | "North", 23 | "East", 24 | "South", 25 | "West", 26 | "Air" 27 | }; 28 | 29 | SourceType Source_From_Name(const char *name) 30 | { 31 | if (strcasecmp(name, "") == 0 || strcasecmp(name, "none") == 0) { 32 | return SOURCE_NONE; 33 | } 34 | 35 | if (name != nullptr) { 36 | for (SourceType source = SOURCE_FIRST; source < SOURCE_COUNT; ++source) { 37 | if (strcasecmp(name, SourceName[source]) == 0) { 38 | return source; 39 | } 40 | } 41 | } 42 | 43 | return SOURCE_NONE; 44 | } 45 | 46 | const char *Name_From_Source(SourceType source) 47 | { 48 | if (source < SOURCE_COUNT && source != SOURCE_NONE) { 49 | return SourceName[source]; 50 | } 51 | return ""; 52 | } 53 | -------------------------------------------------------------------------------- /src/game/engine/source.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author CCHyper 5 | * 6 | * @brief Source type enum and conversion to and from strings. 7 | * 8 | * @copyright Chronoshift is free software: you can redistribute it and/or 9 | * modify it under the terms of the GNU General Public License 10 | * as published by the Free Software Foundation, either version 11 | * 2 of the License, or (at your option) any later version. 12 | * A full copy of the GNU General Public License can be found in 13 | * LICENSE 14 | */ 15 | #pragma once 16 | 17 | #ifndef SOURCE_H 18 | #define SOURCE_H 19 | 20 | #include "always.h" 21 | 22 | enum SourceType 23 | { 24 | SOURCE_NORTH, 25 | SOURCE_EAST, 26 | SOURCE_SOUTH, 27 | SOURCE_WEST, 28 | SOURCE_AIR, 29 | 30 | SOURCE_COUNT, 31 | 32 | SOURCE_NONE = -1, 33 | SOURCE_FIRST = SOURCE_NORTH 34 | }; 35 | 36 | DEFINE_ENUMERATION_OPERATORS(SourceType); 37 | 38 | SourceType Source_From_Name(const char *name); 39 | const char *Name_From_Source(SourceType source); 40 | 41 | #endif // SOURCE_H 42 | -------------------------------------------------------------------------------- /src/game/engine/special.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author CCHyper 5 | * @author OmniBlade 6 | * @author tomsons26 7 | * 8 | * @brief Class holding various special options. 9 | * 10 | * @copyright Chronoshift is free software: you can redistribute it and/or 11 | * modify it under the terms of the GNU General Public License 12 | * as published by the Free Software Foundation, either version 13 | * 2 of the License, or (at your option) any later version. 14 | * A full copy of the GNU General Public License can be found in 15 | * LICENSE 16 | */ 17 | #include "special.h" 18 | 19 | #ifndef GAME_DLL 20 | SpecialClass s_Special; 21 | #endif 22 | -------------------------------------------------------------------------------- /src/game/engine/template.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author tomsons26 5 | * 6 | * @brief 7 | * 8 | * @copyright Chronoshift is free software: you can redistribute it and/or 9 | * modify it under the terms of the GNU General Public License 10 | * as published by the Free Software Foundation, either version 11 | * 2 of the License, or (at your option) any later version. 12 | * A full copy of the GNU General Public License can be found in 13 | * LICENSE 14 | */ 15 | #pragma once 16 | 17 | #ifndef TEMPLATE_H 18 | #define TEMPLATE_H 19 | 20 | #include "always.h" 21 | #include "object.h" 22 | #include "templatetype.h" 23 | 24 | class TemplateClass : public ObjectClass 25 | { 26 | public: 27 | TemplateClass(TemplateType type, cell_t cellnum = -1); 28 | TemplateClass(const TemplateClass &that); 29 | TemplateClass(const NoInitClass &noinit) : ObjectClass(noinit) {} 30 | virtual ~TemplateClass(); 31 | 32 | void *operator new(size_t size); 33 | void *operator new(size_t size, void *ptr) { return ptr; } 34 | void operator delete(void *ptr); 35 | #ifndef COMPILER_WATCOM // Watcom doesn't like this, MSVC/GCC does. 36 | void operator delete(void *ptr, void *place) {} 37 | #endif 38 | 39 | virtual const TemplateTypeClass &Class_Of() const override { return *m_Class; } 40 | virtual void Draw_It(int x, int y, WindowNumberType window) const override {} 41 | virtual BOOL Mark(MarkType mark) override; 42 | 43 | TemplateType What_Type() const { return m_Class->Get_Type(); } 44 | 45 | private: 46 | GamePtr m_Class; 47 | }; 48 | 49 | #ifdef GAME_DLL 50 | extern TFixedIHeapClass &g_Templates; 51 | #else 52 | extern TFixedIHeapClass g_Templates; 53 | #endif 54 | 55 | #endif // TEMPLATE_H 56 | -------------------------------------------------------------------------------- /src/game/engine/theater.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author OmniBlade 5 | * @author CCHyper 6 | * 7 | * @brief Functions for handling theater specific details. 8 | * 9 | * @copyright Chronoshift is free software: you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation, either version 12 | * 2 of the License, or (at your option) any later version. 13 | * A full copy of the GNU General Public License can be found in 14 | * LICENSE 15 | */ 16 | #include "theater.h" 17 | 18 | #ifdef HAVE_STRINGS_H 19 | #include 20 | #endif 21 | 22 | #ifndef GAME_DLL 23 | TheaterType g_LastTheater = THEATER_NONE; 24 | #endif 25 | 26 | TheaterDataType g_Theaters[THEATER_COUNT] = { 27 | {"TEMPERATE", "TEMPERAT", "TEM"}, 28 | {"SNOW", "SNOW", "SNO"}, 29 | {"INTERIOR", "INTERIOR", "INT"}, 30 | }; 31 | 32 | TheaterType Theater_From_Name(const char *name) 33 | { 34 | if (name != nullptr) { 35 | for (int i = 0; i < THEATER_COUNT; ++i) { 36 | if (strcasecmp(name, g_Theaters[i].name) == 0) { 37 | return TheaterType(i); 38 | } 39 | } 40 | } 41 | 42 | return THEATER_NONE; 43 | } 44 | 45 | const char *Name_From_Theater(TheaterType theater) 46 | { 47 | if (theater >= THEATER_NONE && theater < THEATER_COUNT) { 48 | return g_Theaters[theater].name; 49 | } 50 | 51 | return "none"; 52 | } 53 | -------------------------------------------------------------------------------- /src/game/engine/theater.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author OmniBlade 5 | * @author CCHyper 6 | * 7 | * @brief Functions for handling theater specific details. 8 | * 9 | * @copyright Chronoshift is free software: you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation, either version 12 | * 2 of the License, or (at your option) any later version. 13 | * A full copy of the GNU General Public License can be found in 14 | * LICENSE 15 | */ 16 | #pragma once 17 | 18 | #ifndef THEATER_H 19 | #define THEATER_H 20 | 21 | #include "always.h" 22 | 23 | // Type is saved and loaded as binary so needs fixed size. 24 | #ifdef COMPILER_WATCOM 25 | enum TheaterType 26 | #else 27 | enum TheaterType : int8_t 28 | #endif 29 | { 30 | THEATER_NONE = -1, 31 | THEATER_TEMPERATE, 32 | THEATER_SNOW, 33 | THEATER_INTERIOR, 34 | THEATER_COUNT, 35 | THEATER_DEFAULT = THEATER_TEMPERATE, 36 | }; 37 | 38 | enum TheaterBitEnum 39 | { 40 | THEATER_BIT_NONE = 0, 41 | THEATER_BIT_TEMPERATE = 1 << THEATER_TEMPERATE, 42 | THEATER_BIT_SNOW = 1 << THEATER_SNOW, 43 | THEATER_BIT_INTERIOR = 1 << THEATER_INTERIOR, 44 | THEATER_BIT_ALL = THEATER_BIT_TEMPERATE | THEATER_BIT_SNOW | THEATER_BIT_INTERIOR, 45 | }; 46 | 47 | struct TheaterDataType 48 | { 49 | const char name[16]; 50 | const char data[10]; 51 | const char ext[4]; 52 | }; 53 | 54 | TheaterType Theater_From_Name(const char *name); 55 | const char *Name_From_Theater(TheaterType theater); 56 | 57 | extern TheaterDataType g_Theaters[THEATER_COUNT]; 58 | 59 | #ifdef GAME_DLL 60 | #include "hooker.h" 61 | extern TheaterType &g_LastTheater; 62 | #else 63 | extern TheaterType g_LastTheater; 64 | #endif 65 | 66 | #endif // THEATER_H 67 | -------------------------------------------------------------------------------- /src/game/engine/tracker.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author CCHyper 5 | * @author OmniBlade 6 | * 7 | * @brief Function to detach a target from everything else in game. 8 | * 9 | * @copyright Chronoshift is free software: you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation, either version 12 | * 2 of the License, or (at your option) any later version. 13 | * A full copy of the GNU General Public License can be found in 14 | * LICENSE 15 | */ 16 | #pragma once 17 | 18 | #ifndef TRACKER_H 19 | #define TRACKER_H 20 | 21 | #include "always.h" 22 | #include "gametypes.h" 23 | 24 | void Detach_This_From_All(target_t target, BOOL a2 = true); 25 | 26 | #endif // TRACKER_H 27 | -------------------------------------------------------------------------------- /src/game/engine/unitdata.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author CCHyper 5 | * @author OmniBlade 6 | * 7 | * @brief Static instances of unit type objects. 8 | * 9 | * @copyright Chronoshift is free software: you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation, either version 12 | * 2 of the License, or (at your option) any later version. 13 | * A full copy of the GNU General Public License can be found in 14 | * LICENSE 15 | */ 16 | #pragma once 17 | 18 | #ifndef UNITDATA_H 19 | #define UNITDATA_H 20 | 21 | #include "always.h" 22 | #include "unittype.h" 23 | 24 | extern const UnitTypeClass UnitV2Launcher; 25 | extern const UnitTypeClass UnitLTank; 26 | extern const UnitTypeClass UnitMTank; 27 | extern const UnitTypeClass UnitMTank2; 28 | extern const UnitTypeClass UnitHTank; 29 | extern const UnitTypeClass UnitMRJammer; 30 | extern const UnitTypeClass UnitMGG; 31 | extern const UnitTypeClass UnitArty; 32 | extern const UnitTypeClass UnitHarvester; 33 | extern const UnitTypeClass UnitMCV; 34 | extern const UnitTypeClass UnitJeep; 35 | extern const UnitTypeClass UnitAPC; 36 | extern const UnitTypeClass UnitMineLayer; 37 | extern const UnitTypeClass UnitConvoyTruck; 38 | extern const UnitTypeClass UnitAnt1; 39 | extern const UnitTypeClass UnitAnt2; 40 | extern const UnitTypeClass UnitAnt3; 41 | extern const UnitTypeClass UnitChrono; 42 | extern const UnitTypeClass UnitTesla; 43 | extern const UnitTypeClass UnitMAD; 44 | extern const UnitTypeClass UnitDemoTruck; 45 | extern const UnitTypeClass UnitPhase; 46 | 47 | #endif // UNITDATA_H 48 | -------------------------------------------------------------------------------- /src/game/engine/utracker.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author tomsons26 5 | * 6 | * @brief Class for keeping track of various type counts and kills?. 7 | * 8 | * @copyright Chronoshift is free software: you can redistribute it and/or 9 | * modify it under the terms of the GNU General Public License 10 | * as published by the Free Software Foundation, either version 11 | * 2 of the License, or (at your option) any later version. 12 | * A full copy of the GNU General Public License can be found in 13 | * LICENSE 14 | */ 15 | #include "utracker.h" 16 | #include "endiantype.h" 17 | #include 18 | 19 | using std::memset; 20 | 21 | UnitTrackerClass::UnitTrackerClass(int count) 22 | { 23 | m_IsNetworkFormat = 0; 24 | m_Total = new unsigned int[count]; 25 | m_Count = count; 26 | Clear_Unit_Total(); 27 | } 28 | 29 | UnitTrackerClass::~UnitTrackerClass() 30 | { 31 | delete[] m_Total; 32 | } 33 | 34 | void UnitTrackerClass::Increment_Unit_Total(int unit) 35 | { 36 | ++m_Total[unit]; 37 | } 38 | 39 | void UnitTrackerClass::Decrement_Unit_Total(int unit) 40 | { 41 | --m_Total[unit]; 42 | } 43 | 44 | unsigned int *UnitTrackerClass::Get_All_Totals() 45 | { 46 | return m_Total; 47 | } 48 | 49 | void UnitTrackerClass::Clear_Unit_Total() 50 | { 51 | memset(m_Total, 0, sizeof(*m_Total) * m_Count); 52 | } 53 | 54 | void UnitTrackerClass::To_Network_Format() 55 | { 56 | if (!m_IsNetworkFormat) { 57 | for (int i = 0; i < m_Count; ++i) { 58 | m_Total[i] = htobe32(m_Total[i]); 59 | } 60 | } 61 | m_IsNetworkFormat = true; 62 | } 63 | 64 | void UnitTrackerClass::To_PC_Format() 65 | { 66 | if (m_IsNetworkFormat) { 67 | for (int i = 0; i < m_Count; ++i) { 68 | m_Total[i] = be32toh(m_Total[i]); 69 | } 70 | } 71 | m_IsNetworkFormat = false; 72 | } -------------------------------------------------------------------------------- /src/game/engine/utracker.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author tomsons26 5 | * 6 | * @brief Class for keeping track of various type counts and kills, 7 | * collected crate count and other counts. 8 | * 9 | * @copyright Chronoshift is free software: you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation, either version 12 | * 2 of the License, or (at your option) any later version. 13 | * A full copy of the GNU General Public License can be found in 14 | * LICENSE 15 | */ 16 | #pragma once 17 | 18 | #ifndef UTRACKER_H 19 | #define UTRACKER_H 20 | 21 | #include "always.h" 22 | 23 | class UnitTrackerClass 24 | { 25 | public: 26 | UnitTrackerClass(int count); 27 | ~UnitTrackerClass(); //dtor blank in YR 28 | void Increment_Unit_Total(int unit); 29 | void Decrement_Unit_Total(int unit); 30 | //New function in YR at 00749060 appears to populate unit count 31 | //New function in YR at 007490A0 appears to get populated unit count 32 | unsigned int *Get_All_Totals(); 33 | void Clear_Unit_Total(); 34 | void To_Network_Format(); 35 | void To_PC_Format(); 36 | 37 | private: 38 | unsigned int *m_Total; //unsigned int Total[512]; in YR 39 | int m_Count; 40 | BOOL m_IsNetworkFormat; 41 | }; 42 | 43 | #endif // UTRACKER_H -------------------------------------------------------------------------------- /src/game/engine/vesseldata.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author CCHyper 5 | * @author OmniBlade 6 | * 7 | * @brief Static instances of vessel type objects. 8 | * 9 | * @copyright Chronoshift is free software: you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation, either version 12 | * 2 of the License, or (at your option) any later version. 13 | * A full copy of the GNU General Public License can be found in 14 | * LICENSE 15 | */ 16 | #pragma once 17 | 18 | #ifndef VESSELDATA_H 19 | #define VESSELDATA_H 20 | 21 | #include "always.h" 22 | #include "vesseltype.h" 23 | 24 | extern const VesselTypeClass VesselSubmarine; 25 | extern const VesselTypeClass VesselDestroyer; 26 | extern const VesselTypeClass VesselCruiser; 27 | extern const VesselTypeClass VesselTransport; 28 | extern const VesselTypeClass VesselPTBoat; 29 | extern const VesselTypeClass VesselMissileSubmarine; 30 | extern const VesselTypeClass VesselHeliCarrier; 31 | 32 | #endif // VESSELDATA_H 33 | -------------------------------------------------------------------------------- /src/game/engine/warheaddata.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author CCHyper 5 | * @author OmniBlade 6 | * 7 | * @brief Static instances of warhead type objects. 8 | * 9 | * @copyright Chronoshift is free software: you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation, either version 12 | * 2 of the License, or (at your option) any later version. 13 | * A full copy of the GNU General Public License can be found in 14 | * LICENSE 15 | */ 16 | #include "warheaddata.h" 17 | 18 | /** 19 | * For reference, the constructor argument order is; 20 | * 21 | * Type (WarheadType) 22 | * Name 23 | * 24 | */ 25 | 26 | const WarheadTypeClass WarheadSmallArms(WARHEAD_SA, "SA"); 27 | const WarheadTypeClass WarheadHighExplosive(WARHEAD_HE, "HE"); 28 | const WarheadTypeClass WarheadArmorPiercing(WARHEAD_AP, "AP"); 29 | const WarheadTypeClass WarheadFire(WARHEAD_FIRE, "Fire"); 30 | const WarheadTypeClass WarheadHollowPoint(WARHEAD_HOLLOWPOINT, "HollowPoint"); 31 | const WarheadTypeClass WarheadSuper(WARHEAD_SUPER, "Super"); 32 | const WarheadTypeClass WarheadOrganic(WARHEAD_ORGANIC, "Organic"); 33 | const WarheadTypeClass WarheadNuke(WARHEAD_NUKE, "Nuke"); 34 | const WarheadTypeClass WarheadMechanical(WARHEAD_MECHANICAL, "Mechanical"); 35 | -------------------------------------------------------------------------------- /src/game/engine/warheaddata.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author CCHyper 5 | * @author OmniBlade 6 | * 7 | * @brief Static instances of warhead type objects. 8 | * 9 | * @copyright Chronoshift is free software: you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation, either version 12 | * 2 of the License, or (at your option) any later version. 13 | * A full copy of the GNU General Public License can be found in 14 | * LICENSE 15 | */ 16 | #pragma once 17 | 18 | #ifndef WARHEADDATA_H 19 | #define WARHEADDATA_H 20 | 21 | #include "always.h" 22 | #include "warheadtype.h" 23 | 24 | extern const WarheadTypeClass WarheadSmallArms; 25 | extern const WarheadTypeClass WarheadHighExplosive; 26 | extern const WarheadTypeClass WarheadArmorPiercing; 27 | extern const WarheadTypeClass WarheadFire; 28 | extern const WarheadTypeClass WarheadHollowPoint; 29 | extern const WarheadTypeClass WarheadSuper; 30 | extern const WarheadTypeClass WarheadOrganic; 31 | extern const WarheadTypeClass WarheadNuke; 32 | extern const WarheadTypeClass WarheadMechanical; 33 | 34 | #endif // WARHEADDATA_H 35 | -------------------------------------------------------------------------------- /src/game/gfx/blitters.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author CCHyper 5 | * @author OmniBlade 6 | * 7 | * @brief Low level software blitters. 8 | * 9 | * @copyright Chronoshift is free software: you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation, either version 12 | * 2 of the License, or (at your option) any later version. 13 | * A full copy of the GNU General Public License can be found in 14 | * LICENSE 15 | */ 16 | #pragma once 17 | 18 | #ifndef BLITTERS_H 19 | #define BLITTERS_H 20 | 21 | #include "always.h" 22 | #include "gbuffer.h" 23 | 24 | void __cdecl Buffer_Draw_Line(GraphicViewPortClass &vp, int x1, int y1, int x2, int y2, uint8_t color); 25 | void __cdecl Buffer_Fill_Rect(GraphicViewPortClass &vp, int x, int y, int w, int h, uint8_t color); 26 | void __cdecl Buffer_Remap(GraphicViewPortClass &vp, int x, int y, int w, int h, uint8_t *fading_table); 27 | int __cdecl Buffer_Get_Pixel(GraphicViewPortClass &vp, unsigned x, unsigned y); 28 | void __cdecl Buffer_Put_Pixel(GraphicViewPortClass &vp, unsigned x, unsigned y, uint8_t val); 29 | void __cdecl Linear_Blit_To_Linear(GraphicViewPortClass &src_vp, GraphicViewPortClass &dst_vp, int src_x, int src_y, 30 | int dst_x, int dst_y, int w, int h, bool use_key); 31 | void __cdecl Buffer_Clear(GraphicViewPortClass &vp, uint8_t color); 32 | void __cdecl Buffer_To_Buffer(GraphicViewPortClass &vp, int x, int y, int w, int h, void *buffer, int length); 33 | void __cdecl Buffer_To_Page(int x, int y, int w, int h, void *buffer, GraphicViewPortClass &vp); 34 | void __cdecl Linear_Scale_To_Linear(GraphicViewPortClass &src_vp, GraphicViewPortClass &dst_vp, int src_x, int src_y, 35 | int dst_x, int dst_y, int src_w, int src_h, int dst_w, int dst_h, bool use_keysrc, void *fade); 36 | 37 | #endif // BLITTERS_H 38 | -------------------------------------------------------------------------------- /src/game/gfx/drawshape.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author CCHyper 5 | * @author OmniBlade 6 | * 7 | * @brief Low level functions for loading and rendering C&C sprite files. 8 | * 9 | * @copyright Chronoshift is free software: you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation, either version 12 | * 2 of the License, or (at your option) any later version. 13 | * A full copy of the GNU General Public License can be found in 14 | * LICENSE 15 | */ 16 | #pragma once 17 | 18 | #ifndef DRAWSHAPE_H 19 | #define DRAWSHAPE_H 20 | 21 | #include "facing.h" 22 | #include "dialog.h" 23 | #include "shape.h" 24 | 25 | void CC_Draw_Shape(void *shape, int frame, int draw_x, int draw_y, WindowNumberType window_num = WINDOW_0, 26 | ShapeFlags flags = SHAPE_NORMAL, void *fading_table = nullptr, void *ghost_table = nullptr, DirType angle = DIR_NORTH, 27 | int scale = 256); 28 | 29 | #endif // DRAWSHAPE_H 30 | -------------------------------------------------------------------------------- /src/game/gfx/fading.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author OmniBlade 5 | * 6 | * @brief Functions for building the color lookup tables to simulate transparency. 7 | * 8 | * @copyright Chronoshift is free software: you can redistribute it and/or 9 | * modify it under the terms of the GNU General Public License 10 | * as published by the Free Software Foundation, either version 11 | * 2 of the License, or (at your option) any later version. 12 | * A full copy of the GNU General Public License can be found in 13 | * LICENSE 14 | */ 15 | #pragma once 16 | 17 | #ifndef FADING_H 18 | #define FADING_H 19 | 20 | #include "always.h" 21 | 22 | class PaletteClass; 23 | 24 | struct TLucentType 25 | { 26 | uint8_t PaletteIndex; 27 | uint8_t FadeColor; 28 | uint8_t FadeFraction; 29 | uint8_t __UnknownValue; // Probably padding as orignal was compiled with alignment 1 30 | }; 31 | 32 | inline int Translucent_Table_Size(int table_count) 33 | { 34 | return (table_count << 8) + 256; 35 | } 36 | 37 | void *Make_Fading_Table(const PaletteClass &palette, void *fade_table, int color, int frac); 38 | void *__cdecl Build_Fading_Table(const PaletteClass &palette, void *fade_table, int color, int frac); 39 | void *Conquer_Build_Fading_Table(const PaletteClass &palette, void *fade_table, int color, int frac); 40 | void *Build_Translucent_Table(PaletteClass &palette, const TLucentType *type, int tab_count, void *table); 41 | void *Conquer_Build_Translucent_Table(PaletteClass &palette, const TLucentType *type, int tab_count, void *table); 42 | 43 | #endif // FADING_H 44 | -------------------------------------------------------------------------------- /src/game/gfx/pal.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author OmniBlade 5 | * 6 | * @brief Low level palette handling. 7 | * 8 | * @copyright Chronoshift is free software: you can redistribute it and/or 9 | * modify it under the terms of the GNU General Public License 10 | * as published by the Free Software Foundation, either version 11 | * 2 of the License, or (at your option) any later version. 12 | * A full copy of the GNU General Public License can be found in 13 | * LICENSE 14 | */ 15 | #include "pal.h" 16 | #include "initvideo.h" 17 | #include 18 | 19 | using std::memcpy; 20 | 21 | #ifndef GAME_DLL 22 | uint8_t g_CurrentPalette[768]; 23 | #endif 24 | 25 | void Set_Palette(void *pal) 26 | { 27 | memcpy(g_CurrentPalette, pal, 768); 28 | Set_Video_Palette(pal); 29 | } 30 | -------------------------------------------------------------------------------- /src/game/gfx/pal.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author OmniBlade 5 | * 6 | * @brief Low level palette handling. 7 | * 8 | * @copyright Chronoshift is free software: you can redistribute it and/or 9 | * modify it under the terms of the GNU General Public License 10 | * as published by the Free Software Foundation, either version 11 | * 2 of the License, or (at your option) any later version. 12 | * A full copy of the GNU General Public License can be found in 13 | * LICENSE 14 | */ 15 | #pragma once 16 | 17 | #ifndef PAL_H 18 | #define PAL_H 19 | 20 | #include "always.h" 21 | 22 | #ifdef GAME_DLL 23 | extern uint8_t *g_CurrentPalette; 24 | #else 25 | extern uint8_t g_CurrentPalette[]; 26 | #endif 27 | 28 | void Set_Palette(void *pal); 29 | 30 | #endif // PAL_H 31 | -------------------------------------------------------------------------------- /src/game/gfx/surfacemonitor.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author tomsons26 5 | * 6 | * @brief Class for managing surfaces and their states. 7 | * 8 | * @copyright Chronoshift is free software: you can redistribute it and/or 9 | * modify it under the terms of the GNU General Public License 10 | * as published by the Free Software Foundation, either version 11 | * 2 of the License, or (at your option) any later version. 12 | * A full copy of the GNU General Public License can be found in 13 | * LICENSE 14 | */ 15 | #pragma once 16 | 17 | #ifndef SURFACEMONITOR_H 18 | #define SURFACEMONITOR_H 19 | #include "always.h" 20 | 21 | #ifdef BUILD_WITH_DDRAW 22 | #include 23 | #endif 24 | 25 | class SurfaceMonitorClass 26 | { 27 | enum 28 | { 29 | SURFACE_COUNT = 20, 30 | }; 31 | 32 | public: 33 | SurfaceMonitorClass(); 34 | ~SurfaceMonitorClass(); 35 | #ifdef BUILD_WITH_DDRAW 36 | void Add_Surface(LPDIRECTDRAWSURFACE new_surface); 37 | void Remove_Surface(LPDIRECTDRAWSURFACE old_surface); 38 | bool Got_Surface_Already(LPDIRECTDRAWSURFACE test_surface); 39 | #endif 40 | void Restore_Surfaces(); 41 | void Set_Surface_Focus(bool focus); 42 | void Release(); 43 | BOOL Surfaces_Restored() const { return m_SurfacesRestored; } 44 | void Clear_Surfaces_Restored() { m_SurfacesRestored = false; } 45 | 46 | private: 47 | BOOL m_SurfacesRestored; 48 | #ifdef BUILD_WITH_DDRAW 49 | LPDIRECTDRAWSURFACE m_Surface[SURFACE_COUNT]; 50 | #endif 51 | BOOL m_InFocus; 52 | }; 53 | 54 | #ifdef GAME_DLL 55 | extern void (*&g_MiscFocusLoss)(); 56 | extern void (*&g_MiscFocusRestore)(); 57 | extern SurfaceMonitorClass &g_AllSurfaces; 58 | #else 59 | extern void (*g_MiscFocusLoss)(); 60 | extern void (*g_MiscFocusRestore)(); 61 | extern SurfaceMonitorClass g_AllSurfaces; 62 | #endif 63 | 64 | #endif // SURFACEMONITOR_H 65 | -------------------------------------------------------------------------------- /src/game/io/b64pipe.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author CCHyper 5 | * @author OmniBlade 6 | * 7 | * @brief Pipe interface for writing Base64 encoded data. 8 | * 9 | * @copyright Chronoshift is free software: you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation, either version 12 | * 2 of the License, or (at your option) any later version. 13 | * A full copy of the GNU General Public License can be found in 14 | * LICENSE 15 | */ 16 | #pragma once 17 | 18 | #ifndef BASE64PIPE_H 19 | #define BASE64PIPE_H 20 | 21 | #include "always.h" 22 | #include "pipe.h" 23 | 24 | class Base64Pipe : public Pipe 25 | { 26 | public: 27 | Base64Pipe(PipeControl control = PIPE_ENCODE) : m_Mode(control), m_Counter(0) {} 28 | virtual ~Base64Pipe() {} 29 | 30 | virtual int Flush() override; 31 | virtual int Put(const void *source, int slen) override; 32 | 33 | private: 34 | PipeControl m_Mode; 35 | int m_Counter; 36 | char m_CBuffer[4]; 37 | char m_PBuffer[3]; 38 | }; 39 | 40 | #endif // BASE64PIPE_H 41 | -------------------------------------------------------------------------------- /src/game/io/b64straw.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author CCHyper 5 | * @author OmniBlade 6 | * 7 | * @brief Straw interface for reading Base64 encoded data. 8 | * 9 | * @copyright Chronoshift is free software: you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation, either version 12 | * 2 of the License, or (at your option) any later version. 13 | * A full copy of the GNU General Public License can be found in 14 | * LICENSE 15 | */ 16 | #pragma once 17 | 18 | #ifndef B64STRAW_H 19 | #define B64STRAW_H 20 | 21 | #include "always.h" 22 | #include "straw.h" 23 | 24 | class Base64Straw : public Straw 25 | { 26 | public: 27 | Base64Straw(StrawControl mode = STRAW_DECODE) : m_Mode(mode), m_Counter(0) {} 28 | virtual ~Base64Straw() {} 29 | 30 | virtual int Get(void *dest, int slen) override; 31 | 32 | private: 33 | StrawControl m_Mode; 34 | int m_Counter; 35 | char m_CBuffer[4]; 36 | char m_PBuffer[3]; 37 | }; 38 | 39 | #endif // B64STRAW_H 40 | -------------------------------------------------------------------------------- /src/game/io/basefile.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author CCHyper 5 | * @author OmniBlade 6 | * 7 | * @brief FileClass pure virtual base class providing the file io interface. 8 | * 9 | * @copyright Chronoshift is free software: you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation, either version 12 | * 2 of the License, or (at your option) any later version. 13 | * A full copy of the GNU General Public License can be found in 14 | * LICENSE 15 | */ 16 | #include "basefile.h" 17 | 18 | time_t FileClass::Get_Date_Time() 19 | { 20 | return 0; 21 | } 22 | 23 | BOOL FileClass::Set_Date_Time(time_t date_time) 24 | { 25 | return false; 26 | } 27 | -------------------------------------------------------------------------------- /src/game/io/blowpipe.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author CCHyper 5 | * @author OmniBlade 6 | * 7 | * @brief Pipe stream class implementation writing data processed with the blowfish algorithm. 8 | * 9 | * @copyright Chronoshift is free software: you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation, either version 12 | * 2 of the License, or (at your option) any later version. 13 | * A full copy of the GNU General Public License can be found in 14 | * LICENSE 15 | */ 16 | #pragma once 17 | 18 | #ifndef BLOWPIPE_H 19 | #define BLOWPIPE_H 20 | 21 | #include "blowfish.h" 22 | #include "pipe.h" 23 | 24 | class BlowPipe : public Pipe 25 | { 26 | public: 27 | BlowPipe(PipeControl mode = PIPE_ENCRYPT) : m_BlowFish(nullptr), m_Carryover(0), m_Mode(mode) {} 28 | virtual ~BlowPipe(); 29 | 30 | virtual int Flush() override; 31 | virtual int Put(const void *buffer, int length) override; 32 | 33 | void Key(void *key, int key_size); 34 | 35 | private: 36 | BlowfishEngine *m_BlowFish; 37 | char m_CurrentBlock[BF_BLOCKSIZE]; 38 | int m_Carryover; 39 | PipeControl m_Mode; 40 | }; 41 | 42 | #endif // BLOWPIPE_H 43 | -------------------------------------------------------------------------------- /src/game/io/blowstraw.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author CCHyper 5 | * @author OmniBlade 6 | * 7 | * @brief Straw stream class implementation reading data processed with the blowfish algorithm. 8 | * 9 | * @copyright Chronoshift is free software: you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation, either version 12 | * 2 of the License, or (at your option) any later version. 13 | * A full copy of the GNU General Public License can be found in 14 | * LICENSE 15 | */ 16 | #pragma once 17 | 18 | #ifndef BLOWSTRAW_H 19 | #define BLOWSTRAW_H 20 | 21 | #include "blowfish.h" 22 | #include "straw.h" 23 | 24 | class BlowStraw : public Straw 25 | { 26 | public: 27 | BlowStraw(StrawControl mode = STRAW_DECRYPT) : m_BlowFish(nullptr), m_Carryover(0), m_Mode(mode) {} 28 | virtual ~BlowStraw(); 29 | 30 | virtual int Get(void *buffer, int length) override; 31 | 32 | void Key(void *key, int key_size); 33 | 34 | private: 35 | BlowfishEngine *m_BlowFish; 36 | char m_CurrentBlock[BF_BLOCKSIZE]; 37 | int m_Carryover; 38 | StrawControl m_Mode; 39 | }; 40 | 41 | #endif // BLOWSTRAW_H 42 | -------------------------------------------------------------------------------- /src/game/io/buffpipe.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author CCHyper 5 | * @author OmniBlade 6 | * 7 | * @brief Pipe stream class implementation writing data to a memory buffer. 8 | * 9 | * @copyright Chronoshift is free software: you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation, either version 12 | * 2 of the License, or (at your option) any later version. 13 | * A full copy of the GNU General Public License can be found in 14 | * LICENSE 15 | */ 16 | #include "buffpipe.h" 17 | #include 18 | #include 19 | 20 | /** 21 | * @brief Writes data from the provided buffer to the underlying buffer class. 22 | */ 23 | int BufferPipe::Put(const void *buffer, int length) 24 | { 25 | if (!m_Buffer.Get_Buffer() || !buffer || length <= 0) { 26 | return 0; 27 | } 28 | 29 | int buff_size = m_Buffer.Get_Size(); 30 | int size = length; 31 | 32 | if (buff_size) { 33 | buff_size -= m_Index; 34 | size = std::min(size, buff_size); 35 | } 36 | 37 | if (size > 0) { 38 | memmove(m_Buffer.Get_Buffer() + m_Index, buffer, size); 39 | } 40 | 41 | m_Index += size; 42 | 43 | return size; 44 | } 45 | -------------------------------------------------------------------------------- /src/game/io/buffpipe.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author CCHyper 5 | * @author OmniBlade 6 | * 7 | * @brief Pipe stream class implementation writing data to a memory buffer. 8 | * 9 | * @copyright Chronoshift is free software: you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation, either version 12 | * 2 of the License, or (at your option) any later version. 13 | * A full copy of the GNU General Public License can be found in 14 | * LICENSE 15 | */ 16 | #pragma once 17 | 18 | #ifndef BUFFPIPE_H 19 | #define BUFFPIPE_H 20 | 21 | #include "always.h" 22 | #include "buffer.h" 23 | #include "pipe.h" 24 | 25 | class BufferPipe : public Pipe 26 | { 27 | public: 28 | BufferPipe(void *buffer, int length) : m_Buffer(buffer, length), m_Index(0) {} 29 | virtual ~BufferPipe() {} 30 | 31 | virtual int Put(const void *buffer, int length) override; 32 | 33 | bool Is_Valid() { return m_Buffer.Is_Valid(); } 34 | 35 | private: 36 | BufferClass m_Buffer; 37 | int m_Index; 38 | }; 39 | 40 | #endif // BUFFPIPE_H 41 | -------------------------------------------------------------------------------- /src/game/io/buffstraw.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author CCHyper 5 | * @author OmniBlade 6 | * 7 | * @brief Straw stream class implementation reading data from a memory buffer. 8 | * 9 | * @copyright Chronoshift is free software: you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation, either version 12 | * 2 of the License, or (at your option) any later version. 13 | * A full copy of the GNU General Public License can be found in 14 | * LICENSE 15 | */ 16 | #include "buffstraw.h" 17 | #include 18 | #include 19 | 20 | /** 21 | * @brief Reads data to the provided buffer from the underlying buffer class. 22 | */ 23 | int BufferStraw::Get(void *buffer, int length) 24 | { 25 | if (!m_Buffer.Get_Buffer() || !buffer || length <= 0) { 26 | return 0; 27 | } 28 | 29 | int read_len = m_Buffer.Get_Size(); 30 | 31 | if (read_len) { 32 | read_len -= m_Index; 33 | read_len = std::min(length, read_len); 34 | } 35 | 36 | if (read_len > 0) { 37 | memmove(buffer, m_Buffer.Get_Buffer() + m_Index, read_len); 38 | } 39 | 40 | m_Index += read_len; 41 | 42 | return read_len; 43 | } 44 | -------------------------------------------------------------------------------- /src/game/io/buffstraw.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author CCHyper 5 | * @author OmniBlade 6 | * 7 | * @brief Straw stream class implementation reading data from a memory buffer. 8 | * 9 | * @copyright Chronoshift is free software: you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation, either version 12 | * 2 of the License, or (at your option) any later version. 13 | * A full copy of the GNU General Public License can be found in 14 | * LICENSE 15 | */ 16 | #pragma once 17 | 18 | #ifndef BUFFSTRAW_H 19 | #define BUFFSTRAW_H 20 | 21 | #include "always.h" 22 | #include "buffer.h" 23 | #include "straw.h" 24 | 25 | class BufferStraw : public Straw 26 | { 27 | public: 28 | BufferStraw(void *buffer, int length) : m_Buffer((uint8_t *)buffer, length), m_Index(0) {} 29 | virtual ~BufferStraw() {} 30 | 31 | virtual int Get(void *buffer, int length) override; 32 | 33 | bool Is_Valid() { return m_Buffer.Is_Valid(); } 34 | 35 | private: 36 | BufferClass m_Buffer; 37 | int m_Index; 38 | }; 39 | 40 | #endif // BUFFSTRAW_H 41 | -------------------------------------------------------------------------------- /src/game/io/cd.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author OmniBlade 5 | * 6 | * @brief Disk change handling. 7 | * 8 | * @copyright Chronoshift is free software: you can redistribute it and/or 9 | * modify it under the terms of the GNU General Public License 10 | * as published by the Free Software Foundation, either version 11 | * 2 of the License, or (at your option) any later version. 12 | * A full copy of the GNU General Public License can be found in 13 | * LICENSE 14 | */ 15 | #pragma once 16 | 17 | #ifndef CD_H 18 | #define CD_H 19 | 20 | #include "always.h" 21 | 22 | enum DiskType 23 | { 24 | DISK_ANY = -2, // Any disk or none at all. 25 | DISK_CDCHECK = -1, // Any disk, but must have a disk in drive. Acts as no-cd check. 26 | DISK_FIRST = 0, 27 | DISK_ALLIED = 0, 28 | DISK_SOVIET, 29 | DISK_COUNTERSTRIKE, 30 | DISK_AFTERMATH, 31 | DISK_EXPANSION, // Either CS or AM. If neither is already in, it will ask for AM. 32 | DISK_DVD, // Unused as DVD was never released. 33 | DISK_COUNT, 34 | }; 35 | 36 | int Get_CD_Index(int drive, int delay); 37 | BOOL Force_CD_Available(int cd); 38 | 39 | #ifdef GAME_DLL 40 | extern int &g_CurrentCD; 41 | extern int &g_RequiredCD; 42 | #else 43 | extern int g_CurrentCD; 44 | extern int g_RequiredCD; 45 | #endif 46 | 47 | #endif // CD_H 48 | -------------------------------------------------------------------------------- /src/game/io/filepipe.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author CCHyper 5 | * @author OmniBlade 6 | * 7 | * @brief Pipe stream class implementation writing data to a file. 8 | * 9 | * @copyright Chronoshift is free software: you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation, either version 12 | * 2 of the License, or (at your option) any later version. 13 | * A full copy of the GNU General Public License can be found in 14 | * LICENSE 15 | */ 16 | #include "filepipe.h" 17 | #include "basefile.h" 18 | 19 | FilePipe::~FilePipe() 20 | { 21 | if (Valid_File() && m_HasOpened) { 22 | // Close the file if it is open. 23 | m_File->Close(); 24 | 25 | // Reset members. 26 | m_HasOpened = false; 27 | m_File = nullptr; 28 | } 29 | } 30 | 31 | /** 32 | * @brief Finishes writing any cached data from the stream chain and closes the file. 33 | */ 34 | int FilePipe::End() 35 | { 36 | int retval = Flush(); 37 | 38 | if (Valid_File() && m_HasOpened) { 39 | m_File->Close(); 40 | m_HasOpened = false; 41 | } 42 | 43 | return retval; 44 | } 45 | 46 | /** 47 | * @brief Writes data from the buffer to the underlying file class. 48 | */ 49 | int FilePipe::Put(const void *buffer, int length) 50 | { 51 | if (Valid_File() && buffer != nullptr && length > 0) { 52 | if (!m_File->Is_Open()) { 53 | // If file doesn't exist open it? 54 | if (!m_File->Is_Available()) { 55 | m_File->Open(FM_WRITE); 56 | } else { 57 | // open it anyhow to overwrite? 58 | m_File->Open(FM_WRITE); 59 | } 60 | 61 | m_HasOpened = true; 62 | } 63 | 64 | return m_File->Write(buffer, length); 65 | } 66 | 67 | return 0; 68 | } 69 | -------------------------------------------------------------------------------- /src/game/io/filepipe.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author CCHyper 5 | * @author OmniBlade 6 | * 7 | * @brief Pipe stream class implementation writing data to a file. 8 | * 9 | * @copyright Chronoshift is free software: you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation, either version 12 | * 2 of the License, or (at your option) any later version. 13 | * A full copy of the GNU General Public License can be found in 14 | * LICENSE 15 | */ 16 | #pragma once 17 | 18 | #ifndef FILEPIPE_H 19 | #define FILEPIPE_H 20 | 21 | #include "always.h" 22 | #include "pipe.h" 23 | 24 | class FileClass; 25 | 26 | class FilePipe : public Pipe 27 | { 28 | public: 29 | FilePipe() : m_File(nullptr), m_HasOpened(false) {} 30 | FilePipe(FileClass &file) : m_File(&file), m_HasOpened(false) {} 31 | FilePipe(FileClass *file) : m_File(file), m_HasOpened(false) {} 32 | virtual ~FilePipe(); 33 | 34 | virtual int Put(const void *buffer, int length) override; 35 | virtual int End() override; 36 | 37 | private: 38 | bool Valid_File() { return m_File != nullptr; }; 39 | 40 | private: 41 | FileClass *m_File; 42 | BOOL m_HasOpened; 43 | }; 44 | 45 | #endif // FILEPIPE_H 46 | -------------------------------------------------------------------------------- /src/game/io/filestraw.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author CCHyper 5 | * @author OmniBlade 6 | * 7 | * @brief Straw stream class implementation reading data from a file. 8 | * 9 | * @copyright Chronoshift is free software: you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation, either version 12 | * 2 of the License, or (at your option) any later version. 13 | * A full copy of the GNU General Public License can be found in 14 | * LICENSE 15 | */ 16 | #include "filestraw.h" 17 | #include "basefile.h" 18 | 19 | FileStraw::~FileStraw() 20 | { 21 | if (Valid_File() && m_HasOpened) { 22 | m_File->Close(); 23 | m_HasOpened = false; 24 | m_File = nullptr; 25 | } 26 | } 27 | 28 | /** 29 | * @brief Reads data to the buffer from the underlying file class. 30 | */ 31 | int FileStraw::Get(void *buffer, int length) 32 | { 33 | if (Valid_File() && buffer && length > 0) { 34 | if (!m_File->Is_Open()) { 35 | if (m_File->Is_Available()) { 36 | m_HasOpened = m_File->Open(FM_READ); 37 | } 38 | } 39 | 40 | return m_File->Read(buffer, length); 41 | } 42 | 43 | return 0; 44 | } 45 | -------------------------------------------------------------------------------- /src/game/io/filestraw.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author CCHyper 5 | * @author OmniBlade 6 | * 7 | * @brief Straw stream class implementation reading data from a file. 8 | * 9 | * @copyright Chronoshift is free software: you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation, either version 12 | * 2 of the License, or (at your option) any later version. 13 | * A full copy of the GNU General Public License can be found in 14 | * LICENSE 15 | */ 16 | #pragma once 17 | 18 | #ifndef FILESTRAW_H 19 | #define FILESTRAW_H 20 | 21 | #include "always.h" 22 | #include "straw.h" 23 | 24 | class FileClass; 25 | 26 | class FileStraw : public Straw 27 | { 28 | public: 29 | FileStraw() : m_File(nullptr), m_HasOpened(false) {} 30 | FileStraw(FileClass &file) : m_File(&file), m_HasOpened(false) {} 31 | FileStraw(FileClass *file) : m_File(file), m_HasOpened(false) {} 32 | virtual ~FileStraw(); 33 | 34 | virtual int Get(void *buffer, int length) override; 35 | 36 | private: 37 | bool Valid_File() { return m_File != nullptr; } 38 | 39 | private: 40 | FileClass *m_File; 41 | BOOL m_HasOpened; 42 | }; 43 | 44 | #endif // FILESTRAW_H 45 | -------------------------------------------------------------------------------- /src/game/io/lcwpipe.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author CCHyper 5 | * @author OmniBlade 6 | * 7 | * @brief Pipe interface for writing LCW encoded data. 8 | * 9 | * @copyright Chronoshift is free software: you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation, either version 12 | * 2 of the License, or (at your option) any later version. 13 | * A full copy of the GNU General Public License can be found in 14 | * LICENSE 15 | */ 16 | #pragma once 17 | 18 | #ifndef LCWPIPE_H 19 | #define LCWPIPE_H 20 | 21 | #include "always.h" 22 | #include "pipe.h" 23 | 24 | #define LCW_DEFAULT_SIZE 8192 25 | 26 | class LCWPipe : public Pipe 27 | { 28 | public: 29 | LCWPipe(PipeControl mode = PIPE_COMPRESS, int size = LCW_DEFAULT_SIZE); 30 | virtual ~LCWPipe(); 31 | 32 | virtual int Flush() override; 33 | virtual int Put(const void *buffer, int length) override; 34 | 35 | private: 36 | PipeControl m_Mode; 37 | int m_DataInBuffer; 38 | uint8_t *m_InBuffer; 39 | uint8_t *m_OutBuffer; 40 | int m_BlockSize; 41 | int m_MaxBlockSize; 42 | int16_t m_CompressedBytes; 43 | int16_t m_UncompressedBytes; 44 | }; 45 | 46 | #endif // LCWPIPE_H 47 | -------------------------------------------------------------------------------- /src/game/io/lcwstraw.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author CCHyper 5 | * @author OmniBlade 6 | * 7 | * @brief Straw interface for reading LCW encoded data. 8 | * 9 | * @copyright Chronoshift is free software: you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation, either version 12 | * 2 of the License, or (at your option) any later version. 13 | * A full copy of the GNU General Public License can be found in 14 | * LICENSE 15 | */ 16 | #pragma once 17 | 18 | #ifndef LCWSTRAW_H 19 | #define LCWSTRAW_H 20 | 21 | #include "always.h" 22 | #include "straw.h" 23 | 24 | #define LCW_DEFAULT_SIZE 8192 25 | 26 | class LCWStraw : public Straw 27 | { 28 | public: 29 | LCWStraw(StrawControl mode = STRAW_DECODE, int size = LCW_DEFAULT_SIZE); 30 | virtual ~LCWStraw(); 31 | 32 | virtual int Get(void *buffer, int length) override; 33 | 34 | private: 35 | StrawControl m_Mode; 36 | int m_Carryover; 37 | uint8_t *m_InBuffer; 38 | uint8_t *m_OutBuffer; 39 | int m_BlockSize; 40 | int m_CompressedBlockSize; 41 | int16_t m_CompressedBytes; 42 | int16_t m_UncompressedBytes; 43 | }; 44 | 45 | #endif // LCWSTRAW_H 46 | -------------------------------------------------------------------------------- /src/game/io/lzopipe.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author CCHyper 5 | * @author OmniBlade 6 | * 7 | * @brief Pipe interface for writing LZO encoded data. 8 | * 9 | * @copyright Chronoshift is free software: you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation, either version 12 | * 2 of the License, or (at your option) any later version. 13 | * A full copy of the GNU General Public License can be found in 14 | * LICENSE 15 | */ 16 | #pragma once 17 | 18 | #ifndef LZOPIPE_H 19 | #define LZOPIPE_H 20 | 21 | #include "always.h" 22 | #include "pipe.h" 23 | 24 | class LZOPipe : public Pipe 25 | { 26 | public: 27 | LZOPipe(PipeControl mode, int size = 0); 28 | virtual ~LZOPipe(); 29 | 30 | virtual int Flush(); 31 | virtual int Put(const void *source, int length); 32 | 33 | private: 34 | PipeControl m_Mode; 35 | int m_DataInBuffer; 36 | uint8_t *m_InBuffer; 37 | uint8_t *m_OutBuffer; 38 | int m_BlockSize; 39 | int m_MaxBlockSize; 40 | int16_t m_CompressedBytes; 41 | int16_t m_UncompressedBytes; 42 | }; 43 | 44 | #endif // LZOPIPE_H 45 | -------------------------------------------------------------------------------- /src/game/io/lzostraw.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author CCHyper 5 | * @author OmniBlade 6 | * 7 | * @brief Straw interface for reading LZO encoded data. 8 | * 9 | * @copyright Chronoshift is free software: you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation, either version 12 | * 2 of the License, or (at your option) any later version. 13 | * A full copy of the GNU General Public License can be found in 14 | * LICENSE 15 | */ 16 | #pragma once 17 | 18 | #ifndef LZOSTRAW_H 19 | #define LZOSTRAW_H 20 | 21 | #include "always.h" 22 | #include "straw.h" 23 | 24 | class LZOStraw : public Straw 25 | { 26 | public: 27 | LZOStraw(StrawControl mode, int size = 0); 28 | virtual ~LZOStraw(); 29 | 30 | virtual int Get(void *buffer, int length) override; 31 | 32 | private: 33 | StrawControl m_Mode; 34 | int m_Carryover; 35 | uint8_t *m_InBuffer; 36 | uint8_t *m_OutBuffer; 37 | int m_BlockSize; 38 | int m_CompressedBlockSize; 39 | int16_t m_CompressedBytes; 40 | int16_t m_UncompressedBytes; 41 | }; 42 | 43 | #endif // LZOSTRAW_H 44 | -------------------------------------------------------------------------------- /src/game/io/mixfile.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author CCHyper 5 | * @author OmniBlade 6 | * 7 | * @brief Handles the "Mix" file archives used by Westwood games. 8 | * 9 | * @copyright Chronoshift is free software: you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation, either version 12 | * 2 of the License, or (at your option) any later version. 13 | * A full copy of the GNU General Public License can be found in 14 | * LICENSE 15 | */ 16 | #include "mixfile.h" 17 | #include "gamefile.h" 18 | 19 | // Explicit template instantiation. 20 | template class MixFileClass; 21 | -------------------------------------------------------------------------------- /src/game/io/pcxpipe.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author OmniBlade 5 | * 6 | * @brief Pipe stream interface for writing PCX RLE compressed data. 7 | * 8 | * @copyright Chronoshift is free software: you can redistribute it and/or 9 | * modify it under the terms of the GNU General Public License 10 | * as published by the Free Software Foundation, either version 11 | * 2 of the License, or (at your option) any later version. 12 | * A full copy of the GNU General Public License can be found in 13 | * LICENSE 14 | */ 15 | #pragma once 16 | 17 | #ifndef PCXPIPE_H 18 | #define PCXPIPE_H 19 | 20 | #include "always.h" 21 | #include "pipe.h" 22 | 23 | #define RLE_DEFAULT_SIZE 640 24 | 25 | class PCXPipe : public Pipe 26 | { 27 | public: 28 | PCXPipe(PipeControl mode, int size = RLE_DEFAULT_SIZE); 29 | virtual ~PCXPipe(); 30 | virtual int Flush() override; 31 | virtual int Put(const void *buffer, int length) override; 32 | 33 | private: 34 | PipeControl m_Mode; 35 | int m_LineLength; 36 | int m_Carryover; 37 | int m_Remaining; 38 | uint8_t *m_InBuffer; 39 | uint8_t *m_OutBuffer; 40 | }; 41 | 42 | #endif // PCXPIPE_H 43 | -------------------------------------------------------------------------------- /src/game/io/pcxstraw.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author OmniBlade 5 | * 6 | * @brief Straw stream interface for reading PCX RLE compressed data. 7 | * 8 | * @copyright Chronoshift is free software: you can redistribute it and/or 9 | * modify it under the terms of the GNU General Public License 10 | * as published by the Free Software Foundation, either version 11 | * 2 of the License, or (at your option) any later version. 12 | * A full copy of the GNU General Public License can be found in 13 | * LICENSE 14 | */ 15 | #pragma once 16 | 17 | #ifndef PCXSTRAW_H 18 | #define PCXSTRAW_H 19 | 20 | #include "always.h" 21 | #include "straw.h" 22 | 23 | #define RLE_DEFAULT_LINE_LENGTH 640 24 | 25 | class PCXStraw : public Straw 26 | { 27 | public: 28 | PCXStraw(StrawControl mode, unsigned pitch = RLE_DEFAULT_LINE_LENGTH, unsigned width = RLE_DEFAULT_LINE_LENGTH); 29 | virtual ~PCXStraw(); 30 | 31 | virtual int Get(void *buffer, int length) override; 32 | 33 | private: 34 | StrawControl m_Mode; 35 | int m_LinePitch; 36 | int m_LineWidth; 37 | int m_Carryover; 38 | int m_Remaining; 39 | uint8_t *m_InBuffer; 40 | uint8_t *m_OutBuffer; 41 | }; 42 | 43 | #endif // _RLESTRAW_H_ 44 | -------------------------------------------------------------------------------- /src/game/io/pipe.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author CCHyper 5 | * @author OmniBlade 6 | * 7 | * @brief Base class for output stream classes. 8 | * 9 | * @copyright Chronoshift is free software: you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation, either version 12 | * 2 of the License, or (at your option) any later version. 13 | * A full copy of the GNU General Public License can be found in 14 | * LICENSE 15 | */ 16 | #include "pipe.h" 17 | #include 18 | 19 | Pipe::~Pipe() 20 | { 21 | if (m_ChainTo != nullptr) { 22 | m_ChainTo->m_ChainFrom = m_ChainFrom; 23 | } 24 | 25 | if (m_ChainFrom != nullptr) { 26 | m_ChainFrom->Put_To(m_ChainTo); 27 | } 28 | 29 | m_ChainTo = nullptr; 30 | m_ChainFrom = nullptr; 31 | } 32 | 33 | void Pipe::Put_To(Pipe *pipe) 34 | { 35 | if (m_ChainTo != pipe) { 36 | if (pipe != nullptr && pipe->m_ChainFrom != nullptr) { 37 | pipe->m_ChainFrom->Put_To(nullptr); 38 | pipe->m_ChainFrom = nullptr; 39 | } 40 | 41 | if (m_ChainTo != nullptr) { 42 | m_ChainTo->m_ChainFrom = nullptr; 43 | m_ChainTo->Flush(); 44 | } 45 | 46 | m_ChainTo = pipe; 47 | 48 | if (pipe != nullptr) { 49 | pipe->m_ChainFrom = this; 50 | } 51 | } 52 | } 53 | 54 | int Pipe::Put(const void *source, int length) 55 | { 56 | captainslog_assert(source != nullptr); 57 | captainslog_assert(length > 0); 58 | 59 | if (m_ChainTo != nullptr) { 60 | return m_ChainTo->Put(source, length); 61 | } 62 | 63 | return length; 64 | } 65 | 66 | int Pipe::Flush() 67 | { 68 | if (m_ChainTo != nullptr) { 69 | return m_ChainTo->Flush(); 70 | } 71 | 72 | return 0; 73 | } 74 | 75 | int Pipe::End() 76 | { 77 | return Flush(); 78 | } 79 | -------------------------------------------------------------------------------- /src/game/io/pipe.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author CCHyper 5 | * @author OmniBlade 6 | * 7 | * @brief Base class for output stream classes. 8 | * 9 | * @copyright Chronoshift is free software: you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation, either version 12 | * 2 of the License, or (at your option) any later version. 13 | * A full copy of the GNU General Public License can be found in 14 | * LICENSE 15 | */ 16 | #pragma once 17 | 18 | #ifndef PIPE_H 19 | #define PIPE_H 20 | 21 | #include "always.h" 22 | 23 | enum PipeControl 24 | { 25 | PIPE_DECODE = 1, 26 | PIPE_DECRYPT = 1, 27 | PIPE_UNCOMPRESS = 1, 28 | PIPE_ENCODE = 0, 29 | PIPE_ENCRYPT = 0, 30 | PIPE_COMPRESS = 0 31 | }; 32 | 33 | class Pipe 34 | { 35 | public: 36 | Pipe() : m_ChainTo(nullptr), m_ChainFrom(nullptr) {} 37 | Pipe(Pipe const &that) : m_ChainTo(that.m_ChainTo), m_ChainFrom(that.m_ChainFrom) {} 38 | virtual ~Pipe(); 39 | 40 | Pipe &operator=(Pipe &that); 41 | 42 | virtual int Flush(); 43 | virtual int End(); 44 | virtual void Put_To(Pipe *pipe); 45 | virtual int Put(const void *source, int length); 46 | 47 | protected: 48 | Pipe *m_ChainTo; 49 | Pipe *m_ChainFrom; 50 | }; 51 | 52 | inline Pipe &Pipe::operator=(Pipe &that) 53 | { 54 | if (this != &that) { 55 | m_ChainTo = that.m_ChainTo; 56 | m_ChainFrom = that.m_ChainFrom; 57 | } 58 | return *this; 59 | } 60 | 61 | #endif // PIPE_H 62 | -------------------------------------------------------------------------------- /src/game/io/pkpipe.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author CCHyper 5 | * @author OmniBlade 6 | * 7 | * @brief Pipe that processes the data with RSA and Blowfish as it writes it. 8 | * 9 | * @copyright Chronoshift is free software: you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation, either version 12 | * 2 of the License, or (at your option) any later version. 13 | * A full copy of the GNU General Public License can be found in 14 | * LICENSE 15 | */ 16 | #pragma once 17 | 18 | #ifndef PKPIPE_H 19 | #define PKPIPE_H 20 | 21 | #include "always.h" 22 | #include "blowpipe.h" 23 | #include "pipe.h" 24 | 25 | class Straw; 26 | class PKey; 27 | 28 | class PKPipe : public Pipe 29 | { 30 | public: 31 | PKPipe(PipeControl mode, Straw &rstraw); 32 | virtual ~PKPipe(){}; 33 | 34 | virtual int Put(const void *buffer, int length) override; 35 | virtual void Put_To(Pipe *pipe) override; 36 | 37 | void Key(PKey *key); 38 | int Encrypted_Key_Length() const; 39 | int Plain_Key_Length() const; 40 | 41 | private: 42 | BOOL m_ChangeKey; 43 | Straw &m_CryptRandom; 44 | BlowPipe m_BlowFish; 45 | PipeControl m_Mode; 46 | PKey *m_RSAKey; 47 | int m_CryptoBuffer[256]; 48 | int m_EncryptedKeyLength; 49 | int m_Carryover; 50 | }; 51 | 52 | #endif // PKPIPE_H 53 | -------------------------------------------------------------------------------- /src/game/io/pkstraw.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author CCHyper 5 | * @author OmniBlade 6 | * 7 | * @brief Straw that processes the data with RSA and Blowfish as it reads it. 8 | * 9 | * @copyright Chronoshift is free software: you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation, either version 12 | * 2 of the License, or (at your option) any later version. 13 | * A full copy of the GNU General Public License can be found in 14 | * LICENSE 15 | */ 16 | #pragma once 17 | 18 | #ifndef PKSTRAW_H 19 | #define PKSTRAW_H 20 | 21 | #include "always.h" 22 | #include "blowstraw.h" 23 | #include "rndstraw.h" 24 | #include "straw.h" 25 | 26 | class PKey; 27 | 28 | class PKStraw : public Straw 29 | { 30 | public: 31 | PKStraw(StrawControl mode, Straw &rstraw); 32 | virtual ~PKStraw() {}; 33 | 34 | virtual int Get(void *buffer, int length) override; 35 | virtual void Get_From(Straw *straw) override; 36 | 37 | void Key(PKey *key); 38 | 39 | int Encrypted_Key_Length() const; 40 | int Plain_Key_Length() const; 41 | 42 | private: 43 | BOOL m_ChangeKey; 44 | Straw &m_CryptRandom; 45 | BlowStraw m_BlowFish; 46 | StrawControl m_Mode; 47 | PKey *m_RSAKey; 48 | char m_CryptoBuffer[256]; 49 | int m_EncryptedKeyLength; 50 | int m_Carryover; 51 | }; 52 | 53 | #endif // PKSTRAW_H 54 | -------------------------------------------------------------------------------- /src/game/io/rndstraw.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author CCHyper 5 | * @author OmniBlade 6 | * 7 | * @brief Straw that provides a stream of random bytes. 8 | * 9 | * @copyright Chronoshift is free software: you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation, either version 12 | * 2 of the License, or (at your option) any later version. 13 | * A full copy of the GNU General Public License can be found in 14 | * LICENSE 15 | */ 16 | #include "rndstraw.h" 17 | 18 | // Global instance of random straw to use as a source of random data. 19 | #ifndef GAME_DLL 20 | RandomStraw g_CryptRandom; 21 | #endif 22 | -------------------------------------------------------------------------------- /src/game/io/shapipe.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author CCHyper 5 | * @author OmniBlade 6 | * 7 | * @brief Output stream implementation that hashes data with SHA1 as it passes it through. 8 | * 9 | * @copyright Chronoshift is free software: you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation, either version 12 | * 2 of the License, or (at your option) any later version. 13 | * A full copy of the GNU General Public License can be found in 14 | * LICENSE 15 | */ 16 | #include "shapipe.h" 17 | 18 | /** 19 | * @brief Write data to the pipe from the specified memory buffer. 20 | * 21 | * @return Returns the number of bytes written from the buffer. 22 | */ 23 | int SHAPipe::Put(const void *buffer, int length) 24 | { 25 | m_SHA1.Hash(buffer, length); 26 | 27 | return Pipe::Put(buffer, length); 28 | } 29 | -------------------------------------------------------------------------------- /src/game/io/shapipe.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author CCHyper 5 | * @author OmniBlade 6 | * 7 | * @brief Output stream implementation that hashes data with SHA1 as it passes it through. 8 | * 9 | * @copyright Chronoshift is free software: you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation, either version 12 | * 2 of the License, or (at your option) any later version. 13 | * A full copy of the GNU General Public License can be found in 14 | * LICENSE 15 | */ 16 | #pragma once 17 | 18 | #ifndef SHAPIPE_H 19 | #define SHAPIPE_H 20 | 21 | #include "always.h" 22 | #include "pipe.h" 23 | #include "sha.h" 24 | 25 | class SHAPipe : public Pipe 26 | { 27 | public: 28 | SHAPipe() : Pipe(), m_SHA1() {} 29 | virtual ~SHAPipe() {} 30 | 31 | virtual int Put(const void *buffer, int length) override; 32 | int const Result(void *data) { return m_SHA1.Result(data); } 33 | 34 | protected: 35 | SHAEngine m_SHA1; 36 | 37 | }; 38 | 39 | #endif // SHAPIPE_H 40 | -------------------------------------------------------------------------------- /src/game/io/shastraw.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author CCHyper 5 | * @author OmniBlade 6 | * 7 | * @brief Input stream implementation that hashes data with SHA1 as it passes it through. 8 | * 9 | * @copyright Chronoshift is free software: you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation, either version 12 | * 2 of the License, or (at your option) any later version. 13 | * A full copy of the GNU General Public License can be found in 14 | * LICENSE 15 | */ 16 | #include "shastraw.h" 17 | #include 18 | 19 | /** 20 | * @brief Read data from the straw into specified memory buffer. 21 | * 22 | * @return Returns the number of bytes read into the buffer. 23 | */ 24 | int SHAStraw::Get(void *buffer, int length) 25 | { 26 | int retval = 0; 27 | 28 | if (buffer && length > 0) { 29 | retval = Straw::Get(buffer, length); 30 | m_SHA1.Hash(buffer, retval); 31 | } 32 | 33 | return retval; 34 | } 35 | 36 | /** 37 | * @brief Read the SHA1 hash result into the specified memory buffer. 38 | * 39 | * @return Returns the number of bytes read into the buffer. 40 | */ 41 | int SHAStraw::Result(void *data) 42 | { 43 | return m_SHA1.Result(data); 44 | } 45 | -------------------------------------------------------------------------------- /src/game/io/shastraw.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author CCHyper 5 | * @author OmniBlade 6 | * 7 | * @brief Input stream implementation that hashes data with SHA1 as it passes it through. 8 | * 9 | * @copyright Chronoshift is free software: you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation, either version 12 | * 2 of the License, or (at your option) any later version. 13 | * A full copy of the GNU General Public License can be found in 14 | * LICENSE 15 | */ 16 | #pragma once 17 | 18 | #ifndef SHASTRAW_H 19 | #define SHASTRAW_H 20 | 21 | #include "always.h" 22 | #include "sha.h" 23 | #include "straw.h" 24 | 25 | class SHAStraw : public Straw 26 | { 27 | public: 28 | SHAStraw() : m_SHA1() {} 29 | virtual ~SHAStraw() {} 30 | 31 | virtual int Get(void *buffer, int length) override; 32 | 33 | int Result(void *data); 34 | 35 | protected: 36 | SHAEngine m_SHA1; // A instance of the SHA-1 Engine class. 37 | }; 38 | 39 | #endif // SHASTRAW_H 40 | -------------------------------------------------------------------------------- /src/game/io/straw.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author CCHyper 5 | * @author OmniBlade 6 | * 7 | * @brief Base interface for fetching a stream of data. 8 | * 9 | * @copyright Chronoshift is free software: you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation, either version 12 | * 2 of the License, or (at your option) any later version. 13 | * A full copy of the GNU General Public License can be found in 14 | * LICENSE 15 | */ 16 | #include "straw.h" 17 | #include 18 | 19 | Straw::~Straw() 20 | { 21 | if (m_ChainTo != nullptr) { 22 | m_ChainTo->m_ChainFrom = m_ChainFrom; 23 | } 24 | 25 | if (m_ChainFrom != nullptr) { 26 | m_ChainFrom->Get_From(m_ChainTo); 27 | } 28 | 29 | m_ChainTo = nullptr; 30 | m_ChainFrom = nullptr; 31 | } 32 | 33 | void Straw::Get_From(Straw *straw) 34 | { 35 | if (m_ChainTo != straw) { 36 | if (straw != nullptr && straw->m_ChainFrom != nullptr) { 37 | straw->m_ChainFrom->Get_From(nullptr); 38 | straw->m_ChainFrom = nullptr; 39 | } 40 | 41 | if (m_ChainTo != nullptr) { 42 | m_ChainTo->m_ChainFrom = nullptr; 43 | } 44 | 45 | m_ChainTo = straw; 46 | 47 | if (straw) { 48 | straw->m_ChainFrom = this; 49 | } 50 | } 51 | } 52 | 53 | int Straw::Get(void *source, int length) 54 | { 55 | if (m_ChainTo != nullptr) { 56 | return m_ChainTo->Get(source, length); 57 | } 58 | 59 | return 0; 60 | } 61 | -------------------------------------------------------------------------------- /src/game/io/straw.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author CCHyper 5 | * @author OmniBlade 6 | * 7 | * @brief Base interface for fetching a stream of data. 8 | * 9 | * @copyright Chronoshift is free software: you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation, either version 12 | * 2 of the License, or (at your option) any later version. 13 | * A full copy of the GNU General Public License can be found in 14 | * LICENSE 15 | */ 16 | #pragma once 17 | 18 | #ifndef STRAW_H 19 | #define STRAW_H 20 | 21 | #include "always.h" 22 | 23 | enum StrawControl 24 | { 25 | STRAW_DECODE = 1, 26 | STRAW_DECRYPT = 1, 27 | STRAW_UNCOMPRESS = 1, 28 | STRAW_ENCODE = 0, 29 | STRAW_ENCRYPT = 0, 30 | STRAW_COMPRESS = 0, 31 | }; 32 | 33 | /* 34 | enum Base64Straw::CodeControl { 35 | ENCODE = 0x0, 36 | DECODE = 0x1, 37 | }; 38 | 39 | enum Base64Pipe::CodeControl { 40 | ENCODE = 0x0, 41 | DECODE = 0x1, 42 | }; 43 | */ 44 | 45 | class Straw 46 | { 47 | public: 48 | Straw() : m_ChainTo(nullptr), m_ChainFrom(nullptr) {} 49 | Straw(Straw const &that) : m_ChainTo(that.m_ChainTo), m_ChainFrom(that.m_ChainFrom) {} 50 | virtual ~Straw(); 51 | 52 | Straw &operator=(Straw &that); 53 | 54 | virtual void Get_From(Straw *straw); 55 | virtual int Get(void *source, int length); 56 | 57 | protected: 58 | Straw *m_ChainTo; 59 | Straw *m_ChainFrom; 60 | 61 | }; 62 | 63 | inline Straw &Straw::operator=(Straw &that) 64 | { 65 | if (this != &that) { 66 | m_ChainTo = that.m_ChainTo; 67 | m_ChainFrom = that.m_ChainFrom; 68 | } 69 | 70 | return *this; 71 | } 72 | 73 | #endif // STRAW_H 74 | -------------------------------------------------------------------------------- /src/game/main.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author OmniBlade 5 | * 6 | * @brief Entry point and associated low level init code. 7 | * 8 | * @copyright Chronoshift is free software: you can redistribute it and/or 9 | * modify it under the terms of the GNU General Public License 10 | * as published by the Free Software Foundation, either version 11 | * 2 of the License, or (at your option) any later version. 12 | * A full copy of the GNU General Public License can be found in 13 | * LICENSE 14 | */ 15 | #pragma once 16 | 17 | #ifndef MAIN_H 18 | #define MAIN_H 19 | 20 | #include "always.h" 21 | 22 | #ifdef GAME_DLL 23 | // This will eventually be replaced by a standard int main(int arc, char *argv[]) function 24 | int __stdcall Main_Func(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow); 25 | 26 | // Watcom doesn't like main defined in a dll project it seems. 27 | int not_main(int argc, char **argv); 28 | #else 29 | int main(int argc, char **argv); 30 | #endif 31 | 32 | #endif // MAIN_H -------------------------------------------------------------------------------- /src/game/memory/alloc.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author tomsons26 5 | * @author OmniBlade 6 | * 7 | * @brief Memory allocation wrapper functions. 8 | * 9 | * @copyright Chronoshift is free software: you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation, either version 12 | * 2 of the License, or (at your option) any later version. 13 | * A full copy of the GNU General Public License can be found in 14 | * LICENSE 15 | */ 16 | #pragma once 17 | 18 | #ifndef ALLOC_H 19 | #define ALLOC_H 20 | 21 | #include "always.h" 22 | 23 | enum MemoryFlagType 24 | { 25 | MEM_NORMAL = 0x0, 26 | MEM_NEW = 0x1, 27 | MEM_CLEAR = 0x2, 28 | MEM_REAL = 0x4, 29 | MEM_TEMP = 0x8, 30 | MEM_LOCK = 0x10 31 | }; 32 | 33 | DEFINE_ENUMERATION_BITWISE_OPERATORS(MemoryFlagType); 34 | 35 | typedef void(*memerrorhandler_t)(); 36 | typedef void (*memexithandler_t)(const char *); 37 | 38 | void *Alloc(unsigned int bytes_to_alloc, MemoryFlagType flags); 39 | void Free(void *pointer); 40 | void *Resize_Alloc(void *original_ptr, unsigned int new_size_in_bytes); 41 | int Ram_Free(); 42 | int Heap_Size(MemoryFlagType flag); 43 | int Total_Ram_Free(MemoryFlagType flag); 44 | 45 | #ifdef GAME_DLL 46 | extern memerrorhandler_t &g_MemoryError; // Memory error handler function pointer. 47 | extern memexithandler_t &g_MemoryErrorExit; 48 | #else 49 | extern memerrorhandler_t g_MemoryError; // Memory error handler function pointer. 50 | extern memexithandler_t g_MemoryErrorExit; 51 | #endif 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /src/game/memory/newdel.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author OmniBlade 5 | * @author tomsons26 6 | * 7 | * @brief Custom memory allocators for new and delete. 8 | * 9 | * @copyright Chronoshift is free software: you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation, either version 12 | * 2 of the License, or (at your option) any later version. 13 | * A full copy of the GNU General Public License can be found in 14 | * LICENSE 15 | */ 16 | #include "newdel.h" 17 | #include "alloc.h" 18 | 19 | void* operator new(size_t size) 20 | { 21 | return Alloc(size, MEM_NEW); 22 | } 23 | 24 | void* operator new[](size_t size) 25 | { 26 | return Alloc(size, MEM_NEW); 27 | } 28 | 29 | void operator delete(void* ptr) noexcept 30 | { 31 | Free(ptr); 32 | } -------------------------------------------------------------------------------- /src/game/memory/newdel.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author OmniBlade 5 | * @author tomsons26 6 | * 7 | * @brief Custom memory allocators for new and delete. 8 | * 9 | * @copyright Chronoshift is free software: you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation, either version 12 | * 2 of the License, or (at your option) any later version. 13 | * A full copy of the GNU General Public License can be found in 14 | * LICENSE 15 | */ 16 | #pragma once 17 | 18 | #ifndef NEWDEL_H 19 | #define NEWDEL_H 20 | 21 | #include "always.h" 22 | 23 | void* operator new(size_t size); 24 | void* operator new[](size_t size); 25 | void operator delete(void* ptr) noexcept; 26 | 27 | #endif -------------------------------------------------------------------------------- /src/game/net/field.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author tomsons26 5 | * @author OmniBlade 6 | * 7 | * @brief Class for packing network fields used for packets and the statistics function. 8 | * 9 | * @copyright Chronoshift is free software: you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation, either version 12 | * 2 of the License, or (at your option) any later version. 13 | * A full copy of the GNU General Public License can be found in 14 | * LICENSE 15 | */ 16 | #pragma once 17 | 18 | #include "always.h" 19 | 20 | #ifndef FIELD_H 21 | #define FIELD_H 22 | 23 | enum FieldDataType 24 | { 25 | FD_UINT8 = 1, 26 | FD_BOOLEAN = 2, 27 | FD_INT16 = 3, 28 | FD_UINT16 = 4, 29 | FD_INT32 = 5, 30 | FD_UINT32 = 6, 31 | FD_STRING = 7, 32 | FD_CUSTOM = 20 33 | }; 34 | 35 | class FieldClass 36 | { 37 | friend class PacketClass; 38 | 39 | public: 40 | FieldClass() : m_DataType(0), m_Size(0), m_Data(nullptr), m_Next(nullptr) {} 41 | FieldClass(char *id, uint8_t data); 42 | FieldClass(char *id, bool data); 43 | FieldClass(char *id, int16_t data); 44 | FieldClass(char *id, uint16_t data); 45 | FieldClass(char *id, int32_t data); 46 | FieldClass(char *id, uint32_t data); 47 | FieldClass(char *id, char *data); 48 | FieldClass(char *id, void *data, int size); 49 | ~FieldClass() 50 | { 51 | delete[] m_Data; 52 | m_Data = nullptr; 53 | } 54 | void Host_To_Net(); 55 | void Net_To_Host(); 56 | 57 | protected: 58 | char m_ID[4]; 59 | int16_t m_DataType; 60 | int16_t m_Size; 61 | uint8_t *m_Data; 62 | FieldClass *m_Next; 63 | }; 64 | #endif // FIELD_H 65 | -------------------------------------------------------------------------------- /src/game/net/ipxaddress.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author OmniBlade 5 | * 6 | * @brief Holds and manipulates an IPX address. 7 | * 8 | * @copyright Chronoshift is free software: you can redistribute it and/or 9 | * modify it under the terms of the GNU General Public License 10 | * as published by the Free Software Foundation, either version 11 | * 2 of the License, or (at your option) any later version. 12 | * A full copy of the GNU General Public License can be found in 13 | * LICENSE 14 | */ 15 | #pragma once 16 | 17 | #ifndef IPXADDRESS_H 18 | #define IPXADDRESS_H 19 | 20 | #include "always.h" 21 | 22 | #pragma pack(push,1) 23 | struct IPXHEADER 24 | { 25 | char checksum[2]; 26 | char length[2]; 27 | char transport_control; 28 | char packet_type; 29 | char dst_net[4]; 30 | char dst_node[6]; 31 | char dst_sock[2]; 32 | char src_net[4]; 33 | char src_node[6]; 34 | char src_sock[2]; 35 | }; 36 | #pragma pack(pop) 37 | 38 | class IPXAddressClass 39 | { 40 | public: 41 | IPXAddressClass(); 42 | IPXAddressClass(char *net, char *node); 43 | IPXAddressClass(IPXHEADER *header); 44 | 45 | void Set_Address(char *net, char *node); 46 | void Set_Address(IPXHEADER *header); 47 | void Get_Address(char *net, char *node); 48 | void Get_Address(IPXHEADER *header); 49 | BOOL Is_Broadcast(); 50 | 51 | BOOL operator==(IPXAddressClass &that); 52 | BOOL operator!=(IPXAddressClass &that); 53 | BOOL operator>(IPXAddressClass &that); 54 | BOOL operator<(IPXAddressClass &that); 55 | BOOL operator>=(IPXAddressClass &that); 56 | BOOL operator<=(IPXAddressClass &that); 57 | 58 | private: 59 | uint8_t m_NetNum[4]; 60 | uint8_t m_NodeNum[6]; 61 | }; 62 | 63 | #endif // IPXADDRESS_H 64 | -------------------------------------------------------------------------------- /src/game/net/packet.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author OmniBlade 5 | * 6 | * @brief Class for building data packets such as those used for sending match statistics. 7 | * 8 | * @copyright Chronoshift is free software: you can redistribute it and/or 9 | * modify it under the terms of the GNU General Public License 10 | * as published by the Free Software Foundation, either version 11 | * 2 of the License, or (at your option) any later version. 12 | * A full copy of the GNU General Public License can be found in 13 | * LICENSE 14 | */ 15 | #pragma once 16 | 17 | #include "always.h" 18 | 19 | #ifndef PACKET_H 20 | #define PACKET_H 21 | 22 | class FieldClass; 23 | 24 | class PacketClass 25 | { 26 | public: 27 | PacketClass() : m_Size(0), m_ID(0), m_Head(nullptr), m_Current(nullptr) {} 28 | PacketClass(const uint8_t *data); 29 | ~PacketClass(); 30 | 31 | void Add_Field(FieldClass *field); 32 | uint8_t *Create_Comm_Packet(unsigned &size); 33 | FieldClass *Find_Field(const char *id); 34 | BOOL Get_Field(const char *id, int8_t &data); 35 | BOOL Get_Field(const char *id, uint8_t &data); 36 | BOOL Get_Field(const char *id, int16_t &data); 37 | BOOL Get_Field(const char *id, uint16_t &data); 38 | BOOL Get_Field(const char *id, int32_t &data); 39 | BOOL Get_Field(const char *id, uint32_t &data); 40 | BOOL Get_Field(const char *id, char *data); 41 | BOOL Get_Field(const char *id, void *data, unsigned &size); 42 | 43 | private: 44 | int16_t m_Size; 45 | int16_t m_ID; 46 | FieldClass *m_Head; 47 | FieldClass *m_Current; 48 | }; 49 | 50 | #endif // PACKET_H 51 | -------------------------------------------------------------------------------- /src/game/net/udp.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author OmniBlade 5 | * 6 | * @brief Networkng interface class utilising the UDP protocol. 7 | * 8 | * @copyright Chronoshift is free software: you can redistribute it and/or 9 | * modify it under the terms of the GNU General Public License 10 | * as published by the Free Software Foundation, either version 11 | * 2 of the License, or (at your option) any later version. 12 | * A full copy of the GNU General Public License can be found in 13 | * LICENSE 14 | */ 15 | #pragma once 16 | 17 | #ifndef UDP_H 18 | #define UDP_H 19 | 20 | #include "always.h" 21 | #include "vector.h" 22 | #include "wsock.h" 23 | 24 | extern const uint16_t g_ChronoshiftPortNumber; 25 | 26 | class UDPInterfaceClass : public WinsockInterfaceClass 27 | { 28 | public: 29 | UDPInterfaceClass() {} 30 | virtual ~UDPInterfaceClass() {} 31 | 32 | virtual void Broadcast(void *src, int src_len) override; 33 | virtual void Set_Broadcast_Address(void *address) override; 34 | virtual ProtocolEnum Get_Protocol() override { return PROTOCOL_UDP; } 35 | // This one will need replacing with something for SDL messages 36 | virtual int Protocol_Event_Message() override { return UDP_MESSAGE; } 37 | virtual int Open_Socket(unsigned port) override; 38 | virtual int32_t Message_Handler(void *hwnd, uint32_t msg, uint32_t wparam, int32_t lparam) override; 39 | 40 | private: 41 | DynamicVectorClass m_BroadcastAddresses; 42 | DynamicVectorClass m_LocalAddresses; 43 | }; 44 | 45 | #endif // _UDP_H_ 46 | -------------------------------------------------------------------------------- /src/game/platform/eventhandler.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author OmniBlade 5 | * 6 | * @brief Platform/Framework specific event handling code. 7 | * 8 | * @copyright Chronoshift is free software: you can redistribute it and/or 9 | * modify it under the terms of the GNU General Public License 10 | * as published by the Free Software Foundation, either version 11 | * 2 of the License, or (at your option) any later version. 12 | * A full copy of the GNU General Public License can be found in 13 | * LICENSE 14 | */ 15 | #pragma once 16 | 17 | #ifndef EVENTHANDLER_H 18 | #define EVENTHANDLER_H 19 | 20 | #include "always.h" 21 | 22 | typedef void (*focusfunc_t)(); 23 | 24 | void Prog_End(); 25 | 26 | #if defined PLATFORM_WINDOWS 27 | LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam); 28 | #endif 29 | 30 | #ifdef GAME_DLL 31 | extern unsigned &g_CCFocusMessage; 32 | extern focusfunc_t &g_AudioFocusLoss; 33 | extern focusfunc_t &g_GBufferFocusLoss; 34 | #else 35 | extern unsigned g_CCFocusMessage; 36 | extern focusfunc_t g_AudioFocusLoss; 37 | extern focusfunc_t g_GBufferFocusLoss; 38 | #endif 39 | 40 | #endif // EVENTHANDLER_H 41 | -------------------------------------------------------------------------------- /src/game/platform/excepthandler.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author tomsons26 5 | * 6 | * @brief Functions for exception handling and log outputting. 7 | * 8 | * @copyright Chronoshift is free software: you can redistribute it and/or 9 | * modify it under the terms of the GNU General Public License 10 | * as published by the Free Software Foundation, either version 11 | * 2 of the License, or (at your option) any later version. 12 | * 13 | * A full copy of the GNU General Public License can be found in 14 | * LICENSE 15 | */ 16 | #pragma once 17 | 18 | #ifndef EXCEPTHANDLER_H 19 | #define EXCEPTHANDLER_H 20 | 21 | #include "always.h" 22 | 23 | #if defined COMPILER_WATCOM || defined COMPILER_MSVC 24 | LONG __cdecl Exception_Handler(unsigned int u, struct _EXCEPTION_POINTERS *e_info); 25 | #endif 26 | 27 | #ifdef COMPILER_WATCOM 28 | int __cdecl Watcom_Exception_Handler( 29 | EXCEPTION_RECORD *ex, void *establisher_frame, CONTEXT *context, void *dispatch_context); 30 | #endif 31 | 32 | #endif // EXCEPTHANDLER_H 33 | -------------------------------------------------------------------------------- /src/game/platform/initvideo.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author OmniBlade 5 | * 6 | * @brief Initialisation functions for graphics API. 7 | * 8 | * @copyright Chronoshift is free software: you can redistribute it and/or 9 | * modify it under the terms of the GNU General Public License 10 | * as published by the Free Software Foundation, either version 11 | * 2 of the License, or (at your option) any later version. 12 | * A full copy of the GNU General Public License can be found in 13 | * LICENSE 14 | */ 15 | #pragma once 16 | 17 | #ifndef INITVIDEO_H 18 | #define INITVIDEO_H 19 | 20 | #include "always.h" 21 | 22 | #ifdef BUILD_WITH_DDRAW 23 | #define DIRECTDRAW_VERSION 0x300 24 | #include 25 | #endif 26 | 27 | BOOL Set_Video_Mode(uintptr_t handle, int w, int h, int bpp); 28 | void Reset_Video_Mode(); 29 | BOOL Init_Video(); 30 | void Set_Video_Palette(void *pal); 31 | 32 | #ifdef GAME_DLL 33 | #ifdef BUILD_WITH_DDRAW 34 | extern LPDIRECTDRAW &g_DirectDrawObject; 35 | extern LPDIRECTDRAWSURFACE &g_PaletteSurface; 36 | #endif 37 | #else 38 | #ifdef BUILD_WITH_DDRAW 39 | extern LPDIRECTDRAW g_DirectDrawObject; 40 | extern LPDIRECTDRAWSURFACE g_PaletteSurface; 41 | #endif 42 | #endif 43 | 44 | #endif // INITVIDEO_H 45 | -------------------------------------------------------------------------------- /src/game/platform/stackdump.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author OmniBlade 5 | * @author tomsons26 6 | * 7 | * @brief Functions for creating dumps of information on program crash. 8 | * 9 | * @copyright Chronoshift is free software: you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation, either version 12 | * 2 of the License, or (at your option) any later version. 13 | * 14 | * A full copy of the GNU General Public License can be found in 15 | * LICENSE 16 | */ 17 | #pragma once 18 | 19 | #ifndef STACKDUMP_H 20 | #define STACKDUMP_H 21 | 22 | #include "always.h" 23 | #include 24 | 25 | #ifdef PLATFORM_WINDOWS 26 | #include 27 | #include 28 | 29 | #ifdef COMPILER_MSVC 30 | #include 31 | #endif 32 | 33 | #ifdef COMPILER_WATCOM 34 | #include 35 | #endif 36 | 37 | #include 38 | 39 | 40 | void __cdecl Dump_Exception_Info(unsigned int u, struct _EXCEPTION_POINTERS *e_info); 41 | BOOL Init_Symbol_Info(); 42 | void Uninit_Symbol_Info(); 43 | void __cdecl Stack_Dump_Handler(const char *data); 44 | void Make_Stack_Trace( 45 | uintptr_t myeip, uintptr_t myesp, uintptr_t myebp, int skipFrames, void(__cdecl *callback)(char const *)); 46 | 47 | extern char g_ExceptionFileBuffer[65536]; 48 | #endif 49 | 50 | #endif // STACKDUMP_H 51 | -------------------------------------------------------------------------------- /src/game/startup.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author CCHyper 5 | * @author OmniBlade 6 | * 7 | * @brief Startup code. 8 | * 9 | * @copyright Chronoshift is free software: you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation, either version 12 | * 2 of the License, or (at your option) any later version. 13 | * A full copy of the GNU General Public License can be found in 14 | * LICENSE 15 | */ 16 | #pragma once 17 | 18 | #ifndef STARTUP_H 19 | #define STARTUP_H 20 | 21 | #include "always.h" 22 | 23 | class FileClass; 24 | 25 | void Emergency_Exit(int exit_code); 26 | BOOL InitDDraw(); 27 | void Read_Startup_Options(FileClass *fc); // Original takes RawFileClass specifically 28 | uint64_t Disk_Space_Available(); // don't hook this, abi does not match. 29 | 30 | #ifdef GAME_DLL 31 | #include "hooker.h" 32 | #endif 33 | 34 | #endif // STARTUP_H 35 | -------------------------------------------------------------------------------- /src/game/ui/bigcheck.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author tomsons26 5 | * 6 | * @brief Class representing a big checkbox element. 7 | * 8 | * @copyright Chronoshift is free software: you can redistribute it and/or 9 | * modify it under the terms of the GNU General Public License 10 | * as published by the Free Software Foundation, either version 11 | * 2 of the License, or (at your option) any later version. 12 | * A full copy of the GNU General Public License can be found in 13 | * LICENSE 14 | */ 15 | #pragma once 16 | 17 | #ifndef BIGCHECK_H 18 | #define BIGCHECK_H 19 | 20 | #include "toggle.h" 21 | #include "dialog.h" 22 | 23 | class BigCheckBoxClass : public ToggleClass 24 | { 25 | public: 26 | BigCheckBoxClass(unsigned id, int x, int y, int w, int h, const char *text, TextPrintType style); 27 | BigCheckBoxClass(BigCheckBoxClass &that); 28 | virtual ~BigCheckBoxClass(); 29 | 30 | virtual BOOL Draw_Me(BOOL redraw) override; 31 | virtual BOOL Action(unsigned flags, KeyNumType &key) override; 32 | 33 | BigCheckBoxClass & operator=(BigCheckBoxClass &that); 34 | 35 | protected: 36 | TextPrintType m_TextStyle; 37 | const char *m_TextString; 38 | }; 39 | 40 | inline BigCheckBoxClass &BigCheckBoxClass::operator=(BigCheckBoxClass &that) 41 | { 42 | if (this != &that) { 43 | ToggleClass::operator=(that); 44 | m_TextStyle = that.m_TextStyle; 45 | m_TextString = that.m_TextString; 46 | } 47 | 48 | return *this; 49 | } 50 | 51 | #endif // BIGCHECK_H 52 | -------------------------------------------------------------------------------- /src/game/ui/checkbox.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author CCHyper 5 | * @author OmniBlade 6 | * 7 | * @brief Class representing a ehckbox element. 8 | * 9 | * @copyright Chronoshift is free software: you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation, either version 12 | * 2 of the License, or (at your option) any later version. 13 | * A full copy of the GNU General Public License can be found in 14 | * LICENSE 15 | */ 16 | #include "checkbox.h" 17 | #include "dialog.h" 18 | #include "gbuffer.h" 19 | #include "mouse.h" 20 | 21 | BOOL CheckBoxClass::Draw_Me(BOOL redraw) 22 | { 23 | if (ControlClass::Draw_Me(redraw)) { 24 | g_Mouse->Hide_Mouse(); 25 | Draw_Box(m_XPos, m_YPos, m_Width, m_Height, BOX_STYLE_0, false); 26 | // This appears to be how it was originally 27 | // LogicPage->Fill_Rect(XPos + 1, YPos + 1, 28 | // XPos + Width - 2, YPos + Height - 2, 29 | // 13); 30 | // if ( ToggleState ) { 31 | // LogicPage->Fill_Rect(XPos + 1, YPos + 1, 32 | // XPos + Width - 2, YPos + Height - 2, 33 | // 4); 34 | //} 35 | 36 | // This way only calls Fill_Rect once. 37 | int fill_color = m_ToggleState ? 4 : 13; 38 | g_LogicPage->Fill_Rect(m_XPos + 1, m_YPos + 1, m_XPos + m_Width - 2, m_YPos + m_Height - 2, fill_color); 39 | g_Mouse->Show_Mouse(); 40 | 41 | return true; 42 | } 43 | 44 | return false; 45 | } 46 | 47 | BOOL CheckBoxClass::Action(unsigned flags, KeyNumType &key) 48 | { 49 | if (flags & MOUSE_LEFT_RLSE) { 50 | if (m_ToggleState) { 51 | Turn_Off(); 52 | } else { 53 | Turn_On(); 54 | } 55 | } 56 | 57 | return ToggleClass::Action(flags, key); 58 | } 59 | -------------------------------------------------------------------------------- /src/game/ui/checkbox.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author CCHyper 5 | * @author OmniBlade 6 | * 7 | * @brief Class representing a ehckbox element. 8 | * 9 | * @copyright Chronoshift is free software: you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation, either version 12 | * 2 of the License, or (at your option) any later version. 13 | * A full copy of the GNU General Public License can be found in 14 | * LICENSE 15 | */ 16 | #ifndef CHECKBOX_H 17 | #define CHECKBOX_H 18 | 19 | #include "always.h" 20 | #include "toggle.h" 21 | 22 | class CheckBoxClass : public ToggleClass 23 | { 24 | public: 25 | CheckBoxClass(unsigned id, int x, int y, int w, int h) : ToggleClass(id, x, y, w, h) {} 26 | CheckBoxClass(CheckBoxClass &that) : ToggleClass(that) {} 27 | virtual ~CheckBoxClass() {} 28 | 29 | virtual BOOL Draw_Me(BOOL redraw) override; 30 | virtual BOOL Action(unsigned flags, KeyNumType &key) override; 31 | 32 | CheckBoxClass &operator=(CheckBoxClass &that); 33 | }; 34 | 35 | inline CheckBoxClass &CheckBoxClass::operator=(CheckBoxClass &that) 36 | { 37 | if (this != &that) { 38 | ToggleClass::operator=(that); 39 | } 40 | 41 | return *this; 42 | } 43 | 44 | #endif // CHECKBOX_H 45 | -------------------------------------------------------------------------------- /src/game/ui/controlc.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author CCHyper 5 | * @author OmniBlade 6 | * 7 | * @brief Base class for UI elements that generate events themselves. 8 | * 9 | * @copyright Chronoshift is free software: you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation, either version 12 | * 2 of the License, or (at your option) any later version. 13 | * A full copy of the GNU General Public License can be found in 14 | * LICENSE 15 | */ 16 | #include "controlc.h" 17 | 18 | ControlClass::ControlClass(unsigned id, int x, int y, int w, int h, unsigned input_flag, BOOL is_sticky) : 19 | GadgetClass(x, y, w, h, input_flag, is_sticky), 20 | m_ID(id), 21 | m_Peer(nullptr) 22 | { 23 | } 24 | 25 | ControlClass::ControlClass(ControlClass &that) : GadgetClass(that), m_ID(that.m_ID), m_Peer(that.m_Peer) {} 26 | 27 | BOOL ControlClass::Draw_Me(BOOL redraw) 28 | { 29 | if (m_Peer) { 30 | m_Peer->Draw_Me(false); 31 | } 32 | 33 | return GadgetClass::Draw_Me(redraw); 34 | } 35 | 36 | BOOL ControlClass::Action(unsigned flags, KeyNumType &key) 37 | { 38 | if (flags) { 39 | if (m_ID) { 40 | key = (KeyNumType)(m_ID | KN_BUTTON); 41 | } else { 42 | key = KN_NONE; 43 | } 44 | } 45 | 46 | if (m_Peer) { 47 | m_Peer->Peer_To_Peer(flags, key, *this); 48 | } 49 | 50 | return GadgetClass::Action(flags, key); 51 | } 52 | -------------------------------------------------------------------------------- /src/game/ui/controlc.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author CCHyper 5 | * @author OmniBlade 6 | * 7 | * @brief Base class for UI elements that generate events themselves. 8 | * 9 | * @copyright Chronoshift is free software: you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation, either version 12 | * 2 of the License, or (at your option) any later version. 13 | * A full copy of the GNU General Public License can be found in 14 | * LICENSE 15 | */ 16 | #pragma once 17 | 18 | #ifndef CONTROLC_H 19 | #define CONTROLC_H 20 | 21 | #include "always.h" 22 | #include "gadget.h" 23 | 24 | class ControlClass : public GadgetClass 25 | { 26 | public: 27 | ControlClass(unsigned input_flag, BOOL sticky = false) : GadgetClass(input_flag, sticky), m_ID(0), m_Peer(nullptr) {} 28 | ControlClass(unsigned id, int x, int y, int w, int h, unsigned input_flag, BOOL is_sticky = false); 29 | ControlClass(ControlClass &that); 30 | virtual ~ControlClass() {} 31 | 32 | virtual unsigned Get_ID() const override { return m_ID; } 33 | virtual BOOL Draw_Me(BOOL redraw) override; 34 | virtual BOOL Action(unsigned flags, KeyNumType &key) override; 35 | virtual void Make_Peer(GadgetClass const &peer) { m_Peer = (GadgetClass *)&peer; } 36 | 37 | ControlClass &operator=(ControlClass &that); 38 | 39 | void Set_ID(unsigned id) { m_ID = id; } 40 | 41 | protected: 42 | unsigned m_ID; 43 | GadgetClass *m_Peer; 44 | }; 45 | 46 | inline ControlClass &ControlClass::operator=(ControlClass &that) 47 | { 48 | if (this != &that) { 49 | GadgetClass::operator=(that); 50 | m_ID = that.m_ID; 51 | m_Peer = that.m_Peer; 52 | } 53 | 54 | return *this; 55 | } 56 | 57 | #endif // CONTROLC_H 58 | -------------------------------------------------------------------------------- /src/game/ui/dial8.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author OmniBlade 5 | * @author CCHyper 6 | * 7 | * @brief 8 | * 9 | * @copyright Chronoshift is free software: you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation, either version 12 | * 2 of the License, or (at your option) any later version. 13 | * A full copy of the GNU General Public License can be found in 14 | * LICENSE 15 | */ 16 | #pragma once 17 | 18 | #ifndef DIAL8_H 19 | #define DIAL8_H 20 | 21 | #include "always.h" 22 | #include "controlc.h" 23 | #include "facing.h" 24 | #include "tpoint.h" 25 | 26 | class Dial8Class : public ControlClass 27 | { 28 | public: 29 | Dial8Class(unsigned id, int x, int y, int w, int h, DirType direction); 30 | Dial8Class(Dial8Class &that); 31 | virtual ~Dial8Class(void) {} 32 | 33 | Dial8Class &operator=(Dial8Class &that); 34 | 35 | // GadgetClass 36 | virtual BOOL Draw_Me(BOOL redraw) override; 37 | virtual BOOL Action(unsigned flags, KeyNumType &key) override; 38 | 39 | void Set_Direction(DirType direction); 40 | DirType const Get_Direction() const { return m_Direction; } 41 | 42 | protected: 43 | TPoint2D m_Center; 44 | TPoint2D m_CompassPoints[FACING_COUNT]; 45 | TPoint2D m_LinePoints[FACING_COUNT]; 46 | DirType m_Direction; 47 | FacingType m_Facing; 48 | FacingType m_LastFacing; 49 | }; 50 | 51 | #endif // DIAL8_H 52 | -------------------------------------------------------------------------------- /src/game/ui/link.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author OmniBlade 5 | * @author CCHyper 6 | * 7 | * @brief Base class for UI elements linking them together for processing. 8 | * 9 | * @copyright Chronoshift is free software: you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation, either version 12 | * 2 of the License, or (at your option) any later version. 13 | * A full copy of the GNU General Public License can be found in 14 | * LICENSE 15 | */ 16 | #pragma once 17 | 18 | #ifndef LINK_H 19 | #define LINK_H 20 | 21 | #include "always.h" 22 | 23 | class LinkClass 24 | { 25 | public: 26 | LinkClass() : m_Next(nullptr), m_Prev(nullptr) {} 27 | LinkClass(LinkClass &that) : m_Next(nullptr), m_Prev(nullptr) { Add(that); } 28 | virtual ~LinkClass() { Remove(); } 29 | 30 | virtual LinkClass *Get_Next() const { return m_Next; } 31 | virtual LinkClass *Get_Prev() const { return m_Prev; } 32 | virtual LinkClass &Add(LinkClass &that); 33 | virtual LinkClass &Add_Tail(LinkClass &that); 34 | virtual LinkClass &Add_Head(LinkClass &that); 35 | virtual LinkClass &Head_Of_List(); 36 | virtual LinkClass &Tail_Of_List(); 37 | virtual void Zap(); 38 | virtual LinkClass *Remove(); 39 | 40 | LinkClass &operator=(LinkClass &that); 41 | void Unlink(); 42 | int Count(); 43 | 44 | protected: 45 | LinkClass *m_Next; 46 | LinkClass *m_Prev; 47 | }; 48 | 49 | 50 | inline LinkClass &LinkClass::operator=(LinkClass &that) 51 | { 52 | if (this != &that) { 53 | Remove(); 54 | Add(that); 55 | } 56 | 57 | return *this; 58 | } 59 | 60 | inline int LinkClass::Count() 61 | { 62 | int count = 0; 63 | 64 | for (LinkClass *next = Get_Next(); next != nullptr; next = next->Get_Next()) { 65 | ++count; 66 | } 67 | 68 | return count; 69 | } 70 | 71 | #endif // LINK_H 72 | -------------------------------------------------------------------------------- /src/game/ui/musiclist.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author CCHyper 5 | * @author OmniBlade 6 | * 7 | * @brief Class specialised for the list of music tracks. 8 | * 9 | * @copyright Chronoshift is free software: you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation, either version 12 | * 2 of the License, or (at your option) any later version. 13 | * A full copy of the GNU General Public License can be found in 14 | * LICENSE 15 | */ 16 | #include "musiclist.h" 17 | #include "gamefile.h" 18 | #include "gbuffer.h" 19 | #include "mixfile.h" 20 | #include "remap.h" 21 | 22 | MusicListClass::MusicListClass(int id, int x, int y, int w, int h, TextPrintType style) : 23 | ListClass(id, x, y, w, h, style | TPF_6PT_GRAD | TPF_NOSHADOW, GameFileClass::Retrieve("btn-up.shp"), 24 | GameFileClass::Retrieve("btn-dn.shp")) 25 | { 26 | // empty 27 | } 28 | 29 | void MusicListClass::Draw_Entry(int index, int x, int y, int x_max, BOOL selected) 30 | { 31 | TextPrintType style = m_TextStyle; 32 | RemapControlType *remapper = Get_Color_Scheme(); 33 | const char *entry = m_Entries[index] + 1; 34 | 35 | if (style & TPF_6PT_GRAD) { 36 | if (selected) { 37 | style |= TPF_USE_BRIGHT; 38 | g_LogicPage->Fill_Rect(x, y, ((x + x_max) - 1), ((y + m_YSpacing) - 1), remapper->WindowPalette[0]); 39 | } else if (!(style & TPF_USE_GRAD_PAL)) { 40 | style |= TPF_USE_MEDIUM; 41 | } 42 | } else { 43 | remapper = (selected ? &g_ColorRemaps[REMAP_10] : &g_ColorRemaps[REMAP_5]); 44 | } 45 | 46 | Conquer_Clip_Text_Print(entry, x, y, remapper, COLOR_TBLACK, style, x_max, m_Tabs); 47 | } 48 | -------------------------------------------------------------------------------- /src/game/ui/musiclist.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author CCHyper 5 | * @author OmniBlade 6 | * 7 | * @brief Class specialised for the list of music tracks. 8 | * 9 | * @copyright Chronoshift is free software: you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation, either version 12 | * 2 of the License, or (at your option) any later version. 13 | * A full copy of the GNU General Public License can be found in 14 | * LICENSE 15 | */ 16 | #pragma once 17 | 18 | #ifndef MUSICLIST_H 19 | #define MUSICLIST_H 20 | 21 | #include "always.h" 22 | #include "dialog.h" 23 | #include "list.h" 24 | 25 | class MusicListClass : public ListClass 26 | { 27 | public: 28 | MusicListClass(int id, int x, int y, int w, int h, TextPrintType style); 29 | MusicListClass(MusicListClass &that) : ListClass(that) {} 30 | virtual ~MusicListClass() {} 31 | 32 | virtual void Draw_Entry(int index, int x, int y, int x_max, BOOL selected = false) override; 33 | 34 | MusicListClass &operator=(MusicListClass &that); 35 | }; 36 | 37 | inline MusicListClass &MusicListClass::operator=(MusicListClass &that) 38 | { 39 | if (this != &that) { 40 | ListClass::operator=(that); 41 | } 42 | 43 | return *this; 44 | } 45 | 46 | #endif // MUSICLIST_H 47 | -------------------------------------------------------------------------------- /src/game/ui/shapebtn.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author OmniBlade 5 | * @author CCHyper 6 | * 7 | * @brief Classes for representing button UI elements with sprites. 8 | * 9 | * @copyright Chronoshift is free software: you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation, either version 12 | * 2 of the License, or (at your option) any later version. 13 | * A full copy of the GNU General Public License can be found in 14 | * LICENSE 15 | */ 16 | #pragma once 17 | 18 | #ifndef SHAPEBTN_H 19 | #define SHAPEBTN_H 20 | 21 | #include "always.h" 22 | #include "dialog.h" 23 | #include "language.h" 24 | #include "toggle.h" 25 | 26 | class ShapeButtonClass : public ToggleClass 27 | { 28 | enum 29 | { 30 | SHAPE_DEFAULT, 31 | SHAPE_ENABLED, 32 | SHAPE_DISABLED, 33 | }; 34 | public: 35 | ShapeButtonClass() : ToggleClass(0, 0, 0, INPUT_NONE, false), m_BooleanOne(false) {} 36 | ShapeButtonClass(unsigned id, void *button_shape, int x, int y); 37 | ShapeButtonClass(ShapeButtonClass &that); 38 | virtual ~ShapeButtonClass() {} 39 | 40 | ShapeButtonClass &operator=(ShapeButtonClass &that); 41 | 42 | virtual BOOL Draw_Me(BOOL redraw) override; 43 | virtual void Set_Shape(void *button_shape); 44 | 45 | void *Get_Shape() const { return m_ButtonShape; } 46 | void Set_Shape_Bool_One(BOOL unk) { m_BooleanOne = unk; } 47 | 48 | protected: 49 | #ifndef CHRONOSHIFT_NO_BITFIELDS 50 | BOOL m_BooleanOne : 1; // & 1 51 | #else 52 | bool m_BooleanOne; 53 | #endif 54 | void *m_ButtonShape; 55 | }; 56 | 57 | #endif // SHAPEBTN_H 58 | -------------------------------------------------------------------------------- /src/game/ui/staticbtn.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author CCHyper 5 | * @author OmniBlade 6 | * 7 | * @brief Class for static text UI gadgets. 8 | * 9 | * @copyright Chronoshift is free software: you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation, either version 12 | * 2 of the License, or (at your option) any later version. 13 | * A full copy of the GNU General Public License can be found in 14 | * LICENSE 15 | */ 16 | #pragma once 17 | 18 | #ifndef STATICBTN_H 19 | #define STATICBTN_H 20 | 21 | #include "always.h" 22 | #include "buffer.h" 23 | #include "dialog.h" 24 | #include "gadget.h" 25 | #include "language.h" 26 | 27 | class StaticButtonClass : public GadgetClass 28 | { 29 | public: 30 | StaticButtonClass(unsigned id, const char *text, TextPrintType style, int x, int y, int w = -1, int h = -1); 31 | StaticButtonClass(StaticButtonClass &that); 32 | virtual ~StaticButtonClass() {} 33 | 34 | virtual BOOL Draw_Me(BOOL redraw) override; 35 | virtual void Set_Text(const char *string, BOOL adjust); 36 | virtual void Draw_Background(); 37 | virtual void Draw_Text(const char *string); 38 | 39 | StaticButtonClass &operator=(StaticButtonClass &that); 40 | 41 | void Set_Style(TextPrintType style) { m_TextStyle = style; } 42 | 43 | protected: 44 | BufferClass m_DrawBuffer; 45 | char *m_ButtonText; 46 | TextPrintType m_TextStyle; 47 | }; 48 | 49 | inline StaticButtonClass &StaticButtonClass::operator=(StaticButtonClass &that) 50 | { 51 | if (this != &that) { 52 | m_DrawBuffer = that.m_DrawBuffer; 53 | m_ButtonText = that.m_ButtonText; 54 | m_TextStyle = that.m_TextStyle; 55 | } 56 | 57 | return *this; 58 | } 59 | 60 | #endif // STATICBTN_H 61 | -------------------------------------------------------------------------------- /src/game/ui/toggle.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author CCHyper 5 | * @author OmniBlade 6 | * 7 | * @brief Base class for toggleable UI elements. 8 | * 9 | * @copyright Chronoshift is free software: you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation, either version 12 | * 2 of the License, or (at your option) any later version. 13 | * A full copy of the GNU General Public License can be found in 14 | * LICENSE 15 | */ 16 | #pragma once 17 | 18 | #ifndef TOGGLE_H 19 | #define TOGGLE_H 20 | 21 | #include "always.h" 22 | #include "controlc.h" 23 | 24 | class ToggleClass : public ControlClass 25 | { 26 | public: 27 | ToggleClass(unsigned id, int x, int y, int w, int h); 28 | ToggleClass(ToggleClass &that); 29 | virtual ~ToggleClass() {} 30 | 31 | ToggleClass &operator=(ToggleClass &that); 32 | 33 | virtual BOOL Action(unsigned flags, KeyNumType &key) override; 34 | 35 | void Turn_On(); 36 | void Turn_Off(); 37 | 38 | void Set_Toggle_Bool1(BOOL unk) { m_Toggle_Boolean1 = unk; } 39 | void Set_Toggle_Disabled(BOOL disabled) { m_ToggleDisabled = disabled; } 40 | 41 | bool Get_Toggle_State() { return m_ToggleState; } 42 | 43 | protected: 44 | #ifndef CHRONOSHIFT_NO_BITFIELDS 45 | BOOL m_Toggle_Boolean1 : 1; // & 1 46 | BOOL m_ToggleState : 1; // & 2 47 | BOOL m_ToggleDisabled : 1; // & 4 48 | #else 49 | bool m_Toggle_Boolean1; 50 | bool m_ToggleState; 51 | bool m_ToggleDisabled; 52 | #endif 53 | }; 54 | 55 | inline ToggleClass &ToggleClass::operator=(ToggleClass &that) 56 | { 57 | if (this != &that) { 58 | ControlClass::operator=(that); 59 | m_Toggle_Boolean1 = that.m_Toggle_Boolean1; 60 | m_ToggleState = that.m_ToggleState; 61 | m_ToggleDisabled = that.m_ToggleDisabled; 62 | } 63 | 64 | return *this; 65 | } 66 | 67 | #endif // TOGGLE_H 68 | -------------------------------------------------------------------------------- /src/game/ui/trigauge.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author CCHyper 5 | * 6 | * @brief 7 | * 8 | * @copyright Chronoshift is free software: you can redistribute it and/or 9 | * modify it under the terms of the GNU General Public License 10 | * as published by the Free Software Foundation, either version 11 | * 2 of the License, or (at your option) any later version. 12 | * A full copy of the GNU General Public License can be found in 13 | * LICENSE 14 | */ 15 | #pragma once 16 | 17 | #ifndef TRICOLOR_H 18 | #define TRICOLOR_H 19 | 20 | #include "always.h" 21 | #include "gauge.h" 22 | 23 | class TriColorGaugeClass : public GaugeClass 24 | { 25 | public: 26 | TriColorGaugeClass(unsigned id, int x, int y, int w, int h) : GaugeClass(id, x, y, w, h), m_RedLimit(0), m_YellowLimit(0) 27 | { 28 | } 29 | TriColorGaugeClass(TriColorGaugeClass &that) : 30 | GaugeClass(that), m_RedLimit(that.m_RedLimit), m_YellowLimit(that.m_YellowLimit) 31 | { 32 | } 33 | virtual ~TriColorGaugeClass(void) {} 34 | 35 | TriColorGaugeClass &operator=(TriColorGaugeClass &that); 36 | 37 | // GadgetClass 38 | virtual BOOL Draw_Me(BOOL redraw) override; 39 | 40 | virtual bool Set_Red_Limit(int value); 41 | virtual bool Set_Yellow_Limit(int value); 42 | 43 | protected: 44 | int m_RedLimit; 45 | int m_YellowLimit; 46 | }; 47 | 48 | #endif // TRICOLOR_H 49 | -------------------------------------------------------------------------------- /src/game/ui/txtlabel.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author CCHyper 5 | * @author OmniBlade 6 | * 7 | * @brief Class representing UI text labels. 8 | * 9 | * @copyright Chronoshift is free software: you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation, either version 12 | * 2 of the License, or (at your option) any later version. 13 | * A full copy of the GNU General Public License can be found in 14 | * LICENSE 15 | */ 16 | #include "txtlabel.h" 17 | #include "language.h" 18 | 19 | TextLabelClass::TextLabelClass(char *text, int x, int y, RemapControlType *remap, TextPrintType style) : 20 | GadgetClass(x, y, 1, 1, INPUT_NONE, false), 21 | m_Lifetime(0), 22 | ID(0), 23 | m_TextStyle(style), 24 | LabelText(text), 25 | m_Remap(remap), 26 | m_MaxWidth(-1) 27 | { 28 | } 29 | 30 | TextLabelClass::TextLabelClass(TextLabelClass &that) : 31 | GadgetClass(that), 32 | m_Lifetime(that.m_Lifetime), 33 | ID(that.ID), 34 | m_TextStyle(that.m_TextStyle), 35 | LabelText(that.LabelText), 36 | m_Remap(that.m_Remap), 37 | m_MaxWidth(that.m_MaxWidth) 38 | { 39 | } 40 | 41 | BOOL TextLabelClass::Draw_Me(BOOL redraw) 42 | { 43 | if (GadgetClass::Draw_Me(redraw)) { 44 | if (m_MaxWidth == -1) { 45 | Simple_Text_Print(LabelText, m_XPos, m_YPos, m_Remap, 0, m_TextStyle); 46 | } else { 47 | Conquer_Clip_Text_Print(LabelText, m_XPos, m_YPos, m_Remap, 0, m_TextStyle, m_MaxWidth, nullptr); 48 | } 49 | 50 | return true; 51 | } 52 | 53 | return false; 54 | } 55 | 56 | void TextLabelClass::Set_Style(TextPrintType style) 57 | { 58 | m_TextStyle = style; 59 | } 60 | -------------------------------------------------------------------------------- /src/hooker/hookcrt.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author OmniBlade 5 | * 6 | * @brief Hooks for CRT functions to ensure same functions are called that maintain state. 7 | * 8 | * @copyright Chronoshift is free software: you can redistribute it and/or 9 | * modify it under the terms of the GNU General Public License 10 | * as published by the Free Software Foundation, either version 11 | * 2 of the License, or (at your option) any later version. 12 | * A full copy of the GNU General Public License can be found in 13 | * LICENSE 14 | */ 15 | #pragma once 16 | 17 | #ifndef HOOK_CRT_H 18 | #define HOOK_CRT_H 19 | 20 | #include "hooker.h" 21 | 22 | #endif // _HOOK_CRT_H 23 | -------------------------------------------------------------------------------- /src/hooker/setuphooks.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * @author OmniBlade 5 | * 6 | * @brief Function to hook all required functions. 7 | * 8 | * @copyright Chronoshift is free software: you can redistribute it and/or 9 | * modify it under the terms of the GNU General Public License 10 | * as published by the Free Software Foundation, either version 11 | * 2 of the License, or (at your option) any later version. 12 | * A full copy of the GNU General Public License can be found in 13 | * LICENSE 14 | */ 15 | 16 | #ifndef SETUP_HOOKS_H 17 | #define SETUP_HOOKS_H 18 | 19 | void Setup_Hooks(); 20 | 21 | #endif 22 | --------------------------------------------------------------------------------