Merge pull request #1 from flibitijibibo/master

Port Linux/macOS to 64-bit, using new CMake build system
This commit is contained in:
blendogames 2020-10-22 10:44:49 -07:00 committed by GitHub
commit d4fc21e641
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
117 changed files with 2835 additions and 3127 deletions

504
CMakeLists.txt Normal file
View file

@ -0,0 +1,504 @@
# CMake File for Quadrilateral Cowboy (Because scons and Xcode are butt)
# Written by Ethan "flibitijibibo" Lee
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.12)
PROJECT(QuadrilateralCowboy)
# CMake Options
OPTION(STEAM "Enable Steamworks" OFF)
# Compiler Flags
ADD_COMPILE_OPTIONS(
-pipe
-Wno-unknown-pragmas
-Wno-write-strings
-fmessage-length=0
-fpermissive
-fvisibility=hidden
-fno-strict-aliasing
)
ADD_DEFINITIONS(-D_D3XP -DCTF -DID_ENABLE_CURL=0 -DUSE_SDL -DXTHREADS)
IF(CMAKE_BUILD_TYPE STREQUAL "Debug")
ADD_DEFINITIONS(-D_DEBUG -DID_MCHECK)
ELSEIF(CMAKE_BUILD_TYPE STREQUAL "Release")
ADD_COMPILE_OPTIONS(
-Winline
-ffast-math
-fno-unsafe-math-optimizations
-fomit-frame-pointer
)
ENDIF()
IF(STEAM)
ADD_DEFINITIONS(-DSTEAM)
INCLUDE_DIRECTORIES(steam)
LINK_DIRECTORIES(steam)
ENDIF()
# RPATH
IF(APPLE)
SET(CMAKE_OSX_SYSROOT /Library/Developer/CommandLineTools/SDKs/MacOSX10.8.sdk)
SET(CMAKE_OSX_DEPLOYMENT_TARGET 10.8)
SET(BIN_LIBROOT "osx")
SET(BIN_RPATH "@executable_path/osx")
ADD_DEFINITIONS(-DMACOS_X) # WTF? -flibit
ELSE()
SET(BIN_LIBROOT "lib64")
SET(BIN_RPATH "\$ORIGIN/lib64")
ENDIF()
SET(CMAKE_SKIP_BUILD_RPATH TRUE)
SET(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
SET(CMAKE_INSTALL_RPATH ${BIN_RPATH})
SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH FALSE)
# Include Directories
INCLUDE_DIRECTORIES(. sound/OggVorbis/vorbissrc/)
# Source Lists
SET(QC_SRC
renderer/jpeg-6/jcapimin.c
renderer/jpeg-6/jccoefct.c
renderer/jpeg-6/jccolor.c
renderer/jpeg-6/jcdctmgr.c
renderer/jpeg-6/jchuff.c
renderer/jpeg-6/jcinit.c
renderer/jpeg-6/jcmainct.c
renderer/jpeg-6/jcmarker.c
renderer/jpeg-6/jcmaster.c
renderer/jpeg-6/jcomapi.c
renderer/jpeg-6/jcparam.c
renderer/jpeg-6/jcphuff.c
renderer/jpeg-6/jcprepct.c
renderer/jpeg-6/jcsample.c
renderer/jpeg-6/jdapimin.c
renderer/jpeg-6/jdapistd.c
renderer/jpeg-6/jdatadst.c
renderer/jpeg-6/jdatasrc.c
renderer/jpeg-6/jdcoefct.c
renderer/jpeg-6/jdcolor.c
renderer/jpeg-6/jddctmgr.c
renderer/jpeg-6/jdhuff.c
renderer/jpeg-6/jdinput.c
renderer/jpeg-6/jdmainct.c
renderer/jpeg-6/jdmarker.c
renderer/jpeg-6/jdmaster.c
renderer/jpeg-6/jdmerge.c
renderer/jpeg-6/jdphuff.c
renderer/jpeg-6/jdpostct.c
renderer/jpeg-6/jdsample.c
renderer/jpeg-6/jdtrans.c
renderer/jpeg-6/jerror.c
renderer/jpeg-6/jfdctflt.c
renderer/jpeg-6/jfdctfst.c
renderer/jpeg-6/jfdctint.c
renderer/jpeg-6/jidctflt.c
renderer/jpeg-6/jidctfst.c
renderer/jpeg-6/jidctint.c
renderer/jpeg-6/jidctred.c
renderer/jpeg-6/jmemmgr.c
renderer/jpeg-6/jmemnobs.c
renderer/jpeg-6/jquant1.c
renderer/jpeg-6/jquant2.c
renderer/jpeg-6/jutils.c
sound/OggVorbis/oggsrc/bitwise.c
sound/OggVorbis/oggsrc/framing.c
sound/OggVorbis/vorbissrc/analysis.c
sound/OggVorbis/vorbissrc/bitrate.c
sound/OggVorbis/vorbissrc/block.c
sound/OggVorbis/vorbissrc/codebook.c
sound/OggVorbis/vorbissrc/envelope.c
sound/OggVorbis/vorbissrc/floor0.c
sound/OggVorbis/vorbissrc/floor1.c
sound/OggVorbis/vorbissrc/info.c
sound/OggVorbis/vorbissrc/lookup.c
sound/OggVorbis/vorbissrc/lpc.c
sound/OggVorbis/vorbissrc/lsp.c
sound/OggVorbis/vorbissrc/mapping0.c
sound/OggVorbis/vorbissrc/mdct.c
sound/OggVorbis/vorbissrc/psy.c
sound/OggVorbis/vorbissrc/registry.c
sound/OggVorbis/vorbissrc/res0.c
sound/OggVorbis/vorbissrc/sharedbook.c
sound/OggVorbis/vorbissrc/smallft.c
sound/OggVorbis/vorbissrc/synthesis.c
sound/OggVorbis/vorbissrc/vorbisenc.c
sound/OggVorbis/vorbissrc/vorbisfile.c
sound/OggVorbis/vorbissrc/windowvb.c
renderer/Cinematic.cpp
renderer/GuiModel.cpp
renderer/Image_files.cpp
renderer/Image_init.cpp
renderer/Image_load.cpp
renderer/Image_process.cpp
renderer/Image_program.cpp
renderer/Interaction.cpp
renderer/Material.cpp
renderer/MegaTexture.cpp
renderer/Model.cpp
renderer/ModelDecal.cpp
renderer/ModelManager.cpp
renderer/ModelOverlay.cpp
renderer/Model_beam.cpp
renderer/Model_ase.cpp
renderer/Model_liquid.cpp
renderer/Model_lwo.cpp
renderer/Model_ma.cpp
renderer/Model_md3.cpp
renderer/Model_md5.cpp
renderer/Model_prt.cpp
renderer/Model_sprite.cpp
renderer/RenderEntity.cpp
renderer/RenderSystem.cpp
renderer/RenderSystem_init.cpp
renderer/RenderWorld.cpp
renderer/RenderWorld_demo.cpp
renderer/RenderWorld_load.cpp
renderer/RenderWorld_portals.cpp
renderer/VertexCache.cpp
renderer/cg_explicit.cpp
renderer/draw_arb.cpp
renderer/draw_arb2.cpp
renderer/draw_common.cpp
renderer/draw_exp_stub.cpp
renderer/draw_nv10.cpp
renderer/draw_nv20.cpp
renderer/draw_r200.cpp
renderer/tr_backend.cpp
renderer/tr_deform.cpp
renderer/tr_font.cpp
renderer/tr_guisurf.cpp
renderer/tr_light.cpp
renderer/tr_lightrun.cpp
renderer/tr_main.cpp
renderer/tr_orderIndexes.cpp
renderer/tr_polytope.cpp
renderer/tr_render.cpp
renderer/tr_rendertools.cpp
renderer/tr_shadowbounds.cpp
renderer/tr_stencilshadow.cpp
renderer/tr_subview.cpp
renderer/tr_trace.cpp
renderer/tr_trisurf.cpp
renderer/tr_turboshadow.cpp
framework/CVarSystem.cpp
framework/CmdSystem.cpp
framework/Common.cpp
framework/Compressor.cpp
framework/Console.cpp
framework/DemoFile.cpp
framework/DeclAF.cpp
framework/DeclEntityDef.cpp
framework/DeclFX.cpp
framework/DeclManager.cpp
framework/DeclParticle.cpp
framework/DeclPDA.cpp
framework/DeclSkin.cpp
framework/DeclTable.cpp
framework/EditField.cpp
framework/EventLoop.cpp
framework/File.cpp
framework/FileSystem.cpp
framework/KeyInput.cpp
framework/Unzip.cpp
framework/UsercmdGen.cpp
framework/Session_menu.cpp
framework/Session.cpp
framework/async/AsyncClient.cpp
framework/async/AsyncNetwork.cpp
framework/async/AsyncServer.cpp
framework/async/MsgChannel.cpp
framework/async/NetworkSystem.cpp
framework/async/ServerScan.cpp
cm/CollisionModel_contacts.cpp
cm/CollisionModel_contents.cpp
cm/CollisionModel_debug.cpp
cm/CollisionModel_files.cpp
cm/CollisionModel_load.cpp
cm/CollisionModel_rotate.cpp
cm/CollisionModel_trace.cpp
cm/CollisionModel_translate.cpp
tools/compilers/dmap/dmap.cpp
tools/compilers/dmap/facebsp.cpp
tools/compilers/dmap/gldraw.cpp
tools/compilers/dmap/glfile.cpp
tools/compilers/dmap/leakfile.cpp
tools/compilers/dmap/map.cpp
tools/compilers/dmap/optimize.cpp
tools/compilers/dmap/output.cpp
tools/compilers/dmap/portals.cpp
tools/compilers/dmap/shadowopt3.cpp
tools/compilers/dmap/tritjunction.cpp
tools/compilers/dmap/tritools.cpp
tools/compilers/dmap/ubrush.cpp
tools/compilers/dmap/usurface.cpp
tools/compilers/dmap/optimize_gcc.cpp
tools/compilers/aas/AASBuild.cpp
tools/compilers/aas/AASBuild_file.cpp
tools/compilers/aas/AASBuild_gravity.cpp
tools/compilers/aas/AASBuild_ledge.cpp
tools/compilers/aas/AASBuild_merge.cpp
tools/compilers/aas/AASCluster.cpp
tools/compilers/aas/AASFile.cpp
tools/compilers/aas/AASFile_optimize.cpp
tools/compilers/aas/AASFile_sample.cpp
tools/compilers/aas/AASReach.cpp
tools/compilers/aas/AASFileManager.cpp
tools/compilers/aas/Brush.cpp
tools/compilers/aas/BrushBSP.cpp
tools/compilers/roqvq/NSBitmapImageRep.cpp
tools/compilers/roqvq/codec.cpp
tools/compilers/roqvq/roq.cpp
tools/compilers/roqvq/roqParam.cpp
tools/compilers/renderbump/renderbump.cpp
sound/snd_cache.cpp
sound/snd_decoder.cpp
sound/snd_efxfile.cpp
sound/snd_emitter.cpp
sound/snd_shader.cpp
sound/snd_system.cpp
sound/snd_wavefile.cpp
sound/snd_world.cpp
ui/BindWindow.cpp
ui/ChoiceWindow.cpp
ui/DeviceContext.cpp
ui/EditWindow.cpp
ui/FieldWindow.cpp
ui/GameBearShootWindow.cpp
ui/GameBustOutWindow.cpp
ui/GameSSDWindow.cpp
ui/gamelaserduckwindow.cpp
ui/GuiScript.cpp
ui/ListGUI.cpp
ui/ListWindow.cpp
ui/MarkerWindow.cpp
ui/RegExp.cpp
ui/RenderWindow.cpp
ui/SimpleWindow.cpp
ui/SliderWindow.cpp
ui/UserInterface.cpp
ui/Window.cpp
ui/Winvar.cpp
idlib/bv/Bounds.cpp
idlib/bv/Frustum.cpp
idlib/bv/Sphere.cpp
idlib/bv/Box.cpp
idlib/geometry/DrawVert.cpp
idlib/geometry/Winding2D.cpp
idlib/geometry/Surface_SweptSpline.cpp
idlib/geometry/Winding.cpp
idlib/geometry/Surface.cpp
idlib/geometry/Surface_Patch.cpp
idlib/geometry/TraceModel.cpp
idlib/geometry/JointTransform.cpp
idlib/hashing/CRC32.cpp
idlib/hashing/MD4.cpp
idlib/hashing/MD5.cpp
idlib/math/Angles.cpp
idlib/math/Lcp.cpp
idlib/math/idMath.cpp
idlib/math/Matrix.cpp
idlib/math/Ode.cpp
idlib/math/Plane.cpp
idlib/math/Pluecker.cpp
idlib/math/Polynomial.cpp
idlib/math/Quat.cpp
idlib/math/Rotation.cpp
idlib/math/Simd.cpp
idlib/math/Simd_Generic.cpp
idlib/math/Vector.cpp
idlib/BitMsg.cpp
idlib/LangDict.cpp
idlib/Lexer.cpp
idlib/Lib.cpp
idlib/containers/HashIndex.cpp
idlib/Dict.cpp
idlib/Str.cpp
idlib/Parser.cpp
idlib/MapFile.cpp
idlib/CmdArgs.cpp
idlib/Token.cpp
idlib/Base64.cpp
idlib/Timer.cpp
idlib/Heap.cpp
d3xp/AF.cpp
d3xp/AFEntity.cpp
d3xp/Actor.cpp
d3xp/Camera.cpp
d3xp/Entity.cpp
d3xp/BrittleFracture.cpp
d3xp/Fx.cpp
d3xp/GameEdit.cpp
d3xp/Game_local.cpp
d3xp/Game_network.cpp
d3xp/Item.cpp
d3xp/IK.cpp
d3xp/Light.cpp
d3xp/Misc.cpp
d3xp/Mover.cpp
d3xp/Moveable.cpp
d3xp/MultiplayerGame.cpp
d3xp/Player.cpp
d3xp/PlayerIcon.cpp
d3xp/PlayerView.cpp
d3xp/Projectile.cpp
d3xp/Pvs.cpp
d3xp/SecurityCamera.cpp
d3xp/SmokeParticles.cpp
d3xp/Sound.cpp
d3xp/Target.cpp
d3xp/Trigger.cpp
d3xp/Weapon.cpp
d3xp/WorldSpawn.cpp
d3xp/ai/AAS.cpp
d3xp/ai/AAS_debug.cpp
d3xp/ai/AAS_pathing.cpp
d3xp/ai/AAS_routing.cpp
d3xp/ai/AI.cpp
d3xp/ai/AI_events.cpp
d3xp/ai/AI_pathing.cpp
d3xp/ai/AI_Vagary.cpp
d3xp/gamesys/DebugGraph.cpp
d3xp/gamesys/Class.cpp
d3xp/gamesys/Event.cpp
d3xp/gamesys/SaveGame.cpp
d3xp/gamesys/SysCmds.cpp
d3xp/gamesys/SysCvar.cpp
d3xp/gamesys/TypeInfo.cpp
d3xp/anim/Anim.cpp
d3xp/anim/Anim_Blend.cpp
d3xp/anim/Anim_Import.cpp
d3xp/anim/Anim_Testmodel.cpp
d3xp/script/Script_Compiler.cpp
d3xp/script/Script_Interpreter.cpp
d3xp/script/Script_Program.cpp
d3xp/script/Script_Thread.cpp
d3xp/physics/Clip.cpp
d3xp/physics/Force.cpp
d3xp/physics/Force_Constant.cpp
d3xp/physics/Force_Drag.cpp
d3xp/physics/Force_Field.cpp
d3xp/physics/Force_Spring.cpp
d3xp/physics/Physics.cpp
d3xp/physics/Physics_AF.cpp
d3xp/physics/Physics_Actor.cpp
d3xp/physics/Physics_Base.cpp
d3xp/physics/Physics_Monster.cpp
d3xp/physics/Physics_Parametric.cpp
d3xp/physics/Physics_Player.cpp
d3xp/physics/Physics_RigidBody.cpp
d3xp/physics/Physics_Static.cpp
d3xp/physics/Physics_StaticMulti.cpp
d3xp/physics/Push.cpp
d3xp/Grabber.cpp
d3xp/physics/Force_Grab.cpp
d3xp/laserwire.cpp
d3xp/panel.cpp
d3xp/picker.cpp
d3xp/turret.cpp
d3xp/rotdoor.cpp
d3xp/sentry.cpp
d3xp/lever.cpp
d3xp/steamstats.cpp
d3xp/itemgate.cpp
d3xp/worldmanager.cpp
d3xp/powerscrewgeneric.cpp
d3xp/camturret.cpp
d3xp/zeppelinbig.cpp
d3xp/keypad.cpp
d3xp/screw.cpp
d3xp/airlock.cpp
d3xp/powersawgeneric.cpp
d3xp/frobcube.cpp
d3xp/weevil.cpp
d3xp/clock.cpp
d3xp/contractcamera.cpp
d3xp/steamleaderboard.cpp
d3xp/steamremote.cpp
d3xp/qglass.cpp
d3xp/trembler.cpp
d3xp/button_switcher.cpp
d3xp/commentary.cpp
d3xp/cybervendor.cpp
d3xp/launcher.cpp
d3xp/bluebox.cpp
d3xp/camerapoint.cpp
d3xp/jellypoint.cpp
d3xp/worldman_moveable.cpp
d3xp/doorfolding.cpp
d3xp/countdowntimer.cpp
d3xp/animloop.cpp
d3xp/tablefold.cpp
TypeInfo/TypeInfoGen.cpp
sys/glimp.cpp
sys/events.cpp
sys/sys_local.cpp
sys/stub/util_stub.cpp
sys/posix/posix_net.cpp
sys/posix/posix_main.cpp
sys/posix/posix_input.cpp
sys/posix/posix_signal.cpp
sys/posix/posix_threads.cpp
sys/linux/stack.cpp
)
IF(APPLE)
SET(QC_SRC
${QC_SRC}
sys/osx/DOOMController.mm
sys/osx/macosx_event.mm
sys/osx/macosx_glimp.mm
sys/osx/macosx_guids.cpp
sys/osx/macosx_misc.mm
sys/osx/macosx_sound.cpp
sys/osx/PickMonitor.cpp
sys/osx/PreferencesDialog.cpp
)
ELSE()
SET(QC_SRC
${QC_SRC}
idlib/bv/Frustum_gcc.cpp
sys/linux/sound_oal.cpp
sys/linux/input.cpp
sys/linux/glimp.cpp
sys/linux/glimp_dlopen.cpp
sys/linux/main.cpp
)
ENDIF()
# Executable information
ADD_EXECUTABLE(qc ${QC_SRC})
# SDL2 Dependency (Detection pulled from FAudio)
if (DEFINED SDL2_INCLUDE_DIRS AND DEFINED SDL2_LIBRARIES)
message(STATUS "using pre-defined SDL2 variables SDL2_INCLUDE_DIRS and SDL2_LIBRARIES")
target_include_directories(qc PUBLIC "$<BUILD_INTERFACE:${SDL2_INCLUDE_DIRS}>")
target_link_libraries(qc PUBLIC ${SDL2_LIBRARIES})
else()
# Only try to autodetect if both SDL2 variables aren't explicitly set
find_package(SDL2 CONFIG)
if (TARGET SDL2::SDL2)
message(STATUS "using TARGET SDL2::SDL2")
target_link_libraries(qc PUBLIC SDL2::SDL2)
elseif (TARGET SDL2)
message(STATUS "using TARGET SDL2")
target_link_libraries(qc PUBLIC SDL2)
else()
message(STATUS "no TARGET SDL2::SDL2, or SDL2, using variables")
target_include_directories(qc PUBLIC "$<BUILD_INTERFACE:${SDL2_INCLUDE_DIRS}>")
target_link_libraries(qc PUBLIC ${SDL2_LIBRARIES})
endif()
endif()
# Other Dependencies
IF(APPLE)
FIND_LIBRARY(OPENGL NAMES OpenGL)
FIND_LIBRARY(OPENAL NAMES OpenAL)
FIND_LIBRARY(COCOA NAMES Cocoa)
FIND_LIBRARY(IOKIT NAMES IOKit)
FIND_LIBRARY(COREAUDIO NAMES CoreAudio)
TARGET_LINK_LIBRARIES(qc PUBLIC objc ${OPENGL} ${OPENAL} ${COCOA} ${IOKIT} ${COREAUDIO})
ELSE()
TARGET_LINK_LIBRARIES(qc PUBLIC openal)
ENDIF()
TARGET_LINK_LIBRARIES(qc PUBLIC dl pthread)
IF(STEAM)
TARGET_LINK_LIBRARIES(qc PUBLIC steam_api)
ENDIF()

View file

@ -152,7 +152,7 @@ EnsureSConsVersion( 0, 96 )
cpu = commands.getoutput('uname -m') cpu = commands.getoutput('uname -m')
exp = re.compile('.*i?86.*') exp = re.compile('.*i?86.*')
if exp.match(cpu): if exp.match(cpu):
cpu = 'x86' cpu = 'x86_64'
else: else:
cpu = commands.getoutput('uname -p') cpu = commands.getoutput('uname -p')
if ( cpu == 'powerpc' ): if ( cpu == 'powerpc' ):
@ -290,8 +290,9 @@ OPTCPPFLAGS = [ ]
BASECPPFLAGS.append( BASEFLAGS ) BASECPPFLAGS.append( BASEFLAGS )
BASECPPFLAGS.append( '-pipe' ) BASECPPFLAGS.append( '-pipe' )
# warn all # warn all
BASECPPFLAGS.append( '-Wall' ) # flibit removed: BASECPPFLAGS.append( '-Wall' )
BASECPPFLAGS.append( '-Wno-unknown-pragmas' ) BASECPPFLAGS.append( '-Wno-unknown-pragmas' )
BASECPPFLAGS.append( '-Wno-write-strings' )
# this define is necessary to make sure threading support is enabled in X # this define is necessary to make sure threading support is enabled in X
CORECPPFLAGS.append( '-DXTHREADS' ) CORECPPFLAGS.append( '-DXTHREADS' )
# don't wrap gcc messages # don't wrap gcc messages
@ -303,10 +304,11 @@ if ( g_os == 'Linux' ):
# gcc 4.x option only - only export what we mean to from the game SO # gcc 4.x option only - only export what we mean to from the game SO
BASECPPFLAGS.append( '-fvisibility=hidden' ) BASECPPFLAGS.append( '-fvisibility=hidden' )
# get the 64 bits machine on the distcc array to produce 32 bit binaries :) # get the 64 bits machine on the distcc array to produce 32 bit binaries :)
BASECPPFLAGS.append( '-m32' ) # BASECPPFLAGS.append( '-m32' )
BASELINKFLAGS.append( '-m32' ) # BASELINKFLAGS.append( '-m32' )
#rpath #rpath
BASELINKFLAGS.append( '-Wl,-rpath=\$$ORIGIN/lib' ) #BASELINKFLAGS.append( '-Wl,-rpath=\$$ORIGIN/lib' )
BASELINKFLAGS.append( '-Wl,-rpath=\$$ORIGIN/lib64' )
if ( g_sdk or SDK != '0' ): if ( g_sdk or SDK != '0' ):
BASECPPFLAGS.append( '-D_D3SDK' ) BASECPPFLAGS.append( '-D_D3SDK' )
@ -322,10 +324,11 @@ elif ( BUILD == 'debug' ):
elif ( BUILD == 'release' ): elif ( BUILD == 'release' ):
# -fomit-frame-pointer: "-O also turns on -fomit-frame-pointer on machines where doing so does not interfere with debugging." # -fomit-frame-pointer: "-O also turns on -fomit-frame-pointer on machines where doing so does not interfere with debugging."
# on x86 have to set it explicitely # on x86 have to set it explicitely
# -march=pentium3: flibit removed this, wtf 2004
# -finline-functions: implicit at -O3 # -finline-functions: implicit at -O3
# -fschedule-insns2: implicit at -O2 # -fschedule-insns2: implicit at -O2
# no-unsafe-math-optimizations: that should be on by default really. hit some wonko bugs in physics code because of that # no-unsafe-math-optimizations: that should be on by default really. hit some wonko bugs in physics code because of that
OPTCPPFLAGS = [ '-O3', '-march=pentium3', '-Winline', '-ffast-math', '-fno-unsafe-math-optimizations', '-fomit-frame-pointer' ] OPTCPPFLAGS = [ '-O3', '-Winline', '-ffast-math', '-fno-unsafe-math-optimizations', '-fomit-frame-pointer' ]
if ( ID_MCHECK == '0' ): if ( ID_MCHECK == '0' ):
ID_MCHECK = '2' ID_MCHECK = '2'
else: else:

View file

