diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 48c3a60..0000000 --- a/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -# git-ls-files --others --exclude-from=.git/info/exclude -# Lines that start with '#' are comments. -# For a project mostly in C, the following would be a good set of -# exclude patterns (uncomment them if you want to use them): -*.[oa] -avp diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..168f85f --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,341 @@ +# Aliens vs Predator Linux - http://icculus.org/avp/ +# CMake 2.8 project +CMAKE_MINIMUM_REQUIRED(VERSION 2.8) + +# default to Release +IF(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) + MESSAGE(STATUS "No build type specified, defaulting to Release") + SET(CMAKE_BUILD_TYPE Release CACHE STRING "Build type; one of: Debug Release RelWithDebInfo MinSizeRel" FORCE) + SET_PROPERTY(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo") +ENDIF(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) + +PROJECT(avp) + +# required dependencies +INCLUDE(FindSDL2.cmake) +INCLUDE(FindSDL) +INCLUDE(FindOpenGL) +INCLUDE(FindOpenAL) + +# Use SDL 1.2 if it is installed, else use SDL 2.0. +IF(NOT SDL_TYPE) + SET(SDL_TYPE AUTO CACHE STRING "SDL Version; one of: AUTO SDL SDL2") + SET_PROPERTY(CACHE SDL_TYPE PROPERTY STRINGS "AUTO" "SDL" "SDL2") +ENDIF(NOT SDL_TYPE) + +IF(NOT SDL_TYPE STREQUAL "AUTO" AND NOT SDL_TYPE STREQUAL "SDL" AND NOT SDL_TYPE STREQUAL "SDL2") + MESSAGE(FATAL_ERROR "Invalid SDL_TYPE setting ${SDL_TYPE}; must be one of AUTO SDL SDL2") +ENDIF(NOT SDL_TYPE STREQUAL "AUTO" AND NOT SDL_TYPE STREQUAL "SDL" AND NOT SDL_TYPE STREQUAL "SDL2") + +IF(SDL_TYPE STREQUAL "AUTO") + IF(SDL_FOUND) + MESSAGE(STATUS "SDL 1.2 found; using that.") + SET(SDL_TYPE "SDL") + ENDIF(SDL_FOUND) +ENDIF(SDL_TYPE STREQUAL "AUTO") + +IF(SDL_TYPE STREQUAL "AUTO") + IF(SDL2_FOUND) + MESSAGE(STATUS "SDL 2.0 found; using that.") + SET(SDL_TYPE "SDL2") + ENDIF(SDL2_FOUND) +ENDIF(SDL_TYPE STREQUAL "AUTO") + +IF(SDL_TYPE STREQUAL "AUTO") + MESSAGE(FATAL_ERROR "SDL 1.2 or SDL 2.0 is required but CMake couldn't find it.") +ENDIF(SDL_TYPE STREQUAL "AUTO") + +IF(SDL_TYPE STREQUAL "SDL") + IF(NOT SDL_FOUND) + MESSAGE(FATAL_ERROR "SDL 1.2 was requested but CMake couldn't find it.") + ENDIF(NOT SDL_FOUND) +ENDIF(SDL_TYPE STREQUAL "SDL") + +IF(SDL_TYPE STREQUAL "SDL2") + IF(NOT SDL2_FOUND) + MESSAGE(FATAL_ERROR "SDL 2.0 was requested but CMake couldn't find it.") + ENDIF(NOT SDL2_FOUND) + MESSAGE(WARNING "SDL 2.0 support is EXPERIMENTAL and INCOMPLETE.") +ENDIF(SDL_TYPE STREQUAL "SDL2") + +IF(NOT OPENGL_FOUND) + MESSAGE(FATAL_ERROR "OpenGL is required but CMake couldn't find it") +ENDIF(NOT OPENGL_FOUND) + +IF(NOT OPENAL_FOUND) + MESSAGE(FATAL_ERROR "OpenAL is required but CMake couldn't find it") +ENDIF(NOT OPENAL_FOUND) + +# required source files +LIST(APPEND source src/files.c) +LIST(APPEND source src/winapi.c) +LIST(APPEND source src/stubs.c) +LIST(APPEND source src/version.c) +LIST(APPEND source src/mathline.c) +LIST(APPEND source src/net.c) +LIST(APPEND source src/frustum.c) +LIST(APPEND source src/kshape.c) +LIST(APPEND source src/map.c) +LIST(APPEND source src/maths.c) +LIST(APPEND source src/md5.c) +LIST(APPEND source src/mem3dc.c) +LIST(APPEND source src/mem3dcpp.cpp) +LIST(APPEND source src/module.c) +LIST(APPEND source src/morph.c) +LIST(APPEND source src/object.c) +LIST(APPEND source src/shpanim.c) +LIST(APPEND source src/sphere.c) +LIST(APPEND source src/tables.c) +LIST(APPEND source src/vdb.c) +LIST(APPEND source src/avp/ai_sight.c) +LIST(APPEND source src/avp/avpview.c) +LIST(APPEND source src/avp/bh_agun.c) +LIST(APPEND source src/avp/bh_ais.c) +LIST(APPEND source src/avp/bh_alien.c) +LIST(APPEND source src/avp/bh_binsw.c) +LIST(APPEND source src/avp/bh_cable.c) +LIST(APPEND source src/avp/bh_corpse.c) +LIST(APPEND source src/avp/bh_deathvol.c) +LIST(APPEND source src/avp/bh_debri.c) +LIST(APPEND source src/avp/bh_dummy.c) +LIST(APPEND source src/avp/bh_fan.c) +LIST(APPEND source src/avp/bh_far.c) +LIST(APPEND source src/avp/bh_fhug.c) +LIST(APPEND source src/avp/bh_gener.c) +LIST(APPEND source src/avp/bh_ldoor.c) +LIST(APPEND source src/avp/bh_lift.c) +LIST(APPEND source src/avp/bh_light.c) +LIST(APPEND source src/avp/bh_lnksw.c) +LIST(APPEND source src/avp/bh_ltfx.c) +LIST(APPEND source src/avp/bh_marin.c) +LIST(APPEND source src/avp/bh_mission.c) +LIST(APPEND source src/avp/bh_near.c) +LIST(APPEND source src/avp/bh_pargen.c) +LIST(APPEND source src/avp/bh_plachier.c) +LIST(APPEND source src/avp/bh_plift.c) +LIST(APPEND source src/avp/bh_pred.c) +LIST(APPEND source src/avp/bh_queen.c) +LIST(APPEND source src/avp/bh_rubberduck.c) +LIST(APPEND source src/avp/bh_selfdest.c) +LIST(APPEND source src/avp/bh_snds.c) +LIST(APPEND source src/avp/bh_spcl.c) +LIST(APPEND source src/avp/bh_swdor.c) +LIST(APPEND source src/avp/bh_track.c) +LIST(APPEND source src/avp/bh_types.c) +LIST(APPEND source src/avp/bh_videoscreen.c) +LIST(APPEND source src/avp/bh_waypt.c) +LIST(APPEND source src/avp/bh_weap.c) +LIST(APPEND source src/avp/bh_xeno.c) +LIST(APPEND source src/avp/bonusabilities.c) +LIST(APPEND source src/avp/cconvars.cpp) +LIST(APPEND source src/avp/cdtrackselection.cpp) +LIST(APPEND source src/avp/cheatmodes.c) +LIST(APPEND source src/avp/comp_map.c) +LIST(APPEND source src/avp/comp_shp.c) +LIST(APPEND source src/avp/consolelog.cpp) +LIST(APPEND source src/avp/davehook.cpp) +LIST(APPEND source src/avp/deaths.c) +LIST(APPEND source src/avp/decal.c) +LIST(APPEND source src/avp/detaillevels.c) +LIST(APPEND source src/avp/dynamics.c) +LIST(APPEND source src/avp/dynblock.c) +LIST(APPEND source src/avp/equipmnt.c) +LIST(APPEND source src/avp/extents.c) +LIST(APPEND source src/avp/game.c) +LIST(APPEND source src/avp/game_statistics.c) +LIST(APPEND source src/avp/gamecmds.cpp) +LIST(APPEND source src/avp/gamevars.cpp) +LIST(APPEND source src/avp/hmodel.c) +LIST(APPEND source src/avp/hud.c) +LIST(APPEND source src/avp/inventry.c) +LIST(APPEND source src/avp/language.c) +LIST(APPEND source src/avp/lighting.c) +LIST(APPEND source src/avp/load_shp.c) +LIST(APPEND source src/avp/los.c) +LIST(APPEND source src/avp/mempool.c) +LIST(APPEND source src/avp/messagehistory.c) +LIST(APPEND source src/avp/missions.cpp) +LIST(APPEND source src/avp/movement.c) +LIST(APPEND source src/avp/paintball.c) +LIST(APPEND source src/avp/particle.c) +LIST(APPEND source src/avp/pfarlocs.c) +LIST(APPEND source src/avp/pheromon.c) +LIST(APPEND source src/avp/player.c) +LIST(APPEND source src/avp/pmove.c) +LIST(APPEND source src/avp/psnd.c) +LIST(APPEND source src/avp/psndproj.c) +LIST(APPEND source src/avp/pvisible.c) +LIST(APPEND source src/avp/savegame.c) +LIST(APPEND source src/avp/scream.cpp) +LIST(APPEND source src/avp/secstats.c) +LIST(APPEND source src/avp/sfx.c) +LIST(APPEND source src/avp/stratdef.c) +LIST(APPEND source src/avp/targeting.c) +LIST(APPEND source src/avp/track.c) +LIST(APPEND source src/avp/triggers.c) +LIST(APPEND source src/avp/weapons.c) +LIST(APPEND source src/avp/shapes/cube.c) +LIST(APPEND source src/avp/support/consbind.cpp) +LIST(APPEND source src/avp/support/consbtch.cpp) +LIST(APPEND source src/avp/support/coordstr.cpp) +LIST(APPEND source src/avp/support/daemon.cpp) +LIST(APPEND source src/avp/support/indexfnt.cpp) +LIST(APPEND source src/avp/support/r2base.cpp) +LIST(APPEND source src/avp/support/r2pos666.cpp) +LIST(APPEND source src/avp/support/reflist.cpp) +LIST(APPEND source src/avp/support/refobj.cpp) +LIST(APPEND source src/avp/support/rentrntq.cpp) +LIST(APPEND source src/avp/support/scstring.cpp) +LIST(APPEND source src/avp/support/strtab.cpp) +LIST(APPEND source src/avp/support/strutil.c) +LIST(APPEND source src/avp/support/trig666.cpp) +LIST(APPEND source src/avp/support/wrapstr.cpp) +LIST(APPEND source src/avp/win95/avpchunk.cpp) +LIST(APPEND source src/avp/win95/cheat.c) +LIST(APPEND source src/avp/win95/chtcodes.cpp) +LIST(APPEND source src/avp/win95/d3d_hud.cpp) +LIST(APPEND source src/avp/win95/ddplat.cpp) +LIST(APPEND source src/avp/win95/endianio.c) +LIST(APPEND source src/avp/win95/ffread.cpp) +LIST(APPEND source src/avp/win95/ffstdio.cpp) +LIST(APPEND source src/avp/win95/gammacontrol.cpp) +LIST(APPEND source src/avp/win95/hierplace.cpp) +LIST(APPEND source src/avp/win95/iofocus.cpp) +LIST(APPEND source src/avp/win95/jsndsup.cpp) +LIST(APPEND source src/avp/win95/kzsort.c) +LIST(APPEND source src/avp/win95/langplat.c) +LIST(APPEND source src/avp/win95/modcmds.cpp) +LIST(APPEND source src/avp/win95/npcsetup.cpp) +LIST(APPEND source src/avp/win95/objsetup.cpp) +LIST(APPEND source src/avp/win95/pathchnk.cpp) +LIST(APPEND source src/avp/win95/platsup.c) +LIST(APPEND source src/avp/win95/pldghost.c) +LIST(APPEND source src/avp/win95/pldnet.c) +LIST(APPEND source src/avp/win95/progress_bar.cpp) +LIST(APPEND source src/avp/win95/projload.cpp) +LIST(APPEND source src/avp/win95/scrshot.cpp) +LIST(APPEND source src/avp/win95/strachnk.cpp) +LIST(APPEND source src/avp/win95/system.c) +LIST(APPEND source src/avp/win95/usr_io.c) +LIST(APPEND source src/avp/win95/vision.c) +LIST(APPEND source src/avp/win95/frontend/avp_envinfo.c) +LIST(APPEND source src/avp/win95/frontend/avp_intro.cpp) +LIST(APPEND source src/avp/win95/frontend/avp_menudata.c) +LIST(APPEND source src/avp/win95/frontend/avp_menus.c) +LIST(APPEND source src/avp/win95/frontend/avp_mp_config.cpp) +LIST(APPEND source src/avp/win95/frontend/avp_userprofile.cpp) +LIST(APPEND source src/avp/win95/gadgets/ahudgadg.cpp) +LIST(APPEND source src/avp/win95/gadgets/conscmnd.cpp) +LIST(APPEND source src/avp/win95/gadgets/conssym.cpp) +LIST(APPEND source src/avp/win95/gadgets/consvar.cpp) +LIST(APPEND source src/avp/win95/gadgets/gadget.cpp) +LIST(APPEND source src/avp/win95/gadgets/hudgadg.cpp) +LIST(APPEND source src/avp/win95/gadgets/rootgadg.cpp) +LIST(APPEND source src/avp/win95/gadgets/t_ingadg.cpp) +LIST(APPEND source src/avp/win95/gadgets/teletype.cpp) +LIST(APPEND source src/avp/win95/gadgets/textexp.cpp) +LIST(APPEND source src/avp/win95/gadgets/textin.cpp) +LIST(APPEND source src/avp/win95/gadgets/trepgadg.cpp) +LIST(APPEND source src/win95/animchnk.cpp) +LIST(APPEND source src/win95/animobs.cpp) +LIST(APPEND source src/win95/awtexld.cpp) +LIST(APPEND source src/win95/awbmpld.cpp) +LIST(APPEND source src/win95/awiffld.cpp) +LIST(APPEND source src/win95/awpnmld.cpp) +LIST(APPEND source src/win95/bmpnames.cpp) +LIST(APPEND source src/win95/chnkload.cpp) +LIST(APPEND source src/win95/chnktexi.cpp) +LIST(APPEND source src/win95/chnktype.cpp) +LIST(APPEND source src/win95/chunk.cpp) +LIST(APPEND source src/win95/chunkpal.cpp) +LIST(APPEND source src/win95/db.c) +LIST(APPEND source src/win95/debuglog.cpp) +LIST(APPEND source src/win95/dummyobjectchunk.cpp) +LIST(APPEND source src/win95/enumchnk.cpp) +LIST(APPEND source src/win95/enumsch.cpp) +LIST(APPEND source src/win95/envchunk.cpp) +LIST(APPEND source src/win95/fail.c) +LIST(APPEND source src/win95/fragchnk.cpp) +LIST(APPEND source src/win95/gsprchnk.cpp) +LIST(APPEND source src/win95/hierchnk.cpp) +LIST(APPEND source src/win95/huffman.cpp) +LIST(APPEND source src/win95/iff.cpp) +LIST(APPEND source src/win95/iff_ilbm.cpp) +LIST(APPEND source src/win95/ilbm_ext.cpp) +LIST(APPEND source src/win95/io.c) +LIST(APPEND source src/win95/list_tem.cpp) +LIST(APPEND source src/win95/ltchunk.cpp) +LIST(APPEND source src/win95/media.cpp) +LIST(APPEND source src/win95/mishchnk.cpp) +LIST(APPEND source src/win95/obchunk.cpp) +LIST(APPEND source src/win95/oechunk.cpp) +LIST(APPEND source src/win95/our_mem.c) +LIST(APPEND source src/win95/plat_shp.c) +LIST(APPEND source src/win95/plspecfn.c) +LIST(APPEND source src/win95/shpchunk.cpp) +LIST(APPEND source src/win95/sndchunk.cpp) +LIST(APPEND source src/win95/sprchunk.cpp) +LIST(APPEND source src/win95/string.cpp) +LIST(APPEND source src/win95/texio.c) +LIST(APPEND source src/win95/toolchnk.cpp) +LIST(APPEND source src/win95/txioctrl.cpp) +LIST(APPEND source src/win95/wpchunk.cpp) +LIST(APPEND source src/win95/zsp.cpp) +LIST(APPEND source src/opengl.c) +LIST(APPEND source src/oglfunc.c) +LIST(APPEND source src/fmv.c) +LIST(APPEND source src/openal.c) +LIST(APPEND source src/cdplayer.c) +LIST(APPEND source src/menus.c) + +IF(SDL_TYPE STREQUAL "SDL") + LIST(APPEND source src/main.c) + + # SDL 1.2 on OS X requires this support file + IF(APPLE AND ${CMAKE_SYSTEM_NAME} MATCHES "Darwin") + LIST(APPEND source src/sdl12/sdlmain.m) + ENDIF(APPLE AND ${CMAKE_SYSTEM_NAME} MATCHES "Darwin") +ENDIF(SDL_TYPE STREQUAL "SDL") + +IF(SDL_TYPE STREQUAL "SDL2") + LIST(APPEND source src/main2.c) +ENDIF(SDL_TYPE STREQUAL "SDL2") + +### build all source as C++ +### (not normally used) +##SET_SOURCE_FILES_PROPERTIES(${source} PROPERTIES LANGUAGE CXX) + +# auto-include directories with source files +FOREACH(sourcefile IN LISTS source) + GET_FILENAME_COMPONENT(includedir ${sourcefile} DIRECTORY) + LIST(APPEND include ${includedir}) +ENDFOREACH(sourcefile) +INCLUDE_DIRECTORIES(${include}) + +# manually include src/include +INCLUDE_DIRECTORIES(src/include) + +ADD_EXECUTABLE(avp ${source}) + +# required dependencies +IF(SDL_TYPE STREQUAL "SDL") + INCLUDE_DIRECTORIES(${SDL_INCLUDE_DIR}) +ENDIF(SDL_TYPE STREQUAL "SDL") + +IF(SDL_TYPE STREQUAL "SDL2") + INCLUDE_DIRECTORIES(${SDL2_INCLUDE_DIR}) +ENDIF(SDL_TYPE STREQUAL "SDL2") + +INCLUDE_DIRECTORIES(${OPENGL_INCLUDE_DIR}) +INCLUDE_DIRECTORIES(${OPENAL_INCLUDE_DIR}) + +IF(SDL_TYPE STREQUAL "SDL") + TARGET_LINK_LIBRARIES(avp ${SDL_LIBRARY}) +ENDIF(SDL_TYPE STREQUAL "SDL") + +IF(SDL_TYPE STREQUAL "SDL2") + TARGET_LINK_LIBRARIES(avp ${SDL2_LIBRARY}) +ENDIF(SDL_TYPE STREQUAL "SDL2") + +TARGET_LINK_LIBRARIES(avp ${OPENGL_gl_LIBRARY}) +TARGET_LINK_LIBRARIES(avp ${OPENAL_LIBRARY}) diff --git a/FindSDL2.cmake b/FindSDL2.cmake new file mode 100644 index 0000000..4e6dab1 --- /dev/null +++ b/FindSDL2.cmake @@ -0,0 +1,168 @@ +# Locate SDL2 library +# This module defines +# SDL2_LIBRARY, the name of the library to link against +# SDL2_FOUND, if false, do not try to link to SDL2 +# SDL2_INCLUDE_DIR, where to find SDL.h +# +# This module responds to the the flag: +# SDL2_BUILDING_LIBRARY +# If this is defined, then no SDL2main will be linked in because +# only applications need main(). +# Otherwise, it is assumed you are building an application and this +# module will attempt to locate and set the the proper link flags +# as part of the returned SDL2_LIBRARY variable. +# +# Don't forget to include SDLmain.h and SDLmain.m your project for the +# OS X framework based version. (Other versions link to -lSDL2main which +# this module will try to find on your behalf.) Also for OS X, this +# module will automatically add the -framework Cocoa on your behalf. +# +# +# Additional Note: If you see an empty SDL2_LIBRARY_TEMP in your configuration +# and no SDL2_LIBRARY, it means CMake did not find your SDL2 library +# (SDL2.dll, libsdl2.so, SDL2.framework, etc). +# Set SDL2_LIBRARY_TEMP to point to your SDL2 library, and configure again. +# Similarly, if you see an empty SDL2MAIN_LIBRARY, you should set this value +# as appropriate. These values are used to generate the final SDL2_LIBRARY +# variable, but when these values are unset, SDL2_LIBRARY does not get created. +# +# +# $SDL2DIR is an environment variable that would +# correspond to the ./configure --prefix=$SDL2DIR +# used in building SDL2. +# l.e.galup 9-20-02 +# +# Modified by Eric Wing. +# Added code to assist with automated building by using environmental variables +# and providing a more controlled/consistent search behavior. +# Added new modifications to recognize OS X frameworks and +# additional Unix paths (FreeBSD, etc). +# Also corrected the header search path to follow "proper" SDL guidelines. +# Added a search for SDL2main which is needed by some platforms. +# Added a search for threads which is needed by some platforms. +# Added needed compile switches for MinGW. +# +# On OSX, this will prefer the Framework version (if found) over others. +# People will have to manually change the cache values of +# SDL2_LIBRARY to override this selection or set the CMake environment +# CMAKE_INCLUDE_PATH to modify the search paths. +# +# Note that the header path has changed from SDL2/SDL.h to just SDL.h +# This needed to change because "proper" SDL convention +# is #include "SDL.h", not . This is done for portability +# reasons because not all systems place things in SDL2/ (see FreeBSD). + +#============================================================================= +# Copyright 2003-2009 Kitware, Inc. +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) + +SET(SDL2_SEARCH_PATHS + ~/Library/Frameworks + /Library/Frameworks + /usr/local + /usr + /sw # Fink + /opt/local # DarwinPorts + /opt/csw # Blastwave + /opt +) + +FIND_PATH(SDL2_INCLUDE_DIR + NAMES + SDL_gesture.h # A SDL2-only header + HINTS + $ENV{SDL2DIR} + PATH_SUFFIXES + include/SDL2 + include + PATHS + ${SDL2_SEARCH_PATHS} +) + +FIND_LIBRARY(SDL2_LIBRARY_TEMP + NAMES SDL2 + HINTS + $ENV{SDL2DIR} + PATH_SUFFIXES lib64 lib + PATHS ${SDL2_SEARCH_PATHS} +) + +IF(NOT SDL2_BUILDING_LIBRARY) + IF(NOT ${SDL2_INCLUDE_DIR} MATCHES ".framework") + # Non-OS X framework versions expect you to also dynamically link to + # SDL2main. This is mainly for Windows and OS X. Other (Unix) platforms + # seem to provide SDL2main for compatibility even though they don't + # necessarily need it. + FIND_LIBRARY(SDL2MAIN_LIBRARY + NAMES SDL2main + HINTS + $ENV{SDL2DIR} + PATH_SUFFIXES lib64 lib + PATHS ${SDL2_SEARCH_PATHS} + ) + ENDIF(NOT ${SDL2_INCLUDE_DIR} MATCHES ".framework") +ENDIF(NOT SDL2_BUILDING_LIBRARY) + +# SDL2 may require threads on your system. +# The Apple build may not need an explicit flag because one of the +# frameworks may already provide it. +# But for non-OSX systems, I will use the CMake Threads package. +IF(NOT APPLE) + FIND_PACKAGE(Threads) +ENDIF(NOT APPLE) + +# MinGW needs an additional library, mwindows +# It's total link flags should look like -lmingw32 -lSDL2main -lSDL2 -lmwindows +# (Actually on second look, I think it only needs one of the m* libraries.) +IF(MINGW) + SET(MINGW32_LIBRARY mingw32 CACHE STRING "mwindows for MinGW") +ENDIF(MINGW) + +IF(SDL2_LIBRARY_TEMP) + # For SDL2main + IF(NOT SDL2_BUILDING_LIBRARY) + IF(SDL2MAIN_LIBRARY) + SET(SDL2_LIBRARY_TEMP ${SDL2MAIN_LIBRARY} ${SDL2_LIBRARY_TEMP}) + ENDIF(SDL2MAIN_LIBRARY) + ENDIF(NOT SDL2_BUILDING_LIBRARY) + + # For OS X, SDL2 uses Cocoa as a backend so it must link to Cocoa. + # CMake doesn't display the -framework Cocoa string in the UI even + # though it actually is there if I modify a pre-used variable. + # I think it has something to do with the CACHE STRING. + # So I use a temporary variable until the end so I can set the + # "real" variable in one-shot. + IF(APPLE) + SET(SDL2_LIBRARY_TEMP ${SDL2_LIBRARY_TEMP} "-framework Cocoa") + ENDIF(APPLE) + + # For threads, as mentioned Apple doesn't need this. + # In fact, there seems to be a problem if I used the Threads package + # and try using this line, so I'm just skipping it entirely for OS X. + IF(NOT APPLE) + SET(SDL2_LIBRARY_TEMP ${SDL2_LIBRARY_TEMP} ${CMAKE_THREAD_LIBS_INIT}) + ENDIF(NOT APPLE) + + # For MinGW library + IF(MINGW) + SET(SDL2_LIBRARY_TEMP ${MINGW32_LIBRARY} ${SDL2_LIBRARY_TEMP}) + ENDIF(MINGW) + + # Set the final string here so the GUI reflects the final state. + SET(SDL2_LIBRARY ${SDL2_LIBRARY_TEMP} CACHE STRING "Where the SDL2 Library can be found") + # Set the temp variable to INTERNAL so it is not seen in the CMake GUI + SET(SDL2_LIBRARY_TEMP "${SDL2_LIBRARY_TEMP}" CACHE INTERNAL "") +ENDIF(SDL2_LIBRARY_TEMP) + +INCLUDE(FindPackageHandleStandardArgs) + +FIND_PACKAGE_HANDLE_STANDARD_ARGS(SDL2 REQUIRED_VARS SDL2_LIBRARY SDL2_INCLUDE_DIR) diff --git a/LICENSE b/LICENSE index 7d5d285..fd47c27 100644 --- a/LICENSE +++ b/LICENSE @@ -1,5 +1,10 @@ +The copyright statement for the original version of the source code: The source code to Aliens Vs Predator is copyright (c) 1999-2000 Rebellion and is provided as is with no warranty for its suitability for use. You may not use this source code in full or in part for commercial purposes. Any use must include a clearly visible credit to Rebellion as the creators and owners, and reiteration of this license. + +Any changes made after the fact are not copyright Rebellion and are provided +as is with no warranty for its suitability for use. You still may not use +this source code in full or in part for commercial purposes. diff --git a/Makefile b/Makefile deleted file mode 100644 index 5e6a23f..0000000 --- a/Makefile +++ /dev/null @@ -1,58 +0,0 @@ -CC = gcc -CXX = g++ - -CFLAGS = -m32 -g -Wall -pipe -#CFLAGS += -O2 -#CFLAGS += -DNDEBUG -O6 -ffast-math -fomit-frame-pointer -march=pentium3 -mtune=pentium4 - -CFLAGS += -Isrc -Isrc/include -Isrc/win95 -Isrc/avp -Isrc/avp/win95 -Isrc/avp/support -Isrc/avp/win95/frontend -Isrc/avp/win95/gadgets -CFLAGS += $(shell sdl-config --cflags) $(shell pkg-config openal --cflags) -CXXFLAGS = $(CFLAGS) - -LDLIBS = -m32 $(shell sdl-config --libs) $(shell pkg-config openal --libs) - -ROOT = main.c files.c winapi.c stubs.c version.c mathline.c opengl.c fmv.c oglfunc.c openal.c cdplayer.c menus.c net.c frustum.c kshape.c map.c maths.c md5.c mem3dc.c mem3dcpp.cpp module.c morph.c object.c shpanim.c sphere.c tables.c vdb.c -AVP = ai_sight.c avpview.c bh_agun.c bh_ais.c bh_alien.c bh_binsw.c bh_cable.c bh_corpse.c bh_deathvol.c bh_debri.c bh_dummy.c bh_fan.c bh_far.c bh_fhug.c bh_gener.c bh_ldoor.c bh_lift.c bh_light.c bh_lnksw.c bh_ltfx.c bh_marin.c bh_mission.c bh_near.c bh_pargen.c bh_plachier.c bh_plift.c bh_pred.c bh_queen.c bh_rubberduck.c bh_selfdest.c bh_snds.c bh_spcl.c bh_swdor.c bh_track.c bh_types.c bh_videoscreen.c bh_waypt.c bh_weap.c bh_xeno.c bonusabilities.c cconvars.cpp cdtrackselection.cpp cheatmodes.c comp_map.c comp_shp.c consolelog.cpp davehook.cpp deaths.c decal.c detaillevels.c dynamics.c dynblock.c equipmnt.c extents.c game.c game_statistics.c gamecmds.cpp gamevars.cpp hmodel.c hud.c inventry.c language.c lighting.c load_shp.c los.c mempool.c messagehistory.c missions.cpp movement.c paintball.c particle.c pfarlocs.c pheromon.c player.c pmove.c psnd.c psndproj.c pvisible.c savegame.c scream.cpp secstats.c sfx.c stratdef.c targeting.c track.c triggers.c weapons.c -SHAPES = cube.c -SUPPORT = consbind.cpp consbtch.cpp coordstr.cpp daemon.cpp indexfnt.cpp r2base.cpp r2pos666.cpp reflist.cpp refobj.cpp rentrntq.cpp scstring.cpp strtab.cpp strutil.c trig666.cpp wrapstr.cpp -AVPWIN95 = avpchunk.cpp cheat.c chtcodes.cpp d3d_hud.cpp ddplat.cpp endianio.c ffread.cpp ffstdio.cpp gammacontrol.cpp hierplace.cpp iofocus.cpp jsndsup.cpp kzsort.c langplat.c modcmds.cpp npcsetup.cpp objsetup.cpp pathchnk.cpp platsup.c pldghost.c pldnet.c progress_bar.cpp projload.cpp scrshot.cpp strachnk.cpp system.c usr_io.c vision.c -FRONTEND = avp_envinfo.c avp_intro.cpp avp_menudata.c avp_menus.c avp_mp_config.cpp avp_userprofile.cpp -GADGETS = ahudgadg.cpp conscmnd.cpp conssym.cpp consvar.cpp gadget.cpp hudgadg.cpp rootgadg.cpp t_ingadg.cpp teletype.cpp textexp.cpp textin.cpp trepgadg.cpp -WIN95 = animchnk.cpp animobs.cpp awtexld.cpp awbmpld.cpp awiffld.cpp awpnmld.cpp bmpnames.cpp chnkload.cpp chnktexi.cpp chnktype.cpp chunk.cpp chunkpal.cpp db.c debuglog.cpp dummyobjectchunk.cpp enumchnk.cpp enumsch.cpp envchunk.cpp fail.c fragchnk.cpp gsprchnk.cpp hierchnk.cpp huffman.cpp iff.cpp iff_ilbm.cpp ilbm_ext.cpp io.c list_tem.cpp ltchunk.cpp media.cpp mishchnk.cpp obchunk.cpp oechunk.cpp our_mem.c plat_shp.c plspecfn.c shpchunk.cpp sndchunk.cpp sprchunk.cpp string.cpp texio.c toolchnk.cpp txioctrl.cpp wpchunk.cpp zsp.cpp - -# the following should really be autogenerated... - -SRCNAMES = $(addprefix $(2)/,$(1)) -OBJNAMES = $(addprefix $(2)/,$(addsuffix .o,$(basename $(1)))) - -ROOTSRC = $(call SRCNAMES,$(ROOT),src) -ROOTOBJ = $(call OBJNAMES,$(ROOT),src) -AVPSRC = $(call SRCNAMES,$(AVP),src/avp) -AVPOBJ = $(call OBJNAMES,$(AVP),src/avp) -SHAPESSRC = $(call SRCNAMES,$(SHAPES),src/avp/shapes) -SHAPESOBJ = $(call OBJNAMES,$(SHAPES),src/avp/shapes) -SUPPORTSRC = $(call SRCNAMES,$(SUPPORT),src/avp/support) -SUPPORTOBJ = $(call OBJNAMES,$(SUPPORT),src/avp/support) -AVPWIN95SRC = $(call SRCNAMES,$(AVPWIN95),src/avp/win95) -AVPWIN95OBJ = $(call OBJNAMES,$(AVPWIN95),src/avp/win95) -FRONTENDSRC = $(call SRCNAMES,$(FRONTEND),src/avp/win95/frontend) -FRONTENDOBJ = $(call OBJNAMES,$(FRONTEND),src/avp/win95/frontend) -GADGETSSRC = $(call SRCNAMES,$(GADGETS),src/avp/win95/gadgets) -GADGETSOBJ = $(call OBJNAMES,$(GADGETS),src/avp/win95/gadgets) -WIN95SRC = $(call SRCNAMES,$(WIN95),src/win95) -WIN95OBJ = $(call OBJNAMES,$(WIN95),src/win95) - -SRC = $(ROOTSRC) $(AVPSRC) $(SHAPESSRC) $(SUPPORTSRC) $(AVPWIN95SRC) $(FRONTENDSRC) $(GADGETSSRC) $(WIN95SRC) -OBJ = $(ROOTOBJ) $(AVPOBJ) $(SHAPESOBJ) $(SUPPORTOBJ) $(AVPWIN95OBJ) $(FRONTENDOBJ) $(GADGETSOBJ) $(WIN95OBJ) - -all: avp - -avp: $(OBJ) - $(CXX) -o avp $(OBJ) $(LDLIBS) - -clean: - -rm -rf $(OBJ) avp - -distclean: clean - -rm -rf `find . \( -not -type d \) -and \ - \( -name '*~' -or -name '.#*' \) -type f -print` diff --git a/README b/README index 9d33e71..5bdd578 100644 --- a/README +++ b/README @@ -1,137 +1,279 @@ Aliens vs Predator Linux http://icculus.org/avp/ ------------------------ -This is an unofficial Linux port of the Fox Interactive / Rebellion -Developments game, Aliens Versus Predator. +Table of Contents: +1. Introduction +2. Current Status +3. Compilation +4. Installation +5. Credits +a. Gold edition MD5s +Part 1: Introduction +-------------------- + +This is an unofficial Linux and Mac OS X port of the Fox Interactive / +Rebellion Developments game, Aliens Versus Predator Gold. + +More information can be found at the project homepage and the Discourse +forum. + +http://icculus.org/avp/ +http://community.ioquake.org/c/avp + +Please see LICENSE for copyright and licensing information. +Part 2: Current Status +---------------------- -(Please see note below regarding installation/running.) +As of this release, i686 and x86_64 builds have been tested on Mac OS X +10.8, Ubuntu 14.04 LTS and Fedora 21. + +Previously missing features are still missing. Multiplayer, movies, etc. -Obviously this README is totally incomplete, and will probably remain so for -quite a while, so I'll just try to list a few important notes. +Part 3: Compilation +------------------- + +CMake, SDL 1.2, OpenAL and OpenGL support are required. SDL 2.0 support is +also available but is experimental and incomplete at this time. + +An example of how to use CMake to build the game: +$ tar xvzf .tar.gz +$ cd +$ mkdir build +$ cd build +$ cmake .. +$ make + +If all goes well, an executable named "avp" will be built. -The original copyright statement for the source code: -"The source code to Aliens Vs Predator is copyright (c) 1999-2000 Rebellion - and is provided as is with no warranty for its suitability for use. You may - not use this source code in full or in part for commercial purposes. Any use - must include a clearly visible credit to Rebellion as the creators and - owners, and reiteration of this license." -Take that as you will. -You can find the original source code and other related tools at: -http://www.avpnews.com/mods/tools/ +Part 4: Installation +-------------------- + +All of the AvP game data, files and directories, need to be lowercase. +Either copy the avp executable to the game data directory or set the +AVP_DATA environment variable to the game data directory. + +Local user settings are stored in ~/.avp. -Yes, the code does something. No, it's not ready for a release. No, it is not -vaporware. I hope to at least complete the single player part of the game -before making an official release. Check out the TODO to see what's needed to -be done. +Part 5: Credits +--------------- + +The original game is by Rebellion Developments. + +Tim Beckmann, various code cleanup fixes +Chuck Mason, initial OpenAL implementation + +For everything else, there's http://community.ioquake.org/c/avp -If you are really itching to try this out, either install the Gold Ed. in -windows/vmware (read below to find out why), or download the AvP Alien demo. -If you are wanting to run the Alien demo (the installer is an .exe but you -can just use unzip to extract the files from the .exe), add -DALIEN_DEMO to -the CFLAGS line (the one that's uncommented) in the Makefile. Rename all game -files lowercase. Be sure to install SDL 1.2 (http://www.libsdl.org) with -OpenGL support, nasm 0.98, and the latest OpenAL CVS (http://www.openal.org). -AvP requires a 3D card with OpenGL support. +Appendix A: Gold edition MD5s +----------------------------- -*** -IMPORTANT: -AvP now uses $HOME/.avp/ to load/store configs, logs, etc. -NOTE: Windows profiles probably do not work in Linux and vice versa. - -AvP will no longer use the current working directory to look for files. You -must either copy or symlink the AvP binary to the game data directory and run -that, or set AVP_DATA to the data directory. - -Currently: -If you want to install the mappacks from -http://www.avpnews.com/files/avpfiles.html, install them with the rest of -the game data, not in ~/.avp/. Make sure everything is lowercase (although, -the maps in avp_rifs/Custom do not have to be totally lowercase, just the .rif -extension). Maybe in the future users will be able to install the files in -~/.avp/ also. - -Hopefully all the necessary file loading changes were made. Please let me -know if something goes wrong. -*** - -The next line can be ignored for now: -If you have the regular edition, add -DREGULAR_EDITION to CFLAGS. - -If the version you want to use is not the Gold Edition, download -http://www.icculus.org/avp/english.txt.gz, extract it, and rename it -language.txt (Regular Ed.) or aenglish.txt (Alien Demo). - -If you get "Aborted" after starting a new game the second time or so, -try recompiling with gcc-3.0.2. This problem should be fixed now; if not, -let me know. - -The OpenGL library is loaded dynamically. This means that if there is -a problem initializing OpenGL, it will not occur until you start -a new game. - - -relnev:~/avp/AvP Demo 3 - Alien$ ls -aenglish.txt alienavp_huds/ alienfastfile/ avp_rifs/ -relnev:~/avp/Gold Edition$ ls -avp_huds/ avp_rifs/ cd tracks.txt fastfile/ language.txt - -Support for the demo is not quite complete (some sounds are missing). - - -Linux Port-specific commands: -- ALT-ENTER for fullscreen -- CTRL-G for mouse grab -- PRTSCN for screenshot - - -The source code that was released only works with Aliens vs Predator Gold. -This port currently supports Gold Edition, Regular, and the Alien demo. -(The Marine and Predator demos are a bit older and might not work.) - - -At least with the Gold edition, a number of files are encoded on the CD. So -you would need to install the game in Windows (VMware works also) in order -to get this to work. WINE will not work because the CD Check fails. - - -Currently, all AvP files and directories need to be lowercase, and the -program ran from the directory with all the game data (language.txt, -avp_huds, avp_rifs, fastfile). zakk recommends -http://blemished.net/chcase.html for renaming the files. - - -Apparantly AvP Gold is no longer available at most places. I had ordered my -copy May 2001 from http://www.dragon.ca, but they no longer list it. -Try searching http://www.amazon.com, http://www.ebgames.com, -http://www.ebay.com, or the bargin bin at your local computer store. - - -It is unknown if the Mac Gold Edition will work with this (I'd be interested -in knowing if it does or not). - - -The full motion sequences cannot be played because they are encoded with -proprietary codecs (Bink and Smacker - http://www.radgametools.com). But I -do not think they will be greatly missed. - - -More information about the game and the series can be found at -http://www.avpnews.com. - - -Last, but definitely not least: -Thanks go out to Chuck Mason for testing and the OpenAL code, Dan Olson for -trying the code out with the Regular version, Zachary 'zakk' Slater for -providing tons of feedback, Tim Beckmann for sending patches, and Ryan C. -Gordon for hosting this project. - ---- -Steven Fuller +A proper install of the Gold edition should look similar to this: +MD5 (avp_huds/alien.rif) = 4267d305ad3f18e6683f86b4eb755665 +MD5 (avp_huds/alien_hud.rif) = ff6b892af4665c81082e24a43903e987 +MD5 (avp_huds/disk.rif) = fe9a1f4e5caab35e38aabdbbb445aabc +MD5 (avp_huds/dropship.rif) = 4f8ad8e9a4c43e2216ad2bc0dbe29ea5 +MD5 (avp_huds/hnpc_civvie.rif) = 5d06ea82a096558d70069c8a48830ec0 +MD5 (avp_huds/hnpc_xenoborg.rif) = 92ab2760ff7abf2a4fdb691c8cfb8222 +MD5 (avp_huds/hnpcalien.rif) = 1867c90c8f3101eaea42294b8da70f2d +MD5 (avp_huds/hnpchugger.rif) = b12d7b171ffb4c8699416543010663d0 +MD5 (avp_huds/hnpcmarine.rif) = a220b5822b58b6c8f9a6d26a4774289e +MD5 (avp_huds/hnpcpred_alien.rif) = 85ae382e13c7f438d32bb971f21dedf0 +MD5 (avp_huds/hnpcpredator.rif) = 31ab741eba3fbc9c72a801bc68901847 +MD5 (avp_huds/hnpcpretorian.rif) = 4221affbcd0a132a87fc1ed3528f9abb +MD5 (avp_huds/marine.rif) = 906b7ad1522ee507f3ae635db174bd2e +MD5 (avp_huds/marwep.rif) = 709e70ece003374fba61640dcb73ed9f +MD5 (avp_huds/mdisk.rif) = bf5313faefed4f5ee5876bf811b3e16d +MD5 (avp_huds/multip.rif) = 0f47112c36bdcc7ce2d36d9f65ae264b +MD5 (avp_huds/pred ship fury.rif) = 514f1a7248db2315081c36e40a5cf041 +MD5 (avp_huds/pred ship ob.rif) = 5c50c6a1b9b651c5b9bdf66fa1b2f955 +MD5 (avp_huds/pred_hud.rif) = 2207090cd22a96afec84ed01ef72ea05 +MD5 (avp_huds/predator.rif) = 735c0f33db055322ebf95363acc69119 +MD5 (avp_huds/queen.rif) = 1800cd24226db14b36549b06175fb6e5 +MD5 (avp_huds/sentry.rif) = 16d2efb5095fec300dd60698ff445fb2 +MD5 (avp_huds/tongue.rif) = c09dbf413ea107bccce9b3b917a5d800 +MD5 (avp_rifs/als-dm-coop.rif) = 8777d7f7bbfe7a87cc37e9b766be8bba +MD5 (avp_rifs/als-dm.rif) = 1a4fdffafb4678b8d0ca2537cc4ae689 +MD5 (avp_rifs/area52.rif) = b52af8fa3ec154a83ca8fbe71fa9a59d +MD5 (avp_rifs/base.rif) = a054573e82728d0656eea4757f1077d3 +MD5 (avp_rifs/battle.rif) = 107a3fb48ebdb000ae652f4a6d0a9c72 +MD5 (avp_rifs/breakout.rif) = b94444bbc581d8aaf398ad07fdc425d3 +MD5 (avp_rifs/breakout_p.rif) = 18d9dc2d979a99c410ddbd4ddf785b78 +MD5 (avp_rifs/caverns.rif) = b761218c32e4f210aee42b7d40acde2c +MD5 (avp_rifs/caverns_a.rif) = 3bf4871492c958c1915615b292390181 +MD5 (avp_rifs/co-op_meat_factory.rif) = fe6e7cb73750f18f0bfee097b229b6a4 +MD5 (avp_rifs/colony_c.rif) = 2dc68e92a8cf2c47a47dd8ff827e5abd +MD5 (avp_rifs/compound.rif) = b954a582c4976cbab95859d31fd210f7 +MD5 (avp_rifs/compoundcoop.rif) = 02c770a1e88533d7156fac9cbaa7f624 +MD5 (avp_rifs/derelict.rif) = aa1a029da32eeffd3e30bb1291e6ad5d +MD5 (avp_rifs/derelict_a.rif) = 917cb15d9ffe404630544b0e41444316 +MD5 (avp_rifs/e3demo.rif) = e102b1def6220aff18e57b0b9f6f6731 +MD5 (avp_rifs/e3demosp.rif) = 6720212a41d0c7e51b7e3c03fbc32e84 +MD5 (avp_rifs/elevator.rif) = ec7b75ca1730c8db5f239900c7c41fa3 +MD5 (avp_rifs/elevator_co-op.rif) = 28403b2be75c24744aa3d0c3c3422fd7 +MD5 (avp_rifs/escape.rif) = e0919deb6a55778f65ff9b2ef0068944 +MD5 (avp_rifs/escape_p.rif) = 9e1fb4bcb05f2c640a95ba0ad494233b +MD5 (avp_rifs/fall.rif) = a3d7902cdf78253d742818153241248c +MD5 (avp_rifs/fall_m.rif) = d7af5d070fedb847ded66206c475546e +MD5 (avp_rifs/furyall.rif) = 09c0510003892184d760b278c1da9476 +MD5 (avp_rifs/furyall_a.rif) = 4b9bb88e60a115136bcf66c4a56be2cb +MD5 (avp_rifs/genshd1.rif) = 38865339152458110bee6c0e87b5d509 +MD5 (avp_rifs/hadleyshope.rif) = 773c69733b063cff7da53d53e8de443a +MD5 (avp_rifs/hadleyshope_coop.rif) = d95a1981e3ea6187160ae6c5ca6dffe8 +MD5 (avp_rifs/hangar.rif) = 46f27e38c2f1e39f5b8af85d25f97d21 +MD5 (avp_rifs/hive.rif) = aff965e71897a2efa2919096559a1f29 +MD5 (avp_rifs/hive_c.rif) = 861a90530bb903bbd4daa1b25c484bed +MD5 (avp_rifs/invasion.rif) = 2355ae72ef68960d881a2df1f7cdfbb5 +MD5 (avp_rifs/invasion_a.rif) = e57cd3ba63064229b2b11a2f83014089 +MD5 (avp_rifs/invasion_p.rif) = 13372362090e5e52d40fae53bcb221a0 +MD5 (avp_rifs/jockey.rif) = a2942f0c76ca13ff05e72e059f4e8511 +MD5 (avp_rifs/jockeycoop.rif) = eb1064bdbfff5befba0148bd9136f263 +MD5 (avp_rifs/kens-co-op.rif) = 55d8ff72d70c9d416509df7c5eca7ba6 +MD5 (avp_rifs/lab14.rif) = 283b3b88adfa848b8d6bfbb21bd50013 +MD5 (avp_rifs/lab14coop.rif) = 7a391b85893f457c833643ce65970742 +MD5 (avp_rifs/leadworks.rif) = 2bb1a602ae00ff843f8cd671a3412b5b +MD5 (avp_rifs/leadworks_coop.rif) = 896bf46cd67a7c2a68f99ae5824c43ea +MD5 (avp_rifs/lockdown4.rif) = ae6ff47adeb2fc7969591bc2e278ce93 +MD5 (avp_rifs/meat_factory.rif) = 90078c255d306961836b7bf3a6ce026e +MD5 (avp_rifs/nost03.rif) = b6c20145b51e9abc46939b1ea55aa986 +MD5 (avp_rifs/nost03_m.rif) = 2cc94c22cb23cd02c708a4c076ec324a +MD5 (avp_rifs/nostromo.rif) = ee84b908593ebf05558b074a87611645 +MD5 (avp_rifs/nostromo_coop.rif) = af556b4a5cf6c66695bdb07e6823d984 +MD5 (avp_rifs/odobenus.rif) = 33fcb7fd8879c1a3af030830eb3540a3 +MD5 (avp_rifs/office.rif) = 8d70b915a2e0c276481dfda1c265f9f0 +MD5 (avp_rifs/stat101.rif) = fe44c96e2f3a031f3a4374da4df445a5 +MD5 (avp_rifs/stat101_m.rif) = 205089ea581f03cc56d251ca31fc2df8 +MD5 (avp_rifs/statue.rif) = ff47b9db187211920994f1dcd5ed5599 +MD5 (avp_rifs/subway.rif) = 620ea0cc73f516ed8adecbdff6f789ed +MD5 (avp_rifs/subwaycoop.rif) = 63e4ef8b8f1a93b1c461b34350c8d217 +MD5 (avp_rifs/sulaco.rif) = d401b6f78170161623893d97ff59b53a +MD5 (avp_rifs/sulaco_a.rif) = c4fd18fd7e27b734318c2a2e5e4475c3 +MD5 (avp_rifs/sulaco_p.rif) = 4d794c520a0ffbc597514d1b9eaf4593 +MD5 (avp_rifs/temple.rif) = 1302a03fb0dba9b45c76e55ea89683fe +MD5 (avp_rifs/temple_m.rif) = b7a024ffd6f2b50b93338ba84996093d +MD5 (avp_rifs/temple_p.rif) = 8e4fe32448e5dbb9b0b571d126b81fba +MD5 (avp_rifs/trapped.rif) = a5ceca52bd19098daa02fe8138ed29a4 +MD5 (avp_rifs/vaults.rif) = ef7d4e3fd13fc5b4294e58033d582c65 +MD5 (avp_rifs/vaults_m.rif) = ac4b4bdae7f6dd2e8e4a2be9e38a0092 +MD5 (fastfile/aliensound.dat) = 663211754e9f742cc66dd7b67d99d9ea +MD5 (fastfile/common.ffl) = 6c3818f03a987b99e28713289eb84556 +MD5 (fastfile/ffinfo.txt) = 8011119b8456329457f0872037b22243 +MD5 (fastfile/marsound.dat) = aa69bb3181234fabb025ea50c036a311 +MD5 (fastfile/predsound.dat) = 4fef41f3367e6b2325703f0d6bbbe578 +MD5 (fastfile/queensound.dat) = 25dc700a67228db461cadb914efee05e +MD5 (fastfile/snd10.ffl) = 2142e48b243d71ed93c92f54d7b8a605 +MD5 (fastfile/snd11.ffl) = 7d6efc94c1eac7cab969ab2cf4a8f0f8 +MD5 (fastfile/snd12.ffl) = 993d75ed2eaa92db171437de90d0d021 +MD5 (fastfile/snd13.ffl) = 27bd66d194e811d7a004e1143aff9cee +MD5 (fastfile/snd14.ffl) = 7c0694d9ac8d7fff5a71bf268f296610 +MD5 (fastfile/snd15.ffl) = d4e717f36d3244b67fc44375ca747eed +MD5 (fastfile/snd16.ffl) = 9fecdd75362782f8cd695a9cbb716509 +MD5 (fastfile/snd17.ffl) = 1e3c73765ab4bf012f7a0c8835536d68 +MD5 (fastfile/snd18.ffl) = a36a92af0c981896496d2b1e2fa16d69 +MD5 (fastfile/snd19.ffl) = 2cba77b90216cf238e8e67431c0c2509 +MD5 (fastfile/snd2.ffl) = 6447697cc0bf026ceac07e58c8e6acb0 +MD5 (fastfile/snd20.ffl) = 5712e0d0f8d6dca2ecf12e154c2f3668 +MD5 (fastfile/snd21.ffl) = 8648a5360ef375ab812fb5f1aa98deaa +MD5 (fastfile/snd22.ffl) = 625d35cf9eabb987172ecd01385de5a8 +MD5 (fastfile/snd23.ffl) = e17a0b0135e47a3f0284f01b46e54ba4 +MD5 (fastfile/snd24.ffl) = f083983ecb863bdfd414c76a6dd0cc4c +MD5 (fastfile/snd25.ffl) = 9d342e0e05cf34d62ad19d92a336aa94 +MD5 (fastfile/snd26.ffl) = b298641d60b39dfe1f20a331c8def4f4 +MD5 (fastfile/snd27.ffl) = fa5521d0c54c256931a6dfa1007b226d +MD5 (fastfile/snd28.ffl) = 4175b3f72363d0e90a84c8f87b098160 +MD5 (fastfile/snd29.ffl) = 4814847b1ce58b97c510712089a96088 +MD5 (fastfile/snd3.ffl) = 88f6cb4ebca040a39e33671b60eaeb95 +MD5 (fastfile/snd30.ffl) = 417e358abaf2600c8c893bb7c83e6bfa +MD5 (fastfile/snd31.ffl) = 53020a87d8e31c9c352411b6ef3d3327 +MD5 (fastfile/snd32.ffl) = 4cb3a5e71ea6e75aa7dac3da93a47c0d +MD5 (fastfile/snd33.ffl) = 82bfe46770fc10f2bb766bc833de5d8a +MD5 (fastfile/snd34.ffl) = 2e0ceccebd393007c649f95972ae1217 +MD5 (fastfile/snd35.ffl) = f94bac7b5f8d412683282608bbacf87f +MD5 (fastfile/snd36.ffl) = 60c6f42caba59a668b556fcd82c09110 +MD5 (fastfile/snd37.ffl) = 5923b35cc4c85b4b00c683db2a967009 +MD5 (fastfile/snd38.ffl) = 9707d7ec21860d27926b8ca1fea32511 +MD5 (fastfile/snd39.ffl) = 6bab76db16787a6adb575f62482ec47a +MD5 (fastfile/snd4.ffl) = 97a113d56b355912b32e05c69e0d10bf +MD5 (fastfile/snd40.ffl) = 38234404a17fb33c44ad6f76e6bb4992 +MD5 (fastfile/snd41.ffl) = f1126f5b21b17b2f708a1cf7cf774e32 +MD5 (fastfile/snd42.ffl) = 69205ccd483d62668f6d0c9f15024bc0 +MD5 (fastfile/snd43.ffl) = e35b56f2bd2172a6e17a1c251488f40e +MD5 (fastfile/snd44.ffl) = f76dfefe3a2b7ca675e71abcb8ee8771 +MD5 (fastfile/snd45.ffl) = db700d990dcedb5a90dd33fedc443b6d +MD5 (fastfile/snd46.ffl) = c2f499f4b98c65c2c9307eb4d225503c +MD5 (fastfile/snd47.ffl) = a7d893d38d6b5532693124c3192ca199 +MD5 (fastfile/snd48.ffl) = 30ee9a7447ea82744b35a32709e3433f +MD5 (fastfile/snd49.ffl) = 0580d2915e8ef3c4bef5f6c59de94fbb +MD5 (fastfile/snd5.ffl) = e0dea9b8de9e1303ebd137d6a792c4d0 +MD5 (fastfile/snd50.ffl) = e13f9db8c08c8f055efc19945a078359 +MD5 (fastfile/snd51.ffl) = 2d8b4e528d2d784c374ad5d17424708c +MD5 (fastfile/snd6.ffl) = 5eb1c874e57349b79255f07786d77519 +MD5 (fastfile/snd7.ffl) = 7abbdcd4cb9ec878eeec279ffce8eaa0 +MD5 (fastfile/snd8.ffl) = 1ea6f5460788946c6eb5e117f31bd085 +MD5 (fastfile/snd9.ffl) = 7abc7189c778e2627a6d2288067be00b +MD5 (fastfile/tex1.ffl) = d9ecc8666917d167fc0f151287d3546a +MD5 (fastfile/tex10.ffl) = 519858b7d238a587a85652192ec2468d +MD5 (fastfile/tex11.ffl) = c49461369e40c098ecb706ce7ae59495 +MD5 (fastfile/tex12.ffl) = 117311a6e1c96fa8e6834071ec10c2c6 +MD5 (fastfile/tex13.ffl) = b8d2ce2970349d1e03c80a691f00b4c2 +MD5 (fastfile/tex14.ffl) = c67da430a9d2949dabbfecc8efac5d33 +MD5 (fastfile/tex15.ffl) = b4c10dfec3c73002ce2b0a38666fc171 +MD5 (fastfile/tex16.ffl) = 0411c98c2db4c8bd9d67925b4924dbb3 +MD5 (fastfile/tex17.ffl) = 2a1de9941e80dcdd6d252575189f26a8 +MD5 (fastfile/tex18.ffl) = 15fbbc0ce657e597b960349930d2c2c8 +MD5 (fastfile/tex19.ffl) = 4881d6cc9ee0adcd50b3392bab88523a +MD5 (fastfile/tex2.ffl) = 655c23f494879ea826b6dadcd2669d1d +MD5 (fastfile/tex20.ffl) = 7602a80deb49813c96e7e9c6804ba27d +MD5 (fastfile/tex21.ffl) = e4eb4c0f3269939a8d9c6cca413e95f0 +MD5 (fastfile/tex22.ffl) = ae0caf7209f457312c5333338cc7021c +MD5 (fastfile/tex23.ffl) = 058930e377fa413fb5dcd2018d2ddee7 +MD5 (fastfile/tex24.ffl) = a611dbc06035aefd1e38b6eaac80fab9 +MD5 (fastfile/tex25.ffl) = 196b5eca90fcf921d18697ceec96565a +MD5 (fastfile/tex26.ffl) = b5bd750e210e7c82bc4c7010401df70a +MD5 (fastfile/tex27.ffl) = 85cb0b4a083be8f87ab04fa76dbc6478 +MD5 (fastfile/tex28.ffl) = ec1949224ea3a2c104c9908d89c5f8f1 +MD5 (fastfile/tex29.ffl) = 45abffc0107966677adfdd89cba9e18e +MD5 (fastfile/tex3.ffl) = feee0e06c91c88ca0f96aeaf1a724301 +MD5 (fastfile/tex30.ffl) = 61d983086a4e5ad2e1d1685cb9b47aa2 +MD5 (fastfile/tex31.ffl) = 80ecacc0282f6d917befd8328ee60272 +MD5 (fastfile/tex32.ffl) = 21d2777d86e6a6ce0fb3f12c74cc978f +MD5 (fastfile/tex33.ffl) = 5490df39f625c7d2f2d837645bc91822 +MD5 (fastfile/tex34.ffl) = c14eb4ce768a7cae4e474016320e09da +MD5 (fastfile/tex35.ffl) = 28074571a4fc9804e612244775d6aefc +MD5 (fastfile/tex36.ffl) = 788fadfef9603d1ba3ccb8c74f5ddaf9 +MD5 (fastfile/tex37.ffl) = 53fa29efc83880c9e56f26ab727b1c6e +MD5 (fastfile/tex38.ffl) = 58c6103dd399bab9fd1554aa848916aa +MD5 (fastfile/tex39.ffl) = 91cb7a34c64620c74cd2c3dcb8f02bb6 +MD5 (fastfile/tex4.ffl) = b0e9dbca444b38ddd5570ee94847071a +MD5 (fastfile/tex40.ffl) = 77a28d333b39b33f08d87a5963b17aa9 +MD5 (fastfile/tex41.ffl) = 778644485c113c023a638ab70789983d +MD5 (fastfile/tex42.ffl) = 83b442ff98786f2cb033462dc2ef56f7 +MD5 (fastfile/tex43.ffl) = 9fe624873f73f55a7af95ea6ecc804f6 +MD5 (fastfile/tex44.ffl) = 188cca218e1dc4f43ebacbf7ee1cce47 +MD5 (fastfile/tex45.ffl) = 8994489ef0c9fb825663ae603149c94b +MD5 (fastfile/tex46.ffl) = 7b8a28452f37f9630b47c1d13cfa48d5 +MD5 (fastfile/tex47.ffl) = bd1a5f16278e8c204d653521726aee18 +MD5 (fastfile/tex48.ffl) = 6456a8731e32824759a09860a0edf76a +MD5 (fastfile/tex49.ffl) = dbcb3bfeaaf85212b2ad27528f3697a2 +MD5 (fastfile/tex5.ffl) = 77de24b3fd5d2904806d2adefe398d1e +MD5 (fastfile/tex50.ffl) = c396dd292505f01b264c398dd64bec16 +MD5 (fastfile/tex51.ffl) = 655d729709ade2c7d10afeef349a441d +MD5 (fastfile/tex52.ffl) = 7a6644197c44767ef920ee880f5b9631 +MD5 (fastfile/tex53.ffl) = 7db4a4a3643eea4ad03b5b7532a0da28 +MD5 (fastfile/tex54.ffl) = 1cafa7df826f33138eb535c249681106 +MD5 (fastfile/tex55.ffl) = ee6473804edb88692ac8d1e34782228d +MD5 (fastfile/tex56.ffl) = 6a5504d9dc663a96ea6fc81426f827b5 +MD5 (fastfile/tex57.ffl) = a76b1a4f582e57933f9107f25fab43ed +MD5 (fastfile/tex58.ffl) = e9c4c5f233a71a39432765f084cd4c26 +MD5 (fastfile/tex6.ffl) = ffad911262fe7e8e6744e288aa3e62d9 +MD5 (fastfile/tex7.ffl) = a1ee192c4a44d5bdb6dc1fe290c9fa77 +MD5 (fastfile/tex8.ffl) = 69c927deb5448b63a9c11186e8c29d3b +MD5 (fastfile/tex9.ffl) = 156b6dcdc3b92a9d6c0cfdfbc2421b10 +MD5 (language.txt) = 10564fea944ef6680191ecc89a4616d5 diff --git a/src/avp/avpview.c b/src/avp/avpview.c index e982476..fd4fe21 100644 --- a/src/avp/avpview.c +++ b/src/avp/avpview.c @@ -16,6 +16,7 @@ #include "lighting.h" #include "weapons.h" #include "sfx.h" +#include "fmv.h" /* character extents data so you know where the player's eyes are */ #include "extents.h" #include "avp_userprofile.h" @@ -100,7 +101,7 @@ extern int GetSingleColourForPrimary(int Colour); extern void ColourFillBackBuffer(int FillColour); static void ModifyHeadOrientation(void); -int AVPViewVolumePlaneTest(CLIPPLANEBLOCK *cpb, DISPLAYBLOCK *dblockptr, int or); +int AVPViewVolumePlaneTest(CLIPPLANEBLOCK *cpb, DISPLAYBLOCK *dblockptr, int obr); @@ -875,16 +876,16 @@ void InitialiseRenderer(void) int AVPViewVolumeTest(VIEWDESCRIPTORBLOCK *VDB_Ptr, DISPLAYBLOCK *dblockptr) { - int or = dblockptr->ObRadius; + int obr = dblockptr->ObRadius; /* Perform the view volume plane tests */ if( - AVPViewVolumePlaneTest(&VDB_Ptr->VDB_ClipZPlane, dblockptr, or) && - AVPViewVolumePlaneTest(&VDB_Ptr->VDB_ClipLeftPlane, dblockptr, or) && - AVPViewVolumePlaneTest(&VDB_Ptr->VDB_ClipRightPlane, dblockptr, or) && - AVPViewVolumePlaneTest(&VDB_Ptr->VDB_ClipUpPlane, dblockptr, or) && - AVPViewVolumePlaneTest(&VDB_Ptr->VDB_ClipDownPlane, dblockptr, or)) + AVPViewVolumePlaneTest(&VDB_Ptr->VDB_ClipZPlane, dblockptr, obr) && + AVPViewVolumePlaneTest(&VDB_Ptr->VDB_ClipLeftPlane, dblockptr, obr) && + AVPViewVolumePlaneTest(&VDB_Ptr->VDB_ClipRightPlane, dblockptr, obr) && + AVPViewVolumePlaneTest(&VDB_Ptr->VDB_ClipUpPlane, dblockptr, obr) && + AVPViewVolumePlaneTest(&VDB_Ptr->VDB_ClipDownPlane, dblockptr, obr)) return Yes; else @@ -900,13 +901,13 @@ int AVPViewVolumeTest(VIEWDESCRIPTORBLOCK *VDB_Ptr, DISPLAYBLOCK *dblockptr) */ -int AVPViewVolumePlaneTest(CLIPPLANEBLOCK *cpb, DISPLAYBLOCK *dblockptr, int or) +int AVPViewVolumePlaneTest(CLIPPLANEBLOCK *cpb, DISPLAYBLOCK *dblockptr, int obr) { VECTORCH POPRelObView; MakeVector(&dblockptr->ObView, &cpb->CPB_POP, &POPRelObView); - if(DotProduct(&POPRelObView, &cpb->CPB_Normal) < or) return Yes; + if(DotProduct(&POPRelObView, &cpb->CPB_Normal) < obr) return Yes; else return No; } diff --git a/src/avp/bh_waypt.c b/src/avp/bh_waypt.c index 899c33a..b1408f4 100644 --- a/src/avp/bh_waypt.c +++ b/src/avp/bh_waypt.c @@ -131,7 +131,7 @@ int NPCGetWaypointDirection(WAYPOINT_HEADER *waypoints, STRATEGYBLOCK *sbPtr, VE //Base shift value on strategy block so that the aliens don't keep changing their minds //about which route to take - GlobalLinkShift=(((int)sbPtr)&0xffff)>>4; + GlobalLinkShift=(((intptr_t)sbPtr)&0xffff)>>4; if (FindBestRoute(¤t_route,waypoints)==0) { /* Yuck! */ textprint("Waypoint dropout: no continuous route!\n"); diff --git a/src/avp/davehook.cpp b/src/avp/davehook.cpp index daa7c59..0571148 100644 --- a/src/avp/davehook.cpp +++ b/src/avp/davehook.cpp @@ -54,7 +54,7 @@ #define UseLocalAssert Yes #include "ourasert.h" -#include "frontend/avp_menus.h" +#include "avp_menus.h" /* Version settings ************************************************/ /* Constants *******************************************************/ diff --git a/src/avp/game.c b/src/avp/game.c index c7b8e02..c818a21 100644 --- a/src/avp/game.c +++ b/src/avp/game.c @@ -24,6 +24,7 @@ #include "psndplat.h" #include "particle.h" #include "sfx.h" +#include "fmv.h" #include "version.h" #include "bh_rubberduck.h" #include "bh_marin.h" diff --git a/src/avp/hud.c b/src/avp/hud.c index ee27bf9..bc945a1 100644 --- a/src/avp/hud.c +++ b/src/avp/hud.c @@ -101,7 +101,7 @@ int predHUDSoundHandle=SOUND_NOACTIVEINDEX; static int HUD_PrimaryRounds; static int HUD_SecondaryRounds; /* numerics buffer - the marine has more digits on his HUD than the other species */ -char ValueOfHUDDigit[MAX_NO_OF_COMMON_HUD_DIGITS]; +char ValueOfHUDDigit[MAX_NO_OF_MARINE_HUD_DIGITS]; #define PREDATOR_LOCK_ON_TIME (ONE_FIXED*5/3) @@ -237,7 +237,7 @@ void InitMarineHUD(void) { int i; - for (i=0; i MEMORY_BLOCK_SIZE) + { + // fatal error + return NULL; + } + // align up + amount = (amount + 7) & ~7; + if(amount>MemoryLeft) { CurrentMemoryBlock++; GLOBALASSERT(CurrentMemoryBlock= MAX_NUM_MEMORY_BLOCK) + { + // fatal error + return NULL; + } MemoryBlocks[CurrentMemoryBlock]=AllocateMem(MEMORY_BLOCK_SIZE); - GLOBALASSERT(MemoryBlocks[CurrentMemoryBlock]); - + GLOBALASSERT(MemoryBlocks[CurrentMemoryBlock]!=NULL); + if (MemoryBlocks[CurrentMemoryBlock] == NULL) + { + // fatal error + return NULL; + } MemoryLeft=MEMORY_BLOCK_SIZE; MemoryPoolPtr=MemoryBlocks[CurrentMemoryBlock]; diff --git a/src/avp/psndproj.c b/src/avp/psndproj.c index 4f8e959..59aad05 100644 --- a/src/avp/psndproj.c +++ b/src/avp/psndproj.c @@ -856,7 +856,7 @@ int FindAndLoadWavFile(int soundNum,char* wavFileName) #if LOAD_SOUND_FROM_FAST_FILE //first look in fast file { - unsigned nLen; + size_t nLen; if(ffreadbuf(sound_name,&nLen)) { return LoadWavFromFastFile(soundNum,sound_name); diff --git a/src/avp/savegame.c b/src/avp/savegame.c index 0047c99..5125995 100644 --- a/src/avp/savegame.c +++ b/src/avp/savegame.c @@ -30,6 +30,7 @@ #include "game_statistics.h" #include "avp_userprofile.h" #include "huddefs.h" +#include "fmv.h" #include "savegame.h" #include "huffman.hpp" diff --git a/src/avp/shapes/cube.c b/src/avp/shapes/cube.c index 291ae99..72c03b8 100644 --- a/src/avp/shapes/cube.c +++ b/src/avp/shapes/cube.c @@ -1,4 +1,5 @@ #include +#include #include "system.h" #include "shape.h" diff --git a/src/avp/support/consbind.cpp b/src/avp/support/consbind.cpp index 6477673..527210a 100644 --- a/src/avp/support/consbind.cpp +++ b/src/avp/support/consbind.cpp @@ -29,7 +29,7 @@ #define UseLocalAssert Yes #include "ourasert.h" -#include "frontend/avp_menus.h" +#include "avp_menus.h" /* Version settings ************************************************/ diff --git a/src/avp/win95/avpchunk.cpp b/src/avp/win95/avpchunk.cpp index 5731d47..b247797 100644 --- a/src/avp/win95/avpchunk.cpp +++ b/src/avp/win95/avpchunk.cpp @@ -242,7 +242,7 @@ AVP_Generator_Extra_Name_Chunk::AVP_Generator_Extra_Name_Chunk(Chunk_With_Childr AVP_Generator_Extra_Name_Chunk::~AVP_Generator_Extra_Name_Chunk() { - delete name; + delete [] name; } void AVP_Generator_Extra_Name_Chunk::fill_data_block(char* data_start) @@ -292,7 +292,7 @@ AVP_Generator_Extended_Settings_Chunk::AVP_Generator_Extended_Settings_Chunk(Chu AVP_Generator_Extended_Settings_Chunk::AVP_Generator_Extended_Settings_Chunk(Chunk_With_Children* parent) :Chunk(parent,"GENEXSET") { - weights=new AVP_Generator_Weighting; + weights=(AVP_Generator_Weighting *)new unsigned char[sizeof(AVP_Generator_Weighting)]; memset(weights,0,sizeof(AVP_Generator_Weighting)); weights->data_size=sizeof(AVP_Generator_Weighting); GenLimit=pad1=pad2=pad3=0; @@ -303,7 +303,7 @@ AVP_Generator_Extended_Settings_Chunk::AVP_Generator_Extended_Settings_Chunk(Chu AVP_Generator_Extended_Settings_Chunk::~AVP_Generator_Extended_Settings_Chunk() { - delete weights; + delete [] weights; } void AVP_Generator_Extended_Settings_Chunk::fill_data_block (char * data) @@ -580,7 +580,7 @@ AVP_Environment_Settings_Chunk::AVP_Environment_Settings_Chunk(Chunk_With_Childr AVP_Environment_Settings_Chunk::AVP_Environment_Settings_Chunk(Chunk_With_Children* parent) :Chunk(parent,"AVPENVIR") { - settings=new AVP_Environment_Settings; + settings=(AVP_Environment_Settings*)new unsigned char[sizeof(AVP_Environment_Settings)]; settings->data_size=sizeof(AVP_Environment_Settings); settings->sky_colour_red=200; settings->sky_colour_green=200; @@ -601,7 +601,7 @@ AVP_Environment_Settings_Chunk::AVP_Environment_Settings_Chunk(Chunk_With_Childr AVP_Environment_Settings_Chunk::~AVP_Environment_Settings_Chunk() { - delete settings; + delete [] settings; } void AVP_Environment_Settings_Chunk::fill_data_block (char * data_start) diff --git a/src/avp/win95/ffread.cpp b/src/avp/win95/ffread.cpp index e5ba27e..cc6aa1d 100644 --- a/src/avp/win95/ffread.cpp +++ b/src/avp/win95/ffread.cpp @@ -114,7 +114,7 @@ FFDataI::FFDataI(char const *_filename, void *_data, size_t _length) FFDataI::FFDataI(FFDataI const & ffd, ptrdiff_t offset) : filename(0) -, data((void *)((size_t)ffd.data + offset)) +, data((void *)((intptr_t)ffd.data + offset)) , length(ffd.length) { if (ffd.filename) @@ -212,7 +212,7 @@ FFHeaderI::FFHeaderI(FFHeaderI const & ffh) data = malloc(length); memcpy(data,ffh.data,length); } - ptrdiff_t offset = (size_t)data - (size_t)ffh.data; + ptrdiff_t offset = (intptr_t)data - (intptr_t)ffh.data; for (int i=0; i i_file(&ffh.files[i]); !i_file.done(); i_file.next()) @@ -243,7 +243,7 @@ FFHeaderI & FFHeaderI::operator = (FFHeaderI const & ffh) data = malloc(length); memcpy(data,ffh.data,length); } - ptrdiff_t offset = (size_t)data - (size_t)ffh.data; + ptrdiff_t offset = (intptr_t)data - (intptr_t)ffh.data; for (int i=0; i i_file(&ffh.files[i]); !i_file.done(); i_file.next()) @@ -300,9 +300,10 @@ FFError FFHeaderI::Read(char const *_filename) Clear(); char magic[4]; - unsigned long rffl_version; - size_t num_files; - size_t total_headsize; + uint32_t rffl_version; + uint32_t num_files; + uint32_t total_headsize; + uint32_t data_length; DWORD bytes_read; @@ -310,8 +311,10 @@ FFError FFHeaderI::Read(char const *_filename) READ_FILE(filename,(void)0,fclose(h),h,&rffl_version,4,bytes_read,0) READ_FILE(filename,(void)0,fclose(h),h,&num_files,4,bytes_read,0) READ_FILE(filename,(void)0,fclose(h),h,&total_headsize,4,bytes_read,0) - READ_FILE(filename,(void)0,fclose(h),h,&length,4,bytes_read,0) - + READ_FILE(filename,(void)0,fclose(h),h,&data_length,4,bytes_read,0) + + length = data_length; + if (strncmp(magic,"RFFL",4)) { ReportError(filename,"Incorrect file type"); @@ -341,14 +344,14 @@ FFError FFHeaderI::Read(char const *_filename) for (unsigned int i=0; i #include + +int SelectDirectDrawObject(void *pGUID); extern void StartMenuBackgroundBink(void); extern int PlayMenuBackgroundBink(void); @@ -45,10 +48,15 @@ extern void EndMenuBackgroundBink(void); extern int IDemandSelect(void); extern char *GetVideoModeDescription(void); +extern char *GetVideoModeDescription2(void); +extern char *GetVideoModeDescription3(void); extern void PreviousVideoMode(void); +extern void PreviousVideoMode2(void); extern void NextVideoMode(void); +extern void NextVideoMode2(void); extern void SaveVideoModeSettings(void); - +extern void LoadDeviceAndVideoModePreferences(void); +extern void SaveDeviceAndVideoModePreferences(void); extern void MakeSelectSessionMenu(void); @@ -665,11 +673,12 @@ extern void AvP_UpdateMenus(void) { int i; AVP_USER_PROFILE *profilePtr = GetFirstUserProfile(); + time_t FileTime = profilePtr->FileTime; for (i=0; iName,MENU_CENTREX,MENU_CENTREY-100,ONE_FIXED,AVPMENUFORMAT_CENTREJUSTIFIED); - RenderSmallMenuText(ctime(&profilePtr->FileTime),MENU_CENTREX,MENU_CENTREY-70,ONE_FIXED,AVPMENUFORMAT_CENTREJUSTIFIED); + RenderSmallMenuText(ctime(&FileTime),MENU_CENTREX,MENU_CENTREY-70,ONE_FIXED,AVPMENUFORMAT_CENTREJUSTIFIED); RenderMenu(); RenderHelpString(); @@ -1727,6 +1736,7 @@ static void RenderUserProfileSelectMenu(void) if (y>=-150 && y<=150) { char *textPtr = profilePtr->Name; + time_t FileTime = profilePtr->FileTime; int b; int targetBrightness; @@ -1758,7 +1768,7 @@ static void RenderUserProfileSelectMenu(void) b=Brightness[i]; RenderMenuText_Clipped(textPtr,MENU_CENTREX,MENU_CENTREY+y-60,b,AVPMENUFORMAT_CENTREJUSTIFIED,MENU_CENTREY-60-100,MENU_CENTREY-30+150); if (i > 0) - RenderSmallMenuText(ctime(&profilePtr->FileTime),MENU_CENTREX,MENU_CENTREY+y-30,b,AVPMENUFORMAT_CENTREJUSTIFIED); + RenderSmallMenuText(ctime(&FileTime),MENU_CENTREX,MENU_CENTREY+y-30,b,AVPMENUFORMAT_CENTREJUSTIFIED); } } diff --git a/src/avp/win95/frontend/avp_userprofile.h b/src/avp/win95/frontend/avp_userprofile.h index a630373..5d26a69 100644 --- a/src/avp/win95/frontend/avp_userprofile.h +++ b/src/avp/win95/frontend/avp_userprofile.h @@ -69,9 +69,10 @@ typedef struct { char Name[MAX_SIZE_OF_USERS_NAME+1]; - time_t FileTime; + // SBF: 32-bit time_t + uint32_t FileTime; - // used to be an incomplete SYSTEMTIME struct, TimeLastUpdated + // SBF: used to be an incomplete SYSTEMTIME struct, TimeLastUpdated int unused[6]; /* KJL 15:14:12 10/12/98 - array to hold level completion data diff --git a/src/avp/win95/gadgets/teletype.cpp b/src/avp/win95/gadgets/teletype.cpp index e7d4a7c..ad9cce8 100644 --- a/src/avp/win95/gadgets/teletype.cpp +++ b/src/avp/win95/gadgets/teletype.cpp @@ -292,6 +292,10 @@ TeletypeDaemon :: TeletypeDaemon { GLOBALASSERT( pTeletypeGadg ); + #if SupportTeletypeSound + SoundHandle = SOUND_NOACTIVEINDEX; + #endif + pTeletypeGadg_Val = pTeletypeGadg; fFinished_Val = No; diff --git a/src/avp/win95/pathchnk.cpp b/src/avp/win95/pathchnk.cpp index d37897e..044251a 100644 --- a/src/avp/win95/pathchnk.cpp +++ b/src/avp/win95/pathchnk.cpp @@ -45,8 +45,8 @@ AVP_Path_Chunk::AVP_Path_Chunk(Chunk_With_Children* parent,const char* data,size AVP_Path_Chunk::~AVP_Path_Chunk() { - if(PathName) delete PathName; - if(Path) delete Path; + if(PathName) delete [] PathName; + if(Path) delete [] Path; } void AVP_Path_Chunk::fill_data_block(char* data_start) diff --git a/src/avp/win95/strachnk.cpp b/src/avp/win95/strachnk.cpp index 6a3cf93..2ecde1d 100644 --- a/src/avp/win95/strachnk.cpp +++ b/src/avp/win95/strachnk.cpp @@ -360,7 +360,7 @@ Virtual_Object_Properties_Chunk::Virtual_Object_Properties_Chunk(Chunk_With_Chil Virtual_Object_Properties_Chunk::~Virtual_Object_Properties_Chunk() { - if(name)delete name; + if(name)delete [] name; } size_t Virtual_Object_Properties_Chunk::size_chunk() @@ -1046,8 +1046,8 @@ MultiSwitchStrategy::MultiSwitchStrategy(const char* data_start,size_t /*size*/) MultiSwitchStrategy::~MultiSwitchStrategy() { - if(Targets)delete Targets; - if(LinkedSwitches)delete LinkedSwitches; + if(Targets)delete [] Targets; + if(LinkedSwitches)delete [] LinkedSwitches; } @@ -1523,7 +1523,7 @@ TrackStrategy::~TrackStrategy() delete point_effects[i]; } if(point_effects) - delete point_effects; + delete [] point_effects; } size_t TrackStrategy::GetStrategySize() diff --git a/src/avp/win95/system.c b/src/avp/win95/system.c index e2c9345..6fc1279 100644 --- a/src/avp/win95/system.c +++ b/src/avp/win95/system.c @@ -21,6 +21,7 @@ #include "huddefs.h" #include "hud.h" //#include "hudgfx.h" +#include "fmv.h" #include "font.h" #include "bh_gener.h" #include "pvisible.h" diff --git a/src/cdplayer.c b/src/cdplayer.c index b8bf9ec..1d8dfe3 100644 --- a/src/cdplayer.c +++ b/src/cdplayer.c @@ -8,14 +8,15 @@ #include "win95/cd_player.h" #include "cdplayer.h" +/* cd_player.cpp */ +int CDPlayerVolume; + +#if SDL_MAJOR_VERSION < 2 static int HaveCDROM = 0; static SDL_CD *cdrom = NULL; /* ** */ -/* cd_player.cpp */ -int CDPlayerVolume; - void CheckCDVolume() { /* @@ -155,3 +156,58 @@ void CDDA_SwitchOn() fprintf(stderr, "CDDA_SwitchOn()\n"); */ } + +#else + +// What's a CD? + +void CheckCDVolume() +{ +} + +/* ** */ + +void CDDA_Start() +{ +} + +void CDDA_End() +{ +} + +void CDDA_ChangeVolume(int volume) +{ +} + +int CDDA_CheckNumberOfTracks() +{ + return 0; +} + +int CDDA_IsOn() +{ + return 0; +} + +int CDDA_IsPlaying() +{ + return 0; +} + +void CDDA_Play(int CDDATrack) +{ +} + +void CDDA_PlayLoop(int CDDATrack) +{ +} + +void CDDA_Stop() +{ +} + +void CDDA_SwitchOn() +{ +} + +#endif diff --git a/src/fixer.h b/src/fixer.h index 2479780..3d39012 100644 --- a/src/fixer.h +++ b/src/fixer.h @@ -9,6 +9,7 @@ #include #include #include +#include #define Yes 1 // sigh #define No 0 // sigh diff --git a/src/fmv.c b/src/fmv.c index 8edbd65..eea329b 100644 --- a/src/fmv.c +++ b/src/fmv.c @@ -11,7 +11,7 @@ #include "fmv.h" #include "avp_menus.h" #include "avp_userprofile.h" -#include "oglfunc.h" +#include "oglfunc.h" // move this into opengl.c #define UseLocalAssert 1 #include "ourasert.h" @@ -332,6 +332,7 @@ void UpdateFMVTexture(FMVTEXTURE *ftPtr) dstPtr += 3; } while(--pixels); +//#warning move this into opengl.c // update the opengl texture pglBindTexture(GL_TEXTURE_2D, ftPtr->ImagePtr->D3DTexture->id); diff --git a/src/fmv.h b/src/fmv.h index 4d7b5db..364d963 100644 --- a/src/fmv.h +++ b/src/fmv.h @@ -39,4 +39,6 @@ void UpdateAllFMVTextures(void); void ScanImagesForFMVs(void); void ReleaseAllFMVTextures(void); +void PlayBinkedFMV(char *filenamePtr); + #endif diff --git a/src/include/shape.h b/src/include/shape.h index cc5e986..6fe2edf 100644 --- a/src/include/shape.h +++ b/src/include/shape.h @@ -890,7 +890,7 @@ typedef struct txanimframe { int txf_orienty; int txf_numuvs; int *txf_uvdata; - int txf_image; + intptr_t txf_image; // SBF: 64HACK - needed to match TXANIMFRAME_MVS } TXANIMFRAME; diff --git a/src/kshape.c b/src/kshape.c index 7107c0b..a17d305 100644 --- a/src/kshape.c +++ b/src/kshape.c @@ -3015,8 +3015,11 @@ void CreateTxAnimUVArray(int *txa_data, int *uv_array, int *shapeitemptr) /* The sequence # will have been copied across by the control block */ - sequence = *txa_data++; - + sequence = *txa_data; + + // SBF: 64HACK - skip over the rest of the int* + txa_data = (int *)((intptr_t) txa_data + sizeof(int *)); + #if 0 textprint("sequence = %d\n", sequence); #endif @@ -4027,7 +4030,7 @@ void AddShape(DISPLAYBLOCK *dptr, VIEWDESCRIPTORBLOCK *VDB_Ptr) { if (dptr->ObStrategyBlock->I_SBtype==I_BehaviourInanimateObject) { - INANIMATEOBJECT_STATUSBLOCK* objStatPtr = dptr->ObStrategyBlock->SBdataptr; + INANIMATEOBJECT_STATUSBLOCK* objStatPtr = (INANIMATEOBJECT_STATUSBLOCK*) dptr->ObStrategyBlock->SBdataptr; if(objStatPtr->typeId==IOT_FieldCharge) { diff --git a/src/main.c b/src/main.c index eff537f..20b8e97 100644 --- a/src/main.c +++ b/src/main.c @@ -246,12 +246,17 @@ typedef struct VideoModeStruct VideoModeStruct VideoModeList[] = { { 512, 384, 0 }, { 640, 480, 0 }, +{ 720, 480, 0 }, { 800, 600, 0 }, { 1024, 768, 0 }, { 1152, 864, 0 }, -{ 1280, 960, 0, }, +{ 1280, 720, 0 }, +{ 1280, 768, 0 }, +{ 1280, 960, 0 }, { 1280, 1024, 0 }, -{ 1600, 1200, 0 } +{ 1600, 1200, 0 }, +{ 1920, 1080, 0 }, +{ 1920, 1200, 0 } }; int CurrentVideoMode; @@ -361,7 +366,8 @@ int InitSDL() atexit(SDL_Quit); - SDL_AvailableVideoModes = SDL_ListModes(NULL, SDL_FULLSCREEN | SDL_OPENGL); + // needs to be cleaned up; SDL_VideoModeOK and SDL_ListModes aren't compatible + SDL_AvailableVideoModes = (SDL_Rect **)-1; //SDL_ListModes(NULL, SDL_FULLSCREEN | SDL_OPENGL); if (SDL_AvailableVideoModes == NULL) return -1; @@ -544,7 +550,6 @@ int SetOGLVideoMode(int Width, int Height) { SDL_GrabMode isgrab; int flags; - char *ext; ScanDrawMode = ScanDrawD3DHardwareRGB; GotMouse = 1; @@ -580,7 +585,12 @@ int SetOGLVideoMode(int Width, int Height) SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 5); SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16); SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); - + + // These should be configurable video options. + //SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1); + //SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 4); + SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL, 1); + if ((surface = SDL_SetVideoMode(Width, Height, 0, flags)) == NULL) { fprintf(stderr, "(OpenGL) SDL SetVideoMode failed: %s\n", SDL_GetError()); exit(EXIT_FAILURE); @@ -624,8 +634,6 @@ int SetOGLVideoMode(int Width, int Height) pglClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - pglHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); - ScreenDescriptorBlock.SDB_Width = Width; ScreenDescriptorBlock.SDB_Height = Height; ScreenDescriptorBlock.SDB_CentreX = Width/2; @@ -637,8 +645,6 @@ int SetOGLVideoMode(int Width, int Height) ScreenDescriptorBlock.SDB_ClipUp = 0; ScreenDescriptorBlock.SDB_ClipDown = Height; - ext = (char *) pglGetString(GL_EXTENSIONS); - load_ogl_functions(1); InitOpenGL(); diff --git a/src/main2.c b/src/main2.c new file mode 100644 index 0000000..cdc353c --- /dev/null +++ b/src/main2.c @@ -0,0 +1,1561 @@ +#include +#include +#include +#include + +#include "SDL.h" +#include "oglfunc.h" + +#if !defined(_MSC_VER) +#ifndef _GNU_SOURCE +#define _GNU_SOURCE +#endif +#include +#endif + +#include "fixer.h" + +#include "3dc.h" +#include "platform.h" +#include "inline.h" +#include "gamedef.h" +#include "gameplat.h" +#include "ffstdio.h" +#include "vision.h" +#include "comp_shp.h" +#include "avp_envinfo.h" +#include "stratdef.h" +#include "bh_types.h" +#include "avp_userprofile.h" +#include "pldnet.h" +#include "cdtrackselection.h" +#include "gammacontrol.h" +#include "opengl.h" +#include "avp_menus.h" +#include "avp_mp_config.h" +#include "npcsetup.h" +#include "cdplayer.h" +#include "hud.h" +#include "player.h" +#include "mempool.h" +#include "avpview.h" +#include "consbind.hpp" +#include "progress_bar.h" +#include "scrshot.hpp" +#include "version.h" +#include "fmv.h" + +void RE_ENTRANT_QUEUE_WinProc_AddMessage_WM_CHAR(char Ch); +void RE_ENTRANT_QUEUE_WinProc_AddMessage_WM_KEYDOWN(int wParam); + +char LevelName[] = {"predbit6\0QuiteALongNameActually"}; /* the real way to load levels */ + +int DebouncedGotAnyKey; +unsigned char DebouncedKeyboardInput[MAX_NUMBER_OF_INPUT_KEYS]; +int GotJoystick; +int GotMouse; +int JoystickEnabled; +int MouseVelX; +int MouseVelY; + +extern int ScanDrawMode; +extern SCREENDESCRIPTORBLOCK ScreenDescriptorBlock; +extern unsigned char KeyboardInput[MAX_NUMBER_OF_INPUT_KEYS]; +extern unsigned char GotAnyKey; +extern int NormalFrameTime; + +SDL_Window *window; +SDL_GLContext context; +SDL_Surface *surface; + +SDL_Joystick *joy; +JOYINFOEX JoystickData; +JOYCAPS JoystickCaps; + +/* defaults */ +static int WantFullscreen = 0; +static int WantMouseGrab = 0; +int WantSound = 1; +static int WantCDRom = 0; +static int WantJoystick = 0; + +static int ViewportWidth; +static int ViewportHeight; + +/* originally was "/usr/lib/libGL.so.1:/usr/lib/tls/libGL.so.1:/usr/X11R6/lib/libGL.so" */ +static const char * opengl_library = NULL; + +/* ** */ + +static void IngameKeyboardInput_ClearBuffer(void) +{ + // clear the keyboard state + memset((void*) KeyboardInput, 0, MAX_NUMBER_OF_INPUT_KEYS); + GotAnyKey = 0; +} + +void DirectReadKeyboard() +{ +} + +void DirectReadMouse() +{ +} + +void ReadJoysticks() +{ + int axes, balls, hats; + Uint8 hat; + + JoystickData.dwXpos = 0; + JoystickData.dwYpos = 0; + JoystickData.dwRpos = 0; + JoystickData.dwUpos = 0; + JoystickData.dwVpos = 0; + JoystickData.dwPOV = (DWORD) -1; + + if (joy == NULL || !GotJoystick) { + return; + } + + SDL_JoystickUpdate(); + + axes = SDL_JoystickNumAxes(joy); + balls = SDL_JoystickNumBalls(joy); + hats = SDL_JoystickNumHats(joy); + + if (axes > 0) { + JoystickData.dwXpos = SDL_JoystickGetAxis(joy, 0) + 32768; + } + if (axes > 1) { + JoystickData.dwYpos = SDL_JoystickGetAxis(joy, 1) + 32768; + } + + if (hats > 0) { + hat = SDL_JoystickGetHat(joy, 0); + + switch (hat) { + default: + case SDL_HAT_CENTERED: + JoystickData.dwPOV = (DWORD) -1; + break; + case SDL_HAT_UP: + JoystickData.dwPOV = 0; + break; + case SDL_HAT_RIGHT: + JoystickData.dwPOV = 9000; + break; + case SDL_HAT_DOWN: + JoystickData.dwPOV = 18000; + break; + case SDL_HAT_LEFT: + JoystickData.dwPOV = 27000; + break; + case SDL_HAT_RIGHTUP: + JoystickData.dwPOV = 4500; + break; + case SDL_HAT_RIGHTDOWN: + JoystickData.dwPOV = 13500; + break; + case SDL_HAT_LEFTUP: + JoystickData.dwPOV = 31500; + break; + case SDL_HAT_LEFTDOWN: + JoystickData.dwPOV = 22500; + break; + } + } +} + +/* ** */ + +unsigned char *GetScreenShot24(int *width, int *height) +{ +#if 0//REVIEW + unsigned char *buf; +// Uint16 redtable[256], greentable[256], bluetable[256]; + + if (surface == NULL) { + return NULL; + } + + buf = (unsigned char *)malloc(surface->w * surface->h * 3); + + if (surface->flags & SDL_WINDOW_OPENGL) { + pglPixelStorei(GL_PACK_ALIGNMENT, 1); + pglPixelStorei(GL_UNPACK_ALIGNMENT, 1); + pglReadPixels(0, 0, surface->w, surface->h, GL_RGB, GL_UNSIGNED_BYTE, buf); + } else { + unsigned char *ptrd; + unsigned short int *ptrs; + int x, y; + + if (SDL_MUSTLOCK(surface)) { + if (SDL_LockSurface(surface) < 0) { + free(buf); + return NULL; /* ... */ + } + } + + ptrd = buf; + for (y = 0; y < surface->h; y++) { + ptrs = (unsigned short *)(((unsigned char *)surface->pixels) + (surface->h-y-1)*surface->pitch); + for (x = 0; x < surface->w; x++) { + unsigned int c; + + c = *ptrs; + ptrd[0] = (c & 0xF800)>>8; + ptrd[1] = (c & 0x07E0)>>3; + ptrd[2] = (c & 0x001F)<<3; + + ptrs++; + ptrd += 3; + } + } + + if (SDL_MUSTLOCK(surface)) { + SDL_UnlockSurface(surface); + } + } + + *width = surface->w; + *height = surface->h; + +#if 0 + if (SDL_GetGammaRamp(redtable, greentable, bluetable) != -1) { + unsigned char *ptr; + int i; + + ptr = buf; + for (i = 0; i < surface->w*surface->h; i++) { + ptr[i*3+0] = redtable[ptr[i*3+0]]>>8; + ptr[i*3+1] = greentable[ptr[i*3+1]]>>8; + ptr[i*3+2] = bluetable[ptr[i*3+2]]>>8; + ptr += 3; + } + } +#endif + return buf; +#endif + return NULL; +} + +/* ** */ + +PROCESSORTYPES ReadProcessorType() +{ + return PType_PentiumMMX; +} + +/* ** */ + +typedef struct VideoModeStruct +{ + int w; + int h; + int available; +} VideoModeStruct; +VideoModeStruct VideoModeList[] = { + { 512, 384, 0 }, + { 640, 480, 0 }, + { 800, 600, 0 }, + { 1024, 768, 0 }, + { 1152, 864, 0 }, + { 1280, 720, 0 }, + { 1280, 960, 0 }, + { 1280, 1024, 0 }, + { 1600, 1200, 0 }, + { 1920, 1080, 0 } +}; + +int CurrentVideoMode; +const int TotalVideoModes = sizeof(VideoModeList) / sizeof(VideoModeList[0]); + +void LoadDeviceAndVideoModePreferences() +{ + FILE *fp; + int mode; + + fp = OpenGameFile("AvP_TempVideo.cfg", FILEMODE_READONLY, FILETYPE_CONFIG); + + if (fp != NULL) { + if (fscanf(fp, "%d", &mode) == 1) { + fclose(fp); + + if (mode >= 0 && mode < TotalVideoModes && VideoModeList[mode].available) { + CurrentVideoMode = mode; + return; + } + } else { + fclose(fp); + } + } + + /* No, or invalid, mode found */ + + /* Try 640x480 first */ + if (VideoModeList[1].available) { + CurrentVideoMode = 1; + } else { + int i; + + for (i = 0; i < TotalVideoModes; i++) { + if (VideoModeList[i].available) { + CurrentVideoMode = i; + break; + } + } + } +} + +void SaveDeviceAndVideoModePreferences() +{ + FILE *fp; + + fp = OpenGameFile("AvP_TempVideo.cfg", FILEMODE_WRITEONLY, FILETYPE_CONFIG); + if (fp != NULL) { + fprintf(fp, "%d\n", CurrentVideoMode); + fclose(fp); + } +} + +void PreviousVideoMode2() +{ + int cur = CurrentVideoMode; + + do { + if (cur == 0) + cur = TotalVideoModes; + cur--; + if (cur == CurrentVideoMode) + return; + } while(!VideoModeList[cur].available); + + CurrentVideoMode = cur; +} + +void NextVideoMode2() +{ + int cur = CurrentVideoMode; + + do { + cur++; + if (cur == TotalVideoModes) + cur = 0; + + if (cur == CurrentVideoMode) + return; + } while(!VideoModeList[cur].available); + + CurrentVideoMode = cur; +} + +char *GetVideoModeDescription2() +{ + return "SDL2"; +} + +char *GetVideoModeDescription3() +{ + static char buf[64]; + + _snprintf(buf, 64, "%dx%d", VideoModeList[CurrentVideoMode].w, VideoModeList[CurrentVideoMode].h); + + return buf; +} + +int InitSDL() +{ + if (SDL_Init(SDL_INIT_VIDEO) < 0) { + fprintf(stderr, "SDL Init failed: %s\n", SDL_GetError()); + exit(EXIT_FAILURE); + } + + atexit(SDL_Quit); + +#if 0 + SDL_Rect **SDL_AvailableVideoModes; + SDL_AvailableVideoModes = SDL_ListModes(NULL, SDL_WINDOW_FULLSCREEN | SDL_WINDOW_OPENGL); + if (SDL_AvailableVideoModes == NULL) + return -1; + + if (SDL_AvailableVideoModes != (SDL_Rect **)-1) { + int i, j, foundit; + + foundit = 0; + for (i = 0; i < TotalVideoModes; i++) { + SDL_Rect **modes = SDL_AvailableVideoModes; + + for (j = 0; modes[j]; j++) { + if (modes[j]->w >= VideoModeList[i].w && + modes[j]->h >= VideoModeList[i].h) { + if (SDL_VideoModeOK(VideoModeList[i].w, VideoModeList[i].h, 16, SDL_FULLSCREEN | SDL_OPENGL)) { + /* assume SDL isn't lying to us */ + VideoModeList[i].available = 1; + + foundit = 1; + } + break; + } + } + } + if (foundit == 0) + return -1; + } else { + int i, foundit; + + foundit = 0; + for (i = 0; i < TotalVideoModes; i++) { + if (SDL_VideoModeOK(VideoModeList[i].w, VideoModeList[i].h, 16, SDL_FULLSCREEN | SDL_OPENGL)) { + /* assume SDL isn't lying to us */ + VideoModeList[i].available = 1; + + foundit = 1; + } + } + + if (foundit == 0) + return -1; + } +#endif + +{ + int i; + + for (i = 0; i < TotalVideoModes; i++) { + //if (SDL_VideoModeOK(VideoModeList[i].w, VideoModeList[i].h, 16, SDL_FULLSCREEN | SDL_OPENGL)) { + /* assume SDL isn't lying to us */ + VideoModeList[i].available = 1; + + //foundit = 1; + //} + } +} + + LoadDeviceAndVideoModePreferences(); + + if (WantJoystick) { + SDL_InitSubSystem(SDL_INIT_JOYSTICK); + + if (SDL_NumJoysticks() > 0) { + /* TODO: make joystick number a configuration parameter */ + + joy = SDL_JoystickOpen(0); + if (joy) { + GotJoystick = 1; + } + + JoystickCaps.wCaps = 0; /* no rudder... ? */ + + JoystickData.dwXpos = 0; + JoystickData.dwYpos = 0; + JoystickData.dwRpos = 0; + JoystickData.dwUpos = 0; + JoystickData.dwVpos = 0; + JoystickData.dwPOV = (DWORD) -1; + } + } + + Uint32 rmask, gmask, bmask, amask; + + // pre-create the software surface in OpenGL RGBA order + // menus.c assumes RGB565; possible to support both? +#if SDL_BYTEORDER == SDL_BIG_ENDIAN + rmask = 0xff000000; + gmask = 0x00ff0000; + bmask = 0x0000ff00; + amask = 0x000000ff; +#else + rmask = 0x0000f800; + gmask = 0x000007e0; + bmask = 0x0000001f; + amask = 0x00000000; +#endif + + surface = SDL_CreateRGBSurface(0, 640, 480, 16, rmask, gmask, bmask, amask); + if (surface == NULL) { + return -1; + } + + return 0; +} + +/* ** */ +static void load_opengl_library(const char *lib) +{ +#if 0//REVIEW + char tmppath[PATH_MAX]; + size_t len, copylen; + + if (lib == NULL) { + if (SDL_GL_LoadLibrary(NULL) == 0) { + /* success */ + return; + } + + fprintf( stderr, "ERROR: no opengl libraries given\n" ); + exit( EXIT_FAILURE ); + } + + while (lib != NULL && *lib) { + len = strcspn(lib, ":"); + + copylen = min(len, PATH_MAX-1); + + strncpy(tmppath, lib, copylen); + tmppath[copylen] = 0; + + if (SDL_GL_LoadLibrary(tmppath) == 0) { + /* success */ + return; + } + + lib += len; + lib += strspn(lib, ":"); + } + + fprintf(stderr, "ERROR: unable to initialize opengl library: %s\n", SDL_GetError()); + exit(EXIT_FAILURE); +#endif +} + +int SetSoftVideoMode(int Width, int Height, int Depth) +{ + //TODO: clear surface + + ScanDrawMode = ScanDrawD3DHardwareRGB; + GotMouse = 1; + + // reset input + IngameKeyboardInput_ClearBuffer(); + + ScreenDescriptorBlock.SDB_Width = Width; + ScreenDescriptorBlock.SDB_Height = Height; + ScreenDescriptorBlock.SDB_CentreX = Width/2; + ScreenDescriptorBlock.SDB_CentreY = Height/2; + ScreenDescriptorBlock.SDB_ProjX = Width/2; + ScreenDescriptorBlock.SDB_ProjY = Height/2; + ScreenDescriptorBlock.SDB_ClipLeft = 0; + ScreenDescriptorBlock.SDB_ClipRight = Width; + ScreenDescriptorBlock.SDB_ClipUp = 0; + ScreenDescriptorBlock.SDB_ClipDown = Height; + + return 0; +} + +static int SDLCALL SDLEventFilter(void* userData, SDL_Event* event) { + (void) userData; + + //printf("SDLEventFilter: %d\n", event->type); + + switch (event->type) { + case SDL_APP_TERMINATING: + AvP.MainLoopRunning = 0; /* TODO */ + break; + } + + return 1; +} + +int SetOGLVideoMode(int Width, int Height) +{ + int oldflags; + int flags; + + ScanDrawMode = ScanDrawD3DHardwareRGB; + GotMouse = 1; + + if (window == NULL) { + load_ogl_functions(0); + + /* + if (window != NULL) { + oldflags = SDL_GetWindowFlags(window); + + SDL_DestroyWindow(window); + } + + */ + flags = SDL_WINDOW_OPENGL; + if (WantFullscreen) { + flags |= SDL_WINDOW_FULLSCREEN; + } + + // reset input + IngameKeyboardInput_ClearBuffer(); + + // force restart the video system + SDL_QuitSubSystem(SDL_INIT_VIDEO); + SDL_InitSubSystem(SDL_INIT_VIDEO); + + load_opengl_library(opengl_library); + + SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2); + SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 1); + + SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 5); + SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 5); + SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 5); + SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16); + SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); + + // These should be configurable video options. + //SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1); + //SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 4); + SDL_GL_SetSwapInterval(1); + + window = SDL_CreateWindow("Aliens vs Predator", + SDL_WINDOWPOS_UNDEFINED, + SDL_WINDOWPOS_UNDEFINED, + Width, + Height, + flags); + if (window == NULL) { + fprintf(stderr, "(OpenGL) SDL SDL_CreateWindow failed: %s\n", SDL_GetError()); + exit(EXIT_FAILURE); + } + + context = SDL_GL_CreateContext(window); + if (context == NULL) { + fprintf(stderr, "(OpenGL) SDL SDL_GL_CreateContext failed: %s\n", SDL_GetError()); + exit(EXIT_FAILURE); + } + SDL_GL_MakeCurrent(window, context); + + SDL_AddEventWatch(SDLEventFilter, NULL); //TODO move this to startup? + + load_ogl_functions(1); + + ///* this is for supporting keyboard input processing with little hassle */ + //SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL); + + //SDL_SetRelativeMouseMode(isgrab); + } + + ViewportWidth = Width; + ViewportHeight = Height; + + SDL_SetWindowSize(window, Width, Height); + + pglViewport(0, 0, Width, Height); + + pglMatrixMode(GL_PROJECTION); + pglLoadIdentity(); + pglMatrixMode(GL_MODELVIEW); + pglLoadIdentity(); + + pglEnable(GL_BLEND); + pglBlendFunc(GL_SRC_ALPHA, GL_ONE); + + pglEnable(GL_DEPTH_TEST); + pglDepthFunc(GL_LEQUAL); + pglDepthMask(GL_TRUE); + pglDepthRange(0.0, 1.0); + + pglEnable(GL_TEXTURE_2D); + + pglPolygonMode(GL_FRONT, GL_FILL); + pglPolygonMode(GL_BACK, GL_FILL); + pglDisable(GL_CULL_FACE); + + pglClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + + ScreenDescriptorBlock.SDB_Width = Width; + ScreenDescriptorBlock.SDB_Height = Height; + ScreenDescriptorBlock.SDB_CentreX = Width/2; + ScreenDescriptorBlock.SDB_CentreY = Height/2; + ScreenDescriptorBlock.SDB_ProjX = Width/2; + ScreenDescriptorBlock.SDB_ProjY = Height/2; + ScreenDescriptorBlock.SDB_ClipLeft = 0; + ScreenDescriptorBlock.SDB_ClipRight = Width; + ScreenDescriptorBlock.SDB_ClipUp = 0; + ScreenDescriptorBlock.SDB_ClipDown = Height; + + InitOpenGL(); + + return 0; +} + +int InitialiseWindowsSystem(HANDLE hInstance, int nCmdShow, int WinInitMode) +{ + return 0; +} + +int ExitWindowsSystem() +{ + if (joy != NULL) { + SDL_JoystickClose(joy); + } + + load_ogl_functions(0); + + if (surface != NULL) { + SDL_FreeSurface(surface); + } + surface = NULL; + + if (context != NULL) { + SDL_GL_DeleteContext(context); + } + context = NULL; + + if (window != NULL) { + SDL_DestroyWindow(window); + } + window = NULL; + + return 0; +} + +static int GotPrintScn, HavePrintScn; + +static int KeySymToKey(int keysym) +{ + switch(keysym) { + case SDLK_ESCAPE: + return KEY_ESCAPE; + + case SDLK_0: + return KEY_0; + case SDLK_1: + return KEY_1; + case SDLK_2: + return KEY_2; + case SDLK_3: + return KEY_3; + case SDLK_4: + return KEY_4; + case SDLK_5: + return KEY_5; + case SDLK_6: + return KEY_6; + case SDLK_7: + return KEY_7; + case SDLK_8: + return KEY_8; + case SDLK_9: + return KEY_9; + + case SDLK_a: + return KEY_A; + case SDLK_b: + return KEY_B; + case SDLK_c: + return KEY_C; + case SDLK_d: + return KEY_D; + case SDLK_e: + return KEY_E; + case SDLK_f: + return KEY_F; + case SDLK_g: + return KEY_G; + case SDLK_h: + return KEY_H; + case SDLK_i: + return KEY_I; + case SDLK_j: + return KEY_J; + case SDLK_k: + return KEY_K; + case SDLK_l: + return KEY_L; + case SDLK_m: + return KEY_M; + case SDLK_n: + return KEY_N; + case SDLK_o: + return KEY_O; + case SDLK_p: + return KEY_P; + case SDLK_q: + return KEY_Q; + case SDLK_r: + return KEY_R; + case SDLK_s: + return KEY_S; + case SDLK_t: + return KEY_T; + case SDLK_u: + return KEY_U; + case SDLK_v: + return KEY_V; + case SDLK_w: + return KEY_W; + case SDLK_x: + return KEY_X; + case SDLK_y: + return KEY_Y; + case SDLK_z: + return KEY_Z; + + case SDLK_LEFT: + return KEY_LEFT; + case SDLK_RIGHT: + return KEY_RIGHT; + case SDLK_UP: + return KEY_UP; + case SDLK_DOWN: + return KEY_DOWN; + case SDLK_RETURN: + return KEY_CR; + case SDLK_TAB: + return KEY_TAB; + case SDLK_INSERT: + return KEY_INS; + case SDLK_DELETE: + return KEY_DEL; + case SDLK_END: + return KEY_END; + case SDLK_HOME: + return KEY_HOME; + case SDLK_PAGEUP: + return KEY_PAGEUP; + case SDLK_PAGEDOWN: + return KEY_PAGEDOWN; + case SDLK_BACKSPACE: + return KEY_BACKSPACE; + case SDLK_COMMA: + return KEY_COMMA; + case SDLK_PERIOD: + return KEY_FSTOP; + case SDLK_SPACE: + return KEY_SPACE; + + case SDLK_LSHIFT: + return KEY_LEFTSHIFT; + case SDLK_RSHIFT: + return KEY_RIGHTSHIFT; + case SDLK_LALT: + return KEY_LEFTALT; + case SDLK_RALT: + return KEY_RIGHTALT; + case SDLK_LCTRL: + return KEY_LEFTCTRL; + case SDLK_RCTRL: + return KEY_RIGHTCTRL; + + case SDLK_CAPSLOCK: + return KEY_CAPS; + case SDLK_NUMLOCKCLEAR: + return KEY_NUMLOCK; + case SDLK_SCROLLLOCK: + return KEY_SCROLLOK; + + case SDLK_KP_0: + return KEY_NUMPAD0; + case SDLK_KP_1: + return KEY_NUMPAD1; + case SDLK_KP_2: + return KEY_NUMPAD2; + case SDLK_KP_3: + return KEY_NUMPAD3; + case SDLK_KP_4: + return KEY_NUMPAD4; + case SDLK_KP_5: + return KEY_NUMPAD5; + case SDLK_KP_6: + return KEY_NUMPAD6; + case SDLK_KP_7: + return KEY_NUMPAD7; + case SDLK_KP_8: + return KEY_NUMPAD8; + case SDLK_KP_9: + return KEY_NUMPAD9; + case SDLK_KP_MINUS: + return KEY_NUMPADSUB; + case SDLK_KP_PLUS: + return KEY_NUMPADADD; + case SDLK_KP_PERIOD: + return KEY_NUMPADDEL; + case SDLK_KP_ENTER: + return KEY_NUMPADENTER; + case SDLK_KP_DIVIDE: + return KEY_NUMPADDIVIDE; + case SDLK_KP_MULTIPLY: + return KEY_NUMPADMULTIPLY; + + case SDLK_LEFTBRACKET: + return KEY_LBRACKET; + case SDLK_RIGHTBRACKET: + return KEY_RBRACKET; + case SDLK_SEMICOLON: + return KEY_SEMICOLON; + case SDLK_QUOTE: + return KEY_APOSTROPHE; + case SDLK_BACKQUOTE: + return KEY_GRAVE; + case SDLK_BACKSLASH: + return KEY_BACKSLASH; + case SDLK_SLASH: + return KEY_SLASH; +/* case SDLK_ + return KEY_CAPITAL; */ + case SDLK_MINUS: + return KEY_MINUS; + case SDLK_EQUALS: + return KEY_EQUALS; + case SDLK_LGUI: + return KEY_LWIN; + case SDLK_RGUI: + return KEY_RWIN; +/* case SDLK_ + return KEY_APPS; */ + + case SDLK_F1: + return KEY_F1; + case SDLK_F2: + return KEY_F2; + case SDLK_F3: + return KEY_F3; + case SDLK_F4: + return KEY_F4; + case SDLK_F5: + return KEY_F5; + case SDLK_F6: + return KEY_F6; + case SDLK_F7: + return KEY_F7; + case SDLK_F8: + return KEY_F8; + case SDLK_F9: + return KEY_F9; + case SDLK_F10: + return KEY_F10; + case SDLK_F11: + return KEY_F11; + case SDLK_F12: + return KEY_F12; + +/* finish foreign keys */ + + default: + return -1; + } +} + +static void handle_keypress(int key, int unicode, int press) +{ + if (key == -1) + return; + + if (press) { + switch(key) { + case KEY_BACKSPACE: + RE_ENTRANT_QUEUE_WinProc_AddMessage_WM_KEYDOWN(VK_BACK); + break; + case KEY_END: + RE_ENTRANT_QUEUE_WinProc_AddMessage_WM_KEYDOWN(VK_END); + break; + case KEY_HOME: + RE_ENTRANT_QUEUE_WinProc_AddMessage_WM_KEYDOWN(VK_HOME); + break; + case KEY_LEFT: + RE_ENTRANT_QUEUE_WinProc_AddMessage_WM_KEYDOWN(VK_LEFT); + break; + case KEY_UP: + RE_ENTRANT_QUEUE_WinProc_AddMessage_WM_KEYDOWN(VK_UP); + break; + case KEY_RIGHT: + RE_ENTRANT_QUEUE_WinProc_AddMessage_WM_KEYDOWN(VK_RIGHT); + break; + case KEY_DOWN: + RE_ENTRANT_QUEUE_WinProc_AddMessage_WM_KEYDOWN(VK_DOWN); + break; + case KEY_INS: + RE_ENTRANT_QUEUE_WinProc_AddMessage_WM_KEYDOWN(VK_INSERT); + break; + case KEY_DEL: + RE_ENTRANT_QUEUE_WinProc_AddMessage_WM_KEYDOWN(VK_DELETE); + break; + case KEY_TAB: + RE_ENTRANT_QUEUE_WinProc_AddMessage_WM_KEYDOWN(VK_TAB); + break; + default: + break; + } + } + + if (press && !KeyboardInput[key]) { + DebouncedKeyboardInput[key] = 1; + DebouncedGotAnyKey = 1; + } + + if (press) + GotAnyKey = 1; + KeyboardInput[key] = press; +} + +static void handle_buttonpress(int button, int press) +{ + int key; + + switch(button) { + case 4: /* mouse wheel up */ + key = KEY_MOUSEWHEELUP; + break; + case 5: /* mouse wheel down */ + key = KEY_MOUSEWHEELDOWN; + break; + default: /* other buttons are handled elsewhere */ + return; + } + + /* since this currently only handles wheel up/down */ + if (press == 0) + return; + + if (press && !KeyboardInput[key]) { + DebouncedKeyboardInput[key] = 1; + } + + GotAnyKey = 1; + KeyboardInput[key] = press; +} + +void CheckForWindowsMessages() +{ + SDL_Event event; + int x, y, buttons, wantmouse; + + GotAnyKey = 0; + DebouncedGotAnyKey = 0; + memset(DebouncedKeyboardInput, 0, sizeof(DebouncedKeyboardInput)); + + wantmouse = 0; //(surface->flags & SDL_FULLSCREEN) || + //(SDL_WM_GrabInput(SDL_GRAB_QUERY) == SDL_GRAB_ON); + + KeyboardInput[KEY_MOUSEWHEELUP] = 0; + KeyboardInput[KEY_MOUSEWHEELDOWN] = 0; + + if (SDL_PollEvent(&event)) { + do { + switch(event.type) { + case SDL_MOUSEBUTTONDOWN: + if (wantmouse) + handle_buttonpress(event.button.button, 1); + break; + case SDL_MOUSEBUTTONUP: + break; + case SDL_TEXTINPUT: { + int unicode = event.text.text[0]; //TODO convert to utf-32 + if (unicode && !(unicode & 0xFF80)) { + RE_ENTRANT_QUEUE_WinProc_AddMessage_WM_CHAR(unicode); + KeyboardEntryQueue_Add(unicode); + } + } + break; + case SDL_KEYDOWN: + if (event.key.keysym.sym == SDLK_PRINTSCREEN) { + if (HavePrintScn == 0) + GotPrintScn = 1; + HavePrintScn = 1; + } else { + handle_keypress(KeySymToKey(event.key.keysym.sym), 0, 1); + } + break; + case SDL_KEYUP: + if (event.key.keysym.sym == SDLK_PRINTSCREEN) { + GotPrintScn = 0; + HavePrintScn = 0; + } else { + handle_keypress(KeySymToKey(event.key.keysym.sym), 0, 0); + } + break; + case SDL_QUIT: + AvP.MainLoopRunning = 0; /* TODO */ + exit(0); //TODO + break; + } + } while (SDL_PollEvent(&event)); + } + + buttons = SDL_GetRelativeMouseState(&x, &y); + + if (wantmouse) { + if (buttons & SDL_BUTTON(1)) + handle_keypress(KEY_LMOUSE, 0, 1); + else + handle_keypress(KEY_LMOUSE, 0, 0); + if (buttons & SDL_BUTTON(2)) + handle_keypress(KEY_MMOUSE, 0, 1); + else + handle_keypress(KEY_MMOUSE, 0, 0); + if (buttons & SDL_BUTTON(3)) + handle_keypress(KEY_RMOUSE, 0, 1); + else + handle_keypress(KEY_RMOUSE, 0, 0); + + MouseVelX = DIV_FIXED(x, NormalFrameTime); + MouseVelY = DIV_FIXED(y, NormalFrameTime); + } else { + KeyboardInput[KEY_LMOUSE] = 0; + KeyboardInput[KEY_MMOUSE] = 0; + KeyboardInput[KEY_RMOUSE] = 0; + MouseVelX = 0; + MouseVelY = 0; + } + + if (GotJoystick) { + int numbuttons; + + SDL_JoystickUpdate(); + + numbuttons = SDL_JoystickNumButtons(joy); + if (numbuttons > 16) numbuttons = 16; + + for (x = 0; x < numbuttons; x++) { + if (SDL_JoystickGetButton(joy, x)) { + GotAnyKey = 1; + if (!KeyboardInput[KEY_JOYSTICK_BUTTON_1+x]) { + KeyboardInput[KEY_JOYSTICK_BUTTON_1+x] = 1; + DebouncedKeyboardInput[KEY_JOYSTICK_BUTTON_1+x] = 1; + } + } else { + KeyboardInput[KEY_JOYSTICK_BUTTON_1+x] = 0; + } + } + } + + if ((KeyboardInput[KEY_LEFTALT]||KeyboardInput[KEY_RIGHTALT]) && DebouncedKeyboardInput[KEY_CR]) { + //SDL_GrabMode gm; + // + //SDL_WM_ToggleFullScreen(surface); + // + //gm = SDL_WM_GrabInput(SDL_GRAB_QUERY); + //if (gm == SDL_GRAB_OFF && !(surface->flags & SDL_FULLSCREEN)) + // SDL_ShowCursor(1); + //else + // SDL_ShowCursor(0); + } + + if (KeyboardInput[KEY_LEFTCTRL] && DebouncedKeyboardInput[KEY_G]) { + //SDL_GrabMode gm; + // + //gm = SDL_WM_GrabInput(SDL_GRAB_QUERY); + //SDL_WM_GrabInput((gm == SDL_GRAB_ON) ? SDL_GRAB_OFF : SDL_GRAB_ON); + // + //gm = SDL_WM_GrabInput(SDL_GRAB_QUERY); + //if (gm == SDL_GRAB_OFF && !(surface->flags & SDL_FULLSCREEN)) + // SDL_ShowCursor(1); + //else + // SDL_ShowCursor(0); + } + + if (GotPrintScn) { + GotPrintScn = 0; + + ScreenShot(); + } +} + +void InGameFlipBuffers() +{ + if (window != NULL) { + SDL_GL_SwapWindow(window); + } +} + +void FlipBuffers() +{ + // TODO: move this to init + static GLuint t; + + if (t == 0) { + pglGenTextures(1, &t); + + pglBindTexture(GL_TEXTURE_2D, t); + + pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); + pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); + + pglTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 640, 480, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, NULL); + } + + pglDisableClientState(GL_VERTEX_ARRAY); + pglDisableClientState(GL_TEXTURE_COORD_ARRAY); + pglDisableClientState(GL_COLOR_ARRAY); + + pglClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + + pglMatrixMode(GL_PROJECTION); + pglLoadIdentity(); + pglMatrixMode(GL_MODELVIEW); + pglLoadIdentity(); + + pglDisable(GL_ALPHA_TEST); + pglDisable(GL_BLEND); + pglDisable(GL_DEPTH_TEST); + + pglBindTexture(GL_TEXTURE_2D, t); + pglTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); + pglTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 640, 480, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, surface->pixels); + + GLfloat x0; + GLfloat x1; + GLfloat y0; + GLfloat y1; + + // figure out the best way to fit the 640x480 virtual window + GLfloat a = ViewportHeight * 640.0f / 480.0f; + GLfloat b = ViewportWidth * 480.0f / 640.0f; + + if (a <= ViewportWidth) { + // a x ViewportHeight window + y0 = -1.0f; + y1 = 1.0f; + + x1 = 1.0 - (ViewportWidth - a) / ViewportWidth; + x0 = -x1; + } else { + // ViewportWidth x b window + x0 = -1.0f; + x1 = 1.0f; + + y1 = 1.0 - (ViewportHeight - b) / ViewportHeight; + y0 = -y1; + } + + pglBegin(GL_QUADS); + + pglTexCoord2f(0.0, 1.0); + pglVertex3f(x0, y0, -1.0); + + pglTexCoord2f(1.0, 1.0); + pglVertex3f(x1, y0, -1.0); + + pglTexCoord2f(1.0, 0.0); + pglVertex3f(x1, y1, -1.0); + + pglTexCoord2f(0.0, 0.0); + pglVertex3f(x0, y1, -1.0); + + pglEnd(); + + pglBindTexture(GL_TEXTURE_2D, 0); + + SDL_GL_SwapWindow(window); +} + +char *AvpCDPath = 0; + +#if !defined(_MSC_VER) +static const struct option getopt_long_options[] = { +{ "help", 0, NULL, 'h' }, +{ "version", 0, NULL, 'v' }, +{ "fullscreen", 0, NULL, 'f' }, +{ "windowed", 0, NULL, 'w' }, +{ "nosound", 0, NULL, 's' }, +{ "nocdrom", 0, NULL, 'c' }, +{ "nojoy", 0, NULL, 'j' }, +{ "debug", 0, NULL, 'd' }, +{ "withgl", 1, NULL, 'g' }, +/* +{ "loadrifs", 1, NULL, 'l' }, +{ "server", 0, someval, 1 }, +{ "client", 1, someval, 2 }, +*/ +{ NULL, 0, NULL, 0 }, +}; +#endif + +static const char *usage_string = +"Aliens vs Predator Linux - http://www.icculus.org/avp/\n" +"Based on Rebellion Developments AvP Gold source\n" +" [-h | --help] Display this help message\n" +" [-v | --version] Display the game version\n" +" [-f | --fullscreen] Run the game fullscreen\n" +" [-w | --windowed] Run the game in a window\n" +" [-s | --nosound] Do not access the soundcard\n" +" [-c | --nocdrom] Do not access the CD-ROM\n" +" [-j | --nojoy] Do not access the joystick\n" +" [-g | --withgl] [x] Use [x] instead of /usr/lib/libGL.so.1 for OpenGL\n" +; + +int main(int argc, char *argv[]) +{ +#if !defined(_MSC_VER) + int c; + + opterr = 0; + while ((c = getopt_long(argc, argv, "hvfwscdg:", getopt_long_options, NULL)) != -1) { + switch(c) { + case 'h': + printf("%s", usage_string); + exit(EXIT_SUCCESS); + case 'v': + printf("%s", AvPVersionString); + exit(EXIT_SUCCESS); + case 'f': + WantFullscreen = 1; + break; + case 'w': + WantFullscreen = 0; + break; + case 's': + WantSound = 0; + break; + case 'c': + WantCDRom = 0; + break; + case 'j': + WantJoystick = 0; + break; + case 'd': { + extern int DebuggingCommandsActive; + DebuggingCommandsActive = 1; + } + break; + case 'g': + opengl_library = optarg; + break; + default: + printf("%s", usage_string); + exit(EXIT_FAILURE); + } + } +#endif + + InitGameDirectories(argv[0]); + + if (InitSDL() == -1) { + fprintf(stderr, "Could not find a sutable resolution!\n"); + fprintf(stderr, "At least 512x384 is needed. Does OpenGL work?\n"); + exit(EXIT_FAILURE); + } + + LoadCDTrackList(); + + SetFastRandom(); + +#if MARINE_DEMO + ffInit("fastfile/mffinfo.txt","fastfile/"); +#elif ALIEN_DEMO + ffInit("alienfastfile/ffinfo.txt","alienfastfile/"); +#else + ffInit("fastfile/ffinfo.txt","fastfile/"); +#endif + InitGame(); + + //NEW + SetOGLVideoMode(VideoModeList[1].w, VideoModeList[1].h); + //NEW + + SetSoftVideoMode(640, 480, 16); + + InitialVideoMode(); + + /* Env_List can probably be removed */ + Env_List[0]->main = LevelName; + + InitialiseSystem(); + InitialiseRenderer(); + + LoadKeyConfiguration(); + + SoundSys_Start(); + if (WantCDRom) CDDA_Start(); + + InitTextStrings(); + + BuildMultiplayerLevelNameArray(); + + ChangeDirectDrawObject(); + AvP.LevelCompleted = 0; + LoadSounds("PLAYER"); + + /* is this still neccessary? */ + AvP.CurrentEnv = AvP.StartingEnv = 0; + +#if ALIEN_DEMO + AvP.PlayerType = I_Alien; + SetLevelToLoad(AVP_ENVIRONMENT_INVASION_A); +#elif PREDATOR_DEMO + AvP.PlayerType = I_Predator; + SetLevelToLoad(AVP_ENVIRONMENT_INVASION_P); +#elif MARINE_DEMO + AvP.PlayerType = I_Marine; + SetLevelToLoad(AVP_ENVIRONMENT_INVASION); +#endif + +#if !(ALIEN_DEMO|PREDATOR_DEMO|MARINE_DEMO) +while (AvP_MainMenus()) +#else +if (AvP_MainMenus()) +#endif +{ + int menusActive = 0; + int thisLevelHasBeenCompleted = 0; + + /* turn off any special effects */ + d3d_light_ctrl.ctrl = LCCM_NORMAL; + + //NEW + //TODO + // need to watch for CurrentVideoMode to change in all cases + // the menu will always render in a 640x480 virtual window + // game will render in a user-specified virtual window + // real window will be which ever size is available + //TODO + //NEW + SetOGLVideoMode(VideoModeList[CurrentVideoMode].w, VideoModeList[CurrentVideoMode].h); + + InitialiseGammaSettings(RequestedGammaSetting); + + start_of_loaded_shapes = load_precompiled_shapes(); + + InitCharacter(); + + LoadRifFile(); /* sets up a map */ + + AssignAllSBNames(); + + StartGame(); + + ffcloseall(); + + AvP.MainLoopRunning = 1; + + ScanImagesForFMVs(); + + ResetFrameCounter(); + + Game_Has_Loaded(); + + ResetFrameCounter(); + + if(AvP.Network!=I_No_Network) + { + /*Need to choose a starting position for the player , but first we must look + through the network messages to find out which generator spots are currently clear*/ + netGameData.myGameState = NGS_Playing; + MinimalNetCollectMessages(); + TeleportNetPlayerToAStartingPosition(Player->ObStrategyBlock,1); + } + + IngameKeyboardInput_ClearBuffer(); + + while(AvP.MainLoopRunning) { + CheckForWindowsMessages(); + + switch(AvP.GameMode) { + case I_GM_Playing: + if ((!menusActive || (AvP.Network!=I_No_Network && !netGameData.skirmishMode)) && !AvP.LevelCompleted) { + /* TODO: print some debugging stuff */ + + DoAllShapeAnimations(); + + UpdateGame(); + + AvpShowViews(); + + MaintainHUD(); + + CheckCDAndChooseTrackIfNeeded(); + + if(InGameMenusAreRunning() && ( (AvP.Network!=I_No_Network && netGameData.skirmishMode) || (AvP.Network==I_No_Network)) ) { + SoundSys_StopAll(); + } + } else { + ReadUserInput(); + + SoundSys_Management(); + + FlushD3DZBuffer(); + + ThisFramesRenderingHasBegun(); + } + + menusActive = AvP_InGameMenus(); + if (AvP.RestartLevel) menusActive=0; + + if (AvP.LevelCompleted) { + SoundSys_FadeOutFast(); + DoCompletedLevelStatisticsScreen(); + thisLevelHasBeenCompleted = 1; + } + + ThisFramesRenderingHasFinished(); + + InGameFlipBuffers(); + + FrameCounterHandler(); + { + PLAYER_STATUS *playerStatusPtr = (PLAYER_STATUS *) (Player->ObStrategyBlock->SBdataptr); + + if (!menusActive && playerStatusPtr->IsAlive && !AvP.LevelCompleted) { + DealWithElapsedTime(); + } + } + break; + + case I_GM_Menus: + AvP.GameMode = I_GM_Playing; + break; + default: + fprintf(stderr, "AvP.MainLoopRunning: gamemode = %d\n", AvP.GameMode); + exit(EXIT_FAILURE); + } + + if (AvP.RestartLevel) { + AvP.RestartLevel = 0; + AvP.LevelCompleted = 0; + + FixCheatModesInUserProfile(UserProfilePtr); + + RestartLevel(); + } + } + + AvP.LevelCompleted = thisLevelHasBeenCompleted; + + FixCheatModesInUserProfile(UserProfilePtr); + + ReleaseAllFMVTextures(); + + CONSBIND_WriteKeyBindingsToConfigFile(); + + DeInitialisePlayer(); + + DeallocatePlayersMirrorImage(); + + KillHUD(); + + Destroy_CurrentEnvironment(); + + DeallocateAllImages(); + + EndNPCs(); + + ExitGame(); + + SoundSys_StopAll(); + + SoundSys_ResetFadeLevel(); + + CDDA_Stop(); + + if (AvP.Network != I_No_Network) { + EndAVPNetGame(); + } + + ClearMemoryPool(); + +/* go back to menu mode */ +#if !(ALIEN_DEMO|PREDATOR_DEMO|MARINE_DEMO) + SetSoftVideoMode(640, 480, 16); +#endif +} + + SoundSys_StopAll(); + SoundSys_RemoveAll(); + + ExitSystem(); + + CDDA_End(); + ClearMemoryPool(); + + return 0; +} diff --git a/src/maths.c b/src/maths.c index 71a1389..ea5ad8a 100644 --- a/src/maths.c +++ b/src/maths.c @@ -2311,7 +2311,7 @@ dx = 0; /* TODO: uninitialized?? */ #define DEG_3 31 #define SEP_3 3 -static long table [DEG_3] = +static int32_t table [DEG_3] = { -851904987, -43806228, -2029755270, 1390239686, -1912102820, -485608943, 1969813258, -1590463333, -1944053249, 455935928, @@ -2324,8 +2324,8 @@ static long table [DEG_3] = #define TABLE_END (table + sizeof (table) / sizeof (table [0])) -static long * front_ptr = table + SEP_3; -static long * rear_ptr = table; +static int32_t * front_ptr = table + SEP_3; +static int32_t * rear_ptr = table; void SetSeededFastRandom(int seed); @@ -2359,7 +2359,7 @@ int FastRandom(void) { - long i; + int32_t i; /* @@ -2370,7 +2370,7 @@ int FastRandom(void) */ *front_ptr += *rear_ptr; - i = (long) ((unsigned long) *front_ptr >> 1); + i = (int32_t) ((uint32_t) *front_ptr >> 1); /* `front_ptr' and `rear_ptr' can't wrap at the same time. */ @@ -2402,12 +2402,12 @@ int FastRandom(void) #define SEEDED_DEG_3 13 #define SEEDED_SEP_3 3 -static long seeded_table [SEEDED_DEG_3]; +static int32_t seeded_table [SEEDED_DEG_3]; #define SEEDED_TABLE_END (seeded_table + sizeof (seeded_table) / sizeof (seeded_table [0])) -static long * seeded_front_ptr = seeded_table + SEEDED_SEP_3; -static long * seeded_rear_ptr = seeded_table; +static int32_t * seeded_front_ptr = seeded_table + SEEDED_SEP_3; +static int32_t * seeded_rear_ptr = seeded_table; @@ -2415,7 +2415,7 @@ int SeededFastRandom(void) { - long i; + int32_t i; /* @@ -2426,7 +2426,7 @@ int SeededFastRandom(void) */ *seeded_front_ptr += *seeded_rear_ptr; - i = (long) ((unsigned long) *seeded_front_ptr >> 1); + i = (int32_t) ((uint32_t) *seeded_front_ptr >> 1); /* `front_ptr' and `rear_ptr' can't wrap at the same time. */ @@ -2458,7 +2458,7 @@ void SetSeededFastRandom(int seed) { int i; - long number = seed; + int32_t number = seed; for(i = 0; i < SEEDED_DEG_3; ++i) { diff --git a/src/md5.c b/src/md5.c index 611f151..247d21c 100644 --- a/src/md5.c +++ b/src/md5.c @@ -142,7 +142,7 @@ MD5Final(md5byte digest[16], struct MD5Context *ctx) byteSwap(ctx->buf, 4); memcpy(digest, ctx->buf, 16); - memset(ctx, 0, sizeof(ctx)); /* In case it's sensitive */ + memset(ctx, 0, sizeof(*ctx)); /* In case it's sensitive */ } #ifndef ASM_MD5 diff --git a/src/menus.c b/src/menus.c index 5415dc3..25e98ae 100644 --- a/src/menus.c +++ b/src/menus.c @@ -290,7 +290,7 @@ static void LoadMenuFont() { AVPMENUGFX *gfxPtr; char buffer[100]; - unsigned int fastFileLength; + size_t fastFileLength; void const *pFastFileData; IntroFont_Light.height = 33; @@ -1050,7 +1050,7 @@ void LoadAvPMenuGfx(enum AVPMENUGFX_ID menuGfxID) { AVPMENUGFX *gfxPtr; char buffer[100]; - unsigned int fastFileLength; + size_t fastFileLength; void const *pFastFileData; GLOBALASSERT(menuGfxID < MAX_NO_OF_AVPMENUGFXS); diff --git a/src/module.c b/src/module.c index 8efcece..393f19a 100644 --- a/src/module.c +++ b/src/module.c @@ -643,7 +643,7 @@ int GetModuleVisArrays(void) ModuleArraySize = index + 1; - ModuleCurrVisArray = AllocateMem(ModuleArraySize); + ModuleCurrVisArray = (char*) AllocateMem(ModuleArraySize); if(ModuleCurrVisArray) { diff --git a/src/oglfunc.c b/src/oglfunc.c index 0df0bf7..c5ec48e 100644 --- a/src/oglfunc.c +++ b/src/oglfunc.c @@ -42,6 +42,7 @@ PFNGLGETERRORPROC pglGetError; PFNGLGETFLOATVPROC pglGetFloatv; PFNGLGETINTEGERVPROC pglGetIntegerv; PFNGLGETSTRINGPROC pglGetString; +PFNGLGETTEXPARAMETERFVPROC pglGetTexParameterfv; PFNGLHINTPROC pglHint; PFNGLLOADIDENTITYPROC pglLoadIdentity; PFNGLLOADMATRIXFPROC pglLoadMatrixf; @@ -100,11 +101,15 @@ PFNGLSECONDARYCOLOR3UBEXTPROC pglSecondaryColor3ubEXT; PFNGLSECONDARYCOLOR3UBVEXTPROC pglSecondaryColor3ubvEXT; PFNGLSECONDARYCOLORPOINTEREXTPROC pglSecondaryColorPointerEXT; +int ogl_have_multisample_filter_hint; int ogl_have_paletted_texture; int ogl_have_secondary_color; +int ogl_have_texture_filter_anisotropic; +int ogl_use_multisample_filter_hint; int ogl_use_paletted_texture; int ogl_use_secondary_color; +int ogl_use_texture_filter_anisotropic; static void dummyfunc() { @@ -183,6 +188,7 @@ void load_ogl_functions(int mode) LoadOGLProc(PFNGLGETFLOATVPROC, glGetFloatv); LoadOGLProc(PFNGLGETINTEGERVPROC, glGetIntegerv); LoadOGLProc(PFNGLGETSTRINGPROC, glGetString); + LoadOGLProc(PFNGLGETTEXPARAMETERFVPROC, glGetTexParameterfv); LoadOGLProc(PFNGLHINTPROC, glHint); LoadOGLProc(PFNGLLOADIDENTITYPROC, glLoadIdentity); LoadOGLProc(PFNGLLOADMATRIXFPROC, glLoadMatrixf); @@ -247,8 +253,10 @@ void load_ogl_functions(int mode) ext = (const char *) pglGetString(GL_EXTENSIONS); + ogl_have_multisample_filter_hint = check_token(ext, "GL_NV_multisample_filter_hint"); ogl_have_paletted_texture = check_token(ext, "GL_EXT_paletted_texture"); ogl_have_secondary_color = check_token(ext, "GL_EXT_secondary_color"); + ogl_have_texture_filter_anisotropic = check_token(ext, "GL_EXT_texture_filter_anisotropic"); #ifndef GL_COLOR_TABLE_WIDTH_EXT #define GL_COLOR_TABLE_WIDTH_EXT GL_COLOR_TABLE_WIDTH @@ -287,11 +295,20 @@ void load_ogl_functions(int mode) ogl_have_secondary_color = 0; } } - + + ogl_use_multisample_filter_hint = ogl_have_multisample_filter_hint; ogl_use_paletted_texture = ogl_have_paletted_texture; ogl_use_secondary_color = ogl_have_secondary_color; - - // fprintf(stderr, "RENDER DEBUG: pal:%d sec:%d\n", ogl_use_paletted_texture, ogl_use_secondary_color); + ogl_use_texture_filter_anisotropic = ogl_have_texture_filter_anisotropic; + +#if 0 + fprintf(stderr, "RENDER DEBUG: pal:%d sec:%d mfh:%d tfa:%d\n", + ogl_use_paletted_texture, + ogl_use_secondary_color, + ogl_use_multisample_filter_hint, + ogl_use_texture_filter_anisotropic + ); +#endif } int check_for_errors(const char *file, int line) diff --git a/src/oglfunc.h b/src/oglfunc.h index ffb108a..a55fc1f 100644 --- a/src/oglfunc.h +++ b/src/oglfunc.h @@ -5,7 +5,8 @@ #include #endif -#include +#include "SDL_opengl.h" +//#include //#include typedef void (APIENTRY *PFNGLALPHAFUNCPROC)(GLenum, GLclampf); @@ -45,6 +46,7 @@ typedef GLenum (APIENTRY *PFNGLGETERRORPROC)(void); typedef void (APIENTRY *PFNGLGETFLOATVPROC)(GLenum, GLfloat *); typedef void (APIENTRY *PFNGLGETINTEGERVPROC)(GLenum, GLint *); typedef const GLubyte* (APIENTRY *PFNGLGETSTRINGPROC)(GLenum); +typedef void (APIENTRY *PFNGLGETTEXPARAMETERFVPROC)(GLenum, GLenum, GLfloat*); typedef void (APIENTRY *PFNGLHINTPROC)(GLenum, GLenum); typedef void (APIENTRY *PFNGLLOADIDENTITYPROC)(void); typedef void (APIENTRY *PFNGLLOADMATRIXFPROC)(const GLfloat *); @@ -119,6 +121,8 @@ typedef void (APIENTRY * PFNGLSECONDARYCOLOR3USVEXTPROC) (const GLushort *v); typedef void (APIENTRY * PFNGLSECONDARYCOLORPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); #endif +typedef void (APIENTRY *PFNGLXSWAPINTERVALSGIPROC)(int interval); + extern PFNGLALPHAFUNCPROC pglAlphaFunc; extern PFNGLARRAYELEMENTPROC pglArrayElement; extern PFNGLBEGINPROC pglBegin; @@ -156,6 +160,7 @@ extern PFNGLGETERRORPROC pglGetError; extern PFNGLGETFLOATVPROC pglGetFloatv; extern PFNGLGETINTEGERVPROC pglGetIntegerv; extern PFNGLGETSTRINGPROC pglGetString; +extern PFNGLGETTEXPARAMETERFVPROC pglGetTexParameterfv; extern PFNGLHINTPROC pglHint; extern PFNGLLOADIDENTITYPROC pglLoadIdentity; extern PFNGLLOADMATRIXFPROC pglLoadMatrixf; @@ -214,11 +219,15 @@ extern PFNGLSECONDARYCOLOR3UBEXTPROC pglSecondaryColor3ubEXT; extern PFNGLSECONDARYCOLOR3UBVEXTPROC pglSecondaryColor3ubvEXT; extern PFNGLSECONDARYCOLORPOINTEREXTPROC pglSecondaryColorPointerEXT; +extern int ogl_have_multisample_filter_hint; extern int ogl_have_paletted_texture; extern int ogl_have_secondary_color; +extern int ogl_have_texture_filter_anisotropic; +extern int ogl_use_multisample_filter_hint; extern int ogl_use_paletted_texture; extern int ogl_use_secondary_color; +extern int ogl_use_texture_filter_anisotropic; extern void load_ogl_functions(int mode); extern int check_for_errors(const char *file, int line); diff --git a/src/openal.c b/src/openal.c index 70418c8..7018255 100644 --- a/src/openal.c +++ b/src/openal.c @@ -3,8 +3,8 @@ #include #include -#include -#include +#include "al.h" +#include "alc.h" #include "fixer.h" @@ -23,6 +23,10 @@ #include #endif +#if 0 +#define OPENAL_DEBUG +#endif + ACTIVESOUNDSAMPLE ActiveSounds[SOUND_MAXACTIVE]; ACTIVESOUNDSAMPLE BlankActiveSound = {SID_NOSOUND,ASP_Minimum,0,0,NULL,0,0,0,0,0, { {0,0,0},{0,0,0},0,0 }, 0, 0, { 0.0, 0.0, 0.0 }, { 0.0, 0.0, 0.0 }, NULL, NULL, NULL}; SOUNDSAMPLEDATA BlankGameSound = {0,0,0,0,0,NULL,0,0,NULL,0}; @@ -563,6 +567,7 @@ int PlatPlaySound(int activeIndex) if (ActiveSounds[activeIndex].threedee) { alSourcei(ActiveSounds[activeIndex].ds3DBufferP, AL_SOURCE_RELATIVE, AL_FALSE); + alSourcef(ActiveSounds[activeIndex].ds3DBufferP, AL_REFERENCE_DISTANCE, ActiveSounds[activeIndex].threedeedata.inner_range); // TODO: min distance ActiveSounds[activeIndex].threedeedata.inner_range? // TODO: max distance DS3D_DEFAULTMAXDISTANCE? @@ -865,7 +870,9 @@ void PlatUpdatePlayer() or[5] = -(float) ((Global_VDB_Ptr->VDB_Mat.mat32) / 65536.0F); } - if ((AvP.PlayerType == I_Alien && DopplerShiftIsOn && NormalFrameTime)) { +#warning VELOCITY AND/OR OPENAL SETUP IS IN WRONG UNITS + static int useVel = 0; + if (useVel!=0&&(AvP.PlayerType == I_Alien && DopplerShiftIsOn && NormalFrameTime)) { DYNAMICSBLOCK *dynPtr = Player->ObStrategyBlock->DynPtr; float invFrameTime = 100000.0f/(float)NormalFrameTime; @@ -883,7 +890,7 @@ void PlatUpdatePlayer() pos[2] = Global_VDB_Ptr->VDB_World.vz; // 10000.0; #ifdef OPENAL_DEBUG - fprintf(stderr, "OPENAL: Player: (%f, %f, %f) (%f, %f, %f %f, %f, %f)\n", pos[0], pos[1], pos[2], or[0], or[1], or[2], or[3], or[4], or[5]); + fprintf(stderr, "OPENAL: Player: (%f, %f, %f) (%f, %f, %f %f, %f, %f) (%f, %f, %f)\n", pos[0], pos[1], pos[2], or[0], or[1], or[2], or[3], or[4], or[5], vel[0], vel[1], vel[2]); #endif pos[0] = 0.0f; diff --git a/src/opengl.c b/src/opengl.c index f4f041b..15195cd 100644 --- a/src/opengl.c +++ b/src/opengl.c @@ -54,10 +54,6 @@ static D3DTexture *CurrentlyBoundTexture = NULL; #define TA_MAXVERTICES 2048 #define TA_MAXTRIANGLES 2048 -#if GL_EXT_secondary_color -extern PFNGLSECONDARYCOLORPOINTEREXTPROC pglSecondaryColorPointerEXT; -#endif - typedef struct VertexArray { GLfloat v[4]; @@ -69,9 +65,9 @@ typedef struct VertexArray typedef struct TriangleArray { - int a; - int b; - int c; + unsigned short a; + unsigned short b; + unsigned short c; } TriangleArray; static VertexArray varr[TA_MAXVERTICES*2]; @@ -132,6 +128,14 @@ A few things: void InitOpenGL() { + pglHint( GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST ); + pglHint( GL_GENERATE_MIPMAP_HINT, GL_NICEST ); + + if ( ogl_use_multisample_filter_hint ) + { + pglHint( GL_MULTISAMPLE_FILTER_HINT_NV, GL_NICEST ); + } + CurrentTranslucencyMode = TRANSLUCENCY_OFF; pglBlendFunc(GL_ONE, GL_ZERO); @@ -155,12 +159,12 @@ void InitOpenGL() #if 0 #if GL_EXT_secondary_color - if (useseparate) { - pglEnableClientState(GL_SEPARATE_COLOR_ARRAY_EXT); - pglSecondaryColorPointerEXT(4, GL_UNSIGNED_BYTE, sizeof(svarr[0]), svarr[0].c); - } else { - pglDisableClientState(GL_SEPARATE_COLOR_ARRAY_EXT); - } + if (ogl_use_secondary_color) { + pglEnableClientState(GL_SEPARATE_COLOR_ARRAY_EXT); + pglSecondaryColorPointerEXT(4, GL_UNSIGNED_BYTE, sizeof(svarr[0]), svarr[0].c); + } else { + pglDisableClientState(GL_SEPARATE_COLOR_ARRAY_EXT); + } #endif #endif @@ -179,20 +183,8 @@ void InitOpenGL() static void FlushTriangleBuffers(int backup) { - int i; - if (tarrc) { -#if 1 - pglBegin(GL_TRIANGLES); - for (i = 0; i < tarrc; i++) { - pglArrayElement(tarr[i].a); - pglArrayElement(tarr[i].b); - pglArrayElement(tarr[i].c); - } - pglEnd(); -#else - pglDrawElements(GL_TRIANGLES, tarrc*3, GL_UNSIGNED_INT, tarr); -#endif + pglDrawElements(GL_TRIANGLES, tarrc*3, GL_UNSIGNED_SHORT, tarr); tarrc = 0; tarrp = tarr; @@ -217,17 +209,7 @@ static void FlushTriangleBuffers(int backup) pglDisableClientState(GL_TEXTURE_COORD_ARRAY); -#if 1 - pglBegin(GL_TRIANGLES); - for (i = 0; i < starrc; i++) { - pglArrayElement(starr[i].a); - pglArrayElement(starr[i].b); - pglArrayElement(starr[i].c); - } - pglEnd(); -#else - pglDrawElements(GL_TRIANGLES, starrc*3, GL_UNSIGNED_INT, starr); -#endif + pglDrawElements(GL_TRIANGLES, starrc*3, GL_UNSIGNED_SHORT, starr); pglEnableClientState(GL_TEXTURE_COORD_ARRAY); @@ -339,7 +321,7 @@ static void CheckTriangleBuffer(int rver, int sver, int rtri, int stri, D3DTextu FlushTriangleBuffers(0); } - if ((int)tex != -1) + if ((intptr_t)tex != -1) CheckBoundTextureIsCorrect(tex); if (mode != -1) CheckTranslucencyModeIsCorrect(mode); @@ -450,17 +432,20 @@ static void SelectPolygonBeginType(int points) GLuint CreateOGLTexture(D3DTexture *tex, unsigned char *buf) { GLuint h; + GLfloat max_anisotropy; FlushTriangleBuffers(1); pglGenTextures(1, &h); pglBindTexture(GL_TEXTURE_2D, h); + pglTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE); + pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); pglTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, tex->w, tex->h, 0, GL_RGBA, GL_UNSIGNED_BYTE, buf); @@ -469,8 +454,17 @@ GLuint CreateOGLTexture(D3DTexture *tex, unsigned char *buf) tex->id = h; tex->filter = FILTERING_BILINEAR_ON; - if (CurrentlyBoundTexture) - pglBindTexture(GL_TEXTURE_2D, CurrentlyBoundTexture->id); /* restore current */ + if ( ogl_use_texture_filter_anisotropic ) + { + pglGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &max_anisotropy); + pglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, max_anisotropy); + } + + if ( CurrentlyBoundTexture != NULL ) + { + /* restore the previously-bound texture */ + pglBindTexture(GL_TEXTURE_2D, CurrentlyBoundTexture->id); + } return h; } diff --git a/src/sdl12/SDLMain.h b/src/sdl12/SDLMain.h new file mode 100644 index 0000000..c56d90c --- /dev/null +++ b/src/sdl12/SDLMain.h @@ -0,0 +1,16 @@ +/* SDLMain.m - main entry point for our Cocoa-ized SDL app + Initial Version: Darrell Walisser + Non-NIB-Code & other changes: Max Horn + + Feel free to customize this file to suit your needs +*/ + +#ifndef _SDLMain_h_ +#define _SDLMain_h_ + +#import + +@interface SDLMain : NSObject +@end + +#endif /* _SDLMain_h_ */ diff --git a/src/sdl12/SDLMain.m b/src/sdl12/SDLMain.m new file mode 100644 index 0000000..2434f81 --- /dev/null +++ b/src/sdl12/SDLMain.m @@ -0,0 +1,381 @@ +/* SDLMain.m - main entry point for our Cocoa-ized SDL app + Initial Version: Darrell Walisser + Non-NIB-Code & other changes: Max Horn + + Feel free to customize this file to suit your needs +*/ + +#include "SDL.h" +#include "SDLMain.h" +#include /* for MAXPATHLEN */ +#include + +/* For some reaon, Apple removed setAppleMenu from the headers in 10.4, + but the method still is there and works. To avoid warnings, we declare + it ourselves here. */ +@interface NSApplication(SDL_Missing_Methods) +- (void)setAppleMenu:(NSMenu *)menu; +@end + +/* Use this flag to determine whether we use SDLMain.nib or not */ +#define SDL_USE_NIB_FILE 0 + +/* Use this flag to determine whether we use CPS (docking) or not */ +#define SDL_USE_CPS 1 +#ifdef SDL_USE_CPS +/* Portions of CPS.h */ +typedef struct CPSProcessSerNum +{ + UInt32 lo; + UInt32 hi; +} CPSProcessSerNum; + +extern OSErr CPSGetCurrentProcess( CPSProcessSerNum *psn); +extern OSErr CPSEnableForegroundOperation( CPSProcessSerNum *psn, UInt32 _arg2, UInt32 _arg3, UInt32 _arg4, UInt32 _arg5); +extern OSErr CPSSetFrontProcess( CPSProcessSerNum *psn); + +#endif /* SDL_USE_CPS */ + +static int gArgc; +static char **gArgv; +static BOOL gFinderLaunch; +static BOOL gCalledAppMainline = FALSE; + +static NSString *getApplicationName(void) +{ + const NSDictionary *dict; + NSString *appName = 0; + + /* Determine the application name */ + dict = (const NSDictionary *)CFBundleGetInfoDictionary(CFBundleGetMainBundle()); + if (dict) + appName = [dict objectForKey: @"CFBundleName"]; + + if (![appName length]) + appName = [[NSProcessInfo processInfo] processName]; + + return appName; +} + +#if SDL_USE_NIB_FILE +/* A helper category for NSString */ +@interface NSString (ReplaceSubString) +- (NSString *)stringByReplacingRange:(NSRange)aRange with:(NSString *)aString; +@end +#endif + +@interface NSApplication (SDLApplication) +@end + +@implementation NSApplication (SDLApplication) +/* Invoked from the Quit menu item */ +- (void)terminate:(id)sender +{ + /* Post a SDL_QUIT event */ + SDL_Event event; + event.type = SDL_QUIT; + SDL_PushEvent(&event); +} +@end + +/* The main class of the application, the application's delegate */ +@implementation SDLMain + +/* Set the working directory to the .app's parent directory */ +- (void) setupWorkingDirectory:(BOOL)shouldChdir +{ + if (shouldChdir) + { + char parentdir[MAXPATHLEN]; + CFURLRef url = CFBundleCopyBundleURL(CFBundleGetMainBundle()); + CFURLRef url2 = CFURLCreateCopyDeletingLastPathComponent(0, url); + if (CFURLGetFileSystemRepresentation(url2, 1, (UInt8 *)parentdir, MAXPATHLEN)) { + chdir(parentdir); /* chdir to the binary app's parent */ + } + CFRelease(url); + CFRelease(url2); + } +} + +#if SDL_USE_NIB_FILE + +/* Fix menu to contain the real app name instead of "SDL App" */ +- (void)fixMenu:(NSMenu *)aMenu withAppName:(NSString *)appName +{ + NSRange aRange; + NSEnumerator *enumerator; + NSMenuItem *menuItem; + + aRange = [[aMenu title] rangeOfString:@"SDL App"]; + if (aRange.length != 0) + [aMenu setTitle: [[aMenu title] stringByReplacingRange:aRange with:appName]]; + + enumerator = [[aMenu itemArray] objectEnumerator]; + while ((menuItem = [enumerator nextObject])) + { + aRange = [[menuItem title] rangeOfString:@"SDL App"]; + if (aRange.length != 0) + [menuItem setTitle: [[menuItem title] stringByReplacingRange:aRange with:appName]]; + if ([menuItem hasSubmenu]) + [self fixMenu:[menuItem submenu] withAppName:appName]; + } +} + +#else + +static void setApplicationMenu(void) +{ + /* warning: this code is very odd */ + NSMenu *appleMenu; + NSMenuItem *menuItem; + NSString *title; + NSString *appName; + + appName = getApplicationName(); + appleMenu = [[NSMenu alloc] initWithTitle:@""]; + + /* Add menu items */ + title = [@"About " stringByAppendingString:appName]; + [appleMenu addItemWithTitle:title action:@selector(orderFrontStandardAboutPanel:) keyEquivalent:@""]; + + [appleMenu addItem:[NSMenuItem separatorItem]]; + + title = [@"Hide " stringByAppendingString:appName]; + [appleMenu addItemWithTitle:title action:@selector(hide:) keyEquivalent:@"h"]; + + menuItem = (NSMenuItem *)[appleMenu addItemWithTitle:@"Hide Others" action:@selector(hideOtherApplications:) keyEquivalent:@"h"]; + [menuItem setKeyEquivalentModifierMask:(NSAlternateKeyMask|NSCommandKeyMask)]; + + [appleMenu addItemWithTitle:@"Show All" action:@selector(unhideAllApplications:) keyEquivalent:@""]; + + [appleMenu addItem:[NSMenuItem separatorItem]]; + + title = [@"Quit " stringByAppendingString:appName]; + [appleMenu addItemWithTitle:title action:@selector(terminate:) keyEquivalent:@"q"]; + + + /* Put menu into the menubar */ + menuItem = [[NSMenuItem alloc] initWithTitle:@"" action:nil keyEquivalent:@""]; + [menuItem setSubmenu:appleMenu]; + [[NSApp mainMenu] addItem:menuItem]; + + /* Tell the application object that this is now the application menu */ + [NSApp setAppleMenu:appleMenu]; + + /* Finally give up our references to the objects */ + [appleMenu release]; + [menuItem release]; +} + +/* Create a window menu */ +static void setupWindowMenu(void) +{ + NSMenu *windowMenu; + NSMenuItem *windowMenuItem; + NSMenuItem *menuItem; + + windowMenu = [[NSMenu alloc] initWithTitle:@"Window"]; + + /* "Minimize" item */ + menuItem = [[NSMenuItem alloc] initWithTitle:@"Minimize" action:@selector(performMiniaturize:) keyEquivalent:@"m"]; + [windowMenu addItem:menuItem]; + [menuItem release]; + + /* Put menu into the menubar */ + windowMenuItem = [[NSMenuItem alloc] initWithTitle:@"Window" action:nil keyEquivalent:@""]; + [windowMenuItem setSubmenu:windowMenu]; + [[NSApp mainMenu] addItem:windowMenuItem]; + + /* Tell the application object that this is now the window menu */ + [NSApp setWindowsMenu:windowMenu]; + + /* Finally give up our references to the objects */ + [windowMenu release]; + [windowMenuItem release]; +} + +/* Replacement for NSApplicationMain */ +static void CustomApplicationMain (int argc, char **argv) +{ + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + SDLMain *sdlMain; + + /* Ensure the application object is initialised */ + [NSApplication sharedApplication]; + +#ifdef SDL_USE_CPS + { + CPSProcessSerNum PSN; + /* Tell the dock about us */ + if (!CPSGetCurrentProcess(&PSN)) + if (!CPSEnableForegroundOperation(&PSN,0x03,0x3C,0x2C,0x1103)) + if (!CPSSetFrontProcess(&PSN)) + [NSApplication sharedApplication]; + } +#endif /* SDL_USE_CPS */ + + /* Set up the menubar */ + [NSApp setMainMenu:[[NSMenu alloc] init]]; + setApplicationMenu(); + setupWindowMenu(); + + /* Create SDLMain and make it the app delegate */ + sdlMain = [[SDLMain alloc] init]; + [NSApp setDelegate:sdlMain]; + + /* Start the main event loop */ + [NSApp run]; + + [sdlMain release]; + [pool release]; +} + +#endif + + +/* + * Catch document open requests...this lets us notice files when the app + * was launched by double-clicking a document, or when a document was + * dragged/dropped on the app's icon. You need to have a + * CFBundleDocumentsType section in your Info.plist to get this message, + * apparently. + * + * Files are added to gArgv, so to the app, they'll look like command line + * arguments. Previously, apps launched from the finder had nothing but + * an argv[0]. + * + * This message may be received multiple times to open several docs on launch. + * + * This message is ignored once the app's mainline has been called. + */ +- (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filename +{ + const char *temparg; + size_t arglen; + char *arg; + char **newargv; + + if (!gFinderLaunch) /* MacOS is passing command line args. */ + return FALSE; + + if (gCalledAppMainline) /* app has started, ignore this document. */ + return FALSE; + + temparg = [filename UTF8String]; + arglen = SDL_strlen(temparg) + 1; + arg = (char *) SDL_malloc(arglen); + if (arg == NULL) + return FALSE; + + newargv = (char **) realloc(gArgv, sizeof (char *) * (gArgc + 2)); + if (newargv == NULL) + { + SDL_free(arg); + return FALSE; + } + gArgv = newargv; + + SDL_strlcpy(arg, temparg, arglen); + gArgv[gArgc++] = arg; + gArgv[gArgc] = NULL; + return TRUE; +} + + +/* Called when the internal event loop has just started running */ +- (void) applicationDidFinishLaunching: (NSNotification *) note +{ + int status; + + /* Set the working directory to the .app's parent directory */ + [self setupWorkingDirectory:gFinderLaunch]; + +#if SDL_USE_NIB_FILE + /* Set the main menu to contain the real app name instead of "SDL App" */ + [self fixMenu:[NSApp mainMenu] withAppName:getApplicationName()]; +#endif + + /* Hand off to main application code */ + gCalledAppMainline = TRUE; + status = SDL_main (gArgc, gArgv); + + /* We're done, thank you for playing */ + exit(status); +} +@end + + +@implementation NSString (ReplaceSubString) + +- (NSString *)stringByReplacingRange:(NSRange)aRange with:(NSString *)aString +{ + unsigned int bufferSize; + unsigned int selfLen = [self length]; + unsigned int aStringLen = [aString length]; + unichar *buffer; + NSRange localRange; + NSString *result; + + bufferSize = selfLen + aStringLen - aRange.length; + buffer = (unichar *)NSAllocateMemoryPages(bufferSize*sizeof(unichar)); + + /* Get first part into buffer */ + localRange.location = 0; + localRange.length = aRange.location; + [self getCharacters:buffer range:localRange]; + + /* Get middle part into buffer */ + localRange.location = 0; + localRange.length = aStringLen; + [aString getCharacters:(buffer+aRange.location) range:localRange]; + + /* Get last part into buffer */ + localRange.location = aRange.location + aRange.length; + localRange.length = selfLen - localRange.location; + [self getCharacters:(buffer+aRange.location+aStringLen) range:localRange]; + + /* Build output string */ + result = [NSString stringWithCharacters:buffer length:bufferSize]; + + NSDeallocateMemoryPages(buffer, bufferSize); + + return result; +} + +@end + + + +#ifdef main +# undef main +#endif + + +/* Main entry point to executable - should *not* be SDL_main! */ +int main (int argc, char **argv) +{ + /* Copy the arguments into a global variable */ + /* This is passed if we are launched by double-clicking */ + if ( argc >= 2 && strncmp (argv[1], "-psn", 4) == 0 ) { + gArgv = (char **) SDL_malloc(sizeof (char *) * 2); + gArgv[0] = argv[0]; + gArgv[1] = NULL; + gArgc = 1; + gFinderLaunch = YES; + } else { + int i; + gArgc = argc; + gArgv = (char **) SDL_malloc(sizeof (char *) * (argc+1)); + for (i = 0; i <= argc; i++) + gArgv[i] = argv[i]; + gFinderLaunch = NO; + } + +#if SDL_USE_NIB_FILE + NSApplicationMain (argc, argv); +#else + CustomApplicationMain (argc, argv); +#endif + return 0; +} + diff --git a/src/vdb.c b/src/vdb.c index 848497c..dc69000 100644 --- a/src/vdb.c +++ b/src/vdb.c @@ -19,7 +19,7 @@ extern int ScanDrawMode; */ -SCENE Global_Scene = 0; +SCENE Global_Scene/* = 0*/; @@ -386,37 +386,11 @@ static void CreateProjectorArray(VIEWDESCRIPTORBLOCK *vdb) SetVDB requires a VIEWDESCRIPTORBLOCK - See the actual function code for what each parameter is - */ -void SetVDB(vdb, fl, ty, d, cx,cy, prx,pry, mxp, cl,cr,cu,cd, h1,h2,hc, amb) - - VIEWDESCRIPTORBLOCK *vdb; - - int fl; - int ty; - - int d; - - int cx; - int cy; - - int prx; - int pry; - int mxp; - - int cl; - int cr; - int cu; - int cd; - - int h1; - int h2; - int hc; - - int amb; - +void SetVDB(VIEWDESCRIPTORBLOCK *vdb, int fl, int ty, int d, int cx, int cy, + int prx, int pry, int mxp, int cl, int cr, int cu, int cd, + int h1, int h2, int hc, int amb) { @@ -729,10 +703,7 @@ VIEWDESCRIPTORBLOCK* CreateActiveVDB(void) */ -int DestroyActiveVDB(dblockptr) - - VIEWDESCRIPTORBLOCK *dblockptr; - +int DestroyActiveVDB(VIEWDESCRIPTORBLOCK *dblockptr) { int j = -1; diff --git a/src/win95/animchnk.cpp b/src/win95/animchnk.cpp index f6802cb..adaecaa 100644 --- a/src/win95/animchnk.cpp +++ b/src/win95/animchnk.cpp @@ -218,7 +218,7 @@ FrameList::FrameList(TEXANIM* p,FrameList* fl,int* conv) FrameList::~FrameList() { delete [] Textures; - delete UVCoords; + delete [] UVCoords; } TEXANIM::TEXANIM() diff --git a/src/win95/animobs.cpp b/src/win95/animobs.cpp index 56539f5..f1c00ee 100644 --- a/src/win95/animobs.cpp +++ b/src/win95/animobs.cpp @@ -153,9 +153,9 @@ void Object_Animation_Sequence_Header_Chunk::fill_data_block (char *data_start) Object_Animation_Sequence_Header_Chunk::~Object_Animation_Sequence_Header_Chunk() { if (sequence_name) - delete sequence_name; + delete[] sequence_name; if(extra_data) - delete extra_data; + delete[] extra_data; } Object_Animation_Sequence_Header_Chunk::Object_Animation_Sequence_Header_Chunk (Chunk_With_Children * parent,const char * data_start, size_t) diff --git a/src/win95/animobs.hpp b/src/win95/animobs.hpp index 727df47..ee93efb 100644 --- a/src/win95/animobs.hpp +++ b/src/win95/animobs.hpp @@ -246,7 +246,9 @@ struct Object_Animation_Frame { ChunkQuat orientation; ChunkVectorInt transform; - signed long at_frame_no; //frame start time (0-65535) + + // SBF: 64HACK - changed long to int32_t as this structure isn't serialized correctly + int32_t at_frame_no; //frame start time (0-65535) int flags; int get_sound_index(){return ((flags & HierarchyFrame_SoundIndexMask )>>24);} diff --git a/src/win95/chnkload.cpp b/src/win95/chnkload.cpp index 1d450c2..99bc0a5 100644 --- a/src/win95/chnkload.cpp +++ b/src/win95/chnkload.cpp @@ -91,7 +91,7 @@ Shape_Fragment_Type::~Shape_Fragment_Type() #endif } - if(name) delete name; + if(name) delete[] name; } void Shape_Fragment_Type::AddShape(SHAPEHEADER* shp) @@ -2403,7 +2403,7 @@ BOOL copy_to_shapeheader ( uv_imnums[item_list[i*9+3]>>16]=local_tex_index_nos[texno]; item_list[i*9 + 3] += local_tex_index_nos[texno]; - shphd->sh_textures[UVIndex] = (int *) PoolAllocateMem (sizeof(int) * cshp_ptr->uv_list[UVIndex].num_verts * 2); + shphd->sh_textures[UVIndex] = (int *) PoolAllocateMem (sizeof(int *) * cshp_ptr->uv_list[UVIndex].num_verts * 2); for (j=0; juv_list[UVIndex].num_verts; j++) { (shphd->sh_textures[UVIndex])[(j*2)] = ProcessUVCoord(h,UVC_POLY_U,(int)cshp_ptr->uv_list[UVIndex].vert[j].u,uv_imnums[UVIndex]); (shphd->sh_textures[UVIndex])[(j*2)+1] = ProcessUVCoord(h,UVC_POLY_V,(int)cshp_ptr->uv_list[UVIndex].vert[j].v,uv_imnums[UVIndex]); @@ -3444,7 +3444,7 @@ BOOL copy_to_mainshpl (Shape_Chunk * shp, int list_pos) if (cshp.num_uvs) { for (i=0; ish_textures[i] = (int *) AllocateMem (sizeof(int) * cshp.uv_list[i].num_verts * 2); + shphd->sh_textures[i] = (int *) AllocateMem (sizeof(int *) * cshp.uv_list[i].num_verts * 2); for (j=0; jsh_textures[i])[(j*2)] = (int)cshp.uv_list[i].vert[j].u; (shphd->sh_textures[i])[(j*2)+1] = (int)cshp.uv_list[i].vert[j].v; @@ -3738,7 +3738,7 @@ BOOL copy_to_mainshpl (Shape_Sub_Shape_Chunk * shp, int list_pos) if (cshp.num_uvs) { for (i=0; ish_textures[i] = (int *) AllocateMem (sizeof(int) * cshp.uv_list[i].num_verts * 2); + shphd->sh_textures[i] = (int *) AllocateMem (sizeof(int *) * cshp.uv_list[i].num_verts * 2); for (j=0; jsh_textures[i])[(j*2)] = (int)cshp.uv_list[i].vert[j].u; (shphd->sh_textures[i])[(j*2)+1] = (int)cshp.uv_list[i].vert[j].v; @@ -3957,7 +3957,7 @@ BOOL copy_to_mainshpl (Shape_Sub_Shape_Chunk * shp, int list_pos) if (cshp.num_uvs) { for (i=0; ish_textures[i] = (int *) AllocateMem (sizeof(int) * cshp.uv_list[i].num_verts * 2); + shphd->sh_textures[i] = (int *) AllocateMem (sizeof(int *) * cshp.uv_list[i].num_verts * 2); for (j=0; jsh_textures[i])[(j*2)] = (int)cshp.uv_list[i].vert[j].u; (shphd->sh_textures[i])[(j*2)+1] = (int)cshp.uv_list[i].vert[j].v; diff --git a/src/win95/fragchnk.cpp b/src/win95/fragchnk.cpp index 1affcc7..50af938 100644 --- a/src/win95/fragchnk.cpp +++ b/src/win95/fragchnk.cpp @@ -56,7 +56,7 @@ Fragment_Type_Data_Chunk::Fragment_Type_Data_Chunk(Chunk_With_Children* const pa Fragment_Type_Data_Chunk::~Fragment_Type_Data_Chunk() { - if(frag_type_name) delete frag_type_name; + if(frag_type_name) delete [] frag_type_name; } void Fragment_Type_Data_Chunk::fill_data_block(char* data_start) @@ -124,7 +124,7 @@ Fragment_Type_Shape_Chunk::Fragment_Type_Shape_Chunk(Chunk_With_Children* const Fragment_Type_Shape_Chunk::~Fragment_Type_Shape_Chunk() { - if(name) delete name; + if(name) delete [] name; } void Fragment_Type_Shape_Chunk::fill_data_block(char* data_start) @@ -195,7 +195,7 @@ Fragment_Type_Sound_Chunk::Fragment_Type_Sound_Chunk(Chunk_With_Children* const Fragment_Type_Sound_Chunk::~Fragment_Type_Sound_Chunk() { - if(wav_name) delete wav_name; + if(wav_name) delete [] wav_name; } void Fragment_Type_Sound_Chunk::fill_data_block(char* data_start) diff --git a/src/win95/hash_tem.hpp b/src/win95/hash_tem.hpp index bc25f53..8edda53 100644 --- a/src/win95/hash_tem.hpp +++ b/src/win95/hash_tem.hpp @@ -242,7 +242,7 @@ inline unsigned HashFunction(void const * const _vP) { // treat as integer - return HashFunction(reinterpret_cast(_vP)); + return HashFunction(reinterpret_cast(_vP)); } // a hash function for strings diff --git a/src/win95/hierchnk.cpp b/src/win95/hierchnk.cpp index 56d4437..1ebe41e 100644 --- a/src/win95/hierchnk.cpp +++ b/src/win95/hierchnk.cpp @@ -323,7 +323,7 @@ Object_Hierarchy_Alternate_Shape_Set_Chunk::Object_Hierarchy_Alternate_Shape_Set Object_Hierarchy_Alternate_Shape_Set_Chunk::~Object_Hierarchy_Alternate_Shape_Set_Chunk() { - if(Shape_Set_Name) delete Shape_Set_Name; + if(Shape_Set_Name) delete[] Shape_Set_Name; while(Replaced_Shape_List.size()) { @@ -428,7 +428,7 @@ Hierarchy_Shape_Set_Collection_Chunk::Hierarchy_Shape_Set_Collection_Chunk(Chunk Hierarchy_Shape_Set_Collection_Chunk::~Hierarchy_Shape_Set_Collection_Chunk() { - if(Set_Collection_Name) delete Set_Collection_Name; + if(Set_Collection_Name) delete[] Set_Collection_Name; } void Hierarchy_Shape_Set_Collection_Chunk::fill_data_block(char* data_start) @@ -521,7 +521,7 @@ Hierarchy_Degradation_Distance_Chunk::Hierarchy_Degradation_Distance_Chunk(Chunk Hierarchy_Degradation_Distance_Chunk::~Hierarchy_Degradation_Distance_Chunk() { - if(distance_array)delete distance_array; + if(distance_array)delete[] distance_array; } void Hierarchy_Degradation_Distance_Chunk::fill_data_block(char* data_start) diff --git a/src/win95/hierchnk.hpp b/src/win95/hierchnk.hpp index 4772196..46dd333 100644 --- a/src/win95/hierchnk.hpp +++ b/src/win95/hierchnk.hpp @@ -101,8 +101,8 @@ struct Replaced_Shape_Details { ~Replaced_Shape_Details() { - if(old_object_name) delete old_object_name; - if(new_object_name) delete new_object_name; + if(old_object_name) delete[] old_object_name; + if(new_object_name) delete[] new_object_name; } //object name of shape to be replaced diff --git a/src/win95/mishchnk.cpp b/src/win95/mishchnk.cpp index a0e3795..c170364 100644 --- a/src/win95/mishchnk.cpp +++ b/src/win95/mishchnk.cpp @@ -639,7 +639,7 @@ void File_Chunk::post_input_processing() ol()->assoc_with_shape(shape_array[ol()->get_header()->shape_id_no]); } - delete shape_array; + delete [] shape_array; Chunk_With_Children::post_input_processing(); diff --git a/src/win95/obchunk.cpp b/src/win95/obchunk.cpp index b062570..2222370 100644 --- a/src/win95/obchunk.cpp +++ b/src/win95/obchunk.cpp @@ -1012,7 +1012,7 @@ Object_Track_Chunk2::Object_Track_Chunk2(Object_Chunk * parent) Object_Track_Chunk2::~Object_Track_Chunk2() { - if(sections) delete sections; + if(sections) delete [] sections; } void Object_Track_Chunk2::fill_data_block (char *data_start) @@ -1132,7 +1132,7 @@ Object_Track_Sound_Chunk::Object_Track_Sound_Chunk(Chunk_With_Children* const pa Object_Track_Sound_Chunk::~Object_Track_Sound_Chunk() { - if(wav_name) delete wav_name; + if(wav_name) delete [] wav_name; } void Object_Track_Sound_Chunk::fill_data_block(char* data_start) diff --git a/src/win95/shpchunk.cpp b/src/win95/shpchunk.cpp index 332ff39..779045b 100644 --- a/src/win95/shpchunk.cpp +++ b/src/win95/shpchunk.cpp @@ -1523,7 +1523,7 @@ Shape_Merge_Data_Chunk::Shape_Merge_Data_Chunk (Shape_Sub_Shape_Chunk * parent, Shape_Merge_Data_Chunk::~Shape_Merge_Data_Chunk() { - if (num_polys) delete merge_data; + if (num_polys) delete [] merge_data; } void Shape_Merge_Data_Chunk::fill_data_block(char * data_start) @@ -2575,7 +2575,7 @@ Shape_Fragment_Type_Chunk::Shape_Fragment_Type_Chunk(Chunk_With_Children* const Shape_Fragment_Type_Chunk::~Shape_Fragment_Type_Chunk() { - if(frag_type_name) delete frag_type_name; + if(frag_type_name) delete [] frag_type_name; } void Shape_Fragment_Type_Chunk::fill_data_block(char* data_start) @@ -3337,6 +3337,9 @@ void* Shape_Preprocessed_Data_Chunk::GetMemoryBlock() { void* retval=memory_block; +// 64HACK +#pragma message ("64HACK") +#if 0 unsigned int* current=(unsigned int*)&first_pointer; unsigned int* next; while((*current>>16)!=0xffff) @@ -3346,7 +3349,7 @@ void* Shape_Preprocessed_Data_Chunk::GetMemoryBlock() current=next; } *current=(unsigned int)&memory_block[(*current)&0xffff]; - +#endif memory_block=0; block_size=0; return retval; diff --git a/src/winfiles.c b/src/winfiles.c index 8cc87b6..798210d 100644 --- a/src/winfiles.c +++ b/src/winfiles.c @@ -678,7 +678,7 @@ static char* GetLocalDirectory(void) if( homepath != NULL ) { - homedir = (unsigned char*)malloc(strlen(homedrive)+strlen(homepath)+1); + homedir = (char*)malloc(strlen(homedrive)+strlen(homepath)+1); strcpy(homedir, homedrive); strcat(homedir, homepath); @@ -704,7 +704,7 @@ static char* GetLocalDirectory(void) homedir = _strdup("."); } - localdir = (unsigned char*)malloc(strlen(homedir) + 10); + localdir = (char*)malloc(strlen(homedir) + 10); strcpy(localdir, homedir); strcat(localdir, "\\AvPLinux"); // temp name, maybe @@ -762,11 +762,13 @@ static const char* GetGlobalDirectory(const char* argv0) /* Game-specific initialization */ +extern "C" { + extern char const *SecondTex_Directory; + extern char const *SecondSoundDir; +} + void InitGameDirectories(char *argv0) { - extern char *SecondTex_Directory; - extern char *SecondSoundDir; - const char* localdir; const char* globaldir;