@ -586,7 +586,7 @@ bool idCollisionModelManagerLocal::LoadCollisionModelFile( const char *name, uns
return false; return false;
} }
crc = token.GetUnsignedLongValue(); crc = token.GetUnsignedIntValue();
if ( mapFileCRC && crc != mapFileCRC ) { if ( mapFileCRC && crc != mapFileCRC ) {
common->Printf( "%s is out of date\n", fileName.c_str() ); common->Printf( "%s is out of date\n", fileName.c_str() );
delete src; delete src;

View file

@ -78,23 +78,27 @@ Collision model
=============================================================================== ===============================================================================
*/ */
// flibit: 64 bit fix, changed long to int
typedef struct cm_vertex_s { typedef struct cm_vertex_s {
idVec3 p; // vertex point idVec3 p; // vertex point
int checkcount; // for multi-check avoidance int checkcount; // for multi-check avoidance
unsigned long side; // each bit tells at which side this vertex passes one of the trace model edges unsigned int side; // each bit tells at which side this vertex passes one of the trace model edges
unsigned long sideSet; // each bit tells if sidedness for the trace model edge has been calculated yet unsigned int sideSet; // each bit tells if sidedness for the trace model edge has been calculated yet
} cm_vertex_t; } cm_vertex_t;
typedef struct cm_edge_s { typedef struct cm_edge_s {
int checkcount; // for multi-check avoidance int checkcount; // for multi-check avoidance
unsigned short internal; // a trace model can never collide with internal edges unsigned short internal; // a trace model can never collide with internal edges
unsigned short numUsers; // number of polygons using this edge unsigned short numUsers; // number of polygons using this edge
unsigned long side; // each bit tells at which side of this edge one of the trace model vertices passes unsigned int side; // each bit tells at which side of this edge one of the trace model vertices passes
unsigned long sideSet; // each bit tells if sidedness for the trace model vertex has been calculated yet unsigned int sideSet; // each bit tells if sidedness for the trace model vertex has been calculated yet
int vertexNum[2]; // start and end point of edge int vertexNum[2]; // start and end point of edge
idVec3 normal; // edge normal idVec3 normal; // edge normal
} cm_edge_t; } cm_edge_t;
// flibit end
typedef struct cm_polygonBlock_s { typedef struct cm_polygonBlock_s {
int bytesRemaining; int bytesRemaining;
byte * next; byte * next;

View file

@ -458,7 +458,9 @@ idActor::idActor( void ) {
waitState = ""; waitState = "";
blink_anim = NULL; // flibit: 64 bit fix, change NULL to 0
blink_anim = 0;
// flibit end
blink_time = 0; blink_time = 0;
blink_min = 0; blink_min = 0;
blink_max = 0; blink_max = 0;
@ -3171,11 +3173,13 @@ idActor::Event_HasAnim
================ ================
*/ */
void idActor::Event_HasAnim( int channel, const char *animname ) { void idActor::Event_HasAnim( int channel, const char *animname ) {
if ( GetAnim( channel, animname ) != NULL ) { // flibit: 64 bit fix, change NULL to 0
if ( GetAnim( channel, animname ) != 0 ) {
idThread::ReturnFloat( 1.0f ); idThread::ReturnFloat( 1.0f );
} else { } else {
idThread::ReturnFloat( 0.0f ); idThread::ReturnFloat( 0.0f );
} }
// flibit end
} }
/* /*

View file

@ -276,7 +276,9 @@ void idGrabber::StartDrag( idEntity *grabEnt, int id ) {
aiEnt->StartRagdoll(); aiEnt->StartRagdoll();
} }
} else if ( grabEnt->IsType( idMoveableItem::Type ) ) { } else if ( grabEnt->IsType( idMoveableItem::Type ) ) {
grabEnt->PostEventMS( &EV_Touch, 250, thePlayer, NULL ); // RB: 64 bit fixes, changed NULL to 0
grabEnt->PostEventMS( &EV_Touch, 250, thePlayer, 0 );
// RB end
} }
// Get the current physics object to manipulate // Get the current physics object to manipulate

View file

@ -305,7 +305,10 @@ void idItem::Spawn( void ) {
if ( !ent ) { if ( !ent ) {
gameLocal.Error( "Item couldn't find owner '%s'", giveTo.c_str() ); gameLocal.Error( "Item couldn't find owner '%s'", giveTo.c_str() );
} }
PostEventMS( &EV_Touch, 0, ent, NULL );
// RB: 64 bit fixes, changed NULL to 0
PostEventMS( &EV_Touch, 0, ent, 0 );
// RB end
} }
spin = false; spin = false;

View file

@ -4725,7 +4725,7 @@ idPlayer::GiveVideo
*/ */
void idPlayer::GiveVideo( const char *videoName, idDict *item ) { void idPlayer::GiveVideo( const char *videoName, idDict *item ) {
if ( videoName == NULL || *videoName == NULL ) { if ( videoName == NULL || *videoName == '\0' ) {
return; return;
} }
@ -4762,7 +4762,7 @@ idPlayer::GiveEmail
*/ */
void idPlayer::GiveEmail( const char *emailName ) { void idPlayer::GiveEmail( const char *emailName ) {
if ( emailName == NULL || *emailName == NULL ) { if ( emailName == NULL || *emailName == '\0' ) {
return; return;
} }
@ -4789,7 +4789,7 @@ void idPlayer::GivePDA( const char *pdaName, idDict *item )
inventory.pdaSecurity.AddUnique( item->GetString( "inv_name" ) ); inventory.pdaSecurity.AddUnique( item->GetString( "inv_name" ) );
} }
if ( pdaName == NULL || *pdaName == NULL ) { if ( pdaName == NULL || *pdaName == '\0' ) {
pdaName = "personal"; pdaName = "personal";
} }
@ -7993,7 +7993,7 @@ void idPlayer::UpdatePDAInfo( bool updatePDASel ) {
const char *security = pda->GetSecurity(); const char *security = pda->GetSecurity();
if ( j == currentPDA || (currentPDA == 0 && security && *security ) ) { if ( j == currentPDA || (currentPDA == 0 && security && *security ) ) {
if ( *security == NULL ) { if ( *security == '\0' ) {
security = common->GetLanguageDict()->GetString( "#str_00066" ); security = common->GetLanguageDict()->GetString( "#str_00066" );
} }
objectiveSystem->SetStateString( "PDASecurityClearance", security ); objectiveSystem->SetStateString( "PDASecurityClearance", security );
@ -8610,7 +8610,7 @@ void idPlayer::PerformImpulse( int impulse ) {
case IMPULSE_17: { case IMPULSE_17: {
#ifdef STEAM && DEBUG #if defined(STEAM) && defined(DEBUG)
//g_SteamRemote->DeleteAll(); //g_SteamRemote->DeleteAll();
g_SteamStats->ResetStats(); g_SteamStats->ResetStats();

View file

@ -329,7 +329,9 @@ pvsStack_t *idPVS::FloodPassagePVS_r( pvsPortal_t *source, const pvsPortal_t *po
pvsArea_t *area; pvsArea_t *area;
pvsStack_t *stack; pvsStack_t *stack;
pvsPassage_t *passage; pvsPassage_t *passage;
long *sourceVis, *passageVis, *portalVis, *mightSee, *prevMightSee, more; // RB: 64 bit fixes, changed long to int
int *sourceVis, *passageVis, *portalVis, *mightSee, *prevMightSee, more;
// RB end
area = &pvsAreas[portal->areaNum]; area = &pvsAreas[portal->areaNum];
@ -364,15 +366,20 @@ pvsStack_t *idPVS::FloodPassagePVS_r( pvsPortal_t *source, const pvsPortal_t *po
source->vis[n >> 3] |= (1 << (n & 7)); source->vis[n >> 3] |= (1 << (n & 7));
// get pointers to vis data // get pointers to vis data
prevMightSee = reinterpret_cast<long *>(prevStack->mightSee);
passageVis = reinterpret_cast<long *>(passage->canSee); // RB: 64 bit fixes, changed long to int
sourceVis = reinterpret_cast<long *>(source->vis); prevMightSee = reinterpret_cast<int *>(prevStack->mightSee);
mightSee = reinterpret_cast<long *>(stack->mightSee); passageVis = reinterpret_cast<int *>(passage->canSee);
sourceVis = reinterpret_cast<int *>(source->vis);
mightSee = reinterpret_cast<int *>(stack->mightSee);
// RB end
more = 0; more = 0;
// use the portal PVS if it has been calculated // use the portal PVS if it has been calculated
if ( p->done ) { if ( p->done ) {
portalVis = reinterpret_cast<long *>(p->vis); // RB: 64 bit fixes, changed long to int
portalVis = reinterpret_cast<int *>(p->vis);
// RB end
for ( j = 0; j < portalVisLongs; j++ ) { for ( j = 0; j < portalVisLongs; j++ ) {
// get new PVS which is decreased by going through this passage // get new PVS which is decreased by going through this passage
m = *prevMightSee++ & *passageVis++ & *portalVis++; m = *prevMightSee++ & *passageVis++ & *portalVis++;
@ -730,7 +737,9 @@ idPVS::AreaPVSFromPortalPVS
*/ */
int idPVS::AreaPVSFromPortalPVS( void ) const { int idPVS::AreaPVSFromPortalPVS( void ) const {
int i, j, k, areaNum, totalVisibleAreas; int i, j, k, areaNum, totalVisibleAreas;
long *p1, *p2; // RB: 64 bit fixes, changed long to int
int *p1, *p2;
// RB end
byte *pvs, *portalPVS; byte *pvs, *portalPVS;
pvsArea_t *area; pvsArea_t *area;
@ -755,8 +764,10 @@ int idPVS::AreaPVSFromPortalPVS( void ) const {
// store the PVS of all portals in this area at the first portal // store the PVS of all portals in this area at the first portal
for ( j = 1; j < area->numPortals; j++ ) { for ( j = 1; j < area->numPortals; j++ ) {
p1 = reinterpret_cast<long *>(area->portals[0]->vis); // RB: 64 bit fixes, changed long to int
p2 = reinterpret_cast<long *>(area->portals[j]->vis); p1 = reinterpret_cast<int *>(area->portals[0]->vis);
p2 = reinterpret_cast<int *>(area->portals[j]->vis);
// RB end
for ( k = 0; k < portalVisLongs; k++ ) { for ( k = 0; k < portalVisLongs; k++ ) {
*p1++ |= *p2++; *p1++ |= *p2++;
} }
@ -807,7 +818,9 @@ void idPVS::Init( void ) {
areaQueue = new int[numAreas]; areaQueue = new int[numAreas];
areaVisBytes = ( ((numAreas+31)&~31) >> 3); areaVisBytes = ( ((numAreas+31)&~31) >> 3);
areaVisLongs = areaVisBytes/sizeof(long); // RB: 64 bit fixes, changed long to int
areaVisLongs = areaVisBytes/sizeof(int);
// RB end
areaPVS = new byte[numAreas * areaVisBytes]; areaPVS = new byte[numAreas * areaVisBytes];
memset( areaPVS, 0xFF, numAreas * areaVisBytes ); memset( areaPVS, 0xFF, numAreas * areaVisBytes );
@ -815,7 +828,9 @@ void idPVS::Init( void ) {
numPortals = GetPortalCount(); numPortals = GetPortalCount();
portalVisBytes = ( ((numPortals+31)&~31) >> 3); portalVisBytes = ( ((numPortals+31)&~31) >> 3);
portalVisLongs = portalVisBytes/sizeof(long); // RB: 64 bit fixes, changed long to int
portalVisLongs = portalVisBytes/sizeof(int);
// RB end
for ( int i = 0; i < MAX_CURRENT_PVS; i++ ) { for ( int i = 0; i < MAX_CURRENT_PVS; i++ ) {
currentPVS[i].handle.i = -1; currentPVS[i].handle.i = -1;
@ -1013,7 +1028,9 @@ idPVS::SetupCurrentPVS
pvsHandle_t idPVS::SetupCurrentPVS( const int *sourceAreas, const int numSourceAreas, const pvsType_t type ) const { pvsHandle_t idPVS::SetupCurrentPVS( const int *sourceAreas, const int numSourceAreas, const pvsType_t type ) const {
int i, j; int i, j;
unsigned int h; unsigned int h;
long *vis, *pvs; // RB: 64 bit fixes, changed long to int
int *vis, *pvs;
// RB end
pvsHandle_t handle; pvsHandle_t handle;
h = 0; h = 0;
@ -1034,8 +1051,10 @@ pvsHandle_t idPVS::SetupCurrentPVS( const int *sourceAreas, const int numSourceA
assert( sourceAreas[i] >= 0 && sourceAreas[i] < numAreas ); assert( sourceAreas[i] >= 0 && sourceAreas[i] < numAreas );
vis = reinterpret_cast<long*>(areaPVS + sourceAreas[i] * areaVisBytes); // RB: 64 bit fixes, changed long to int
pvs = reinterpret_cast<long*>(currentPVS[handle.i].pvs); vis = reinterpret_cast<int*>(areaPVS + sourceAreas[i] * areaVisBytes);
pvs = reinterpret_cast<int*>(currentPVS[handle.i].pvs);
// RB end
for ( j = 0; j < areaVisLongs; j++ ) { for ( j = 0; j < areaVisLongs; j++ ) {
*pvs++ |= *vis++; *pvs++ |= *vis++;
} }
@ -1074,7 +1093,9 @@ idPVS::MergeCurrentPVS
*/ */
pvsHandle_t idPVS::MergeCurrentPVS( pvsHandle_t pvs1, pvsHandle_t pvs2 ) const { pvsHandle_t idPVS::MergeCurrentPVS( pvsHandle_t pvs1, pvsHandle_t pvs2 ) const {
int i; int i;
long *pvs1Ptr, *pvs2Ptr, *ptr; // RB: 64 bit fixes, changed long to int
int *pvs1Ptr, *pvs2Ptr, *ptr;
// RB end
pvsHandle_t handle; pvsHandle_t handle;
if ( pvs1.i < 0 || pvs1.i >= MAX_CURRENT_PVS || pvs1.h != currentPVS[pvs1.i].handle.h || if ( pvs1.i < 0 || pvs1.i >= MAX_CURRENT_PVS || pvs1.h != currentPVS[pvs1.i].handle.h ||
@ -1084,9 +1105,11 @@ pvsHandle_t idPVS::MergeCurrentPVS( pvsHandle_t pvs1, pvsHandle_t pvs2 ) const {
handle = AllocCurrentPVS( pvs1.h ^ pvs2.h ); handle = AllocCurrentPVS( pvs1.h ^ pvs2.h );
ptr = reinterpret_cast<long*>(currentPVS[handle.i].pvs); // RB: 64 bit fixes, changed long to int
pvs1Ptr = reinterpret_cast<long*>(currentPVS[pvs1.i].pvs); ptr = reinterpret_cast<int*>(currentPVS[handle.i].pvs);
pvs2Ptr = reinterpret_cast<long*>(currentPVS[pvs2.i].pvs); pvs1Ptr = reinterpret_cast<int*>(currentPVS[pvs1.i].pvs);
pvs2Ptr = reinterpret_cast<int*>(currentPVS[pvs2.i].pvs);
// RB end
for ( i = 0; i < areaVisLongs; i++ ) { for ( i = 0; i < areaVisLongs; i++ ) {
*ptr++ = *pvs1Ptr++ | *pvs2Ptr++; *ptr++ = *pvs1Ptr++ | *pvs2Ptr++;

View file

@ -1676,12 +1676,14 @@ void idTrigger_Flag::Event_Touch( idEntity *other, trace_t *trace ) {
case 0 : case 0 :
flag->PostEventMS( eventFlag, 0 ); flag->PostEventMS( eventFlag, 0 );
break; break;
// RB: 64 bit fixes, changed NULL to 0
case 1 : case 1 :
flag->PostEventMS( eventFlag, 0, NULL ); flag->PostEventMS( eventFlag, 0, 0 );
break; break;
case 2 : case 2 :
flag->PostEventMS( eventFlag, 0, NULL, NULL ); flag->PostEventMS( eventFlag, 0, 0, 0 );
break; break;
// RB end
} }
/* /*

View file

@ -167,7 +167,9 @@ void idAASLocal::CalculateAreaTravelTimes(void) {
} }
} }
assert( ( (unsigned int) bytePtr - (unsigned int) areaTravelTimes ) <= numAreaTravelTimes * sizeof( unsigned short ) ); // RB: 64 bit fixes, changed unsigned int to ptrdiff_t
assert( ( (ptrdiff_t) bytePtr - (ptrdiff_t) areaTravelTimes ) <= numAreaTravelTimes * sizeof( unsigned short ) );
// RB end
} }
/* /*

View file

@ -2495,7 +2495,10 @@ void idAI::Event_ThrowMoveable( void ) {
} }
if ( moveable ) { if ( moveable ) {
moveable->Unbind(); moveable->Unbind();
moveable->PostEventMS( &EV_SetOwner, 200, NULL );
// RB: 64-bit fixes, changed NULL to 0
moveable->PostEventMS( &EV_SetOwner, 200, 0 );
// RB end
} }
} }
@ -2516,7 +2519,10 @@ void idAI::Event_ThrowAF( void ) {
} }
if ( af ) { if ( af ) {
af->Unbind(); af->Unbind();
af->PostEventMS( &EV_SetOwner, 200, NULL );
// RB: 64 bit fixes, changed NULL to 0
af->PostEventMS( &EV_SetOwner, 200, 0 );
// RB end
} }
} }

View file

@ -42,7 +42,9 @@ static idStr Maya_Error;
static exporterInterface_t Maya_ConvertModel = NULL; static exporterInterface_t Maya_ConvertModel = NULL;
static exporterShutdown_t Maya_Shutdown = NULL; static exporterShutdown_t Maya_Shutdown = NULL;
static int importDLL = 0; // flibit: 64 bit fix, changed int to void*
static void* importDLL = NULL;
// flibit end
bool idModelExport::initialized = false; bool idModelExport::initialized = false;

File diff suppressed because it is too large Load diff

View file

@ -4,7 +4,7 @@
Doom 3 GPL Source Code Doom 3 GPL Source Code
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company. Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?). This file is part of the Doom 3 GPL Source Code ("Doom 3 Source Code").
Doom 3 Source Code is free software: you can redistribute it and/or modify Doom 3 Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -394,7 +394,7 @@ void idClass::Init( void ) {
// is a subclass of another // is a subclass of another
num = 0; num = 0;
for( c = classHierarchy.GetNext(); c != NULL; c = c->node.GetNext(), num++ ) { for( c = classHierarchy.GetNext(); c != NULL; c = c->node.GetNext(), num++ ) {
c->typeNum = num; c->typeNum = num;
c->lastChild += num; c->lastChild += num;
} }
@ -504,7 +504,7 @@ void idClass::operator delete( void *ptr ) {
p = ( ( int * )ptr ) - 1; p = ( ( int * )ptr ) - 1;
memused -= *p; memused -= *p;
numobjects--; numobjects--;
Mem_Free( p ); Mem_Free( p );
} }
} }
@ -515,7 +515,7 @@ void idClass::operator delete( void *ptr, int, int, char *, int ) {
p = ( ( int * )ptr ) - 1; p = ( ( int * )ptr ) - 1;
memused -= *p; memused -= *p;
numobjects--; numobjects--;
Mem_Free( p ); Mem_Free( p );
} }
} }
@ -632,8 +632,6 @@ bool idClass::PostEventArgs( const idEventDef *ev, int time, int numargs, ... )
assert( ev ); assert( ev );
//common->Printf(" state %d %d\n", gameLocal.GameState() , IsType( idThread::Type ) );
if ( !idEvent::initialized ) { if ( !idEvent::initialized ) {
return false; return false;
} }
@ -647,14 +645,9 @@ bool idClass::PostEventArgs( const idEventDef *ev, int time, int numargs, ... )
// we service events on the client to avoid any bad code filling up the event pool // we service events on the client to avoid any bad code filling up the event pool
// we don't want them processed usually, unless when the map is (re)loading. // we don't want them processed usually, unless when the map is (re)loading.
// we allow threads to run fine, though. // we allow threads to run fine, though.
if ( gameLocal.isClient && ( gameLocal.GameState() != GAMESTATE_STARTUP ) && !IsType( idThread::Type ) ) {
//BC TODO: find out why the deck is making this break.
/*
if ( gameLocal.isClient && ( gameLocal.GameState() != GAMESTATE_STARTUP ) && !IsType( idThread::Type ) )
{
return true; return true;
} }
*/
va_start( args, numargs ); va_start( args, numargs );
event = idEvent::Alloc( ev, numargs, args ); event = idEvent::Alloc( ev, numargs, args );
@ -835,7 +828,7 @@ idClass::ProcessEventArgs
bool idClass::ProcessEventArgs( const idEventDef *ev, int numargs, ... ) { bool idClass::ProcessEventArgs( const idEventDef *ev, int numargs, ... ) {
idTypeInfo *c; idTypeInfo *c;
int num; int num;
int data[ D_EVENT_MAXARGS ]; intptr_t data[ D_EVENT_MAXARGS ];
va_list args; va_list args;
assert( ev ); assert( ev );
@ -943,7 +936,7 @@ bool idClass::ProcessEvent( const idEventDef *ev, idEventArg arg1, idEventArg ar
idClass::ProcessEventArgPtr idClass::ProcessEventArgPtr
================ ================
*/ */
bool idClass::ProcessEventArgPtr( const idEventDef *ev, int *data ) { bool idClass::ProcessEventArgPtr( const idEventDef *ev, intptr_t *data ) {
idTypeInfo *c; idTypeInfo *c;
int num; int num;
eventCallback_t callback; eventCallback_t callback;
@ -1006,42 +999,42 @@ http://developer.apple.com/documentation/DeveloperTools/Conceptual/MachORuntime/
break; break;
case 1 : case 1 :
typedef void ( idClass::*eventCallback_1_t )( const int ); typedef void ( idClass::*eventCallback_1_t )( const intptr_t );
( this->*( eventCallback_1_t )callback )( data[ 0 ] ); ( this->*( eventCallback_1_t )callback )( data[ 0 ] );
break; break;
case 2 : case 2 :
typedef void ( idClass::*eventCallback_2_t )( const int, const int ); typedef void ( idClass::*eventCallback_2_t )( const intptr_t, const intptr_t );
( this->*( eventCallback_2_t )callback )( data[ 0 ], data[ 1 ] ); ( this->*( eventCallback_2_t )callback )( data[ 0 ], data[ 1 ] );
break; break;
case 3 : case 3 :
typedef void ( idClass::*eventCallback_3_t )( const int, const int, const int ); typedef void ( idClass::*eventCallback_3_t )( const intptr_t, const intptr_t, const intptr_t );
( this->*( eventCallback_3_t )callback )( data[ 0 ], data[ 1 ], data[ 2 ] ); ( this->*( eventCallback_3_t )callback )( data[ 0 ], data[ 1 ], data[ 2 ] );
break; break;
case 4 : case 4 :
typedef void ( idClass::*eventCallback_4_t )( const int, const int, const int, const int ); typedef void ( idClass::*eventCallback_4_t )( const intptr_t, const intptr_t, const intptr_t, const intptr_t );
( this->*( eventCallback_4_t )callback )( data[ 0 ], data[ 1 ], data[ 2 ], data[ 3 ] ); ( this->*( eventCallback_4_t )callback )( data[ 0 ], data[ 1 ], data[ 2 ], data[ 3 ] );
break; break;
case 5 : case 5 :
typedef void ( idClass::*eventCallback_5_t )( const int, const int, const int, const int, const int ); typedef void ( idClass::*eventCallback_5_t )( const intptr_t, const intptr_t, const intptr_t, const intptr_t, const intptr_t );
( this->*( eventCallback_5_t )callback )( data[ 0 ], data[ 1 ], data[ 2 ], data[ 3 ], data[ 4 ] ); ( this->*( eventCallback_5_t )callback )( data[ 0 ], data[ 1 ], data[ 2 ], data[ 3 ], data[ 4 ] );
break; break;
case 6 : case 6 :
typedef void ( idClass::*eventCallback_6_t )( const int, const int, const int, const int, const int, const int ); typedef void ( idClass::*eventCallback_6_t )( const intptr_t, const intptr_t, const intptr_t, const intptr_t, const intptr_t, const intptr_t );
( this->*( eventCallback_6_t )callback )( data[ 0 ], data[ 1 ], data[ 2 ], data[ 3 ], data[ 4 ], data[ 5 ] ); ( this->*( eventCallback_6_t )callback )( data[ 0 ], data[ 1 ], data[ 2 ], data[ 3 ], data[ 4 ], data[ 5 ] );
break; break;
case 7 : case 7 :
typedef void ( idClass::*eventCallback_7_t )( const int, const int, const int, const int, const int, const int, const int ); typedef void ( idClass::*eventCallback_7_t )( const intptr_t, const intptr_t, const intptr_t, const intptr_t, const intptr_t, const intptr_t, const intptr_t );
( this->*( eventCallback_7_t )callback )( data[ 0 ], data[ 1 ], data[ 2 ], data[ 3 ], data[ 4 ], data[ 5 ], data[ 6 ] ); ( this->*( eventCallback_7_t )callback )( data[ 0 ], data[ 1 ], data[ 2 ], data[ 3 ], data[ 4 ], data[ 5 ], data[ 6 ] );
break; break;
case 8 : case 8 :
typedef void ( idClass::*eventCallback_8_t )( const int, const int, const int, const int, const int, const int, const int, const int ); typedef void ( idClass::*eventCallback_8_t )( const intptr_t, const intptr_t, const intptr_t, const intptr_t, const intptr_t, const intptr_t, const intptr_t, const intptr_t );
( this->*( eventCallback_8_t )callback )( data[ 0 ], data[ 1 ], data[ 2 ], data[ 3 ], data[ 4 ], data[ 5 ], data[ 6 ], data[ 7 ] ); ( this->*( eventCallback_8_t )callback )( data[ 0 ], data[ 1 ], data[ 2 ], data[ 3 ], data[ 4 ], data[ 5 ], data[ 6 ], data[ 7 ] );
break; break;

View file

@ -4,7 +4,7 @@
Doom 3 GPL Source Code Doom 3 GPL Source Code
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company. Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?). This file is part of the Doom 3 GPL Source Code ("Doom 3 Source Code").
Doom 3 Source Code is free software: you can redistribute it and/or modify Doom 3 Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -57,16 +57,16 @@ struct idEventFunc {
class idEventArg { class idEventArg {
public: public:
int type; int type;
int value; intptr_t value;
idEventArg() { type = D_EVENT_INTEGER; value = 0; }; idEventArg() { type = D_EVENT_INTEGER; value = 0; };
idEventArg( int data ) { type = D_EVENT_INTEGER; value = data; }; idEventArg( int data ) { type = D_EVENT_INTEGER; value = data; };
idEventArg( float data ) { type = D_EVENT_FLOAT; value = *reinterpret_cast<int *>( &data ); }; idEventArg( float data ) { type = D_EVENT_FLOAT; value = *reinterpret_cast<int *>( &data ); };
idEventArg( idVec3 &data ) { type = D_EVENT_VECTOR; value = reinterpret_cast<int>( &data ); }; idEventArg( idVec3 &data ) { type = D_EVENT_VECTOR; value = reinterpret_cast<intptr_t>( &data ); };
idEventArg( const idStr &data ) { type = D_EVENT_STRING; value = reinterpret_cast<int>( data.c_str() ); }; idEventArg( const idStr &data ) { type = D_EVENT_STRING; value = reinterpret_cast<intptr_t>( data.c_str() ); };
idEventArg( const char *data ) { type = D_EVENT_STRING; value = reinterpret_cast<int>( data ); }; idEventArg( const char *data ) { type = D_EVENT_STRING; value = reinterpret_cast<intptr_t>( data ); };
idEventArg( const class idEntity *data ) { type = D_EVENT_ENTITY; value = reinterpret_cast<int>( data ); }; idEventArg( const class idEntity *data ) { type = D_EVENT_ENTITY; value = reinterpret_cast<intptr_t>( data ); };
idEventArg( const struct trace_s *data ) { type = D_EVENT_TRACE; value = reinterpret_cast<int>( data ); }; idEventArg( const struct trace_s *data ) { type = D_EVENT_TRACE; value = reinterpret_cast<intptr_t>( data ); };
}; };
class idAllocError : public idException { class idAllocError : public idException {
@ -230,7 +230,7 @@ public:
bool ProcessEvent( const idEventDef *ev, idEventArg arg1, idEventArg arg2, idEventArg arg3, idEventArg arg4, idEventArg arg5, idEventArg arg6, idEventArg arg7 ); bool ProcessEvent( const idEventDef *ev, idEventArg arg1, idEventArg arg2, idEventArg arg3, idEventArg arg4, idEventArg arg5, idEventArg arg6, idEventArg arg7 );
bool ProcessEvent( const idEventDef *ev, idEventArg arg1, idEventArg arg2, idEventArg arg3, idEventArg arg4, idEventArg arg5, idEventArg arg6, idEventArg arg7, idEventArg arg8 ); bool ProcessEvent( const idEventDef *ev, idEventArg arg1, idEventArg arg2, idEventArg arg3, idEventArg arg4, idEventArg arg5, idEventArg arg6, idEventArg arg7, idEventArg arg8 );
bool ProcessEventArgPtr( const idEventDef *ev, int *data ); bool ProcessEventArgPtr( const idEventDef *ev, intptr_t *data );
void CancelEvents( const idEventDef *ev ); void CancelEvents( const idEventDef *ev );
void Event_Remove( void ); void Event_Remove( void );

View file

@ -4,7 +4,7 @@
Doom 3 GPL Source Code Doom 3 GPL Source Code
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company. Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?). This file is part of the Doom 3 GPL Source Code ("Doom 3 Source Code").
Doom 3 Source Code is free software: you can redistribute it and/or modify Doom 3 Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -92,15 +92,15 @@ idEventDef::idEventDef( const char *command, const char *formatspec, char return
switch( formatspec[ i ] ) { switch( formatspec[ i ] ) {
case D_EVENT_FLOAT : case D_EVENT_FLOAT :
bits |= 1 << i; bits |= 1 << i;
argsize += sizeof( float ); argsize += sizeof( intptr_t );
break; break;
case D_EVENT_INTEGER : case D_EVENT_INTEGER :
argsize += sizeof( int ); argsize += sizeof( intptr_t );
break; break;
case D_EVENT_VECTOR : case D_EVENT_VECTOR :
argsize += sizeof( idVec3 ); argsize += E_EVENT_SIZEOF_VEC;
break; break;
case D_EVENT_STRING : case D_EVENT_STRING :
@ -334,7 +334,7 @@ idEvent *idEvent::Alloc( const idEventDef *evdef, int numargs, va_list args ) {
idEvent::CopyArgs idEvent::CopyArgs
================ ================
*/ */
void idEvent::CopyArgs( const idEventDef *evdef, int numargs, va_list args, int data[ D_EVENT_MAXARGS ] ) { void idEvent::CopyArgs( const idEventDef *evdef, int numargs, va_list args, intptr_t data[ D_EVENT_MAXARGS ] ) {
int i; int i;
const char *format; const char *format;
idEventArg *arg; idEventArg *arg;
@ -493,7 +493,7 @@ idEvent::ServiceEvents
void idEvent::ServiceEvents( void ) { void idEvent::ServiceEvents( void ) {
idEvent *event; idEvent *event;
int num; int num;
int args[ D_EVENT_MAXARGS ]; intptr_t args[ D_EVENT_MAXARGS ];
int offset; int offset;
int i; int i;
int numargs; int numargs;
@ -593,7 +593,7 @@ idEvent::ServiceFastEvents
void idEvent::ServiceFastEvents() { void idEvent::ServiceFastEvents() {
idEvent *event; idEvent *event;
int num; int num;
int args[ D_EVENT_MAXARGS ]; intptr_t args[ D_EVENT_MAXARGS ];
int offset; int offset;
int i; int i;
int numargs; int numargs;
@ -768,17 +768,17 @@ void idEvent::Save( idSaveGame *savefile ) {
switch( format[ i ] ) { switch( format[ i ] ) {
case D_EVENT_FLOAT : case D_EVENT_FLOAT :
savefile->WriteFloat( *reinterpret_cast<float *>( dataPtr ) ); savefile->WriteFloat( *reinterpret_cast<float *>( dataPtr ) );
size += sizeof( float ); size += sizeof( intptr_t );
break; break;
case D_EVENT_INTEGER : case D_EVENT_INTEGER :
case D_EVENT_ENTITY : case D_EVENT_ENTITY :
case D_EVENT_ENTITY_NULL : case D_EVENT_ENTITY_NULL :
savefile->WriteInt( *reinterpret_cast<int *>( dataPtr ) ); savefile->WriteInt( *reinterpret_cast<int *>( dataPtr ) );
size += sizeof( int ); size += sizeof( intptr_t );
break; break;
case D_EVENT_VECTOR : case D_EVENT_VECTOR :
savefile->WriteVec3( *reinterpret_cast<idVec3 *>( dataPtr ) ); savefile->WriteVec3( *reinterpret_cast<idVec3 *>( dataPtr ) );
size += sizeof( idVec3 ); size += E_EVENT_SIZEOF_VEC;
break; break;
case D_EVENT_TRACE : case D_EVENT_TRACE :
validTrace = *reinterpret_cast<bool *>( dataPtr ); validTrace = *reinterpret_cast<bool *>( dataPtr );
@ -877,17 +877,17 @@ void idEvent::Restore( idRestoreGame *savefile ) {
switch( format[ j ] ) { switch( format[ j ] ) {
case D_EVENT_FLOAT : case D_EVENT_FLOAT :
savefile->ReadFloat( *reinterpret_cast<float *>( dataPtr ) ); savefile->ReadFloat( *reinterpret_cast<float *>( dataPtr ) );
size += sizeof( float ); size += sizeof( intptr_t );
break; break;
case D_EVENT_INTEGER : case D_EVENT_INTEGER :
case D_EVENT_ENTITY : case D_EVENT_ENTITY :
case D_EVENT_ENTITY_NULL : case D_EVENT_ENTITY_NULL :
savefile->ReadInt( *reinterpret_cast<int *>( dataPtr ) ); savefile->ReadInt( *reinterpret_cast<int *>( dataPtr ) );
size += sizeof( int ); size += sizeof( intptr_t );
break; break;
case D_EVENT_VECTOR : case D_EVENT_VECTOR :
savefile->ReadVec3( *reinterpret_cast<idVec3 *>( dataPtr ) ); savefile->ReadVec3( *reinterpret_cast<idVec3 *>( dataPtr ) );
size += sizeof( idVec3 ); size += E_EVENT_SIZEOF_VEC;
break; break;
case D_EVENT_TRACE : case D_EVENT_TRACE :
savefile->ReadBool( *reinterpret_cast<bool *>( dataPtr ) ); savefile->ReadBool( *reinterpret_cast<bool *>( dataPtr ) );
@ -1016,8 +1016,6 @@ CreateEventCallbackHandler
================ ================
*/ */
void CreateEventCallbackHandler( void ) { void CreateEventCallbackHandler( void ) {
int num;
int count;
int i, j, k; int i, j, k;
char argString[ D_EVENT_MAXARGS + 1 ]; char argString[ D_EVENT_MAXARGS + 1 ];
idStr string1; idStr string1;
@ -1046,7 +1044,7 @@ void CreateEventCallbackHandler( void ) {
string1 += "const float"; string1 += "const float";
string2 += va( "*( float * )&data[ %d ]", k ); string2 += va( "*( float * )&data[ %d ]", k );
} else { } else {
string1 += "const int"; string1 += "const intptr_t";
string2 += va( "data[ %d ]", k ); string2 += va( "data[ %d ]", k );
} }

View file

@ -4,7 +4,7 @@
Doom 3 GPL Source Code Doom 3 GPL Source Code
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company. Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?). This file is part of the Doom 3 GPL Source Code ("Doom 3 Source Code").
Doom 3 Source Code is free software: you can redistribute it and/or modify Doom 3 Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -36,6 +36,9 @@ Event are used for scheduling tasks and for linking script commands.
#define D_EVENT_MAXARGS 8 // if changed, enable the CREATE_EVENT_CODE define in Event.cpp to generate switch statement for idClass::ProcessEventArgPtr. #define D_EVENT_MAXARGS 8 // if changed, enable the CREATE_EVENT_CODE define in Event.cpp to generate switch statement for idClass::ProcessEventArgPtr.
// running the game will then generate c:\doom\base\events.txt, the contents of which should be copied into the switch statement. // running the game will then generate c:\doom\base\events.txt, the contents of which should be copied into the switch statement.
// stack size of idVec3, aligned to native pointer size
#define E_EVENT_SIZEOF_VEC ((sizeof(idVec3) + (sizeof(intptr_t) - 1)) & ~(sizeof(intptr_t) - 1))
#define D_EVENT_VOID ( ( char )0 ) #define D_EVENT_VOID ( ( char )0 )
#define D_EVENT_INTEGER 'd' #define D_EVENT_INTEGER 'd'
#define D_EVENT_FLOAT 'f' #define D_EVENT_FLOAT 'f'
@ -104,7 +107,7 @@ public:
~idEvent(); ~idEvent();
static idEvent *Alloc( const idEventDef *evdef, int numargs, va_list args ); static idEvent *Alloc( const idEventDef *evdef, int numargs, va_list args );
static void CopyArgs( const idEventDef *evdef, int numargs, va_list args, int data[ D_EVENT_MAXARGS ] ); static void CopyArgs( const idEventDef *evdef, int numargs, va_list args, intptr_t data[ D_EVENT_MAXARGS ] );
void Free( void ); void Free( void );
void Schedule( idClass *object, const idTypeInfo *cls, int time ); void Schedule( idClass *object, const idTypeInfo *cls, int time );

View file

@ -129,7 +129,7 @@ void Cmd_ListSpawnArgs_f( const idCmdArgs &args ) {
for ( i = 0; i < ent->spawnArgs.GetNumKeyVals(); i++ ) { for ( i = 0; i < ent->spawnArgs.GetNumKeyVals(); i++ ) {
const idKeyValue *kv = ent->spawnArgs.GetKeyVal( i ); const idKeyValue *kv = ent->spawnArgs.GetKeyVal( i );
gameLocal.Printf( "\"%s\" "S_COLOR_WHITE"\"%s\"\n", kv->GetKey().c_str(), kv->GetValue().c_str() ); gameLocal.Printf( "\"%s\" " S_COLOR_WHITE "\"%s\"\n", kv->GetKey().c_str(), kv->GetValue().c_str() );
} }
} }

View file

@ -26,6 +26,10 @@ If you have questions concerning this license or the applicable additional terms
=========================================================================== ===========================================================================
*/ */
#ifdef _WIN32
#define _ALLOW_KEYWORD_MACROS /* Thanks Visual Studio! */
#endif
// This is real evil but allows the code to inspect arbitrary class variables. // This is real evil but allows the code to inspect arbitrary class variables.
#define private public #define private public
#define protected public #define protected public
@ -563,7 +567,9 @@ int idTypeInfoTools::WriteVariable_r( const void *varPtr, const char *varName, c
// if this is a pointer // if this is a pointer
isPointer = 0; isPointer = 0;
for ( i = typeString.Length(); i > 0 && typeString[i - 1] == '*'; i -= 2 ) { for ( i = typeString.Length(); i > 0 && typeString[i - 1] == '*'; i -= 2 ) {
if ( varPtr == (void *)0xcdcdcdcd || ( varPtr != NULL && *((unsigned long *)varPtr) == 0xcdcdcdcd ) ) { // flibit: 64 bit fix, changed long to int
if ( varPtr == (void *)0xcdcdcdcd || ( varPtr != NULL && *((unsigned int *)varPtr) == 0xcdcdcdcd ) ) {
// flibit end
common->Warning( "%s%s::%s%s references uninitialized memory", prefix, scope, varName, "" ); common->Warning( "%s%s::%s%s references uninitialized memory", prefix, scope, varName, "" );
return typeSize; return typeSize;
} }
@ -1129,7 +1135,9 @@ int idTypeInfoTools::WriteVariable_r( const void *varPtr, const char *varName, c
i = 0; i = 0;
do { do {
if ( *((unsigned long *)varPtr) == 0xcdcdcdcd ) { // flibit: 64 bit fix, changed long to int
if ( *((unsigned int *)varPtr) == 0xcdcdcdcd ) {
// flibit end
common->Warning( "%s%s::%s%s uses uninitialized memory", prefix, scope, varName, "" ); common->Warning( "%s%s::%s%s uses uninitialized memory", prefix, scope, varName, "" );
break; break;
} }

View file

@ -202,7 +202,9 @@ void idPicker::StartDrag( idEntity *grabEnt, int id ) {
} }
grabEnt->PostEventMS( &EV_Touch, 250, thePlayer, NULL ); // flibit: 64 bit fixes, changed NULL to 0
grabEnt->PostEventMS( &EV_Touch, 250, thePlayer, 0 );
// flibit end
} }

View file

@ -686,7 +686,9 @@ void idInterpreter::CallEvent( const function_t *func, int argsize ) {
varEval_t var; varEval_t var;
int pos; int pos;
int start; int start;
int data[ D_EVENT_MAXARGS ]; // RB: 64 bit fixes, changed int to intptr_t
intptr_t data[ D_EVENT_MAXARGS ];
// RB end
const idEventDef *evdef; const idEventDef *evdef;
const char *format; const char *format;
@ -745,7 +747,7 @@ void idInterpreter::CallEvent( const function_t *func, int argsize ) {
switch( format[ i ] ) { switch( format[ i ] ) {
case D_EVENT_INTEGER : case D_EVENT_INTEGER :
var.intPtr = ( int * )&localstack[ start + pos ]; var.intPtr = ( int * )&localstack[ start + pos ];
data[ i ] = int( *var.floatPtr ); ( *( int * )&data[ i ] ) = int( *var.floatPtr );
break; break;
case D_EVENT_FLOAT : case D_EVENT_FLOAT :
@ -857,7 +859,9 @@ void idInterpreter::CallSysEvent( const function_t *func, int argsize ) {
varEval_t source; varEval_t source;
int pos; int pos;
int start; int start;
int data[ D_EVENT_MAXARGS ]; // RB: 64 bit fixes, changed int to intptr_t
intptr_t data[ D_EVENT_MAXARGS ];
// RB end
const idEventDef *evdef; const idEventDef *evdef;
const char *format; const char *format;
@ -1808,9 +1812,14 @@ bool idInterpreter::Execute( void ) {
case OP_PUSH_V: case OP_PUSH_V:
var_a = GetVariable( st->a ); var_a = GetVariable( st->a );
// RB: 64 bit fix, changed individual pushes with PushVector
/*
Push( *reinterpret_cast<int *>( &var_a.vectorPtr->x ) ); Push( *reinterpret_cast<int *>( &var_a.vectorPtr->x ) );
Push( *reinterpret_cast<int *>( &var_a.vectorPtr->y ) ); Push( *reinterpret_cast<int *>( &var_a.vectorPtr->y ) );
Push( *reinterpret_cast<int *>( &var_a.vectorPtr->z ) ); Push( *reinterpret_cast<int *>( &var_a.vectorPtr->z ) );
*/
PushVector( *var_a.vectorPtr );
// RB end
break; break;
case OP_PUSH_OBJ: case OP_PUSH_OBJ:
@ -1871,9 +1880,12 @@ bool idInterpreter::EnterFunctionVarArgVN(const function_t *func, bool clearStac
case 'v': case 'v':
v = va_arg(args, idVec3 *); v = va_arg(args, idVec3 *);
/*
Push(*reinterpret_cast<int *>(&v->x)); Push(*reinterpret_cast<int *>(&v->x));
Push(*reinterpret_cast<int *>(&v->y)); Push(*reinterpret_cast<int *>(&v->y));
Push(*reinterpret_cast<int *>(&v->z)); Push(*reinterpret_cast<int *>(&v->z));
*/
PushVector(*v);
break; break;
case 's': case 's':

View file

@ -60,7 +60,13 @@ private:
void PopParms( int numParms ); void PopParms( int numParms );
void PushString( const char *string ); void PushString( const char *string );
void Push( int value ); // RB begin
// RB: 64 bit fix, changed int to intptr_t
void Push( intptr_t value );
// RB: added PushVector to new E_EVENT_SIZEOF_VEC
void PushVector( const idVec3& vector );
// RB end
const char *FloatToString( float value ); const char *FloatToString( float value );
void AppendString( idVarDef *def, const char *from ); void AppendString( idVarDef *def, const char *from );
void SetString( idVarDef *def, const char *from ); void SetString( idVarDef *def, const char *from );
@ -144,13 +150,32 @@ ID_INLINE void idInterpreter::PopParms( int numParms ) {
idInterpreter::Push idInterpreter::Push
==================== ====================
*/ */
ID_INLINE void idInterpreter::Push( int value ) { // RB: 64 bit fix, changed int to intptr_t
if ( localstackUsed + sizeof( int ) > LOCALSTACK_SIZE ) { ID_INLINE void idInterpreter::Push( intptr_t value ) {
if ( localstackUsed + sizeof( intptr_t ) > LOCALSTACK_SIZE ) {
Error( "Push: locals stack overflow\n" ); Error( "Push: locals stack overflow\n" );
} }
*( int * )&localstack[ localstackUsed ] = value; *( intptr_t * )&localstack[ localstackUsed ] = value;
localstackUsed += sizeof( int ); localstackUsed += sizeof( intptr_t );
} }
// RB end
// RB begin
/*
====================
idInterpreter::PushVector
====================
*/
ID_INLINE void idInterpreter::PushVector( const idVec3& vector )
{
if( localstackUsed + E_EVENT_SIZEOF_VEC > LOCALSTACK_SIZE )
{
Error( "Push: locals stack overflow\n" );
}
*( idVec3* )&localstack[ localstackUsed ] = vector;
localstackUsed += E_EVENT_SIZEOF_VEC;
}
// RB end
/* /*
==================== ====================

View file

@ -4,7 +4,7 @@
Doom 3 GPL Source Code Doom 3 GPL Source Code
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company. Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?). This file is part of the Doom 3 GPL Source Code ("Doom 3 Source Code").
Doom 3 Source Code is free software: you can redistribute it and/or modify Doom 3 Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -33,20 +33,20 @@ If you have questions concerning this license or the applicable additional terms
// simple types. function types are dynamically allocated // simple types. function types are dynamically allocated
idTypeDef type_void( ev_void, &def_void, "void", 0, NULL ); idTypeDef type_void( ev_void, &def_void, "void", 0, NULL );
idTypeDef type_scriptevent( ev_scriptevent, &def_scriptevent, "scriptevent", sizeof( void * ), NULL ); idTypeDef type_scriptevent( ev_scriptevent, &def_scriptevent, "scriptevent", sizeof( intptr_t ), NULL );
idTypeDef type_namespace( ev_namespace, &def_namespace, "namespace", sizeof( void * ), NULL ); idTypeDef type_namespace( ev_namespace, &def_namespace, "namespace", sizeof( intptr_t ), NULL );
idTypeDef type_string( ev_string, &def_string, "string", MAX_STRING_LEN, NULL ); idTypeDef type_string( ev_string, &def_string, "string", MAX_STRING_LEN, NULL );
idTypeDef type_float( ev_float, &def_float, "float", sizeof( float ), NULL ); idTypeDef type_float( ev_float, &def_float, "float", sizeof( intptr_t ), NULL );
idTypeDef type_vector( ev_vector, &def_vector, "vector", sizeof( idVec3 ), NULL ); idTypeDef type_vector( ev_vector, &def_vector, "vector", E_EVENT_SIZEOF_VEC, NULL );
idTypeDef type_entity( ev_entity, &def_entity, "entity", sizeof( int * ), NULL ); // stored as entity number pointer idTypeDef type_entity( ev_entity, &def_entity, "entity", sizeof( intptr_t ), NULL ); // stored as entity number pointer
idTypeDef type_field( ev_field, &def_field, "field", sizeof( void * ), NULL ); idTypeDef type_field( ev_field, &def_field, "field", sizeof( intptr_t ), NULL );
idTypeDef type_function( ev_function, &def_function, "function", sizeof( void * ), &type_void ); idTypeDef type_function( ev_function, &def_function, "function", sizeof( intptr_t ), &type_void );
idTypeDef type_virtualfunction( ev_virtualfunction, &def_virtualfunction, "virtual function", sizeof( int ), NULL ); idTypeDef type_virtualfunction( ev_virtualfunction, &def_virtualfunction, "virtual function", sizeof( intptr_t ), NULL );
idTypeDef type_pointer( ev_pointer, &def_pointer, "pointer", sizeof( void * ), NULL ); idTypeDef type_pointer( ev_pointer, &def_pointer, "pointer", sizeof( intptr_t ), NULL );
idTypeDef type_object( ev_object, &def_object, "object", sizeof( int * ), NULL ); // stored as entity number pointer idTypeDef type_object( ev_object, &def_object, "object", sizeof( intptr_t ), NULL ); // stored as entity number pointer
idTypeDef type_jumpoffset( ev_jumpoffset, &def_jumpoffset, "<jump>", sizeof( int ), NULL ); // only used for jump opcodes idTypeDef type_jumpoffset( ev_jumpoffset, &def_jumpoffset, "<jump>", sizeof( intptr_t ), NULL ); // only used for jump opcodes
idTypeDef type_argsize( ev_argsize, &def_argsize, "<argsize>", sizeof( int ), NULL ); // only used for function call and thread opcodes idTypeDef type_argsize( ev_argsize, &def_argsize, "<argsize>", sizeof( intptr_t ), NULL ); // only used for function call and thread opcodes
idTypeDef type_boolean( ev_boolean, &def_boolean, "boolean", sizeof( int ), NULL ); idTypeDef type_boolean( ev_boolean, &def_boolean, "boolean", sizeof( intptr_t ), NULL );
idVarDef def_void( &type_void ); idVarDef def_void( &type_void );
idVarDef def_scriptevent( &type_scriptevent ); idVarDef def_scriptevent( &type_scriptevent );
@ -795,7 +795,7 @@ void idVarDef::PrintInfo( idFile *file, int instructionPointer ) const {
break; break;
case ev_float : case ev_float :
file->Printf( "%f", *value.floatPtr ); file->Printf( "%f", *value.floatPtr );
break; break;
case ev_virtualfunction : case ev_virtualfunction :
@ -898,7 +898,7 @@ idScriptObject::Save
================ ================
*/ */
void idScriptObject::Save( idSaveGame *savefile ) const { void idScriptObject::Save( idSaveGame *savefile ) const {
size_t size; int size;
if ( type == &type_object && data == NULL ) { if ( type == &type_object && data == NULL ) {
// Write empty string for uninitialized object // Write empty string for uninitialized object
@ -918,7 +918,7 @@ idScriptObject::Restore
*/ */
void idScriptObject::Restore( idRestoreGame *savefile ) { void idScriptObject::Restore( idRestoreGame *savefile ) {
idStr typeName; idStr typeName;
size_t size; int size;
savefile->ReadString( typeName ); savefile->ReadString( typeName );
@ -931,7 +931,7 @@ void idScriptObject::Restore( idRestoreGame *savefile ) {
savefile->Error( "idScriptObject::Restore: failed to restore object of type '%s'.", typeName.c_str() ); savefile->Error( "idScriptObject::Restore: failed to restore object of type '%s'.", typeName.c_str() );
} }
savefile->ReadInt( (int &)size ); savefile->ReadInt( size );
if ( size != type->Size() ) { if ( size != type->Size() ) {
savefile->Error( "idScriptObject::Restore: size of object '%s' doesn't match size in save game.", typeName.c_str() ); savefile->Error( "idScriptObject::Restore: size of object '%s' doesn't match size in save game.", typeName.c_str() );
} }
@ -1226,6 +1226,44 @@ void idProgram::AddDefToNameList( idVarDef *def, const char *name ) {
varDefNames[i]->AddDef( def ); varDefNames[i]->AddDef( def );
} }
/*
==============
idProgram::ReserveMem
reserves memory for global variables and returns the starting pointer
==============
*/
byte *idProgram::ReserveMem(int size) {
byte *res = &variables[ numVariables ];
numVariables += size;
if ( numVariables > sizeof( variables ) ) {
throw idCompileError( va( "Exceeded global memory size (%d bytes)", sizeof( variables ) ) );
}
memset( res, 0, size );
return res;
}
/*
============
idProgram::AllocVarDef
============
*/
idVarDef *idProgram::AllocVarDef(idTypeDef *type, const char *name, idVarDef *scope) {
idVarDef *def;
def = new idVarDef( type );
def->scope = scope;
def->numUsers = 1;
def->num = varDefs.Append( def );
// add the def to the list with defs with this name and set the name pointer
AddDefToNameList( def, name );
return def;
}
/* /*
============ ============
idProgram::AllocDef idProgram::AllocDef
@ -1239,13 +1277,7 @@ idVarDef *idProgram::AllocDef( idTypeDef *type, const char *name, idVarDef *scop
idVarDef *def_z; idVarDef *def_z;
// allocate a new def // allocate a new def
def = new idVarDef( type ); def = AllocVarDef(type, name, scope);
def->scope = scope;
def->numUsers = 1;
def->num = varDefs.Append( def );
// add the def to the list with defs with this name and set the name pointer
AddDefToNameList( def, name );
if ( ( type->Type() == ev_vector ) || ( ( type->Type() == ev_field ) && ( type->FieldType()->Type() == ev_vector ) ) ) { if ( ( type->Type() == ev_vector ) || ( ( type->Type() == ev_field ) && ( type->FieldType()->Type() == ev_vector ) ) ) {
// //
@ -1259,7 +1291,7 @@ idVarDef *idProgram::AllocDef( idTypeDef *type, const char *name, idVarDef *scop
scope->value.functionPtr->locals += type->Size(); scope->value.functionPtr->locals += type->Size();
} else if ( scope->TypeDef()->Inherits( &type_object ) ) { } else if ( scope->TypeDef()->Inherits( &type_object ) ) {
idTypeDef newtype( ev_field, NULL, "float field", 0, &type_float ); idTypeDef newtype( ev_field, NULL, "float field", 0, &type_float );
idTypeDef *type = GetType( newtype, true ); idTypeDef *ftype = GetType( newtype, true );
// set the value to the variable's position in the object // set the value to the variable's position in the object
def->value.ptrOffset = scope->TypeDef()->Size(); def->value.ptrOffset = scope->TypeDef()->Size();
@ -1267,30 +1299,52 @@ idVarDef *idProgram::AllocDef( idTypeDef *type, const char *name, idVarDef *scop
// make automatic defs for the vectors elements // make automatic defs for the vectors elements
// origin can be accessed as origin_x, origin_y, and origin_z // origin can be accessed as origin_x, origin_y, and origin_z
sprintf( element, "%s_x", def->Name() ); sprintf( element, "%s_x", def->Name() );
def_x = AllocDef( type, element, scope, constant ); def_x = AllocDef( ftype, element, scope, constant );
sprintf( element, "%s_y", def->Name() ); sprintf( element, "%s_y", def->Name() );
def_y = AllocDef( type, element, scope, constant ); def_y = AllocDef( ftype, element, scope, constant );
def_y->value.ptrOffset = def_x->value.ptrOffset + type_float.Size(); def_y->value.ptrOffset = def_x->value.ptrOffset + sizeof(float);
sprintf( element, "%s_z", def->Name() ); sprintf( element, "%s_z", def->Name() );
def_z = AllocDef( type, element, scope, constant ); def_z = AllocDef( ftype, element, scope, constant );
def_z->value.ptrOffset = def_y->value.ptrOffset + type_float.Size(); def_z->value.ptrOffset = def_y->value.ptrOffset + sizeof(float);
} else { } else {
idTypeDef newtype( ev_float, &def_float, "vector float", 0, NULL );
idTypeDef *ftype = GetType( newtype, true );
// make automatic defs for the vectors elements // make automatic defs for the vectors elements
// origin can be accessed as origin_x, origin_y, and origin_z // origin can be accessed as origin_x, origin_y, and origin_z
sprintf( element, "%s_x", def->Name() ); sprintf( element, "%s_x", def->Name() );
def_x = AllocDef( &type_float, element, scope, constant ); def_x = AllocVarDef( ftype, element, scope );
sprintf( element, "%s_y", def->Name() ); sprintf( element, "%s_y", def->Name() );
def_y = AllocDef( &type_float, element, scope, constant ); def_y = AllocVarDef( ftype, element, scope );
sprintf( element, "%s_z", def->Name() ); sprintf( element, "%s_z", def->Name() );
def_z = AllocDef( &type_float, element, scope, constant ); def_z = AllocVarDef( ftype, element, scope );
// point the vector def to the x coordinate // get the memory for the full vector and point the _x, _y and _z
def->value = def_x->value; // defs at the vector member offsets
def->initialized = def_x->initialized; if ( scope->Type() == ev_function ) {
// vector on stack
def->value.stackOffset = scope->value.functionPtr->locals;
def->initialized = idVarDef::stackVariable;
scope->value.functionPtr->locals += type->Size();
def_x->value.stackOffset = def->value.stackOffset;
def_y->value.stackOffset = def_x->value.stackOffset + sizeof(float);
def_z->value.stackOffset = def_y->value.stackOffset + sizeof(float);
} else {
// global vector
def->value.bytePtr = ReserveMem(type->Size());
def_x->value.bytePtr = def->value.bytePtr;
def_y->value.bytePtr = def_x->value.bytePtr + sizeof(float);
def_z->value.bytePtr = def_y->value.bytePtr + sizeof(float);
}
def_x->initialized = def->initialized;
def_y->initialized = def->initialized;
def_z->initialized = def->initialized;
} }
} else if ( scope->TypeDef()->Inherits( &type_object ) ) { } else if ( scope->TypeDef()->Inherits( &type_object ) ) {
// //
@ -1317,13 +1371,7 @@ idVarDef *idProgram::AllocDef( idTypeDef *type, const char *name, idVarDef *scop
// //
// global variable // global variable
// //
def->value.bytePtr = &variables[ numVariables ]; def->value.bytePtr = ReserveMem(def->TypeDef()->Size());
numVariables += def->TypeDef()->Size();
if ( numVariables > sizeof( variables ) ) {
throw idCompileError( va( "Exceeded global memory size (%d bytes)", sizeof( variables ) ) );
}
memset( def->value.bytePtr, 0, def->TypeDef()->Size() );
} }
return def; return def;
@ -1597,7 +1645,7 @@ void idProgram::BeginCompilation( void ) {
// make the first statement a return for a "NULL" function // make the first statement a return for a "NULL" function
statement = AllocStatement(); statement = AllocStatement();
statement->linenumber = 0; statement->linenumber = 0;
statement->file = 0; statement->file = 0;
statement->op = OP_RETURN; statement->op = OP_RETURN;
statement->a = NULL; statement->a = NULL;
statement->b = NULL; statement->b = NULL;
@ -1627,7 +1675,7 @@ idProgram::DisassembleStatement
============== ==============
*/ */
void idProgram::DisassembleStatement( idFile *file, int instructionPointer ) const { void idProgram::DisassembleStatement( idFile *file, int instructionPointer ) const {
opcode_t *op; const opcode_t *op;
const statement_t *statement; const statement_t *statement;
statement = &statements[ instructionPointer ]; statement = &statements[ instructionPointer ];
@ -1718,7 +1766,6 @@ called after all files are compiled to report memory usage.
void idProgram::CompileStats( void ) { void idProgram::CompileStats( void ) {
int memused; int memused;
int memallocated; int memallocated;
int numdefs;
int stringspace; int stringspace;
int funcMem; int funcMem;
int i; int i;
@ -1733,7 +1780,6 @@ void idProgram::CompileStats( void ) {
} }
stringspace += fileList.Size(); stringspace += fileList.Size();
numdefs = varDefs.Num();
memused = varDefs.Num() * sizeof( idVarDef ); memused = varDefs.Num() * sizeof( idVarDef );
memused += types.Num() * sizeof( idTypeDef ); memused += types.Num() * sizeof( idTypeDef );
memused += stringspace; memused += stringspace;

View file

@ -4,7 +4,7 @@
Doom 3 GPL Source Code Doom 3 GPL Source Code
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company. Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?). This file is part of the Doom 3 GPL Source Code ("Doom 3 Source Code").
Doom 3 Source Code is free software: you can redistribute it and/or modify Doom 3 Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -38,9 +38,9 @@ class idThread;
class idSaveGame; class idSaveGame;
class idRestoreGame; class idRestoreGame;
#define MAX_STRING_LEN 512 //BC determines how long a deck command can be. 128 default. 256 = crashy. #define MAX_STRING_LEN 128
#ifdef _D3XP #ifdef _D3XP
#define MAX_GLOBALS 1193216 //BC in bytes was 596608 #define MAX_GLOBALS 296608 // in bytes
#else #else
#define MAX_GLOBALS 196608 // in bytes #define MAX_GLOBALS 196608 // in bytes
#endif #endif
@ -72,16 +72,16 @@ public:
void Clear( void ); void Clear( void );
private: private:
idStr name; idStr name;
public: public:
const idEventDef *eventdef; const idEventDef *eventdef;
idVarDef *def; idVarDef *def;
const idTypeDef *type; const idTypeDef *type;
int firstStatement; int firstStatement;
int numStatements; int numStatements;
int parmTotal; int parmTotal;
int locals; // total ints of parms + locals int locals; // total ints of parms + locals
int filenum; // source file defined in int filenum; // source file defined in
idList<int> parmSize; idList<int> parmSize;
}; };
@ -90,8 +90,8 @@ typedef union eval_s {
float _float; float _float;
float vector[ 3 ]; float vector[ 3 ];
function_t *function; function_t *function;
int _int; int _int;
int entity; int entity;
} eval_t; } eval_t;
/*********************************************************************** /***********************************************************************
@ -105,7 +105,7 @@ Contains type information for variables and functions.
class idTypeDef { class idTypeDef {
private: private:
etype_t type; etype_t type;
idStr name; idStr name;
int size; int size;
// function types are more complex // function types are more complex
@ -309,9 +309,9 @@ typedef union varEval_s {
float *floatPtr; float *floatPtr;
idVec3 *vectorPtr; idVec3 *vectorPtr;
function_t *functionPtr; function_t *functionPtr;
int *intPtr; int *intPtr;
byte *bytePtr; byte *bytePtr;
int *entityNumberPtr; int *entityNumberPtr;
int virtualFunction; int virtualFunction;
int jumpOffset; int jumpOffset;
int stackOffset; // offset in stack for local variables int stackOffset; // offset in stack for local variables
@ -328,7 +328,7 @@ class idVarDef {
public: public:
int num; int num;
varEval_t value; varEval_t value;
idVarDef * scope; // function, namespace, or object the var was defined in idVarDef * scope; // function, namespace, or object the var was defined in
int numUsers; // number of users if this is a constant int numUsers; // number of users if this is a constant
typedef enum { typedef enum {
@ -448,7 +448,7 @@ single idProgram.
class idProgram { class idProgram {
private: private:
idStrList fileList; idStrList fileList;
idStr filename; idStr filename;
int filenum; int filenum;
int numVariables; int numVariables;
@ -470,6 +470,8 @@ private:
int top_files; int top_files;
void CompileStats( void ); void CompileStats( void );
byte *ReserveMem(int size);
idVarDef *AllocVarDef(idTypeDef *type, const char *name, idVarDef *scope);
public: public:
idVarDef *returnDef; idVarDef *returnDef;
@ -524,7 +526,7 @@ public:
statement_t &GetStatement( int index ); statement_t &GetStatement( int index );
int NumStatements( void ) { return statements.Num(); } int NumStatements( void ) { return statements.Num(); }
int GetReturnedInteger( void ); int GetReturnedInteger( void );
void ReturnFloat( float value ); void ReturnFloat( float value );
void ReturnInteger( int value ); void ReturnInteger( int value );

6
flibitGLIMP.sh Executable file
View file

@ -0,0 +1,6 @@
#!/bin/bash
set -ex
cd "`dirname "$0"`"
cd sys/linux
m4 glimp_dlopen.cpp.m4 > glimp_dlopen.cpp
m4 glimp_local.h.m4 > glimp_local.h

View file

@ -198,7 +198,7 @@ private:
idStrList warningList; idStrList warningList;
idStrList errorList; idStrList errorList;
int gameDLL; void * gameDLL;
idLangDict languageDict; idLangDict languageDict;

View file

@ -1483,7 +1483,7 @@ idCompressor_Arithmetic::GetCurrentCount
================ ================
*/ */
int idCompressor_Arithmetic::GetCurrentCount( void ) { int idCompressor_Arithmetic::GetCurrentCount( void ) {
return (unsigned int) ( ( ( ( (long) code - low ) + 1 ) * scale - 1 ) / ( ( (long) high - low ) + 1 ) ); return (unsigned int) ( ( ( ( (int) code - low ) + 1 ) * scale - 1 ) / ( ( (int) high - low ) + 1 ) );
} }
/* /*
@ -1552,9 +1552,9 @@ idCompressor_Arithmetic::RemoveSymbolFromStream
================ ================
*/ */
void idCompressor_Arithmetic::RemoveSymbolFromStream( acSymbol_t* symbol ) { void idCompressor_Arithmetic::RemoveSymbolFromStream( acSymbol_t* symbol ) {
long range; int range;
range = ( long )( high - low ) + 1; range = ( int )( high - low ) + 1;
high = low + ( unsigned short )( ( range * symbol->high ) / scale - 1 ); high = low + ( unsigned short )( ( range * symbol->high ) / scale - 1 );
low = low + ( unsigned short )( ( range * symbol->low ) / scale ); low = low + ( unsigned short )( ( range * symbol->low ) / scale );

View file

@ -39,8 +39,8 @@ FS_WriteFloatString
================= =================
*/ */
int FS_WriteFloatString( char *buf, const char *fmt, va_list argPtr ) { int FS_WriteFloatString( char *buf, const char *fmt, va_list argPtr ) {
long i; int i;
unsigned long u; unsigned int u;
double f; double f;
char *str; char *str;
int index; int index;
@ -78,27 +78,27 @@ int FS_WriteFloatString( char *buf, const char *fmt, va_list argPtr ) {
break; break;
case 'd': case 'd':
case 'i': case 'i':
i = va_arg( argPtr, long ); i = va_arg( argPtr, int );
index += sprintf( buf+index, format.c_str(), i ); index += sprintf( buf+index, format.c_str(), i );
break; break;
case 'u': case 'u':
u = va_arg( argPtr, unsigned long ); u = va_arg( argPtr, unsigned int );
index += sprintf( buf+index, format.c_str(), u ); index += sprintf( buf+index, format.c_str(), u );
break; break;
case 'o': case 'o':
u = va_arg( argPtr, unsigned long ); u = va_arg( argPtr, unsigned int );
index += sprintf( buf+index, format.c_str(), u ); index += sprintf( buf+index, format.c_str(), u );
break; break;
case 'x': case 'x':
u = va_arg( argPtr, unsigned long ); u = va_arg( argPtr, unsigned int );
index += sprintf( buf+index, format.c_str(), u ); index += sprintf( buf+index, format.c_str(), u );
break; break;
case 'X': case 'X':
u = va_arg( argPtr, unsigned long ); u = va_arg( argPtr, unsigned int );
index += sprintf( buf+index, format.c_str(), u ); index += sprintf( buf+index, format.c_str(), u );
break; break;
case 'c': case 'c':
i = va_arg( argPtr, long ); i = va_arg( argPtr, int );
index += sprintf( buf+index, format.c_str(), (char) i ); index += sprintf( buf+index, format.c_str(), (char) i );
break; break;
case 's': case 's':

View file

@ -3439,15 +3439,15 @@ idFile *idFileSystemLocal::OpenFileWrite( const char *relativePath, const char *
OSpath = BuildOSPath( path, gameFolder, relativePath ); OSpath = BuildOSPath( path, gameFolder, relativePath );
//if ( fs_debug.GetInteger() ) { if ( fs_debug.GetInteger() ) {
common->Printf( "idFileSystem::OpenFileWrite: %s\n", OSpath.c_str() ); common->Printf( "idFileSystem::OpenFileWrite: %s\n", OSpath.c_str() );
//} }
// if the dir we are writing to is in our current list, it will be outdated // if the dir we are writing to is in our current list, it will be outdated
// so just flush everything // so just flush everything
ClearDirCache(); ClearDirCache();
common->Printf( "writing to: %s\n", OSpath.c_str() ); common->DPrintf( "writing to: %s\n", OSpath.c_str() );
CreateOSPath( OSpath ); CreateOSPath( OSpath );
f = new idFile_Permanent(); f = new idFile_Permanent();
@ -3624,7 +3624,7 @@ size_t idFileSystemLocal::CurlWriteFunction( void *ptr, size_t size, size_t nmem
return size * nmemb; return size * nmemb;
} }
#ifdef _WIN32 #ifdef _WIN32
return _write( static_cast<idFile_Permanent*>(bgl->f)->GetFilePtr()->_file, ptr, size * nmemb ); return _write( _fileno(static_cast<idFile_Permanent*>(bgl->f)->GetFilePtr()), ptr, size * nmemb );
#else #else
return fwrite( ptr, size, nmemb, static_cast<idFile_Permanent*>(bgl->f)->GetFilePtr() ); return fwrite( ptr, size, nmemb, static_cast<idFile_Permanent*>(bgl->f)->GetFilePtr() );
#endif #endif
@ -3673,7 +3673,7 @@ dword BackgroundDownloadThread( void *parms ) {
if ( bgl->opcode == DLTYPE_FILE ) { if ( bgl->opcode == DLTYPE_FILE ) {
// use the low level read function, because fread may allocate memory // use the low level read function, because fread may allocate memory
#if defined(WIN32) #if defined(WIN32)
_read( static_cast<idFile_Permanent*>(bgl->f)->GetFilePtr()->_file, bgl->file.buffer, bgl->file.length ); _read( _fileno(static_cast<idFile_Permanent*>(bgl->f)->GetFilePtr()), bgl->file.buffer, bgl->file.length );
#else #else
fread( bgl->file.buffer, bgl->file.length, 1, static_cast<idFile_Permanent*>(bgl->f)->GetFilePtr() ); fread( bgl->file.buffer, bgl->file.length, 1, static_cast<idFile_Permanent*>(bgl->f)->GetFilePtr() );
#endif #endif

View file

@ -350,13 +350,13 @@ void idSessionLocal::SetModsMenuGuiVars( void ) {
descPath.Append(PATH_SLASH"description.txt"); descPath.Append(PATH_SLASH"description.txt");
//generate a relative folder path. //generate a relative folder path.
int foldernameIndex = idStr::FindText(modpaths[i], PATH_SLASH"steamapps"PATH_SLASH"workshop"PATH_SLASH, false); int foldernameIndex = idStr::FindText(modpaths[i], PATH_SLASH "steamapps" PATH_SLASH "workshop" PATH_SLASH, false);
int steamappsFolderLength = 10; int steamappsFolderLength = 10;
modpaths[i] = modpaths[i].Right(modpaths[i].Length() - foldernameIndex - steamappsFolderLength); modpaths[i] = modpaths[i].Right(modpaths[i].Length() - foldernameIndex - steamappsFolderLength);
#ifdef __APPLE__ #ifdef __APPLE__
modpaths[i] = ".."PATH_SLASH".."PATH_SLASH".."PATH_SLASH".."PATH_SLASH".." + modpaths[i]; //append the .. modpaths[i] = ".." PATH_SLASH ".." PATH_SLASH ".." PATH_SLASH ".." PATH_SLASH ".." + modpaths[i]; //append the ..
#else #else
modpaths[i] = ".."PATH_SLASH".." + modpaths[i]; //append the .. modpaths[i] = ".." PATH_SLASH ".." + modpaths[i]; //append the ..
#endif #endif
#undef PATH_SLASH #undef PATH_SLASH

View file

@ -329,7 +329,9 @@ pvsStack_t *idPVS::FloodPassagePVS_r( pvsPortal_t *source, const pvsPortal_t *po
pvsArea_t *area; pvsArea_t *area;
pvsStack_t *stack; pvsStack_t *stack;
pvsPassage_t *passage; pvsPassage_t *passage;
long *sourceVis, *passageVis, *portalVis, *mightSee, *prevMightSee, more; // RB: 64 bit fixes, changed long to int
int *sourceVis, *passageVis, *portalVis, *mightSee, *prevMightSee, more;
// RB end
area = &pvsAreas[portal->areaNum]; area = &pvsAreas[portal->areaNum];
@ -364,15 +366,20 @@ pvsStack_t *idPVS::FloodPassagePVS_r( pvsPortal_t *source, const pvsPortal_t *po
source->vis[n >> 3] |= (1 << (n & 7)); source->vis[n >> 3] |= (1 << (n & 7));
// get pointers to vis data // get pointers to vis data
prevMightSee = reinterpret_cast<long *>(prevStack->mightSee);
passageVis = reinterpret_cast<long *>(passage->canSee); // RB: 64 bit fixes, changed long to int
sourceVis = reinterpret_cast<long *>(source->vis); prevMightSee = reinterpret_cast<int *>(prevStack->mightSee);
mightSee = reinterpret_cast<long *>(stack->mightSee); passageVis = reinterpret_cast<int *>(passage->canSee);
sourceVis = reinterpret_cast<int *>(source->vis);
mightSee = reinterpret_cast<int *>(stack->mightSee);
// RB end
more = 0; more = 0;
// use the portal PVS if it has been calculated // use the portal PVS if it has been calculated
if ( p->done ) { if ( p->done ) {
portalVis = reinterpret_cast<long *>(p->vis); // RB: 64 bit fixes, changed long to int
portalVis = reinterpret_cast<int *>(p->vis);
// RB end
for ( j = 0; j < portalVisLongs; j++ ) { for ( j = 0; j < portalVisLongs; j++ ) {
// get new PVS which is decreased by going through this passage // get new PVS which is decreased by going through this passage
m = *prevMightSee++ & *passageVis++ & *portalVis++; m = *prevMightSee++ & *passageVis++ & *portalVis++;
@ -730,7 +737,9 @@ idPVS::AreaPVSFromPortalPVS
*/ */
int idPVS::AreaPVSFromPortalPVS( void ) const { int idPVS::AreaPVSFromPortalPVS( void ) const {
int i, j, k, areaNum, totalVisibleAreas; int i, j, k, areaNum, totalVisibleAreas;
long *p1, *p2; // RB: 64 bit fixes, changed long to int
int *p1, *p2;
// RB end
byte *pvs, *portalPVS; byte *pvs, *portalPVS;
pvsArea_t *area; pvsArea_t *area;
@ -755,8 +764,11 @@ int idPVS::AreaPVSFromPortalPVS( void ) const {
// store the PVS of all portals in this area at the first portal // store the PVS of all portals in this area at the first portal
for ( j = 1; j < area->numPortals; j++ ) { for ( j = 1; j < area->numPortals; j++ ) {
p1 = reinterpret_cast<long *>(area->portals[0]->vis); // RB: 64 bit fixes, changed long to int
p2 = reinterpret_cast<long *>(area->portals[j]->vis); p1 = reinterpret_cast<int *>(area->portals[0]->vis);
p2 = reinterpret_cast<int *>(area->portals[j]->vis);
// RB end
for ( k = 0; k < portalVisLongs; k++ ) { for ( k = 0; k < portalVisLongs; k++ ) {
*p1++ |= *p2++; *p1++ |= *p2++;
} }
@ -807,7 +819,9 @@ void idPVS::Init( void ) {
areaQueue = new int[numAreas]; areaQueue = new int[numAreas];
areaVisBytes = ( ((numAreas+31)&~31) >> 3); areaVisBytes = ( ((numAreas+31)&~31) >> 3);
areaVisLongs = areaVisBytes/sizeof(long); // RB: 64 bit fixes, changed long to int
areaVisLongs = areaVisBytes/sizeof(int);
// RB end
areaPVS = new byte[numAreas * areaVisBytes]; areaPVS = new byte[numAreas * areaVisBytes];
memset( areaPVS, 0xFF, numAreas * areaVisBytes ); memset( areaPVS, 0xFF, numAreas * areaVisBytes );
@ -815,7 +829,9 @@ void idPVS::Init( void ) {
numPortals = GetPortalCount(); numPortals = GetPortalCount();
portalVisBytes = ( ((numPortals+31)&~31) >> 3); portalVisBytes = ( ((numPortals+31)&~31) >> 3);
portalVisLongs = portalVisBytes/sizeof(long); // RB: 64 bit fixes, changed long to int
portalVisLongs = portalVisBytes/sizeof(int);
// RB end
for ( int i = 0; i < MAX_CURRENT_PVS; i++ ) { for ( int i = 0; i < MAX_CURRENT_PVS; i++ ) {
currentPVS[i].handle.i = -1; currentPVS[i].handle.i = -1;
@ -1013,7 +1029,9 @@ idPVS::SetupCurrentPVS
pvsHandle_t idPVS::SetupCurrentPVS( const int *sourceAreas, const int numSourceAreas, const pvsType_t type ) const { pvsHandle_t idPVS::SetupCurrentPVS( const int *sourceAreas, const int numSourceAreas, const pvsType_t type ) const {
int i, j; int i, j;
unsigned int h; unsigned int h;
long *vis, *pvs; // RB: 64 bit fixes, changed long to int
int *vis, *pvs;
// RB end
pvsHandle_t handle; pvsHandle_t handle;
h = 0; h = 0;
@ -1034,8 +1052,10 @@ pvsHandle_t idPVS::SetupCurrentPVS( const int *sourceAreas, const int numSourceA
assert( sourceAreas[i] >= 0 && sourceAreas[i] < numAreas ); assert( sourceAreas[i] >= 0 && sourceAreas[i] < numAreas );
vis = reinterpret_cast<long*>(areaPVS + sourceAreas[i] * areaVisBytes); // RB: 64 bit fixes, changed long to int
pvs = reinterpret_cast<long*>(currentPVS[handle.i].pvs); vis = reinterpret_cast<int*>(areaPVS + sourceAreas[i] * areaVisBytes);
pvs = reinterpret_cast<int*>(currentPVS[handle.i].pvs);
// RB end
for ( j = 0; j < areaVisLongs; j++ ) { for ( j = 0; j < areaVisLongs; j++ ) {
*pvs++ |= *vis++; *pvs++ |= *vis++;
} }
@ -1074,7 +1094,9 @@ idPVS::MergeCurrentPVS
*/ */
pvsHandle_t idPVS::MergeCurrentPVS( pvsHandle_t pvs1, pvsHandle_t pvs2 ) const { pvsHandle_t idPVS::MergeCurrentPVS( pvsHandle_t pvs1, pvsHandle_t pvs2 ) const {
int i; int i;
long *pvs1Ptr, *pvs2Ptr, *ptr; // RB: 64 bit fixes, changed long to int
int *pvs1Ptr, *pvs2Ptr, *ptr;
// RB end
pvsHandle_t handle; pvsHandle_t handle;
if ( pvs1.i < 0 || pvs1.i >= MAX_CURRENT_PVS || pvs1.h != currentPVS[pvs1.i].handle.h || if ( pvs1.i < 0 || pvs1.i >= MAX_CURRENT_PVS || pvs1.h != currentPVS[pvs1.i].handle.h ||
@ -1084,9 +1106,11 @@ pvsHandle_t idPVS::MergeCurrentPVS( pvsHandle_t pvs1, pvsHandle_t pvs2 ) const {
handle = AllocCurrentPVS( pvs1.h ^ pvs2.h ); handle = AllocCurrentPVS( pvs1.h ^ pvs2.h );
ptr = reinterpret_cast<long*>(currentPVS[handle.i].pvs); // RB: 64 bit fixes, changed long to int
pvs1Ptr = reinterpret_cast<long*>(currentPVS[pvs1.i].pvs); ptr = reinterpret_cast<int*>(currentPVS[handle.i].pvs);
pvs2Ptr = reinterpret_cast<long*>(currentPVS[pvs2.i].pvs); pvs1Ptr = reinterpret_cast<int*>(currentPVS[pvs1.i].pvs);
pvs2Ptr = reinterpret_cast<int*>(currentPVS[pvs2.i].pvs);
// RB end
for ( i = 0; i < areaVisLongs; i++ ) { for ( i = 0; i < areaVisLongs; i++ ) {
*ptr++ = *pvs1Ptr++ | *pvs2Ptr++; *ptr++ = *pvs1Ptr++ | *pvs2Ptr++;

View file

@ -167,7 +167,9 @@ void idAASLocal::CalculateAreaTravelTimes(void) {
} }
} }
assert( ( (unsigned int) bytePtr - (unsigned int) areaTravelTimes ) <= numAreaTravelTimes * sizeof( unsigned short ) ); // RB: 64 bit fixes, changed unsigned int to ptrdiff_t
assert( ( (ptrdiff_t) bytePtr - (ptrdiff_t) areaTravelTimes ) <= numAreaTravelTimes * sizeof( unsigned short ) );
// RB end
} }
/* /*

File diff suppressed because it is too large Load diff

View file

@ -4,7 +4,7 @@
Doom 3 GPL Source Code Doom 3 GPL Source Code
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company. Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?). This file is part of the Doom 3 GPL Source Code ("Doom 3 Source Code").
Doom 3 Source Code is free software: you can redistribute it and/or modify Doom 3 Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -394,7 +394,7 @@ void idClass::Init( void ) {
// is a subclass of another // is a subclass of another
num = 0; num = 0;
for( c = classHierarchy.GetNext(); c != NULL; c = c->node.GetNext(), num++ ) { for( c = classHierarchy.GetNext(); c != NULL; c = c->node.GetNext(), num++ ) {
c->typeNum = num; c->typeNum = num;
c->lastChild += num; c->lastChild += num;
} }
@ -504,7 +504,7 @@ void idClass::operator delete( void *ptr ) {
p = ( ( int * )ptr ) - 1; p = ( ( int * )ptr ) - 1;
memused -= *p; memused -= *p;
numobjects--; numobjects--;
Mem_Free( p ); Mem_Free( p );
} }
} }
@ -515,7 +515,7 @@ void idClass::operator delete( void *ptr, int, int, char *, int ) {
p = ( ( int * )ptr ) - 1; p = ( ( int * )ptr ) - 1;
memused -= *p; memused -= *p;
numobjects--; numobjects--;
Mem_Free( p ); Mem_Free( p );
} }
} }
@ -828,7 +828,7 @@ idClass::ProcessEventArgs
bool idClass::ProcessEventArgs( const idEventDef *ev, int numargs, ... ) { bool idClass::ProcessEventArgs( const idEventDef *ev, int numargs, ... ) {
idTypeInfo *c; idTypeInfo *c;
int num; int num;
int data[ D_EVENT_MAXARGS ]; intptr_t data[ D_EVENT_MAXARGS ];
va_list args; va_list args;
assert( ev ); assert( ev );
@ -936,7 +936,7 @@ bool idClass::ProcessEvent( const idEventDef *ev, idEventArg arg1, idEventArg ar
idClass::ProcessEventArgPtr idClass::ProcessEventArgPtr
================ ================
*/ */
bool idClass::ProcessEventArgPtr( const idEventDef *ev, int *data ) { bool idClass::ProcessEventArgPtr( const idEventDef *ev, intptr_t *data ) {
idTypeInfo *c; idTypeInfo *c;
int num; int num;
eventCallback_t callback; eventCallback_t callback;
@ -990,42 +990,42 @@ http://developer.apple.com/documentation/DeveloperTools/Conceptual/MachORuntime/
break; break;
case 1 : case 1 :
typedef void ( idClass::*eventCallback_1_t )( const int ); typedef void ( idClass::*eventCallback_1_t )( const intptr_t );
( this->*( eventCallback_1_t )callback )( data[ 0 ] ); ( this->*( eventCallback_1_t )callback )( data[ 0 ] );
break; break;
case 2 : case 2 :
typedef void ( idClass::*eventCallback_2_t )( const int, const int ); typedef void ( idClass::*eventCallback_2_t )( const intptr_t, const intptr_t );
( this->*( eventCallback_2_t )callback )( data[ 0 ], data[ 1 ] ); ( this->*( eventCallback_2_t )callback )( data[ 0 ], data[ 1 ] );
break; break;
case 3 : case 3 :
typedef void ( idClass::*eventCallback_3_t )( const int, const int, const int ); typedef void ( idClass::*eventCallback_3_t )( const intptr_t, const intptr_t, const intptr_t );
( this->*( eventCallback_3_t )callback )( data[ 0 ], data[ 1 ], data[ 2 ] ); ( this->*( eventCallback_3_t )callback )( data[ 0 ], data[ 1 ], data[ 2 ] );
break; break;
case 4 : case 4 :
typedef void ( idClass::*eventCallback_4_t )( const int, const int, const int, const int ); typedef void ( idClass::*eventCallback_4_t )( const intptr_t, const intptr_t, const intptr_t, const intptr_t );
( this->*( eventCallback_4_t )callback )( data[ 0 ], data[ 1 ], data[ 2 ], data[ 3 ] ); ( this->*( eventCallback_4_t )callback )( data[ 0 ], data[ 1 ], data[ 2 ], data[ 3 ] );
break; break;
case 5 : case 5 :
typedef void ( idClass::*eventCallback_5_t )( const int, const int, const int, const int, const int ); typedef void ( idClass::*eventCallback_5_t )( const intptr_t, const intptr_t, const intptr_t, const intptr_t, const intptr_t );
( this->*( eventCallback_5_t )callback )( data[ 0 ], data[ 1 ], data[ 2 ], data[ 3 ], data[ 4 ] ); ( this->*( eventCallback_5_t )callback )( data[ 0 ], data[ 1 ], data[ 2 ], data[ 3 ], data[ 4 ] );
break; break;
case 6 : case 6 :
typedef void ( idClass::*eventCallback_6_t )( const int, const int, const int, const int, const int, const int ); typedef void ( idClass::*eventCallback_6_t )( const intptr_t, const intptr_t, const intptr_t, const intptr_t, const intptr_t, const intptr_t );
( this->*( eventCallback_6_t )callback )( data[ 0 ], data[ 1 ], data[ 2 ], data[ 3 ], data[ 4 ], data[ 5 ] ); ( this->*( eventCallback_6_t )callback )( data[ 0 ], data[ 1 ], data[ 2 ], data[ 3 ], data[ 4 ], data[ 5 ] );
break; break;
case 7 : case 7 :
typedef void ( idClass::*eventCallback_7_t )( const int, const int, const int, const int, const int, const int, const int ); typedef void ( idClass::*eventCallback_7_t )( const intptr_t, const intptr_t, const intptr_t, const intptr_t, const intptr_t, const intptr_t, const intptr_t );
( this->*( eventCallback_7_t )callback )( data[ 0 ], data[ 1 ], data[ 2 ], data[ 3 ], data[ 4 ], data[ 5 ], data[ 6 ] ); ( this->*( eventCallback_7_t )callback )( data[ 0 ], data[ 1 ], data[ 2 ], data[ 3 ], data[ 4 ], data[ 5 ], data[ 6 ] );
break; break;
case 8 : case 8 :
typedef void ( idClass::*eventCallback_8_t )( const int, const int, const int, const int, const int, const int, const int, const int ); typedef void ( idClass::*eventCallback_8_t )( const intptr_t, const intptr_t, const intptr_t, const intptr_t, const intptr_t, const intptr_t, const intptr_t, const intptr_t );
( this->*( eventCallback_8_t )callback )( data[ 0 ], data[ 1 ], data[ 2 ], data[ 3 ], data[ 4 ], data[ 5 ], data[ 6 ], data[ 7 ] ); ( this->*( eventCallback_8_t )callback )( data[ 0 ], data[ 1 ], data[ 2 ], data[ 3 ], data[ 4 ], data[ 5 ], data[ 6 ], data[ 7 ] );
break; break;

View file

@ -4,7 +4,7 @@
Doom 3 GPL Source Code Doom 3 GPL Source Code
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company. Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?). This file is part of the Doom 3 GPL Source Code ("Doom 3 Source Code").
Doom 3 Source Code is free software: you can redistribute it and/or modify Doom 3 Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -57,16 +57,16 @@ struct idEventFunc {
class idEventArg { class idEventArg {
public: public:
int type; int type;
int value; intptr_t value;
idEventArg() { type = D_EVENT_INTEGER; value = 0; }; idEventArg() { type = D_EVENT_INTEGER; value = 0; };
idEventArg( int data ) { type = D_EVENT_INTEGER; value = data; }; idEventArg( int data ) { type = D_EVENT_INTEGER; value = data; };
idEventArg( float data ) { type = D_EVENT_FLOAT; value = *reinterpret_cast<int *>( &data ); }; idEventArg( float data ) { type = D_EVENT_FLOAT; value = *reinterpret_cast<int *>( &data ); };
idEventArg( idVec3 &data ) { type = D_EVENT_VECTOR; value = reinterpret_cast<int>( &data ); }; idEventArg( idVec3 &data ) { type = D_EVENT_VECTOR; value = reinterpret_cast<intptr_t>( &data ); };
idEventArg( const idStr &data ) { type = D_EVENT_STRING; value = reinterpret_cast<int>( data.c_str() ); }; idEventArg( const idStr &data ) { type = D_EVENT_STRING; value = reinterpret_cast<intptr_t>( data.c_str() ); };
idEventArg( const char *data ) { type = D_EVENT_STRING; value = reinterpret_cast<int>( data ); }; idEventArg( const char *data ) { type = D_EVENT_STRING; value = reinterpret_cast<intptr_t>( data ); };
idEventArg( const class idEntity *data ) { type = D_EVENT_ENTITY; value = reinterpret_cast<int>( data ); }; idEventArg( const class idEntity *data ) { type = D_EVENT_ENTITY; value = reinterpret_cast<intptr_t>( data ); };
idEventArg( const struct trace_s *data ) { type = D_EVENT_TRACE; value = reinterpret_cast<int>( data ); }; idEventArg( const struct trace_s *data ) { type = D_EVENT_TRACE; value = reinterpret_cast<intptr_t>( data ); };
}; };
class idAllocError : public idException { class idAllocError : public idException {
@ -230,7 +230,7 @@ public:
bool ProcessEvent( const idEventDef *ev, idEventArg arg1, idEventArg arg2, idEventArg arg3, idEventArg arg4, idEventArg arg5, idEventArg arg6, idEventArg arg7 ); bool ProcessEvent( const idEventDef *ev, idEventArg arg1, idEventArg arg2, idEventArg arg3, idEventArg arg4, idEventArg arg5, idEventArg arg6, idEventArg arg7 );
bool ProcessEvent( const idEventDef *ev, idEventArg arg1, idEventArg arg2, idEventArg arg3, idEventArg arg4, idEventArg arg5, idEventArg arg6, idEventArg arg7, idEventArg arg8 ); bool ProcessEvent( const idEventDef *ev, idEventArg arg1, idEventArg arg2, idEventArg arg3, idEventArg arg4, idEventArg arg5, idEventArg arg6, idEventArg arg7, idEventArg arg8 );
bool ProcessEventArgPtr( const idEventDef *ev, int *data ); bool ProcessEventArgPtr( const idEventDef *ev, intptr_t *data );
void CancelEvents( const idEventDef *ev ); void CancelEvents( const idEventDef *ev );
void Event_Remove( void ); void Event_Remove( void );

View file

@ -4,7 +4,7 @@
Doom 3 GPL Source Code Doom 3 GPL Source Code
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company. Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?). This file is part of the Doom 3 GPL Source Code ("Doom 3 Source Code").
Doom 3 Source Code is free software: you can redistribute it and/or modify Doom 3 Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -92,15 +92,15 @@ idEventDef::idEventDef( const char *command, const char *formatspec, char return
switch( formatspec[ i ] ) { switch( formatspec[ i ] ) {
case D_EVENT_FLOAT : case D_EVENT_FLOAT :
bits |= 1 << i; bits |= 1 << i;
argsize += sizeof( float ); argsize += sizeof( intptr_t );
break; break;
case D_EVENT_INTEGER : case D_EVENT_INTEGER :
argsize += sizeof( int ); argsize += sizeof( intptr_t );
break; break;
case D_EVENT_VECTOR : case D_EVENT_VECTOR :
argsize += sizeof( idVec3 ); argsize += E_EVENT_SIZEOF_VEC;
break; break;
case D_EVENT_STRING : case D_EVENT_STRING :
@ -331,7 +331,7 @@ idEvent *idEvent::Alloc( const idEventDef *evdef, int numargs, va_list args ) {
idEvent::CopyArgs idEvent::CopyArgs
================ ================
*/ */
void idEvent::CopyArgs( const idEventDef *evdef, int numargs, va_list args, int data[ D_EVENT_MAXARGS ] ) { void idEvent::CopyArgs( const idEventDef *evdef, int numargs, va_list args, intptr_t data[ D_EVENT_MAXARGS ] ) {
int i; int i;
const char *format; const char *format;
idEventArg *arg; idEventArg *arg;
@ -460,7 +460,7 @@ idEvent::ServiceEvents
void idEvent::ServiceEvents( void ) { void idEvent::ServiceEvents( void ) {
idEvent *event; idEvent *event;
int num; int num;
int args[ D_EVENT_MAXARGS ]; intptr_t args[ D_EVENT_MAXARGS ];
int offset; int offset;
int i; int i;
int numargs; int numargs;
@ -850,7 +850,7 @@ void CreateEventCallbackHandler( void ) {
string1 += "const float"; string1 += "const float";
string2 += va( "*( float * )&data[ %d ]", k ); string2 += va( "*( float * )&data[ %d ]", k );
} else { } else {
string1 += "const int"; string1 += "const intptr_t";
string2 += va( "data[ %d ]", k ); string2 += va( "data[ %d ]", k );
} }

View file

@ -4,7 +4,7 @@
Doom 3 GPL Source Code Doom 3 GPL Source Code
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company. Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?). This file is part of the Doom 3 GPL Source Code ("Doom 3 Source Code").
Doom 3 Source Code is free software: you can redistribute it and/or modify Doom 3 Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -36,6 +36,9 @@ Event are used for scheduling tasks and for linking script commands.
#define D_EVENT_MAXARGS 8 // if changed, enable the CREATE_EVENT_CODE define in Event.cpp to generate switch statement for idClass::ProcessEventArgPtr. #define D_EVENT_MAXARGS 8 // if changed, enable the CREATE_EVENT_CODE define in Event.cpp to generate switch statement for idClass::ProcessEventArgPtr.
// running the game will then generate c:\doom\base\events.txt, the contents of which should be copied into the switch statement. // running the game will then generate c:\doom\base\events.txt, the contents of which should be copied into the switch statement.
// stack size of idVec3, aligned to native pointer size
#define E_EVENT_SIZEOF_VEC ((sizeof(idVec3) + (sizeof(intptr_t) - 1)) & ~(sizeof(intptr_t) - 1))
#define D_EVENT_VOID ( ( char )0 ) #define D_EVENT_VOID ( ( char )0 )
#define D_EVENT_INTEGER 'd' #define D_EVENT_INTEGER 'd'
#define D_EVENT_FLOAT 'f' #define D_EVENT_FLOAT 'f'
@ -104,7 +107,7 @@ public:
~idEvent(); ~idEvent();
static idEvent *Alloc( const idEventDef *evdef, int numargs, va_list args ); static idEvent *Alloc( const idEventDef *evdef, int numargs, va_list args );
static void CopyArgs( const idEventDef *evdef, int numargs, va_list args, int data[ D_EVENT_MAXARGS ] ); static void CopyArgs( const idEventDef *evdef, int numargs, va_list args, intptr_t data[ D_EVENT_MAXARGS ] );
void Free( void ); void Free( void );
void Schedule( idClass *object, const idTypeInfo *cls, int time ); void Schedule( idClass *object, const idTypeInfo *cls, int time );

View file

@ -563,7 +563,9 @@ int idTypeInfoTools::WriteVariable_r( const void *varPtr, const char *varName, c
// if this is a pointer // if this is a pointer
isPointer = 0; isPointer = 0;
for ( i = typeString.Length(); i > 0 && typeString[i - 1] == '*'; i -= 2 ) { for ( i = typeString.Length(); i > 0 && typeString[i - 1] == '*'; i -= 2 ) {
if ( varPtr == (void *)0xcdcdcdcd || ( varPtr != NULL && *((unsigned long *)varPtr) == 0xcdcdcdcd ) ) { // flibit: 64 bit fix, changed long to int
if ( varPtr == (void *)0xcdcdcdcd || ( varPtr != NULL && *((unsigned int *)varPtr) == 0xcdcdcdcd ) ) {
// flibit end
common->Warning( "%s%s::%s%s references uninitialized memory", prefix, scope, varName, "" ); common->Warning( "%s%s::%s%s references uninitialized memory", prefix, scope, varName, "" );
return typeSize; return typeSize;
} }
@ -1129,7 +1131,9 @@ int idTypeInfoTools::WriteVariable_r( const void *varPtr, const char *varName, c
i = 0; i = 0;
do { do {
if ( *((unsigned long *)varPtr) == 0xcdcdcdcd ) { // flibit: 64 bit fix, changed long to int
if ( *((unsigned int *)varPtr) == 0xcdcdcdcd ) {
// flibit end
common->Warning( "%s%s::%s%s uses uninitialized memory", prefix, scope, varName, "" ); common->Warning( "%s%s::%s%s uses uninitialized memory", prefix, scope, varName, "" );
break; break;
} }

View file

@ -745,7 +745,7 @@ void idInterpreter::CallEvent( const function_t *func, int argsize ) {
switch( format[ i ] ) { switch( format[ i ] ) {
case D_EVENT_INTEGER : case D_EVENT_INTEGER :
var.intPtr = ( int * )&localstack[ start + pos ]; var.intPtr = ( int * )&localstack[ start + pos ];
data[ i ] = int( *var.floatPtr ); ( *( int * )&data[ i ] ) = int( *var.floatPtr );
break; break;
case D_EVENT_FLOAT : case D_EVENT_FLOAT :

View file

@ -4,7 +4,7 @@
Doom 3 GPL Source Code Doom 3 GPL Source Code
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company. Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?). This file is part of the Doom 3 GPL Source Code ("Doom 3 Source Code").
Doom 3 Source Code is free software: you can redistribute it and/or modify Doom 3 Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -33,20 +33,20 @@ If you have questions concerning this license or the applicable additional terms
// simple types. function types are dynamically allocated // simple types. function types are dynamically allocated
idTypeDef type_void( ev_void, &def_void, "void", 0, NULL ); idTypeDef type_void( ev_void, &def_void, "void", 0, NULL );
idTypeDef type_scriptevent( ev_scriptevent, &def_scriptevent, "scriptevent", sizeof( void * ), NULL ); idTypeDef type_scriptevent( ev_scriptevent, &def_scriptevent, "scriptevent", sizeof( intptr_t ), NULL );
idTypeDef type_namespace( ev_namespace, &def_namespace, "namespace", sizeof( void * ), NULL ); idTypeDef type_namespace( ev_namespace, &def_namespace, "namespace", sizeof( intptr_t ), NULL );
idTypeDef type_string( ev_string, &def_string, "string", MAX_STRING_LEN, NULL ); idTypeDef type_string( ev_string, &def_string, "string", MAX_STRING_LEN, NULL );
idTypeDef type_float( ev_float, &def_float, "float", sizeof( float ), NULL ); idTypeDef type_float( ev_float, &def_float, "float", sizeof( intptr_t ), NULL );
idTypeDef type_vector( ev_vector, &def_vector, "vector", sizeof( idVec3 ), NULL ); idTypeDef type_vector( ev_vector, &def_vector, "vector", E_EVENT_SIZEOF_VEC, NULL );
idTypeDef type_entity( ev_entity, &def_entity, "entity", sizeof( int * ), NULL ); // stored as entity number pointer idTypeDef type_entity( ev_entity, &def_entity, "entity", sizeof( intptr_t ), NULL ); // stored as entity number pointer
idTypeDef type_field( ev_field, &def_field, "field", sizeof( void * ), NULL ); idTypeDef type_field( ev_field, &def_field, "field", sizeof( intptr_t ), NULL );
idTypeDef type_function( ev_function, &def_function, "function", sizeof( void * ), &type_void ); idTypeDef type_function( ev_function, &def_function, "function", sizeof( intptr_t ), &type_void );
idTypeDef type_virtualfunction( ev_virtualfunction, &def_virtualfunction, "virtual function", sizeof( int ), NULL ); idTypeDef type_virtualfunction( ev_virtualfunction, &def_virtualfunction, "virtual function", sizeof( intptr_t ), NULL );
idTypeDef type_pointer( ev_pointer, &def_pointer, "pointer", sizeof( void * ), NULL ); idTypeDef type_pointer( ev_pointer, &def_pointer, "pointer", sizeof( intptr_t ), NULL );
idTypeDef type_object( ev_object, &def_object, "object", sizeof( int * ), NULL ); // stored as entity number pointer idTypeDef type_object( ev_object, &def_object, "object", sizeof( intptr_t ), NULL ); // stored as entity number pointer
idTypeDef type_jumpoffset( ev_jumpoffset, &def_jumpoffset, "<jump>", sizeof( int ), NULL ); // only used for jump opcodes idTypeDef type_jumpoffset( ev_jumpoffset, &def_jumpoffset, "<jump>", sizeof( intptr_t ), NULL ); // only used for jump opcodes
idTypeDef type_argsize( ev_argsize, &def_argsize, "<argsize>", sizeof( int ), NULL ); // only used for function call and thread opcodes idTypeDef type_argsize( ev_argsize, &def_argsize, "<argsize>", sizeof( intptr_t ), NULL ); // only used for function call and thread opcodes
idTypeDef type_boolean( ev_boolean, &def_boolean, "boolean", sizeof( int ), NULL ); idTypeDef type_boolean( ev_boolean, &def_boolean, "boolean", sizeof( intptr_t ), NULL );
idVarDef def_void( &type_void ); idVarDef def_void( &type_void );
idVarDef def_scriptevent( &type_scriptevent ); idVarDef def_scriptevent( &type_scriptevent );
@ -795,7 +795,7 @@ void idVarDef::PrintInfo( idFile *file, int instructionPointer ) const {
break; break;
case ev_float : case ev_float :
file->Printf( "%f", *value.floatPtr ); file->Printf( "%f", *value.floatPtr );
break; break;
case ev_virtualfunction : case ev_virtualfunction :
@ -898,7 +898,7 @@ idScriptObject::Save
================ ================
*/ */
void idScriptObject::Save( idSaveGame *savefile ) const { void idScriptObject::Save( idSaveGame *savefile ) const {
size_t size; int size;
if ( type == &type_object && data == NULL ) { if ( type == &type_object && data == NULL ) {
// Write empty string for uninitialized object // Write empty string for uninitialized object
@ -918,7 +918,7 @@ idScriptObject::Restore
*/ */
void idScriptObject::Restore( idRestoreGame *savefile ) { void idScriptObject::Restore( idRestoreGame *savefile ) {
idStr typeName; idStr typeName;
size_t size; int size;
savefile->ReadString( typeName ); savefile->ReadString( typeName );
@ -931,7 +931,7 @@ void idScriptObject::Restore( idRestoreGame *savefile ) {
savefile->Error( "idScriptObject::Restore: failed to restore object of type '%s'.", typeName.c_str() ); savefile->Error( "idScriptObject::Restore: failed to restore object of type '%s'.", typeName.c_str() );
} }
savefile->ReadInt( (int &)size ); savefile->ReadInt( size );
if ( size != type->Size() ) { if ( size != type->Size() ) {
savefile->Error( "idScriptObject::Restore: size of object '%s' doesn't match size in save game.", typeName.c_str() ); savefile->Error( "idScriptObject::Restore: size of object '%s' doesn't match size in save game.", typeName.c_str() );
} }
@ -1226,6 +1226,44 @@ void idProgram::AddDefToNameList( idVarDef *def, const char *name ) {
varDefNames[i]->AddDef( def ); varDefNames[i]->AddDef( def );
} }
/*
==============
idProgram::ReserveMem
reserves memory for global variables and returns the starting pointer
==============
*/
byte *idProgram::ReserveMem(int size) {
byte *res = &variables[ numVariables ];
numVariables += size;
if ( numVariables > sizeof( variables ) ) {
throw idCompileError( va( "Exceeded global memory size (%d bytes)", sizeof( variables ) ) );
}
memset( res, 0, size );
return res;
}
/*
============
idProgram::AllocVarDef
============
*/
idVarDef *idProgram::AllocVarDef(idTypeDef *type, const char *name, idVarDef *scope) {
idVarDef *def;
def = new idVarDef( type );
def->scope = scope;
def->numUsers = 1;
def->num = varDefs.Append( def );
// add the def to the list with defs with this name and set the name pointer
AddDefToNameList( def, name );
return def;
}
/* /*
============ ============
idProgram::AllocDef idProgram::AllocDef
@ -1239,13 +1277,7 @@ idVarDef *idProgram::AllocDef( idTypeDef *type, const char *name, idVarDef *scop
idVarDef *def_z; idVarDef *def_z;
// allocate a new def // allocate a new def
def = new idVarDef( type ); def = AllocVarDef(type, name, scope);
def->scope = scope;
def->numUsers = 1;
def->num = varDefs.Append( def );
// add the def to the list with defs with this name and set the name pointer
AddDefToNameList( def, name );
if ( ( type->Type() == ev_vector ) || ( ( type->Type() == ev_field ) && ( type->FieldType()->Type() == ev_vector ) ) ) { if ( ( type->Type() == ev_vector ) || ( ( type->Type() == ev_field ) && ( type->FieldType()->Type() == ev_vector ) ) ) {
// //
@ -1259,7 +1291,7 @@ idVarDef *idProgram::AllocDef( idTypeDef *type, const char *name, idVarDef *scop
scope->value.functionPtr->locals += type->Size(); scope->value.functionPtr->locals += type->Size();
} else if ( scope->TypeDef()->Inherits( &type_object ) ) { } else if ( scope->TypeDef()->Inherits( &type_object ) ) {
idTypeDef newtype( ev_field, NULL, "float field", 0, &type_float ); idTypeDef newtype( ev_field, NULL, "float field", 0, &type_float );
idTypeDef *type = GetType( newtype, true ); idTypeDef *ftype = GetType( newtype, true );
// set the value to the variable's position in the object // set the value to the variable's position in the object
def->value.ptrOffset = scope->TypeDef()->Size(); def->value.ptrOffset = scope->TypeDef()->Size();
@ -1267,30 +1299,52 @@ idVarDef *idProgram::AllocDef( idTypeDef *type, const char *name, idVarDef *scop
// make automatic defs for the vectors elements // make automatic defs for the vectors elements
// origin can be accessed as origin_x, origin_y, and origin_z // origin can be accessed as origin_x, origin_y, and origin_z
sprintf( element, "%s_x", def->Name() ); sprintf( element, "%s_x", def->Name() );
def_x = AllocDef( type, element, scope, constant ); def_x = AllocDef( ftype, element, scope, constant );
sprintf( element, "%s_y", def->Name() ); sprintf( element, "%s_y", def->Name() );
def_y = AllocDef( type, element, scope, constant ); def_y = AllocDef( ftype, element, scope, constant );
def_y->value.ptrOffset = def_x->value.ptrOffset + type_float.Size(); def_y->value.ptrOffset = def_x->value.ptrOffset + sizeof(float);
sprintf( element, "%s_z", def->Name() ); sprintf( element, "%s_z", def->Name() );
def_z = AllocDef( type, element, scope, constant ); def_z = AllocDef( ftype, element, scope, constant );
def_z->value.ptrOffset = def_y->value.ptrOffset + type_float.Size(); def_z->value.ptrOffset = def_y->value.ptrOffset + sizeof(float);
} else { } else {
idTypeDef newtype( ev_float, &def_float, "vector float", 0, NULL );
idTypeDef *ftype = GetType( newtype, true );
// make automatic defs for the vectors elements // make automatic defs for the vectors elements
// origin can be accessed as origin_x, origin_y, and origin_z // origin can be accessed as origin_x, origin_y, and origin_z
sprintf( element, "%s_x", def->Name() ); sprintf( element, "%s_x", def->Name() );
def_x = AllocDef( &type_float, element, scope, constant ); def_x = AllocVarDef( ftype, element, scope );
sprintf( element, "%s_y", def->Name() ); sprintf( element, "%s_y", def->Name() );
def_y = AllocDef( &type_float, element, scope, constant ); def_y = AllocVarDef( ftype, element, scope );
sprintf( element, "%s_z", def->Name() ); sprintf( element, "%s_z", def->Name() );
def_z = AllocDef( &type_float, element, scope, constant ); def_z = AllocVarDef( ftype, element, scope );
// point the vector def to the x coordinate // get the memory for the full vector and point the _x, _y and _z
def->value = def_x->value; // defs at the vector member offsets
def->initialized = def_x->initialized; if ( scope->Type() == ev_function ) {
// vector on stack
def->value.stackOffset = scope->value.functionPtr->locals;
def->initialized = idVarDef::stackVariable;
scope->value.functionPtr->locals += type->Size();
def_x->value.stackOffset = def->value.stackOffset;
def_y->value.stackOffset = def_x->value.stackOffset + sizeof(float);
def_z->value.stackOffset = def_y->value.stackOffset + sizeof(float);
} else {
// global vector
def->value.bytePtr = ReserveMem(type->Size());
def_x->value.bytePtr = def->value.bytePtr;
def_y->value.bytePtr = def_x->value.bytePtr + sizeof(float);
def_z->value.bytePtr = def_y->value.bytePtr + sizeof(float);
}
def_x->initialized = def->initialized;
def_y->initialized = def->initialized;
def_z->initialized = def->initialized;
} }
} else if ( scope->TypeDef()->Inherits( &type_object ) ) { } else if ( scope->TypeDef()->Inherits( &type_object ) ) {
// //
@ -1317,13 +1371,7 @@ idVarDef *idProgram::AllocDef( idTypeDef *type, const char *name, idVarDef *scop
// //
// global variable // global variable
// //
def->value.bytePtr = &variables[ numVariables ]; def->value.bytePtr = ReserveMem(def->TypeDef()->Size());
numVariables += def->TypeDef()->Size();
if ( numVariables > sizeof( variables ) ) {
throw idCompileError( va( "Exceeded global memory size (%d bytes)", sizeof( variables ) ) );
}
memset( def->value.bytePtr, 0, def->TypeDef()->Size() );
} }
return def; return def;
@ -1597,7 +1645,7 @@ void idProgram::BeginCompilation( void ) {
// make the first statement a return for a "NULL" function // make the first statement a return for a "NULL" function
statement = AllocStatement(); statement = AllocStatement();
statement->linenumber = 0; statement->linenumber = 0;
statement->file = 0; statement->file = 0;
statement->op = OP_RETURN; statement->op = OP_RETURN;
statement->a = NULL; statement->a = NULL;
statement->b = NULL; statement->b = NULL;
@ -1627,7 +1675,7 @@ idProgram::DisassembleStatement
============== ==============
*/ */
void idProgram::DisassembleStatement( idFile *file, int instructionPointer ) const { void idProgram::DisassembleStatement( idFile *file, int instructionPointer ) const {
opcode_t *op; const opcode_t *op;
const statement_t *statement; const statement_t *statement;
statement = &statements[ instructionPointer ]; statement = &statements[ instructionPointer ];
@ -1718,7 +1766,6 @@ called after all files are compiled to report memory usage.
void idProgram::CompileStats( void ) { void idProgram::CompileStats( void ) {
int memused; int memused;
int memallocated; int memallocated;
int numdefs;
int stringspace; int stringspace;
int funcMem; int funcMem;
int i; int i;
@ -1733,7 +1780,6 @@ void idProgram::CompileStats( void ) {
} }
stringspace += fileList.Size(); stringspace += fileList.Size();
numdefs = varDefs.Num();
memused = varDefs.Num() * sizeof( idVarDef ); memused = varDefs.Num() * sizeof( idVarDef );
memused += types.Num() * sizeof( idTypeDef ); memused += types.Num() * sizeof( idTypeDef );
memused += stringspace; memused += stringspace;

View file

@ -4,7 +4,7 @@
Doom 3 GPL Source Code Doom 3 GPL Source Code
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company. Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?). This file is part of the Doom 3 GPL Source Code ("Doom 3 Source Code").
Doom 3 Source Code is free software: you can redistribute it and/or modify Doom 3 Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -58,16 +58,16 @@ public:
void Clear( void ); void Clear( void );
private: private:
idStr name; idStr name;
public: public:
const idEventDef *eventdef; const idEventDef *eventdef;
idVarDef *def; idVarDef *def;
const idTypeDef *type; const idTypeDef *type;
int firstStatement; int firstStatement;
int numStatements; int numStatements;
int parmTotal; int parmTotal;
int locals; // total ints of parms + locals int locals; // total ints of parms + locals
int filenum; // source file defined in int filenum; // source file defined in
idList<int> parmSize; idList<int> parmSize;
}; };
@ -76,8 +76,8 @@ typedef union eval_s {
float _float; float _float;
float vector[ 3 ]; float vector[ 3 ];
function_t *function; function_t *function;
int _int; int _int;
int entity; int entity;
} eval_t; } eval_t;
/*********************************************************************** /***********************************************************************
@ -91,7 +91,7 @@ Contains type information for variables and functions.
class idTypeDef { class idTypeDef {
private: private:
etype_t type; etype_t type;
idStr name; idStr name;
int size; int size;
// function types are more complex // function types are more complex
@ -295,9 +295,9 @@ typedef union varEval_s {
float *floatPtr; float *floatPtr;
idVec3 *vectorPtr; idVec3 *vectorPtr;
function_t *functionPtr; function_t *functionPtr;
int *intPtr; int *intPtr;
byte *bytePtr; byte *bytePtr;
int *entityNumberPtr; int *entityNumberPtr;
int virtualFunction; int virtualFunction;
int jumpOffset; int jumpOffset;
int stackOffset; // offset in stack for local variables int stackOffset; // offset in stack for local variables
@ -314,7 +314,7 @@ class idVarDef {
public: public:
int num; int num;
varEval_t value; varEval_t value;
idVarDef * scope; // function, namespace, or object the var was defined in idVarDef * scope; // function, namespace, or object the var was defined in
int numUsers; // number of users if this is a constant int numUsers; // number of users if this is a constant
typedef enum { typedef enum {
@ -434,7 +434,7 @@ single idProgram.
class idProgram { class idProgram {
private: private:
idStrList fileList; idStrList fileList;
idStr filename; idStr filename;
int filenum; int filenum;
int numVariables; int numVariables;
@ -456,6 +456,8 @@ private:
int top_files; int top_files;
void CompileStats( void ); void CompileStats( void );
byte *ReserveMem(int size);
idVarDef *AllocVarDef(idTypeDef *type, const char *name, idVarDef *scope);
public: public:
idVarDef *returnDef; idVarDef *returnDef;
@ -510,7 +512,7 @@ public:
statement_t &GetStatement( int index ); statement_t &GetStatement( int index );
int NumStatements( void ) { return statements.Num(); } int NumStatements( void ) { return statements.Num(); }
int GetReturnedInteger( void ); int GetReturnedInteger( void );
void ReturnFloat( float value ); void ReturnFloat( float value );
void ReturnInteger( int value ); void ReturnInteger( int value );

View file

@ -43,7 +43,9 @@ static const char sixtet_to_base64[] =
void idBase64::Encode( const byte *from, int size ) { void idBase64::Encode( const byte *from, int size ) {
int i, j; int i, j;
unsigned long w; // flibit: 64 bit fix, change long to int
unsigned int w;
// flibit end
byte *to; byte *to;
EnsureAlloced( 4*(size+3)/3 + 2 ); // ratio and padding + trailing \0 EnsureAlloced( 4*(size+3)/3 + 2 ); // ratio and padding + trailing \0
@ -93,7 +95,9 @@ idBase64::Decode
============ ============
*/ */
int idBase64::Decode( byte *to ) const { int idBase64::Decode( byte *to ) const {
unsigned long w; // flibit: 64 bit fix, change long to int
unsigned int w;
// flibit end
int i, j; int i, j;
size_t n; size_t n;
static char base64_to_sixtet[256]; static char base64_to_sixtet[256];

View file

@ -235,7 +235,9 @@ idDict::Checksum
================ ================
*/ */
int idDict::Checksum( void ) const { int idDict::Checksum( void ) const {
unsigned long ret; // RB: 64 bit fixes, changed long to int
unsigned int ret;
// RB end
int i, n; int i, n;
idList<idKeyValue> sorted = args; idList<idKeyValue> sorted = args;
@ -475,7 +477,9 @@ int idDict::FindKeyIndex( const char *key ) const {
if ( key == NULL || key[0] == '\0' ) { if ( key == NULL || key[0] == '\0' ) {
idLib::common->DWarning( "idDict::FindKeyIndex: empty key" ); idLib::common->DWarning( "idDict::FindKeyIndex: empty key" );
return NULL; // flibit: 64 bit fix, change NULL to 0
return 0;
// flibit end
} }
int hash = argHash.GenerateKey( key, false ); int hash = argHash.GenerateKey( key, false );

View file

@ -4,7 +4,7 @@
Doom 3 GPL Source Code Doom 3 GPL Source Code
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company. Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?). This file is part of the Doom 3 GPL Source Code ("Doom 3 Source Code").
Doom 3 Source Code is free software: you can redistribute it and/or modify Doom 3 Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -43,9 +43,9 @@ If you have questions concerning this license or the applicable additional terms
// //
//=============================================================== //===============================================================
#define SMALL_HEADER_SIZE ( (int) ( sizeof( byte ) + sizeof( byte ) ) ) #define SMALL_HEADER_SIZE ( (intptr_t) ( sizeof( byte ) + sizeof( byte ) ) )
#define MEDIUM_HEADER_SIZE ( (int) ( sizeof( mediumHeapEntry_s ) + sizeof( byte ) ) ) #define MEDIUM_HEADER_SIZE ( (intptr_t) ( sizeof( mediumHeapEntry_s ) + sizeof( byte ) ) )
#define LARGE_HEADER_SIZE ( (int) ( sizeof( dword * ) + sizeof( byte ) ) ) #define LARGE_HEADER_SIZE ( (intptr_t) ( sizeof( dword * ) + sizeof( byte ) ) )
#define ALIGN_SIZE( bytes ) ( ( (bytes) + ALIGN - 1 ) & ~(ALIGN - 1) ) #define ALIGN_SIZE( bytes ) ( ( (bytes) + ALIGN - 1 ) & ~(ALIGN - 1) )
#define SMALL_ALIGN( bytes ) ( ALIGN_SIZE( (bytes) + SMALL_HEADER_SIZE ) - SMALL_HEADER_SIZE ) #define SMALL_ALIGN( bytes ) ( ALIGN_SIZE( (bytes) + SMALL_HEADER_SIZE ) - SMALL_HEADER_SIZE )
@ -65,7 +65,7 @@ public:
dword Msize( void *p ); // return size of data block dword Msize( void *p ); // return size of data block
void Dump( void ); void Dump( void );
void AllocDefragBlock( void ); // hack for huge renderbumps void AllocDefragBlock( void ); // hack for huge renderbumps
private: private:
@ -305,7 +305,7 @@ void idHeap::Free( void *p ) {
break; break;
} }
default: { default: {
idLib::common->FatalError( "idHeap::Free: invalid memory block (%s)", idLib::sys->GetCallStackCurStr( 4 ) ); idLib::common->FatalError( "idHeap::Free: invalid memory block" );
break; break;
} }
} }
@ -320,24 +320,24 @@ idHeap::Allocate16
void *idHeap::Allocate16( const dword bytes ) { void *idHeap::Allocate16( const dword bytes ) {
byte *ptr, *alignedPtr; byte *ptr, *alignedPtr;
ptr = (byte *) malloc( bytes + 16 + 4 ); ptr = (byte *) malloc( bytes + 16 + sizeof(intptr_t) );
if ( !ptr ) { if ( !ptr ) {
if ( defragBlock ) { if ( defragBlock ) {
idLib::common->Printf( "Freeing defragBlock on alloc of %i.\n", bytes ); idLib::common->Printf( "Freeing defragBlock on alloc of %i.\n", bytes );
free( defragBlock ); free( defragBlock );
defragBlock = NULL; defragBlock = NULL;
ptr = (byte *) malloc( bytes + 16 + 4 ); ptr = (byte *) malloc( bytes + 16 + sizeof(intptr_t) );
AllocDefragBlock(); AllocDefragBlock();
} }
if ( !ptr ) { if ( !ptr ) {
common->FatalError( "malloc failure for %i", bytes ); common->FatalError( "malloc failure for %i", bytes );
} }
} }
alignedPtr = (byte *) ( ( (int) ptr ) + 15 & ~15 ); alignedPtr = (byte *) ( ( ( (intptr_t) ptr ) + 15) & ~15 );
if ( alignedPtr - ptr < 4 ) { if ( alignedPtr - ptr < sizeof(intptr_t) ) {
alignedPtr += 16; alignedPtr += 16;
} }
*((int *)(alignedPtr - 4)) = (int) ptr; *((intptr_t *)(alignedPtr - sizeof(intptr_t))) = (intptr_t) ptr;
return (void *) alignedPtr; return (void *) alignedPtr;
} }
@ -347,7 +347,7 @@ idHeap::Free16
================ ================
*/ */
void idHeap::Free16( void *p ) { void idHeap::Free16( void *p ) {
free( (void *) *((int *) (( (byte *) p ) - 4)) ); free( (void *) *((intptr_t *) (( (byte *) p ) - sizeof(intptr_t))) );
} }
/* /*
@ -381,10 +381,10 @@ dword idHeap::Msize( void *p ) {
return ((mediumHeapEntry_s *)(((byte *)(p)) - ALIGN_SIZE( MEDIUM_HEADER_SIZE )))->size - ALIGN_SIZE( MEDIUM_HEADER_SIZE ); return ((mediumHeapEntry_s *)(((byte *)(p)) - ALIGN_SIZE( MEDIUM_HEADER_SIZE )))->size - ALIGN_SIZE( MEDIUM_HEADER_SIZE );
} }
case LARGE_ALLOC: { case LARGE_ALLOC: {
return ((idHeap::page_s*)(*((dword *)(((byte *)p) - ALIGN_SIZE( LARGE_HEADER_SIZE )))))->dataSize - ALIGN_SIZE( LARGE_HEADER_SIZE ); return ((idHeap::page_s*)(*((intptr_t *)(((byte *)p) - ALIGN_SIZE( LARGE_HEADER_SIZE )))))->dataSize - ALIGN_SIZE( LARGE_HEADER_SIZE );
} }
default: { default: {
idLib::common->FatalError( "idHeap::Msize: invalid memory block (%s)", idLib::sys->GetCallStackCurStr( 4 ) ); idLib::common->FatalError( "idHeap::Msize: invalid memory block" );
return 0; return 0;
} }
} }
@ -489,7 +489,7 @@ idHeap::page_s* idHeap::AllocatePage( dword bytes ) {
} }
} }
p->data = (void *) ALIGN_SIZE( (int)((byte *)(p)) + sizeof( idHeap::page_s ) ); p->data = (void *) ALIGN_SIZE( (intptr_t)((byte *)(p)) + sizeof( idHeap::page_s ) );
p->dataSize = size - sizeof(idHeap::page_s); p->dataSize = size - sizeof(idHeap::page_s);
p->firstFree = NULL; p->firstFree = NULL;
p->largestFree = 0; p->largestFree = 0;
@ -542,8 +542,8 @@ idHeap::SmallAllocate
*/ */
void *idHeap::SmallAllocate( dword bytes ) { void *idHeap::SmallAllocate( dword bytes ) {
// we need the at least sizeof( dword ) bytes for the free list // we need the at least sizeof( dword ) bytes for the free list
if ( bytes < sizeof( dword ) ) { if ( bytes < sizeof( intptr_t ) ) {
bytes = sizeof( dword ); bytes = sizeof( intptr_t );
} }
// increase the number of bytes if necessary to make sure the next small allocation is aligned // increase the number of bytes if necessary to make sure the next small allocation is aligned
@ -551,13 +551,13 @@ void *idHeap::SmallAllocate( dword bytes ) {
byte *smallBlock = (byte *)(smallFirstFree[bytes / ALIGN]); byte *smallBlock = (byte *)(smallFirstFree[bytes / ALIGN]);
if ( smallBlock ) { if ( smallBlock ) {
dword *link = (dword *)(smallBlock + SMALL_HEADER_SIZE); intptr_t *link = (intptr_t *)(smallBlock + SMALL_HEADER_SIZE);
smallBlock[1] = SMALL_ALLOC; // allocation identifier smallBlock[1] = SMALL_ALLOC; // allocation identifier
smallFirstFree[bytes / ALIGN] = (void *)(*link); smallFirstFree[bytes / ALIGN] = (void *)(*link);
return (void *)(link); return (void *)(link);
} }
dword bytesLeft = (long)(pageSize) - smallCurPageOffset; dword bytesLeft = (size_t)(pageSize) - smallCurPageOffset;
// if we need to allocate a new page // if we need to allocate a new page
if ( bytes >= bytesLeft ) { if ( bytes >= bytesLeft ) {
@ -590,7 +590,7 @@ void idHeap::SmallFree( void *ptr ) {
((byte *)(ptr))[-1] = INVALID_ALLOC; ((byte *)(ptr))[-1] = INVALID_ALLOC;
byte *d = ( (byte *)ptr ) - SMALL_HEADER_SIZE; byte *d = ( (byte *)ptr ) - SMALL_HEADER_SIZE;
dword *dt = (dword *)ptr; intptr_t *link = (intptr_t *)ptr;
// index into the table with free small memory blocks // index into the table with free small memory blocks
dword ix = *d; dword ix = *d;
@ -599,7 +599,7 @@ void idHeap::SmallFree( void *ptr ) {
idLib::common->FatalError( "SmallFree: invalid memory block" ); idLib::common->FatalError( "SmallFree: invalid memory block" );
} }
*dt = (dword)smallFirstFree[ix]; // write next index *link = (intptr_t)smallFirstFree[ix]; // write next index
smallFirstFree[ix] = (void *)d; // link smallFirstFree[ix] = (void *)d; // link
} }
@ -731,7 +731,7 @@ void *idHeap::MediumAllocate( dword bytes ) {
data = MediumAllocateFromPage( p, sizeNeeded ); // allocate data from page data = MediumAllocateFromPage( p, sizeNeeded ); // allocate data from page
// if the page can no longer serve memory, move it away from free list // if the page can no longer serve memory, move it away from free list
// (so that it won't slow down the later alloc queries) // (so that it won't slow down the later alloc queries)
// this modification speeds up the pageWalk from O(N) to O(sqrt(N)) // this modification speeds up the pageWalk from O(N) to O(sqrt(N))
// a call to free may swap this page back to the free list // a call to free may swap this page back to the free list
@ -929,8 +929,8 @@ void *idHeap::LargeAllocate( dword bytes ) {
} }
byte * d = (byte*)(p->data) + ALIGN_SIZE( LARGE_HEADER_SIZE ); byte * d = (byte*)(p->data) + ALIGN_SIZE( LARGE_HEADER_SIZE );
dword * dw = (dword*)(d - ALIGN_SIZE( LARGE_HEADER_SIZE )); intptr_t * dw = (intptr_t*)(d - ALIGN_SIZE( LARGE_HEADER_SIZE ));
dw[0] = (dword)p; // write pointer back to page table dw[0] = (intptr_t)p; // write pointer back to page table
d[-1] = LARGE_ALLOC; // allocation identifier d[-1] = LARGE_ALLOC; // allocation identifier
// link to 'large used page list' // link to 'large used page list'
@ -958,7 +958,7 @@ void idHeap::LargeFree( void *ptr) {
((byte *)(ptr))[-1] = INVALID_ALLOC; ((byte *)(ptr))[-1] = INVALID_ALLOC;
// get page pointer // get page pointer
pg = (idHeap::page_s *)(*((dword *)(((byte *)ptr) - ALIGN_SIZE( LARGE_HEADER_SIZE )))); pg = (idHeap::page_s *)(*((intptr_t *)(((byte *)ptr) - ALIGN_SIZE( LARGE_HEADER_SIZE ))));
// unlink from doubly linked list // unlink from doubly linked list
if ( pg->prev ) { if ( pg->prev ) {
@ -1096,7 +1096,7 @@ void Mem_Free( void *ptr ) {
return; return;
} }
Mem_UpdateFreeStats( mem_heap->Msize( ptr ) ); Mem_UpdateFreeStats( mem_heap->Msize( ptr ) );
mem_heap->Free( ptr ); mem_heap->Free( ptr );
} }
/* /*
@ -1116,7 +1116,7 @@ void *Mem_Alloc16( const int size ) {
} }
void *mem = mem_heap->Allocate16( size ); void *mem = mem_heap->Allocate16( size );
// make sure the memory is 16 byte aligned // make sure the memory is 16 byte aligned
assert( ( ((int)mem) & 15) == 0 ); assert( ( ((intptr_t)mem) & 15) == 0 );
return mem; return mem;
} }
@ -1137,8 +1137,8 @@ void Mem_Free16( void *ptr ) {
return; return;
} }
// make sure the memory is 16 byte aligned // make sure the memory is 16 byte aligned
assert( ( ((int)ptr) & 15) == 0 ); assert( ( ((intptr_t)ptr) & 15) == 0 );
mem_heap->Free16( ptr ); mem_heap->Free16( ptr );
} }
/* /*
@ -1230,15 +1230,12 @@ void Mem_EnableLeakTest( const char *name ) {
#undef Mem_Alloc16 #undef Mem_Alloc16
#undef Mem_Free16 #undef Mem_Free16
#define MAX_CALLSTACK_DEPTH 6
// size of this struct must be a multiple of 16 bytes // size of this struct must be a multiple of 16 bytes
typedef struct debugMemory_s { typedef struct debugMemory_s {
const char * fileName; const char * fileName;
int lineNumber; int lineNumber;
int frameNumber; int frameNumber;
int size; int size;
address_t callStack[MAX_CALLSTACK_DEPTH];
struct debugMemory_s * prev; struct debugMemory_s * prev;
struct debugMemory_s * next; struct debugMemory_s * next;
} debugMemory_t; } debugMemory_t;
@ -1310,15 +1307,13 @@ void Mem_Dump( const char *fileName ) {
} }
dump[i] = '\0'; dump[i] = '\0';
if ( ( b->size >> 10 ) != 0 ) { if ( ( b->size >> 10 ) != 0 ) {
fprintf( f, "size: %6d KB: %s, line: %d [%s], call stack: %s\r\n", ( b->size >> 10 ), Mem_CleanupFileName(b->fileName), b->lineNumber, dump, idLib::sys->GetCallStackStr( b->callStack, MAX_CALLSTACK_DEPTH ) ); fprintf( f, "size: %6d KB: %s, line: %d [%s]\r\n", ( b->size >> 10 ), Mem_CleanupFileName(b->fileName), b->lineNumber, dump );
} }
else { else {
fprintf( f, "size: %7d B: %s, line: %d [%s], call stack: %s\r\n", b->size, Mem_CleanupFileName(b->fileName), b->lineNumber, dump, idLib::sys->GetCallStackStr( b->callStack, MAX_CALLSTACK_DEPTH ) ); fprintf( f, "size: %7d B: %s, line: %d [%s], call stack: %s\r\n", b->size, Mem_CleanupFileName(b->fileName), b->lineNumber, dump );
} }
} }
idLib::sys->ShutdownSymbols();
fprintf( f, "%8d total memory blocks allocated\r\n", numBlocks ); fprintf( f, "%8d total memory blocks allocated\r\n", numBlocks );
fprintf( f, "%8d KB memory allocated\r\n", ( totalSize >> 10 ) ); fprintf( f, "%8d KB memory allocated\r\n", ( totalSize >> 10 ) );
@ -1352,7 +1347,6 @@ typedef struct allocInfo_s {
int lineNumber; int lineNumber;
int size; int size;
int numAllocs; int numAllocs;
address_t callStack[MAX_CALLSTACK_DEPTH];
struct allocInfo_s * next; struct allocInfo_s * next;
} allocInfo_t; } allocInfo_t;
@ -1360,10 +1354,9 @@ typedef enum {
MEMSORT_SIZE, MEMSORT_SIZE,
MEMSORT_LOCATION, MEMSORT_LOCATION,
MEMSORT_NUMALLOCS, MEMSORT_NUMALLOCS,
MEMSORT_CALLSTACK
} memorySortType_t; } memorySortType_t;
void Mem_DumpCompressed( const char *fileName, memorySortType_t memSort, int sortCallStack, int numFrames ) { void Mem_DumpCompressed( const char *fileName, memorySortType_t memSort, int numFrames ) {
int numBlocks, totalSize, r, j; int numBlocks, totalSize, r, j;
debugMemory_t *b; debugMemory_t *b;
allocInfo_t *a, *nexta, *allocInfo = NULL, *sortedAllocInfo = NULL, *prevSorted, *nextSorted; allocInfo_t *a, *nexta, *allocInfo = NULL, *sortedAllocInfo = NULL, *prevSorted, *nextSorted;
@ -1387,11 +1380,6 @@ void Mem_DumpCompressed( const char *fileName, memorySortType_t memSort, int sor
if ( a->lineNumber != b->lineNumber ) { if ( a->lineNumber != b->lineNumber ) {
continue; continue;
} }
for ( j = 0; j < MAX_CALLSTACK_DEPTH; j++ ) {
if ( a->callStack[j] != b->callStack[j] ) {
break;
}
}
if ( j < MAX_CALLSTACK_DEPTH ) { if ( j < MAX_CALLSTACK_DEPTH ) {
continue; continue;
} }
@ -1410,9 +1398,6 @@ void Mem_DumpCompressed( const char *fileName, memorySortType_t memSort, int sor
a->lineNumber = b->lineNumber; a->lineNumber = b->lineNumber;
a->size = b->size; a->size = b->size;
a->numAllocs = 1; a->numAllocs = 1;
for ( j = 0; j < MAX_CALLSTACK_DEPTH; j++ ) {
a->callStack[j] = b->callStack[j];
}
a->next = allocInfo; a->next = allocInfo;
allocInfo = a; allocInfo = a;
} }
@ -1455,16 +1440,6 @@ void Mem_DumpCompressed( const char *fileName, memorySortType_t memSort, int sor
} }
break; break;
} }
// sort on call stack
case MEMSORT_CALLSTACK: {
for ( nextSorted = sortedAllocInfo; nextSorted; nextSorted = nextSorted->next ) {
if ( a->callStack[sortCallStack] < nextSorted->callStack[sortCallStack] ) {
break;
}
prevSorted = nextSorted;
}
break;
}
} }
if ( !prevSorted ) { if ( !prevSorted ) {
a->next = sortedAllocInfo; a->next = sortedAllocInfo;
@ -1484,14 +1459,12 @@ void Mem_DumpCompressed( const char *fileName, memorySortType_t memSort, int sor
// write list to file // write list to file
for ( a = sortedAllocInfo; a; a = nexta ) { for ( a = sortedAllocInfo; a; a = nexta ) {
nexta = a->next; nexta = a->next;
fprintf( f, "size: %6d KB, allocs: %5d: %s, line: %d, call stack: %s\r\n", fprintf( f, "size: %6d KB, allocs: %5d: %s, line: %d\r\n",
(a->size >> 10), a->numAllocs, Mem_CleanupFileName(a->fileName), (a->size >> 10), a->numAllocs, Mem_CleanupFileName(a->fileName),
a->lineNumber, idLib::sys->GetCallStackStr( a->callStack, MAX_CALLSTACK_DEPTH ) ); a->lineNumber );
::free( a ); ::free( a );
} }
idLib::sys->ShutdownSymbols();
fprintf( f, "%8d total memory blocks allocated\r\n", numBlocks ); fprintf( f, "%8d total memory blocks allocated\r\n", numBlocks );
fprintf( f, "%8d KB memory allocated\r\n", ( totalSize >> 10 ) ); fprintf( f, "%8d KB memory allocated\r\n", ( totalSize >> 10 ) );
@ -1507,7 +1480,7 @@ void Mem_DumpCompressed_f( const idCmdArgs &args ) {
int argNum; int argNum;
const char *arg, *fileName; const char *arg, *fileName;
memorySortType_t memSort = MEMSORT_LOCATION; memorySortType_t memSort = MEMSORT_LOCATION;
int sortCallStack = 0, numFrames = 0; int numFrames = 0;
// get cmd-line options // get cmd-line options
argNum = 1; argNum = 1;
@ -1520,15 +1493,6 @@ void Mem_DumpCompressed_f( const idCmdArgs &args ) {
memSort = MEMSORT_LOCATION; memSort = MEMSORT_LOCATION;
} else if ( idStr::Icmp( arg, "a" ) == 0 ) { } else if ( idStr::Icmp( arg, "a" ) == 0 ) {
memSort = MEMSORT_NUMALLOCS; memSort = MEMSORT_NUMALLOCS;
} else if ( idStr::Icmp( arg, "cs1" ) == 0 ) {
memSort = MEMSORT_CALLSTACK;
sortCallStack = 2;
} else if ( idStr::Icmp( arg, "cs2" ) == 0 ) {
memSort = MEMSORT_CALLSTACK;
sortCallStack = 1;
} else if ( idStr::Icmp( arg, "cs3" ) == 0 ) {
memSort = MEMSORT_CALLSTACK;
sortCallStack = 0;
} else if ( arg[0] == 'f' ) { } else if ( arg[0] == 'f' ) {
numFrames = atoi( arg + 1 ); numFrames = atoi( arg + 1 );
} else { } else {
@ -1552,7 +1516,7 @@ void Mem_DumpCompressed_f( const idCmdArgs &args ) {
} else { } else {
fileName = arg; fileName = arg;
} }
Mem_DumpCompressed( fileName, memSort, sortCallStack, numFrames ); Mem_DumpCompressed( fileName, memSort, numFrames );
} }
/* /*
@ -1596,7 +1560,6 @@ void *Mem_AllocDebugMemory( const int size, const char *fileName, const int line
mem_debugMemory->prev = m; mem_debugMemory->prev = m;
} }
mem_debugMemory = m; mem_debugMemory = m;
idLib::sys->GetCallStack( m->callStack, MAX_CALLSTACK_DEPTH );
return ( ( (byte *) p ) + sizeof( debugMemory_t ) ); return ( ( (byte *) p ) + sizeof( debugMemory_t ) );
} }
@ -1625,7 +1588,7 @@ void Mem_FreeDebugMemory( void *p, const char *fileName, const int lineNumber, c
m = (debugMemory_t *) ( ( (byte *) p ) - sizeof( debugMemory_t ) ); m = (debugMemory_t *) ( ( (byte *) p ) - sizeof( debugMemory_t ) );
if ( m->size < 0 ) { if ( m->size < 0 ) {
idLib::common->FatalError( "memory freed twice, first from %s, now from %s", idLib::sys->GetCallStackStr( m->callStack, MAX_CALLSTACK_DEPTH ), idLib::sys->GetCallStackCurStr( MAX_CALLSTACK_DEPTH ) ); idLib::common->FatalError( "memory freed twice" );
} }
Mem_UpdateFreeStats( m->size ); Mem_UpdateFreeStats( m->size );
@ -1644,13 +1607,12 @@ void Mem_FreeDebugMemory( void *p, const char *fileName, const int lineNumber, c
m->lineNumber = lineNumber; m->lineNumber = lineNumber;
m->frameNumber = idLib::frameNumber; m->frameNumber = idLib::frameNumber;
m->size = -m->size; m->size = -m->size;
idLib::sys->GetCallStack( m->callStack, MAX_CALLSTACK_DEPTH );
if ( align16 ) { if ( align16 ) {
mem_heap->Free16( m ); mem_heap->Free16( m );
} }
else { else {
mem_heap->Free( m ); mem_heap->Free( m );
} }
} }
@ -1748,9 +1710,8 @@ Mem_Shutdown
void Mem_Shutdown( void ) { void Mem_Shutdown( void ) {
if ( mem_leakName[0] != '\0' ) { if ( mem_leakName[0] != '\0' ) {
Mem_DumpCompressed( va( "%s_leak_size.txt", mem_leakName ), MEMSORT_SIZE, 0, 0 ); Mem_DumpCompressed( va( "%s_leak_size.txt", mem_leakName ), MEMSORT_SIZE, 0 );
Mem_DumpCompressed( va( "%s_leak_location.txt", mem_leakName ), MEMSORT_LOCATION, 0, 0 ); Mem_DumpCompressed( va( "%s_leak_location.txt", mem_leakName ), MEMSORT_LOCATION, 0 );
Mem_DumpCompressed( va( "%s_leak_cs1.txt", mem_leakName ), MEMSORT_CALLSTACK, 2, 0 );
} }
idHeap *m = mem_heap; idHeap *m = mem_heap;

View file

@ -214,7 +214,9 @@ type *idBlockAlloc<type,blockSize>::Alloc( void ) {
template<class type, int blockSize> template<class type, int blockSize>
void idBlockAlloc<type,blockSize>::Free( type *t ) { void idBlockAlloc<type,blockSize>::Free( type *t ) {
element_t *element = (element_t *)( ( (unsigned char *) t ) - ( (int) &((element_t *)0)->t ) ); // flibit: 64 bit fix, changed int to intptr_t
element_t *element = (element_t *)( ( (unsigned char *) t ) - ( (intptr_t) &((element_t *)0)->t ) );
// flibit end
element->next = free; element->next = free;
free = element; free = element;
active--; active--;

View file

@ -152,7 +152,7 @@ dword PackColor( const idVec4 &color ) {
dz = ColorFloatToByte( color.z ); dz = ColorFloatToByte( color.z );
dw = ColorFloatToByte( color.w ); dw = ColorFloatToByte( color.w );
#if defined(_WIN32) || defined(__linux__) || (defined(MACOS_X) && defined(__i386__)) #if defined(_WIN32) || defined(__linux__) || (defined(MACOS_X) && !defined(__ppc__))
return ( dx << 0 ) | ( dy << 8 ) | ( dz << 16 ) | ( dw << 24 ); return ( dx << 0 ) | ( dy << 8 ) | ( dz << 16 ) | ( dw << 24 );
#elif (defined(MACOS_X) && defined(__ppc__)) #elif (defined(MACOS_X) && defined(__ppc__))
return ( dx << 24 ) | ( dy << 16 ) | ( dz << 8 ) | ( dw << 0 ); return ( dx << 24 ) | ( dy << 16 ) | ( dz << 8 ) | ( dw << 0 );
@ -167,7 +167,7 @@ UnpackColor
================ ================
*/ */
void UnpackColor( const dword color, idVec4 &unpackedColor ) { void UnpackColor( const dword color, idVec4 &unpackedColor ) {
#if defined(_WIN32) || defined(__linux__) || (defined(MACOS_X) && defined(__i386__)) #if defined(_WIN32) || defined(__linux__) || (defined(MACOS_X) && !defined(__ppc__))
unpackedColor.Set( ( ( color >> 0 ) & 255 ) * ( 1.0f / 255.0f ), unpackedColor.Set( ( ( color >> 0 ) & 255 ) * ( 1.0f / 255.0f ),
( ( color >> 8 ) & 255 ) * ( 1.0f / 255.0f ), ( ( color >> 8 ) & 255 ) * ( 1.0f / 255.0f ),
( ( color >> 16 ) & 255 ) * ( 1.0f / 255.0f ), ( ( color >> 16 ) & 255 ) * ( 1.0f / 255.0f ),
@ -194,7 +194,7 @@ dword PackColor( const idVec3 &color ) {
dy = ColorFloatToByte( color.y ); dy = ColorFloatToByte( color.y );
dz = ColorFloatToByte( color.z ); dz = ColorFloatToByte( color.z );
#if defined(_WIN32) || defined(__linux__) || (defined(MACOS_X) && defined(__i386__)) #if defined(_WIN32) || defined(__linux__) || (defined(MACOS_X) && !defined(__ppc__))
return ( dx << 0 ) | ( dy << 8 ) | ( dz << 16 ); return ( dx << 0 ) | ( dy << 8 ) | ( dz << 16 );
#elif (defined(MACOS_X) && defined(__ppc__)) #elif (defined(MACOS_X) && defined(__ppc__))
return ( dy << 16 ) | ( dz << 8 ) | ( dx << 0 ); return ( dy << 16 ) | ( dz << 8 ) | ( dx << 0 );
@ -209,7 +209,7 @@ UnpackColor
================ ================
*/ */
void UnpackColor( const dword color, idVec3 &unpackedColor ) { void UnpackColor( const dword color, idVec3 &unpackedColor ) {
#if defined(_WIN32) || defined(__linux__) || (defined(MACOS_X) && defined(__i386__)) #if defined(_WIN32) || defined(__linux__) || (defined(MACOS_X) && !defined(__ppc__))
unpackedColor.Set( ( ( color >> 0 ) & 255 ) * ( 1.0f / 255.0f ), unpackedColor.Set( ( ( color >> 0 ) & 255 ) * ( 1.0f / 255.0f ),
( ( color >> 8 ) & 255 ) * ( 1.0f / 255.0f ), ( ( color >> 8 ) & 255 ) * ( 1.0f / 255.0f ),
( ( color >> 16 ) & 255 ) * ( 1.0f / 255.0f ) ); ( ( color >> 16 ) & 255 ) * ( 1.0f / 255.0f ) );
@ -576,9 +576,17 @@ bool Swap_IsBigEndian( void ) {
void AssertFailed( const char *file, int line, const char *expression ) { void AssertFailed( const char *file, int line, const char *expression ) {
idLib::sys->DebugPrintf( "\n\nASSERTION FAILED!\n%s(%d): '%s'\n", file, line, expression ); idLib::sys->DebugPrintf( "\n\nASSERTION FAILED!\n%s(%d): '%s'\n", file, line, expression );
#ifdef _WIN32 #ifdef _WIN32
#ifdef _WIN64
// FIXME: Need a Win64 debugbreak
#else
__asm int 0x03 __asm int 0x03
#endif
#elif defined( __linux__ ) #elif defined( __linux__ )
#ifdef __i386__
__asm__ __volatile__ ("int $0x03"); __asm__ __volatile__ ("int $0x03");
#else
#warning "Need a debugbreak for assertion failures"
#endif
#elif defined( MACOS_X ) #elif defined( MACOS_X )
kill( getpid(), SIGINT ); kill( getpid(), SIGINT );
#endif #endif

View file

@ -1294,7 +1294,9 @@ typedef struct operator_s
typedef struct value_s typedef struct value_s
{ {
signed long int intvalue; // flibit: 64 bit fix, remove long keyword
int intvalue;
// flibit end
double floatvalue; double floatvalue;
int parentheses; int parentheses;
struct value_s *prev, *next; struct value_s *prev, *next;
@ -1365,7 +1367,9 @@ int PC_OperatorPriority(int op) {
#define FreeOperator(op) #define FreeOperator(op)
int idParser::EvaluateTokens( idToken *tokens, signed long int *intvalue, double *floatvalue, int integer ) { // flibit: 64 bit fix, remove long keyword
int idParser::EvaluateTokens( idToken *tokens, int *intvalue, double *floatvalue, int integer ) {
// flibit end
operator_t *o, *firstoperator, *lastoperator; operator_t *o, *firstoperator, *lastoperator;
value_t *v, *firstvalue, *lastvalue, *v1, *v2; value_t *v, *firstvalue, *lastvalue, *v1, *v2;
idToken *t; idToken *t;
@ -1790,7 +1794,9 @@ int idParser::EvaluateTokens( idToken *tokens, signed long int *intvalue, double
idParser::Evaluate idParser::Evaluate
================ ================
*/ */
int idParser::Evaluate( signed long int *intvalue, double *floatvalue, int integer ) { // flibit: 64 bit fix, remove long keyword
int idParser::Evaluate( int *intvalue, double *floatvalue, int integer ) {
// flibit end
idToken token, *firsttoken, *lasttoken; idToken token, *firsttoken, *lasttoken;
idToken *t, *nexttoken; idToken *t, *nexttoken;
define_t *define; define_t *define;
@ -1881,7 +1887,9 @@ int idParser::Evaluate( signed long int *intvalue, double *floatvalue, int integ
idParser::DollarEvaluate idParser::DollarEvaluate
================ ================
*/ */
int idParser::DollarEvaluate( signed long int *intvalue, double *floatvalue, int integer) { // flibit: 64 bit fix, remove long keyword
int idParser::DollarEvaluate( int *intvalue, double *floatvalue, int integer) {
// flibit end
int indent, defined = false; int indent, defined = false;
idToken token, *firsttoken, *lasttoken; idToken token, *firsttoken, *lasttoken;
idToken *t, *nexttoken; idToken *t, *nexttoken;
@ -1983,7 +1991,9 @@ idParser::Directive_elif
================ ================
*/ */
int idParser::Directive_elif( void ) { int idParser::Directive_elif( void ) {
signed long int value; // flibit: 64 bit fix, remove long keyword
int value;
// flibit end
int type, skip; int type, skip;
idParser::PopIndent( &type, &skip ); idParser::PopIndent( &type, &skip );
@ -2005,7 +2015,9 @@ idParser::Directive_if
================ ================
*/ */
int idParser::Directive_if( void ) { int idParser::Directive_if( void ) {
signed long int value; // flibit: 64 bit fix, remove long keyword
int value;
// flibit end
int skip; int skip;
if ( !idParser::Evaluate( &value, NULL, true ) ) { if ( !idParser::Evaluate( &value, NULL, true ) ) {
@ -2101,7 +2113,9 @@ idParser::Directive_eval
================ ================
*/ */
int idParser::Directive_eval( void ) { int idParser::Directive_eval( void ) {
signed long int value; // flibit: 64 bit fix, remove long keyword
int value;
// flibit end
idToken token; idToken token;
char buf[128]; char buf[128];
@ -2240,7 +2254,9 @@ idParser::DollarDirective_evalint
================ ================
*/ */
int idParser::DollarDirective_evalint( void ) { int idParser::DollarDirective_evalint( void ) {
signed long int value; // flibit: 64 bit fix, remove long keyword
int value;
// flibit end
idToken token; idToken token;
char buf[128]; char buf[128];
@ -2289,7 +2305,9 @@ int idParser::DollarDirective_evalfloat( void ) {
token = buf; token = buf;
token.type = TT_NUMBER; token.type = TT_NUMBER;
token.subtype = TT_FLOAT | TT_LONG | TT_DECIMAL | TT_VALUESVALID; token.subtype = TT_FLOAT | TT_LONG | TT_DECIMAL | TT_VALUESVALID;
token.intvalue = (unsigned long) fabs( value ); // flibit: 64 bit fix, changed long to int
token.intvalue = (unsigned int) fabs( value );
// flibit end
token.floatvalue = fabs( value ); token.floatvalue = fabs( value );
idParser::UnreadSourceToken( &token ); idParser::UnreadSourceToken( &token );
if ( value < 0 ) { if ( value < 0 ) {

View file

@ -225,9 +225,11 @@ private:
int Directive_ifndef( void ); int Directive_ifndef( void );
int Directive_else( void ); int Directive_else( void );
int Directive_endif( void ); int Directive_endif( void );
int EvaluateTokens( idToken *tokens, signed long int *intvalue, double *floatvalue, int integer ); // flibit: 64 bit fix, removed long keyword
int Evaluate( signed long int *intvalue, double *floatvalue, int integer ); int EvaluateTokens( idToken *tokens, int *intvalue, double *floatvalue, int integer );
int DollarEvaluate( signed long int *intvalue, double *floatvalue, int integer); int Evaluate( int *intvalue, double *floatvalue, int integer );
int DollarEvaluate( int *intvalue, double *floatvalue, int integer);
// flibit end
int Directive_define( void ); int Directive_define( void );
int Directive_elif( void ); int Directive_elif( void );
int Directive_if( void ); int Directive_if( void );

View file

@ -170,7 +170,9 @@ void idStr::operator=( const char *text ) {
return; return;
} }
l = strlen( text ); // RB: 64 bit fixes, conversion from 'size_t' to 'int', possible loss of data
l = ( int )strlen( text );
// RB end
EnsureAlloced( l + 1, false ); EnsureAlloced( l + 1, false );
strcpy( data, text ); strcpy( data, text );
len = l; len = l;
@ -187,7 +189,9 @@ int idStr::FindChar( const char *str, const char c, int start, int end ) {
int i; int i;
if ( end == -1 ) { if ( end == -1 ) {
end = strlen( str ) - 1; // RB: 64 bit fixes, conversion from 'size_t' to 'int', possible loss of data
end = ( int )strlen( str ) - 1;
// RB end
} }
for ( i = start; i <= end; i++ ) { for ( i = start; i <= end; i++ ) {
if ( str[i] == c ) { if ( str[i] == c ) {
@ -208,9 +212,13 @@ int idStr::FindText( const char *str, const char *text, bool casesensitive, int
int l, i, j; int l, i, j;
if ( end == -1 ) { if ( end == -1 ) {
end = strlen( str ); // RB: 64 bit fixes, conversion from 'size_t' to 'int', possible loss of data
end = ( int )strlen( str );
// RB end
} }
l = end - strlen( text ); // RB: 64 bit fixes, conversion from 'size_t' to 'int', possible loss of data
l = end - ( int )strlen( text );
// RB end
for ( i = start; i <= l; i++ ) { for ( i = start; i <= l; i++ ) {
if ( casesensitive ) { if ( casesensitive ) {
for ( j = 0; text[j]; j++ ) { for ( j = 0; text[j]; j++ ) {
@ -481,7 +489,9 @@ idStr::StripLeading
void idStr::StripLeading( const char *string ) { void idStr::StripLeading( const char *string ) {
int l; int l;
l = strlen( string ); // RB: 64 bit fixes, conversion from 'size_t' to 'int', possible loss of data
l = ( int )strlen( string );
// RB end
if ( l > 0 ) { if ( l > 0 ) {
while ( !Cmpn( string, l ) ) { while ( !Cmpn( string, l ) ) {
memmove( data, data + l, len - l + 1 ); memmove( data, data + l, len - l + 1 );
@ -498,7 +508,9 @@ idStr::StripLeadingOnce
bool idStr::StripLeadingOnce( const char *string ) { bool idStr::StripLeadingOnce( const char *string ) {
int l; int l;
l = strlen( string ); // RB: 64 bit fixes, conversion from 'size_t' to 'int', possible loss of data
l = ( int )strlen( string );
// RB end
if ( ( l > 0 ) && !Cmpn( string, l ) ) { if ( ( l > 0 ) && !Cmpn( string, l ) ) {
memmove( data, data + l, len - l + 1 ); memmove( data, data + l, len - l + 1 );
len -= l; len -= l;
@ -529,7 +541,9 @@ idStr::StripLeading
void idStr::StripTrailing( const char *string ) { void idStr::StripTrailing( const char *string ) {
int l; int l;
l = strlen( string ); // RB: 64 bit fixes, conversion from 'size_t' to 'int', possible loss of data
l = ( int )strlen( string );
// RB end
if ( l > 0 ) { if ( l > 0 ) {
while ( ( len >= l ) && !Cmpn( string, data + len - l, l ) ) { while ( ( len >= l ) && !Cmpn( string, data + len - l, l ) ) {
len -= l; len -= l;
@ -546,7 +560,9 @@ idStr::StripTrailingOnce
bool idStr::StripTrailingOnce( const char *string ) { bool idStr::StripTrailingOnce( const char *string ) {
int l; int l;
l = strlen( string ); // RB: 64 bit fixes, conversion from 'size_t' to 'int', possible loss of data
l = ( int )strlen( string );
// RB end
if ( ( l > 0 ) && ( len >= l ) && !Cmpn( string, data + len - l, l ) ) { if ( ( l > 0 ) && ( len >= l ) && !Cmpn( string, data + len - l, l ) ) {
len -= l; len -= l;
data[len] = '\0'; data[len] = '\0';
@ -564,8 +580,10 @@ void idStr::Replace( const char *old, const char *nw ) {
int oldLen, newLen, i, j, count; int oldLen, newLen, i, j, count;
idStr oldString( data ); idStr oldString( data );
oldLen = strlen( old ); // RB: 64 bit fixes, conversion from 'size_t' to 'int', possible loss of data
newLen = strlen( nw ); oldLen = ( int )strlen( old );
newLen = ( int )strlen( nw );
// RB end
// Work out how big the new string will be // Work out how big the new string will be
count = 0; count = 0;
@ -591,7 +609,9 @@ void idStr::Replace( const char *old, const char *nw ) {
} }
} }
data[j] = 0; data[j] = 0;
len = strlen( data ); // RB: 64 bit fixes, conversion from 'size_t' to 'int', possible loss of data
len = ( int )strlen( data );
// RB end
} }
} }
@ -698,8 +718,9 @@ idStr::FileNameHash
============ ============
*/ */
int idStr::FileNameHash( void ) const { int idStr::FileNameHash( void ) const {
// flibit: 64 bit fix, changed long to int
int i; int i;
long hash; int hash;
char letter; char letter;
hash = 0; hash = 0;
@ -712,11 +733,12 @@ int idStr::FileNameHash( void ) const {
if ( letter =='\\' ) { if ( letter =='\\' ) {
letter = '/'; letter = '/';
} }
hash += (long)(letter)*(i+119); hash += (int)(letter)*(i+119);
i++; i++;
} }
hash &= (FILE_HASH_SIZE-1); hash &= (FILE_HASH_SIZE-1);
return hash; return hash;
// flibit end
} }
/* /*
@ -833,7 +855,9 @@ void idStr::AppendPath( const char *text ) {
if ( text && text[i] ) { if ( text && text[i] ) {
pos = len; pos = len;
EnsureAlloced( len + strlen( text ) + 2 ); // RB: 64 bit fixes, conversion from 'size_t' to 'int', possible loss of data
EnsureAlloced( len + ( int )strlen( text ) + 2 );
// RB end
if ( pos ) { if ( pos ) {
if ( data[ pos-1 ] != '/' ) { if ( data[ pos-1 ] != '/' ) {
@ -1397,7 +1421,9 @@ idStr::Append
void idStr::Append( char *dest, int size, const char *src ) { void idStr::Append( char *dest, int size, const char *src ) {
int l1; int l1;
l1 = strlen( dest ); // RB: 64 bit fixes, conversion from 'size_t' to 'int', possible loss of data
l1 = ( int )strlen( dest );
// RB end
if ( l1 >= size ) { if ( l1 >= size ) {
idLib::common->Error( "idStr::Append: already overflowed" ); idLib::common->Error( "idStr::Append: already overflowed" );
} }

View file

@ -389,7 +389,9 @@ ID_INLINE idStr::idStr( const char *text ) {
Init(); Init();
if ( text ) { if ( text ) {
l = strlen( text ); // RB: 64 bit fixes, conversion from 'size_t' to 'int', possible loss of data
l = ( int )strlen( text );
// RB end
EnsureAlloced( l + 1 ); EnsureAlloced( l + 1 );
strcpy( data, text ); strcpy( data, text );
len = l; len = l;
@ -398,7 +400,9 @@ ID_INLINE idStr::idStr( const char *text ) {
ID_INLINE idStr::idStr( const char *text, int start, int end ) { ID_INLINE idStr::idStr( const char *text, int start, int end ) {
int i; int i;
int l = strlen( text ); // RB: 64 bit fixes, conversion from 'size_t' to 'int', possible loss of data
int l = ( int )strlen( text );
// RB end
Init(); Init();
if ( end > l ) { if ( end > l ) {
@ -661,7 +665,9 @@ ID_INLINE int idStr::Cmpn( const char *text, int n ) const {
ID_INLINE int idStr::CmpPrefix( const char *text ) const { ID_INLINE int idStr::CmpPrefix( const char *text ) const {
assert( text ); assert( text );
return idStr::Cmpn( data, text, strlen( text ) ); // RB: 64 bit fixes, conversion from 'size_t' to 'int', possible loss of data
return idStr::Cmpn( data, text, ( int )strlen( text ) );
// RB end
} }
ID_INLINE int idStr::Icmp( const char *text ) const { ID_INLINE int idStr::Icmp( const char *text ) const {
@ -676,7 +682,9 @@ ID_INLINE int idStr::Icmpn( const char *text, int n ) const {
ID_INLINE int idStr::IcmpPrefix( const char *text ) const { ID_INLINE int idStr::IcmpPrefix( const char *text ) const {
assert( text ); assert( text );
return idStr::Icmpn( data, text, strlen( text ) ); // RB: 64 bit fixes, conversion from 'size_t' to 'int', possible loss of data
return idStr::Icmpn( data, text, ( int )strlen( text ) );
// RB end
} }
ID_INLINE int idStr::IcmpNoColor( const char *text ) const { ID_INLINE int idStr::IcmpNoColor( const char *text ) const {
@ -696,7 +704,9 @@ ID_INLINE int idStr::IcmpnPath( const char *text, int n ) const {
ID_INLINE int idStr::IcmpPrefixPath( const char *text ) const { ID_INLINE int idStr::IcmpPrefixPath( const char *text ) const {
assert( text ); assert( text );
return idStr::IcmpnPath( data, text, strlen( text ) ); // RB: 64 bit fixes, conversion from 'size_t' to 'int', possible loss of data
return idStr::IcmpnPath( data, text, ( int )strlen( text ) );
// RB end
} }
ID_INLINE int idStr::Length( void ) const { ID_INLINE int idStr::Length( void ) const {
@ -751,7 +761,9 @@ ID_INLINE void idStr::Append( const char *text ) {
int i; int i;
if ( text ) { if ( text ) {
newLen = len + strlen( text ); // RB: 64 bit fixes, conversion from 'size_t' to 'int', possible loss of data
newLen = len + ( int )strlen( text );
// RB end
EnsureAlloced( newLen + 1 ); EnsureAlloced( newLen + 1 );
for ( i = 0; text[ i ]; i++ ) { for ( i = 0; text[ i ]; i++ ) {
data[ len + i ] = text[ i ]; data[ len + i ] = text[ i ];
@ -803,7 +815,9 @@ ID_INLINE void idStr::Insert( const char *text, int index ) {
index = len; index = len;
} }
l = strlen( text ); // RB: 64 bit fixes, conversion from 'size_t' to 'int', possible loss of data
l = ( int )strlen( text );
// RB end
EnsureAlloced( len + l + 1 ); EnsureAlloced( len + l + 1 );
for ( i = len; i >= index; i-- ) { for ( i = len; i >= index; i-- ) {
data[i+l] = data[i]; data[i+l] = data[i];

View file

@ -90,7 +90,9 @@ public:
double GetDoubleValue( void ); // double value of TT_NUMBER double GetDoubleValue( void ); // double value of TT_NUMBER
float GetFloatValue( void ); // float value of TT_NUMBER float GetFloatValue( void ); // float value of TT_NUMBER
unsigned long GetUnsignedLongValue( void ); // unsigned long value of TT_NUMBER // flibit: 64 bit fix, changed to GetUnsignedIntValue
unsigned int GetUnsignedIntValue( void ); // unsigned long value of TT_NUMBER
// flibit end
int GetIntValue( void ); // int value of TT_NUMBER int GetIntValue( void ); // int value of TT_NUMBER
int WhiteSpaceBeforeToken( void ) const;// returns length of whitespace before token int WhiteSpaceBeforeToken( void ) const;// returns length of whitespace before token
void ClearTokenWhiteSpace( void ); // forget whitespace before token void ClearTokenWhiteSpace( void ); // forget whitespace before token
@ -98,7 +100,7 @@ public:
void NumberValue( void ); // calculate values for a TT_NUMBER void NumberValue( void ); // calculate values for a TT_NUMBER
private: private:
unsigned long intvalue; // integer value unsigned int intvalue; // integer value
double floatvalue; // floating point value double floatvalue; // floating point value
const char * whiteSpaceStart_p; // start of white space before token, only used by idLexer const char * whiteSpaceStart_p; // start of white space before token, only used by idLexer
const char * whiteSpaceEnd_p; // end of white space before token, only used by idLexer const char * whiteSpaceEnd_p; // end of white space before token, only used by idLexer
@ -139,7 +141,8 @@ ID_INLINE float idToken::GetFloatValue( void ) {
return (float) GetDoubleValue(); return (float) GetDoubleValue();
} }
ID_INLINE unsigned long idToken::GetUnsignedLongValue( void ) { // flibit: 64 bit fix, GetUnsignedIntValue
ID_INLINE unsigned int idToken::GetUnsignedIntValue( void ) {
if ( type != TT_NUMBER ) { if ( type != TT_NUMBER ) {
return 0; return 0;
} }
@ -148,9 +151,10 @@ ID_INLINE unsigned long idToken::GetUnsignedLongValue( void ) {
} }
return intvalue; return intvalue;
} }
// flibit end
ID_INLINE int idToken::GetIntValue( void ) { ID_INLINE int idToken::GetIntValue( void ) {
return (int) GetUnsignedLongValue(); return (int) GetUnsignedIntValue();
} }
ID_INLINE int idToken::WhiteSpaceBeforeToken( void ) const { ID_INLINE int idToken::WhiteSpaceBeforeToken( void ) const {

View file

@ -12,7 +12,9 @@
#ifdef CREATE_CRC_TABLE #ifdef CREATE_CRC_TABLE
static unsigned long crctable[256]; // RB: 64 bit fix, changed long to int
static unsigned int crctable[256];
// RB end
/* /*
Generate a table for a byte-wise 32-bit CRC calculation on the polynomial: Generate a table for a byte-wise 32-bit CRC calculation on the polynomial:
@ -41,7 +43,9 @@ static unsigned long crctable[256];
void make_crc_table( void ) { void make_crc_table( void ) {
int i, j; int i, j;
unsigned long c, poly; // RB: 64 bit fix, changed long to int
unsigned int c, poly;
// RB end
/* terms of polynomial defining this crc (except x^32): */ /* terms of polynomial defining this crc (except x^32): */
static const byte p[] = {0,1,2,4,5,7,8,10,11,12,16,22,23,26}; static const byte p[] = {0,1,2,4,5,7,8,10,11,12,16,22,23,26};
@ -52,7 +56,9 @@ void make_crc_table( void ) {
} }
for ( i = 0; i < 256; i++ ) { for ( i = 0; i < 256; i++ ) {
c = (unsigned long)i; // RB: 64 bit fix, changed long to int
c = (unsigned int)i;
// RB end
for ( j = 0; j < 8; j++ ) { for ( j = 0; j < 8; j++ ) {
c = ( c & 1 ) ? poly ^ ( c >> 1 ) : ( c >> 1 ); c = ( c & 1 ) ? poly ^ ( c >> 1 ) : ( c >> 1 );
} }
@ -65,7 +71,9 @@ void make_crc_table( void ) {
/* /*
Table of CRC-32's of all single-byte values (made by make_crc_table) Table of CRC-32's of all single-byte values (made by make_crc_table)
*/ */
static unsigned long crctable[256] = { // RB: 64 bit fix, changed long to int
static unsigned int crctable[256] = {
// RB end
0x00000000L, 0x77073096L, 0xee0e612cL, 0x990951baL, 0x00000000L, 0x77073096L, 0xee0e612cL, 0x990951baL,
0x076dc419L, 0x706af48fL, 0xe963a535L, 0x9e6495a3L, 0x076dc419L, 0x706af48fL, 0xe963a535L, 0x9e6495a3L,
0x0edb8832L, 0x79dcb8a4L, 0xe0d5e91eL, 0x97d2d988L, 0x0edb8832L, 0x79dcb8a4L, 0xe0d5e91eL, 0x97d2d988L,
@ -134,16 +142,17 @@ static unsigned long crctable[256] = {
#endif #endif
void CRC32_InitChecksum( unsigned long &crcvalue ) { // RB: 64 bit fixes, changed long to int
void CRC32_InitChecksum( unsigned int &crcvalue ) {
crcvalue = CRC32_INIT_VALUE; crcvalue = CRC32_INIT_VALUE;
} }
void CRC32_Update( unsigned long &crcvalue, const byte data ) { void CRC32_Update( unsigned int &crcvalue, const byte data ) {
crcvalue = crctable[ ( crcvalue ^ data ) & 0xff ] ^ ( crcvalue >> 8 ); crcvalue = crctable[ ( crcvalue ^ data ) & 0xff ] ^ ( crcvalue >> 8 );
} }
void CRC32_UpdateChecksum( unsigned long &crcvalue, const void *data, int length ) { void CRC32_UpdateChecksum( unsigned int &crcvalue, const void *data, int length ) {
unsigned long crc; unsigned int crc;
const unsigned char *buf = (const unsigned char *) data; const unsigned char *buf = (const unsigned char *) data;
crc = crcvalue; crc = crcvalue;
@ -153,15 +162,16 @@ void CRC32_UpdateChecksum( unsigned long &crcvalue, const void *data, int length
crcvalue = crc; crcvalue = crc;
} }
void CRC32_FinishChecksum( unsigned long &crcvalue ) { void CRC32_FinishChecksum( unsigned int &crcvalue ) {
crcvalue ^= CRC32_XOR_VALUE; crcvalue ^= CRC32_XOR_VALUE;
} }
unsigned long CRC32_BlockChecksum( const void *data, int length ) { unsigned int CRC32_BlockChecksum( const void *data, int length ) {
unsigned long crc; unsigned int crc;
CRC32_InitChecksum( crc ); CRC32_InitChecksum( crc );
CRC32_UpdateChecksum( crc, data, length ); CRC32_UpdateChecksum( crc, data, length );
CRC32_FinishChecksum( crc ); CRC32_FinishChecksum( crc );
return crc; return crc;
} }
// RB end

View file

@ -10,9 +10,11 @@
=============================================================================== ===============================================================================
*/ */
void CRC32_InitChecksum( unsigned long &crcvalue ); // RB: 64 bit fixes, changed long to int
void CRC32_UpdateChecksum( unsigned long &crcvalue, const void *data, int length ); void CRC32_InitChecksum( unsigned int &crcvalue );
void CRC32_FinishChecksum( unsigned long &crcvalue ); void CRC32_UpdateChecksum( unsigned int &crcvalue, const void *data, int length );
unsigned long CRC32_BlockChecksum( const void *data, int length ); void CRC32_FinishChecksum( unsigned int &crcvalue );
unsigned int CRC32_BlockChecksum( const void *data, int length );
// RB end
#endif /* !__CRC32_H__ */ #endif /* !__CRC32_H__ */

View file

@ -38,7 +38,9 @@ typedef unsigned char *POINTER;
typedef unsigned short int UINT2; typedef unsigned short int UINT2;
/* UINT4 defines a four byte word */ /* UINT4 defines a four byte word */
typedef unsigned long int UINT4; // RB: 64 bit fix, changed long int to int
typedef unsigned int UINT4;
// RB end
/* MD4 context. */ /* MD4 context. */
typedef struct { typedef struct {
@ -244,9 +246,10 @@ void MD4_Final( MD4_CTX *context, unsigned char digest[16] ) {
MD4_BlockChecksum MD4_BlockChecksum
=============== ===============
*/ */
unsigned long MD4_BlockChecksum( const void *data, int length ) { // RB: 64 bit fixes, changed long int to int
unsigned long digest[4]; unsigned int MD4_BlockChecksum( const void *data, int length ) {
unsigned long val; unsigned int digest[4];
unsigned int val;
MD4_CTX ctx; MD4_CTX ctx;
MD4_Init( &ctx ); MD4_Init( &ctx );
@ -257,3 +260,4 @@ unsigned long MD4_BlockChecksum( const void *data, int length ) {
return val; return val;
} }
// RB end

View file

@ -10,6 +10,8 @@
=============================================================================== ===============================================================================
*/ */
unsigned long MD4_BlockChecksum( const void *data, int length ); // RB: 64 bit fix, changed long to int
unsigned int MD4_BlockChecksum( const void *data, int length );
// RB end
#endif /* !__MD4_H__ */ #endif /* !__MD4_H__ */

View file

@ -257,10 +257,12 @@ void MD5_Final( MD5_CTX *ctx, unsigned char digest[16] ) {
MD5_BlockChecksum MD5_BlockChecksum
=============== ===============
*/ */
unsigned long MD5_BlockChecksum( const void *data, int length ) { // flibit: 64 bit fix, changed long to int
unsigned long digest[4]; unsigned int MD5_BlockChecksum( const void *data, int length ) {
unsigned long val; unsigned int digest[4];
unsigned int val;
MD5_CTX ctx; MD5_CTX ctx;
// flibit end
MD5_Init( &ctx ); MD5_Init( &ctx );
MD5_Update( &ctx, (unsigned char *)data, length ); MD5_Update( &ctx, (unsigned char *)data, length );

View file

@ -10,6 +10,8 @@
=============================================================================== ===============================================================================
*/ */
unsigned long MD5_BlockChecksum( const void *data, int length ); // flibit: 64 bit fix, changed long to int
unsigned int MD5_BlockChecksum( const void *data, int length );
// flibit end
#endif /* !__MD5_H__ */ #endif /* !__MD5_H__ */

View file

@ -2936,7 +2936,9 @@ const char *idMat6::ToString( int precision ) const {
//=============================================================== //===============================================================
float idMatX::temp[MATX_MAX_TEMP+4]; float idMatX::temp[MATX_MAX_TEMP+4];
float * idMatX::tempPtr = (float *) ( ( (int) idMatX::temp + 15 ) & ~15 ); // flibit: 64 bit fix, changed int to intptr_t
float * idMatX::tempPtr = (float *) ( ( (intptr_t) idMatX::temp + 15 ) & ~15 );
// flibit end
int idMatX::tempIndex = 0; int idMatX::tempIndex = 0;

View file

@ -2280,7 +2280,9 @@ ID_INLINE void idMatX::SetData( int rows, int columns, float *data ) {
if ( mat != NULL && alloced != -1 ) { if ( mat != NULL && alloced != -1 ) {
Mem_Free16( mat ); Mem_Free16( mat );
} }
assert( ( ( (int) data ) & 15 ) == 0 ); // data must be 16 byte aligned // flibit: 64 bit fix, change int to intptr_t
assert( ( ( (intptr_t) data ) & 15 ) == 0 ); // data must be 16 byte aligned
// flibit End
mat = data; mat = data;
alloced = -1; alloced = -1;
numRows = rows; numRows = rows;

View file

@ -96,12 +96,14 @@ ID_INLINE float idRandom::CRandomFloat( void ) {
=============================================================================== ===============================================================================
*/ */
// flibit: 64 bit fix, change long to int
class idRandom2 { class idRandom2 {
public: public:
idRandom2( unsigned long seed = 0 ); idRandom2( unsigned int seed = 0 );
void SetSeed( unsigned long seed ); void SetSeed( unsigned int seed );
unsigned long GetSeed( void ) const; unsigned int GetSeed( void ) const;
int RandomInt( void ); // random integer in the range [0, MAX_RAND] int RandomInt( void ); // random integer in the range [0, MAX_RAND]
int RandomInt( int max ); // random integer in the range [0, max] int RandomInt( int max ); // random integer in the range [0, max]
@ -111,21 +113,21 @@ public:
static const int MAX_RAND = 0x7fff; static const int MAX_RAND = 0x7fff;
private: private:
unsigned long seed; unsigned int seed;
static const unsigned long IEEE_ONE = 0x3f800000; static const unsigned int IEEE_ONE = 0x3f800000;
static const unsigned long IEEE_MASK = 0x007fffff; static const unsigned int IEEE_MASK = 0x007fffff;
}; };
ID_INLINE idRandom2::idRandom2( unsigned long seed ) { ID_INLINE idRandom2::idRandom2( unsigned int seed ) {
this->seed = seed; this->seed = seed;
} }
ID_INLINE void idRandom2::SetSeed( unsigned long seed ) { ID_INLINE void idRandom2::SetSeed( unsigned int seed ) {
this->seed = seed; this->seed = seed;
} }
ID_INLINE unsigned long idRandom2::GetSeed( void ) const { ID_INLINE unsigned int idRandom2::GetSeed( void ) const {
return seed; return seed;
} }
@ -142,17 +144,19 @@ ID_INLINE int idRandom2::RandomInt( int max ) {
} }
ID_INLINE float idRandom2::RandomFloat( void ) { ID_INLINE float idRandom2::RandomFloat( void ) {
unsigned long i; unsigned int i;
seed = 1664525L * seed + 1013904223L; seed = 1664525 * seed + 1013904223;
i = idRandom2::IEEE_ONE | ( seed & idRandom2::IEEE_MASK ); i = idRandom2::IEEE_ONE | ( seed & idRandom2::IEEE_MASK );
return ( ( *(float *)&i ) - 1.0f ); return ( ( *(float *)&i ) - 1.0f );
} }
ID_INLINE float idRandom2::CRandomFloat( void ) { ID_INLINE float idRandom2::CRandomFloat( void ) {
unsigned long i; unsigned int i;
seed = 1664525L * seed + 1013904223L; seed = 1664525 * seed + 1013904223;
i = idRandom2::IEEE_ONE | ( seed & idRandom2::IEEE_MASK ); i = idRandom2::IEEE_ONE | ( seed & idRandom2::IEEE_MASK );
return ( 2.0f * ( *(float *)&i ) - 3.0f ); return ( 2.0f * ( *(float *)&i ) - 3.0f );
} }
// flibit end
#endif /* !__MATH_RANDOM_H__ */ #endif /* !__MATH_RANDOM_H__ */

View file

@ -139,7 +139,9 @@ void idSIMD::Shutdown( void ) {
idSIMDProcessor *p_simd; idSIMDProcessor *p_simd;
idSIMDProcessor *p_generic; idSIMDProcessor *p_generic;
long baseClocks = 0; // flibit: 64 bit fix, change long to int
int baseClocks = 0;
// flibit end
#ifdef _WIN32 #ifdef _WIN32
@ -147,7 +149,9 @@ long baseClocks = 0;
#pragma warning(disable : 4731) // frame pointer register 'ebx' modified by inline assembly code #pragma warning(disable : 4731) // frame pointer register 'ebx' modified by inline assembly code
long saved_ebx = 0; // flibit: 64 bit fix, change long to int
int saved_ebx = 0;
// flibit end
#define StartRecordTime( start ) \ #define StartRecordTime( start ) \
__asm mov saved_ebx, ebx \ __asm mov saved_ebx, ebx \
@ -1498,7 +1502,7 @@ void TestMemcpy( void ) {
p_simd->Memcpy( test1, test0, 8192 ); p_simd->Memcpy( test1, test0, 8192 );
for ( j = 0; j < i; j++ ) { for ( j = 0; j < i; j++ ) {
if ( test1[j] != test0[j] ) { if ( test1[j] != test0[j] ) {
idLib::common->Printf( " simd->Memcpy() "S_COLOR_RED"X\n" ); idLib::common->Printf( " simd->Memcpy() " S_COLOR_RED "X\n" );
return; return;
} }
} }
@ -1524,7 +1528,7 @@ void TestMemset( void ) {
p_simd->Memset( test, j, i ); p_simd->Memset( test, j, i );
for ( k = 0; k < i; k++ ) { for ( k = 0; k < i; k++ ) {
if ( test[k] != (byte)j ) { if ( test[k] != (byte)j ) {
idLib::common->Printf( " simd->Memset() "S_COLOR_RED"X\n" ); idLib::common->Printf( " simd->Memset() " S_COLOR_RED "X\n" );
return; return;
} }
} }

View file

@ -68,8 +68,8 @@ If you have questions concerning this license or the applicable additional terms
#define IDVEC4_OFFSET 4 #define IDVEC4_OFFSET 4
// Alignment tests // Alignment tests
#define IS_16BYTE_ALIGNED( x ) ( ( (unsigned long)&x & 0x0F ) == 0 ) #define IS_16BYTE_ALIGNED( x ) ( ( (unsigned int)&x & 0x0F ) == 0 )
#define NOT_16BYTE_ALIGNED( x ) ( ( (unsigned long)&x & 0x0F) != 0 ) #define NOT_16BYTE_ALIGNED( x ) ( ( (unsigned int)&x & 0x0F) != 0 )
// Aligned storing floats // Aligned storing floats
#define ALIGNED_STORE2( ADDR, V0, V1 ) \ #define ALIGNED_STORE2( ADDR, V0, V1 ) \
@ -7134,7 +7134,7 @@ void VPCALL idSIMD_AltiVec::DeriveTangents( idPlane *planes, idDrawVert *verts,
idPlane *planesPtr = planes; idPlane *planesPtr = planes;
for ( i = 0; i < numIndexes; i += 3 ) { for ( i = 0; i < numIndexes; i += 3 ) {
idDrawVert *a, *b, *c; idDrawVert *a, *b, *c;
// unsigned long signBit; // unsigned int signBit;
float d0[5], d1[5], area; float d0[5], d1[5], area;
idVec3 n, t0, t1; idVec3 n, t0, t1;
float f1, f2, f3; float f1, f2, f3;

View file

@ -2499,7 +2499,7 @@ void VPCALL idSIMD_Generic::DeriveTangents( idPlane *planes, idDrawVert *verts,
idPlane *planesPtr = planes; idPlane *planesPtr = planes;
for ( i = 0; i < numIndexes; i += 3 ) { for ( i = 0; i < numIndexes; i += 3 ) {
idDrawVert *a, *b, *c; idDrawVert *a, *b, *c;
unsigned long signBit; unsigned int signBit;
float d0[5], d1[5], f, area; float d0[5], d1[5], f, area;
idVec3 n, t0, t1; idVec3 n, t0, t1;
@ -2540,7 +2540,7 @@ void VPCALL idSIMD_Generic::DeriveTangents( idPlane *planes, idDrawVert *verts,
// area sign bit // area sign bit
area = d0[3] * d1[4] - d0[4] * d1[3]; area = d0[3] * d1[4] - d0[4] * d1[3];
signBit = ( *(unsigned long *)&area ) & ( 1 << 31 ); signBit = ( *(unsigned int *)&area ) & ( 1 << 31 );
// first tangent // first tangent
t0[0] = d0[0] * d1[4] - d0[4] * d1[0]; t0[0] = d0[0] * d1[4] - d0[4] * d1[0];
@ -2548,7 +2548,7 @@ void VPCALL idSIMD_Generic::DeriveTangents( idPlane *planes, idDrawVert *verts,
t0[2] = d0[2] * d1[4] - d0[4] * d1[2]; t0[2] = d0[2] * d1[4] - d0[4] * d1[2];
f = idMath::RSqrt( t0.x * t0.x + t0.y * t0.y + t0.z * t0.z ); f = idMath::RSqrt( t0.x * t0.x + t0.y * t0.y + t0.z * t0.z );
*(unsigned long *)&f ^= signBit; *(unsigned int *)&f ^= signBit;
t0.x *= f; t0.x *= f;
t0.y *= f; t0.y *= f;
@ -2560,7 +2560,7 @@ void VPCALL idSIMD_Generic::DeriveTangents( idPlane *planes, idDrawVert *verts,
t1[2] = d0[3] * d1[2] - d0[2] * d1[3]; t1[2] = d0[3] * d1[2] - d0[2] * d1[3];
f = idMath::RSqrt( t1.x * t1.x + t1.y * t1.y + t1.z * t1.z ); f = idMath::RSqrt( t1.x * t1.x + t1.y * t1.y + t1.z * t1.z );
*(unsigned long *)&f ^= signBit; *(unsigned int *)&f ^= signBit;
t1.x *= f; t1.x *= f;
t1.y *= f; t1.y *= f;

View file

@ -1017,16 +1017,16 @@ void VPCALL idSIMD_SSE::Dot( float *dst, const idVec3 &constant, const idPlane *
ALIGN8_INIT1( unsigned short SIMD_W_zero, 0 ); ALIGN8_INIT1( unsigned short SIMD_W_zero, 0 );
ALIGN8_INIT1( unsigned short SIMD_W_maxShort, 1<<15 ); ALIGN8_INIT1( unsigned short SIMD_W_maxShort, 1<<15 );
ALIGN4_INIT1( unsigned long SIMD_DW_mat2quatShuffle0, (3<<0)|(2<<8)|(1<<16)|(0<<24) ); ALIGN4_INIT1( unsigned int SIMD_DW_mat2quatShuffle0, (3<<0)|(2<<8)|(1<<16)|(0<<24) );
ALIGN4_INIT1( unsigned long SIMD_DW_mat2quatShuffle1, (0<<0)|(1<<8)|(2<<16)|(3<<24) ); ALIGN4_INIT1( unsigned int SIMD_DW_mat2quatShuffle1, (0<<0)|(1<<8)|(2<<16)|(3<<24) );
ALIGN4_INIT1( unsigned long SIMD_DW_mat2quatShuffle2, (1<<0)|(0<<8)|(3<<16)|(2<<24) ); ALIGN4_INIT1( unsigned int SIMD_DW_mat2quatShuffle2, (1<<0)|(0<<8)|(3<<16)|(2<<24) );
ALIGN4_INIT1( unsigned long SIMD_DW_mat2quatShuffle3, (2<<0)|(3<<8)|(0<<16)|(1<<24) ); ALIGN4_INIT1( unsigned int SIMD_DW_mat2quatShuffle3, (2<<0)|(3<<8)|(0<<16)|(1<<24) );
ALIGN4_INIT4( unsigned long SIMD_SP_singleSignBitMask, (unsigned long) ( 1 << 31 ), 0, 0, 0 ); ALIGN4_INIT4( unsigned int SIMD_SP_singleSignBitMask, (unsigned int) ( 1 << 31 ), 0, 0, 0 );
ALIGN4_INIT1( unsigned long SIMD_SP_signBitMask, (unsigned long) ( 1 << 31 ) ); ALIGN4_INIT1( unsigned int SIMD_SP_signBitMask, (unsigned int) ( 1 << 31 ) );
ALIGN4_INIT1( unsigned long SIMD_SP_absMask, (unsigned long) ~( 1 << 31 ) ); ALIGN4_INIT1( unsigned int SIMD_SP_absMask, (unsigned int) ~( 1 << 31 ) );
ALIGN4_INIT1( unsigned long SIMD_SP_infinityMask, (unsigned long) ~( 1 << 23 ) ); ALIGN4_INIT1( unsigned int SIMD_SP_infinityMask, (unsigned int) ~( 1 << 23 ) );
ALIGN4_INIT1( unsigned long SIMD_SP_not, 0xFFFFFFFF ); ALIGN4_INIT1( unsigned int SIMD_SP_not, 0xFFFFFFFF );
ALIGN4_INIT1( float SIMD_SP_zero, 0.0f ); ALIGN4_INIT1( float SIMD_SP_zero, 0.0f );
ALIGN4_INIT1( float SIMD_SP_half, 0.5f ); ALIGN4_INIT1( float SIMD_SP_half, 0.5f );
@ -1950,7 +1950,7 @@ float SSE_ATan( float y, float x ) {
if ( fabs( y ) > fabs( x ) ) { if ( fabs( y ) > fabs( x ) ) {
a = -x / y; a = -x / y;
d = idMath::HALF_PI; d = idMath::HALF_PI;
*((unsigned long *)&d) ^= ( *((unsigned long *)&x) ^ *((unsigned long *)&y) ) & (1<<31); *((unsigned int *)&d) ^= ( *((unsigned int *)&x) ^ *((unsigned int *)&y) ) & (1<<31);
} else { } else {
a = y / x; a = y / x;
d = 0.0f; d = 0.0f;
@ -11527,7 +11527,7 @@ void VPCALL idSIMD_SSE::BlendJoints( idJointQuat *joints, const idJointQuat *ble
ALIGN16( float omega1[4] ); ALIGN16( float omega1[4] );
ALIGN16( float scale0[4] ); ALIGN16( float scale0[4] );
ALIGN16( float scale1[4] ); ALIGN16( float scale1[4] );
ALIGN16( unsigned long signBit[4] ); ALIGN16( unsigned int signBit[4] );
cosom[0] = jointQuat0[0] * blendQuat0[0]; cosom[0] = jointQuat0[0] * blendQuat0[0];
cosom[1] = jointQuat0[1] * blendQuat0[1]; cosom[1] = jointQuat0[1] * blendQuat0[1];
@ -11549,15 +11549,15 @@ void VPCALL idSIMD_SSE::BlendJoints( idJointQuat *joints, const idJointQuat *ble
cosom[2] += jointQuat3[2] * blendQuat3[2]; cosom[2] += jointQuat3[2] * blendQuat3[2];
cosom[3] += jointQuat3[3] * blendQuat3[3]; cosom[3] += jointQuat3[3] * blendQuat3[3];
signBit[0] = (*(unsigned long *)&cosom[0]) & ( 1 << 31 ); signBit[0] = (*(unsigned int *)&cosom[0]) & ( 1 << 31 );
signBit[1] = (*(unsigned long *)&cosom[1]) & ( 1 << 31 ); signBit[1] = (*(unsigned int *)&cosom[1]) & ( 1 << 31 );
signBit[2] = (*(unsigned long *)&cosom[2]) & ( 1 << 31 ); signBit[2] = (*(unsigned int *)&cosom[2]) & ( 1 << 31 );
signBit[3] = (*(unsigned long *)&cosom[3]) & ( 1 << 31 ); signBit[3] = (*(unsigned int *)&cosom[3]) & ( 1 << 31 );
(*(unsigned long *)&cosom[0]) ^= signBit[0]; (*(unsigned int *)&cosom[0]) ^= signBit[0];
(*(unsigned long *)&cosom[1]) ^= signBit[1]; (*(unsigned int *)&cosom[1]) ^= signBit[1];
(*(unsigned long *)&cosom[2]) ^= signBit[2]; (*(unsigned int *)&cosom[2]) ^= signBit[2];
(*(unsigned long *)&cosom[3]) ^= signBit[3]; (*(unsigned int *)&cosom[3]) ^= signBit[3];
scale0[0] = 1.0f - cosom[0] * cosom[0]; scale0[0] = 1.0f - cosom[0] * cosom[0];
scale0[1] = 1.0f - cosom[1] * cosom[1]; scale0[1] = 1.0f - cosom[1] * cosom[1];
@ -11604,10 +11604,10 @@ void VPCALL idSIMD_SSE::BlendJoints( idJointQuat *joints, const idJointQuat *ble
scale1[2] = SSE_SinZeroHalfPI( omega1[2] ) * sinom[2]; scale1[2] = SSE_SinZeroHalfPI( omega1[2] ) * sinom[2];
scale1[3] = SSE_SinZeroHalfPI( omega1[3] ) * sinom[3]; scale1[3] = SSE_SinZeroHalfPI( omega1[3] ) * sinom[3];
(*(unsigned long *)&scale1[0]) ^= signBit[0]; (*(unsigned int *)&scale1[0]) ^= signBit[0];
(*(unsigned long *)&scale1[1]) ^= signBit[1]; (*(unsigned int *)&scale1[1]) ^= signBit[1];
(*(unsigned long *)&scale1[2]) ^= signBit[2]; (*(unsigned int *)&scale1[2]) ^= signBit[2];
(*(unsigned long *)&scale1[3]) ^= signBit[3]; (*(unsigned int *)&scale1[3]) ^= signBit[3];
jointQuat0[0] = scale0[0] * jointQuat0[0] + scale1[0] * blendQuat0[0]; jointQuat0[0] = scale0[0] * jointQuat0[0] + scale1[0] * blendQuat0[0];
jointQuat0[1] = scale0[1] * jointQuat0[1] + scale1[1] * blendQuat0[1]; jointQuat0[1] = scale0[1] * jointQuat0[1] + scale1[1] * blendQuat0[1];
@ -11663,13 +11663,13 @@ void VPCALL idSIMD_SSE::BlendJoints( idJointQuat *joints, const idJointQuat *ble
float omega; float omega;
float scale0; float scale0;
float scale1; float scale1;
unsigned long signBit; unsigned int signBit;
cosom = jointQuat.x * blendQuat.x + jointQuat.y * blendQuat.y + jointQuat.z * blendQuat.z + jointQuat.w * blendQuat.w; cosom = jointQuat.x * blendQuat.x + jointQuat.y * blendQuat.y + jointQuat.z * blendQuat.z + jointQuat.w * blendQuat.w;
signBit = (*(unsigned long *)&cosom) & ( 1 << 31 ); signBit = (*(unsigned int *)&cosom) & ( 1 << 31 );
(*(unsigned long *)&cosom) ^= signBit; (*(unsigned int *)&cosom) ^= signBit;
scale0 = 1.0f - cosom * cosom; scale0 = 1.0f - cosom * cosom;
scale0 = ( scale0 <= 0.0f ) ? SIMD_SP_tiny[0] : scale0; scale0 = ( scale0 <= 0.0f ) ? SIMD_SP_tiny[0] : scale0;
@ -11678,7 +11678,7 @@ void VPCALL idSIMD_SSE::BlendJoints( idJointQuat *joints, const idJointQuat *ble
scale0 = idMath::Sin16( ( 1.0f - lerp ) * omega ) * sinom; scale0 = idMath::Sin16( ( 1.0f - lerp ) * omega ) * sinom;
scale1 = idMath::Sin16( lerp * omega ) * sinom; scale1 = idMath::Sin16( lerp * omega ) * sinom;
(*(unsigned long *)&scale1) ^= signBit; (*(unsigned int *)&scale1) ^= signBit;
jointQuat.x = scale0 * jointQuat.x + scale1 * blendQuat.x; jointQuat.x = scale0 * jointQuat.x + scale1 * blendQuat.x;
jointQuat.y = scale0 * jointQuat.y + scale1 * blendQuat.y; jointQuat.y = scale0 * jointQuat.y + scale1 * blendQuat.y;
@ -13664,7 +13664,7 @@ void VPCALL idSIMD_SSE::DeriveTangents( idPlane *planes, idDrawVert *verts, cons
for ( i = 0; i <= numIndexes - 12; i += 12 ) { for ( i = 0; i <= numIndexes - 12; i += 12 ) {
idDrawVert *a, *b, *c; idDrawVert *a, *b, *c;
ALIGN16( unsigned long signBit[4] ); ALIGN16( unsigned int signBit[4] );
ALIGN16( float d0[4] ); ALIGN16( float d0[4] );
ALIGN16( float d1[4] ); ALIGN16( float d1[4] );
ALIGN16( float d2[4] ); ALIGN16( float d2[4] );
@ -13967,10 +13967,10 @@ void VPCALL idSIMD_SSE::DeriveTangents( idPlane *planes, idDrawVert *verts, cons
tmp[2] -= d4[2] * d8[2]; tmp[2] -= d4[2] * d8[2];
tmp[3] -= d4[3] * d8[3]; tmp[3] -= d4[3] * d8[3];
signBit[0] = ( *(unsigned long *)&tmp[0] ) & ( 1 << 31 ); signBit[0] = ( *(unsigned int *)&tmp[0] ) & ( 1 << 31 );
signBit[1] = ( *(unsigned long *)&tmp[1] ) & ( 1 << 31 ); signBit[1] = ( *(unsigned int *)&tmp[1] ) & ( 1 << 31 );
signBit[2] = ( *(unsigned long *)&tmp[2] ) & ( 1 << 31 ); signBit[2] = ( *(unsigned int *)&tmp[2] ) & ( 1 << 31 );
signBit[3] = ( *(unsigned long *)&tmp[3] ) & ( 1 << 31 ); signBit[3] = ( *(unsigned int *)&tmp[3] ) & ( 1 << 31 );
// first tangent // first tangent
t0[0] = d0[0] * d9[0]; t0[0] = d0[0] * d9[0];
@ -14023,10 +14023,10 @@ void VPCALL idSIMD_SSE::DeriveTangents( idPlane *planes, idDrawVert *verts, cons
tmp[2] = idMath::RSqrt( tmp[2] ); tmp[2] = idMath::RSqrt( tmp[2] );
tmp[3] = idMath::RSqrt( tmp[3] ); tmp[3] = idMath::RSqrt( tmp[3] );
*(unsigned long *)&tmp[0] ^= signBit[0]; *(unsigned int *)&tmp[0] ^= signBit[0];
*(unsigned long *)&tmp[1] ^= signBit[1]; *(unsigned int *)&tmp[1] ^= signBit[1];
*(unsigned long *)&tmp[2] ^= signBit[2]; *(unsigned int *)&tmp[2] ^= signBit[2];
*(unsigned long *)&tmp[3] ^= signBit[3]; *(unsigned int *)&tmp[3] ^= signBit[3];
t0[0] *= tmp[0]; t0[0] *= tmp[0];
t0[1] *= tmp[1]; t0[1] *= tmp[1];
@ -14094,10 +14094,10 @@ void VPCALL idSIMD_SSE::DeriveTangents( idPlane *planes, idDrawVert *verts, cons
tmp[2] = idMath::RSqrt( tmp[2] ); tmp[2] = idMath::RSqrt( tmp[2] );
tmp[3] = idMath::RSqrt( tmp[3] ); tmp[3] = idMath::RSqrt( tmp[3] );
*(unsigned long *)&tmp[0] ^= signBit[0]; *(unsigned int *)&tmp[0] ^= signBit[0];
*(unsigned long *)&tmp[1] ^= signBit[1]; *(unsigned int *)&tmp[1] ^= signBit[1];
*(unsigned long *)&tmp[2] ^= signBit[2]; *(unsigned int *)&tmp[2] ^= signBit[2];
*(unsigned long *)&tmp[3] ^= signBit[3]; *(unsigned int *)&tmp[3] ^= signBit[3];
t3[0] *= tmp[0]; t3[0] *= tmp[0];
t3[1] *= tmp[1]; t3[1] *= tmp[1];
@ -14220,7 +14220,7 @@ void VPCALL idSIMD_SSE::DeriveTangents( idPlane *planes, idDrawVert *verts, cons
for ( ; i < numIndexes; i += 3 ) { for ( ; i < numIndexes; i += 3 ) {
idDrawVert *a, *b, *c; idDrawVert *a, *b, *c;
ALIGN16( unsigned long signBit[4] ); ALIGN16( unsigned int signBit[4] );
float d0, d1, d2, d3, d4; float d0, d1, d2, d3, d4;
float d5, d6, d7, d8, d9; float d5, d6, d7, d8, d9;
float n0, n1, n2; float n0, n1, n2;
@ -14446,7 +14446,7 @@ void VPCALL idSIMD_SSE::DeriveTangents( idPlane *planes, idDrawVert *verts, cons
// area sign bit // area sign bit
tmp = d3 * d9 - d4 * d8; tmp = d3 * d9 - d4 * d8;
signBit[0] = ( *(unsigned long *)&tmp ) & ( 1 << 31 ); signBit[0] = ( *(unsigned int *)&tmp ) & ( 1 << 31 );
// first tangent // first tangent
t0 = d0 * d9 - d4 * d5; t0 = d0 * d9 - d4 * d5;
@ -14454,7 +14454,7 @@ void VPCALL idSIMD_SSE::DeriveTangents( idPlane *planes, idDrawVert *verts, cons
t2 = d2 * d9 - d4 * d7; t2 = d2 * d9 - d4 * d7;
tmp = idMath::RSqrt( t0 * t0 + t1 * t1 + t2 * t2 ); tmp = idMath::RSqrt( t0 * t0 + t1 * t1 + t2 * t2 );
*(unsigned long *)&tmp ^= signBit[0]; *(unsigned int *)&tmp ^= signBit[0];
t0 *= tmp; t0 *= tmp;
t1 *= tmp; t1 *= tmp;
@ -14466,7 +14466,7 @@ void VPCALL idSIMD_SSE::DeriveTangents( idPlane *planes, idDrawVert *verts, cons
t5 = d3 * d7 - d2 * d8; t5 = d3 * d7 - d2 * d8;
tmp = idMath::RSqrt( t3 * t3 + t4 * t4 + t5 * t5 ); tmp = idMath::RSqrt( t3 * t3 + t4 * t4 + t5 * t5 );
*(unsigned long *)&tmp ^= signBit[0]; *(unsigned int *)&tmp ^= signBit[0];
t3 *= tmp; t3 *= tmp;
t4 *= tmp; t4 *= tmp;

View file

@ -261,10 +261,10 @@ void VPCALL idSIMD_SSE2::CmpLT( byte *dst, const byte bitNum, const float *src0,
ALIGN8_INIT1( unsigned short SIMD_W_zero, 0 ); ALIGN8_INIT1( unsigned short SIMD_W_zero, 0 );
ALIGN8_INIT1( unsigned short SIMD_W_maxShort, 1<<15 ); ALIGN8_INIT1( unsigned short SIMD_W_maxShort, 1<<15 );
ALIGN4_INIT4( unsigned long SIMD_SP_singleSignBitMask, (unsigned long) ( 1 << 31 ), 0, 0, 0 ); ALIGN4_INIT4( unsigned int SIMD_SP_singleSignBitMask, (unsigned int) ( 1 << 31 ), 0, 0, 0 );
ALIGN4_INIT1( unsigned long SIMD_SP_signBitMask, (unsigned long) ( 1 << 31 ) ); ALIGN4_INIT1( unsigned int SIMD_SP_signBitMask, (unsigned int) ( 1 << 31 ) );
ALIGN4_INIT1( unsigned long SIMD_SP_absMask, (unsigned long) ~( 1 << 31 ) ); ALIGN4_INIT1( unsigned int SIMD_SP_absMask, (unsigned int) ~( 1 << 31 ) );
ALIGN4_INIT1( unsigned long SIMD_SP_infinityMask, (unsigned long) ~( 1 << 23 ) ); ALIGN4_INIT1( unsigned int SIMD_SP_infinityMask, (unsigned int) ~( 1 << 23 ) );
ALIGN4_INIT1( float SIMD_SP_zero, 0.0f ); ALIGN4_INIT1( float SIMD_SP_zero, 0.0f );
ALIGN4_INIT1( float SIMD_SP_one, 1.0f ); ALIGN4_INIT1( float SIMD_SP_one, 1.0f );

View file

@ -384,7 +384,9 @@ const char *idVec6::ToString( int precision ) const {
//=============================================================== //===============================================================
float idVecX::temp[VECX_MAX_TEMP+4]; float idVecX::temp[VECX_MAX_TEMP+4];
float * idVecX::tempPtr = (float *) ( ( (int) idVecX::temp + 15 ) & ~15 ); // flibit: 64 bit fix, changed int to intptr_t
float * idVecX::tempPtr = (float *) ( ( (intptr_t) idVecX::temp + 15 ) & ~15 );
// flibit end
int idVecX::tempIndex = 0; int idVecX::tempIndex = 0;
/* /*

View file

@ -1757,7 +1757,9 @@ ID_INLINE void idVecX::SetData( int length, float *data ) {
if ( p && ( p < idVecX::tempPtr || p >= idVecX::tempPtr + VECX_MAX_TEMP ) && alloced != -1 ) { if ( p && ( p < idVecX::tempPtr || p >= idVecX::tempPtr + VECX_MAX_TEMP ) && alloced != -1 ) {
Mem_Free16( p ); Mem_Free16( p );
} }
assert( ( ( (int) data ) & 15 ) == 0 ); // data must be 16 byte aligned // flibit: 64 bit fix, change int to intptr_t
assert( ( ( (intptr_t) data ) & 15 ) == 0 ); // data must be 16 byte aligned
// flibit End
p = data; p = data;
size = length; size = length;
alloced = -1; alloced = -1;

View file

@ -45,6 +45,8 @@ If you have questions concerning this license or the applicable additional terms
=============================================================================== ===============================================================================
*/ */
// flibit: 64 bit fix, changed long to int
#ifdef INFINITY #ifdef INFINITY
#undef INFINITY #undef INFINITY
#endif #endif
@ -65,17 +67,17 @@ If you have questions concerning this license or the applicable additional terms
#define ANGLE2BYTE(x) ( idMath::FtoiFast( (x) * 256.0f / 360.0f ) & 255 ) #define ANGLE2BYTE(x) ( idMath::FtoiFast( (x) * 256.0f / 360.0f ) & 255 )
#define BYTE2ANGLE(x) ( (x) * ( 360.0f / 256.0f ) ) #define BYTE2ANGLE(x) ( (x) * ( 360.0f / 256.0f ) )
#define FLOATSIGNBITSET(f) ((*(const unsigned long *)&(f)) >> 31) #define FLOATSIGNBITSET(f) ((*(const unsigned int *)&(f)) >> 31)
#define FLOATSIGNBITNOTSET(f) ((~(*(const unsigned long *)&(f))) >> 31) #define FLOATSIGNBITNOTSET(f) ((~(*(const unsigned int *)&(f))) >> 31)
#define FLOATNOTZERO(f) ((*(const unsigned long *)&(f)) & ~(1<<31) ) #define FLOATNOTZERO(f) ((*(const unsigned int *)&(f)) & ~(1<<31) )
#define INTSIGNBITSET(i) (((const unsigned long)(i)) >> 31) #define INTSIGNBITSET(i) (((const unsigned int)(i)) >> 31)
#define INTSIGNBITNOTSET(i) ((~((const unsigned long)(i))) >> 31) #define INTSIGNBITNOTSET(i) ((~((const unsigned int)(i))) >> 31)
#define FLOAT_IS_NAN(x) (((*(const unsigned long *)&x) & 0x7f800000) == 0x7f800000) #define FLOAT_IS_NAN(x) (((*(const unsigned int *)&x) & 0x7f800000) == 0x7f800000)
#define FLOAT_IS_INF(x) (((*(const unsigned long *)&x) & 0x7fffffff) == 0x7f800000) #define FLOAT_IS_INF(x) (((*(const unsigned int *)&x) & 0x7fffffff) == 0x7f800000)
#define FLOAT_IS_IND(x) ((*(const unsigned long *)&x) == 0xffc00000) #define FLOAT_IS_IND(x) ((*(const unsigned int *)&x) == 0xffc00000)
#define FLOAT_IS_DENORMAL(x) (((*(const unsigned long *)&x) & 0x7f800000) == 0x00000000 && \ #define FLOAT_IS_DENORMAL(x) (((*(const unsigned int *)&x) & 0x7f800000) == 0x00000000 && \
((*(const unsigned long *)&x) & 0x007fffff) != 0x00000000 ) ((*(const unsigned int *)&x) & 0x007fffff) != 0x00000000 )
#define IEEE_FLT_MANTISSA_BITS 23 #define IEEE_FLT_MANTISSA_BITS 23
#define IEEE_FLT_EXPONENT_BITS 8 #define IEEE_FLT_EXPONENT_BITS 8
@ -185,8 +187,8 @@ public:
static float Rint( float f ); // returns the nearest integer static float Rint( float f ); // returns the nearest integer
static int Ftoi( float f ); // float to int conversion static int Ftoi( float f ); // float to int conversion
static int FtoiFast( float f ); // fast float to int conversion but uses current FPU round mode (default round nearest) static int FtoiFast( float f ); // fast float to int conversion but uses current FPU round mode (default round nearest)
static unsigned long Ftol( float f ); // float to long conversion static unsigned int Ftol( float f ); // float to long conversion
static unsigned long FtolFast( float ); // fast float to long conversion but uses current FPU round mode (default round nearest) static unsigned int FtolFast( float ); // fast float to long conversion but uses current FPU round mode (default round nearest)
static signed char ClampChar( int i ); static signed char ClampChar( int i );
static signed short ClampShort( int i ); static signed short ClampShort( int i );
@ -243,11 +245,11 @@ private:
ID_INLINE float idMath::RSqrt( float x ) { ID_INLINE float idMath::RSqrt( float x ) {
long i; int i;
float y, r; float y, r;
y = x * 0.5f; y = x * 0.5f;
i = *reinterpret_cast<long *>( &x ); i = *reinterpret_cast<int *>( &x );
i = 0x5f3759df - ( i >> 1 ); i = 0x5f3759df - ( i >> 1 );
r = *reinterpret_cast<float *>( &i ); r = *reinterpret_cast<float *>( &i );
r = r * ( 1.5f - r * r * y ); r = r * ( 1.5f - r * r * y );
@ -391,7 +393,7 @@ ID_INLINE double idMath::Cos64( float a ) {
} }
ID_INLINE void idMath::SinCos( float a, float &s, float &c ) { ID_INLINE void idMath::SinCos( float a, float &s, float &c ) {
#ifdef _WIN32 #if defined(_WIN32) && !defined(_WIN64)
_asm { _asm {
fld a fld a
fsincos fsincos
@ -444,7 +446,7 @@ ID_INLINE void idMath::SinCos16( float a, float &s, float &c ) {
} }
ID_INLINE void idMath::SinCos64( float a, double &s, double &c ) { ID_INLINE void idMath::SinCos64( float a, double &s, double &c ) {
#ifdef _WIN32 #if defined(_WIN32) && !defined(_WIN64)
_asm { _asm {
fld a fld a
fsincos fsincos
@ -802,7 +804,7 @@ ID_INLINE int idMath::Ftoi( float f ) {
} }
ID_INLINE int idMath::FtoiFast( float f ) { ID_INLINE int idMath::FtoiFast( float f ) {
#ifdef _WIN32 #if defined(_WIN32) && !defined(_WIN64)
int i; int i;
__asm fld f __asm fld f
__asm fistp i // use default rouding mode (round nearest) __asm fistp i // use default rouding mode (round nearest)
@ -829,14 +831,14 @@ ID_INLINE int idMath::FtoiFast( float f ) {
#endif #endif
} }
ID_INLINE unsigned long idMath::Ftol( float f ) { ID_INLINE unsigned int idMath::Ftol( float f ) {
return (unsigned long) f; return (unsigned int) f;
} }
ID_INLINE unsigned long idMath::FtolFast( float f ) { ID_INLINE unsigned int idMath::FtolFast( float f ) {
#ifdef _WIN32 #if defined(_WIN32) && !defined(_WIN64)
// FIXME: this overflows on 31bits still .. same as FtoiFast // FIXME: this overflows on 31bits still .. same as FtoiFast
unsigned long i; unsigned int i;
__asm fld f __asm fld f
__asm fistp i // use default rouding mode (round nearest) __asm fistp i // use default rouding mode (round nearest)
return i; return i;
@ -859,10 +861,12 @@ ID_INLINE unsigned long idMath::FtolFast( float f ) {
: "m" (f) ); : "m" (f) );
return i; return i;
#else #else
return (unsigned long) f; return (unsigned int) f;
#endif #endif
} }
// flibit end
ID_INLINE signed char idMath::ClampChar( int i ) { ID_INLINE signed char idMath::ClampChar( int i ) {
if ( i < -128 ) { if ( i < -128 ) {
return -128; return -128;

View file

@ -114,8 +114,14 @@ using std::min;
#ifdef _WIN32 // TODO: have main for windows match mac/linux #ifdef _WIN32 // TODO: have main for windows match mac/linux
#define SDL_MAIN_HANDLED 1 #define SDL_MAIN_HANDLED 1
#endif
#include "../sdl2/include/SDL.h" #include "../sdl2/include/SDL.h"
#else
#ifdef __APPLE__
#include <SDL.h>
#else
#include <SDL2/SDL.h> // Really should just be SDL.h but oh welllll -flibit
#endif
#endif
// non-portable system services // non-portable system services
#include "../sys/sys_public.h" #include "../sys/sys_public.h"

View file

@ -1 +0,0 @@
link libopenal.so.1

View file

@ -1 +0,0 @@
link libopenal.so.1.16.0

Binary file not shown.

View file

@ -1 +0,0 @@
Versions/Current/Headers

View file

@ -1 +0,0 @@
Versions/Current/OpenAL

View file

@ -1 +0,0 @@
Versions/Current/Resources

View file

@ -1,498 +0,0 @@
#ifndef _AL_H_
#define _AL_H_
/**
* OpenAL cross platform audio library
* Copyright (C) 1999-2000 by authors.
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
* Or go to http://www.gnu.org/copyleft/lgpl.html
*/
#include "altypes.h"
#ifdef __cplusplus
extern "C" {
#endif
#ifdef _WIN32
#ifdef _LIB
#define ALAPI __declspec(dllexport)
#else
#define ALAPI __declspec(dllimport)
#endif
#define ALAPIENTRY __cdecl
#define AL_CALLBACK
#else
#ifdef TARGET_OS_MAC
#if TARGET_OS_MAC
#pragma export on
#endif
#endif
#define ALAPI
#define ALAPIENTRY
#define AL_CALLBACK
#endif
#define OPENAL
#ifndef AL_NO_PROTOTYPES
/**
* OpenAL Maintenance Functions
* Initialization and exiting.
* State Management and Query.
* Error Handling.
* Extension Support.
*/
/** State management. */
ALAPI ALvoid ALAPIENTRY alEnable( ALenum capability );
ALAPI ALvoid ALAPIENTRY alDisable( ALenum capability );
ALAPI ALboolean ALAPIENTRY alIsEnabled( ALenum capability );
/** Application preferences for driver performance choices. */
ALAPI ALvoid ALAPIENTRY alHint( ALenum target, ALenum mode );
/** State retrieval. */
ALAPI ALboolean ALAPIENTRY alGetBoolean( ALenum param );
ALAPI ALint ALAPIENTRY alGetInteger( ALenum param );
ALAPI ALfloat ALAPIENTRY alGetFloat( ALenum param );
ALAPI ALdouble ALAPIENTRY alGetDouble( ALenum param );
ALAPI ALvoid ALAPIENTRY alGetBooleanv( ALenum param, ALboolean* data );
ALAPI ALvoid ALAPIENTRY alGetIntegerv( ALenum param, ALint* data );
ALAPI ALvoid ALAPIENTRY alGetFloatv( ALenum param, ALfloat* data );
ALAPI ALvoid ALAPIENTRY alGetDoublev( ALenum param, ALdouble* data );
ALAPI ALubyte* ALAPIENTRY alGetString( ALenum param );
ALAPI ALvoid ALAPIENTRY alSetInteger( ALenum pname, ALint value );
ALAPI ALvoid ALAPIENTRY alSetDouble( ALenum pname, ALdouble value );
/**
* Error support.
* Obtain the most recent error generated in the AL state machine.
*/
ALAPI ALenum ALAPIENTRY alGetError();
/**
* Extension support.
* Obtain the address of a function (usually an extension)
* with the name fname. All addresses are context-independent.
*/
ALAPI ALboolean ALAPIENTRY alIsExtensionPresent( ALubyte* fname );
/**
* Extension support.
* Obtain the address of a function (usually an extension)
* with the name fname. All addresses are context-independent.
*/
ALAPI ALvoid* ALAPIENTRY alGetProcAddress( ALubyte* fname );
/**
* Extension support.
* Obtain the integer value of an enumeration (usually an extension) with the name ename.
*/
ALAPI ALenum ALAPIENTRY alGetEnumValue( ALubyte* ename );
/**
* LISTENER
* Listener is the sample position for a given context.
* The multi-channel (usually stereo) output stream generated
* by the mixer is parametrized by this Listener object:
* its position and velocity relative to Sources, within
* occluder and reflector geometry.
*/
/**
*
* Listener Environment: default 0.
*/
ALAPI ALvoid ALAPIENTRY alListeneri( ALenum param, ALint value );
/**
*
* Listener Gain: default 1.0f.
*/
ALAPI ALvoid ALAPIENTRY alListenerf( ALenum param, ALfloat value );
/**
*
* Listener Position.
* Listener Velocity.
*/
ALAPI ALvoid ALAPIENTRY alListener3f( ALenum param, ALfloat v1, ALfloat v2, ALfloat v3 );
/**
*
* Listener Position: ALfloat[3]
* Listener Velocity: ALfloat[3]
* Listener Orientation: ALfloat[6] (forward and up vector).
*/
ALAPI ALvoid ALAPIENTRY alListenerfv( ALenum param, ALfloat* values );
ALAPI ALvoid ALAPIENTRY alGetListeneri( ALenum param, ALint* value );
ALAPI ALvoid ALAPIENTRY alGetListenerf( ALenum param, ALfloat* value );
ALAPI ALvoid ALAPIENTRY alGetListener3f( ALenum param, ALfloat* v1, ALfloat* v2, ALfloat* v3 );
ALAPI ALvoid ALAPIENTRY alGetListenerfv( ALenum param, ALfloat* values );
/**
* SOURCE
* Source objects are by default localized. Sources
* take the PCM data provided in the specified Buffer,
* apply Source-specific modifications, and then
* submit them to be mixed according to spatial
* arrangement etc.
*/
/** Create Source objects. */
ALAPI ALvoid ALAPIENTRY alGenSources( ALsizei n, ALuint* sources );
/** Delete Source objects. */
ALAPI ALvoid ALAPIENTRY alDeleteSources( ALsizei n, ALuint* sources );
/** Verify a handle is a valid Source. */
ALAPI ALboolean ALAPIENTRY alIsSource( ALuint id );
/** Set an integer parameter for a Source object. */
ALAPI ALvoid ALAPIENTRY alSourcei( ALuint source, ALenum param, ALint value );
ALAPI ALvoid ALAPIENTRY alSourcef( ALuint source, ALenum param, ALfloat value );
ALAPI ALvoid ALAPIENTRY alSource3f( ALuint source, ALenum param, ALfloat v1, ALfloat v2, ALfloat v3 );
ALAPI ALvoid ALAPIENTRY alSourcefv( ALuint source, ALenum param, ALfloat* values );
/** Get an integer parameter for a Source object. */
ALAPI ALvoid ALAPIENTRY alGetSourcei( ALuint source, ALenum param, ALint* value );
ALAPI ALvoid ALAPIENTRY alGetSourcef( ALuint source, ALenum param, ALfloat* value );
ALAPI ALvoid ALAPIENTRY alGetSource3f( ALuint source, ALenum param, ALfloat* v1, ALfloat* v2, ALfloat* v3 );
ALAPI ALvoid ALAPIENTRY alGetSourcefv( ALuint source, ALenum param, ALfloat* values );
ALAPI ALvoid ALAPIENTRY alSourcePlayv( ALsizei n, ALuint *sources );
ALAPI ALvoid ALAPIENTRY alSourcePausev( ALsizei n, ALuint *sources );
ALAPI ALvoid ALAPIENTRY alSourceStopv( ALsizei n, ALuint *sources );
ALAPI ALvoid ALAPIENTRY alSourceRewindv(ALsizei n,ALuint *sources);
/** Activate a source, start replay. */
ALAPI ALvoid ALAPIENTRY alSourcePlay( ALuint source );
/**
* Pause a source,
* temporarily remove it from the mixer list.
*/
ALAPI ALvoid ALAPIENTRY alSourcePause( ALuint source );
/**
* Stop a source,
* temporarily remove it from the mixer list,
* and reset its internal state to pre-Play.
* To remove a Source completely, it has to be
* deleted following Stop, or before Play.
*/
ALAPI ALvoid ALAPIENTRY alSourceStop( ALuint source );
/**
* Rewinds a source,
* temporarily remove it from the mixer list,
* and reset its internal state to pre-Play.
*/
ALAPI ALvoid ALAPIENTRY alSourceRewind( ALuint source );
/**
* BUFFER
* Buffer objects are storage space for sample data.
* Buffers are referred to by Sources. There can be more than
* one Source using the same Buffer data. If Buffers have
* to be duplicated on a per-Source basis, the driver has to
* take care of allocation, copying, and deallocation as well
* as propagating buffer data changes.
*/
/** Buffer object generation. */
ALAPI ALvoid ALAPIENTRY alGenBuffers( ALsizei n, ALuint* buffers );
ALAPI ALvoid ALAPIENTRY alDeleteBuffers( ALsizei n, ALuint* buffers );
ALAPI ALboolean ALAPIENTRY alIsBuffer( ALuint buffer );
/**
* Specify the data to be filled into a buffer.
*/
ALAPI ALvoid ALAPIENTRY alBufferData( ALuint buffer,
ALenum format,
ALvoid* data,
ALsizei size,
ALsizei freq );
ALAPI ALvoid ALAPIENTRY alGetBufferi( ALuint buffer, ALenum param, ALint* value );
ALAPI ALvoid ALAPIENTRY alGetBufferf( ALuint buffer, ALenum param, ALfloat* value );
/**
* Queue stuff
*/
ALAPI ALvoid ALAPIENTRY alSourceQueueBuffers( ALuint source, ALsizei n, ALuint* buffers );
ALAPI ALvoid ALAPIENTRY alSourceUnqueueBuffers( ALuint source, ALsizei n, ALuint* buffers );
/**
* Knobs and dials
*/
ALAPI ALvoid ALAPIENTRY alDistanceModel( ALenum value );
ALAPI ALvoid ALAPIENTRY alDopplerFactor( ALfloat value );
ALAPI ALvoid ALAPIENTRY alDopplerVelocity( ALfloat value );
#else /* AL_NO_PROTOTYPES */
/**
* OpenAL Maintenance Functions
* Initialization and exiting.
* State Management and Query.
* Error Handling.
* Extension Support.
*/
/** State management. */
ALAPI ALvoid ALAPIENTRY (*alEnable)( ALenum capability );
ALAPI ALvoid ALAPIENTRY (*alDisable)( ALenum capability );
ALAPI ALboolean ALAPIENTRY (*alIsEnabled)( ALenum capability );
/** Application preferences for driver performance choices. */
ALAPI ALvoid ALAPIENTRY (*alHint)( ALenum target, ALenum mode );
/** State retrieval. */
ALAPI ALboolean ALAPIENTRY (*alGetBoolean)( ALenum param );
ALAPI ALint ALAPIENTRY (*alGetInteger)( ALenum param );
ALAPI ALfloat ALAPIENTRY (*alGetFloat)( ALenum param );
ALAPI ALdouble ALAPIENTRY (*alGetDouble)( ALenum param );
ALAPI ALvoid ALAPIENTRY (*alGetBooleanv)( ALenum param, ALboolean* data );
ALAPI ALvoid ALAPIENTRY (*alGetIntegerv)( ALenum param, ALint* data );
ALAPI ALvoid ALAPIENTRY (*alGetFloatv)( ALenum param, ALfloat* data );
ALAPI ALvoid ALAPIENTRY (*alGetDoublev)( ALenum param, ALdouble* data );
ALAPI ALubyte* ALAPIENTRY (*alGetString)( ALenum param );
ALAPI ALvoid ALAPIENTRY (*alSetInteger)( ALenum pname, ALint value );
ALAPI ALvoid ALAPIENTRY (*alSetDouble)( ALenum pname, ALdouble value );
/**
* Error support.
* Obtain the most recent error generated in the AL state machine.
*/
ALAPI ALenum ALAPIENTRY (*alGetError)( ALvoid );
/**
* Extension support.
* Obtain the address of a function (usually an extension)
* with the name fname. All addresses are context-independent.
*/
ALAPI ALboolean ALAPIENTRY (*alIsExtensionPresent)( ALubyte* fname );
/**
* Extension support.
* Obtain the address of a function (usually an extension)
* with the name fname. All addresses are context-independent.
*/
ALAPI ALvoid* ALAPIENTRY (*alGetProcAddress)( ALubyte* fname );
/**
* Extension support.
* Obtain the integer value of an enumeration (usually an extension) with the name ename.
*/
ALAPI ALenum ALAPIENTRY (*alGetEnumValue)( ALubyte* ename );
/**
* LISTENER
* Listener is the sample position for a given context.
* The multi-channel (usually stereo) output stream generated
* by the mixer is parametrized by this Listener object:
* its position and velocity relative to Sources, within
* occluder and reflector geometry.
*/
/**
*
* Listener Environment: default 0.
*/
ALAPI ALvoid ALAPIENTRY (*alListeneri)( ALenum param, ALint value );
/**
*
* Listener Gain: default 1.0f.
*/
ALAPI ALvoid ALAPIENTRY (*alListenerf)( ALenum param, ALfloat value );
/**
*
* Listener Position.
* Listener Velocity.
*/
ALAPI ALvoid ALAPIENTRY (*alListener3f)( ALenum param, ALfloat v1, ALfloat v2, ALfloat v3 );
/**
*
* Listener Position: ALfloat[3]
* Listener Velocity: ALfloat[3]
* Listener Orientation: ALfloat[6] (forward and up vector).
*/
ALAPI ALvoid ALAPIENTRY (*alListenerfv)( ALenum param, ALfloat* values );
ALAPI ALvoid ALAPIENTRY (*alGetListeneri)( ALenum param, ALint* value );
ALAPI ALvoid ALAPIENTRY (*alGetListenerf)( ALenum param, ALfloat* value );
ALAPI ALvoid ALAPIENTRY (*alGetListener3f)( ALenum param, ALfloat* v1, ALfloat* v2, ALfloat* v3 );
ALAPI ALvoid ALAPIENTRY (*alGetListenerfv)( ALenum param, ALfloat* values );
/**
* SOURCE
* Source objects are by default localized. Sources
* take the PCM data provided in the specified Buffer,
* apply Source-specific modifications, and then
* submit them to be mixed according to spatial
* arrangement etc.
*/
/** Create Source objects. */
ALAPI ALvoid ALAPIENTRY (*alGenSources)( ALsizei n, ALuint* sources );
/** Delete Source objects. */
ALAPI ALvoid ALAPIENTRY (*alDeleteSources)( ALsizei n, ALuint* sources );
/** Verify a handle is a valid Source. */
ALAPI ALboolean ALAPIENTRY (*alIsSource)( ALuint id );
/** Set an integer parameter for a Source object. */
ALAPI ALvoid ALAPIENTRY (*alSourcei)( ALuint source, ALenum param, ALint value );
ALAPI ALvoid ALAPIENTRY (*alSourcef)( ALuint source, ALenum param, ALfloat value );
ALAPI ALvoid ALAPIENTRY (*alSource3f)( ALuint source, ALenum param, ALfloat v1, ALfloat v2, ALfloat v3 );
ALAPI ALvoid ALAPIENTRY (*alSourcefv)( ALuint source, ALenum param, ALfloat* values );
/** Get an integer parameter for a Source object. */
ALAPI ALvoid ALAPIENTRY (*alGetSourcei)( ALuint source, ALenum param, ALint* value );
ALAPI ALvoid ALAPIENTRY (*alGetSourcef)( ALuint source, ALenum param, ALfloat* value );
ALAPI ALvoid ALAPIENTRY (*alGetSourcefv)( ALuint source, ALenum param, ALfloat* values );
ALAPI ALvoid ALAPIENTRY (*alSourcePlayv)( ALsizei n, ALuint *sources );
ALAPI ALvoid ALAPIENTRY (*alSourceStopv)( ALsizei n, ALuint *sources );
/** Activate a source, start replay. */
ALAPI ALvoid ALAPIENTRY (*alSourcePlay)( ALuint source );
/**
* Pause a source,
* temporarily remove it from the mixer list.
*/
ALAPI ALvoid ALAPIENTRY (*alSourcePause)( ALuint source );
/**
* Stop a source,
* temporarily remove it from the mixer list,
* and reset its internal state to pre-Play.
* To remove a Source completely, it has to be
* deleted following Stop, or before Play.
*/
ALAPI ALvoid ALAPIENTRY (*alSourceStop)( ALuint source );
/**
* BUFFER
* Buffer objects are storage space for sample data.
* Buffers are referred to by Sources. There can be more than
* one Source using the same Buffer data. If Buffers have
* to be duplicated on a per-Source basis, the driver has to
* take care of allocation, copying, and deallocation as well
* as propagating buffer data changes.
*/
/** Buffer object generation. */
ALAPI ALvoid ALAPIENTRY (*alGenBuffers)( ALsizei n, ALuint* buffers );
ALAPI ALvoid ALAPIENTRY (*alDeleteBuffers)( ALsizei n, ALuint* buffers );
ALAPI ALboolean ALAPIENTRY (*alIsBuffer)( ALuint buffer );
/**
* Specify the data to be filled into a buffer.
*/
ALAPI ALvoid ALAPIENTRY (*alBufferData)( ALuint buffer,
ALenum format,
ALvoid* data,
ALsizei size,
ALsizei freq );
ALAPI ALvoid ALAPIENTRY (*alGetBufferi)( ALuint buffer, ALenum param, ALint* value );
ALAPI ALvoid ALAPIENTRY (*alGetBufferf)( ALuint buffer, ALenum param, ALfloat* value );
/**
* Queue stuff
*/
ALAPI ALvoid ALAPIENTRY (*alSourceQueueBuffers)( ALuint source, ALsizei n, ALuint* buffers );
ALAPI ALvoid ALAPIENTRY (*alSourceUnqueueBuffers)( ALuint source, ALsizei n, ALuint* buffers );
/**
* Knobs and dials
*/
ALAPI ALvoid ALAPIENTRY (*alDistanceModel)( ALenum value );
ALAPI ALvoid ALAPIENTRY (*alDopplerFactor)( ALfloat value );
ALAPI ALvoid ALAPIENTRY (*alDopplerVelocity)( ALfloat value );
#endif /* AL_NO_PROTOTYPES */
#ifdef TARGET_OS_MAC
#if TARGET_OS_MAC
#pragma export off
#endif
#endif
#ifdef __cplusplus
}
#endif
#endif

View file

@ -1,88 +0,0 @@
#ifndef _ALC_H_
#define _ALC_H_
#include "altypes.h"
#include "alctypes.h"
#ifdef __cplusplus
extern "C" {
#endif
#ifdef _WIN32
#ifdef _LIB
#define ALCAPI __declspec(dllexport)
#else
#define ALCAPI __declspec(dllimport)
typedef ALCvoid ALCdevice;
typedef ALCvoid ALCcontext;
#endif
#define ALCAPIENTRY __cdecl
#else
#ifdef TARGET_OS_MAC
#if TARGET_OS_MAC
#pragma export on
#endif
#endif
#define ALCAPI
#define ALCAPIENTRY
typedef ALCvoid ALCdevice;
typedef ALCvoid ALCcontext;
#endif
#ifndef ALC_NO_PROTOTYPES
ALCAPI ALCubyte* ALCAPIENTRY alcGetString(ALCdevice *device,ALCenum param);
ALCAPI ALCvoid ALCAPIENTRY alcGetIntegerv(ALCdevice *device,ALCenum param,ALCsizei size,ALCint *data);
ALCAPI ALCdevice* ALCAPIENTRY alcOpenDevice(ALCubyte *deviceName);
ALCAPI ALCvoid ALCAPIENTRY alcCloseDevice(ALCdevice *device);
ALCAPI ALCcontext*ALCAPIENTRY alcCreateContext(ALCdevice *device,ALCint *attrList);
ALCAPI ALCboolean ALCAPIENTRY alcMakeContextCurrent(ALCcontext *context);
ALCAPI ALCvoid ALCAPIENTRY alcProcessContext(ALCcontext *context);
ALCAPI ALCcontext*ALCAPIENTRY alcGetCurrentContext();
ALCAPI ALCdevice* ALCAPIENTRY alcGetContextsDevice(ALCcontext *context);
ALCAPI ALCvoid ALCAPIENTRY alcSuspendContext(ALCcontext *context);
ALCAPI ALCvoid ALCAPIENTRY alcDestroyContext(ALCcontext *context);
ALCAPI ALCenum ALCAPIENTRY alcGetError(ALCdevice *device);
ALCAPI ALCboolean ALCAPIENTRY alcIsExtensionPresent(ALCdevice *device,ALCubyte *extName);
ALCAPI ALCvoid * ALCAPIENTRY alcGetProcAddress(ALCdevice *device,ALCubyte *funcName);
ALCAPI ALCenum ALCAPIENTRY alcGetEnumValue(ALCdevice *device,ALCubyte *enumName);
#else /* AL_NO_PROTOTYPES */
ALCAPI ALCubyte* ALCAPIENTRY (*alcGetString)(ALCdevice *device,ALCenum param);
ALCAPI ALCvoid ALCAPIENTRY (*alcGetIntegerv)(ALCdevice * device,ALCenum param,ALCsizei size,ALCint *data);
ALCAPI ALCdevice* ALCAPIENTRY (*alcOpenDevice)(ALubyte *deviceName);
ALCAPI ALCvoid ALCAPIENTRY (*alcCloseDevice)(ALCdevice *device);
ALCAPI ALCcontext*ALCAPIENTRY (*alcCreateContext)(ALCdevice *device,ALCint *attrList);
ALCAPI ALCboolean ALCAPIENTRY (*alcMakeContextCurrent)(ALCcontext *context);
ALCAPI ALCvoid ALCAPIENTRY (*alcProcessContext)(ALCcontext *context);
ALCAPI ALCcontext*ALCAPIENTRY (*alcGetCurrentContext)(ALCvoid);
ALCAPI ALCdevice* ALCAPIENTRY (*alcGetContextsDevice)(ALCcontext *context);
ALCAPI ALCvoid ALCAPIENTRY (*alcSuspendContext)(ALCcontext *context);
ALCAPI ALCvoid ALCAPIENTRY (*alcDestroyContext)(ALCcontext *context);
ALCAPI ALCenum ALCAPIENTRY (*alcGetError)(ALCdevice *device);
ALCAPI ALCboolean ALCAPIENTRY (*alcIsExtensionPresent)(ALCdevice *device,ALCubyte *extName);
ALCAPI ALCvoid * ALCAPIENTRY (*alcGetProcAddress)(ALCdevice *device,ALCubyte *funcName);
ALCAPI ALCenum ALCAPIENTRY (*alcGetEnumValue)(ALCdevice *device,ALCubyte *enumName);
#endif /* AL_NO_PROTOTYPES */
#ifdef TARGET_OS_MAC
#if TARGET_OS_MAC
#pragma export off
#endif
#endif
#ifdef __cplusplus
}
#endif
#endif

View file

@ -1,165 +0,0 @@
#ifndef _ALCTYPES_H_
#define _ALCTYPES_H_
/**
* OpenAL cross platform audio library
* Copyright (C) 1999-2000 by authors.
* Portions Copyright (C) 2004 by Apple Computer Inc.
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
* Or go to http://www.gnu.org/copyleft/lgpl.html
*/
#ifdef __cplusplus
extern "C" {
#endif
/** ALC boolean type. */
typedef char ALCboolean;
/** ALC 8bit signed byte. */
typedef char ALCbyte;
/** ALC 8bit unsigned byte. */
typedef unsigned char ALCubyte;
/** ALC 16bit signed short integer type. */
typedef short ALCshort;
/** ALC 16bit unsigned short integer type. */
typedef unsigned short ALCushort;
/** ALC 32bit unsigned integer type. */
typedef unsigned ALCuint;
/** ALC 32bit signed integer type. */
typedef int ALCint;
/** ALC 32bit floating point type. */
typedef float ALCfloat;
/** ALC 64bit double point type. */
typedef double ALCdouble;
/** ALC 32bit type. */
typedef unsigned int ALCsizei;
/** ALC void type */
typedef void ALCvoid;
/** ALC enumerations. */
typedef int ALCenum;
/* Bad value. */
#define ALC_INVALID (-1)
/* Boolean False. */
#define ALC_FALSE 0
/* Boolean True. */
#define ALC_TRUE 1
/** Errors: No Error. */
#define ALC_NO_ERROR ALC_FALSE
#define ALC_MAJOR_VERSION 0x1000
#define ALC_MINOR_VERSION 0x1001
#define ALC_ATTRIBUTES_SIZE 0x1002
#define ALC_ALL_ATTRIBUTES 0x1003
#define ALC_DEFAULT_DEVICE_SPECIFIER 0x1004
#define ALC_DEVICE_SPECIFIER 0x1005
#define ALC_EXTENSIONS 0x1006
#define ALC_FREQUENCY 0x1007
#define ALC_REFRESH 0x1008
#define ALC_SYNC 0x1009
/**
* The device argument does not name a valid dvice.
*/
#define ALC_INVALID_DEVICE 0xA001
/**
* The context argument does not name a valid context.
*/
#define ALC_INVALID_CONTEXT 0xA002
/**
* A function was called at inappropriate time,
* or in an inappropriate way, causing an illegal state.
* This can be an incompatible ALenum, object ID,
* and/or function.
*/
#define ALC_INVALID_ENUM 0xA003
/**
* Illegal value passed as an argument to an AL call.
* Applies to parameter values, but not to enumerations.
*/
#define ALC_INVALID_VALUE 0xA004
/**
* A function could not be completed,
* because there is not enough memory available.
*/
#define ALC_OUT_OF_MEMORY 0xA005
//*********************************************************************************
// OSX Specific Properties
//*********************************************************************************
/**
* Convert Data When Loading. Default false, currently applies only to monophonic sounds
*/
#define ALC_CONVERT_DATA_UPON_LOADING 0xF001
/**
* Render Quality.
*/
#define ALC_SPATIAL_RENDERING_QUALITY 0xF002
#define ALC_SPATIAL_RENDERING_QUALITY_HIGH 'rqhi'
#define ALC_SPATIAL_RENDERING_QUALITY_LOW 'rdlo'
/**
* Mixer Output Rate.
*/
#define ALC_MIXER_OUTPUT_RATE 0xF003
/**
* Maximum Mixer Busses.
* Set this before opening a new OAL device to indicate how many busses on the mixer
* are desired. Get returns either the current devices bus count value, or the value
* that will be used to open a device
*/
#define ALC_MIXER_MAXIMUM_BUSSES 0xF004
/**
* Render Channels.
* Allows a user to force OpenAL to render to stereo, regardless of the audio hardware being used
*/
#define ALC_RENDER_CHANNEL_COUNT 0xF005
#define ALC_RENDER_CHANNEL_COUNT_STEREO 'rcst'
#define ALC_RENDER_CHANNEL_COUNT_MULTICHANNEL 'rcmc'
#ifdef __cplusplus
}
#endif
#endif

View file

@ -1,326 +0,0 @@
#ifndef _ALTYPES_H_
#define _ALTYPES_H_
/**
* OpenAL cross platform audio library
* Copyright (C) 1999-2000 by authors.
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
* Or go to http://www.gnu.org/copyleft/lgpl.html
*/
#ifdef __cplusplus
extern "C" {
#endif
/** OpenAL boolean type. */
typedef char ALboolean;
/** OpenAL 8bit signed byte. */
typedef char ALbyte;
/** OpenAL 8bit unsigned byte. */
typedef unsigned char ALubyte;
/** OpenAL 16bit signed short integer type. */
typedef short ALshort;
/** OpenAL 16bit unsigned short integer type. */
typedef unsigned short ALushort;
/** OpenAL 32bit unsigned integer type. */
typedef unsigned ALuint;
/** OpenAL 32bit signed integer type. */
typedef int ALint;
/** OpenAL 32bit floating point type. */
typedef float ALfloat;
/** OpenAL 64bit double point type. */
typedef double ALdouble;
/** OpenAL 32bit type. */
typedef unsigned int ALsizei;
/** OpenAL void type */
typedef void ALvoid;
/** OpenAL enumerations. */
typedef int ALenum;
/* Bad value. */
#define AL_INVALID (-1)
/* Disable value. */
#define AL_NONE 0
/* Boolean False. */
#define AL_FALSE 0
/* Boolean True. */
#define AL_TRUE 1
/**
* Indicate the type of AL_SOURCE.
* Sources can be spatialized
*/
#define AL_SOURCE_TYPE 0x200
/** Indicate source has absolute coordinates. */
#define AL_SOURCE_ABSOLUTE 0x201
/** Indicate Source has listener relative coordinates. */
#define AL_SOURCE_RELATIVE 0x202
/**
* Directional source, inner cone angle, in degrees.
* Range: [0-360]
* Default: 360
*/
#define AL_CONE_INNER_ANGLE 0x1001
/**
* Directional source, outer cone angle, in degrees.
* Range: [0-360]
* Default: 360
*/
#define AL_CONE_OUTER_ANGLE 0x1002
/**
* Specify the pitch to be applied, either at source,
* or on mixer results, at listener.
* Range: [0.5-2.0]
* Default: 1.0
*/
#define AL_PITCH 0x1003
/**
* Specify the current location in three dimensional space.
* OpenAL, like OpenGL, uses a right handed coordinate system,
* where in a frontal default view X (thumb) points right,
* Y points up (index finger), and Z points towards the
* viewer/camera (middle finger).
* To switch from a left handed coordinate system, flip the
* sign on the Z coordinate.
* Listener position is always in the world coordinate system.
*/
#define AL_POSITION 0x1004
/** Specify the current direction as forward vector. */
#define AL_DIRECTION 0x1005
/** Specify the current velocity in three dimensional space. */
#define AL_VELOCITY 0x1006
/**
* Indicate whether source has to loop infinite.
* Type: ALboolean
* Range: [AL_TRUE, AL_FALSE]
* Default: AL_FALSE
*/
#define AL_LOOPING 0x1007
/**
* Indicate the buffer to provide sound samples.
* Type: ALuint.
* Range: any valid Buffer id.
*/
#define AL_BUFFER 0x1009
/**
* Indicate the gain (volume amplification) applied.
* Type: ALfloat.
* Range: ]0.0- ]
* A value of 1.0 means un-attenuated/unchanged.
* Each division by 2 equals an attenuation of -6dB.
* Each multiplicaton with 2 equals an amplification of +6dB.
* A value of 0.0 is meaningless with respect to a logarithmic
* scale; it is interpreted as zero volume - the channel
* is effectively disabled.
*/
#define AL_GAIN 0x100A
/**
* Indicate minimum source attenuation.
* Type: ALfloat
* Range: [0.0 - 1.0]
*/
#define AL_MIN_GAIN 0x100D
/**
* Indicate maximum source attenuation.
* Type: ALfloat
* Range: [0.0 - 1.0]
*/
#define AL_MAX_GAIN 0x100E
/**
* Specify the current orientation.
* Type: ALfv6 (at/up)
* Range: N/A
*/
#define AL_ORIENTATION 0x100F
/* byte offset into source (in canon format). -1 if source
* is not playing. Don't set this, get this.
*
* Type: ALfloat
* Range: [0.0 - ]
* Default: 1.0
*/
#define AL_REFERENCE_DISTANCE 0x1020
/**
* Indicate the rolloff factor for the source.
* Type: ALfloat
* Range: [0.0 - ]
* Default: 1.0
*/
#define AL_ROLLOFF_FACTOR 0x1021
/**
* Indicate the gain (volume amplification) applied.
* Type: ALfloat.
* Range: ]0.0- ]
* A value of 1.0 means un-attenuated/unchanged.
* Each division by 2 equals an attenuation of -6dB.
* Each multiplicaton with 2 equals an amplification of +6dB.
* A value of 0.0 is meaningless with respect to a logarithmic
* scale; it is interpreted as zero volume - the channel
* is effectively disabled.
*/
#define AL_CONE_OUTER_GAIN 0x1022
/**
* Specify the maximum distance.
* Type: ALfloat
* Range: [0.0 - ]
*/
#define AL_MAX_DISTANCE 0x1023
/**
* Source state information
*/
#define AL_SOURCE_STATE 0x1010
#define AL_INITIAL 0x1011
#define AL_PLAYING 0x1012
#define AL_PAUSED 0x1013
#define AL_STOPPED 0x1014
/**
* Buffer Queue params
*/
#define AL_BUFFERS_QUEUED 0x1015
#define AL_BUFFERS_PROCESSED 0x1016
/** Sound buffers: format specifier. */
#define AL_FORMAT_MONO8 0x1100
#define AL_FORMAT_MONO16 0x1101
#define AL_FORMAT_STEREO8 0x1102
#define AL_FORMAT_STEREO16 0x1103
/**
* Sound buffers: frequency, in units of Hertz [Hz].
* This is the number of samples per second. Half of the
* sample frequency marks the maximum significant
* frequency component.
*/
#define AL_FREQUENCY 0x2001
#define AL_BITS 0x2002
#define AL_CHANNELS 0x2003
#define AL_SIZE 0x2004
#define AL_DATA 0x2005
/**
* Buffer state.
*
* Not supported for public use (yet).
*/
#define AL_UNUSED 0x2010
#define AL_PENDING 0x2011
#define AL_PROCESSED 0x2012
/** Errors: No Error. */
#define AL_NO_ERROR AL_FALSE
/**
* Illegal name passed as an argument to an AL call.
*/
#define AL_INVALID_NAME 0xA001
/**
* Illegal enum passed as an argument to an AL call.
*/
#define AL_INVALID_ENUM 0xA002
/**
* Illegal value passed as an argument to an AL call.
* Applies to parameter values, but not to enumerations.
*/
#define AL_INVALID_VALUE 0xA003
/**
* A function was called at inappropriate time,
* or in an inappropriate way, causing an illegal state.
* This can be an incompatible ALenum, object ID,
* and/or function.
*/
#define AL_INVALID_OPERATION 0xA004
/**
* A function could not be completed,
* because there is not enough memory available.
*/
#define AL_OUT_OF_MEMORY 0xA005
/** Context strings: Vendor Name. */
#define AL_VENDOR 0xB001
#define AL_VERSION 0xB002
#define AL_RENDERER 0xB003
#define AL_EXTENSIONS 0xB004
/** Global tweakage. */
/**
* Doppler scale. Default 1.0
*/
#define AL_DOPPLER_FACTOR 0xC000
/**
* Doppler velocity. Default 1.0
*/
#define AL_DOPPLER_VELOCITY 0xC001
/**
* Distance model. Default AL_INVERSE_DISTANCE_CLAMPED
*/
#define AL_DISTANCE_MODEL 0xD000
/** Distance models. */
#define AL_INVERSE_DISTANCE 0xD001
#define AL_INVERSE_DISTANCE_CLAMPED 0xD002
/**
* enables
*/
#ifdef __cplusplus
}
#endif
#endif

View file

@ -1,55 +0,0 @@
/**
* OpenAL cross platform audio library
* Copyright (C) 1999-2000 by authors.
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
* Or go to http://www.gnu.org/copyleft/lgpl.html
*/
#ifndef _ALUT_H_
#define _ALUT_H_
#define ALUTAPI
#define ALUTAPIENTRY
#include "al.h"
#ifdef __cplusplus
extern "C" {
#endif
#ifdef TARGET_OS_MAC
#if TARGET_OS_MAC
#pragma export on
#endif
#endif
ALUTAPI ALvoid ALUTAPIENTRY alutInit(ALint *argc,ALbyte **argv);
ALUTAPI ALvoid ALUTAPIENTRY alutExit(ALvoid);
ALUTAPI ALvoid ALUTAPIENTRY alutLoadWAVFile(ALbyte *file,ALenum *format,ALvoid **data,ALsizei *size,ALsizei *freq);
ALUTAPI ALvoid ALUTAPIENTRY alutLoadWAVMemory(ALbyte *memory,ALenum *format,ALvoid **data,ALsizei *size,ALsizei *freq);
ALUTAPI ALvoid ALUTAPIENTRY alutUnloadWAV(ALenum format,ALvoid *data,ALsizei size,ALsizei freq);
#ifdef TARGET_OS_MAC
#if TARGET_OS_MAC
#pragma export off
#endif
#endif
#ifdef __cplusplus
}
#endif
#endif

View file

@ -1,26 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>OpenAL</string>
<key>CFBundleGetInfoString</key>
<string>OpenAL</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>OpenAL</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>OpenAL</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.0.1d1</string>
<key>CSResourcesFileMapped</key>
<true/>
</dict>
</plist>

View file

@ -1,86 +0,0 @@
February 13th, 2004 - Apple Computer Inc.
updated: March 15th, 2004 - Apple Computer Inc.
----------------------------------------------------------------------------------------------------------------------
READ ME: OPEN AL - OSX IMPLEMENTATION USING THE 3DMIXER AUDIOUNIT
----------------------------------------------------------------------------------------------------------------------
This Read Me should accompany the 3DMixer implementation of OpenAL (Open Audio Library).
CoreAUdio SDK Requirements
-----------------------
Building this implementation of OpenAL for Mac OSX requires the latest CoreAudio SDK (version 1.3.1), due to it use
of new CoreAudio Public Utility classes.
CoreAudio Version requirements
-----------------------
There are Recommended and Minimum CoreAudio framework and component pieces for running this implementation
of OpenAL for Mac OSX:
Recommended:
------------
OSX: version 10.2.6 AND
QuickTime: version 6.5.1
AudioToolbox.framework (version 1.3.2)
AudioUnit.framework (version 1.3.2)
CoreAudio.component (version 1.3.2 - this version contains the 2.0 version of the 3DMixer AudioUnit)
Minimum:
------------
OSX: version 10.2 (Jaguar) AND
QuickTime: version 6.4
AudioToolbox.framework (version 1.2xxxxx)
AudioUnit.framework (version 1.2xxxxx)
CoreAudio.component (version 1.2xxxxxx - this version contains the 1.3 version of the 3DMixer AudioUnit)
----------------------------------------------------------------------------------------------------------------------
OpenAL Extensions:
----------------------------------------------------------------------------------------------------------------------
This implementation has the following OpenAL extensions. These constants can be found in the included "alctypes.h" header.
***** ALC_CONVERT_DATA_UPON_LOADING
This extension allows the caller to tell OpenAL to preconvert to the native CoreAudio format, the audio data passed to the
library with the alBufferData() call. Preconverting the audio data, reduces CPU usage by removing an audio data conversion
(per source) at render timem at the expense of a larger memory footprint.
This feature is toggled on/off by using the alDisable() & alEnable() APIs. This setting will be applied to all subsequent
calls to alBufferData().
***** ALC_SPATIAL_RENDERING_QUALITY
This extension allows the application to specify the quality of spatial rendering to better suit the resources of the CPU.
At this time, the quality settings are only applied when rendering to stereo hw. All multichannel rendering uses the same
spatilaization setting on the 3DMixer. Use the alSetInteger() & alGetInteger() APIs to specify and retrieve this setting.
This implmentation provides 2 setting constants: ALC_SPATIAL_RENDERING_QUALITY_HIGH (HRTF)
ALC_SPATIAL_RENDERING_QUALITY_LOW (EqualPowerPanning)
note: This implementation applies the setting to all the OAL Sources of an OAL Context. However, spatial settings can be applied to
each input bus of the 3DMixer, so it is possible to have this setting on a per OAL Source basis, allowing the developer to give
quality priorities to the various sounds used in an application.
note: Currently, all stereo sounds are 'passed thru' with no spatial rendering applied. This has the best output quality for rendering
what are typically background sound tracks. However, the 3DMixer has the ability to render a stereo source to a spatial coordinate
if this was desired and support to do so would be trivial.
***** ALC_MIXER_OUTPUT_RATE
This extension allows the developer to let the AudioGraph be efficient about sample rate conversion. If for example, all sounds
being played have a sample rate of 44k, but the output hardware is set to 48k, then it is best for the 3DMixer to leave the
the audio data (Mixer Outputut Rate) at 44k, letting the output AU rate convert the streams after they have been mixed. By default,
this is set to 44k which is very common sample rate for sound hw.
***** ALC_MIXER_MAXIMUM_BUSSES
This extension allows the developer to optimize the 3DMixer by setting it available input bus count. This allows the 3DMixer to be as
efficient as possible in resource allocations. By default, the 3DMixer currently defaults to 64 busses (note: the 1.3 version of the
3DMixer does not respect this setting, so always confirm the bus count with a get call, after setting the bus count and creating a new device).
Use: set the bus count before making a call to alOpenDevice(). This will cause the library to set the mixer to you desired bus count.
as it creates the AUGraph. Use the alSetInteger() & alGetInteger() APIs to specify and retrieve this setting.
***** ALC_RENDER_CHANNEL_COUNT
Because the audio system has no way to know if a user has actually connected a speaker to an output of the audio hardware, it may be desired
to allow the user to clamp all rendering to stereo. Use the alSetInteger() & alGetInteger() APIs to specify and retrieve this setting.
This implmentation provides 2 setting constants: ALC_RENDER_CHANNEL_COUNT_STEREO (clamp the 3DMixer output rendering to stereo, regardless of the hw capabilities)
ALC_RENDER_CHANNEL_COUNT_MULTICHANNEL (try and render to the maximum speakers possible by interrogating the device)
----------------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------------

View file

@ -1,8 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>PBXProjectSourcePath</key>
<string>/Users/mmarks/Development/OpenAL/openal/macosx/al_osx.xcode</string>
</dict>
</plist>

View file

@ -1 +0,0 @@
A

View file

@ -54,31 +54,36 @@ public:
virtual void ResetTime(int time); virtual void ResetTime(int time);
private: private:
unsigned int mcomp[256]; // RB: 64 bit fixes, changed int to size_t
size_t mcomp[256];
// RB end
byte ** qStatus[2]; byte ** qStatus[2];
idStr fileName; idStr fileName;
int CIN_WIDTH, CIN_HEIGHT; int CIN_WIDTH, CIN_HEIGHT;
idFile * iFile; idFile * iFile;
cinStatus_t status; cinStatus_t status;
long tfps; // RB: 64 bit fixes, changed long to int
long RoQPlayed; int tfps;
long ROQSize;
int RoQPlayed;
int ROQSize;
unsigned int RoQFrameSize; unsigned int RoQFrameSize;
long onQuad; int onQuad;
long numQuads; int numQuads;
long samplesPerLine; int samplesPerLine;
unsigned int roq_id; unsigned int roq_id;
long screenDelta; int screenDelta;
byte * buf; byte * buf;
long samplesPerPixel; // defaults to 2 int samplesPerPixel; // defaults to 2
unsigned int xsize, ysize, maxsize, minsize; unsigned int xsize, ysize, maxsize, minsize;
long normalBuffer0; int normalBuffer0;
long roq_flags; int roq_flags;
long roqF0; int roqF0;
long roqF1; int roqF1;
long t[2]; int t[2];
long roqFPS; int roqFPS;
long drawX, drawY; int drawX, drawY;
// RB end
int animationLength; int animationLength;
int startTime; int startTime;
@ -103,15 +108,17 @@ private:
void blit4_32( byte *src, byte *dst, int spl ); void blit4_32( byte *src, byte *dst, int spl );
void blit2_32( byte *src, byte *dst, int spl ); void blit2_32( byte *src, byte *dst, int spl );
unsigned short yuv_to_rgb( long y, long u, long v ); // RB: 64 bit fixes, changed long to int
unsigned int yuv_to_rgb24( long y, long u, long v ); unsigned short yuv_to_rgb( int y, int u, int v );
unsigned int yuv_to_rgb24( int y, int u, int v );
void decodeCodeBook( byte *input, unsigned short roq_flags ); void decodeCodeBook( byte *input, unsigned short roq_flags );
void recurseQuad( long startX, long startY, long quadSize, long xOff, long yOff ); void recurseQuad( int startX, int startY, int quadSize, int xOff, int yOff );
void setupQuad( long xOff, long yOff ); void setupQuad( int xOff, int yOff );
void readQuadInfo( byte *qData ); void readQuadInfo( byte *qData );
void RoQPrepMcomp( long xoff, long yoff ); void RoQPrepMcomp( int xoff, int yoff );
void RoQReset(); void RoQReset();
// RB end
}; };
const int DEFAULT_CIN_WIDTH = 512; const int DEFAULT_CIN_WIDTH = 512;
@ -131,11 +138,13 @@ const int ZA_SOUND_MONO = 0x1020;
const int ZA_SOUND_STEREO = 0x1021; const int ZA_SOUND_STEREO = 0x1021;
// temporary buffers used by all cinematics // temporary buffers used by all cinematics
static long ROQ_YY_tab[256]; // RB: 64 bit fixes, changed long to int
static long ROQ_UB_tab[256]; static int ROQ_YY_tab[256];
static long ROQ_UG_tab[256]; static int ROQ_UB_tab[256];
static long ROQ_VG_tab[256]; static int ROQ_UG_tab[256];
static long ROQ_VR_tab[256]; static int ROQ_VG_tab[256];
static int ROQ_VR_tab[256];
// RB end
static byte * file = NULL; static byte * file = NULL;
static unsigned short * vq2 = NULL; static unsigned short * vq2 = NULL;
static unsigned short * vq4 = NULL; static unsigned short * vq4 = NULL;
@ -150,9 +159,10 @@ static unsigned short * vq8 = NULL;
idCinematicLocal::InitCinematic idCinematicLocal::InitCinematic
============== ==============
*/ */
// RB: 64 bit fixes, changed long to int
void idCinematic::InitCinematic( void ) { void idCinematic::InitCinematic( void ) {
float t_ub,t_vr,t_ug,t_vg; float t_ub,t_vr,t_ug,t_vg;
long i; int i;
// generate YUV tables // generate YUV tables
t_ub = (1.77200f/2.0f) * (float)(1<<6) + 0.5f; t_ub = (1.77200f/2.0f) * (float)(1<<6) + 0.5f;
@ -162,11 +172,11 @@ void idCinematic::InitCinematic( void ) {
for( i = 0; i < 256; i++ ) { for( i = 0; i < 256; i++ ) {
float x = (float)(2 * i - 255); float x = (float)(2 * i - 255);
ROQ_UB_tab[i] = (long)( ( t_ub * x) + (1<<5)); ROQ_UB_tab[i] = (int)( ( t_ub * x) + (1<<5));
ROQ_VR_tab[i] = (long)( ( t_vr * x) + (1<<5)); ROQ_VR_tab[i] = (int)( ( t_vr * x) + (1<<5));
ROQ_UG_tab[i] = (long)( (-t_ug * x) ); ROQ_UG_tab[i] = (int)( (-t_ug * x) );
ROQ_VG_tab[i] = (long)( (-t_vg * x) + (1<<5)); ROQ_VG_tab[i] = (int)( (-t_vg * x) + (1<<5));
ROQ_YY_tab[i] = (long)( (i << 6) | (i >> 2) ); ROQ_YY_tab[i] = (int)( (i << 6) | (i >> 2) );
} }
file = (byte *)Mem_Alloc( 65536 ); file = (byte *)Mem_Alloc( 65536 );
@ -174,6 +184,7 @@ void idCinematic::InitCinematic( void ) {
vq4 = (word *)Mem_Alloc( 256*64*4 * sizeof( word ) ); vq4 = (word *)Mem_Alloc( 256*64*4 * sizeof( word ) );
vq8 = (word *)Mem_Alloc( 256*256*4 * sizeof( word ) ); vq8 = (word *)Mem_Alloc( 256*256*4 * sizeof( word ) );
} }
// RB end
/* /*
============== ==============
@ -931,8 +942,9 @@ void idCinematicLocal::blitVQQuad32fs( byte **status, unsigned char *data ) {
idCinematicLocal::yuv_to_rgb idCinematicLocal::yuv_to_rgb
============== ==============
*/ */
unsigned short idCinematicLocal::yuv_to_rgb( long y, long u, long v ) { // RB: 64 bit fixes, changed long to int
long r,g,b,YY = (long)(ROQ_YY_tab[(y)]); unsigned short idCinematicLocal::yuv_to_rgb( int y, int u, int v ) {
int r,g,b,YY = (int)(ROQ_YY_tab[(y)]);
r = (YY + ROQ_VR_tab[v]) >> 9; r = (YY + ROQ_VR_tab[v]) >> 9;
g = (YY + ROQ_UG_tab[u] + ROQ_VG_tab[v]) >> 8; g = (YY + ROQ_UG_tab[u] + ROQ_VG_tab[v]) >> 8;
@ -943,13 +955,15 @@ unsigned short idCinematicLocal::yuv_to_rgb( long y, long u, long v ) {
return (unsigned short)((r<<11)+(g<<5)+(b)); return (unsigned short)((r<<11)+(g<<5)+(b));
} }
// RB end
/* /*
============== ==============
idCinematicLocal::yuv_to_rgb24 idCinematicLocal::yuv_to_rgb24
============== ==============
*/ */
unsigned int idCinematicLocal::yuv_to_rgb24( long y, long u, long v ) { // RB: 64 bit fixes, changed long to int
unsigned int idCinematicLocal::yuv_to_rgb24( int y, int u, int v ) {
long r,g,b,YY = (long)(ROQ_YY_tab[(y)]); long r,g,b,YY = (long)(ROQ_YY_tab[(y)]);
r = (YY + ROQ_VR_tab[v]) >> 6; r = (YY + ROQ_VR_tab[v]) >> 6;
@ -961,16 +975,18 @@ unsigned int idCinematicLocal::yuv_to_rgb24( long y, long u, long v ) {
return LittleLong((r)+(g<<8)+(b<<16)); return LittleLong((r)+(g<<8)+(b<<16));
} }
// RB end
/* /*
============== ==============
idCinematicLocal::decodeCodeBook idCinematicLocal::decodeCodeBook
============== ==============
*/ */
// RB: 64 bit fixes, changed long to int
void idCinematicLocal::decodeCodeBook( byte *input, unsigned short roq_flags ) { void idCinematicLocal::decodeCodeBook( byte *input, unsigned short roq_flags ) {
long i, j, two, four; int i, j, two, four;
unsigned short *aptr, *bptr, *cptr, *dptr; unsigned short *aptr, *bptr, *cptr, *dptr;
long y0,y1,y2,y3,cr,cb; int y0,y1,y2,y3,cr,cb;
unsigned int *iaptr, *ibptr, *icptr, *idptr; unsigned int *iaptr, *ibptr, *icptr, *idptr;
if (!roq_flags) { if (!roq_flags) {
@ -992,12 +1008,12 @@ void idCinematicLocal::decodeCodeBook( byte *input, unsigned short roq_flags ) {
// //
if (samplesPerPixel==2) { if (samplesPerPixel==2) {
for(i=0;i<two;i++) { for(i=0;i<two;i++) {
y0 = (long)*input++; y0 = (int)*input++;
y1 = (long)*input++; y1 = (int)*input++;
y2 = (long)*input++; y2 = (int)*input++;
y3 = (long)*input++; y3 = (int)*input++;
cr = (long)*input++; cr = (int)*input++;
cb = (long)*input++; cb = (int)*input++;
*bptr++ = yuv_to_rgb( y0, cr, cb ); *bptr++ = yuv_to_rgb( y0, cr, cb );
*bptr++ = yuv_to_rgb( y1, cr, cb ); *bptr++ = yuv_to_rgb( y1, cr, cb );
*bptr++ = yuv_to_rgb( y2, cr, cb ); *bptr++ = yuv_to_rgb( y2, cr, cb );
@ -1016,12 +1032,12 @@ void idCinematicLocal::decodeCodeBook( byte *input, unsigned short roq_flags ) {
} else if (samplesPerPixel==4) { } else if (samplesPerPixel==4) {
ibptr = (unsigned int *)bptr; ibptr = (unsigned int *)bptr;
for(i=0;i<two;i++) { for(i=0;i<two;i++) {
y0 = (long)*input++; y0 = (int)*input++;
y1 = (long)*input++; y1 = (int)*input++;
y2 = (long)*input++; y2 = (int)*input++;
y3 = (long)*input++; y3 = (int)*input++;
cr = (long)*input++; cr = (int)*input++;
cb = (long)*input++; cb = (int)*input++;
*ibptr++ = yuv_to_rgb24( y0, cr, cb ); *ibptr++ = yuv_to_rgb24( y0, cr, cb );
*ibptr++ = yuv_to_rgb24( y1, cr, cb ); *ibptr++ = yuv_to_rgb24( y1, cr, cb );
*ibptr++ = yuv_to_rgb24( y2, cr, cb ); *ibptr++ = yuv_to_rgb24( y2, cr, cb );
@ -1044,12 +1060,12 @@ void idCinematicLocal::decodeCodeBook( byte *input, unsigned short roq_flags ) {
// //
if (samplesPerPixel==2) { if (samplesPerPixel==2) {
for(i=0;i<two;i++) { for(i=0;i<two;i++) {
y0 = (long)*input++; y0 = (int)*input++;
y1 = (long)*input++; y1 = (int)*input++;
y2 = (long)*input++; y2 = (int)*input++;
y3 = (long)*input++; y3 = (int)*input++;
cr = (long)*input++; cr = (int)*input++;
cb = (long)*input++; cb = (int)*input++;
*bptr++ = yuv_to_rgb( y0, cr, cb ); *bptr++ = yuv_to_rgb( y0, cr, cb );
*bptr++ = yuv_to_rgb( y1, cr, cb ); *bptr++ = yuv_to_rgb( y1, cr, cb );
*bptr++ = yuv_to_rgb( ((y0*3)+y2)/4, cr, cb ); *bptr++ = yuv_to_rgb( ((y0*3)+y2)/4, cr, cb );
@ -1074,12 +1090,12 @@ void idCinematicLocal::decodeCodeBook( byte *input, unsigned short roq_flags ) {
} else if (samplesPerPixel==4) { } else if (samplesPerPixel==4) {
ibptr = (unsigned int *)bptr; ibptr = (unsigned int *)bptr;
for(i=0;i<two;i++) { for(i=0;i<two;i++) {
y0 = (long)*input++; y0 = (int)*input++;
y1 = (long)*input++; y1 = (int)*input++;
y2 = (long)*input++; y2 = (int)*input++;
y3 = (long)*input++; y3 = (int)*input++;
cr = (long)*input++; cr = (int)*input++;
cb = (long)*input++; cb = (int)*input++;
*ibptr++ = yuv_to_rgb24( y0, cr, cb ); *ibptr++ = yuv_to_rgb24( y0, cr, cb );
*ibptr++ = yuv_to_rgb24( y1, cr, cb ); *ibptr++ = yuv_to_rgb24( y1, cr, cb );
*ibptr++ = yuv_to_rgb24( ((y0*3)+y2)/4, cr, cb ); *ibptr++ = yuv_to_rgb24( ((y0*3)+y2)/4, cr, cb );
@ -1109,10 +1125,10 @@ void idCinematicLocal::decodeCodeBook( byte *input, unsigned short roq_flags ) {
// //
if (samplesPerPixel==2) { if (samplesPerPixel==2) {
for(i=0;i<two;i++) { for(i=0;i<two;i++) {
y0 = (long)*input; input+=2; y0 = (int)*input; input+=2;
y2 = (long)*input; input+=2; y2 = (int)*input; input+=2;
cr = (long)*input++; cr = (int)*input++;
cb = (long)*input++; cb = (int)*input++;
*bptr++ = yuv_to_rgb( y0, cr, cb ); *bptr++ = yuv_to_rgb( y0, cr, cb );
*bptr++ = yuv_to_rgb( y2, cr, cb ); *bptr++ = yuv_to_rgb( y2, cr, cb );
} }
@ -1130,10 +1146,10 @@ void idCinematicLocal::decodeCodeBook( byte *input, unsigned short roq_flags ) {
} else if (samplesPerPixel == 4) { } else if (samplesPerPixel == 4) {
ibptr = (unsigned int *) bptr; ibptr = (unsigned int *) bptr;
for(i=0;i<two;i++) { for(i=0;i<two;i++) {
y0 = (long)*input; input+=2; y0 = (int)*input; input+=2;
y2 = (long)*input; input+=2; y2 = (int)*input; input+=2;
cr = (long)*input++; cr = (int)*input++;
cb = (long)*input++; cb = (int)*input++;
*ibptr++ = yuv_to_rgb24( y0, cr, cb ); *ibptr++ = yuv_to_rgb24( y0, cr, cb );
*ibptr++ = yuv_to_rgb24( y2, cr, cb ); *ibptr++ = yuv_to_rgb24( y2, cr, cb );
} }
@ -1151,16 +1167,18 @@ void idCinematicLocal::decodeCodeBook( byte *input, unsigned short roq_flags ) {
} }
} }
} }
// RB end
/* /*
============== ==============
idCinematicLocal::recurseQuad idCinematicLocal::recurseQuad
============== ==============
*/ */
void idCinematicLocal::recurseQuad( long startX, long startY, long quadSize, long xOff, long yOff ) { // RB: 64 bit fixes, changed long to int
void idCinematicLocal::recurseQuad( int startX, int startY, int quadSize, int xOff, int yOff ) {
byte *scroff; byte *scroff;
long bigx, bigy, lowx, lowy, useY; int bigx, bigy, lowx, lowy, useY;
long offset; int offset;
offset = screenDelta; offset = screenDelta;
@ -1187,14 +1205,16 @@ void idCinematicLocal::recurseQuad( long startX, long startY, long quadSize, lon
recurseQuad( startX+quadSize, startY+quadSize , quadSize, xOff, yOff ); recurseQuad( startX+quadSize, startY+quadSize , quadSize, xOff, yOff );
} }
} }
// RB end
/* /*
============== ==============
idCinematicLocal::setupQuad idCinematicLocal::setupQuad
============== ==============
*/ */
void idCinematicLocal::setupQuad( long xOff, long yOff ) { // RB: 64 bit fixes, changed long to int
long numQuadCels, i,x,y; void idCinematicLocal::setupQuad( int xOff, int yOff ) {
int numQuadCels, i,x,y;
byte *temp; byte *temp;
numQuadCels = (CIN_WIDTH*CIN_HEIGHT) / (16); numQuadCels = (CIN_WIDTH*CIN_HEIGHT) / (16);
@ -1207,8 +1227,8 @@ void idCinematicLocal::setupQuad( long xOff, long yOff ) {
onQuad = 0; onQuad = 0;
for(y=0;y<(long)ysize;y+=16) for(y=0;y<(int)ysize;y+=16)
for(x=0;x<(long)xsize;x+=16) for(x=0;x<(int)xsize;x+=16)
recurseQuad( x, y, 16, xOff, yOff ); recurseQuad( x, y, 16, xOff, yOff );
temp = NULL; temp = NULL;
@ -1218,6 +1238,7 @@ void idCinematicLocal::setupQuad( long xOff, long yOff ) {
qStatus[1][i] = temp; // eoq qStatus[1][i] = temp; // eoq
} }
} }
// RB end
/* /*
============== ==============
@ -1243,8 +1264,10 @@ void idCinematicLocal::readQuadInfo( byte *qData ) {
half = false; half = false;
smootheddouble = false; smootheddouble = false;
t[0] = (0 - (unsigned int)image)+(unsigned int)image+screenDelta; // flibit: 64 bit fix, changed unsigned int to uintptr_t
t[1] = (0 - ((unsigned int)image + screenDelta))+(unsigned int)image; t[0] = (0 - (uintptr_t)image)+(uintptr_t)image+screenDelta;
t[1] = (0 - ((uintptr_t)image + screenDelta))+(uintptr_t)image;
// flibit end
drawX = CIN_WIDTH; drawX = CIN_WIDTH;
drawY = CIN_HEIGHT; drawY = CIN_HEIGHT;
@ -1255,8 +1278,9 @@ void idCinematicLocal::readQuadInfo( byte *qData ) {
idCinematicLocal::RoQPrepMcomp idCinematicLocal::RoQPrepMcomp
============== ==============
*/ */
void idCinematicLocal::RoQPrepMcomp( long xoff, long yoff ) { // RB: 64 bit fixes, changed long to int
long i, j, x, y, temp, temp2; void idCinematicLocal::RoQPrepMcomp( int xoff, int yoff ) {
int i, j, x, y, temp, temp2;
i=samplesPerLine; j=samplesPerPixel; i=samplesPerLine; j=samplesPerPixel;
if ( xsize == (ysize*4) && !half ) { j = j+j; i = i+i; } if ( xsize == (ysize*4) && !half ) { j = j+j; i = i+i; }
@ -1269,6 +1293,7 @@ void idCinematicLocal::RoQPrepMcomp( long xoff, long yoff ) {
} }
} }
} }
// RB end
/* /*
============== ==============

View file

@ -1399,7 +1399,9 @@ bool idImage::CheckPrecompressedImage( bool fullLoad ) {
fileSystem->CloseFile( f ); fileSystem->CloseFile( f );
unsigned long magic = LittleLong( *(unsigned long *)data ); // flibit: 64 bit fix, changed long to int
unsigned int magic = LittleLong( *(unsigned int *)data );
// flibit end
ddsFileHeader_t *_header = (ddsFileHeader_t *)(data + 4); ddsFileHeader_t *_header = (ddsFileHeader_t *)(data + 4);
int ddspf_dwFlags = LittleLong( _header->ddspf.dwFlags ); int ddspf_dwFlags = LittleLong( _header->ddspf.dwFlags );

View file

@ -2676,8 +2676,10 @@ default surface is created.
int lwResolvePolySurfaces( lwPolygonList *polygon, lwTagList *tlist, int lwResolvePolySurfaces( lwPolygonList *polygon, lwTagList *tlist,
lwSurface **surf, int *nsurfs ) lwSurface **surf, int *nsurfs )
{ {
// flibit: 64 bit fix, changed int to intptr_t
lwSurface **s, *st; lwSurface **s, *st;
int i, index; int i;
intptr_t index;
if ( tlist->count == 0 ) return 1; if ( tlist->count == 0 ) return 1;
@ -2696,7 +2698,7 @@ int lwResolvePolySurfaces( lwPolygonList *polygon, lwTagList *tlist,
} }
for ( i = 0; i < polygon->count; i++ ) { for ( i = 0; i < polygon->count; i++ ) {
index = ( int ) polygon->pol[ i ].surf; index = ( intptr_t ) polygon->pol[ i ].surf;
if ( index < 0 || index > tlist->count ) return 0; if ( index < 0 || index > tlist->count ) return 0;
if ( !s[ index ] ) { if ( !s[ index ] ) {
s[ index ] = lwDefaultSurface(); s[ index ] = lwDefaultSurface();
@ -2712,6 +2714,7 @@ int lwResolvePolySurfaces( lwPolygonList *polygon, lwTagList *tlist,
Mem_Free( s ); Mem_Free( s );
return 1; return 1;
// flibit end
} }

View file

@ -4657,10 +4657,8 @@ GLAPI void APIENTRY glVertexBlendARB (GLint count);
#ifndef GL_ARB_vertex_buffer_object #ifndef GL_ARB_vertex_buffer_object
#define GL_ARB_vertex_buffer_object 1 #define GL_ARB_vertex_buffer_object 1
#if !defined(__APPLE__)
typedef ptrdiff_t GLsizeiptrARB; typedef ptrdiff_t GLsizeiptrARB;
typedef ptrdiff_t GLintptrARB; typedef ptrdiff_t GLintptrARB;
#endif
#define GL_BUFFER_SIZE_ARB 0x8764 #define GL_BUFFER_SIZE_ARB 0x8764
#define GL_BUFFER_USAGE_ARB 0x8765 #define GL_BUFFER_USAGE_ARB 0x8765
#define GL_ARRAY_BUFFER_ARB 0x8892 #define GL_ARRAY_BUFFER_ARB 0x8892

View file

@ -344,7 +344,9 @@ bool idRenderSystemLocal::RegisterFont( const char *fontName, fontInfoEx_t &font
idStr::Copynz( outFont->name, name, sizeof( outFont->name ) ); idStr::Copynz( outFont->name, name, sizeof( outFont->name ) );
len = fileSystem->ReadFile( name, NULL, &ftime ); len = fileSystem->ReadFile( name, NULL, &ftime );
if ( len != sizeof( fontInfo_t ) ) { // FIXME: BAD BAD BAD BAD BAD -flibit
//if ( len != sizeof( fontInfo_t ) ) {
if ( len <= 0 ) {
common->Warning( "RegisterFont: couldn't find font: '%s'", name ); common->Warning( "RegisterFont: couldn't find font: '%s'", name );
return false; return false;
} }

View file

@ -1 +0,0 @@
link libSDL2-2.0.so.0.4.0

Binary file not shown.

View file

@ -1 +0,0 @@
link libSDL2-2.0.so.0.4.0

Binary file not shown.

View file

@ -118,7 +118,7 @@ bool idEFXFile::ReadEffect( idLexer &src, idSoundEffect *effect ) {
if ( token == "environment" ) { if ( token == "environment" ) {
src.ReadTokenOnLine( &token ); src.ReadTokenOnLine( &token );
reverb->ulEnvironment = token.GetUnsignedLongValue(); reverb->ulEnvironment = token.GetUnsignedIntValue();
} else if ( token == "environment size" ) { } else if ( token == "environment size" ) {
reverb->flEnvironmentSize = src.ParseFloat(); reverb->flEnvironmentSize = src.ParseFloat();
} else if ( token == "environment diffusion" ) { } else if ( token == "environment diffusion" ) {
@ -169,7 +169,7 @@ bool idEFXFile::ReadEffect( idLexer &src, idSoundEffect *effect ) {
reverb->flRoomRolloffFactor = src.ParseFloat(); reverb->flRoomRolloffFactor = src.ParseFloat();
} else if ( token == "flags" ) { } else if ( token == "flags" ) {
src.ReadTokenOnLine( &token ); src.ReadTokenOnLine( &token );
reverb->ulFlags = token.GetUnsignedLongValue(); reverb->ulFlags = token.GetUnsignedIntValue();
} else { } else {
src.ReadTokenOnLine( &token ); src.ReadTokenOnLine( &token );
src.Error( "idEFXFile::ReadEffect: Invalid parameter in reverb definition" ); src.Error( "idEFXFile::ReadEffect: Invalid parameter in reverb definition" );

View file

@ -185,7 +185,9 @@ void idSoundChannel::Clear( void ) {
memset( &parms, 0, sizeof(parms) ); memset( &parms, 0, sizeof(parms) );
triggered = false; triggered = false;
openalSource = NULL; // flibit: 64 bit fix, changed NULL to 0
openalSource = 0;
// flibit end
openalStreamingOffset = 0; openalStreamingOffset = 0;
openalStreamingBuffer[0] = openalStreamingBuffer[1] = openalStreamingBuffer[2] = 0; openalStreamingBuffer[0] = openalStreamingBuffer[1] = openalStreamingBuffer[2] = 0;
lastopenalStreamingBuffer[0] = lastopenalStreamingBuffer[1] = lastopenalStreamingBuffer[2] = 0; lastopenalStreamingBuffer[0] = lastopenalStreamingBuffer[1] = lastopenalStreamingBuffer[2] = 0;

View file

@ -355,7 +355,9 @@ void idSoundSystemLocal::Init() {
} }
// make a 16 byte aligned finalMixBuffer // make a 16 byte aligned finalMixBuffer
finalMixBuffer = (float *) ( ( ( (int)realAccum ) + 15 ) & ~15 ); // flibit: 64 bit fix, changed int to intptr_t
finalMixBuffer = (float *) ( ( ( (intptr_t)realAccum ) + 15 ) & ~15 );
// flibit end
graph = NULL; graph = NULL;
@ -494,7 +496,9 @@ void idSoundSystemLocal::Shutdown() {
alDeleteSources( 1, &openalSources[i].handle ); alDeleteSources( 1, &openalSources[i].handle );
// clear entry in source array // clear entry in source array
openalSources[i].handle = NULL; // flibit: 64 bit fix, changed NULL to 0
openalSources[i].handle = 0;
// flibit end
openalSources[i].startTime = 0; openalSources[i].startTime = 0;
openalSources[i].chan = NULL; openalSources[i].chan = NULL;
openalSources[i].inUse = false; openalSources[i].inUse = false;
@ -1269,7 +1273,9 @@ ALuint idSoundSystemLocal::AllocOpenALSource( idSoundChannel *chan, bool looping
return openalSources[index].handle; return openalSources[index].handle;
} else { } else {
return NULL; // flibit: 64 bit fix, changed NULL to 0
return 0;
// flibit end
} }
} }
@ -1283,7 +1289,9 @@ void idSoundSystemLocal::FreeOpenALSource( ALuint handle ) {
for ( i = 0; i < openalSourceCount; i++ ) { for ( i = 0; i < openalSourceCount; i++ ) {
if ( openalSources[i].handle == handle ) { if ( openalSources[i].handle == handle ) {
if ( openalSources[i].chan ) { if ( openalSources[i].chan ) {
openalSources[i].chan->openalSource = NULL; // flibit: 64 bit fix, changed NULL to 0
openalSources[i].chan->openalSource = 0;
// flibit end
} }
#if ID_OPENAL #if ID_OPENAL
// Reset source EAX ROOM level when freeing stereo source // Reset source EAX ROOM level when freeing stereo source

View file

@ -589,7 +589,9 @@ void idSoundWorldLocal::AVIUpdate() {
} }
float mix[MIXBUFFER_SAMPLES*6+16]; float mix[MIXBUFFER_SAMPLES*6+16];
float *mix_p = (float *)((( int)mix + 15 ) & ~15); // SIMD align // flibit: 64 bit fix, changed int to intptr_t
float *mix_p = (float *)((( intptr_t)mix + 15 ) & ~15); // SIMD align
// flibit end
SIMDProcessor->Memset( mix_p, 0, MIXBUFFER_SAMPLES*sizeof(float)*numSpeakers ); SIMDProcessor->Memset( mix_p, 0, MIXBUFFER_SAMPLES*sizeof(float)*numSpeakers );
@ -1198,10 +1200,10 @@ void idSoundWorldLocal::WriteToSaveGameSoundChannel( idFile *saveGame, idSoundCh
saveGame->WriteInt( ch->trigger44kHzTime ); saveGame->WriteInt( ch->trigger44kHzTime );
saveGame->WriteInt( ch->triggerGame44kHzTime ); saveGame->WriteInt( ch->triggerGame44kHzTime );
WriteToSaveGameSoundShaderParams( saveGame, &ch->parms ); WriteToSaveGameSoundShaderParams( saveGame, &ch->parms );
saveGame->WriteInt( (int)ch->leadinSample ); saveGame->WriteInt( (int)(size_t)ch->leadinSample );
saveGame->WriteInt( ch->triggerChannel ); saveGame->WriteInt( ch->triggerChannel );
saveGame->WriteInt( (int)ch->soundShader ); saveGame->WriteInt( (int)(size_t)ch->soundShader );
saveGame->WriteInt( (int)ch->decoder ); saveGame->WriteInt( (int)(size_t)ch->decoder );
saveGame->WriteFloat(ch->diversity ); saveGame->WriteFloat(ch->diversity );
saveGame->WriteFloat(ch->lastVolume ); saveGame->WriteFloat(ch->lastVolume );
for (int m = 0; m < 6; m++) for (int m = 0; m < 6; m++)
@ -1714,7 +1716,9 @@ void idSoundWorldLocal::AddChannelContribution( idSoundEmitterLocal *sound, idSo
// //
int offset = current44kHz - chan->trigger44kHzTime; int offset = current44kHz - chan->trigger44kHzTime;
float inputSamples[MIXBUFFER_SAMPLES*2+16]; float inputSamples[MIXBUFFER_SAMPLES*2+16];
float *alignedInputSamples = (float *) ( ( ( (int)inputSamples ) + 15 ) & ~15 ); // flibit: 64 bit fix, changed int to intptr_t
float *alignedInputSamples = (float *) ( ( ( (intptr_t)inputSamples ) + 15 ) & ~15 );
// flibit end
// //
// allocate and initialize hardware source // allocate and initialize hardware source
@ -1764,7 +1768,9 @@ void idSoundWorldLocal::AddChannelContribution( idSoundEmitterLocal *sound, idSo
// handle streaming sounds (decode on the fly) both single shot AND looping // handle streaming sounds (decode on the fly) both single shot AND looping
if ( chan->triggered ) { if ( chan->triggered ) {
alSourcei( chan->openalSource, AL_BUFFER, NULL ); // flibit: 64 bit fix, changed NULL to 0
alSourcei( chan->openalSource, AL_BUFFER, 0 );
// flibit end
alDeleteBuffers( 3, &chan->lastopenalStreamingBuffer[0] ); alDeleteBuffers( 3, &chan->lastopenalStreamingBuffer[0] );
chan->lastopenalStreamingBuffer[0] = chan->openalStreamingBuffer[0]; chan->lastopenalStreamingBuffer[0] = chan->openalStreamingBuffer[0];
chan->lastopenalStreamingBuffer[1] = chan->openalStreamingBuffer[1]; chan->lastopenalStreamingBuffer[1] = chan->openalStreamingBuffer[1];

Some files were not shown because too many files have changed in this diff Show more