From b25e3505d3e88c3a902f346fe804e7bbbc55eb66 Mon Sep 17 00:00:00 2001 From: s1lent Date: Thu, 12 Oct 2017 21:50:56 +0700 Subject: [PATCH] Major refactoring & cleanup --- publish.gradle | 2 +- regamedll/build.gradle | 4 +- regamedll/common/const.h | 6 - regamedll/common/mathlib.h | 28 +- regamedll/dlls/activity.h | 84 +- regamedll/dlls/activitymap.h | 2 +- regamedll/dlls/airtank.h | 6 - regamedll/dlls/ammo.h | 6 - regamedll/dlls/animating.cpp | 3 +- regamedll/dlls/animation.cpp | 5 +- regamedll/dlls/animation.h | 6 - regamedll/dlls/basemonster.cpp | 1008 ++++++++++ regamedll/dlls/basemonster.h | 43 +- regamedll/dlls/bmodels.cpp | 73 +- regamedll/dlls/bmodels.h | 71 +- regamedll/dlls/bot/cs_bot.cpp | 169 +- regamedll/dlls/bot/cs_bot.h | 156 +- regamedll/dlls/bot/cs_bot_chatter.cpp | 210 +-- regamedll/dlls/bot/cs_bot_chatter.h | 10 +- regamedll/dlls/bot/cs_bot_event.cpp | 66 +- regamedll/dlls/bot/cs_bot_init.cpp | 110 +- regamedll/dlls/bot/cs_bot_learn.cpp | 43 +- regamedll/dlls/bot/cs_bot_listen.cpp | 5 +- regamedll/dlls/bot/cs_bot_manager.cpp | 148 +- regamedll/dlls/bot/cs_bot_manager.h | 8 +- regamedll/dlls/bot/cs_bot_nav.cpp | 38 +- regamedll/dlls/bot/cs_bot_pathfind.cpp | 109 +- regamedll/dlls/bot/cs_bot_radio.cpp | 37 +- regamedll/dlls/bot/cs_bot_statemachine.cpp | 22 +- regamedll/dlls/bot/cs_bot_update.cpp | 58 +- regamedll/dlls/bot/cs_bot_vision.cpp | 313 +++- regamedll/dlls/bot/cs_bot_weapon.cpp | 158 +- regamedll/dlls/bot/cs_gamestate.cpp | 98 +- regamedll/dlls/bot/cs_gamestate.h | 8 +- regamedll/dlls/bot/states/cs_bot_attack.cpp | 52 +- regamedll/dlls/bot/states/cs_bot_buy.cpp | 79 +- .../bot/states/cs_bot_escape_from_bomb.cpp | 4 +- .../dlls/bot/states/cs_bot_fetch_bomb.cpp | 6 +- regamedll/dlls/bot/states/cs_bot_follow.cpp | 14 +- regamedll/dlls/bot/states/cs_bot_hide.cpp | 26 +- regamedll/dlls/bot/states/cs_bot_hunt.cpp | 31 +- regamedll/dlls/bot/states/cs_bot_idle.cpp | 34 +- regamedll/dlls/bot/states/cs_bot_move_to.cpp | 24 +- .../dlls/bot/states/cs_bot_plant_bomb.cpp | 6 +- regamedll/dlls/buttons.cpp | 57 +- regamedll/dlls/buttons.h | 43 +- regamedll/dlls/career_tasks.cpp | 16 +- regamedll/dlls/career_tasks.h | 6 - regamedll/dlls/cbase.cpp | 756 ++++++-- regamedll/dlls/cbase.h | 479 ++--- regamedll/dlls/cdll_dll.h | 110 +- regamedll/dlls/client.cpp | 413 +++-- regamedll/dlls/client.h | 110 +- regamedll/dlls/cmdhandler.cpp | 191 ++ .../cssdk/dlls/subs.h => dlls/cmdhandler.h} | 19 +- regamedll/dlls/combat.cpp | 1626 +---------------- regamedll/dlls/{h_ai.h => combat.h} | 78 +- regamedll/dlls/debug.cpp | 16 +- regamedll/dlls/debug.h | 30 +- regamedll/dlls/decals.h | 24 +- regamedll/dlls/doors.cpp | 32 +- regamedll/dlls/doors.h | 38 +- regamedll/dlls/effects.cpp | 64 +- regamedll/dlls/effects.h | 85 +- regamedll/dlls/ehandle.h | 226 +++ regamedll/dlls/enginecallback.h | 270 +-- regamedll/dlls/explode.cpp | 6 +- regamedll/dlls/explode.h | 20 +- regamedll/dlls/extdef.h | 6 +- regamedll/dlls/extdll.h | 8 +- regamedll/dlls/func_break.cpp | 23 +- regamedll/dlls/func_break.h | 37 +- regamedll/dlls/func_tank.cpp | 62 +- regamedll/dlls/func_tank.h | 47 +- regamedll/dlls/game.cpp | 4 +- regamedll/dlls/game.h | 22 +- regamedll/dlls/gamerules.cpp | 4 +- regamedll/dlls/gamerules.h | 107 +- regamedll/dlls/ggrenade.cpp | 104 +- regamedll/dlls/gib.cpp | 295 +++ .../{extra/cssdk/dlls/mortar.h => dlls/gib.h} | 36 +- regamedll/dlls/globals.cpp | 9 +- regamedll/dlls/globals.h | 14 +- regamedll/dlls/h_ai.cpp | 162 -- regamedll/dlls/h_battery.cpp | 29 +- regamedll/dlls/h_battery.h | 6 - regamedll/dlls/h_cycler.cpp | 17 +- regamedll/dlls/h_cycler.h | 8 +- regamedll/dlls/healthkit.cpp | 38 +- regamedll/dlls/healthkit.h | 6 - regamedll/dlls/hintmessage.cpp | 6 +- regamedll/dlls/hintmessage.h | 52 +- regamedll/dlls/hostage/hostage.cpp | 144 +- regamedll/dlls/hostage/hostage.h | 6 - regamedll/dlls/hostage/hostage_improv.cpp | 36 +- regamedll/dlls/hostage/hostage_improv.h | 11 +- regamedll/dlls/hostage/hostage_localnav.cpp | 20 +- regamedll/dlls/hostage/hostage_localnav.h | 20 +- regamedll/dlls/hostage/hostage_states.h | 12 +- .../dlls/hostage/states/hostage_animate.cpp | 14 +- .../dlls/hostage/states/hostage_escape.cpp | 17 +- .../dlls/hostage/states/hostage_follow.cpp | 9 +- .../dlls/hostage/states/hostage_idle.cpp | 37 +- .../dlls/hostage/states/hostage_retreat.cpp | 9 +- regamedll/dlls/items.cpp | 120 +- regamedll/dlls/items.h | 11 +- regamedll/dlls/lights.cpp | 6 +- regamedll/dlls/lights.h | 8 +- regamedll/dlls/mapinfo.h | 2 + regamedll/dlls/maprules.cpp | 148 +- regamedll/dlls/maprules.h | 160 +- regamedll/dlls/monsterevent.h | 20 +- regamedll/dlls/monsters.h | 134 +- regamedll/dlls/mortar.cpp | 34 +- regamedll/dlls/mortar.h | 6 - regamedll/dlls/mpstubb.cpp | 263 --- regamedll/dlls/multiplay_gamerules.cpp | 988 +++++----- regamedll/dlls/nodes.h | 69 - regamedll/dlls/observer.cpp | 48 +- regamedll/dlls/observer.h | 14 +- regamedll/dlls/pathcorner.cpp | 44 +- regamedll/dlls/pathcorner.h | 10 +- regamedll/dlls/plane.cpp | 30 - regamedll/dlls/plane.h | 49 - regamedll/dlls/plats.cpp | 116 +- regamedll/dlls/plats.h | 46 +- regamedll/dlls/player.cpp | 528 ++---- regamedll/dlls/player.h | 350 ++-- .../cssdk/dlls/extdll.h => dlls/qstring.h} | 106 +- regamedll/dlls/revert_saved.h | 6 - regamedll/dlls/saverestore.h | 6 - regamedll/dlls/schedule.h | 117 +- regamedll/dlls/scriptevent.h | 28 +- regamedll/dlls/singleplay_gamerules.cpp | 5 +- regamedll/dlls/skill.h | 12 +- regamedll/dlls/sound.cpp | 158 +- regamedll/dlls/sound.h | 80 +- regamedll/dlls/soundent.cpp | 12 +- regamedll/dlls/soundent.h | 45 +- regamedll/dlls/spectator.cpp | 6 +- regamedll/dlls/spectator.h | 6 - regamedll/dlls/subs.cpp | 52 +- regamedll/dlls/subs.h | 6 - regamedll/dlls/talkmonster.h | 6 - regamedll/dlls/training_gamerules.cpp | 44 +- regamedll/dlls/training_gamerules.h | 19 +- regamedll/dlls/trains.h | 37 +- regamedll/dlls/triggers.cpp | 161 +- regamedll/dlls/triggers.h | 137 +- regamedll/dlls/tutor.cpp | 56 +- regamedll/dlls/tutor.h | 6 - regamedll/dlls/tutor_base_states.cpp | 10 +- regamedll/dlls/tutor_base_states.h | 45 +- regamedll/dlls/tutor_base_tutor.cpp | 59 +- regamedll/dlls/tutor_base_tutor.h | 8 +- regamedll/dlls/tutor_cs_states.cpp | 139 +- regamedll/dlls/tutor_cs_states.h | 59 +- regamedll/dlls/tutor_cs_tutor.cpp | 1444 +++++++-------- regamedll/dlls/tutor_cs_tutor.h | 38 +- regamedll/dlls/unisignals.h | 12 +- regamedll/dlls/util.cpp | 492 +++-- regamedll/dlls/util.h | 157 +- regamedll/dlls/vector.h | 248 ++- regamedll/dlls/vehicle.cpp | 58 +- regamedll/dlls/vehicle.h | 43 +- regamedll/dlls/weapons.cpp | 77 +- regamedll/dlls/weapons.h | 656 ++++++- regamedll/dlls/weapontype.cpp | 540 +++--- regamedll/dlls/weapontype.h | 354 ++-- regamedll/dlls/world.cpp | 163 +- regamedll/dlls/world.h | 18 +- regamedll/dlls/wpn_shared.h | 598 ------ regamedll/dlls/wpn_shared/wpn_ak47.cpp | 10 +- regamedll/dlls/wpn_shared/wpn_aug.cpp | 10 +- regamedll/dlls/wpn_shared/wpn_awp.cpp | 10 +- regamedll/dlls/wpn_shared/wpn_c4.cpp | 18 +- regamedll/dlls/wpn_shared/wpn_deagle.cpp | 8 +- regamedll/dlls/wpn_shared/wpn_elite.cpp | 8 +- regamedll/dlls/wpn_shared/wpn_famas.cpp | 12 +- regamedll/dlls/wpn_shared/wpn_fiveseven.cpp | 8 +- regamedll/dlls/wpn_shared/wpn_flashbang.cpp | 2 +- regamedll/dlls/wpn_shared/wpn_g3sg1.cpp | 4 +- regamedll/dlls/wpn_shared/wpn_galil.cpp | 10 +- regamedll/dlls/wpn_shared/wpn_glock18.cpp | 10 +- regamedll/dlls/wpn_shared/wpn_hegrenade.cpp | 2 +- regamedll/dlls/wpn_shared/wpn_knife.cpp | 16 +- regamedll/dlls/wpn_shared/wpn_m249.cpp | 10 +- regamedll/dlls/wpn_shared/wpn_m3.cpp | 18 +- regamedll/dlls/wpn_shared/wpn_m4a1.cpp | 12 +- regamedll/dlls/wpn_shared/wpn_mac10.cpp | 10 +- regamedll/dlls/wpn_shared/wpn_mp5navy.cpp | 10 +- regamedll/dlls/wpn_shared/wpn_p228.cpp | 8 +- regamedll/dlls/wpn_shared/wpn_p90.cpp | 10 +- regamedll/dlls/wpn_shared/wpn_scout.cpp | 10 +- regamedll/dlls/wpn_shared/wpn_sg550.cpp | 18 +- regamedll/dlls/wpn_shared/wpn_sg552.cpp | 6 +- .../dlls/wpn_shared/wpn_smokegrenade.cpp | 2 +- regamedll/dlls/wpn_shared/wpn_tmp.cpp | 10 +- regamedll/dlls/wpn_shared/wpn_ump45.cpp | 10 +- regamedll/dlls/wpn_shared/wpn_usp.cpp | 8 +- regamedll/dlls/wpn_shared/wpn_xm1014.cpp | 12 +- regamedll/engine/eiface.h | 56 +- regamedll/engine/maintypes.h | 3 +- regamedll/engine/osconfig.h | 41 +- regamedll/engine/progdefs.h | 4 +- regamedll/engine/unicode_strtools.cpp | 4 +- .../GameDefinitionFile/regamedll-cs.fgd | 44 +- .../extra/cssdk/common/IGameServerData.h | 15 - regamedll/extra/cssdk/common/Sequence.h | 201 -- regamedll/extra/cssdk/common/SteamCommon.h | 703 ------- regamedll/extra/cssdk/common/beamdef.h | 62 - regamedll/extra/cssdk/common/cl_entity.h | 115 -- regamedll/extra/cssdk/common/com_model.h | 340 ---- regamedll/extra/cssdk/common/con_nprint.h | 38 - regamedll/extra/cssdk/common/const.h | 806 -------- regamedll/extra/cssdk/common/crc.h | 55 - regamedll/extra/cssdk/common/cvardef.h | 39 - regamedll/extra/cssdk/common/demo_api.h | 31 - regamedll/extra/cssdk/common/director_cmds.h | 38 - regamedll/extra/cssdk/common/dlight.h | 33 - regamedll/extra/cssdk/common/dll_state.h | 23 - regamedll/extra/cssdk/common/entity_state.h | 197 -- regamedll/extra/cssdk/common/entity_types.h | 26 - regamedll/extra/cssdk/common/enums.h | 27 - regamedll/extra/cssdk/common/event_api.h | 51 - regamedll/extra/cssdk/common/event_args.h | 50 - regamedll/extra/cssdk/common/event_flags.h | 47 - regamedll/extra/cssdk/common/hltv.h | 61 - regamedll/extra/cssdk/common/in_buttons.h | 38 - regamedll/extra/cssdk/common/ivoicetweak.h | 38 - regamedll/extra/cssdk/common/kbutton.h | 44 - regamedll/extra/cssdk/common/mathlib.h | 127 -- regamedll/extra/cssdk/common/net_api.h | 99 - regamedll/extra/cssdk/common/netadr.h | 40 - regamedll/extra/cssdk/common/nowin.h | 16 - regamedll/extra/cssdk/common/parsemsg.cpp | 259 --- regamedll/extra/cssdk/common/parsemsg.h | 66 - regamedll/extra/cssdk/common/particledef.h | 57 - regamedll/extra/cssdk/common/pmtrace.h | 43 - regamedll/extra/cssdk/common/port.h | 119 -- regamedll/extra/cssdk/common/qfont.h | 41 - regamedll/extra/cssdk/common/qlimits.h | 39 - regamedll/extra/cssdk/common/quakedef.h | 44 - regamedll/extra/cssdk/common/r_efx.h | 197 -- regamedll/extra/cssdk/common/r_studioint.h | 151 -- regamedll/extra/cssdk/common/ref_params.h | 75 - regamedll/extra/cssdk/common/screenfade.h | 24 - regamedll/extra/cssdk/common/studio_event.h | 29 - regamedll/extra/cssdk/common/triangleapi.h | 64 - regamedll/extra/cssdk/common/usercmd.h | 41 - regamedll/extra/cssdk/common/vmodes.h | 35 - regamedll/extra/cssdk/common/weaponinfo.h | 53 - regamedll/extra/cssdk/common/winsani_in.h | 7 - regamedll/extra/cssdk/common/winsani_out.h | 4 - regamedll/extra/cssdk/dlls/activity.h | 145 -- regamedll/extra/cssdk/dlls/activitymap.h | 111 -- regamedll/extra/cssdk/dlls/airtank.h | 42 - regamedll/extra/cssdk/dlls/ammo.h | 98 - regamedll/extra/cssdk/dlls/basemonster.h | 105 -- regamedll/extra/cssdk/dlls/bmodels.h | 150 -- regamedll/extra/cssdk/dlls/bot/cs_bot.h | 641 ------- .../extra/cssdk/dlls/bot/cs_bot_chatter.h | 339 ---- .../extra/cssdk/dlls/bot/cs_bot_manager.h | 145 -- regamedll/extra/cssdk/dlls/bot/cs_gamestate.h | 90 - regamedll/extra/cssdk/dlls/buttons.h | 109 -- regamedll/extra/cssdk/dlls/cbase.h | 383 ---- regamedll/extra/cssdk/dlls/cdll_dll.h | 127 -- regamedll/extra/cssdk/dlls/client.h | 97 - regamedll/extra/cssdk/dlls/csbot_dll.h | 50 - regamedll/extra/cssdk/dlls/decals.h | 83 - regamedll/extra/cssdk/dlls/doors.h | 93 - regamedll/extra/cssdk/dlls/effects.h | 407 ----- regamedll/extra/cssdk/dlls/enginecallback.h | 178 -- regamedll/extra/cssdk/dlls/explode.h | 55 - regamedll/extra/cssdk/dlls/extdef.h | 113 -- regamedll/extra/cssdk/dlls/func_break.h | 120 -- regamedll/extra/cssdk/dlls/func_tank.h | 159 -- regamedll/extra/cssdk/dlls/gamerules.h | 688 ------- regamedll/extra/cssdk/dlls/h_battery.h | 45 - regamedll/extra/cssdk/dlls/h_cycler.h | 104 -- regamedll/extra/cssdk/dlls/healthkit.h | 52 - regamedll/extra/cssdk/dlls/hintmessage.h | 81 - regamedll/extra/cssdk/dlls/hookchains.h | 121 -- regamedll/extra/cssdk/dlls/hostage/hostage.h | 233 --- .../extra/cssdk/dlls/hostage/hostage_improv.h | 333 ---- .../cssdk/dlls/hostage/hostage_localnav.h | 58 - .../extra/cssdk/dlls/hostage/hostage_states.h | 203 -- regamedll/extra/cssdk/dlls/items.h | 155 -- regamedll/extra/cssdk/dlls/lights.h | 50 - regamedll/extra/cssdk/dlls/mapinfo.h | 41 - regamedll/extra/cssdk/dlls/maprules.h | 236 --- regamedll/extra/cssdk/dlls/monsterevent.h | 44 - regamedll/extra/cssdk/dlls/monsters.h | 113 -- regamedll/extra/cssdk/dlls/observer.h | 32 - regamedll/extra/cssdk/dlls/pathcorner.h | 39 - regamedll/extra/cssdk/dlls/plats.h | 178 -- regamedll/extra/cssdk/dlls/player.h | 625 ------- regamedll/extra/cssdk/dlls/regamedll_api.h | 490 ----- regamedll/extra/cssdk/dlls/regamedll_common.h | 96 - regamedll/extra/cssdk/dlls/regamedll_const.h | 104 -- .../extra/cssdk/dlls/regamedll_interfaces.h | 302 --- regamedll/extra/cssdk/dlls/revert_saved.h | 49 - regamedll/extra/cssdk/dlls/skill.h | 53 - regamedll/extra/cssdk/dlls/sound.h | 141 -- regamedll/extra/cssdk/dlls/spectator.h | 33 - .../extra/cssdk/dlls/training_gamerules.h | 84 - regamedll/extra/cssdk/dlls/trains.h | 149 -- regamedll/extra/cssdk/dlls/triggers.h | 385 ---- regamedll/extra/cssdk/dlls/unisignals.h | 57 - regamedll/extra/cssdk/dlls/util.h | 173 -- regamedll/extra/cssdk/dlls/vector.h | 176 -- regamedll/extra/cssdk/dlls/vehicle.h | 53 - regamedll/extra/cssdk/dlls/weapons.h | 909 --------- regamedll/extra/cssdk/dlls/weapontype.h | 417 ----- regamedll/extra/cssdk/dlls/wpn_shared.h | 598 ------ regamedll/extra/cssdk/engine/FlightRecorder.h | 61 - regamedll/extra/cssdk/engine/Sequence.h | 201 -- regamedll/extra/cssdk/engine/archtypes.h | 66 - regamedll/extra/cssdk/engine/bspfile.h | 160 -- regamedll/extra/cssdk/engine/cmd_rehlds.h | 49 - regamedll/extra/cssdk/engine/common_rehlds.h | 78 - regamedll/extra/cssdk/engine/crc32c.cpp | 143 -- regamedll/extra/cssdk/engine/crc32c.h | 22 - regamedll/extra/cssdk/engine/custom.h | 96 - regamedll/extra/cssdk/engine/customentity.h | 38 - regamedll/extra/cssdk/engine/d_local.h | 43 - regamedll/extra/cssdk/engine/edict.h | 36 - regamedll/extra/cssdk/engine/eiface.h | 540 ------ regamedll/extra/cssdk/engine/keydefs.h | 131 -- regamedll/extra/cssdk/engine/maintypes.h | 52 - regamedll/extra/cssdk/engine/model.h | 409 ----- regamedll/extra/cssdk/engine/modelgen.h | 128 -- regamedll/extra/cssdk/engine/osconfig.h | 195 -- regamedll/extra/cssdk/engine/progdefs.h | 224 --- regamedll/extra/cssdk/engine/progs.h | 82 - regamedll/extra/cssdk/engine/rehlds_api.h | 300 --- .../extra/cssdk/engine/rehlds_interfaces.h | 132 -- regamedll/extra/cssdk/engine/shake.h | 57 - regamedll/extra/cssdk/engine/spritegn.h | 84 - regamedll/extra/cssdk/engine/static_map.h | 257 --- regamedll/extra/cssdk/engine/studio.h | 361 ---- regamedll/extra/cssdk/engine/sys_shared.cpp | 72 - regamedll/extra/cssdk/engine/sys_shared.h | 39 - regamedll/extra/cssdk/engine/userid_rehlds.h | 46 - regamedll/extra/cssdk/game_shared/GameEvent.h | 138 -- regamedll/extra/cssdk/game_shared/bitvec.h | 157 -- regamedll/extra/cssdk/game_shared/bot/bot.h | 164 -- .../cssdk/game_shared/bot/bot_constants.h | 47 - .../extra/cssdk/game_shared/bot/bot_manager.h | 72 - .../extra/cssdk/game_shared/bot/bot_profile.h | 116 -- .../extra/cssdk/game_shared/bot/bot_util.h | 141 -- .../extra/cssdk/game_shared/bot/improv.h | 120 -- regamedll/extra/cssdk/game_shared/bot/nav.h | 409 ----- .../extra/cssdk/game_shared/bot/nav_area.h | 320 ---- .../extra/cssdk/game_shared/bot/nav_node.h | 110 -- .../extra/cssdk/game_shared/bot/nav_path.h | 99 - .../game_shared/bot/simple_state_machine.h | 101 - regamedll/extra/cssdk/game_shared/counter.h | 188 -- .../extra/cssdk/game_shared/shared_util.h | 63 - .../extra/cssdk/game_shared/simple_checksum.h | 49 - .../extra/cssdk/game_shared/steam_util.h | 76 - .../extra/cssdk/game_shared/voice_common.h | 36 - .../extra/cssdk/game_shared/voice_gamemgr.h | 56 - regamedll/extra/cssdk/pm_shared/pm_defs.h | 192 -- regamedll/extra/cssdk/pm_shared/pm_info.h | 30 - .../extra/cssdk/pm_shared/pm_materials.h | 45 - regamedll/extra/cssdk/pm_shared/pm_movevars.h | 59 - regamedll/extra/cssdk/pm_shared/pm_shared.h | 75 - regamedll/extra/cssdk/public/FileSystem.h | 189 -- regamedll/extra/cssdk/public/basetypes.h | 275 --- regamedll/extra/cssdk/public/commonmacros.h | 30 - regamedll/extra/cssdk/public/interface.cpp | 263 --- regamedll/extra/cssdk/public/interface.h | 150 -- .../extra/cssdk/public/protected_things.h | 187 -- regamedll/extra/cssdk/public/tier0/dbg.cpp | 435 ----- regamedll/extra/cssdk/public/tier0/dbg.h | 453 ----- regamedll/extra/cssdk/public/tier0/platform.h | 630 ------- regamedll/extra/cssdk/public/utlmemory.h | 357 ---- regamedll/extra/cssdk/public/utlvector.h | 565 ------ regamedll/game_shared/GameEvent.h | 6 - regamedll/game_shared/bitvec.h | 6 - regamedll/game_shared/bot/bot.cpp | 6 +- regamedll/game_shared/bot/bot.h | 8 +- regamedll/game_shared/bot/bot_constants.h | 14 +- regamedll/game_shared/bot/bot_manager.cpp | 45 +- regamedll/game_shared/bot/bot_manager.h | 9 +- regamedll/game_shared/bot/bot_profile.cpp | 113 +- regamedll/game_shared/bot/bot_profile.h | 14 +- regamedll/game_shared/bot/bot_util.cpp | 207 +-- regamedll/game_shared/bot/bot_util.h | 26 +- regamedll/game_shared/bot/improv.h | 40 +- regamedll/game_shared/bot/nav.h | 53 +- regamedll/game_shared/bot/nav_area.cpp | 769 ++++---- regamedll/game_shared/bot/nav_area.h | 255 ++- regamedll/game_shared/bot/nav_file.cpp | 196 +- regamedll/game_shared/bot/nav_file.h | 17 +- regamedll/game_shared/bot/nav_node.cpp | 22 +- regamedll/game_shared/bot/nav_node.h | 8 +- regamedll/game_shared/bot/nav_path.cpp | 99 +- regamedll/game_shared/bot/nav_path.h | 40 +- .../game_shared/bot/simple_state_machine.h | 16 +- regamedll/game_shared/shared_util.cpp | 33 +- regamedll/game_shared/shared_util.h | 2 +- regamedll/game_shared/steam_util.h | 14 +- regamedll/game_shared/voice_common.h | 12 +- regamedll/game_shared/voice_gamemgr.cpp | 33 +- regamedll/game_shared/voice_gamemgr.h | 10 +- regamedll/hookers/hooker.cpp | 14 +- regamedll/hookers/hooker_impl.cpp | 10 +- regamedll/hookers/hooker_impl.h | 39 +- regamedll/hookers/hooklist.cpp | 48 +- regamedll/hookers/hooklist.h | 6 +- regamedll/hookers/memory.cpp | 18 +- regamedll/msvc/PreBuild.bat | 8 + regamedll/msvc/ReGameDLL.vcxproj | 60 +- regamedll/msvc/ReGameDLL.vcxproj.filters | 123 +- regamedll/pm_shared/pm_defs.h | 56 +- regamedll/pm_shared/pm_shared.cpp | 271 +-- regamedll/public/FileSystem.h | 196 +- regamedll/public/MemPool.cpp | 28 + regamedll/public/MemPool.h | 6 - regamedll/public/basetypes.h | 258 +-- regamedll/public/commonmacros.h | 63 +- regamedll/public/interface.cpp | 325 ++-- regamedll/public/interface.h | 97 +- regamedll/public/protected_things.h | 187 -- regamedll/public/regamedll/csbot_dll.h | 1 + regamedll/public/regamedll/hookchains.h | 1 + regamedll/public/regamedll/regamedll_api.h | 193 +- regamedll/public/regamedll/regamedll_common.h | 142 -- regamedll/public/regamedll/regamedll_const.h | 126 +- regamedll/public/strtools.h | 211 +++ regamedll/public/tier0/dbg.cpp | 215 +-- regamedll/public/tier0/dbg.h | 476 +++-- regamedll/public/tier0/platform.h | 645 +------ regamedll/public/utlbuffer.cpp | 170 +- regamedll/public/utllinkedlist.h | 239 +-- regamedll/public/utlmap.h | 41 +- regamedll/public/utlmemory.h | 27 +- regamedll/public/utlrbtree.h | 50 +- regamedll/public/utlsymbol.cpp | 43 +- regamedll/public/utlsymbol.h | 32 +- regamedll/public/utlvector.h | 275 ++- .../regamedll/RegameDLLRuntimeConfig.cpp | 34 +- regamedll/regamedll/RegameDLLRuntimeConfig.h | 28 + regamedll/regamedll/classes_dummy.cpp | 28 + regamedll/regamedll/dlls.h | 15 - regamedll/regamedll/hookchains_impl.cpp | 16 +- regamedll/regamedll/hookchains_impl.h | 8 +- regamedll/regamedll/platform.cpp | 48 - regamedll/regamedll/platform.h | 12 - regamedll/regamedll/precompiled.cpp | 28 + regamedll/regamedll/precompiled.h | 30 +- regamedll/regamedll/regamedll.cpp | 32 +- regamedll/regamedll/regamedll.h | 30 +- regamedll/regamedll/regamedll_api_impl.cpp | 19 +- regamedll/regamedll/regamedll_api_impl.h | 189 +- regamedll/regamedll/regamedll_debug.cpp | 57 - regamedll/regamedll/regamedll_debug.h | 9 - .../regamedll/regamedll_interfaces_impl.cpp | 4 +- .../regamedll/regamedll_interfaces_impl.h | 1 + 461 files changed, 12814 insertions(+), 40802 deletions(-) create mode 100644 regamedll/dlls/basemonster.cpp create mode 100644 regamedll/dlls/cmdhandler.cpp rename regamedll/{extra/cssdk/dlls/subs.h => dlls/cmdhandler.h} (80%) rename regamedll/dlls/{h_ai.h => combat.h} (63%) create mode 100644 regamedll/dlls/ehandle.h create mode 100644 regamedll/dlls/gib.cpp rename regamedll/{extra/cssdk/dlls/mortar.h => dlls/gib.h} (69%) delete mode 100644 regamedll/dlls/h_ai.cpp delete mode 100644 regamedll/dlls/mpstubb.cpp delete mode 100644 regamedll/dlls/nodes.h delete mode 100644 regamedll/dlls/plane.cpp delete mode 100644 regamedll/dlls/plane.h rename regamedll/{extra/cssdk/dlls/extdll.h => dlls/qstring.h} (50%) delete mode 100644 regamedll/dlls/wpn_shared.h delete mode 100644 regamedll/extra/cssdk/common/IGameServerData.h delete mode 100644 regamedll/extra/cssdk/common/Sequence.h delete mode 100644 regamedll/extra/cssdk/common/SteamCommon.h delete mode 100644 regamedll/extra/cssdk/common/beamdef.h delete mode 100644 regamedll/extra/cssdk/common/cl_entity.h delete mode 100644 regamedll/extra/cssdk/common/com_model.h delete mode 100644 regamedll/extra/cssdk/common/con_nprint.h delete mode 100644 regamedll/extra/cssdk/common/const.h delete mode 100644 regamedll/extra/cssdk/common/crc.h delete mode 100644 regamedll/extra/cssdk/common/cvardef.h delete mode 100644 regamedll/extra/cssdk/common/demo_api.h delete mode 100644 regamedll/extra/cssdk/common/director_cmds.h delete mode 100644 regamedll/extra/cssdk/common/dlight.h delete mode 100644 regamedll/extra/cssdk/common/dll_state.h delete mode 100644 regamedll/extra/cssdk/common/entity_state.h delete mode 100644 regamedll/extra/cssdk/common/entity_types.h delete mode 100644 regamedll/extra/cssdk/common/enums.h delete mode 100644 regamedll/extra/cssdk/common/event_api.h delete mode 100644 regamedll/extra/cssdk/common/event_args.h delete mode 100644 regamedll/extra/cssdk/common/event_flags.h delete mode 100644 regamedll/extra/cssdk/common/hltv.h delete mode 100644 regamedll/extra/cssdk/common/in_buttons.h delete mode 100644 regamedll/extra/cssdk/common/ivoicetweak.h delete mode 100644 regamedll/extra/cssdk/common/kbutton.h delete mode 100644 regamedll/extra/cssdk/common/mathlib.h delete mode 100644 regamedll/extra/cssdk/common/net_api.h delete mode 100644 regamedll/extra/cssdk/common/netadr.h delete mode 100644 regamedll/extra/cssdk/common/nowin.h delete mode 100644 regamedll/extra/cssdk/common/parsemsg.cpp delete mode 100644 regamedll/extra/cssdk/common/parsemsg.h delete mode 100644 regamedll/extra/cssdk/common/particledef.h delete mode 100644 regamedll/extra/cssdk/common/pmtrace.h delete mode 100644 regamedll/extra/cssdk/common/port.h delete mode 100644 regamedll/extra/cssdk/common/qfont.h delete mode 100644 regamedll/extra/cssdk/common/qlimits.h delete mode 100644 regamedll/extra/cssdk/common/quakedef.h delete mode 100644 regamedll/extra/cssdk/common/r_efx.h delete mode 100644 regamedll/extra/cssdk/common/r_studioint.h delete mode 100644 regamedll/extra/cssdk/common/ref_params.h delete mode 100644 regamedll/extra/cssdk/common/screenfade.h delete mode 100644 regamedll/extra/cssdk/common/studio_event.h delete mode 100644 regamedll/extra/cssdk/common/triangleapi.h delete mode 100644 regamedll/extra/cssdk/common/usercmd.h delete mode 100644 regamedll/extra/cssdk/common/vmodes.h delete mode 100644 regamedll/extra/cssdk/common/weaponinfo.h delete mode 100644 regamedll/extra/cssdk/common/winsani_in.h delete mode 100644 regamedll/extra/cssdk/common/winsani_out.h delete mode 100644 regamedll/extra/cssdk/dlls/activity.h delete mode 100644 regamedll/extra/cssdk/dlls/activitymap.h delete mode 100644 regamedll/extra/cssdk/dlls/airtank.h delete mode 100644 regamedll/extra/cssdk/dlls/ammo.h delete mode 100644 regamedll/extra/cssdk/dlls/basemonster.h delete mode 100644 regamedll/extra/cssdk/dlls/bmodels.h delete mode 100644 regamedll/extra/cssdk/dlls/bot/cs_bot.h delete mode 100644 regamedll/extra/cssdk/dlls/bot/cs_bot_chatter.h delete mode 100644 regamedll/extra/cssdk/dlls/bot/cs_bot_manager.h delete mode 100644 regamedll/extra/cssdk/dlls/bot/cs_gamestate.h delete mode 100644 regamedll/extra/cssdk/dlls/buttons.h delete mode 100644 regamedll/extra/cssdk/dlls/cbase.h delete mode 100644 regamedll/extra/cssdk/dlls/cdll_dll.h delete mode 100644 regamedll/extra/cssdk/dlls/client.h delete mode 100644 regamedll/extra/cssdk/dlls/csbot_dll.h delete mode 100644 regamedll/extra/cssdk/dlls/decals.h delete mode 100644 regamedll/extra/cssdk/dlls/doors.h delete mode 100644 regamedll/extra/cssdk/dlls/effects.h delete mode 100644 regamedll/extra/cssdk/dlls/enginecallback.h delete mode 100644 regamedll/extra/cssdk/dlls/explode.h delete mode 100644 regamedll/extra/cssdk/dlls/extdef.h delete mode 100644 regamedll/extra/cssdk/dlls/func_break.h delete mode 100644 regamedll/extra/cssdk/dlls/func_tank.h delete mode 100644 regamedll/extra/cssdk/dlls/gamerules.h delete mode 100644 regamedll/extra/cssdk/dlls/h_battery.h delete mode 100644 regamedll/extra/cssdk/dlls/h_cycler.h delete mode 100644 regamedll/extra/cssdk/dlls/healthkit.h delete mode 100644 regamedll/extra/cssdk/dlls/hintmessage.h delete mode 100644 regamedll/extra/cssdk/dlls/hookchains.h delete mode 100644 regamedll/extra/cssdk/dlls/hostage/hostage.h delete mode 100644 regamedll/extra/cssdk/dlls/hostage/hostage_improv.h delete mode 100644 regamedll/extra/cssdk/dlls/hostage/hostage_localnav.h delete mode 100644 regamedll/extra/cssdk/dlls/hostage/hostage_states.h delete mode 100644 regamedll/extra/cssdk/dlls/items.h delete mode 100644 regamedll/extra/cssdk/dlls/lights.h delete mode 100644 regamedll/extra/cssdk/dlls/mapinfo.h delete mode 100644 regamedll/extra/cssdk/dlls/maprules.h delete mode 100644 regamedll/extra/cssdk/dlls/monsterevent.h delete mode 100644 regamedll/extra/cssdk/dlls/monsters.h delete mode 100644 regamedll/extra/cssdk/dlls/observer.h delete mode 100644 regamedll/extra/cssdk/dlls/pathcorner.h delete mode 100644 regamedll/extra/cssdk/dlls/plats.h delete mode 100644 regamedll/extra/cssdk/dlls/player.h delete mode 100644 regamedll/extra/cssdk/dlls/regamedll_api.h delete mode 100644 regamedll/extra/cssdk/dlls/regamedll_common.h delete mode 100644 regamedll/extra/cssdk/dlls/regamedll_const.h delete mode 100644 regamedll/extra/cssdk/dlls/regamedll_interfaces.h delete mode 100644 regamedll/extra/cssdk/dlls/revert_saved.h delete mode 100644 regamedll/extra/cssdk/dlls/skill.h delete mode 100644 regamedll/extra/cssdk/dlls/sound.h delete mode 100644 regamedll/extra/cssdk/dlls/spectator.h delete mode 100644 regamedll/extra/cssdk/dlls/training_gamerules.h delete mode 100644 regamedll/extra/cssdk/dlls/trains.h delete mode 100644 regamedll/extra/cssdk/dlls/triggers.h delete mode 100644 regamedll/extra/cssdk/dlls/unisignals.h delete mode 100644 regamedll/extra/cssdk/dlls/util.h delete mode 100644 regamedll/extra/cssdk/dlls/vector.h delete mode 100644 regamedll/extra/cssdk/dlls/vehicle.h delete mode 100644 regamedll/extra/cssdk/dlls/weapons.h delete mode 100644 regamedll/extra/cssdk/dlls/weapontype.h delete mode 100644 regamedll/extra/cssdk/dlls/wpn_shared.h delete mode 100644 regamedll/extra/cssdk/engine/FlightRecorder.h delete mode 100644 regamedll/extra/cssdk/engine/Sequence.h delete mode 100644 regamedll/extra/cssdk/engine/archtypes.h delete mode 100644 regamedll/extra/cssdk/engine/bspfile.h delete mode 100644 regamedll/extra/cssdk/engine/cmd_rehlds.h delete mode 100644 regamedll/extra/cssdk/engine/common_rehlds.h delete mode 100644 regamedll/extra/cssdk/engine/crc32c.cpp delete mode 100644 regamedll/extra/cssdk/engine/crc32c.h delete mode 100644 regamedll/extra/cssdk/engine/custom.h delete mode 100644 regamedll/extra/cssdk/engine/customentity.h delete mode 100644 regamedll/extra/cssdk/engine/d_local.h delete mode 100644 regamedll/extra/cssdk/engine/edict.h delete mode 100644 regamedll/extra/cssdk/engine/eiface.h delete mode 100644 regamedll/extra/cssdk/engine/keydefs.h delete mode 100644 regamedll/extra/cssdk/engine/maintypes.h delete mode 100644 regamedll/extra/cssdk/engine/model.h delete mode 100644 regamedll/extra/cssdk/engine/modelgen.h delete mode 100644 regamedll/extra/cssdk/engine/osconfig.h delete mode 100644 regamedll/extra/cssdk/engine/progdefs.h delete mode 100644 regamedll/extra/cssdk/engine/progs.h delete mode 100644 regamedll/extra/cssdk/engine/rehlds_api.h delete mode 100644 regamedll/extra/cssdk/engine/rehlds_interfaces.h delete mode 100644 regamedll/extra/cssdk/engine/shake.h delete mode 100644 regamedll/extra/cssdk/engine/spritegn.h delete mode 100644 regamedll/extra/cssdk/engine/static_map.h delete mode 100644 regamedll/extra/cssdk/engine/studio.h delete mode 100644 regamedll/extra/cssdk/engine/sys_shared.cpp delete mode 100644 regamedll/extra/cssdk/engine/sys_shared.h delete mode 100644 regamedll/extra/cssdk/engine/userid_rehlds.h delete mode 100644 regamedll/extra/cssdk/game_shared/GameEvent.h delete mode 100644 regamedll/extra/cssdk/game_shared/bitvec.h delete mode 100644 regamedll/extra/cssdk/game_shared/bot/bot.h delete mode 100644 regamedll/extra/cssdk/game_shared/bot/bot_constants.h delete mode 100644 regamedll/extra/cssdk/game_shared/bot/bot_manager.h delete mode 100644 regamedll/extra/cssdk/game_shared/bot/bot_profile.h delete mode 100644 regamedll/extra/cssdk/game_shared/bot/bot_util.h delete mode 100644 regamedll/extra/cssdk/game_shared/bot/improv.h delete mode 100644 regamedll/extra/cssdk/game_shared/bot/nav.h delete mode 100644 regamedll/extra/cssdk/game_shared/bot/nav_area.h delete mode 100644 regamedll/extra/cssdk/game_shared/bot/nav_node.h delete mode 100644 regamedll/extra/cssdk/game_shared/bot/nav_path.h delete mode 100644 regamedll/extra/cssdk/game_shared/bot/simple_state_machine.h delete mode 100644 regamedll/extra/cssdk/game_shared/counter.h delete mode 100644 regamedll/extra/cssdk/game_shared/shared_util.h delete mode 100644 regamedll/extra/cssdk/game_shared/simple_checksum.h delete mode 100644 regamedll/extra/cssdk/game_shared/steam_util.h delete mode 100644 regamedll/extra/cssdk/game_shared/voice_common.h delete mode 100644 regamedll/extra/cssdk/game_shared/voice_gamemgr.h delete mode 100644 regamedll/extra/cssdk/pm_shared/pm_defs.h delete mode 100644 regamedll/extra/cssdk/pm_shared/pm_info.h delete mode 100644 regamedll/extra/cssdk/pm_shared/pm_materials.h delete mode 100644 regamedll/extra/cssdk/pm_shared/pm_movevars.h delete mode 100644 regamedll/extra/cssdk/pm_shared/pm_shared.h delete mode 100644 regamedll/extra/cssdk/public/FileSystem.h delete mode 100644 regamedll/extra/cssdk/public/basetypes.h delete mode 100644 regamedll/extra/cssdk/public/commonmacros.h delete mode 100644 regamedll/extra/cssdk/public/interface.cpp delete mode 100644 regamedll/extra/cssdk/public/interface.h delete mode 100644 regamedll/extra/cssdk/public/protected_things.h delete mode 100644 regamedll/extra/cssdk/public/tier0/dbg.cpp delete mode 100644 regamedll/extra/cssdk/public/tier0/dbg.h delete mode 100644 regamedll/extra/cssdk/public/tier0/platform.h delete mode 100644 regamedll/extra/cssdk/public/utlmemory.h delete mode 100644 regamedll/extra/cssdk/public/utlvector.h delete mode 100644 regamedll/public/protected_things.h delete mode 100644 regamedll/public/regamedll/regamedll_common.h create mode 100644 regamedll/public/strtools.h delete mode 100644 regamedll/regamedll/platform.cpp delete mode 100644 regamedll/regamedll/platform.h delete mode 100644 regamedll/regamedll/regamedll_debug.cpp delete mode 100644 regamedll/regamedll/regamedll_debug.h diff --git a/publish.gradle b/publish.gradle index 4dd6a485..828d58bb 100644 --- a/publish.gradle +++ b/publish.gradle @@ -2,7 +2,7 @@ import org.doomedsociety.gradlecpp.GradleCppUtils import org.apache.commons.io.FilenameUtils void _copyFileToDir(String from, String to) { - def dst = new File(project.file(to), FilenameUtils.getName(from)) + def dst = new File(project.file(to), FilenameUtils.getName(from)) GradleCppUtils.copyFile(project.file(from), dst, false) } diff --git a/regamedll/build.gradle b/regamedll/build.gradle index da537b37..40e94de6 100644 --- a/regamedll/build.gradle +++ b/regamedll/build.gradle @@ -105,7 +105,7 @@ void setupToolchain(NativeBinarySpec b) b.lib LazyNativeDepSet.create(dep_cppunitlite, 'cppunitlite', b.buildType.name, true) } - cfg.singleDefines 'USE_BREAKPAD_HANDLER', 'DEDICATED', 'REGAMEDLL_SELF', 'REGAMEDLL_API', 'CLIENT_WEAPONS' + cfg.singleDefines 'USE_BREAKPAD_HANDLER', 'DEDICATED', 'REGAMEDLL_SELF', 'REGAMEDLL_API', 'CLIENT_WEAPONS', 'USE_QSTRING' if (cfg instanceof MsvcToolchainConfig) { @@ -140,7 +140,7 @@ void setupToolchain(NativeBinarySpec b) pchSourceSet: 'regamedll_pch' ); - cfg.compilerOptions.languageStandard = 'c++0x' + cfg.compilerOptions.languageStandard = 'c++14' cfg.defines([ '_stricmp': 'strcasecmp', '_strnicmp': 'strncasecmp', diff --git a/regamedll/common/const.h b/regamedll/common/const.h index df828e7f..f3c9b8dc 100644 --- a/regamedll/common/const.h +++ b/regamedll/common/const.h @@ -283,13 +283,7 @@ // volume values #define VOL_NORM 1.0 -// plats -#define PLAT_LOW_TRIGGER 1 -// Trains -#define SF_TRAIN_WAIT_RETRIGGER 1 -#define SF_TRAIN_START_ON 4 // Train is initially moving -#define SF_TRAIN_PASSABLE 8 // Train is not solid -- used to make water trains // Break Model Defines #define BREAK_TYPEMASK 0x4F diff --git a/regamedll/common/mathlib.h b/regamedll/common/mathlib.h index b363490c..3e582310 100644 --- a/regamedll/common/mathlib.h +++ b/regamedll/common/mathlib.h @@ -91,20 +91,20 @@ const T& clamp(const T& a, const T& min, const T& max) { return (a > max) ? max #endif // __cplusplus // bitwise operators templates -template::type> -inline T operator~ (T a) { return (T)~(type)a; } -template::type> -inline T operator| (T a, T b) { return (T)((type)a | (type)b); } -template::type> -inline T operator& (T a, T b) { return (T)((type)a & (type)b); } -template::type> -inline T operator^ (T a, T b) { return (T)((type)a ^ (type)b); } -template::type> -inline T& operator|= (T& a, T b) { return (T&)((type&)a |= (type)b); } -template::type> -inline T& operator&= (T& a, T b) { return (T&)((type&)a &= (type)b); } -template::type> -inline T& operator^= (T& a, T b) { return (T&)((type&)a ^= (type)b); } +//template::type> +//inline T operator~ (T a) { return (T)~(type)a; } +//template::type> +//inline T operator| (T a, T b) { return (T)((type)a | (type)b); } +//template::type> +//inline T operator& (T a, T b) { return (T)((type)a & (type)b); } +//template::type> +//inline T operator^ (T a, T b) { return (T)((type)a ^ (type)b); } +//template::type> +//inline T& operator|= (T& a, T b) { return (T&)((type&)a |= (type)b); } +//template::type> +//inline T& operator&= (T& a, T b) { return (T&)((type&)a &= (type)b); } +//template::type> +//inline T& operator^= (T& a, T b) { return (T&)((type&)a ^= (type)b); } inline float M_sqrt(float value) { return _mm_cvtss_f32(_mm_sqrt_ss(_mm_load_ss(&value))); diff --git a/regamedll/dlls/activity.h b/regamedll/dlls/activity.h index 573ce4ff..043b6dc3 100644 --- a/regamedll/dlls/activity.h +++ b/regamedll/dlls/activity.h @@ -26,11 +26,7 @@ * */ -#ifndef ACTIVITY_H -#define ACTIVITY_H -#ifdef _WIN32 #pragma once -#endif typedef enum Activity_s { @@ -41,21 +37,21 @@ typedef enum Activity_s ACT_GUARD, ACT_WALK, ACT_RUN, - ACT_FLY, + ACT_FLY, // Fly (and flap if appropriate) ACT_SWIM, - ACT_HOP, - ACT_LEAP, + ACT_HOP, // vertical jump + ACT_LEAP, // long forward jump ACT_FALL, ACT_LAND, ACT_STRAFE_LEFT, ACT_STRAFE_RIGHT, - ACT_ROLL_LEFT, - ACT_ROLL_RIGHT, - ACT_TURN_LEFT, - ACT_TURN_RIGHT, - ACT_CROUCH, - ACT_CROUCHIDLE, - ACT_STAND, + ACT_ROLL_LEFT, // tuck and roll, left + ACT_ROLL_RIGHT, // tuck and roll, right + ACT_TURN_LEFT, // turn quickly left (stationary) + ACT_TURN_RIGHT, // turn quickly right (stationary) + ACT_CROUCH, // the act of crouching down from a standing position + ACT_CROUCHIDLE, // holding body in crouched position (loops) + ACT_STAND, // the act of standing from a crouched position ACT_USE, ACT_SIGNAL1, ACT_SIGNAL2, @@ -69,43 +65,43 @@ typedef enum Activity_s ACT_MELEE_ATTACK1, ACT_MELEE_ATTACK2, ACT_RELOAD, - ACT_ARM, - ACT_DISARM, - ACT_EAT, + ACT_ARM, // pull out gun, for instance + ACT_DISARM, // reholster gun + ACT_EAT, // monster chowing on a large food item (loop) ACT_DIESIMPLE, ACT_DIEBACKWARD, ACT_DIEFORWARD, ACT_DIEVIOLENT, - ACT_BARNACLE_HIT, - ACT_BARNACLE_PULL, - ACT_BARNACLE_CHOMP, - ACT_BARNACLE_CHEW, + ACT_BARNACLE_HIT, // barnacle tongue hits a monster + ACT_BARNACLE_PULL, // barnacle is lifting the monster ( loop ) + ACT_BARNACLE_CHOMP, // barnacle latches on to the monster + ACT_BARNACLE_CHEW, // barnacle is holding the monster in its mouth ( loop ) ACT_SLEEP, - ACT_INSPECT_FLOOR, - ACT_INSPECT_WALL, - ACT_IDLE_ANGRY, - ACT_WALK_HURT, - ACT_RUN_HURT, - ACT_HOVER, - ACT_GLIDE, - ACT_FLY_LEFT, - ACT_FLY_RIGHT, - ACT_DETECT_SCENT, - ACT_SNIFF, - ACT_BITE, - ACT_THREAT_DISPLAY, - ACT_FEAR_DISPLAY, - ACT_EXCITED, - ACT_SPECIAL_ATTACK1, + ACT_INSPECT_FLOOR, // for active idles, look at something on or near the floor + ACT_INSPECT_WALL, // for active idles, look at something directly ahead of you ( doesn't HAVE to be a wall or on a wall ) + ACT_IDLE_ANGRY, // alternate idle animation in which the monster is clearly agitated. (loop) + ACT_WALK_HURT, // limp (loop) + ACT_RUN_HURT, // limp (loop) + ACT_HOVER, // Idle while in flight + ACT_GLIDE, // Fly (don't flap) + ACT_FLY_LEFT, // Turn left in flight + ACT_FLY_RIGHT, // Turn right in flight + ACT_DETECT_SCENT, // this means the monster smells a scent carried by the air + ACT_SNIFF, // this is the act of actually sniffing an item in front of the monster + ACT_BITE, // some large monsters can eat small things in one bite. This plays one time, EAT loops. + ACT_THREAT_DISPLAY, // without attacking, monster demonstrates that it is angry. (Yell, stick out chest, etc ) + ACT_FEAR_DISPLAY, // monster just saw something that it is afraid of + ACT_EXCITED, // for some reason, monster is excited. Sees something he really likes to eat, or whatever. + ACT_SPECIAL_ATTACK1, // very monster specific special attacks. ACT_SPECIAL_ATTACK2, - ACT_COMBAT_IDLE, + ACT_COMBAT_IDLE, // agitated idle. ACT_WALK_SCARED, ACT_RUN_SCARED, - ACT_VICTORY_DANCE, - ACT_DIE_HEADSHOT, - ACT_DIE_CHESTSHOT, - ACT_DIE_GUTSHOT, - ACT_DIE_BACKSHOT, + ACT_VICTORY_DANCE, // killed a player, do a victory dance. + ACT_DIE_HEADSHOT, // die, hit in head. + ACT_DIE_CHESTSHOT, // die, hit in chest + ACT_DIE_GUTSHOT, // die, hit in gut + ACT_DIE_BACKSHOT, // die, hit in back ACT_FLINCH_HEAD, ACT_FLINCH_CHEST, ACT_FLINCH_STOMACH, @@ -148,5 +144,3 @@ typedef struct } activity_map_t; extern activity_map_t activity_map[]; - -#endif // ACTIVITY_H diff --git a/regamedll/dlls/activitymap.h b/regamedll/dlls/activitymap.h index cc14c396..8ee24a59 100644 --- a/regamedll/dlls/activitymap.h +++ b/regamedll/dlls/activitymap.h @@ -107,5 +107,5 @@ activity_map_t activity_map[] = _A(ACT_FLINCH_RIGHTARM), _A(ACT_FLINCH_LEFTLEG), _A(ACT_FLINCH_RIGHTLEG), - 0, NULL + 0, nullptr }; diff --git a/regamedll/dlls/airtank.h b/regamedll/dlls/airtank.h index 7117ec53..3b756d07 100644 --- a/regamedll/dlls/airtank.h +++ b/regamedll/dlls/airtank.h @@ -26,11 +26,7 @@ * */ -#ifndef AIRTANK_H -#define AIRTANK_H -#ifdef _WIN32 #pragma once -#endif class CAirtank: public CGrenade { @@ -52,5 +48,3 @@ public: private: int m_state; }; - -#endif // AIRTANK_H diff --git a/regamedll/dlls/ammo.h b/regamedll/dlls/ammo.h index a069d79e..8ed5c9f1 100644 --- a/regamedll/dlls/ammo.h +++ b/regamedll/dlls/ammo.h @@ -26,11 +26,7 @@ * */ -#ifndef AMMO_H -#define AMMO_H -#ifdef _WIN32 #pragma once -#endif class C9MMAmmo: public CBasePlayerAmmo { @@ -111,5 +107,3 @@ public: virtual void Precache(); virtual BOOL AddAmmo(CBaseEntity *pOther); }; - -#endif // AMMO_H diff --git a/regamedll/dlls/animating.cpp b/regamedll/dlls/animating.cpp index 33789ed3..52c575f8 100644 --- a/regamedll/dlls/animating.cpp +++ b/regamedll/dlls/animating.cpp @@ -157,8 +157,7 @@ NOXREF void CBaseAnimating::GetAttachment(int iAttachment, Vector &origin, Vecto NOXREF int CBaseAnimating::FindTransition(int iEndingSequence, int iGoalSequence, int *piDir) { void *pmodel = GET_MODEL_PTR(ENT(pev)); - - if (piDir == NULL) + if (!piDir) { int iDir; int sequence = ::FindTransition(pmodel, iEndingSequence, iGoalSequence, &iDir); diff --git a/regamedll/dlls/animation.cpp b/regamedll/dlls/animation.cpp index d75e4555..162336e2 100644 --- a/regamedll/dlls/animation.cpp +++ b/regamedll/dlls/animation.cpp @@ -5,7 +5,7 @@ */ #ifndef HOOK_GAMEDLL -void SV_StudioSetupBones(model_t *pModel, float frame, int sequence, const vec_t *angles, const vec_t *origin, const byte *pcontroller, const byte *pblending, int iBone, const edict_t *pEdict); +void EXT_FUNC SV_StudioSetupBones(model_t *pModel, float frame, int sequence, const vec_t *angles, const vec_t *origin, const byte *pcontroller, const byte *pblending, int iBone, const edict_t *pEdict); sv_blending_interface_t svBlending = { @@ -687,7 +687,7 @@ mstudioanim_t *StudioGetAnim(model_t *m_pSubModel, mstudioseqdesc_t *pseqdesc) paSequences = (cache_user_t *)m_pSubModel->submodels; - if (paSequences == NULL) + if (!paSequences) { paSequences = (cache_user_t *)IEngineStudio.Mem_Calloc(16, sizeof(cache_user_t)); // UNDONE: leak! m_pSubModel->submodels = (dmodel_t *)paSequences; @@ -1140,7 +1140,6 @@ void SV_StudioSetupBones(model_t *pModel, float frame, int sequence, const vec_t gaitsequence = 0; pseqdesc = (mstudioseqdesc_t *)((byte *)g_pstudiohdr + g_pstudiohdr->seqindex) + gaitsequence; - panim = StudioGetAnim(pModel, pseqdesc); StudioCalcRotations(pbones, chain, chainlength, adj, pos2, q2, pseqdesc, panim, 0, 0); diff --git a/regamedll/dlls/animation.h b/regamedll/dlls/animation.h index eba96819..eb0bdd7b 100644 --- a/regamedll/dlls/animation.h +++ b/regamedll/dlls/animation.h @@ -26,11 +26,7 @@ * */ -#ifndef ANIMATION_H -#define ANIMATION_H -#ifdef _WIN32 #pragma once -#endif #define NUM_BLENDING 9 @@ -57,5 +53,3 @@ int GetBodygroup(void *pmodel, entvars_t *pev, int iGroup); int GetAnimationEvent(void *pmodel, entvars_t *pev, MonsterEvent_t *pMonsterEvent, float flStart, float flEnd, int index); int ExtractBbox(void *pmodel, int sequence, float *mins, float *maxs); - -#endif // ANIMATION_H diff --git a/regamedll/dlls/basemonster.cpp b/regamedll/dlls/basemonster.cpp new file mode 100644 index 00000000..e2f7be80 --- /dev/null +++ b/regamedll/dlls/basemonster.cpp @@ -0,0 +1,1008 @@ +#include "precompiled.h" + +void CBaseMonster::GibMonster() +{ + TraceResult tr; + bool gibbed = false; + + EMIT_SOUND(ENT(pev), CHAN_WEAPON, "common/bodysplat.wav", VOL_NORM, ATTN_NORM); + + // only humans throw skulls UNDONE - eventually monsters will have their own sets of gibs + if (HasHumanGibs()) + { + // Only the player will ever get here + if (CVAR_GET_FLOAT("violence_hgibs") != 0) + { + CGib::SpawnHeadGib(pev); + + // throw some human gibs. + CGib::SpawnRandomGibs(pev, 4, 1); + } + gibbed = true; + } + else if (HasAlienGibs()) + { + // Should never get here, but someone might call it directly + if (CVAR_GET_FLOAT("violence_agibs") != 0) + { + // Throw alien gibs + CGib::SpawnRandomGibs(pev, 4, 0); + } + gibbed = true; + } + + if (!IsPlayer()) + { + if (gibbed) + { + // don't remove players! + SetThink(&CBaseMonster::SUB_Remove); + pev->nextthink = gpGlobals->time; + } + else + FadeMonster(); + } +} + +BOOL CBaseMonster::HasHumanGibs() +{ + int myClass = Classify(); + if (myClass == CLASS_HUMAN_MILITARY + || myClass == CLASS_PLAYER_ALLY + || myClass == CLASS_HUMAN_PASSIVE + || myClass == CLASS_PLAYER) + return TRUE; + + return FALSE; +} + +BOOL CBaseMonster::HasAlienGibs() +{ + int myClass = Classify(); + if (myClass == CLASS_ALIEN_MILITARY + || myClass == CLASS_ALIEN_MONSTER + || myClass == CLASS_ALIEN_PASSIVE + || myClass == CLASS_INSECT + || myClass == CLASS_ALIEN_PREDATOR + || myClass == CLASS_ALIEN_PREY) + return TRUE; + + return FALSE; +} + +void CBaseMonster::FadeMonster() +{ + StopAnimation(); + + pev->velocity = g_vecZero; + pev->movetype = MOVETYPE_NONE; + pev->avelocity = g_vecZero; + pev->animtime = gpGlobals->time; + pev->effects |= EF_NOINTERP; + + SUB_StartFadeOut(); +} + +// Determines the best type of death anim to play. +Activity CBaseMonster::GetDeathActivity() +{ + Activity deathActivity; + BOOL fTriedDirection; + float flDot; + TraceResult tr; + Vector vecSrc; + + if (pev->deadflag != DEAD_NO) + { + // don't run this while dying. + return m_IdealActivity; + } + + vecSrc = Center(); + + fTriedDirection = FALSE; + + // in case we can't find any special deaths to do. + deathActivity = ACT_DIESIMPLE; + + UTIL_MakeVectors(pev->angles); + flDot = DotProduct(gpGlobals->v_forward, g_vecAttackDir * -1); + + switch (m_LastHitGroup) + { + case HITGROUP_HEAD: + // try to pick a region-specific death. + deathActivity = ACT_DIE_HEADSHOT; + break; + case HITGROUP_STOMACH: + deathActivity = ACT_DIE_GUTSHOT; + break; + case HITGROUP_GENERIC: + // try to pick a death based on attack direction + fTriedDirection = TRUE; + + if (flDot > 0.3) + { + deathActivity = ACT_DIEFORWARD; + } + else if (flDot <= -0.3) + { + deathActivity = ACT_DIEBACKWARD; + } + break; + + default: + // try to pick a death based on attack direction + fTriedDirection = TRUE; + + if (flDot > 0.3) + { + deathActivity = ACT_DIEFORWARD; + } + else if (flDot <= -0.3) + { + deathActivity = ACT_DIEBACKWARD; + } + break; + } + + // can we perform the prescribed death? + if (LookupActivity(deathActivity) == ACT_INVALID) + { + // no! did we fail to perform a directional death? + if (fTriedDirection) + { + // if yes, we're out of options. Go simple. + deathActivity = ACT_DIESIMPLE; + } + else + { + // cannot perform the ideal region-specific death, so try a direction. + if (flDot > 0.3) + { + deathActivity = ACT_DIEFORWARD; + } + else if (flDot <= -0.3) + { + deathActivity = ACT_DIEBACKWARD; + } + } + } + + if (LookupActivity(deathActivity) == ACT_INVALID) + { + // if we're still invalid, simple is our only option. + deathActivity = ACT_DIESIMPLE; + } + + if (deathActivity == ACT_DIEFORWARD) + { + // make sure there's room to fall forward + UTIL_TraceHull(vecSrc, vecSrc + gpGlobals->v_forward * 64, dont_ignore_monsters, head_hull, edict(), &tr); + + if (tr.flFraction != 1.0f) + { + deathActivity = ACT_DIESIMPLE; + } + } + + if (deathActivity == ACT_DIEBACKWARD) + { + // make sure there's room to fall backward + UTIL_TraceHull(vecSrc, vecSrc - gpGlobals->v_forward * 64, dont_ignore_monsters, head_hull, edict(), &tr); + + if (tr.flFraction != 1.0f) + { + deathActivity = ACT_DIESIMPLE; + } + } + + return deathActivity; +} + +// Determines the best type of flinch anim to play. +NOXREF Activity CBaseMonster::GetSmallFlinchActivity() +{ + Activity flinchActivity; + BOOL fTriedDirection; + float flDot; + + fTriedDirection = FALSE; + UTIL_MakeVectors(pev->angles); + flDot = DotProduct(gpGlobals->v_forward, g_vecAttackDir * -1); // TODO: noxref + + switch (m_LastHitGroup) + { + case HITGROUP_HEAD: + // pick a region-specific flinch + flinchActivity = ACT_FLINCH_HEAD; + break; + case HITGROUP_STOMACH: + flinchActivity = ACT_FLINCH_STOMACH; + break; + case HITGROUP_LEFTARM: + flinchActivity = ACT_FLINCH_LEFTARM; + break; + case HITGROUP_RIGHTARM: + flinchActivity = ACT_FLINCH_RIGHTARM; + break; + case HITGROUP_LEFTLEG: + flinchActivity = ACT_FLINCH_LEFTLEG; + break; + case HITGROUP_RIGHTLEG: + flinchActivity = ACT_FLINCH_RIGHTLEG; + break; + case HITGROUP_GENERIC: + default: + // just get a generic flinch. + flinchActivity = ACT_SMALL_FLINCH; + break; + } + + // do we have a sequence for the ideal activity? + if (LookupActivity(flinchActivity) == ACT_INVALID) + { + flinchActivity = ACT_SMALL_FLINCH; + } + + return flinchActivity; +} + +void CBaseMonster::BecomeDead() +{ + // don't let autoaim aim at corpses. + pev->takedamage = DAMAGE_YES; + + // give the corpse half of the monster's original maximum health. + pev->health = pev->max_health / 2; + + // max_health now becomes a counter for how many blood decals the corpse can place. + pev->max_health = 5; + + // make the corpse fly away from the attack vector + pev->movetype = MOVETYPE_TOSS; +} + +BOOL CBaseMonster::ShouldGibMonster(int iGib) +{ + if ((iGib == GIB_NORMAL && pev->health < GIB_HEALTH_VALUE) || (iGib == GIB_ALWAYS)) + { + return TRUE; + } + + return FALSE; +} + +void CBaseMonster::CallGibMonster() +{ + BOOL fade = FALSE; + + if (HasHumanGibs()) + { + if (CVAR_GET_FLOAT("violence_hgibs") == 0) + fade = TRUE; + } + else if (HasAlienGibs()) + { + if (CVAR_GET_FLOAT("violence_agibs") == 0) + fade = TRUE; + } + + // do something with the body. while monster blows up + pev->solid = SOLID_NOT; + pev->takedamage = DAMAGE_NO; + + if (fade) + { + FadeMonster(); + } + else + { + // make the model invisible. + pev->effects = EF_NODRAW; + GibMonster(); + } + + pev->deadflag = DEAD_DEAD; + FCheckAITrigger(); + + // don't let the status bar glitch for players.with <0 health. + if (pev->health < -99.0f) + { + pev->health = 0; + } + + if (ShouldFadeOnDeath() && !fade) + UTIL_Remove(this); +} + +void CBaseMonster::Killed(entvars_t *pevAttacker, int iGib) +{ + if (HasMemory(bits_MEMORY_KILLED)) + { + if (ShouldGibMonster(iGib)) + { + CallGibMonster(); + } + + return; + } + + Remember(bits_MEMORY_KILLED); + + // clear the deceased's sound channels.(may have been firing or reloading when killed) + EMIT_SOUND(ENT(pev), CHAN_WEAPON, "common/null.wav", VOL_NORM, ATTN_NORM); + m_IdealMonsterState = MONSTERSTATE_DEAD; + // Make sure this condition is fired too (TakeDamage breaks out before this happens on death) + SetConditions(bits_COND_LIGHT_DAMAGE); + + // tell owner ( if any ) that we're dead.This is mostly for MonsterMaker functionality. + CBaseEntity *pOwner = CBaseEntity::Instance(pev->owner); + if (pOwner) + { + pOwner->DeathNotice(pev); + } + + if (ShouldGibMonster(iGib)) + { + CallGibMonster(); + return; + } + else if (pev->flags & FL_MONSTER) + { + SetTouch(NULL); + BecomeDead(); + } + + // don't let the status bar glitch for players.with <0 health. + if (pev->health < -99) + { + pev->health = 0; + } + + //pev->enemy = ENT(pevAttacker); // why? (sjb) + m_IdealMonsterState = MONSTERSTATE_DEAD; +} + +void CGib::WaitTillLand() +{ + if (!IsInWorld()) + { + UTIL_Remove(this); + return; + } + + if (pev->velocity == g_vecZero) + { + SetThink(&CBaseEntity::SUB_StartFadeOut); + pev->nextthink = gpGlobals->time + m_lifeTime; + +#ifndef REGAMEDLL_FIXES + if (m_bloodColor != DONT_BLEED) + { + CSoundEnt::InsertSound(bits_SOUND_MEAT, pev->origin, 384, 25); + } +#endif + } + else + { + pev->nextthink = gpGlobals->time + 0.5f; + } +} + +BOOL CBaseMonster::TakeHealth(float flHealth, int bitsDamageType) +{ + if (pev->takedamage == DAMAGE_NO) + return FALSE; + + // clear out any damage types we healed. + // UNDONE: generic health should not heal any + // UNDONE: time-based damage + + m_bitsDamageType &= ~(bitsDamageType & ~DMG_TIMEBASED); + return CBaseEntity::TakeHealth(flHealth, bitsDamageType); +} + +// The damage is coming from inflictor, but get mad at attacker +// This should be the only function that ever reduces health. +// bitsDamageType indicates the type of damage sustained, ie: DMG_SHOCK +// +// Time-based damage: only occurs while the monster is within the trigger_hurt. +// When a monster is poisoned via an arrow etc it takes all the poison damage at once. +BOOL CBaseMonster::TakeDamage(entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType) +{ + if (pev->takedamage == DAMAGE_NO) + return FALSE; + + if (!IsAlive()) + { + return DeadTakeDamage(pevInflictor, pevAttacker, flDamage, bitsDamageType); + } + + if (pev->deadflag == DEAD_NO) + { + // no pain sound during death animation. + PainSound(); + } + + // LATER: make armor consideration here! + float flTake = flDamage; + + // set damage type sustained + m_bitsDamageType |= bitsDamageType; + + // grab the vector of the incoming attack. ( pretend that the inflictor is a little lower than it really is, so the body will tend to fly upward a bit). + Vector vecDir(0, 0, 0); + + if (!FNullEnt(pevInflictor)) + { + CBaseEntity *pInflictor = CBaseEntity::Instance(pevInflictor); + + if (pInflictor) + { +#ifndef PLAY_GAMEDLL + vecDir = (pInflictor->Center() - Vector(0, 0, 10) - Center()).Normalize(); +#else + // TODO: fix test demo + vecDir = NormalizeSubtract< + float_precision, float, float_precision, float_precision + >(Center(), pInflictor->Center() - Vector(0, 0, 10)); +#endif + vecDir = g_vecAttackDir = vecDir.Normalize(); + } + } + + // add to the damage total for clients, which will be sent as a single + // message at the end of the frame + // TODO: remove after combining shotgun blasts? + if (IsPlayer()) + { + if (pevInflictor) + { + pev->dmg_inflictor = ENT(pevInflictor); + } + + pev->dmg_take += flTake; + } + + pev->health -= flTake; + + if (m_MonsterState == MONSTERSTATE_SCRIPT) + { + SetConditions(bits_COND_LIGHT_DAMAGE); + return FALSE; + } + + if (pev->health <= 0.0f) + { + g_pevLastInflictor = pevInflictor; + + if (bitsDamageType & DMG_ALWAYSGIB) + Killed(pevAttacker, GIB_ALWAYS); + + else if (bitsDamageType & DMG_NEVERGIB) + Killed(pevAttacker, GIB_NEVER); + else + Killed(pevAttacker, GIB_NORMAL); + + g_pevLastInflictor = nullptr; + return FALSE; + } + if ((pev->flags & FL_MONSTER) && !FNullEnt(pevAttacker)) + { + if (pevAttacker->flags & (FL_MONSTER | FL_CLIENT)) + { + if (pevInflictor) + { + if (!m_hEnemy || pevInflictor == m_hEnemy->pev || !HasConditions(bits_COND_SEE_ENEMY)) + m_vecEnemyLKP = pevInflictor->origin; + } + else + { + m_vecEnemyLKP = pev->origin + (g_vecAttackDir * 64); + } + + MakeIdealYaw(m_vecEnemyLKP); + + if (flDamage > 20.0f) + { + SetConditions(bits_COND_LIGHT_DAMAGE); + } + + if (flDamage >= 20.0f) + { + SetConditions(bits_COND_HEAVY_DAMAGE); + } + } + } + + return TRUE; +} + +// Takedamage function called when a monster's corpse is damaged. +BOOL CBaseMonster::DeadTakeDamage(entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType) +{ + // grab the vector of the incoming attack. ( pretend that the inflictor is a little lower than it really is, so the body will tend to fly upward a bit). + Vector vecDir(0, 0, 0); + + if (!FNullEnt(pevInflictor)) + { + CBaseEntity *pInflictor = CBaseEntity::Instance(pevInflictor); + if (pInflictor) + { + vecDir = (pInflictor->Center() - Vector(0, 0, 10) - Center()).Normalize(); + vecDir = g_vecAttackDir = vecDir.Normalize(); + } + } + +// turn this back on when the bounding box issues are resolved. +#if 0 + + pev->flags &= ~FL_ONGROUND; + pev->origin.z += 1; + + // let the damage scoot the corpse around a bit. + if (!FNullEnt(pevInflictor) && (pevAttacker->solid != SOLID_TRIGGER)) + { + pev->velocity = pev->velocity + vecDir * -DamageForce(flDamage); + } + +#endif + + // kill the corpse if enough damage was done to destroy the corpse and the damage is of a type that is allowed to destroy the corpse. + if (bitsDamageType & DMG_GIB_CORPSE) + { + if (pev->health <= flDamage) + { + pev->health = -50; + Killed(pevAttacker, GIB_ALWAYS); + return FALSE; + } + + // Accumulate corpse gibbing damage, so you can gib with multiple hits + pev->health -= flDamage * 0.1; + } + + return TRUE; +} + +float CBaseMonster::DamageForce(float damage) +{ + float_precision force = damage * ((32 * 32 * 72.0) / (pev->size.x * pev->size.y * pev->size.z)) * 5; + + if (force > 1000.0) + { + force = 1000.0; + } + return force; +} + + +void CBaseMonster::RadiusDamage(entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int iClassIgnore, int bitsDamageType) +{ + if (flDamage > 80) + ::RadiusDamage(pev->origin, pevInflictor, pevAttacker, flDamage, flDamage * 3.5, iClassIgnore, bitsDamageType); + else + ::RadiusDamage2(pev->origin, pevInflictor, pevAttacker, flDamage, flDamage * (RANDOM_FLOAT(0.5, 1.5) + 3), iClassIgnore, bitsDamageType); +} + +NOXREF void CBaseMonster::RadiusDamage(Vector vecSrc, entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int iClassIgnore, int bitsDamageType) +{ + if (flDamage > 80) + ::RadiusDamage(vecSrc, pevInflictor, pevAttacker, flDamage, flDamage * 3.5, iClassIgnore, bitsDamageType); + else + ::RadiusDamage2(vecSrc, pevInflictor, pevAttacker, flDamage, flDamage * (RANDOM_FLOAT(0.5, 1.5) + 3), iClassIgnore, bitsDamageType); +} + +// Expects a length to trace, amount of damage to do, and damage type. +// Returns a pointer to the damaged entity in case the monster wishes to do +// other stuff to the victim (punchangle, etc) +// +// Used for many contact-range melee attacks. Bites, claws, etc. +NOXREF CBaseEntity *CBaseMonster::CheckTraceHullAttack(float flDist, int iDamage, int iDmgType) +{ + TraceResult tr; + + if (IsPlayer()) + UTIL_MakeVectors(pev->angles); + else + UTIL_MakeAimVectors(pev->angles); + + Vector vecStart = pev->origin; + vecStart.z += pev->size.z * 0.5; + Vector vecEnd = vecStart + (gpGlobals->v_forward * flDist); + + UTIL_TraceHull(vecStart, vecEnd, dont_ignore_monsters, head_hull, ENT(pev), &tr); + + if (tr.pHit) + { + CBaseEntity *pEntity = CBaseEntity::Instance(tr.pHit); + + if (iDamage > 0) + { + pEntity->TakeDamage(pev, pev, iDamage, iDmgType); + } + + return pEntity; + } + + return nullptr; +} + +// Returns true is the passed ent is in the caller's forward view cone. +// The dot product is performed in 2d, making the view cone infinitely tall. +BOOL CBaseMonster::FInViewCone(CBaseEntity *pEntity) +{ + Vector2D vec2LOS; + float flDot; + + UTIL_MakeVectors(pev->angles); + + vec2LOS = (pEntity->pev->origin - pev->origin).Make2D(); + vec2LOS = vec2LOS.Normalize(); + + flDot = DotProduct(vec2LOS, gpGlobals->v_forward.Make2D()); + + if (flDot > m_flFieldOfView) + { + return TRUE; + } + else + { + return FALSE; + } +} + +// Returns true is the passed vector is in the caller's forward view cone. +// The dot product is performed in 2d, making the view cone infinitely tall. +BOOL CBaseMonster::FInViewCone(const Vector *pOrigin) +{ + Vector2D vec2LOS; + float flDot; + + UTIL_MakeVectors(pev->angles); + + vec2LOS = (*pOrigin - pev->origin).Make2D(); + vec2LOS = vec2LOS.Normalize(); + + flDot = DotProduct(vec2LOS, gpGlobals->v_forward.Make2D()); + + if (flDot > m_flFieldOfView) + { + return TRUE; + } + else + { + return FALSE; + } +} + +void CBaseMonster::TraceAttack(entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType) +{ + Vector vecOrigin = ptr->vecEndPos - vecDir * 4; + + if (pev->takedamage != DAMAGE_NO) + { + m_LastHitGroup = ptr->iHitgroup; + + switch (ptr->iHitgroup) + { + case HITGROUP_GENERIC: + break; + case HITGROUP_HEAD: + flDamage *= 3; + break; + case HITGROUP_CHEST: + case HITGROUP_STOMACH: + flDamage *= 1.5; + break; + case HITGROUP_LEFTARM: + case HITGROUP_RIGHTARM: + flDamage *= 1.0; + break; + case HITGROUP_LEFTLEG: + case HITGROUP_RIGHTLEG: + flDamage *= 0.75; + break; + case HITGROUP_SHIELD: + flDamage = 0; + break; + default: + break; + } + + AddMultiDamage(pevAttacker, this, flDamage, bitsDamageType); + + int blood = BloodColor(); + if (blood != DONT_BLEED) + { + // a little surface blood. + SpawnBlood(vecOrigin, blood, flDamage); + } + } +} + +float CBaseMonster::ChangeYaw(int speed) +{ + return 0.0f; +} + +void CBaseMonster::MakeIdealYaw(Vector vecTarget) +{ + ; +} + +NOXREF void CBaseMonster::CorpseFallThink() +{ + if (pev->flags & FL_ONGROUND) + { + SetThink(NULL); + SetSequenceBox(); + + // link into world. + UTIL_SetOrigin(pev, pev->origin); + } + else + { + pev->nextthink = gpGlobals->time + 0.1f; + } +} + +void CBaseMonster::MonsterInitDead() +{ + InitBoneControllers(); + + pev->solid = SOLID_BBOX; + pev->movetype = MOVETYPE_TOSS; + + pev->frame = 0; + ResetSequenceInfo(); + pev->framerate = 0; + + pev->max_health = pev->health; + pev->deadflag = DEAD_DEAD; + + UTIL_SetSize(pev, g_vecZero, g_vecZero); + UTIL_SetOrigin(pev, pev->origin); + + BecomeDead(); + SetThink(&CBaseEntity::SUB_Remove); + pev->nextthink = gpGlobals->time + 0.5f; +} + +BOOL CBaseMonster::ShouldFadeOnDeath() +{ +#if 0 + // if flagged to fade out or I have an owner (I came from a monster spawner) + if ((pev->spawnflags & SF_MONSTER_FADECORPSE) || !FNullEnt(pev->owner)) + return TRUE; +#endif + + return FALSE; +} + +BOOL CBaseMonster::FCheckAITrigger() +{ + return FALSE; +} + +void CBaseMonster::KeyValue(KeyValueData *pkvd) +{ + CBaseToggle::KeyValue(pkvd); +} + +int CBaseMonster::IRelationship(CBaseEntity *pTarget) +{ + static int const iEnemy[14][14] = + { + // NONE MACH PLYR HPASS HMIL AMIL APASS AMONST APREY APRED INSECT PLRALY PBWPN ABWPN + { R_NO, R_NO, R_NO, R_NO, R_NO, R_NO, R_NO, R_NO, R_NO, R_NO, R_NO, R_NO, R_NO, R_NO }, // NONE + { R_NO, R_NO, R_DL, R_DL, R_NO, R_DL, R_DL, R_DL, R_DL, R_DL, R_NO, R_DL, R_DL, R_DL }, // MACHINE + { R_NO, R_DL, R_NO, R_NO, R_DL, R_DL, R_DL, R_DL, R_DL, R_DL, R_NO, R_NO, R_DL, R_DL }, // PLAYER + { R_NO, R_NO, R_AL, R_AL, R_HT, R_FR, R_NO, R_HT, R_DL, R_FR, R_NO, R_AL, R_NO, R_NO }, // HUMANPASSIVE + { R_NO, R_NO, R_HT, R_DL, R_NO, R_HT, R_DL, R_DL, R_DL, R_DL, R_NO, R_HT, R_NO, R_NO }, // HUMANMILITAR + { R_NO, R_DL, R_HT, R_DL, R_HT, R_NO, R_NO, R_NO, R_NO, R_NO, R_NO, R_DL, R_NO, R_NO }, // ALIENMILITAR + { R_NO, R_NO, R_NO, R_NO, R_NO, R_NO, R_NO, R_NO, R_NO, R_NO, R_NO, R_NO, R_NO, R_NO }, // ALIENPASSIVE + { R_NO, R_DL, R_DL, R_DL, R_DL, R_NO, R_NO, R_NO, R_NO, R_NO, R_NO, R_DL, R_NO, R_NO }, // ALIENMONSTER + { R_NO, R_NO, R_DL, R_DL, R_DL, R_NO, R_NO, R_NO, R_NO, R_FR, R_NO, R_DL, R_NO, R_NO }, // ALIENPREY + { R_NO, R_NO, R_DL, R_DL, R_DL, R_NO, R_NO, R_NO, R_HT, R_DL, R_NO, R_DL, R_NO, R_NO }, // ALIENPREDATO + { R_FR, R_FR, R_FR, R_FR, R_FR, R_NO, R_FR, R_FR, R_FR, R_FR, R_NO, R_FR, R_NO, R_NO }, // INSECT + { R_NO, R_DL, R_AL, R_AL, R_DL, R_DL, R_DL, R_DL, R_DL, R_DL, R_NO, R_NO, R_NO, R_NO }, // PLAYERALLY + { R_NO, R_NO, R_DL, R_DL, R_DL, R_DL, R_DL, R_DL, R_DL, R_DL, R_NO, R_DL, R_NO, R_DL }, // PBIOWEAPON + { R_NO, R_NO, R_DL, R_DL, R_DL, R_AL, R_NO, R_DL, R_DL, R_NO, R_NO, R_DL, R_DL, R_NO }, // ABIOWEAPON + }; + + return iEnemy[ Classify() ][ pTarget->Classify() ]; +} + +// Base class monster function to find enemies or food by sight. +// iDistance is distance (in units) that the monster can see. +// +// Sets the sight bits of the m_afConditions mask to indicate +// which types of entities were sighted. +// Function also sets the Looker's m_pLink +// to the head of a link list that contains all visible ents. +// (linked via each ent's m_pLink field) +void CBaseMonster::Look(int iDistance) +{ + int iSighted = 0; + + // DON'T let visibility information from last frame sit around! + ClearConditions(bits_COND_SEE_HATE | bits_COND_SEE_DISLIKE | bits_COND_SEE_ENEMY | bits_COND_SEE_FEAR | bits_COND_SEE_NEMESIS | bits_COND_SEE_CLIENT); + + m_pLink = NULL; + + // the current visible entity that we're dealing with + CBaseEntity *pSightEnt = NULL; + CBaseEntity *pList[100]; + + Vector delta(iDistance, iDistance, iDistance); + + // Find only monsters/clients in box, NOT limited to PVS + int count = UTIL_EntitiesInBox(pList, ARRAYSIZE(pList), pev->origin - delta, pev->origin + delta, (FL_CLIENT | FL_MONSTER)); + for (int i = 0; i < count; i++) + { + pSightEnt = pList[i]; + if (pSightEnt != this && pSightEnt->pev->health > 0) + { + // the looker will want to consider this entity + // don't check anything else about an entity that can't be seen, or an entity that you don't care about. + if (IRelationship(pSightEnt) != R_NO && FInViewCone(pSightEnt) && !(pSightEnt->pev->flags & FL_NOTARGET) && FVisible(pSightEnt)) + { + if (pSightEnt->IsPlayer()) + { + // if we see a client, remember that (mostly for scripted AI) + iSighted |= bits_COND_SEE_CLIENT; + } + + pSightEnt->m_pLink = m_pLink; + m_pLink = pSightEnt; + + if (pSightEnt == m_hEnemy) + { + // we know this ent is visible, so if it also happens to be our enemy, store that now. + iSighted |= bits_COND_SEE_ENEMY; + } + + // don't add the Enemy's relationship to the conditions. We only want to worry about conditions when + // we see monsters other than the Enemy. + switch (IRelationship(pSightEnt)) + { + case R_NM: + iSighted |= bits_COND_SEE_NEMESIS; + break; + case R_HT: + iSighted |= bits_COND_SEE_HATE; + break; + case R_DL: + iSighted |= bits_COND_SEE_DISLIKE; + break; + case R_FR: + iSighted |= bits_COND_SEE_FEAR; + break; + case R_AL: + break; + default: + ALERT(at_aiconsole, "%s can't assess %s\n", STRING(pev->classname), STRING(pSightEnt->pev->classname)); + break; + } + } + } + } + + SetConditions(iSighted); +} + +// This functions searches the link list whose head is the caller's m_pLink field, +// and returns a pointer to the enemy entity in that list that is nearest the caller. +// +// UNDONE: currently, this only returns the closest enemy. +// we'll want to consider distance, relationship, attack types, back turned, etc. +CBaseEntity *CBaseMonster::BestVisibleEnemy() +{ + CBaseEntity *pReturn; + CBaseEntity *pNextEnt; + int iNearest; + int iDist; + int iBestRelationship; + + // so first visible entity will become the closest. + iNearest = 8192; + pNextEnt = m_pLink; + pReturn = NULL; + iBestRelationship = R_NO; + + while (pNextEnt != NULL) + { + if (pNextEnt->IsAlive()) + { + if (IRelationship(pNextEnt) > iBestRelationship) + { + // this entity is disliked MORE than the entity that we + // currently think is the best visible enemy. No need to do + // a distance check, just get mad at this one for now. + iBestRelationship = IRelationship(pNextEnt); + iNearest = (pNextEnt->pev->origin - pev->origin).Length(); + pReturn = pNextEnt; + } + else if (IRelationship(pNextEnt) == iBestRelationship) + { + // this entity is disliked just as much as the entity that + // we currently think is the best visible enemy, so we only + // get mad at it if it is closer. + iDist = (pNextEnt->pev->origin - pev->origin).Length(); + + if (iDist <= iNearest) + { + iNearest = iDist; + iBestRelationship = IRelationship(pNextEnt); + pReturn = pNextEnt; + } + } + } + + pNextEnt = pNextEnt->m_pLink; + } + + return pReturn; +} + +NOXREF void CBaseMonster::MakeDamageBloodDecal(int cCount, float flNoise, TraceResult *ptr, Vector &vecDir) +{ + // make blood decal on the wall! + TraceResult Bloodtr; + Vector vecTraceDir; + int i; + + if (!IsAlive()) + { + // dealing with a dead monster. + if (pev->max_health <= 0) + { + // no blood decal for a monster that has already decalled its limit. + return; + } + else + { + pev->max_health--; + } + } + + for (i = 0; i < cCount; ++i) + { + vecTraceDir = vecDir; + + vecTraceDir.x += RANDOM_FLOAT(-flNoise, flNoise); + vecTraceDir.y += RANDOM_FLOAT(-flNoise, flNoise); + vecTraceDir.z += RANDOM_FLOAT(-flNoise, flNoise); + + UTIL_TraceLine(ptr->vecEndPos, ptr->vecEndPos + vecTraceDir * 172, ignore_monsters, ENT(pev), &Bloodtr); + + if (Bloodtr.flFraction != 1.0f) + { + UTIL_BloodDecalTrace(&Bloodtr, BloodColor()); + } + } +} + +void CBaseMonster::BloodSplat(const Vector &vecSrc, const Vector &vecDir, int HitLocation, int iVelocity) +{ + if (HitLocation != HITGROUP_HEAD) + return; + +#ifdef REGAMEDLL_FIXES + UTIL_BloodStream(vecSrc, vecDir, BLOOD_COLOR_DARKRED, iVelocity + RANDOM_LONG(0, 100)); +#else + MESSAGE_BEGIN(MSG_PVS, SVC_TEMPENTITY, vecSrc); + WRITE_BYTE(TE_BLOODSTREAM); + WRITE_COORD(vecSrc.x); + WRITE_COORD(vecSrc.y); + WRITE_COORD(vecSrc.z); + WRITE_COORD(vecDir.x); + WRITE_COORD(vecDir.y); + WRITE_COORD(vecDir.z); + WRITE_BYTE(BLOOD_COLOR_DARKRED); + WRITE_BYTE(iVelocity + RANDOM_LONG(0, 100)); + MESSAGE_END(); +#endif +} diff --git a/regamedll/dlls/basemonster.h b/regamedll/dlls/basemonster.h index 2de88d46..4107097f 100644 --- a/regamedll/dlls/basemonster.h +++ b/regamedll/dlls/basemonster.h @@ -26,11 +26,24 @@ * */ -#ifndef BASEMONSTER_H -#define BASEMONSTER_H -#ifdef _WIN32 #pragma once -#endif + +#include "gib.h" +#include "combat.h" +#include "activity.h" + +enum +{ + ITBD_PARALLYZE = 0, + ITBD_NERVE_GAS, + ITBD_POISON, + ITBD_RADIATION, + ITBD_DROWN_RECOVER, + ITBD_ACID, + ITBD_SLOW_BURN, + ITBD_SLOW_FREEZE, + ITBD_END +}; enum MONSTERSTATE { @@ -45,10 +58,6 @@ enum MONSTERSTATE MONSTERSTATE_DEAD }; -void RadiusFlash(Vector vecSrc, entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int iClassIgnore = 0, int bitsDamageType = 0); -void RadiusDamage(Vector vecSrc, entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, float flRadius, int iClassIgnore, int bitsDamageType); -void RadiusDamage2(Vector vecSrc, entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, float flRadius, int iClassIgnore, int bitsDamageType); - class CBaseMonster: public CBaseToggle { public: @@ -112,20 +121,18 @@ public: Activity m_IdealActivity; // monster should switch to this activity int m_LastHitGroup; // the last body region that took damage int m_bitsDamageType; // what types of damage has monster (player) taken - byte m_rgbTimeBasedDamage[8]; + byte m_rgbTimeBasedDamage[ITBD_END]; MONSTERSTATE m_MonsterState; // monster's current state MONSTERSTATE m_IdealMonsterState; // monster should change to this state int m_afConditions; int m_afMemory; - float m_flNextAttack; // cannot attack again until this time - EHANDLE m_hEnemy; // the entity that the monster is fighting. - EHANDLE m_hTargetEnt; // the entity that the monster is trying to reach - float m_flFieldOfView; // width of monster's field of view ( dot product ) - int m_bloodColor; // color of blood particless - Vector m_HackedGunPos; // HACK until we can query end of gun - Vector m_vecEnemyLKP; // last known position of enemy. (enemy's origin) + float m_flNextAttack; // cannot attack again until this time + EHANDLE m_hEnemy; // the entity that the monster is fighting. + EHANDLE m_hTargetEnt; // the entity that the monster is trying to reach + float m_flFieldOfView; // width of monster's field of view (dot product) + int m_bloodColor; // color of blood particless + Vector m_HackedGunPos; // HACK until we can query end of gun + Vector m_vecEnemyLKP; // last known position of enemy. (enemy's origin) }; - -#endif // BASEMONSTER_H diff --git a/regamedll/dlls/bmodels.cpp b/regamedll/dlls/bmodels.cpp index 4a301614..b837be23 100644 --- a/regamedll/dlls/bmodels.cpp +++ b/regamedll/dlls/bmodels.cpp @@ -64,13 +64,13 @@ void CFuncWallToggle::Spawn() { CFuncWall::Spawn(); - if (pev->spawnflags & SF_WALL_START_OFF) + if (pev->spawnflags & SF_WALL_TOOGLE_START_OFF) { TurnOff(); } #ifdef REGAMEDLL_ADD - if (pev->spawnflags & SF_WALL_NOTSOLID) + if (pev->spawnflags & SF_WALL_TOOGLE_NOTSOLID) { pev->solid = SOLID_NOT; } @@ -83,7 +83,7 @@ void CFuncWallToggle::Restart() { CFuncWall::Spawn(); - if (pev->spawnflags & SF_WALL_START_OFF) + if (pev->spawnflags & SF_WALL_TOOGLE_START_OFF) { TurnOff(); return; @@ -188,7 +188,9 @@ void CFuncIllusionary::KeyValue(KeyValueData *pkvd) pkvd->fHandled = TRUE; } else + { CBaseToggle::KeyValue(pkvd); + } } void CFuncIllusionary::Spawn() @@ -231,7 +233,11 @@ void CFuncRotating::KeyValue(KeyValueData *pkvd) m_flFanFriction = Q_atof(pkvd->szValue) / 100; pkvd->fHandled = TRUE; } +#ifdef REGAMEDLL_FIXES + else if (FStrEq(pkvd->szKeyName, "volume")) +#else else if (FStrEq(pkvd->szKeyName, "Volume")) +#endif { m_flVolume = Q_atof(pkvd->szValue) / 10.0; @@ -259,7 +265,9 @@ void CFuncRotating::KeyValue(KeyValueData *pkvd) pkvd->fHandled = TRUE; } else + { CBaseEntity::KeyValue(pkvd); + } } // QUAKED func_rotating (0 .5 .8) ? START_ON REVERSE X_AXIS Y_AXIS @@ -330,7 +338,7 @@ void CFuncRotating::Spawn() } // some rotating objects like fake volumetric lights will not be solid. - if (pev->spawnflags & SF_ROTATING_NOT_SOLID) + if (pev->spawnflags & SF_BRUSH_ROTATE_NOT_SOLID) { pev->solid = SOLID_NOT; pev->skin = CONTENTS_EMPTY; @@ -358,12 +366,12 @@ void CFuncRotating::Spawn() // pev->dmg = 2; // instant-use brush? - if (pev->spawnflags & SF_BRUSH_ROTATE_INSTANT) + if (pev->spawnflags & SF_BRUSH_ROTATE_START_ON) { SetThink(&CFuncRotating::SUB_CallUseToggle); // leave a magic delay for client to start up - pev->nextthink = pev->ltime + 1.5; + pev->nextthink = pev->ltime + 1.5f; } // can this brush inflict pain? @@ -378,16 +386,15 @@ void CFuncRotating::Spawn() #ifdef REGAMEDLL_FIXES void CFuncRotating::Restart() { - // fan is spinning, so stop it. - SetThink(&CFuncRotating::SpinDown); - pev->nextthink = pev->ltime + 0.1; + // stop sound, we're done + EMIT_SOUND_DYN(ENT(pev), CHAN_STATIC, (char *)STRING(pev->noiseRunning), 0, ATTN_NONE, SND_STOP, m_pitch); // restore angles pev->angles = m_angles; pev->avelocity = g_vecZero; // some rotating objects like fake volumetric lights will not be solid. - if (pev->spawnflags & SF_ROTATING_NOT_SOLID) + if (pev->spawnflags & SF_BRUSH_ROTATE_NOT_SOLID) { pev->solid = SOLID_NOT; pev->skin = CONTENTS_EMPTY; @@ -411,12 +418,12 @@ void CFuncRotating::Restart() } // instant-use brush? - if (pev->spawnflags & SF_BRUSH_ROTATE_INSTANT) + if (pev->spawnflags & SF_BRUSH_ROTATE_START_ON) { SetThink(&CFuncRotating::SUB_CallUseToggle); // leave a magic delay for client to start up - pev->nextthink = pev->ltime + 0.1; + pev->nextthink = pev->ltime + 0.1f; } // can this brush inflict pain? @@ -485,7 +492,7 @@ void CFuncRotating::Precache() // if fan was spinning, and we went through transition or save/restore, // make sure we restart the sound. 1.5 sec delay is magic number. KDB SetThink(&CFuncRotating::SpinUp); - pev->nextthink = pev->ltime + 1.5; + pev->nextthink = pev->ltime + 1.5f; } } @@ -508,8 +515,7 @@ void CFuncRotating::HurtTouch(CBaseEntity *pOther) // RampPitchVol - ramp pitch and volume up to final values, based on difference // between how fast we're going vs how fast we plan to go - -void CFuncRotating::RampPitchVol(int fUp) +void CFuncRotating::RampPitchVol(BOOL fUp) { Vector vecAVel = pev->avelocity; float_precision vecCur; @@ -541,7 +547,7 @@ void CFuncRotating::RampPitchVol(int fUp) fvol = m_flVolume * fpct; } - fpitch = FANPITCHMIN + (FANPITCHMAX - FANPITCHMIN) * fpct; + fpitch = MIN_FANPITCH + (MAX_FANPITCH - MIN_FANPITCH) * fpct; pitch = int(fpitch); if (pitch == PITCH_NORM) @@ -556,7 +562,7 @@ void CFuncRotating::RampPitchVol(int fUp) // SpinUp - accelerates a non-moving func_rotating up to it's speed void CFuncRotating::SpinUp() { - //rotational velocity + // rotational velocity Vector vecAVel; pev->nextthink = pev->ltime + 0.1; @@ -572,7 +578,7 @@ void CFuncRotating::SpinUp() { // set speed in case we overshot pev->avelocity = pev->movedir * pev->speed; - EMIT_SOUND_DYN(ENT(pev), CHAN_STATIC, (char *)STRING(pev->noiseRunning), m_flVolume, m_flAttenuation, (SND_CHANGE_PITCH | SND_CHANGE_VOL), FANPITCHMAX); + EMIT_SOUND_DYN(ENT(pev), CHAN_STATIC, (char *)STRING(pev->noiseRunning), m_flVolume, m_flAttenuation, (SND_CHANGE_PITCH | SND_CHANGE_VOL), MAX_FANPITCH); SetThink(&CFuncRotating::Rotate); Rotate(); @@ -585,13 +591,13 @@ void CFuncRotating::SpinUp() void CFuncRotating::SpinDown() { - //rotational velocity + // rotational velocity Vector vecAVel; vec_t vecdir; - pev->nextthink = pev->ltime + 0.1; + pev->nextthink = pev->ltime + 0.1f; - //spin down slower than spinup + // spin down slower than spinup pev->avelocity = pev->avelocity - (pev->movedir * (pev->speed * m_flFanFriction)); // cache entity's rotational velocity @@ -641,12 +647,13 @@ void CFuncRotating::RotatingUse(CBaseEntity *pActivator, CBaseEntity *pCaller, U SetThink(&CFuncRotating::SpinDown); //EMIT_SOUND_DYN(ENT(pev), CHAN_WEAPON, (char *)STRING(pev->noiseStop), m_flVolume, m_flAttenuation, 0, m_pitch); - pev->nextthink = pev->ltime + 0.1; + pev->nextthink = pev->ltime + 0.1f; } - else // fan is not moving, so start it + // fan is not moving, so start it + else { SetThink(&CFuncRotating::SpinUp); - EMIT_SOUND_DYN(ENT(pev), CHAN_STATIC, (char *)STRING(pev->noiseRunning), 0.01, m_flAttenuation, 0, FANPITCHMIN); + EMIT_SOUND_DYN(ENT(pev), CHAN_STATIC, (char *)STRING(pev->noiseRunning), 0.01, m_flAttenuation, 0, MIN_FANPITCH); pev->nextthink = pev->ltime + 0.1; } @@ -660,12 +667,12 @@ void CFuncRotating::RotatingUse(CBaseEntity *pActivator, CBaseEntity *pCaller, U // EMIT_SOUND_DYN(ENT(pev), CHAN_WEAPON, (char *)STRING(pev->noiseStop), m_flVolume, m_flAttenuation, 0, m_pitch); - pev->nextthink = pev->ltime + 0.1; + pev->nextthink = pev->ltime + 0.1f; // pev->avelocity = g_vecZero; } else { - EMIT_SOUND_DYN(ENT(pev), CHAN_STATIC, (char *)STRING(pev->noiseRunning), m_flVolume, m_flAttenuation, 0, FANPITCHMAX); + EMIT_SOUND_DYN(ENT(pev), CHAN_STATIC, (char *)STRING(pev->noiseRunning), m_flVolume, m_flAttenuation, 0, MAX_FANPITCH); pev->avelocity = pev->movedir * pev->speed; SetThink(&CFuncRotating::Rotate); @@ -696,7 +703,9 @@ void CPendulum::KeyValue(KeyValueData *pkvd) pkvd->fHandled = TRUE; } else + { CBaseEntity::KeyValue(pkvd); + } } void CPendulum::Spawn() @@ -704,7 +713,7 @@ void CPendulum::Spawn() // set the axis of rotation CBaseToggle::AxisDir(pev); - if (pev->spawnflags & SF_DOOR_PASSABLE) + if (pev->spawnflags & SF_PENDULUM_PASSABLE) pev->solid = SOLID_NOT; else pev->solid = SOLID_BSP; @@ -725,18 +734,22 @@ void CPendulum::Spawn() m_start = pev->angles; m_center = pev->angles + (m_distance * 0.5) * pev->movedir; - if (pev->spawnflags & SF_BRUSH_ROTATE_INSTANT) + // instant-use brush? + if (pev->spawnflags & SF_PENDULUM_START_ON) { SetThink(&CPendulum::SUB_CallUseToggle); + + // leave a magic delay for client to start up pev->nextthink = gpGlobals->time + 0.1f; } pev->speed = 0; SetUse(&CPendulum::PendulumUse); + // this brush makes a pendulum a rope swing if (pev->spawnflags & SF_PENDULUM_SWING) { - SetTouch (&CPendulum::RopeTouch); + SetTouch(&CPendulum::RopeTouch); } } @@ -818,7 +831,7 @@ void CPendulum::Swing() pev->avelocity = pev->speed * pev->movedir; // Call this again - pev->nextthink = pev->ltime + 0.1; + pev->nextthink = pev->ltime + 0.1f; if (m_damp) { diff --git a/regamedll/dlls/bmodels.h b/regamedll/dlls/bmodels.h index a9af47de..ea370e02 100644 --- a/regamedll/dlls/bmodels.h +++ b/regamedll/dlls/bmodels.h @@ -26,48 +26,12 @@ * */ -#ifndef BMODELS_H -#define BMODELS_H -#ifdef _WIN32 #pragma once -#endif - -// func_rotating -#define SF_BRUSH_ROTATE_Y_AXIS 0 -#define SF_BRUSH_ROTATE_INSTANT 1 -#define SF_BRUSH_ROTATE_BACKWARDS 2 -#define SF_BRUSH_ROTATE_Z_AXIS 4 -#define SF_BRUSH_ROTATE_X_AXIS 8 - -#define SF_BRUSH_ACCDCC 16 // brush should accelerate and decelerate when toggled -#define SF_BRUSH_HURT 32 // rotating brush that inflicts pain based on rotation speed - -#define SF_ROTATING_NOT_SOLID 64 // some special rotating objects are not solid. - -#define SF_BRUSH_ROTATE_SMALLRADIUS 128 -#define SF_BRUSH_ROTATE_MEDIUMRADIUS 256 -#define SF_BRUSH_ROTATE_LARGERADIUS 512 - -#define FANPITCHMIN 30 -#define FANPITCHMAX 100 - -// func_pendulum -#define SF_PENDULUM_SWING 2 // spawnflag that makes a pendulum a rope swing. -#define SF_PENDULUM_AUTO_RETURN 16 -#define SF_PENDULUM_PASSABLE 32 - -// func_wall_toggle -#define SF_WALL_START_OFF 0x0001 -#define SF_WALL_NOTSOLID 0x0008 - -// func_conveyor -#define SF_CONVEYOR_VISUAL 0x0001 -#define SF_CONVEYOR_NOTSOLID 0x0002 // covering cheesy noise1, noise2, & noise3 fields so they make more sense (for rotating fans) -#define noiseStart noise1 -#define noiseStop noise2 -#define noiseRunning noise3 +#define noiseStart noise1 +#define noiseStop noise2 +#define noiseRunning noise3 // This is just a solid wall if not inhibited class CFuncWall: public CBaseEntity @@ -80,6 +44,9 @@ public: virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); }; +#define SF_WALL_TOOGLE_START_OFF BIT(0) +#define SF_WALL_TOOGLE_NOTSOLID BIT(3) + class CFuncWallToggle: public CFuncWall { public: @@ -97,6 +64,9 @@ public: BOOL IsOn(); }; +#define SF_CONVEYOR_VISUAL BIT(0) +#define SF_CONVEYOR_NOTSOLID BIT(1) + class CFuncConveyor: public CFuncWall { public: @@ -135,6 +105,20 @@ public: virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) {} }; +#define SF_BRUSH_ROTATE_START_ON BIT(0) +#define SF_BRUSH_ROTATE_BACKWARDS BIT(1) +#define SF_BRUSH_ROTATE_Z_AXIS BIT(2) +#define SF_BRUSH_ROTATE_X_AXIS BIT(3) +#define SF_BRUSH_ACCDCC BIT(4) // Brush should accelerate and decelerate when toggled +#define SF_BRUSH_HURT BIT(5) // Rotating brush that inflicts pain based on rotation speed +#define SF_BRUSH_ROTATE_NOT_SOLID BIT(6) // Some special rotating objects are not solid. +#define SF_BRUSH_ROTATE_SMALLRADIUS BIT(7) +#define SF_BRUSH_ROTATE_MEDIUMRADIUS BIT(8) +#define SF_BRUSH_ROTATE_LARGERADIUS BIT(9) + +const int MAX_FANPITCH = 100; +const int MIN_FANPITCH = 30; + class CFuncRotating: public CBaseEntity { public: @@ -157,7 +141,7 @@ public: void EXPORT HurtTouch(CBaseEntity *pOther); void EXPORT RotatingUse(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); void EXPORT Rotate(); - void RampPitchVol(int fUp); + void RampPitchVol(BOOL fUp); public: static TYPEDESCRIPTION IMPL(m_SaveData)[5]; @@ -174,6 +158,11 @@ public: }; +#define SF_PENDULUM_START_ON BIT(0) +#define SF_PENDULUM_SWING BIT(1) // Spawnflag that makes a pendulum a rope swing +#define SF_PENDULUM_PASSABLE BIT(3) +#define SF_PENDULUM_AUTO_RETURN BIT(4) + class CPendulum: public CBaseEntity { public: @@ -208,5 +197,3 @@ public: }; Vector VecBModelOrigin(entvars_t *pevBModel); - -#endif // BMODELS_H diff --git a/regamedll/dlls/bot/cs_bot.cpp b/regamedll/dlls/bot/cs_bot.cpp index c53949ee..e64704ca 100644 --- a/regamedll/dlls/bot/cs_bot.cpp +++ b/regamedll/dlls/bot/cs_bot.cpp @@ -11,7 +11,7 @@ LINK_ENTITY_TO_CLASS(bot, CCSBot, CAPI_CSBot) int GetBotFollowCount(CBasePlayer *leader) { int count = 0; - for (int i = 1; i <= gpGlobals->maxClients; ++i) + for (int i = 1; i <= gpGlobals->maxClients; i++) { CBasePlayer *player = UTIL_PlayerByIndex(i); @@ -32,7 +32,7 @@ int GetBotFollowCount(CBasePlayer *leader) CCSBot *bot = reinterpret_cast(player); if (bot->IsBot() && bot->GetFollowLeader() == leader) - ++count; + count++; } return count; @@ -72,71 +72,69 @@ bool CCSBot::Jump(bool mustJump) // NOTE: We dont want to directly call Attack() here, or the bots will have super-human reaction times when injured BOOL CCSBot::TakeDamage(entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType) { - CBaseEntity *attacker = GetClassPtr((CBaseEntity *)pevInflictor); + CBaseEntity *pAttacker = GetClassPtr((CBaseEntity *)pevInflictor); // if we were attacked by a teammate, rebuke - if (attacker->IsPlayer()) + if (pAttacker->IsPlayer()) { - CBasePlayer *player = static_cast(attacker); - if (BotRelationship(player) == BOT_TEAMMATE && !player->IsBot()) + CBasePlayer *pPlayer = static_cast(pAttacker); + if (BotRelationship(pPlayer) == BOT_TEAMMATE && !pPlayer->IsBot()) { GetChatter()->FriendlyFire(); } - } - if (attacker->IsPlayer() && IsEnemy(attacker)) - { - // Track previous attacker so we don't try to panic multiple times for a shotgun blast - CBasePlayer *lastAttacker = m_attacker; - float lastAttackedTimestamp = m_attackedTimestamp; - - // keep track of our last attacker - m_attacker = static_cast(attacker); - m_attackedTimestamp = gpGlobals->time; - - // no longer safe - AdjustSafeTime(); - - if (!IsSurprised() && (m_attacker != lastAttacker || m_attackedTimestamp != lastAttackedTimestamp)) + if (IsEnemy(pPlayer)) { - CBasePlayer *enemy = static_cast(attacker); + // Track previous attacker so we don't try to panic multiple times for a shotgun blast + CBasePlayer *lastAttacker = m_attacker; + float lastAttackedTimestamp = m_attackedTimestamp; - // being hurt by an enemy we can't see causes panic - if (!IsVisible(enemy, CHECK_FOV)) + // keep track of our last attacker + m_attacker = pPlayer; + m_attackedTimestamp = gpGlobals->time; + + // no longer safe + AdjustSafeTime(); + + if (!IsSurprised() && (m_attacker != lastAttacker || m_attackedTimestamp != lastAttackedTimestamp)) { - bool bPanic = false; + // being hurt by an enemy we can't see causes panic + if (!IsVisible(pPlayer, CHECK_FOV)) + { + bool bPanic = false; - // if not attacking anything, look around to try to find attacker - if (!IsAttacking()) - { - bPanic = true; - } - else - { - // we are attacking - if (!IsEnemyVisible()) + // if not attacking anything, look around to try to find attacker + if (!IsAttacking()) + { + bPanic = true; + } + else + { + // we are attacking + if (!IsEnemyVisible()) + { + // can't see our current enemy, panic to acquire new attacker + bPanic = true; + } + } + + if (!bPanic) + { + float invSkill = 1.0f - GetProfile()->GetSkill(); + float panicChance = invSkill * invSkill * 50.0f; + + if (panicChance > RANDOM_FLOAT(0, 100)) + { + bPanic = true; + } + } + + if (bPanic) { // can't see our current enemy, panic to acquire new attacker - bPanic = true; + Panic(m_attacker); } } - - if (!bPanic) - { - float invSkill = 1.0f - GetProfile()->GetSkill(); - float panicChance = invSkill * invSkill * 50.0f; - - if (panicChance > RANDOM_FLOAT(0, 100)) - { - bPanic = true; - } - } - - if (bPanic) - { - // can't see our current enemy, panic to acquire new attacker - Panic(m_attacker); - } } } } @@ -164,6 +162,13 @@ void CCSBot::Killed(entvars_t *pevAttacker, int iGib) CBasePlayer::Killed(pevAttacker, iGib); } +#define HI_X 0x01 +#define LO_X 0x02 +#define HI_Y 0x04 +#define LO_Y 0x08 +#define HI_Z 0x10 +#define LO_Z 0x20 + // Return true if line segment intersects rectagular volume bool IsIntersectingBox(const Vector *start, const Vector *end, const Vector *boxMin, const Vector *boxMax) { @@ -234,9 +239,9 @@ void CCSBot::BotTouch(CBaseEntity *other) return; // they are higher priority - make way, unless we're already making way for someone more important - if (m_avoid != NULL) + if (m_avoid) { - unsigned int avoidPri = TheCSBots()->GetPlayerPriority(static_cast(m_avoid)); + unsigned int avoidPri = TheCSBots()->GetPlayerPriority(m_avoid); if (avoidPri < otherPri) { // ignore 'other' because we're already avoiding someone better @@ -244,7 +249,7 @@ void CCSBot::BotTouch(CBaseEntity *other) } } - m_avoid = other; + m_avoid = static_cast(other); m_avoidTimestamp = gpGlobals->time; return; @@ -307,11 +312,11 @@ void CCSBot::BotDeathThink() CBasePlayer *CCSBot::FindNearbyPlayer() { - CBaseEntity *pEntity = NULL; + CBaseEntity *pEntity = nullptr; Vector vecSrc = pev->origin; const float flRadius = 800.0f; - while ((pEntity = UTIL_FindEntityInSphere(pEntity, vecSrc, flRadius)) != NULL) + while ((pEntity = UTIL_FindEntityInSphere(pEntity, vecSrc, flRadius))) { if (!pEntity->IsPlayer()) continue; @@ -322,7 +327,7 @@ CBasePlayer *CCSBot::FindNearbyPlayer() return static_cast(pEntity); } - return NULL; + return nullptr; } // Assign given player as our current enemy to attack @@ -335,12 +340,12 @@ void CCSBot::SetEnemy(CBasePlayer *enemy) } } -// If we are not on the navigation mesh (m_currentArea == NULL), +// If we are not on the navigation mesh (m_currentArea == nullptr), // move towards last known area. // Return false if off mesh. bool CCSBot::StayOnNavMesh() { - if (m_currentArea != NULL) + if (m_currentArea) return true; // move back onto the area map @@ -359,7 +364,7 @@ bool CCSBot::StayOnNavMesh() PrintIfWatched("Getting out of NULL area...\n"); } - if (goalArea != NULL) + if (goalArea) { Vector pos; goalArea->GetClosestPointOnArea(&pev->origin, &pos); @@ -461,8 +466,7 @@ bool CCSBot::NoticeLooseBomb() const return false; CBaseEntity *bomb = TheCSBots()->GetLooseBomb(); - - if (bomb != NULL) + if (bomb) { // T's can always see bomb on their radar return true; @@ -478,8 +482,7 @@ bool CCSBot::CanSeeLooseBomb() const return false; CBaseEntity *bomb = TheCSBots()->GetLooseBomb(); - - if (bomb != NULL) + if (bomb) { if (IsVisible(&bomb->pev->origin, CHECK_FOV)) return true; @@ -498,8 +501,7 @@ bool CCSBot::CanSeePlantedBomb() const return false; const Vector *bombPos = GetGameState()->GetBombPosition(); - - if (bombPos != NULL && IsVisible(bombPos, CHECK_FOV)) + if (bombPos && IsVisible(bombPos, CHECK_FOV)) return true; return false; @@ -508,10 +510,10 @@ bool CCSBot::CanSeePlantedBomb() const // Return last enemy that hurt us CBasePlayer *CCSBot::GetAttacker() const { - if (m_attacker != NULL && m_attacker->IsAlive()) + if (m_attacker && m_attacker->IsAlive()) return m_attacker; - return NULL; + return nullptr; } // Immediately jump off of our ladder, if we're on one @@ -527,7 +529,7 @@ void CCSBot::GetOffLadder() // Return time when given spot was last checked float CCSBot::GetHidingSpotCheckTimestamp(HidingSpot *spot) const { - for (int i = 0; i < m_checkedHidingSpotCount; ++i) + for (int i = 0; i < m_checkedHidingSpotCount; i++) { if (m_checkedHidingSpot[i].spot->GetID() == spot->GetID()) return m_checkedHidingSpot[i].timestamp; @@ -543,7 +545,7 @@ void CCSBot::SetHidingSpotCheckTimestamp(HidingSpot *spot) int leastRecent = 0; float leastRecentTime = gpGlobals->time + 1.0f; - for (int i = 0; i < m_checkedHidingSpotCount; ++i) + for (int i = 0; i < m_checkedHidingSpotCount; i++) { // if spot is in the set, just update its timestamp if (m_checkedHidingSpot[i].spot->GetID() == spot->GetID()) @@ -565,7 +567,7 @@ void CCSBot::SetHidingSpotCheckTimestamp(HidingSpot *spot) { m_checkedHidingSpot[ m_checkedHidingSpotCount ].spot = spot; m_checkedHidingSpot[ m_checkedHidingSpotCount ].timestamp = gpGlobals->time; - ++m_checkedHidingSpotCount; + m_checkedHidingSpotCount++; } else { @@ -587,8 +589,8 @@ void CCSBot::UpdateHostageEscortCount() // recount the hostages in case we lost some m_hostageEscortCount = 0; - CHostage *hostage = NULL; - while ((hostage = static_cast(UTIL_FindEntityByClassname(hostage, "hostage_entity")))) + CHostage *hostage = nullptr; + while ((hostage = UTIL_FindEntityByClassname(hostage, "hostage_entity"))) { if (FNullEnt(hostage->edict())) break; @@ -599,7 +601,7 @@ void CCSBot::UpdateHostageEscortCount() // check if hostage has targeted us, and is following if (hostage->IsFollowing(this)) - ++m_hostageEscortCount; + m_hostageEscortCount++; } } @@ -623,14 +625,14 @@ int CCSBot::OutnumberedCount() const // Return the closest "important" enemy for the given scenario (bomb carrier, VIP, hostage escorter) CBasePlayer *CCSBot::GetImportantEnemy(bool checkVisibility) const { - CBasePlayer *nearEnemy = NULL; + CBasePlayer *nearEnemy = nullptr; float nearDist = 999999999.9f; - for (int i = 1; i <= gpGlobals->maxClients; ++i) + for (int i = 1; i <= gpGlobals->maxClients; i++) { CBasePlayer *player = UTIL_PlayerByIndex(i); - if (player == NULL) + if (!player) continue; if (FNullEnt(player->pev)) @@ -808,11 +810,10 @@ bool CCSBot::HasNotSeenEnemyForLongTime() const bool CCSBot::GuardRandomZone(float range) { const CCSBotManager::Zone *zone = TheCSBots()->GetRandomZone(); - - if (zone != NULL) + if (zone) { CNavArea *rescueArea = TheCSBots()->GetRandomAreaInZone(zone); - if (rescueArea != NULL) + if (rescueArea) { Hide(rescueArea, -1.0f, range); return true; @@ -827,15 +828,15 @@ bool CCSBot::GuardRandomZone(float range) const Vector *FindNearbyRetreatSpot(CCSBot *me, float maxRange) { CNavArea *area = me->GetLastKnownArea(); - if (area == NULL) - return NULL; + if (!area) + return nullptr; // collect spots that enemies cannot see CollectRetreatSpotsFunctor collector(me, maxRange); SearchSurroundingAreas(area, &me->pev->origin, collector, maxRange); if (collector.m_count == 0) - return NULL; + return nullptr; // select a hiding spot at random int which = RANDOM_LONG(0, collector.m_count - 1); diff --git a/regamedll/dlls/bot/cs_bot.h b/regamedll/dlls/bot/cs_bot.h index 8c2a0edc..dd8953c1 100644 --- a/regamedll/dlls/bot/cs_bot.h +++ b/regamedll/dlls/bot/cs_bot.h @@ -26,41 +26,30 @@ * */ -#ifndef CS_BOT_H -#define CS_BOT_H -#ifdef _WIN32 #pragma once -#endif #include "bot/cs_gamestate.h" #include "bot/cs_bot_manager.h" #include "bot/cs_bot_chatter.h" -#define CSBOT_VERSION_MAJOR 1 -#define CSBOT_VERSION_MINOR 50 +const int MAX_BUY_WEAPON_PRIMARY = 13; +const int MAX_BUY_WEAPON_SECONDARY = 3; -#define PRIMARY_WEAPON_BUY_COUNT 13 -#define SECONDARY_WEAPON_BUY_COUNT 3 - -#define FLAG_PROGRESS_DRAW 0x0 // draw status bar progress -#define FLAG_PROGRESS_START 0x1 // init status bar progress -#define FLAG_PROGRESS_HIDE 0x2 // hide status bar progress - -#define HI_X 0x01 -#define LO_X 0x02 -#define HI_Y 0x04 -#define LO_Y 0x08 -#define HI_Z 0x10 -#define LO_Z 0x20 +enum +{ + BOT_PROGGRESS_DRAW = 0, // draw status bar progress + BOT_PROGGRESS_START, // init status bar progress + BOT_PROGGRESS_HIDE, // hide status bar progress +}; extern int _navAreaCount; extern int _currentIndex; -extern struct BuyInfo primaryWeaponBuyInfoCT[PRIMARY_WEAPON_BUY_COUNT]; -extern struct BuyInfo secondaryWeaponBuyInfoCT[SECONDARY_WEAPON_BUY_COUNT]; +extern struct BuyInfo primaryWeaponBuyInfoCT[MAX_BUY_WEAPON_PRIMARY]; +extern struct BuyInfo secondaryWeaponBuyInfoCT[MAX_BUY_WEAPON_SECONDARY]; -extern struct BuyInfo primaryWeaponBuyInfoT[PRIMARY_WEAPON_BUY_COUNT]; -extern struct BuyInfo secondaryWeaponBuyInfoT[SECONDARY_WEAPON_BUY_COUNT]; +extern struct BuyInfo primaryWeaponBuyInfoT[MAX_BUY_WEAPON_PRIMARY]; +extern struct BuyInfo secondaryWeaponBuyInfoT[MAX_BUY_WEAPON_SECONDARY]; class CCSBot; class BotChatterInterface; @@ -90,7 +79,7 @@ public: virtual void OnExit(CCSBot *me); virtual const char *GetName() const { return "Hunt"; } - void ClearHuntArea() { m_huntArea = NULL; } + void ClearHuntArea() { m_huntArea = nullptr; } private: CNavArea *m_huntArea; @@ -264,12 +253,12 @@ public: virtual void OnExit(CCSBot *me); virtual const char *GetName() const { return "Follow"; } - void SetLeader(CBaseEntity *leader) { m_leader = leader; } + void SetLeader(CBasePlayer *leader) { m_leader = leader; } private: void ComputeLeaderMotionState(float leaderSpeed); - EHANDLE m_leader; + EntityHandle m_leader; Vector m_lastLeaderPos; bool m_isStopped; float m_stoppedTimestamp; @@ -307,14 +296,14 @@ public: void SetEntity(CBaseEntity *entity) { m_entity = entity; } private: - EHANDLE m_entity; + EntityHandle m_entity; }; // The Counter-strike Bot class CCSBot: public CBot { public: - CCSBot(); // constructor initializes all values to zero + CCSBot(); // constructor initializes all values to zero virtual BOOL TakeDamage(entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType); // invoked when injured by something (EXTEND) - returns the amount of damage inflicted virtual void Killed(entvars_t *pevAttacker, int iGib); // invoked when killed (EXTEND) virtual void RoundRespawn(); @@ -330,11 +319,11 @@ public: virtual void Walk(); virtual bool Jump(bool mustJump = false); // returns true if jump was started - virtual void OnEvent(GameEventType event, CBaseEntity *entity = NULL, CBaseEntity *other = NULL); // invoked when event occurs in the game (some events have NULL entity) + virtual void OnEvent(GameEventType event, CBaseEntity *entity = nullptr, CBaseEntity *other = nullptr); // invoked when event occurs in the game (some events have NULL entity) #define CHECK_FOV true virtual bool IsVisible(const Vector *pos, bool testFOV = false) const; // return true if we can see the point - virtual bool IsVisible(CBasePlayer *player, bool testFOV = false, unsigned char *visParts = NULL) const; // return true if we can see any part of the player + virtual bool IsVisible(CBasePlayer *player, bool testFOV = false, unsigned char *visParts = nullptr) const; // return true if we can see any part of the player virtual bool IsEnemyPartVisible(VisiblePartType part) const; // if enemy is visible, return the part we see for our current enemy @@ -348,19 +337,19 @@ public: bool IsHurrying() const; // return true if we are in a hurry void Hurry(float duration); // force bot to hurry bool IsSafe() const; // return true if we are in a safe region - bool IsWellPastSafe() const; // return true if it is well past the early, "safe", part of the round - bool IsEndOfSafeTime() const; // return true if we were in the safe time last update, but not now - float GetSafeTimeRemaining() const; // return the amount of "safe time" we have left + bool IsWellPastSafe() const; // return true if it is well past the early, "safe", part of the round + bool IsEndOfSafeTime() const; // return true if we were in the safe time last update, but not now + float GetSafeTimeRemaining() const; // return the amount of "safe time" we have left float GetSafeTime() const; // return what we think the total "safe time" for this map is //bool IsUnhealthy() const; // returns true if bot is low on health // behaviors void Idle(); - void Hide(CNavArea *searchFromArea = NULL, float duration = -1.0f, float hideRange = 750.0f, bool holdPosition = false); // DEPRECATED: Use TryToHide() instead + void Hide(CNavArea *searchFromArea = nullptr, float duration = -1.0f, float hideRange = 750.0f, bool holdPosition = false); // DEPRECATED: Use TryToHide() instead #define USE_NEAREST true - bool TryToHide(CNavArea *searchFromArea = NULL, float duration = -1.0f, float hideRange = 750.0f, bool holdPosition = false, bool useNearest = false); // try to hide nearby, return false if cannot + bool TryToHide(CNavArea *searchFromArea = nullptr, float duration = -1.0f, float hideRange = 750.0f, bool holdPosition = false, bool useNearest = false); // try to hide nearby, return false if cannot - void Hide(const Vector *hidingSpot, float duration = -1.0f, bool holdPosition = false); // move to the given hiding place + void Hide(const Vector *hidingSpot, float duration = -1.0f, bool holdPosition = false); // move to the given hiding place bool IsHiding() const; // returns true if bot is currently hiding bool IsAtHidingSpot() const; // return true if we are hiding and at our hiding spot bool TryToRetreat(); // retreat to a nearby hiding spot, away from enemies @@ -454,7 +443,7 @@ public: NUM_TASKS }; - void SetTask(TaskType task, CBaseEntity *entity = NULL); // set our current "task" + void SetTask(TaskType task, CBaseEntity *entity = nullptr); // set our current "task" TaskType GetTask() const; CBaseEntity *GetTaskEntity(); @@ -491,7 +480,7 @@ public: // listening for noises bool IsNoiseHeard() const; // return true if we have heard a noise - bool ShouldInvestigateNoise(float *retNoiseDist = NULL); + bool ShouldInvestigateNoise(float *retNoiseDist = nullptr); void InvestigateNoise(); // investigate recent enemy noise const Vector *GetNoisePosition() const; // return position of last heard noise, or NULL if none heard CNavArea *GetNoiseArea() const; // return area where noise was heard @@ -573,7 +562,7 @@ public: void ResetStuckMonitor(); bool IsAreaVisible(CNavArea *area) const; // is any portion of the area visible to this bot const Vector &GetPathPosition(int numpath) const; - bool GetSimpleGroundHeightWithFloor(const Vector *pos, float *height, Vector *normal = NULL); // find "simple" ground height, treating current nav area as part of the floor + bool GetSimpleGroundHeightWithFloor(const Vector *pos, float *height, Vector *normal = nullptr); // find "simple" ground height, treating current nav area as part of the floor Place GetPlace() const; // get our current radio chatter place @@ -581,7 +570,9 @@ public: void GetOffLadder(); void SetGoalEntity(CBaseEntity *entity); - CBaseEntity *GetGoalEntity(); + + template + T *GetGoalEntity(); bool IsNearJump() const; // return true if nearing a jump in the path float GetApproximateFallDamage(float height) const; // return how much damage will will take from the given fall height @@ -614,6 +605,7 @@ public: return m_eyePos; } float ComputeWeaponSightRange(); // return line-of-sight distance to obstacle along weapon fire ray + bool IsSignificantlyCloser(const CBasePlayer *testPlayer, const CBasePlayer *referencePlayer) const; // return true if testPlayer is significantly closer than referencePlayer // approach points void ComputeApproachPoints(); // determine the set of "approach points" representing where the enemy can enter this region @@ -696,7 +688,7 @@ private: float m_surpriseTimestamp; bool m_isFollowing; // true if we are following someone - EHANDLE m_leader; // the ID of who we are following + EntityHandle m_leader; // the ID of who we are following float m_followTimestamp; // when we started following float m_allowAutoFollowTime; // time when we can auto follow @@ -724,11 +716,11 @@ private: bool m_isAttacking; // if true, special Attack state is overriding the state machine TaskType m_task; // our current task - EHANDLE m_taskEntity; // an entity used for our task + EntityHandle m_taskEntity; // an entity used for our task // navigation Vector m_goalPosition; - EHANDLE m_goalEntity; + EHandle m_goalEntity; void MoveTowardsPosition(const Vector *pos); // move towards position, independant of view angle void MoveAwayFromPosition(const Vector *pos); // move away from position, independant of view angle void StrafeAwayFromPosition(const Vector *pos); // strafe (sidestep) away from position, independant of view angle @@ -736,7 +728,7 @@ private: CNavArea *m_currentArea; // the nav area we are standing on CNavArea *m_lastKnownArea; // the last area we were in - EHANDLE m_avoid; // higher priority player we need to make way for + EntityHandle m_avoid; // higher priority player we need to make way for float m_avoidTimestamp; bool m_isJumpCrouching; bool m_isJumpCrouched; @@ -765,7 +757,7 @@ private: void SetPathIndex(int newIndex); // set the current index along the path void DrawPath(); int FindOurPositionOnPath(Vector *close, bool local = false) const; // compute the closest point to our current position on our path - int FindPathPoint(float aheadRange, Vector *point, int *prevIndex = NULL); // compute a point a fixed distance ahead along our path. + int FindPathPoint(float aheadRange, Vector *point, int *prevIndex = nullptr); // compute a point a fixed distance ahead along our path. bool FindClosestPointOnPath(const Vector *worldPos, int startIndex, int endIndex, Vector *close) const; // compute closest point on path to given point bool IsStraightLinePathWalkable(const Vector *goal) const; // test for un-jumpable height change, or unrecoverable fall @@ -890,12 +882,12 @@ private: Vector m_aimSpot; // the spot we are currently aiming to fire at // attack state data - DispositionType m_disposition; // how we will react to enemies - CountdownTimer m_ignoreEnemiesTimer; // how long will we ignore enemies - mutable EHANDLE m_enemy; // our current enemy - bool m_isEnemyVisible; // result of last visibility test on enemy - unsigned char m_visibleEnemyParts; // which parts of the visible enemy do we see - Vector m_lastEnemyPosition; // last place we saw the enemy + DispositionType m_disposition; // how we will react to enemies + CountdownTimer m_ignoreEnemiesTimer; // how long will we ignore enemies + mutable EntityHandle m_enemy; // our current enemy + bool m_isEnemyVisible; // result of last visibility test on enemy + unsigned char m_visibleEnemyParts; // which parts of the visible enemy do we see + Vector m_lastEnemyPosition; // last place we saw the enemy float m_lastSawEnemyTimestamp; float m_firstSawEnemyTimestamp; float m_currentEnemyAcquireTimestamp; @@ -910,11 +902,15 @@ private: bool isEnemy; } m_watchInfo[MAX_CLIENTS]; - mutable EHANDLE m_bomber; // points to bomber if we can see him + mutable EntityHandle m_bomber; // points to bomber if we can see him - int m_nearbyFriendCount; // number of nearby teammates - mutable EHANDLE m_closestVisibleFriend; // the closest friend we can see - mutable EHANDLE m_closestVisibleHumanFriend; // the closest human friend we can see + int m_nearbyFriendCount; // number of nearby teammates + mutable EntityHandle m_closestVisibleFriend; // the closest friend we can see + mutable EntityHandle m_closestVisibleHumanFriend; // the closest human friend we can see + +#ifdef REGAMEDLL_ADD + IntervalTimer m_attentionInterval; // time between attention checks +#endif CBasePlayer *m_attacker; // last enemy that hurt us (may not be same as m_enemy) float m_attackedTimestamp; // when we were hurt by the m_attacker @@ -923,7 +919,7 @@ private: bool m_isAimingAtEnemy; // if true, we are trying to aim at our enemy bool m_isRapidFiring; // if true, RunUpkeep() will toggle our primary attack as fast as it can IntervalTimer m_equipTimer; // how long have we had our current weapon equipped - bool DoEquip(CBasePlayerWeapon *gun); // equip the given item + bool DoEquip(CBasePlayerWeapon *pWeapon); // equip the given item void ReloadCheck(); // reload our weapon if we must void SilencerCheck(); // use silencer @@ -935,7 +931,7 @@ private: struct ReactionState { // NOTE: player position & orientation is not currently stored separately - EHANDLE player; + EntityHandle player; bool isReloading; bool isProtectedByShield; } @@ -962,7 +958,7 @@ private: Vector m_lastOrigin; // chatter mechanism - GameEventType m_lastRadioCommand; // last radio command we recieved + GameEventType m_lastRadioCommand; // last radio command we recieved void RespondToRadioCommands(); bool IsRadioCommand(GameEventType event) const; // returns true if the radio message is an order to do something @@ -970,7 +966,7 @@ private: void EndVoiceFeedback(bool force = true); float m_lastRadioRecievedTimestamp; // time we recieved a radio message float m_lastRadioSentTimestamp; // time when we send a radio message - EHANDLE m_radioSubject; // who issued the radio message + EntityHandle m_radioSubject; // who issued the radio message Vector m_radioPosition; // position referred to in radio message float m_voiceFeedbackStartTimestamp; float m_voiceFeedbackEndTimestamp; // new-style "voice" chatter gets voice feedback @@ -1008,6 +1004,10 @@ private: void StartSaveProcess(); void UpdateSaveProcess(); void StartNormalProcess(); + +#ifdef REGAMEDLL_ADD + bool IsNoticable(const CBasePlayer *player, unsigned char visibleParts) const; // return true if we "notice" given player +#endif }; // Inlines @@ -1188,7 +1188,7 @@ inline unsigned int CCSBot::GetEnemyPlace() const inline bool CCSBot::CanSeeBomber() const { - return (m_bomber == NULL) ? false : true; + return m_bomber.IsValid(); } inline CBasePlayer *CCSBot::GetBomber() const @@ -1264,7 +1264,7 @@ inline bool CCSBot::HasPath() const inline void CCSBot::DestroyPath() { m_pathLength = 0; - m_pathLadder = NULL; + m_pathLadder = nullptr; } inline CNavArea *CCSBot::GetLastKnownArea() const @@ -1284,7 +1284,7 @@ inline const Vector &CCSBot::GetPathPosition(int numpath) const inline bool CCSBot::IsUsingLadder() const { - return m_pathLadder != NULL; + return m_pathLadder != nullptr; } inline void CCSBot::SetGoalEntity(CBaseEntity *entity) @@ -1292,9 +1292,10 @@ inline void CCSBot::SetGoalEntity(CBaseEntity *entity) m_goalEntity = entity; } -inline CBaseEntity *CCSBot::GetGoalEntity() +template +inline T *CCSBot::GetGoalEntity() { - return m_goalEntity; + return m_goalEntity.Get(); } inline void CCSBot::ForceRun(float duration) @@ -1323,7 +1324,7 @@ inline void CCSBot::ClearLookAt() { //PrintIfWatched("ClearLookAt()\n"); m_lookAtSpotState = NOT_LOOKING_AT_SPOT; - m_lookAtDesc = NULL; + m_lookAtDesc = nullptr; } inline bool CCSBot::IsLookingAtSpot(PriorityType pri) const @@ -1345,6 +1346,21 @@ inline bool CCSBot::IsViewMoving(float angleVelThreshold) const return true; } +inline bool CCSBot::IsSignificantlyCloser(const CBasePlayer *testPlayer, const CBasePlayer *referencePlayer) const +{ + if (!referencePlayer || !testPlayer) + return true; + + float testDist = (pev->origin - testPlayer->pev->origin).Length(); + float referenceDist = (pev->origin - referencePlayer->pev->origin).Length(); + + const float significantRangeFraction = 0.7f; + if (testDist < referenceDist * significantRangeFraction) + return true; + + return false; +} + inline void CCSBot::ClearApproachPoints() { m_approachPointCount = 0; @@ -1411,7 +1427,7 @@ inline const Vector *CCSBot::GetNoisePosition() const if (m_noiseTimestamp > 0.0f) return &m_noisePosition; - return NULL; + return nullptr; } inline bool CCSBot::IsAwareOfEnemyDeath() const @@ -1419,7 +1435,7 @@ inline bool CCSBot::IsAwareOfEnemyDeath() const if (GetEnemyDeathTimestamp() == 0.0f) return false; - if (m_enemy == NULL) + if (!m_enemy.IsValid()) return true; if (!m_enemy->IsAlive() && gpGlobals->time - GetEnemyDeathTimestamp() > (1.0f - GetProfile()->GetSkill())) @@ -1484,7 +1500,7 @@ public: // don't select spot if it is closest to an enemy CBasePlayer *owner = UTIL_GetClosestPlayer(spot->GetPosition()); - if (owner != NULL && m_me->m_iTeam != owner->m_iTeam) + if (owner && m_me->m_iTeam != owner->m_iTeam) continue; m_spot[m_count++] = spot->GetPosition(); @@ -1547,7 +1563,7 @@ public: // respond to the danger modulated by our aggression (even super-aggressives pay SOME attention to danger) float dangerFactor = (1.0f - (0.95f * m_bot->GetProfile()->GetAggression())) * baseDangerFactor; - if (fromArea == NULL) + if (fromArea == nullptr) { if (m_route == FASTEST_ROUTE) return 0.0f; @@ -1753,5 +1769,3 @@ void hideProgressMeter(); bool isSniperRifle(CBasePlayerItem *item); float StayOnLadderLine(CCSBot *me, const CNavLadder *ladder); - -#endif // CS_BOT_H diff --git a/regamedll/dlls/bot/cs_bot_chatter.cpp b/regamedll/dlls/bot/cs_bot_chatter.cpp index 5e61069c..7476a4c4 100644 --- a/regamedll/dlls/bot/cs_bot_chatter.cpp +++ b/regamedll/dlls/bot/cs_bot_chatter.cpp @@ -6,8 +6,7 @@ */ #ifndef HOOK_GAMEDLL -BotPhraseManager *TheBotPhrases = NULL; -CBaseEntity *g_pSelectedZombieSpawn = NULL; +BotPhraseManager *TheBotPhrases = nullptr; CountdownTimer BotChatterInterface::m_encourageTimer; IntervalTimer BotChatterInterface::m_radioSilenceInterval[ 2 ]; @@ -16,37 +15,32 @@ IntervalTimer BotChatterInterface::m_radioSilenceInterval[ 2 ]; const Vector *GetRandomSpotAtPlace(Place place) { int count = 0; - NavAreaList::iterator iter; int which; - for (iter = TheNavAreaList.begin(); iter != TheNavAreaList.end(); ++iter) + for (auto area : TheNavAreaList) { - CNavArea *area = (*iter); - if (area->GetPlace() == place) - ++count; + count++; } if (count == 0) - return NULL; + return nullptr; which = RANDOM_LONG(0, count - 1); - for (iter = TheNavAreaList.begin(); iter != TheNavAreaList.end(); ++iter) + for (auto area : TheNavAreaList) { - CNavArea *area = (*iter); - if (area->GetPlace() == place && which == 0) return area->GetCenter(); } - return NULL; + return nullptr; } // Transmit meme to other bots void BotMeme::Transmit(CCSBot *sender) const { - for (int i = 1; i <= gpGlobals->maxClients; ++i) + for (int i = 1; i <= gpGlobals->maxClients; i++) { CBasePlayer *player = UTIL_PlayerByIndex(i); @@ -235,7 +229,7 @@ void BotHostageBeingTakenMeme::Interpret(CCSBot *sender, CCSBot *receiver) const BotSpeakable::BotSpeakable() { - m_phrase = NULL; + m_phrase = nullptr; } BotSpeakable::~BotSpeakable() @@ -243,13 +237,13 @@ BotSpeakable::~BotSpeakable() if (m_phrase) { delete[] m_phrase; - m_phrase = NULL; + m_phrase = nullptr; } } BotPhrase::BotPhrase(unsigned int id, bool isPlace) { - m_name = NULL; + m_name = nullptr; m_id = id; m_isPlace = isPlace; m_radioEvent = EVENT_INVALID; @@ -263,19 +257,20 @@ BotPhrase::BotPhrase(unsigned int id, bool isPlace) BotPhrase::~BotPhrase() { - for (size_t bank = 0; bank < m_voiceBank.size(); ++bank) + for (size_t bank = 0; bank < m_voiceBank.size(); bank++) { - for (size_t speakable = 0; speakable < m_voiceBank[bank]->size(); ++speakable) + for (size_t speakable = 0; speakable < m_voiceBank[bank]->size(); speakable++) { delete (*m_voiceBank[bank])[speakable]; } + delete m_voiceBank[bank]; } if (m_name) { delete[] m_name; - m_name = NULL; + m_name = nullptr; } } @@ -286,7 +281,7 @@ void BotPhrase::InitVoiceBank(int bankIndex) m_count.push_back(0); m_index.push_back(0); m_voiceBank.push_back(new BotSpeakableVector); - ++m_numVoiceBanks; + m_numVoiceBanks++; } } @@ -298,7 +293,7 @@ char *BotPhrase::GetSpeakable(int bankIndex, float *duration) const if (duration) *duration = 0.0f; - return NULL; + return nullptr; } // find phrase that meets the current criteria @@ -338,18 +333,18 @@ char *BotPhrase::GetSpeakable(int bankIndex, float *duration) const if (duration) *duration = 0.0f; - return NULL; + return nullptr; } } - return NULL; + return nullptr; } // Randomly shuffle the speakable order #ifndef HOOK_GAMEDLL void BotPhrase::Randomize() { - for (size_t i = 0; i < m_voiceBank.size(); ++i) + for (size_t i = 0; i < m_voiceBank.size(); i++) { std::random_shuffle(m_voiceBank[i]->begin(), m_voiceBank[i]->end()); } @@ -358,7 +353,7 @@ void BotPhrase::Randomize() BotPhraseManager::BotPhraseManager() { - for (int i = 0; i < MAX_PLACES_PER_MAP; ++i) + for (int i = 0; i < MAX_PLACES_PER_MAP; i++) m_placeStatementHistory[i].timer.Invalidate(); m_placeCount = 0; @@ -375,18 +370,13 @@ void BotPhraseManager::OnRoundRestart() { // effectively reset all interval timers m_placeCount = 0; - BotPhraseList::const_iterator iter; // shuffle all the speakables - for (iter = m_placeList.begin(); iter != m_placeList.end(); ++iter) - { - (*iter)->Randomize(); - } + for (auto phrase : m_placeList) + phrase->Randomize(); - for (iter = m_list.begin(); iter != m_list.end(); ++iter) - { - (*iter)->Randomize(); - } + for (auto phrase : m_list) + phrase->Randomize(); } // Initialize phrase system from database file @@ -396,7 +386,7 @@ bool BotPhraseManager::Initialize(const char *filename, int bankIndex) int phraseDataLength; char *phraseDataFile = (char *)LOAD_FILE_FOR_ME((char *)filename, &phraseDataLength); - if (phraseDataFile == NULL) + if (!phraseDataFile) { if (AreBotsAllowed()) { @@ -406,6 +396,7 @@ bool BotPhraseManager::Initialize(const char *filename, int bankIndex) return false; } + char *token; char *phraseData = phraseDataFile; unsigned int nextID = 1; @@ -425,16 +416,15 @@ bool BotPhraseManager::Initialize(const char *filename, int bankIndex) // Parse the BotChatter.db into BotPhrase collections while (true) { - phraseData = MP_COM_Parse(phraseData); + phraseData = SharedParse(phraseData); if (!phraseData) break; - char *token = MP_COM_GetToken(); - + token = SharedGetToken(); if (!Q_stricmp(token, "BaseDir")) { // get name of this output device - phraseData = MP_COM_Parse(phraseData); + phraseData = SharedParse(phraseData); if (!phraseData) { CONSOLE_ECHO("Error parsing '%s' - expected identifier\n", filename); @@ -442,7 +432,7 @@ bool BotPhraseManager::Initialize(const char *filename, int bankIndex) return false; } - char *token = MP_COM_GetToken(); + token = SharedGetToken(); Q_strncpy(baseDir, token, RadioPathLen); baseDir[RadioPathLen - 1] = '\0'; } @@ -451,14 +441,14 @@ bool BotPhraseManager::Initialize(const char *filename, int bankIndex) bool isPlace = (Q_stricmp(token, "Place") == 0); // encountered a new phrase collection - BotPhrase *phrase = NULL; + BotPhrase *phrase = nullptr; if (isDefault) { phrase = new BotPhrase(nextID++, isPlace); } // get name of this phrase - phraseData = MP_COM_Parse(phraseData); + phraseData = SharedParse(phraseData); if (!phraseData) { CONSOLE_ECHO("Error parsing '%s' - expected identifier\n", filename); @@ -466,25 +456,26 @@ bool BotPhraseManager::Initialize(const char *filename, int bankIndex) return false; } + token = SharedGetToken(); if (isDefault) { - phrase->m_name = CloneString(MP_COM_GetToken()); + phrase->m_name = CloneString(token); } // look up the existing phrase else { if (isPlace) { - phrase = const_cast(GetPlace(MP_COM_GetToken())); + phrase = const_cast(GetPlace(token)); } else { - phrase = const_cast(GetPhrase(MP_COM_GetToken())); + phrase = const_cast(GetPhrase(token)); } if (!phrase) { - CONSOLE_ECHO("Error parsing '%s' - phrase '%s' is invalid\n", filename, MP_COM_GetToken()); + CONSOLE_ECHO("Error parsing '%s' - phrase '%s' is invalid\n", filename, token); FREE_FILE(phraseDataFile); return false; } @@ -501,7 +492,7 @@ bool BotPhraseManager::Initialize(const char *filename, int bankIndex) while (true) { // get next token - phraseData = MP_COM_Parse(phraseData); + phraseData = SharedParse(phraseData); if (!phraseData) { CONSOLE_ECHO("Error parsing %s - expected 'End'\n", filename); @@ -509,12 +500,12 @@ bool BotPhraseManager::Initialize(const char *filename, int bankIndex) return false; } - token = MP_COM_GetToken(); + token = SharedGetToken(); // check for Place criteria if (!Q_stricmp(token, "Place")) { - phraseData = MP_COM_Parse(phraseData); + phraseData = SharedParse(phraseData); if (!phraseData) { CONSOLE_ECHO("Error parsing %s - expected Place name\n", filename); @@ -522,7 +513,7 @@ bool BotPhraseManager::Initialize(const char *filename, int bankIndex) return false; } - token = MP_COM_GetToken(); + token = SharedGetToken(); // update place criteria for subsequent speak lines // NOTE: this assumes places must be first in the chatter database @@ -541,7 +532,7 @@ bool BotPhraseManager::Initialize(const char *filename, int bankIndex) // check for Count criteria if (!Q_stricmp(token, "Count")) { - phraseData = MP_COM_Parse(phraseData); + phraseData = SharedParse(phraseData); if (!phraseData) { CONSOLE_ECHO("Error parsing %s - expected Count value\n", filename); @@ -549,7 +540,7 @@ bool BotPhraseManager::Initialize(const char *filename, int bankIndex) return false; } - token = MP_COM_GetToken(); + token = SharedGetToken(); // update count criteria for subsequent speak lines if (!Q_stricmp(token, "Many")) @@ -563,7 +554,7 @@ bool BotPhraseManager::Initialize(const char *filename, int bankIndex) // check for radio equivalent if (!Q_stricmp(token, "Radio")) { - phraseData = MP_COM_Parse(phraseData); + phraseData = SharedParse(phraseData); if (!phraseData) { CONSOLE_ECHO("Error parsing %s - expected radio event\n", filename); @@ -571,7 +562,7 @@ bool BotPhraseManager::Initialize(const char *filename, int bankIndex) return false; } - token = MP_COM_GetToken(); + token = SharedGetToken(); GameEventType event = NameToGameEvent(token); if (event <= EVENT_START_RADIO_1 || event >= EVENT_END_RADIO) { @@ -598,7 +589,7 @@ bool BotPhraseManager::Initialize(const char *filename, int bankIndex) #ifdef REGAMEDLL_ADD Q_snprintf(filePath, sizeof(filePath), "%s%s%s", soundDir, baseDir, token); - if (Q_access(filePath, 0) != 0) + if (_access(filePath, 0) != 0) continue; #endif @@ -629,7 +620,7 @@ bool BotPhraseManager::Initialize(const char *filename, int bankIndex) BotSpeakableVector *speakables = phrase->m_voiceBank[ bankIndex ]; speakables->push_back(speak); - ++phrase->m_count[ bankIndex ]; + phrase->m_count[ bankIndex ]++; } if (isDefault) @@ -652,12 +643,11 @@ bool BotPhraseManager::Initialize(const char *filename, int bankIndex) BotPhraseManager::~BotPhraseManager() { - BotPhraseList::iterator iter; - for (iter = m_list.begin(); iter != m_list.end(); ++iter) - delete (*iter); + for (auto phrase : m_list) + delete phrase; - for (iter = m_placeList.begin(); iter != m_placeList.end(); ++iter) - delete (*iter); + for (auto phrase : m_placeList) + delete phrase; m_list.clear(); m_placeList.clear(); @@ -665,125 +655,107 @@ BotPhraseManager::~BotPhraseManager() Place BotPhraseManager::NameToID(const char *name) const { - for (BotPhraseList::const_iterator iter = m_placeList.begin(); iter != m_placeList.end(); ++iter) + for (auto phrase : m_placeList) { - const BotPhrase *phrase = (*iter); - if (!Q_stricmp(phrase->m_name, name)) return phrase->m_id; } - for (BotPhraseList::const_iterator iter = m_list.begin(); iter != m_list.end(); ++iter) + for (auto phrase : m_list) { - const BotPhrase *phrase = (*iter); - if (!Q_stricmp(phrase->m_name, name)) return phrase->m_id; } - return 0; + return UNDEFINED_PLACE; } const char *BotPhraseManager::IDToName(Place id) const { - for (BotPhraseList::const_iterator iter = m_placeList.begin(); iter != m_placeList.end(); ++iter) + for (auto phrase : m_placeList) { - const BotPhrase *phrase = (*iter); - if (phrase->m_id == id) return phrase->m_name; } - for (BotPhraseList::const_iterator iter = m_list.begin(); iter != m_list.end(); ++iter) + for (auto phrase : m_list) { - const BotPhrase *phrase = (*iter); - if (phrase->m_id == id) return phrase->m_name; } - return NULL; + return nullptr; } // Given a name, return the associated phrase collection const BotPhrase *BotPhraseManager::GetPhrase(const char *name) const { - for (BotPhraseList::const_iterator iter = m_list.begin(); iter != m_list.end(); ++iter) + for (auto phrase : m_list) { - const BotPhrase *phrase = (*iter); - if (!Q_stricmp(phrase->m_name, name)) return phrase; } //CONSOLE_ECHO("GetPhrase: ERROR - Invalid phrase '%s'\n", name); - return NULL; + return nullptr; } -/* // Given an id, return the associated phrase collection // TODO: Store phrases in a vector to make this fast const BotPhrase *BotPhraseManager::GetPhrase(unsigned int id) const { - for (BotPhraseList::const_iterator iter = m_list.begin(); iter != m_list.end(); ++iter) + for (auto phrase : m_list) { - const BotPhrase *phrase = (*iter); - if (phrase->m_id == id) return phrase; } CONSOLE_ECHO("GetPhrase: ERROR - Invalid phrase id #%d\n", id); - return NULL; + return nullptr; } -*/ // Given a name, return the associated Place phrase collection const BotPhrase *BotPhraseManager::GetPlace(const char *name) const { - if (name == NULL) - return NULL; + if (!name) + return nullptr; - for (BotPhraseList::const_iterator iter = m_placeList.begin(); iter != m_placeList.end(); ++iter) + for (auto phrase : m_placeList) { - const BotPhrase *phrase = (*iter); - if (!Q_stricmp(phrase->m_name, name)) return phrase; } - return NULL; + return nullptr; } // Given a place, return the associated Place phrase collection const BotPhrase *BotPhraseManager::GetPlace(PlaceCriteria place) const { if (place == UNDEFINED_PLACE) - return NULL; + return nullptr; - for (BotPhraseList::const_iterator iter = m_placeList.begin(); iter != m_placeList.end(); ++iter) + for (auto phrase : m_placeList) { - const BotPhrase *phrase = (*iter); - if (phrase->m_id == place) return phrase; } - return NULL; + return nullptr; } BotStatement::BotStatement(BotChatterInterface *chatter, BotStatementType type, float expireDuration) { m_chatter = chatter; - m_prev = m_next = NULL; + m_prev = m_next = nullptr; m_timestamp = gpGlobals->time; m_speakTimestamp = 0.0f; m_type = type; m_subject = UNDEFINED_SUBJECT; m_place = UNDEFINED_PLACE; - m_meme = NULL; + m_meme = nullptr; m_startTime = gpGlobals->time; m_expireTime = gpGlobals->time + expireDuration; @@ -801,7 +773,7 @@ BotStatement::~BotStatement() if (m_meme) { delete m_meme; - m_meme = NULL; + m_meme = nullptr; } } @@ -827,7 +799,7 @@ void BotStatement::AddCondition(ConditionType condition) bool BotStatement::IsImportant() const { // if a statement contains any important phrases, it is important - for (int i = 0; i < m_count; ++i) + for (int i = 0; i < m_count; i++) { if (m_statement[i].isPhrase && m_statement[i].phrase->IsImportant()) return true; @@ -843,7 +815,7 @@ bool BotStatement::IsImportant() const // Verify all attached conditions bool BotStatement::IsValid() const { - for (int i = 0; i < m_conditionCount; ++i) + for (int i = 0; i < m_conditionCount; i++) { switch (m_condition[i]) { @@ -961,7 +933,7 @@ void BotStatement::Convert(const BotStatement *say) void BotStatement::AppendPhrase(const BotPhrase *phrase) { - if (phrase == NULL) + if (!phrase) return; if (m_count < MAX_BOT_PHRASES) @@ -1025,7 +997,7 @@ bool BotStatement::Update() // start next part of statement float duration = 0.0f; - const BotPhrase *phrase = NULL; + const BotPhrase *phrase = nullptr; if (m_statement[ m_index ].isPhrase) { @@ -1071,7 +1043,7 @@ bool BotStatement::Update() // dont report if there are lots of enemies left if (enemyCount < 0 || enemyCount > 3) { - phrase = NULL; + phrase = nullptr; } else { @@ -1144,7 +1116,7 @@ bool BotStatement::Update() if (sayIt) { - if (filename == NULL) + if (!filename) { GameEventType radioEvent = phrase->GetRadioEquivalent(); if (radioEvent == EVENT_INVALID) @@ -1161,7 +1133,7 @@ bool BotStatement::Update() } else { - me->Radio(filename, NULL, me->GetProfile()->GetVoicePitch(), false); + me->Radio(filename, nullptr, me->GetProfile()->GetVoicePitch(), false); me->GetChatter()->ResetRadioSilenceDuration(); me->StartVoiceFeedback(duration + 1.0f); } @@ -1190,7 +1162,7 @@ Place BotStatement::GetPlace() const return m_place; // look for an implicit place in our statement - for (int i = 0; i < m_count; ++i) + for (int i = 0; i < m_count; i++) { if (m_statement[i].isPhrase && m_statement[i].phrase->IsPlace()) return m_statement[i].phrase->GetID(); @@ -1202,7 +1174,7 @@ Place BotStatement::GetPlace() const // Return true if this statement has an associated count bool BotStatement::HasCount() const { - for (int i = 0; i < m_count; ++i) + for (int i = 0; i < m_count; i++) { if (!m_statement[i].isPhrase && m_statement[i].context == CURRENT_ENEMY_COUNT) return true; @@ -1218,7 +1190,7 @@ static int nextPitch = P_HI; BotChatterInterface::BotChatterInterface(CCSBot *me) { m_me = me; - m_statementList = NULL; + m_statementList = nullptr; switch (nextPitch) { @@ -1325,10 +1297,10 @@ void BotChatterInterface::AddStatement(BotStatement *statement, bool mustAdd) // keep statements in order of start time // check list is empty - if (m_statementList == NULL) + if (!m_statementList) { - statement->m_next = NULL; - statement->m_prev = NULL; + statement->m_next = nullptr; + statement->m_prev = nullptr; m_statementList = statement; return; } @@ -1336,7 +1308,7 @@ void BotChatterInterface::AddStatement(BotStatement *statement, bool mustAdd) // list has at least one statement on it // insert into list in order - BotStatement *earlier = NULL; + BotStatement *earlier = nullptr; for (s = m_statementList; s; s = s->m_next) { if (s->GetStartTime() > statement->GetStartTime()) @@ -1359,7 +1331,7 @@ void BotChatterInterface::AddStatement(BotStatement *statement, bool mustAdd) else { // insert at head - statement->m_prev = NULL; + statement->m_prev = nullptr; statement->m_next = m_statementList; m_statementList->m_prev = statement; m_statementList = statement; @@ -1430,7 +1402,7 @@ void BotChatterInterface::OnDeath() if (pain) { - m_me->Radio(pain->GetSpeakable(m_me->GetProfile()->GetVoiceBank()), NULL, m_me->GetProfile()->GetVoicePitch()); + m_me->Radio(pain->GetSpeakable(m_me->GetProfile()->GetVoiceBank()), nullptr, m_me->GetProfile()->GetVoicePitch()); m_me->GetChatter()->ResetRadioSilenceDuration(); } } @@ -1476,7 +1448,7 @@ void BotChatterInterface::Update() // Remove redundant statements (ie: our teammates already said them) const BotStatement *friendSay = GetActiveStatement(); if (friendSay && friendSay->GetOwner() == m_me) - friendSay = NULL; + friendSay = nullptr; BotStatement *nextSay; for (say = m_statementList; say; say = nextSay) @@ -1526,7 +1498,7 @@ BotStatement *BotChatterInterface::GetActiveStatement() BotStatement *earliest = nullptr; float earlyTime = 999999999.9f; - for (int i = 1; i <= gpGlobals->maxClients; ++i) + for (int i = 1; i <= gpGlobals->maxClients; i++) { CBasePlayer *player = UTIL_PlayerByIndex(i); @@ -2027,7 +1999,7 @@ void BotChatterInterface::RequestBombLocation() void BotChatterInterface::BombsiteClear(int zoneIndex) { const CCSBotManager::Zone *zone = TheCSBots()->GetZone(zoneIndex); - if (zone == NULL) + if (!zone) return; BotStatement *say = new BotStatement(this, REPORT_INFORMATION, 10.0f); @@ -2041,7 +2013,7 @@ void BotChatterInterface::BombsiteClear(int zoneIndex) void BotChatterInterface::FoundPlantedBomb(int zoneIndex) { const CCSBotManager::Zone *zone = TheCSBots()->GetZone(zoneIndex); - if (zone == NULL) + if (!zone) return; BotStatement *say = new BotStatement(this, REPORT_INFORMATION, 3.0f); diff --git a/regamedll/dlls/bot/cs_bot_chatter.h b/regamedll/dlls/bot/cs_bot_chatter.h index 3ee1347d..e4aa6894 100644 --- a/regamedll/dlls/bot/cs_bot_chatter.h +++ b/regamedll/dlls/bot/cs_bot_chatter.h @@ -26,11 +26,7 @@ * */ -#ifndef CS_BOT_CHATTER_H -#define CS_BOT_CHATTER_H -#ifdef _WIN32 #pragma once -#endif #define UNDEFINED_COUNT 0xFFFF #define MAX_PLACES_PER_MAP 64 @@ -262,6 +258,9 @@ public: // given a name, return the associated phrase collection const BotPhrase *GetPhrase(const char *name) const; + // given an id, return the associated phrase collection + const BotPhrase *GetPhrase(unsigned int id) const; + // given a name, return the associated Place phrase collection const BotPhrase *GetPlace(const char *name) const; @@ -585,7 +584,6 @@ inline BotStatement *BotChatterInterface::GetStatement() const } extern BotPhraseManager *TheBotPhrases; -extern CBaseEntity *g_pSelectedZombieSpawn; inline void BotChatterInterface::Say(const char *phraseName, float lifetime, float delay) { @@ -600,5 +598,3 @@ inline void BotChatterInterface::Say(const char *phraseName, float lifetime, flo } const Vector *GetRandomSpotAtPlace(Place place); - -#endif // CS_BOT_CHATTER_H diff --git a/regamedll/dlls/bot/cs_bot_event.cpp b/regamedll/dlls/bot/cs_bot_event.cpp index 9d6f4ad9..50396884 100644 --- a/regamedll/dlls/bot/cs_bot_event.cpp +++ b/regamedll/dlls/bot/cs_bot_event.cpp @@ -33,7 +33,7 @@ void CCSBot::OnEvent(GameEventType event, CBaseEntity *entity, CBaseEntity *othe if (!IsAlive()) return; - CBasePlayer *player = static_cast(entity); + CBasePlayer *pPlayer = static_cast(entity); // If we just saw a nearby friend die, and we haven't yet acquired an enemy // automatically acquire our dead friend's killer @@ -41,16 +41,16 @@ void CCSBot::OnEvent(GameEventType event, CBaseEntity *entity, CBaseEntity *othe { if (event == EVENT_PLAYER_DIED) { - if (BotRelationship(player) == BOT_TEAMMATE) + if (BotRelationship(pPlayer) == BOT_TEAMMATE) { - CBasePlayer *killer = static_cast(other); + CBasePlayer *pKiller = static_cast(other); // check that attacker is an enemy (for friendly fire, etc) - if (killer != NULL && killer->IsPlayer()) + if (pKiller && pKiller->IsPlayer()) { // check if we saw our friend die - dont check FOV - assume we're aware of our surroundings in combat // snipers stay put - if (!IsSniper() && IsVisible(&player->pev->origin)) + if (!IsSniper() && IsVisible(&pPlayer->pev->origin)) { // people are dying - we should hurry Hurry(RANDOM_FLOAT(10.0f, 15.0f)); @@ -60,7 +60,7 @@ void CCSBot::OnEvent(GameEventType event, CBaseEntity *entity, CBaseEntity *othe if (!IsHiding() || !IsUsingKnife() || RANDOM_FLOAT(0, 100) < knifeAmbushChance) { PrintIfWatched("Attacking our friend's killer!\n"); - Attack(killer); + Attack(pKiller); return; } } @@ -73,26 +73,26 @@ void CCSBot::OnEvent(GameEventType event, CBaseEntity *entity, CBaseEntity *othe { case EVENT_PLAYER_DIED: { - CBasePlayer *victim = player; - CBasePlayer *killer = (other != NULL && other->IsPlayer()) ? static_cast(other) : NULL; + CBasePlayer *pVictim = pPlayer; + CBasePlayer *pKiller = (other && other->IsPlayer()) ? static_cast(other) : nullptr; // if the human player died in the single player game, tell the team - if (CSGameRules()->IsCareer() && !victim->IsBot() && BotRelationship(victim) == BOT_TEAMMATE) + if (CSGameRules()->IsCareer() && !pVictim->IsBot() && BotRelationship(pVictim) == BOT_TEAMMATE) { GetChatter()->Say("CommanderDown", 20.0f); } // keep track of the last player we killed - if (killer == this) + if (pKiller == this) { - m_lastVictimID = victim->entindex(); + m_lastVictimID = pVictim->entindex(); } // react to teammate death - if (BotRelationship(victim) == BOT_TEAMMATE) + if (BotRelationship(pVictim) == BOT_TEAMMATE) { // chastise friendly fire from humans - if (killer != NULL && !killer->IsBot() && BotRelationship(killer) == BOT_TEAMMATE && killer != this) + if (pKiller && !pKiller->IsBot() && BotRelationship(pKiller) == BOT_TEAMMATE && pKiller != this) { GetChatter()->KilledFriend(); } @@ -124,7 +124,7 @@ void CCSBot::OnEvent(GameEventType event, CBaseEntity *entity, CBaseEntity *othe // an enemy was killed else { - if (killer != NULL && BotRelationship(killer) == BOT_TEAMMATE) + if (pKiller && BotRelationship(pKiller) == BOT_TEAMMATE) { // only chatter about enemy kills if we see them occur, and they were the last one we see if (GetNearbyEnemyCount() <= 1) @@ -132,13 +132,13 @@ void CCSBot::OnEvent(GameEventType event, CBaseEntity *entity, CBaseEntity *othe // report if number of enemies left is few and we killed the last one we saw locally GetChatter()->EnemiesRemaining(); - if (IsVisible(&victim->pev->origin, CHECK_FOV)) + if (IsVisible(&pVictim->pev->origin, CHECK_FOV)) { // congratulate teammates on their kills - if (killer != this) + if (pKiller != this) { float delay = RANDOM_FLOAT(2.0f, 3.0f); - if (killer->IsBot()) + if (pKiller->IsBot()) { if (RANDOM_FLOAT(0.0f, 100.0f) < 40.0f) GetChatter()->Say("NiceShot", 3.0f, delay); @@ -172,11 +172,11 @@ void CCSBot::OnEvent(GameEventType event, CBaseEntity *entity, CBaseEntity *othe return; case EVENT_BOMB_PICKED_UP: { - if (m_iTeam == CT && player != NULL) + if (m_iTeam == CT && pPlayer) { // check if we're close enough to hear it const float bombPickupHearRangeSq = 1000.0f * 1000.0f; - if ((pev->origin - player->pev->origin).LengthSquared() < bombPickupHearRangeSq) + if ((pev->origin - pPlayer->pev->origin).LengthSquared() < bombPickupHearRangeSq) { GetChatter()->TheyPickedUpTheBomb(); } @@ -196,8 +196,10 @@ void CCSBot::OnEvent(GameEventType event, CBaseEntity *entity, CBaseEntity *othe if (m_iTeam == CT && GetGameState()->GetPlantedBombsite() == CSGameState::UNKNOWN) { const CCSBotManager::Zone *zone = TheCSBots()->GetZone(&entity->pev->origin); - if (zone != NULL) + if (zone) + { GetChatter()->FoundPlantedBomb(zone->m_index); + } } // remember where the bomb is @@ -240,20 +242,20 @@ void CCSBot::OnEvent(GameEventType event, CBaseEntity *entity, CBaseEntity *othe } // Process radio events from our team - if (player != NULL && BotRelationship(player) == BOT_TEAMMATE && event > EVENT_START_RADIO_1 && event < EVENT_END_RADIO) + if (pPlayer && BotRelationship(pPlayer) == BOT_TEAMMATE && event > EVENT_START_RADIO_1 && event < EVENT_END_RADIO) { // TODO: Distinguish between radio commands and responses if (event != EVENT_RADIO_AFFIRMATIVE && event != EVENT_RADIO_NEGATIVE && event != EVENT_RADIO_REPORTING_IN) { m_lastRadioCommand = event; m_lastRadioRecievedTimestamp = gpGlobals->time; - m_radioSubject = player; - m_radioPosition = player->pev->origin; + m_radioSubject = pPlayer; + m_radioPosition = pPlayer->pev->origin; } } // player_follows needs a player - if (player == NULL) + if (!pPlayer) return; if (!IsRogue() && event == EVENT_HOSTAGE_CALLED_FOR_HELP && m_iTeam == CT && IsHunting()) @@ -264,7 +266,7 @@ void CCSBot::OnEvent(GameEventType event, CBaseEntity *entity, CBaseEntity *othe if (IsVisible(&entity->Center())) { m_task = COLLECT_HOSTAGES; - m_taskEntity = NULL; + m_taskEntity = nullptr; Run(); m_goalEntity = entity; @@ -277,7 +279,7 @@ void CCSBot::OnEvent(GameEventType event, CBaseEntity *entity, CBaseEntity *othe } // don't pay attention to noise that friends make - if (!IsEnemy(player)) + if (!IsEnemy(pPlayer)) return; float range; @@ -300,7 +302,7 @@ void CCSBot::OnEvent(GameEventType event, CBaseEntity *entity, CBaseEntity *othe if (!GetGameState()->GetNearestVisibleFreeHostage() && m_task != GUARD_HOSTAGE_RESCUE_ZONE && GuardRandomZone()) { m_task = GUARD_HOSTAGE_RESCUE_ZONE; - m_taskEntity = NULL; + m_taskEntity = nullptr; SetDisposition(OPPORTUNITY_FIRE); PrintIfWatched("Trying to beat them to an escape zone!\n"); @@ -308,7 +310,7 @@ void CCSBot::OnEvent(GameEventType event, CBaseEntity *entity, CBaseEntity *othe } // check if noise is close enough for us to hear - const Vector *newNoisePosition = &player->pev->origin; + const Vector *newNoisePosition = &pPlayer->pev->origin; float newNoiseDist = (pev->origin - *newNoisePosition).Length(); if (newNoiseDist < range) { @@ -317,7 +319,7 @@ void CCSBot::OnEvent(GameEventType event, CBaseEntity *entity, CBaseEntity *othe { PrintIfWatched("Heard noise (%s from %s, pri %s, time %3.1f)\n", (event == EVENT_WEAPON_FIRED) ? "Weapon fire " : "", - STRING(player->pev->netname), + STRING(pPlayer->pev->netname), (priority == PRIORITY_HIGH) ? "HIGH" : ((priority == PRIORITY_MEDIUM) ? "MEDIUM" : "LOW"), gpGlobals->time); } @@ -343,16 +345,15 @@ void CCSBot::OnEvent(GameEventType event, CBaseEntity *entity, CBaseEntity *othe } } - // find the area in which the noise occured // TODO: Better handle when noise occurs off the nav mesh // TODO: Make sure noise area is not through a wall or ceiling from source of noise // TODO: Change GetNavTravelTime to better deal with NULL destination areas CNavArea *noiseArea = TheNavAreaGrid.GetNavArea(newNoisePosition); - if (noiseArea == NULL) + if (!noiseArea) noiseArea = TheNavAreaGrid.GetNearestNavArea(newNoisePosition); - if (noiseArea == NULL) + if (!noiseArea) { PrintIfWatched(" *** Noise occurred off the nav mesh - ignoring!\n"); return; @@ -377,6 +378,7 @@ void CCSBot::OnEvent(GameEventType event, CBaseEntity *entity, CBaseEntity *othe m_noiseArea->GetClosestPointOnArea(&m_noisePosition, &m_noisePosition); m_isNoiseTravelRangeChecked = false; + // note when we heard the noise m_noiseTimestamp = gpGlobals->time; } diff --git a/regamedll/dlls/bot/cs_bot_init.cpp b/regamedll/dlls/bot/cs_bot_init.cpp index 7ece1b9d..d7185973 100644 --- a/regamedll/dlls/bot/cs_bot_init.cpp +++ b/regamedll/dlls/bot/cs_bot_init.cpp @@ -5,46 +5,46 @@ */ #ifndef HOOK_GAMEDLL -cvar_t cv_bot_traceview = { "bot_traceview", "0", FCVAR_SERVER, 0.0f, NULL }; -cvar_t cv_bot_stop = { "bot_stop", "0", FCVAR_SERVER, 0.0f, NULL }; -cvar_t cv_bot_show_nav = { "bot_show_nav", "0", FCVAR_SERVER, 0.0f, NULL }; -cvar_t cv_bot_show_danger = { "bot_show_danger", "0", FCVAR_SERVER, 0.0f, NULL }; -cvar_t cv_bot_nav_edit = { "bot_nav_edit", "0", FCVAR_SERVER, 0.0f, NULL }; -cvar_t cv_bot_nav_zdraw = { "bot_nav_zdraw", "4", FCVAR_SERVER, 0.0f, NULL }; -cvar_t cv_bot_walk = { "bot_walk", "0", FCVAR_SERVER, 0.0f, NULL }; -cvar_t cv_bot_difficulty = { "bot_difficulty", "0", FCVAR_SERVER, 0.0f, NULL }; -cvar_t cv_bot_debug = { "bot_debug", "0", FCVAR_SERVER, 0.0f, NULL }; -cvar_t cv_bot_quicksave = { "bot_quicksave", "0", FCVAR_SERVER, 0.0f, NULL }; -cvar_t cv_bot_quota = { "bot_quota", "0", FCVAR_SERVER, 0.0f, NULL }; -cvar_t cv_bot_quota_match = { "bot_quota_match", "0", FCVAR_SERVER, 0.0f, NULL }; -cvar_t cv_bot_prefix = { "bot_prefix", "", FCVAR_SERVER, 0.0f, NULL }; -cvar_t cv_bot_allow_rogues = { "bot_allow_rogues", "1", FCVAR_SERVER, 0.0f, NULL }; -cvar_t cv_bot_allow_pistols = { "bot_allow_pistols", "1", FCVAR_SERVER, 0.0f, NULL }; -cvar_t cv_bot_allow_shotguns = { "bot_allow_shotguns", "1", FCVAR_SERVER, 0.0f, NULL }; -cvar_t cv_bot_allow_sub_machine_guns = { "bot_allow_sub_machine_guns", "1", FCVAR_SERVER, 0.0f, NULL }; -cvar_t cv_bot_allow_rifles = { "bot_allow_rifles", "1", FCVAR_SERVER, 0.0f, NULL }; -cvar_t cv_bot_allow_machine_guns = { "bot_allow_machine_guns", "1", FCVAR_SERVER, 0.0f, NULL }; -cvar_t cv_bot_allow_grenades = { "bot_allow_grenades", "1", FCVAR_SERVER, 0.0f, NULL }; -cvar_t cv_bot_allow_snipers = { "bot_allow_snipers", "1", FCVAR_SERVER, 0.0f, NULL }; -cvar_t cv_bot_allow_shield = { "bot_allow_shield", "1", FCVAR_SERVER, 0.0f, NULL }; -cvar_t cv_bot_join_team = { "bot_join_team", "any", FCVAR_SERVER, 0.0f, NULL }; -cvar_t cv_bot_join_after_player = { "bot_join_after_player", "1", FCVAR_SERVER, 0.0f, NULL }; -cvar_t cv_bot_auto_vacate = { "bot_auto_vacate", "1", FCVAR_SERVER, 0.0f, NULL }; -cvar_t cv_bot_zombie = { "bot_zombie", "0", FCVAR_SERVER, 0.0f, NULL }; -cvar_t cv_bot_defer_to_human = { "bot_defer_to_human", "0", FCVAR_SERVER, 0.0f, NULL }; -cvar_t cv_bot_chatter = { "bot_chatter", "normal", FCVAR_SERVER, 0.0f, NULL }; -cvar_t cv_bot_profile_db = { "bot_profile_db", "BotProfile.db", FCVAR_SERVER, 0.0f, NULL }; +cvar_t cv_bot_traceview = { "bot_traceview", "0", FCVAR_SERVER, 0.0f, nullptr }; +cvar_t cv_bot_stop = { "bot_stop", "0", FCVAR_SERVER, 0.0f, nullptr }; +cvar_t cv_bot_show_nav = { "bot_show_nav", "0", FCVAR_SERVER, 0.0f, nullptr }; +cvar_t cv_bot_show_danger = { "bot_show_danger", "0", FCVAR_SERVER, 0.0f, nullptr }; +cvar_t cv_bot_nav_edit = { "bot_nav_edit", "0", FCVAR_SERVER, 0.0f, nullptr }; +cvar_t cv_bot_nav_zdraw = { "bot_nav_zdraw", "4", FCVAR_SERVER, 0.0f, nullptr }; +cvar_t cv_bot_walk = { "bot_walk", "0", FCVAR_SERVER, 0.0f, nullptr }; +cvar_t cv_bot_difficulty = { "bot_difficulty", "0", FCVAR_SERVER, 0.0f, nullptr }; +cvar_t cv_bot_debug = { "bot_debug", "0", FCVAR_SERVER, 0.0f, nullptr }; +cvar_t cv_bot_quicksave = { "bot_quicksave", "0", FCVAR_SERVER, 0.0f, nullptr }; +cvar_t cv_bot_quota = { "bot_quota", "0", FCVAR_SERVER, 0.0f, nullptr }; +cvar_t cv_bot_quota_match = { "bot_quota_match", "0", FCVAR_SERVER, 0.0f, nullptr }; +cvar_t cv_bot_prefix = { "bot_prefix", "", FCVAR_SERVER, 0.0f, nullptr }; +cvar_t cv_bot_allow_rogues = { "bot_allow_rogues", "1", FCVAR_SERVER, 0.0f, nullptr }; +cvar_t cv_bot_allow_pistols = { "bot_allow_pistols", "1", FCVAR_SERVER, 0.0f, nullptr }; +cvar_t cv_bot_allow_shotguns = { "bot_allow_shotguns", "1", FCVAR_SERVER, 0.0f, nullptr }; +cvar_t cv_bot_allow_sub_machine_guns = { "bot_allow_sub_machine_guns", "1", FCVAR_SERVER, 0.0f, nullptr }; +cvar_t cv_bot_allow_rifles = { "bot_allow_rifles", "1", FCVAR_SERVER, 0.0f, nullptr }; +cvar_t cv_bot_allow_machine_guns = { "bot_allow_machine_guns", "1", FCVAR_SERVER, 0.0f, nullptr }; +cvar_t cv_bot_allow_grenades = { "bot_allow_grenades", "1", FCVAR_SERVER, 0.0f, nullptr }; +cvar_t cv_bot_allow_snipers = { "bot_allow_snipers", "1", FCVAR_SERVER, 0.0f, nullptr }; +cvar_t cv_bot_allow_shield = { "bot_allow_shield", "1", FCVAR_SERVER, 0.0f, nullptr }; +cvar_t cv_bot_join_team = { "bot_join_team", "any", FCVAR_SERVER, 0.0f, nullptr }; +cvar_t cv_bot_join_after_player = { "bot_join_after_player", "1", FCVAR_SERVER, 0.0f, nullptr }; +cvar_t cv_bot_auto_vacate = { "bot_auto_vacate", "1", FCVAR_SERVER, 0.0f, nullptr }; +cvar_t cv_bot_zombie = { "bot_zombie", "0", FCVAR_SERVER, 0.0f, nullptr }; +cvar_t cv_bot_defer_to_human = { "bot_defer_to_human", "0", FCVAR_SERVER, 0.0f, nullptr }; +cvar_t cv_bot_chatter = { "bot_chatter", "normal", FCVAR_SERVER, 0.0f, nullptr }; +cvar_t cv_bot_profile_db = { "bot_profile_db", "BotProfile.db", FCVAR_SERVER, 0.0f, nullptr }; #endif #ifdef REGAMEDLL_ADD -cvar_t cv_bot_deathmatch = { "bot_deathmatch", "0", FCVAR_SERVER, 0.0f, NULL }; -cvar_t cv_bot_quota_mode = { "bot_quota_mode", "normal", FCVAR_SERVER, 0.0f, NULL }; +cvar_t cv_bot_deathmatch = { "bot_deathmatch", "0", FCVAR_SERVER, 0.0f, nullptr }; +cvar_t cv_bot_quota_mode = { "bot_quota_mode", "normal", FCVAR_SERVER, 0.0f, nullptr }; #endif void InstallBotControl() { - if (TheBots != NULL) + if (TheBots) { delete TheBots; } @@ -55,7 +55,7 @@ void InstallBotControl() // Engine callback for custom server commands void Bot_ServerCommand() { - if (TheBots != NULL) + if (TheBots) { const char *pcmd = CMD_ARGV(0); TheBots->ServerCommand(pcmd); @@ -122,8 +122,8 @@ bool CCSBot::Initialize(const BotProfile *profile) m_combatRange = RANDOM_FLOAT(325, 425); - m_navNodeList = NULL; - m_currentNode = NULL; + m_navNodeList = nullptr; + m_currentNode = nullptr; // set initial safe time guess for this map m_safeTime = 15.0f + 5.0f * GetProfile()->GetAggression(); @@ -142,7 +142,7 @@ void CCSBot::ResetValues() m_chatter.Reset(); m_gameState.Reset(); - m_avoid = NULL; + m_avoid = nullptr; m_avoidTimestamp = 0.0f; m_hurryTimer.Invalidate(); @@ -155,8 +155,8 @@ void CCSBot::ResetValues() m_pathLength = 0; m_pathIndex = 0; m_areaEnteredTimestamp = 0.0f; - m_currentArea = NULL; - m_lastKnownArea = NULL; + m_currentArea = nullptr; + m_lastKnownArea = nullptr; m_avoidFriendTimer.Invalidate(); m_isFriendInTheWay = false; @@ -164,7 +164,7 @@ void CCSBot::ResetValues() m_disposition = ENGAGE_AND_INVESTIGATE; - m_enemy = NULL; + m_enemy = nullptr; m_isWaitingToTossGrenade = false; m_wasSafe = true; @@ -172,10 +172,10 @@ void CCSBot::ResetValues() m_nearbyEnemyCount = 0; m_enemyPlace = 0; m_nearbyFriendCount = 0; - m_closestVisibleFriend = NULL; - m_closestVisibleHumanFriend = NULL; + m_closestVisibleFriend = nullptr; + m_closestVisibleHumanFriend = nullptr; - for (int w = 0; w < ARRAYSIZE(m_watchInfo); ++w) + for (int w = 0; w < ARRAYSIZE(m_watchInfo); w++) { m_watchInfo[w].timestamp = 0.0f; m_watchInfo[w].isEnemy = false; @@ -187,7 +187,7 @@ void CCSBot::ResetValues() m_firstSawEnemyTimestamp = 0.0f; m_currentEnemyAcquireTimestamp = 0.0f; m_isLastEnemyDead = true; - m_attacker = NULL; + m_attacker = nullptr; m_attackedTimestamp = 0.0f; m_enemyDeathTimestamp = 0.0f; m_lastVictimID = 0; @@ -196,14 +196,14 @@ void CCSBot::ResetValues() m_equipTimer.Invalidate(); m_isFollowing = false; - m_leader = NULL; + m_leader = nullptr; m_followTimestamp = 0.0f; m_allowAutoFollowTime = 0.0f; m_enemyQueueIndex = 0; m_enemyQueueCount = 0; m_enemyQueueAttendIndex = 0; - m_bomber = NULL; + m_bomber = nullptr; m_lookAroundStateTimestamp = 0.0f; m_inhibitLookAroundTimestamp = 0.0f; @@ -217,19 +217,19 @@ void CCSBot::ResetValues() m_aimSpreadTimestamp = 0.0f; m_lookAtSpotState = NOT_LOOKING_AT_SPOT; - m_spotEncounter = NULL; + m_spotEncounter = nullptr; m_spotCheckTimestamp = 0.0f; m_peripheralTimestamp = 0.0f; m_avgVelIndex = 0; m_avgVelCount = 0; - m_lastOrigin = (pev != NULL) ? pev->origin : Vector(0, 0, 0); + m_lastOrigin = pev ? pev->origin : Vector(0, 0, 0); m_lastRadioCommand = EVENT_INVALID; m_lastRadioRecievedTimestamp = 0.0f; m_lastRadioSentTimestamp = 0.0f; - m_radioSubject = NULL; + m_radioSubject = nullptr; m_voiceFeedbackEndTimestamp = 0.0f; m_hostageEscortCount = 0; @@ -242,7 +242,7 @@ void CCSBot::ResetValues() m_stateTimestamp = 0.0f; m_task = SEEK_AND_DESTROY; - m_taskEntity = NULL; + m_taskEntity = nullptr; m_approachPointCount = 0; m_approachPointViewPosition = Vector(0, 0, 0); @@ -254,7 +254,7 @@ void CCSBot::ResetValues() Run(); m_mustRunTimer.Invalidate(); m_repathTimer.Invalidate(); - m_pathLadder = NULL; + m_pathLadder = nullptr; m_huntState.ClearHuntArea(); @@ -272,14 +272,14 @@ void CCSBot::ResetValues() m_surpriseTimestamp = 0.0f; // even though these are EHANDLEs, they need to be NULL-ed - m_goalEntity = NULL; - m_avoid = NULL; - m_enemy = NULL; + m_goalEntity = nullptr; + m_avoid = nullptr; + m_enemy = nullptr; #ifdef REGAMEDLL_FIXES - for (int i = 0; i < MAX_ENEMY_QUEUE; ++i) + for (int i = 0; i < MAX_ENEMY_QUEUE; i++) { - m_enemyQueue[i].player = NULL; + m_enemyQueue[i].player = nullptr; m_enemyQueue[i].isReloading = false; m_enemyQueue[i].isProtectedByShield = false; } diff --git a/regamedll/dlls/bot/cs_bot_learn.cpp b/regamedll/dlls/bot/cs_bot_learn.cpp index 36981e96..82e8e311 100644 --- a/regamedll/dlls/bot/cs_bot_learn.cpp +++ b/regamedll/dlls/bot/cs_bot_learn.cpp @@ -42,13 +42,13 @@ inline CNavNode *LadderEndSearch(CBaseEntity *entity, const Vector *pos, NavDirT continue; // if no node exists here, create one and continue the search - if (CNavNode::GetNode(&tryPos) == NULL) + if (!CNavNode::GetNode(&tryPos)) { - return new CNavNode(&tryPos, &tryNormal, NULL); + return new CNavNode(&tryPos, &tryNormal, nullptr); } } - return NULL; + return nullptr; } CNavNode *CCSBot::AddNode(const Vector *destPos, const Vector *normal, NavDirType dir, CNavNode *source) @@ -58,7 +58,7 @@ CNavNode *CCSBot::AddNode(const Vector *destPos, const Vector *normal, NavDirTyp // if no node exists, create one bool useNew = false; - if (node == NULL) + if (!node) { node = new CNavNode(destPos, normal, source); useNew = true; @@ -118,7 +118,7 @@ CNavNode *CCSBot::AddNode(const Vector *destPos, const Vector *normal, NavDirTyp void drawProgressMeter(float progress, char *title) { MESSAGE_BEGIN(MSG_ALL, gmsgBotProgress); - WRITE_BYTE(FLAG_PROGRESS_DRAW); + WRITE_BYTE(BOT_PROGGRESS_DRAW); WRITE_BYTE(int(progress * 100.0f)); WRITE_STRING(title); MESSAGE_END(); @@ -127,7 +127,7 @@ void drawProgressMeter(float progress, char *title) void startProgressMeter(const char *title) { MESSAGE_BEGIN(MSG_ALL, gmsgBotProgress); - WRITE_BYTE(FLAG_PROGRESS_START); + WRITE_BYTE(BOT_PROGGRESS_START); WRITE_STRING(title); MESSAGE_END(); } @@ -135,7 +135,7 @@ void startProgressMeter(const char *title) void hideProgressMeter() { MESSAGE_BEGIN(MSG_ALL, gmsgBotProgress); - WRITE_BYTE(FLAG_PROGRESS_HIDE); + WRITE_BYTE(BOT_PROGGRESS_HIDE); MESSAGE_END(); } @@ -173,14 +173,11 @@ bool CCSBot::LearnStep() // take a step while (true) { - if (m_currentNode == NULL) + if (!m_currentNode) { // search is exhausted - continue search from ends of ladders - NavLadderList::iterator iter; - for (iter = TheNavLadderList.begin(); iter != TheNavLadderList.end(); ++iter) + for (auto ladder : TheNavLadderList) { - CNavLadder *ladder = (*iter); - // check ladder bottom if ((m_currentNode = LadderEndSearch(ladder->m_entity, &ladder->m_bottom, ladder->m_dir)) != 0) break; @@ -190,7 +187,7 @@ bool CCSBot::LearnStep() break; } - if (m_currentNode == NULL) + if (!m_currentNode) { // all seeds exhausted, sampling complete GenerateNavigationAreaMesh(); @@ -215,10 +212,10 @@ bool CCSBot::LearnStep() // attempt to move to adjacent node switch (dir) { - case NORTH: cy -= GenerationStepSize; break; - case SOUTH: cy += GenerationStepSize; break; - case EAST: cx += GenerationStepSize; break; - case WEST: cx -= GenerationStepSize; break; + case NORTH: cy -= GenerationStepSize; break; + case SOUTH: cy += GenerationStepSize; break; + case EAST: cx += GenerationStepSize; break; + case WEST: cx -= GenerationStepSize; break; } pos.x = cx; @@ -324,7 +321,7 @@ bool CCSBot::LearnStep() #ifdef REGAMEDLL_FIXES // if we're incrementally generating, don't overlap existing nav areas CNavArea *overlap = TheNavAreaGrid.GetNavArea(&to, HumanHeight); - if (overlap != NULL) + if (overlap) { walkable = false; } @@ -375,14 +372,14 @@ void CCSBot::StartAnalyzeAlphaProcess() bool CCSBot::AnalyzeAlphaStep() { - ++_currentIndex; + _currentIndex++; if (m_analyzeIter == TheNavAreaList.end()) return false; CNavArea *area = (*m_analyzeIter); area->ComputeHidingSpots(); area->ComputeApproachAreas(); - ++m_analyzeIter; + m_analyzeIter++; return true; } @@ -416,14 +413,14 @@ void CCSBot::StartAnalyzeBetaProcess() bool CCSBot::AnalyzeBetaStep() { - ++_currentIndex; + _currentIndex++; if (m_analyzeIter == TheNavAreaList.end()) return false; CNavArea *area = (*m_analyzeIter); area->ComputeSpotEncounters(); area->ComputeSniperSpots(); - ++m_analyzeIter; + m_analyzeIter++; return true; } @@ -473,7 +470,7 @@ void CCSBot::UpdateSaveProcess() #ifndef REGAMEDLL_FIXES Q_sprintf(cmd, "map %s\n", STRING(gpGlobals->mapname)); #else - Q_sprintf(cmd, "changelevel %s\n", STRING(gpGlobals->mapname)); + Q_snprintf(cmd, sizeof(cmd), "changelevel %s\n", STRING(gpGlobals->mapname)); #endif SERVER_COMMAND(cmd); diff --git a/regamedll/dlls/bot/cs_bot_listen.cpp b/regamedll/dlls/bot/cs_bot_listen.cpp index 3102b5b5..920c292f 100644 --- a/regamedll/dlls/bot/cs_bot_listen.cpp +++ b/regamedll/dlls/bot/cs_bot_listen.cpp @@ -88,7 +88,7 @@ bool CCSBot::CanHearNearbyEnemyGunfire(float range) const if (!CanSeeNoisePosition()) return false; - if (IsAttacking() && m_enemy != NULL) + if (IsAttacking() && m_enemy) { // gunfire is only threatening if it is closer than our current enemy float gunfireDistSq = (m_noisePosition - pev->origin).LengthSquared(); @@ -148,14 +148,13 @@ bool CCSBot::UpdateLookAtNoise() else { // line of sight is blocked, bend it - if (m_approachPointCount == 0) return false; int nearIdx = -1; float nearRangeSq = 9.9999998e10f; - for (int i = 0; i < m_approachPointCount; ++i) + for (int i = 0; i < m_approachPointCount; i++) { float distanceSq = (m_approachPoint[i] - m_noisePosition).LengthSquared(); diff --git a/regamedll/dlls/bot/cs_bot_manager.cpp b/regamedll/dlls/bot/cs_bot_manager.cpp index ddd5a63c..e4c3b1a6 100644 --- a/regamedll/dlls/bot/cs_bot_manager.cpp +++ b/regamedll/dlls/bot/cs_bot_manager.cpp @@ -5,7 +5,7 @@ */ #ifndef HOOK_GAMEDLL -CBotManager *TheBots = NULL; +CBotManager *TheBots = nullptr; float CCSBotManager::m_flNextCVarCheck = 0.0f; bool CCSBotManager::m_isMapDataLoaded = false; @@ -20,10 +20,10 @@ CCSBotManager::CCSBotManager() IMPL(m_flNextCVarCheck) = 0.0f; m_zoneCount = 0; - SetLooseBomb(NULL); + SetLooseBomb(nullptr); m_isBombPlanted = false; - m_bombDefuser = NULL; + m_bombDefuser = nullptr; IMPL(m_isLearningMap) = false; IMPL(m_isAnalysisRequested) = false; @@ -55,15 +55,14 @@ CCSBotManager::CCSBotManager() // read in the list of bot profile DBs int dataLength; char *dataPointer = (char *)LOAD_FILE_FOR_ME((char *)filename, &dataLength); - - if (dataPointer == NULL) + if (!dataPointer) { TheBotProfiles->Init("BotProfile.db"); } else { - const char *dataFile = SharedParse(dataPointer); - const char *token; + char *dataFile = SharedParse(dataPointer); + char *token; while (dataFile) { @@ -80,7 +79,7 @@ CCSBotManager::CCSBotManager() // Now that we've parsed all the profiles, we have a list of the voice banks they're using. // Go back and parse the custom voice speakables. const BotProfileManager::VoiceBankList *pVoiceBanks = TheBotProfiles->GetVoiceBanks(); - for (uint32 i = 1; i < pVoiceBanks->size(); ++i) + for (uint32 i = 1; i < pVoiceBanks->size(); i++) { TheBotPhrases->Initialize((*pVoiceBanks)[i], i); } @@ -92,10 +91,10 @@ void CCSBotManager::RestartRound() // extend CBotManager::RestartRound(); - SetLooseBomb(NULL); + SetLooseBomb(nullptr); m_isBombPlanted = false; m_earliestBombPlantTimestamp = gpGlobals->time + RANDOM_FLOAT(10.0f, 30.0f); - m_bombDefuser = NULL; + m_bombDefuser = nullptr; IMPL(m_editCmd) = EDIT_NONE; @@ -141,7 +140,7 @@ void UTIL_DrawBox(Extent *extent, int lifetime, int red, int green, int blue) Vector from, to; bool restart = true; - for (int i = 0; edge[i] != 0; ++i) + for (int i = 0; edge[i] != 0; i++) { if (restart) { @@ -177,7 +176,7 @@ void CCSBotManager::StartFrame() // debug zone extent visualization if (cv_bot_debug.value == 5.0f) { - for (int z = 0; z < m_zoneCount; ++z) + for (int z = 0; z < m_zoneCount; z++) { Zone *zone = &m_zone[z]; UTIL_DrawBox(&zone->m_extent, 1, 255, 100, 0); @@ -188,7 +187,7 @@ void CCSBotManager::StartFrame() // Return true if the bot can use this weapon bool CCSBotManager::IsWeaponUseable(CBasePlayerItem *item) const { - if (item == NULL) + if (!item) { return false; } @@ -351,7 +350,7 @@ void CCSBotManager::ClientDisconnect(CBasePlayer *pPlayer) void PrintAllEntities() { - for (int i = 1; i < gpGlobals->maxEntities; ++i) + for (int i = 1; i < gpGlobals->maxEntities; i++) { edict_t *edict = INDEXENT(i); @@ -396,11 +395,10 @@ void CCSBotManager::ServerCommand(const char *pcmd) else killThemAll = false; - for (int iIndex = 1; iIndex <= gpGlobals->maxClients; ++iIndex) + for (int i = 1; i <= gpGlobals->maxClients; i++) { - CBasePlayer *pPlayer = UTIL_PlayerByIndex(iIndex); - - if (pPlayer == NULL) + CBasePlayer *pPlayer = UTIL_PlayerByIndex(i); + if (!pPlayer) continue; if (FNullEnt(pPlayer->pev)) @@ -431,11 +429,10 @@ void CCSBotManager::ServerCommand(const char *pcmd) else kickThemAll = false; - for (int iIndex = 1; iIndex <= gpGlobals->maxClients; ++iIndex) + for (int i = 1; i <= gpGlobals->maxClients; i++) { - CBasePlayer *pPlayer = UTIL_PlayerByIndex(iIndex); - - if (pPlayer == NULL) + CBasePlayer *pPlayer = UTIL_PlayerByIndex(i); + if (!pPlayer) continue; if (FNullEnt(pPlayer->pev)) @@ -593,10 +590,8 @@ void CCSBotManager::ServerCommand(const char *pcmd) // no arguments = list all available places int i = 0; const BotPhraseList *placeList = TheBotPhrases->GetPlaceList(); - for (BotPhraseList::const_iterator iter = placeList->begin(); iter != placeList->end(); ++iter, ++i) + for (auto phrase : *placeList) { - const BotPhrase *phrase = (*iter); - if (phrase->GetID() == GetNavPlace()) CONSOLE_ECHO("--> %-26s", phrase->GetName()); else @@ -604,6 +599,7 @@ void CCSBotManager::ServerCommand(const char *pcmd) if (!(i % 3)) CONSOLE_ECHO("\n"); + i++; } CONSOLE_ECHO("\n"); } @@ -611,12 +607,10 @@ void CCSBotManager::ServerCommand(const char *pcmd) { // single argument = set current place const BotPhraseList *placeList = TheBotPhrases->GetPlaceList(); - const BotPhrase *found = NULL; + const BotPhrase *found = nullptr; bool isAmbiguous = false; - for (BotPhraseList::const_iterator iter = placeList->begin(); iter != placeList->end(); ++iter) + for (auto phrase : *placeList) { - const BotPhrase *phrase = (*iter); - if (!Q_strnicmp(phrase->GetName(), msg, Q_strlen(msg))) { // check for exact match in case of subsets of other strings @@ -671,7 +665,7 @@ void CCSBotManager::ServerCommand(const char *pcmd) CNavArea *area = GetMarkedArea(); if (area) { - CBaseEntity *pEntity = NULL; + CBaseEntity *pEntity = nullptr; while ((pEntity = UTIL_FindEntityByClassname(pEntity, "player"))) { if (!pEntity->IsPlayer()) @@ -709,14 +703,10 @@ void CCSBotManager::ServerCommand(const char *pcmd) sizeof(HidingSpot) * TheHidingSpotList.size()); unsigned int encounterMem = 0; - for (NavAreaList::iterator iter = TheNavAreaList.begin(); iter != TheNavAreaList.end(); ++iter) + for (auto area : TheNavAreaList) { - CNavArea *area = (*iter); - - for (SpotEncounterList::iterator siter = area->m_spotEncounterList.begin(); siter != area->m_spotEncounterList.end(); ++siter) + for (auto se : area->m_spotEncounterList) { - SpotEncounter se = (*siter); - encounterMem += sizeof(SpotEncounter); encounterMem += sizeof(SpotOrder) * se.spotList.size(); } @@ -775,7 +765,7 @@ bool CCSBotManager::BotAddCommand(BotProfileTeamType team, bool isFromConsole) if (IMPL(m_isLearningMap)) return false; - const BotProfile *profile = NULL; + const BotProfile *profile = nullptr; if (!isFromConsole || CMD_ARGC() < 2) { @@ -800,8 +790,7 @@ bool CCSBotManager::BotAddCommand(BotProfileTeamType team, bool isFromConsole) // try to add a bot by name profile = TheBotProfiles->GetRandomProfile(GetDifficultyLevel(), team); - - if (profile == NULL) + if (!profile) { CONSOLE_ECHO("All bot profiles at this difficulty level are in use.\n"); return true; @@ -821,7 +810,7 @@ bool CCSBotManager::BotAddCommand(BotProfileTeamType team, bool isFromConsole) } profile = TheBotProfiles->GetProfile(CMD_ARGV(1), team); - if (profile == NULL) + if (!profile) { CONSOLE_ECHO("Error - no profile for '%s' exists.\n", CMD_ARGV(1)); return true; @@ -1038,50 +1027,48 @@ void CCSBotManager::ValidateMapData() m_gameScenario = SCENARIO_DEATHMATCH; // Search all entities in the map and set the game type and store all zones (bomb target, etc). - CBaseEntity *entity = NULL; - int i; - for (i = 1; i < gpGlobals->maxEntities; ++i) + CBaseEntity *pEntity = nullptr; + for (int i = 1; i < gpGlobals->maxEntities; i++) { - entity = CBaseEntity::Instance(INDEXENT(i)); - - if (entity == NULL) + pEntity = CBaseEntity::Instance(INDEXENT(i)); + if (!pEntity) continue; bool found = false; bool isLegacy = false; - if (FClassnameIs(entity->pev, "func_bomb_target")) + if (FClassnameIs(pEntity->pev, "func_bomb_target")) { m_gameScenario = SCENARIO_DEFUSE_BOMB; found = true; isLegacy = false; } - else if (FClassnameIs(entity->pev, "info_bomb_target")) + else if (FClassnameIs(pEntity->pev, "info_bomb_target")) { m_gameScenario = SCENARIO_DEFUSE_BOMB; found = true; isLegacy = true; } - else if (FClassnameIs(entity->pev, "func_hostage_rescue")) + else if (FClassnameIs(pEntity->pev, "func_hostage_rescue")) { m_gameScenario = SCENARIO_RESCUE_HOSTAGES; found = true; isLegacy = false; } - else if (FClassnameIs(entity->pev, "info_hostage_rescue")) + else if (FClassnameIs(pEntity->pev, "info_hostage_rescue")) { m_gameScenario = SCENARIO_RESCUE_HOSTAGES; found = true; isLegacy = true; } - else if (FClassnameIs(entity->pev, "hostage_entity")) + else if (FClassnameIs(pEntity->pev, "hostage_entity")) { // some very old maps (ie: cs_assault) use info_player_start // as rescue zones, so set the scenario if there are hostages // in the map m_gameScenario = SCENARIO_RESCUE_HOSTAGES; } - else if (FClassnameIs(entity->pev, "func_vip_safetyzone")) + else if (FClassnameIs(pEntity->pev, "func_vip_safetyzone")) { m_gameScenario = SCENARIO_ESCORT_VIP; found = true; @@ -1092,14 +1079,16 @@ void CCSBotManager::ValidateMapData() { if (m_zoneCount < MAX_ZONES) { - m_zone[ m_zoneCount ].m_center = (isLegacy) ? entity->pev->origin : (entity->pev->absmax + entity->pev->absmin) / 2.0f; + m_zone[ m_zoneCount ].m_center = isLegacy ? pEntity->pev->origin : (pEntity->pev->absmax + pEntity->pev->absmin) / 2.0f; m_zone[ m_zoneCount ].m_isLegacy = isLegacy; m_zone[ m_zoneCount ].m_index = m_zoneCount; - m_zone[ m_zoneCount ].m_entity = entity; + m_zone[ m_zoneCount ].m_entity = pEntity; m_zoneCount++; } else + { CONSOLE_ECHO("Warning: Too many zones, some will be ignored.\n"); + } } } @@ -1107,33 +1096,35 @@ void CCSBotManager::ValidateMapData() // use the info_player_start entities as rescue zones. if (m_zoneCount == 0 && m_gameScenario == SCENARIO_RESCUE_HOSTAGES) { - entity = NULL; + pEntity = nullptr; - while ((entity = UTIL_FindEntityByClassname(entity, "info_player_start"))) + while ((pEntity = UTIL_FindEntityByClassname(pEntity, "info_player_start"))) { #ifdef REGAMEDLL_FIXES if (m_zoneCount >= MAX_ZONES) break; #endif - if (FNullEnt(entity->edict())) + if (FNullEnt(pEntity->edict())) break; if (m_zoneCount < MAX_ZONES) { - m_zone[ m_zoneCount ].m_center = entity->pev->origin; + m_zone[ m_zoneCount ].m_center = pEntity->pev->origin; m_zone[ m_zoneCount ].m_isLegacy = true; m_zone[ m_zoneCount ].m_index = m_zoneCount; - m_zone[ m_zoneCount ].m_entity = entity; + m_zone[ m_zoneCount ].m_entity = pEntity; m_zoneCount++; } else + { CONSOLE_ECHO("Warning: Too many zones, some will be ignored.\n"); + } } } // Collect nav areas that overlap each zone - for (i = 0; i < m_zoneCount; ++i) + for (int i = 0; i < m_zoneCount; i++) { Zone *zone = &m_zone[i]; @@ -1203,7 +1194,7 @@ bool CCSBotManager::AddBot(const BotProfile *profile, BotProfileTeamType team) } CCSBot *pBot = CreateBot(profile); - if (pBot == NULL) + if (!pBot) { return false; } @@ -1233,14 +1224,13 @@ bool CCSBotManager::AddBot(const BotProfile *profile, BotProfileTeamType team) SERVER_COMMAND(UTIL_VarArgs("kick \"%s\"\n", STRING(pBot->pev->netname))); CONSOLE_ECHO("Could not add bot to the game.\n"); - return false; } // Return the zone that contains the given position const CCSBotManager::Zone *CCSBotManager::GetZone(const Vector *pos) const { - for (int z = 0; z < m_zoneCount; ++z) + for (int z = 0; z < m_zoneCount; z++) { if (m_zone[z].m_extent.Contains(pos)) { @@ -1248,16 +1238,16 @@ const CCSBotManager::Zone *CCSBotManager::GetZone(const Vector *pos) const } } - return NULL; + return nullptr; } // Return the closest zone to the given position const CCSBotManager::Zone *CCSBotManager::GetClosestZone(const Vector *pos) const { - const Zone *close = NULL; + const Zone *close = nullptr; float closeRangeSq = 1e9f; - for (int z = 0; z < m_zoneCount; ++z) + for (int z = 0; z < m_zoneCount; z++) { float rangeSq = (m_zone[z].m_center - (*pos)).LengthSquared(); @@ -1276,11 +1266,11 @@ const Vector *CCSBotManager::GetRandomPositionInZone(const Zone *zone) const { static Vector pos; - if (zone == NULL) - return NULL; + if (!zone) + return nullptr; if (zone->m_areaCount == 0) - return NULL; + return nullptr; // pick a random overlapping area CNavArea *area = GetRandomAreaInZone(zone); @@ -1314,7 +1304,7 @@ CNavArea *CCSBotManager::GetRandomAreaInZone(const Zone *zone) const { // TODO: improvement is needed if (!zone->m_areaCount) - return NULL; + return nullptr; return zone->m_area[ RANDOM_LONG(0, zone->m_areaCount - 1) ]; } @@ -1333,12 +1323,12 @@ void CCSBotManager::OnEvent(GameEventType event, CBaseEntity *entity, CBaseEntit break; case EVENT_BOMB_DEFUSE_ABORTED: - m_bombDefuser = NULL; + m_bombDefuser = nullptr; break; case EVENT_BOMB_DEFUSED: m_isBombPlanted = false; - m_bombDefuser = NULL; + m_bombDefuser = nullptr; break; case EVENT_TERRORISTS_WIN: @@ -1375,7 +1365,7 @@ void CCSBotManager::SetLooseBomb(CBaseEntity *bomb) } else { - m_looseBombArea = NULL; + m_looseBombArea = nullptr; } } @@ -1492,13 +1482,7 @@ void CCSBotManager::SetRadioMessageTimestamp(GameEventType event, int teamID) // Reset all radio message timestamps void CCSBotManager::ResetRadioMessageTimestamps() { - for (int t = 0; t < ARRAYSIZE(m_radioMsgTimestamp[0]); ++t) - { - for (int m = 0; m < ARRAYSIZE(m_radioMsgTimestamp); ++m) - { - m_radioMsgTimestamp[m][t] = 0.0f; - } - } + Q_memset(m_radioMsgTimestamp, 0, sizeof(m_radioMsgTimestamp)); } void CCSBotManager::OnFreeEntPrivateData(CBaseEntity *pEntity) @@ -1513,10 +1497,10 @@ void CCSBotManager::OnFreeEntPrivateData(CBaseEntity *pEntity) { CCSBot *pBot = static_cast(pPlayer); if (pBot->m_attacker == pEntity) - pBot->m_attacker = NULL; + pBot->m_attacker = nullptr; if (pBot->m_bomber == pEntity) - pBot->m_bomber = NULL; + pBot->m_bomber = nullptr; } } } diff --git a/regamedll/dlls/bot/cs_bot_manager.h b/regamedll/dlls/bot/cs_bot_manager.h index e27932bb..21a55b81 100644 --- a/regamedll/dlls/bot/cs_bot_manager.h +++ b/regamedll/dlls/bot/cs_bot_manager.h @@ -26,11 +26,7 @@ * */ -#ifndef CS_BOT_MANAGER_H -#define CS_BOT_MANAGER_H -#ifdef _WIN32 #pragma once -#endif extern CBotManager *TheBots; @@ -134,7 +130,7 @@ public: if (startArea == nullptr) return nullptr; - for (int i = 0; i < m_zoneCount; ++i) + for (int i = 0; i < m_zoneCount; i++) { if (m_zone[i].m_areaCount == 0) continue; @@ -269,5 +265,3 @@ inline bool AreBotsAllowed() void PrintAllEntities(); void UTIL_DrawBox(Extent *extent, int lifetime, int red, int green, int blue); - -#endif // CS_BOT_MANAGER_H diff --git a/regamedll/dlls/bot/cs_bot_nav.cpp b/regamedll/dlls/bot/cs_bot_nav.cpp index 0bac9d5e..0fffeac4 100644 --- a/regamedll/dlls/bot/cs_bot_nav.cpp +++ b/regamedll/dlls/bot/cs_bot_nav.cpp @@ -64,7 +64,7 @@ void CCSBot::StuckCheck() { // we have enough samples to know if we're stuck float avgVel = 0.0f; - for (int t = 0; t < m_avgVelCount; ++t) + for (int t = 0; t < m_avgVelCount; t++) avgVel += m_avgVel[t]; avgVel /= m_avgVelCount; @@ -140,7 +140,7 @@ bool CCSBot::GetSimpleGroundHeightWithFloor(const Vector *pos, float *height, Ve if (GetSimpleGroundHeight(pos, height, normal)) { // our current nav area also serves as a ground polygon - if (m_lastKnownArea != NULL && m_lastKnownArea->IsOverlapping(pos)) + if (m_lastKnownArea && m_lastKnownArea->IsOverlapping(pos)) { *height = Q_max((*height), m_lastKnownArea->GetZ(pos)); } @@ -153,8 +153,10 @@ bool CCSBot::GetSimpleGroundHeightWithFloor(const Vector *pos, float *height, Ve Place CCSBot::GetPlace() const { - if (m_lastKnownArea != NULL) + if (m_lastKnownArea) + { return m_lastKnownArea->GetPlace(); + } return UNDEFINED_PLACE; } @@ -169,7 +171,7 @@ void CCSBot::MoveTowardsPosition(const Vector *pos) // NOTE: We need to do this frequently to catch edges at the right time // TODO: Look ahead *along path* instead of straight line - if ((m_lastKnownArea == NULL || !(m_lastKnownArea->GetAttributes() & NAV_NO_JUMP)) + if ((!m_lastKnownArea || !(m_lastKnownArea->GetAttributes() & NAV_NO_JUMP)) && !IsOnLadder() && !m_isJumpCrouching) { float ground; @@ -243,7 +245,7 @@ void CCSBot::MoveTowardsPosition(const Vector *pos) MoveBackward(); // if we are avoiding someone via strafing, don't override - if (m_avoid != NULL) + if (m_avoid) return; if (latProj >= c) @@ -294,12 +296,27 @@ void CCSBot::StrafeAwayFromPosition(const Vector *pos) Vector2D to(pos->x - pev->origin.x, pos->y - pev->origin.y); to.NormalizeInPlace(); + // move away from the position independant of our view direction + float toProj = to.x * dir.x + to.y * dir.y; float latProj = to.x * lat.x + to.y * lat.y; +#ifdef REGAMEDLL_FIXES + const float c = 0.5f; + if (toProj > c) + MoveBackward(); + else if (toProj < -c) + MoveForward(); + + if (latProj >= c) + StrafeRight(); + else if (latProj <= -c) + StrafeLeft(); +#else if (latProj >= 0.0f) StrafeRight(); else StrafeLeft(); +#endif } // For getting un-stuck @@ -349,7 +366,7 @@ void CCSBot::ComputeApproachPoints() { m_approachPointCount = 0; - if (m_lastKnownArea == NULL) + if (!m_lastKnownArea) { return; } @@ -359,11 +376,10 @@ void CCSBot::ComputeApproachPoints() Vector ap; float halfWidth; - for (int i = 0; i < m_lastKnownArea->GetApproachInfoCount() && m_approachPointCount < MAX_APPROACH_POINTS; ++i) + for (int i = 0; i < m_lastKnownArea->GetApproachInfoCount() && m_approachPointCount < MAX_APPROACH_POINTS; i++) { const CNavArea::ApproachInfo *info = m_lastKnownArea->GetApproachInfo(i); - - if (info->here.area == NULL || info->prev.area == NULL) + if (!info->here.area || !info->prev.area) { continue; } @@ -391,7 +407,7 @@ void CCSBot::ComputeApproachPoints() void CCSBot::DrawApproachPoints() { - for (int i = 0; i < m_approachPointCount; ++i) + for (int i = 0; i < m_approachPointCount; i++) { UTIL_DrawBeamPoints(m_approachPoint[i], m_approachPoint[i] + Vector(0, 0, 50), 3, 0, 255, 255); } @@ -420,7 +436,7 @@ NOXREF bool CCSBot::FindApproachPointNearestPath(Vector *pos) // from us that is near our path const float nearPathSq = 10000.0f; - for (int i = 0; i < m_approachPointCount; ++i) + for (int i = 0; i < m_approachPointCount; i++) { if (FindClosestPointOnPath(&m_approachPoint[i], start, end, &close) == false) continue; diff --git a/regamedll/dlls/bot/cs_bot_pathfind.cpp b/regamedll/dlls/bot/cs_bot_pathfind.cpp index 00205dee..aaae46c5 100644 --- a/regamedll/dlls/bot/cs_bot_pathfind.cpp +++ b/regamedll/dlls/bot/cs_bot_pathfind.cpp @@ -8,10 +8,10 @@ bool CCSBot::ComputePathPositions() // start in first area's center m_path[0].pos = *m_path[0].area->GetCenter(); - m_path[0].ladder = NULL; + m_path[0].ladder = nullptr; m_path[0].how = NUM_TRAVERSE_TYPES; - for (int i = 1; i < m_pathLength; ++i) + for (int i = 1; i < m_pathLength; i++) { const ConnectInfo *from = &m_path[i - 1]; ConnectInfo *to = &m_path[ i ]; @@ -19,7 +19,7 @@ bool CCSBot::ComputePathPositions() // walk along the floor to the next area if (to->how <= GO_WEST) { - to->ladder = NULL; + to->ladder = nullptr; // compute next point, keeping path as straight as possible from->area->ComputeClosestPointInPortal(to->area, (NavDirType)to->how, &from->pos, &to->pos); @@ -49,14 +49,14 @@ bool CCSBot::ComputePathPositions() if (m_pathLength < MAX_PATH_LENGTH - 1) { // copy nodes down - for (int j = m_pathLength; j > i; --j) + for (int j = m_pathLength; j > i; j--) m_path[j] = m_path[j - 1]; // path is one node longer - ++m_pathLength; + m_pathLength++; // move index ahead into the new node we just duplicated - ++i; + i++; m_path[i].pos.x = to->pos.x + pushDist * dir.x; m_path[i].pos.y = to->pos.y + pushDist * dir.y; @@ -72,7 +72,7 @@ bool CCSBot::ComputePathPositions() // find our ladder const NavLadderList *list = from->area->GetLadderList(LADDER_UP); NavLadderList::const_iterator iter; - for (iter = list->begin(); iter != list->end(); ++iter) + for (iter = list->begin(); iter != list->end(); iter++) { CNavLadder *ladder = (*iter); @@ -98,7 +98,7 @@ bool CCSBot::ComputePathPositions() // find our ladder const NavLadderList *list = from->area->GetLadderList(LADDER_DOWN); NavLadderList::const_iterator iter; - for (iter = list->begin(); iter != list->end(); ++iter) + for (iter = list->begin(); iter != list->end(); iter++) { CNavLadder *ladder = (*iter); @@ -130,9 +130,9 @@ void CCSBot::SetupLadderMovement() const ConnectInfo *to = &m_path[ m_pathIndex ]; - if (to->ladder != NULL) + if (to->ladder) { - m_spotEncounter = NULL; + m_spotEncounter = nullptr; m_areaEnteredTimestamp = gpGlobals->time; m_pathLadder = to->ladder; @@ -217,7 +217,7 @@ void CCSBot::ComputeLadderEndpoint(bool isAscending) // TODO: Need Push() and Pop() for run/walk context to keep ladder speed contained. bool CCSBot::UpdateLadderMovement() { - if (m_pathLadder == NULL) + if (!m_pathLadder) return false; bool giveUp = false; @@ -556,7 +556,7 @@ bool CCSBot::UpdateLadderMovement() // successfully traversed ladder and reached destination area // exit ladder state machine PrintIfWatched("Ladder traversed.\n"); - m_pathLadder = NULL; + m_pathLadder = nullptr; // incrememnt path index to next step beyond this ladder SetPathIndex(m_pathIndex + 1); @@ -576,7 +576,7 @@ bool CCSBot::UpdateLadderMovement() // NOTE: This does not do line-of-sight tests, so closest point may be thru the floor, etc bool CCSBot::FindClosestPointOnPath(const Vector *worldPos, int startIndex, int endIndex, Vector *close) const { - if (!HasPath() || close == NULL) + if (!HasPath() || !close) return false; Vector along, toWorldPos; @@ -587,7 +587,7 @@ bool CCSBot::FindClosestPointOnPath(const Vector *worldPos, int startIndex, int float closeDistSq = 9999999999.9f; float distSq; - for (int i = startIndex; i <= endIndex; ++i) + for (int i = startIndex; i <= endIndex; i++) { from = &m_path[i - 1].pos; to = &m_path[i].pos; @@ -661,7 +661,7 @@ int CCSBot::FindOurPositionOnPath(Vector *close, bool local) const end = m_pathLength; } - for (int i = start; i < end; ++i) + for (int i = start; i < end; i++) { from = &m_path[i - 1].pos; to = &m_path[i].pos; @@ -803,7 +803,7 @@ int CCSBot::FindPathPoint(float aheadRange, Vector *point, int *prevIndex) const float closeEpsilon = 20.0f; // 10.0f while ((*point - close).Make2D().IsLengthLessThan(closeEpsilon)) { - ++index; + index++; if (index >= m_pathLength) { @@ -826,7 +826,7 @@ int CCSBot::FindPathPoint(float aheadRange, Vector *point, int *prevIndex) const float closeEpsilon = 20.0f; if ((pos - close).Make2D().IsLengthLessThan(closeEpsilon)) { - ++startIndex; + startIndex++; } else { @@ -836,7 +836,7 @@ int CCSBot::FindPathPoint(float aheadRange, Vector *point, int *prevIndex) // if we hit a ladder, stop, or jump area, must stop (dont use ladder behind us) if (startIndex > m_pathIndex && startIndex < m_pathLength - && (m_path[ startIndex ].ladder != NULL || (m_path[ startIndex ].area->GetAttributes() & NAV_JUMP))) + && (m_path[ startIndex ].ladder || (m_path[ startIndex ].area->GetAttributes() & NAV_JUMP))) { *point = m_path[ startIndex ].pos; return startIndex; @@ -847,7 +847,7 @@ int CCSBot::FindPathPoint(float aheadRange, Vector *point, int *prevIndex) startIndex = m_pathLength - 1; // if we hit a ladder, stop, or jump area, must stop - if (startIndex < m_pathLength && (m_path[ startIndex ].ladder != NULL || (m_path[ startIndex ].area->GetAttributes() & NAV_JUMP))) + if (startIndex < m_pathLength && (m_path[ startIndex ].ladder || (m_path[ startIndex ].area->GetAttributes() & NAV_JUMP))) { *point = m_path[ startIndex ].pos; return startIndex; @@ -868,7 +868,7 @@ int CCSBot::FindPathPoint(float aheadRange, Vector *point, int *prevIndex) // step along the path until we pass aheadRange bool isCorner = false; int i; - for (i = startIndex; i < m_pathLength; ++i) + for (i = startIndex; i < m_pathLength; i++) { Vector pos = m_path[i].pos; Vector to = pos - m_path[i - 1].pos; @@ -878,7 +878,7 @@ int CCSBot::FindPathPoint(float aheadRange, Vector *point, int *prevIndex) // don't allow path to double-back from our starting direction (going upstairs, down curved passages, etc) if (DotProduct(dir, initDir) < 0.0f) // -0.25f { - --i; + i--; break; } @@ -886,7 +886,7 @@ int CCSBot::FindPathPoint(float aheadRange, Vector *point, int *prevIndex) if (DotProduct(dir, prevDir) < 0.5f) { isCorner = true; - --i; + i--; break; } @@ -902,14 +902,14 @@ int CCSBot::FindPathPoint(float aheadRange, Vector *point, int *prevIndex) } // if we encounter a ladder or jump area, we must stop - if (i < m_pathLength && (m_path[ i ].ladder != NULL || (m_path[ i ].area->GetAttributes() & NAV_JUMP))) + if (i < m_pathLength && (m_path[ i ].ladder || (m_path[ i ].area->GetAttributes() & NAV_JUMP))) break; // Check straight-line path from our current position to this position // Test for un-jumpable height change, or unrecoverable fall if (!IsStraightLinePathWalkable(&pos)) { - --i; + i--; break; } @@ -979,11 +979,11 @@ int CCSBot::FindPathPoint(float aheadRange, Vector *point, int *prevIndex) if (DotProduct(toPoint, initDir.Make2D()) < 0.0f || toPoint.IsLengthLessThan(epsilon)) { int i; - for (i = startIndex; i < m_pathLength; ++i) + for (i = startIndex; i < m_pathLength; i++) { toPoint.x = m_path[i].pos.x - pev->origin.x; toPoint.y = m_path[i].pos.y - pev->origin.y; - if (m_path[i].ladder != NULL || (m_path[i].area->GetAttributes() & NAV_JUMP) || toPoint.IsLengthGreaterThan(epsilon)) + if (m_path[i].ladder || (m_path[i].area->GetAttributes() & NAV_JUMP) || toPoint.IsLengthGreaterThan(epsilon)) { *point = m_path[i].pos; startIndex = i; @@ -1019,9 +1019,9 @@ void CCSBot::SetPathIndex(int newIndex) if (m_pathIndex < m_pathLength && m_pathIndex >= 2) m_spotEncounter = m_path[ m_pathIndex - 1 ].area->GetSpotEncounter(m_path[ m_pathIndex - 2 ].area, m_path[ m_pathIndex ].area); else - m_spotEncounter = NULL; + m_spotEncounter = nullptr; - m_pathLadder = NULL; + m_pathLadder = nullptr; } } @@ -1031,14 +1031,15 @@ bool CCSBot::IsNearJump() const if (m_pathIndex == 0 || m_pathIndex >= m_pathLength) return false; - for (int i = m_pathIndex - 1; i < m_pathIndex; ++i) + for (int i = m_pathIndex - 1; i < m_pathIndex; i++) { if (m_path[ i ].area->GetAttributes() & NAV_JUMP) { float dz = m_path[ i + 1 ].pos.z - m_path[ i ].pos.z; - if (dz > 0.0f) + { return true; + } } } @@ -1081,11 +1082,11 @@ bool CCSBot::IsFriendInTheWay(const Vector *goalPos) const m_isFriendInTheWay = false; // check if any friends are overlapping this linear path - for (int i = 1; i <= gpGlobals->maxClients; ++i) + for (int i = 1; i <= gpGlobals->maxClients; i++) { CBasePlayer *player = UTIL_PlayerByIndex(i); - if (player == NULL) + if (!player) continue; if (FNullEnt(player->pev)) @@ -1140,7 +1141,7 @@ bool CCSBot::IsFriendInTheWay(const Vector *goalPos) const void CCSBot::FeelerReflexAdjustment(Vector *goalPosition) { // if we are in a "precise" area, do not do feeler adjustments - if (m_lastKnownArea != NULL && (m_lastKnownArea->GetAttributes() & NAV_PRECISE)) + if (m_lastKnownArea && (m_lastKnownArea->GetAttributes() & NAV_PRECISE)) return; Vector dir(BotCOS(m_forwardAngle), BotSIN(m_forwardAngle), 0.0f); @@ -1330,7 +1331,7 @@ CCSBot::PathResult CCSBot::UpdatePathMovement(bool allowSpeedChange) // if there are no crouch areas coming up, stand const float crouchRange = 50.0f; bool didCrouch = false; - for (int i = prevIndex; i < m_pathLength; ++i) + for (int i = prevIndex; i < m_pathLength; i++) { const CNavArea *to = m_path[i].area; @@ -1381,7 +1382,7 @@ CCSBot::PathResult CCSBot::UpdatePathMovement(bool allowSpeedChange) { float along = toGoal.Length2D(); int i; - for (i = m_pathIndex + 1; i < m_pathLength; ++i) + for (i = m_pathIndex + 1; i < m_pathLength; i++) { Vector delta = m_path[i].pos - m_path[i - 1].pos; float segmentLength = delta.Length2D(); @@ -1414,7 +1415,9 @@ CCSBot::PathResult CCSBot::UpdatePathMovement(bool allowSpeedChange) } if (i == m_pathLength) + { toGoal = GetPathEndpoint() - pev->origin; + } } } else @@ -1554,18 +1557,18 @@ void CCSBot::BuildTrivialPath(const Vector *goal) m_path[0].area = m_lastKnownArea; m_path[0].pos = pev->origin; m_path[0].pos.z = m_lastKnownArea->GetZ(&pev->origin); - m_path[0].ladder = NULL; + m_path[0].ladder = nullptr; m_path[0].how = NUM_TRAVERSE_TYPES; m_path[1].area = m_lastKnownArea; m_path[1].pos = *goal; m_path[1].pos.z = m_lastKnownArea->GetZ(goal); - m_path[1].ladder = NULL; + m_path[1].ladder = nullptr; m_path[1].how = NUM_TRAVERSE_TYPES; m_areaEnteredTimestamp = gpGlobals->time; - m_spotEncounter = NULL; - m_pathLadder = NULL; + m_spotEncounter = nullptr; + m_pathLadder = nullptr; m_goalPosition = *goal; } @@ -1590,16 +1593,16 @@ bool CCSBot::ComputePath(CNavArea *goalArea, const Vector *goal, RouteType route // note final specific position Vector pathEndPosition; - if (goal == NULL && goalArea == NULL) + if (!goal && !goalArea) return false; - if (goal == NULL) + if (!goal) pathEndPosition = *goalArea->GetCenter(); else pathEndPosition = *goal; // make sure path end position is on the ground - if (goalArea != NULL) + if (goalArea) pathEndPosition.z = goalArea->GetZ(&pathEndPosition); else GetGroundHeight(&pathEndPosition, &pathEndPosition.z); @@ -1612,7 +1615,7 @@ bool CCSBot::ComputePath(CNavArea *goalArea, const Vector *goal, RouteType route } // Compute shortest path to goal - CNavArea *closestArea = NULL; + CNavArea *closestArea = nullptr; PathCost pathCost(this, route); bool pathToGoalExists = NavAreaBuildPath(startArea, goalArea, goal, pathCost, &closestArea); @@ -1624,7 +1627,7 @@ bool CCSBot::ComputePath(CNavArea *goalArea, const Vector *goal, RouteType route CNavArea *area; for (area = effectiveGoalArea; area; area = area->GetParent()) { - ++count; + count++; } // save room for endpoint @@ -1644,7 +1647,7 @@ bool CCSBot::ComputePath(CNavArea *goalArea, const Vector *goal, RouteType route m_pathLength = count; for (area = effectiveGoalArea; count && area; area = area->GetParent()) { - --count; + count--; m_path[ count ].area = area; m_path[ count ].how = area->GetParentHow(); } @@ -1657,7 +1660,7 @@ bool CCSBot::ComputePath(CNavArea *goalArea, const Vector *goal, RouteType route return false; } - if (goal == NULL) + if (!goal) { switch (m_path[m_pathLength - 1].how) { @@ -1680,20 +1683,20 @@ bool CCSBot::ComputePath(CNavArea *goalArea, const Vector *goal, RouteType route // append path end position m_path[ m_pathLength ].area = effectiveGoalArea; m_path[ m_pathLength ].pos = pathEndPosition; - m_path[ m_pathLength ].ladder = NULL; + m_path[ m_pathLength ].ladder = nullptr; m_path[ m_pathLength ].how = NUM_TRAVERSE_TYPES; - ++m_pathLength; + m_pathLength++; // do movement setup m_pathIndex = 1; m_areaEnteredTimestamp = gpGlobals->time; - m_spotEncounter = NULL; + m_spotEncounter = nullptr; m_goalPosition = m_path[1].pos; - if (m_path[1].ladder != NULL) + if (m_path[1].ladder) SetupLadderMovement(); else - m_pathLadder = NULL; + m_pathLadder = nullptr; return true; } @@ -1709,7 +1712,7 @@ float CCSBot::GetPathDistanceRemaining() const float dist = 0.0f; const Vector *prevCenter = m_path[m_pathIndex].area->GetCenter(); - for (int i = idx + 1; i < m_pathLength; ++i) + for (int i = idx + 1; i < m_pathLength; i++) { dist += (*m_path[i].area->GetCenter() - *prevCenter).Length(); prevCenter = m_path[i].area->GetCenter(); @@ -1724,7 +1727,7 @@ void CCSBot::DrawPath() if (!HasPath()) return; - for (int i = 1; i < m_pathLength; ++i) + for (int i = 1; i < m_pathLength; i++) { UTIL_DrawBeamPoints(m_path[i - 1].pos, m_path[i].pos, 2, 255, 75, 0); } diff --git a/regamedll/dlls/bot/cs_bot_radio.cpp b/regamedll/dlls/bot/cs_bot_radio.cpp index 19acb6e6..a16465ee 100644 --- a/regamedll/dlls/bot/cs_bot_radio.cpp +++ b/regamedll/dlls/bot/cs_bot_radio.cpp @@ -20,10 +20,9 @@ bool CCSBot::IsRadioCommand(GameEventType event) const void CCSBot::RespondToRadioCommands() { // bots use the chatter system to respond to each other - if (m_radioSubject != NULL && m_radioSubject->IsPlayer()) + if (m_radioSubject.IsValid() && m_radioSubject->IsPlayer()) { - CBasePlayer *player = m_radioSubject; - if (player->IsBot()) + if (m_radioSubject->IsBot()) { m_lastRadioCommand = EVENT_INVALID; return; @@ -71,8 +70,7 @@ void CCSBot::RespondToRadioCommands() return; } - CBasePlayer *player = m_radioSubject; - if (player == NULL) + if (!m_radioSubject) return; // respond to command @@ -92,8 +90,8 @@ void CCSBot::RespondToRadioCommands() { if (!IsFollowing()) { - Follow(player); - player->AllowAutoFollow(); + Follow(m_radioSubject); + m_radioSubject->AllowAutoFollow(); canDo = true; } break; @@ -104,9 +102,9 @@ void CCSBot::RespondToRadioCommands() { if (!IsFollowing()) { - Follow(player); + Follow(m_radioSubject); GetChatter()->Say("OnMyWay"); - player->AllowAutoFollow(); + m_radioSubject->AllowAutoFollow(); canDo = false; } break; @@ -122,7 +120,7 @@ void CCSBot::RespondToRadioCommands() // find the leader's area SetTask(HOLD_POSITION); StopFollowing(); - player->InhibitAutoFollow(inhibitAutoFollowDuration); + m_radioSubject->InhibitAutoFollow(inhibitAutoFollowDuration); Hide(TheNavAreaGrid.GetNearestNavArea(&m_radioPosition)); canDo = true; break; @@ -133,7 +131,7 @@ void CCSBot::RespondToRadioCommands() StopFollowing(); Hunt(); canDo = true; - player->InhibitAutoFollow(inhibitAutoFollowDuration); + m_radioSubject->InhibitAutoFollow(inhibitAutoFollowDuration); break; } case EVENT_RADIO_GET_OUT_OF_THERE: @@ -141,7 +139,7 @@ void CCSBot::RespondToRadioCommands() if (TheCSBots()->IsBombPlanted()) { EscapeFromBomb(); - player->InhibitAutoFollow(inhibitAutoFollowDuration); + m_radioSubject->InhibitAutoFollow(inhibitAutoFollowDuration); canDo = true; } break; @@ -154,9 +152,8 @@ void CCSBot::RespondToRadioCommands() { if (m_iTeam == CT && TheCSBots()->IsBombPlanted()) { - const CCSBotManager::Zone *zone = TheCSBots()->GetClosestZone(player); - - if (zone != NULL) + const CCSBotManager::Zone *zone = TheCSBots()->GetClosestZone(m_radioSubject); + if (zone) { GetGameState()->ClearBombsite(zone->m_index); @@ -197,11 +194,11 @@ void CCSBot::StartVoiceFeedback(float duration) m_voiceFeedbackStartTimestamp = gpGlobals->time; m_voiceFeedbackEndTimestamp = duration + gpGlobals->time; - CBasePlayer *pPlayer = NULL; - while ((pPlayer = GetNextRadioRecipient(pPlayer)) != NULL) + CBasePlayer *pPlayer = nullptr; + while ((pPlayer = GetNextRadioRecipient(pPlayer))) { - MESSAGE_BEGIN(MSG_ONE, gmsgBotVoice, NULL, pPlayer->pev); - WRITE_BYTE(1); // active is talking + MESSAGE_BEGIN(MSG_ONE, gmsgBotVoice, nullptr, pPlayer->pev); + WRITE_BYTE(1); // active is talking WRITE_BYTE(entindex()); // client index speaking MESSAGE_END(); } @@ -264,7 +261,7 @@ bool CCSBot::RespondToHelpRequest(CBasePlayer *them, Place place, float maxRange // go to where help is needed const Vector *pos = GetRandomSpotAtPlace(place); - if (pos != NULL) + if (pos) { MoveTo(pos, FASTEST_ROUTE); } diff --git a/regamedll/dlls/bot/cs_bot_statemachine.cpp b/regamedll/dlls/bot/cs_bot_statemachine.cpp index 8b9a4a1e..7cf323ea 100644 --- a/regamedll/dlls/bot/cs_bot_statemachine.cpp +++ b/regamedll/dlls/bot/cs_bot_statemachine.cpp @@ -3,13 +3,13 @@ // This method is the ONLY legal way to change a bot's current state void CCSBot::SetState(BotState *state) { - PrintIfWatched("SetState: %s -> %s\n", (m_state != NULL) ? m_state->GetName() : "NULL", state->GetName()); + PrintIfWatched("SetState: %s -> %s\n", m_state ? m_state->GetName() : "NULL", state->GetName()); // if we changed state from within the special Attack state, we are no longer attacking if (m_isAttacking) StopAttacking(); - if (m_state != NULL) + if (m_state) m_state->OnExit(this); state->OnEnter(this); @@ -32,7 +32,7 @@ void CCSBot::EscapeFromBomb() void CCSBot::Follow(CBasePlayer *player) { - if (player == NULL) + if (!player) return; // note when we began following @@ -59,7 +59,7 @@ void CCSBot::ContinueFollowing() void CCSBot::StopFollowing() { m_isFollowing = false; - m_leader = NULL; + m_leader = nullptr; m_allowAutoFollowTime = gpGlobals->time + 10.0f; } @@ -96,7 +96,7 @@ void CCSBot::Hide(CNavArea *searchFromArea, float duration, float hideRange, boo sourcePos = pev->origin; } - if (source == NULL) + if (!source) { PrintIfWatched("Hide from area is NULL.\n"); Idle(); @@ -112,7 +112,7 @@ void CCSBot::Hide(CNavArea *searchFromArea, float duration, float hideRange, boo Vector useSpot; const Vector *pos = FindNearbyHidingSpot(this, &sourcePos, source, hideRange, IsSniper()); - if (pos == NULL) + if (!pos) { PrintIfWatched("No available hiding spots.\n"); // hide at our current position @@ -140,7 +140,7 @@ void CCSBot::Hide(CNavArea *searchFromArea, float duration, float hideRange, boo void CCSBot::Hide(const Vector *hidingSpot, float duration, bool holdPosition) { CNavArea *hideArea = TheNavAreaGrid.GetNearestNavArea(hidingSpot); - if (hideArea == NULL) + if (!hideArea) { PrintIfWatched("Hiding spot off nav mesh\n"); Idle(); @@ -183,7 +183,7 @@ bool CCSBot::TryToHide(CNavArea *searchFromArea, float duration, float hideRange sourcePos = pev->origin; } - if (source == NULL) + if (!source) { PrintIfWatched("Hide from area is NULL.\n"); return false; @@ -196,7 +196,7 @@ bool CCSBot::TryToHide(CNavArea *searchFromArea, float duration, float hideRange // search around source area for a good hiding spot const Vector *pos = FindNearbyHidingSpot(this, &sourcePos, source, hideRange, IsSniper(), useNearest); - if (pos == NULL) + if (!pos) { PrintIfWatched("No available hiding spots.\n"); return false; @@ -221,7 +221,7 @@ bool CCSBot::TryToRetreat() const float maxRange = 1000.0f; const Vector *spot = FindNearbyRetreatSpot(this, maxRange); - if (spot != NULL) + if (spot) { // ignore enemies for a second to give us time to hide // reaching our hiding spot clears our disposition @@ -249,7 +249,7 @@ void CCSBot::Hunt() // NOTE: Attacking does not change our task. void CCSBot::Attack(CBasePlayer *victim) { - if (victim == NULL) + if (!victim) return; // zombies never attack diff --git a/regamedll/dlls/bot/cs_bot_update.cpp b/regamedll/dlls/bot/cs_bot_update.cpp index c63b38c1..d37f6d5c 100644 --- a/regamedll/dlls/bot/cs_bot_update.cpp +++ b/regamedll/dlls/bot/cs_bot_update.cpp @@ -15,7 +15,7 @@ void CCSBot::Upkeep() UpdateAimOffset(); // aim at enemy, if he's still alive - if (m_enemy != NULL) + if (m_enemy.IsValid()) { float feetOffset = pev->origin.z - GetFeetZ(); @@ -70,11 +70,15 @@ void CCSBot::Upkeep() m_aimSpot.z -= feetOffset * 0.5f; } else // FEET + { m_aimSpot.z -= (feetOffset + feetOffset); + } } } else + { m_aimSpot = m_lastEnemyPosition; + } // add in aim error m_aimSpot.x += m_aimOffset.x; @@ -157,10 +161,10 @@ void CCSBot::Update() switch (m_processMode) { - case PROCESS_LEARN: UpdateLearnProcess(); return; + case PROCESS_LEARN: UpdateLearnProcess(); return; case PROCESS_ANALYZE_ALPHA: UpdateAnalyzeAlphaProcess(); return; - case PROCESS_ANALYZE_BETA: UpdateAnalyzeBetaProcess(); return; - case PROCESS_SAVE: UpdateSaveProcess(); return; + case PROCESS_ANALYZE_BETA: UpdateAnalyzeBetaProcess(); return; + case PROCESS_SAVE: UpdateSaveProcess(); return; } // update our radio chatter @@ -210,23 +214,15 @@ void CCSBot::Update() // show encounter spot data if ((cv_bot_traceview.value == 4.0f && IsLocalPlayerWatchingMe()) || cv_bot_traceview.value == 5.0f) { - if (m_spotEncounter != NULL) + if (m_spotEncounter) { UTIL_DrawBeamPoints(m_spotEncounter->path.from, m_spotEncounter->path.to, 3, 0, 0, 255); Vector dir = m_spotEncounter->path.to - m_spotEncounter->path.from; float length = dir.NormalizeInPlace(); - const SpotOrder *order; - Vector along; - - for (SpotOrderList::const_iterator iter = m_spotEncounter->spotList.begin(); iter != m_spotEncounter->spotList.end(); ++iter) - { - order = &(*iter); - - along = m_spotEncounter->path.from + order->t * length * dir; - - UTIL_DrawBeamPoints(along, *order->spot->GetPosition(), 3, 0, 255, 255); + for (auto &order : m_spotEncounter->spotList) { + UTIL_DrawBeamPoints(m_spotEncounter->path.from + order.t * length * dir, *order.spot->GetPosition(), 3, 0, 255, 255); } } } @@ -261,7 +257,7 @@ void CCSBot::Update() } // track the last known area we were in - if (m_currentArea != NULL && m_currentArea != m_lastKnownArea) + if (m_currentArea && m_currentArea != m_lastKnownArea) { m_lastKnownArea = m_currentArea; // assume that we "clear" an area of enemies when we enter it @@ -276,7 +272,7 @@ void CCSBot::Update() m_approachPointViewPosition = pev->origin; } - if (cv_bot_show_nav.value > 0.0f && m_lastKnownArea != NULL) + if (cv_bot_show_nav.value > 0.0f && m_lastKnownArea) { m_lastKnownArea->DrawConnectedAreas(); } @@ -310,7 +306,7 @@ void CCSBot::Update() // "threat" may be the same as our current enemy CBasePlayer *threat = GetRecognizedEnemy(); - if (threat != NULL) + if (threat) { // adjust our personal "safe" time AdjustSafeTime(); @@ -355,7 +351,7 @@ void CCSBot::Update() if (doAttack) { - if (GetEnemy() == NULL || threat != GetEnemy() || !IsAttacking()) + if (!GetEnemy() || threat != GetEnemy() || !IsAttacking()) { if (IsUsingKnife() && IsHiding()) { @@ -397,12 +393,12 @@ void CCSBot::Update() } // Validate existing enemy, if any - if (m_enemy != NULL) + if (m_enemy.IsValid()) { if (IsAwareOfEnemyDeath()) { // we have noticed that our enemy has died - m_enemy = NULL; + m_enemy = nullptr; m_isEnemyVisible = false; } else @@ -442,7 +438,7 @@ void CCSBot::Update() // if we have seen an enemy recently, keep an eye on him if we can const float seenRecentTime = 3.0f; - if (m_enemy != NULL && GetTimeSinceLastSawEnemy() < seenRecentTime) + if (m_enemy.IsValid() && GetTimeSinceLastSawEnemy() < seenRecentTime) { AimAtEnemy(); } @@ -523,13 +519,13 @@ void CCSBot::Update() // make way const float avoidTime = 0.33f; - if (gpGlobals->time - m_avoidTimestamp < avoidTime && m_avoid != NULL) + if (gpGlobals->time - m_avoidTimestamp < avoidTime && m_avoid) { StrafeAwayFromPosition(&m_avoid->pev->origin); } else { - m_avoid = NULL; + m_avoid = nullptr; } if (m_isJumpCrouching) @@ -559,11 +555,15 @@ void CCSBot::Update() UpdatePeripheralVision(); // Update gamestate - if (m_bomber != NULL) + if (m_bomber) + { GetChatter()->SpottedBomber(GetBomber()); + } if (CanSeeLooseBomb()) + { GetChatter()->SpottedLooseBomb(TheCSBots()->GetLooseBomb()); + } // Scenario interrupts switch (TheCSBots()->GetScenario()) @@ -632,7 +632,7 @@ void CCSBot::Update() if (GetProfile()->GetTeamwork() > RANDOM_FLOAT(0.0f, 1.0f)) { CBasePlayer *leader = GetClosestVisibleHumanFriend(); - if (leader != NULL && leader->IsAutoFollowAllowed()) + if (leader && leader->IsAutoFollowAllowed()) { // count how many bots are already following this player const float maxFollowCount = 2; @@ -642,7 +642,7 @@ void CCSBot::Update() if ((leader->pev->origin - pev->origin).IsLengthLessThan(autoFollowRange)) { CNavArea *leaderArea = TheNavAreaGrid.GetNavArea(&leader->pev->origin); - if (leaderArea != NULL) + if (leaderArea) { PathCost cost(this, FASTEST_ROUTE); float travelRange = NavAreaTravelDistance(GetLastKnownArea(), leaderArea, cost); @@ -676,8 +676,8 @@ void CCSBot::Update() if (IsFollowing()) { // if we are following someone, make sure they are still alive - CBaseEntity *leader = m_leader; - if (leader == NULL || !leader->IsAlive()) + CBaseEntity *pLeader = m_leader; + if (!pLeader || !pLeader->IsAlive()) { StopFollowing(); } diff --git a/regamedll/dlls/bot/cs_bot_vision.cpp b/regamedll/dlls/bot/cs_bot_vision.cpp index 8a2fb1fa..80ba4a83 100644 --- a/regamedll/dlls/bot/cs_bot_vision.cpp +++ b/regamedll/dlls/bot/cs_bot_vision.cpp @@ -224,7 +224,7 @@ bool CCSBot::IsVisible(const Vector *pos, bool testFOV) const bool CCSBot::IsVisible(CBasePlayer *player, bool testFOV, unsigned char *visParts) const { Vector spot = player->pev->origin; - VisiblePartType testVisParts = NONE; + unsigned char testVisParts = NONE; // finish chest check if (IsVisible(&spot, testFOV)) @@ -266,7 +266,7 @@ bool CCSBot::IsVisible(CBasePlayer *player, bool testFOV, unsigned char *visPart if (IsVisible(&spot, testFOV)) testVisParts |= RIGHT_SIDE; - if (visParts != NULL) + if (visParts) *visParts = testVisParts; if (testVisParts != NONE) @@ -295,7 +295,7 @@ void CCSBot::UpdateLookAt() // Look at the given point in space for the given duration (-1 means forever) void CCSBot::SetLookAt(const char *desc, const Vector *pos, PriorityType pri, float duration, bool clearIfClose, float angleTolerance) { - if (pos == NULL) + if (!pos) return; // if currently looking at a point in space with higher priority, ignore this request @@ -344,14 +344,10 @@ void CCSBot::UpdatePeripheralVision() if (m_spotEncounter) { // check LOS to all spots in case we see them with our "peripheral vision" - const SpotOrder *spotOrder = NULL; Vector pos; - - for (SpotOrderList::const_iterator iter = m_spotEncounter->spotList.begin(); iter != m_spotEncounter->spotList.end(); ++iter) + for (auto &spotOrder : m_spotEncounter->spotList) { - spotOrder = &(*iter); - - const Vector *spotPos = spotOrder->spot->GetPosition(); + const Vector *spotPos = spotOrder.spot->GetPosition(); pos.x = spotPos->x; pos.y = spotPos->y; @@ -361,7 +357,7 @@ void CCSBot::UpdatePeripheralVision() continue; // can see hiding spot, remember when we saw it last - SetHidingSpotCheckTimestamp(spotOrder->spot); + SetHidingSpotCheckTimestamp(spotOrder.spot); } } } @@ -434,7 +430,7 @@ void CCSBot::UpdateLookAround(bool updateNow) } } - if (m_lastKnownArea == NULL) + if (!m_lastKnownArea) return; if (gpGlobals->time < m_lookAroundStateTimestamp) @@ -453,14 +449,12 @@ void CCSBot::UpdateLookAround(bool updateNow) } int which = RANDOM_LONG(0, m_approachPointCount - 1); - Vector spot = m_approachPoint[ which ]; + Vector spot = m_approachPoint[which]; // don't look at the floor, look roughly at chest level // TODO: If this approach point is very near, this will cause us to aim up in the air if were crouching spot.z += HalfHumanHeight; - SetLookAt("Approach Point (Hiding)", &spot, PRIORITY_LOW); - return; } @@ -511,24 +505,22 @@ void CCSBot::UpdateLookAround(bool updateNow) int dangerIndex = 0; const float checkTime = 10.0f; - const SpotOrder *spotOrder; - for (SpotOrderList::iterator iter = m_spotEncounter->spotList.begin(); iter != m_spotEncounter->spotList.end(); ++iter) + for (auto &spotOrder : m_spotEncounter->spotList) { - spotOrder = &(*iter); - // if we have seen this spot recently, we don't need to look at it - if (gpGlobals->time - GetHidingSpotCheckTimestamp(spotOrder->spot) <= checkTime) + if (gpGlobals->time - GetHidingSpotCheckTimestamp(spotOrder.spot) <= checkTime) continue; - if (spotOrder->t > t) + if (spotOrder.t > t) break; - dangerSpot[ dangerIndex++ ] = spotOrder->spot; + dangerSpot[dangerIndex++] = spotOrder.spot; if (dangerIndex >= MAX_DANGER_SPOTS) dangerIndex = 0; + if (dangerSpotCount < MAX_DANGER_SPOTS) - ++dangerSpotCount; + dangerSpotCount++; } if (dangerSpotCount) @@ -536,7 +528,7 @@ void CCSBot::UpdateLookAround(bool updateNow) // pick one of the spots at random int which = RANDOM_LONG(0, dangerSpotCount - 1); - const Vector *checkSpot = dangerSpot[ which ]->GetPosition(); + const Vector *checkSpot = dangerSpot[which]->GetPosition(); Vector pos = *checkSpot; pos.z += HalfHumanHeight; @@ -576,9 +568,9 @@ bool CCSBot::BendLineOfSight(const Vector *eye, const Vector *point, Vector *ben for (float angle = angleInc; angle <= 135.0f; angle += angleInc) { // check both sides at this angle offset - for (int side = 0; side < 2; ++side) + for (int side = 0; side < 2; side++) { - float actualAngle = (side) ? (startAngle + angle) : (startAngle - angle); + float actualAngle = side ? (startAngle + angle) : (startAngle - angle); float dx = BotCOS(actualAngle); float dy = BotSIN(actualAngle); @@ -635,31 +627,44 @@ bool CCSBot::BendLineOfSight(const Vector *eye, const Vector *point, Vector *ben CBasePlayer *CCSBot::FindMostDangerousThreat() { // maximum number of simulataneously attendable threats - enum { MAX_THREATS = 16 }; +#ifdef REGAMEDLL_FIXES + const int MAX_THREATS = MAX_CLIENTS; +#else + const int MAX_THREATS = 16; +#endif + struct CloseInfo { CBasePlayer *enemy; float range; - } - threat[ MAX_THREATS ]; + }; + + CloseInfo threat[MAX_THREATS]; int threatCount = 0; - m_bomber = NULL; +#ifdef REGAMEDLL_ADD + int prevIndex = m_enemyQueueIndex - 1; + if (prevIndex < 0) + prevIndex = MAX_ENEMY_QUEUE - 1; + + CBasePlayer *currentThreat = m_enemyQueue[ prevIndex ].player; +#endif + + m_bomber = nullptr; + m_closestVisibleFriend = nullptr; + m_closestVisibleHumanFriend = nullptr; - m_closestVisibleFriend = NULL; float closeFriendRange = 99999999999.9f; - - m_closestVisibleHumanFriend = NULL; float closeHumanFriendRange = 99999999999.9f; int i; { - for (i = 1; i <= gpGlobals->maxClients; ++i) + for (i = 1; i <= gpGlobals->maxClients; i++) { CBasePlayer *player = UTIL_PlayerByIndex(i); - if (player == NULL) + if (!player) continue; if (FNullEnt(player->pev)) @@ -710,9 +715,21 @@ CBasePlayer *CCSBot::FindMostDangerousThreat() } // check if this enemy is fully - if (!IsVisible(player, CHECK_FOV)) + unsigned char visParts; + if (!IsVisible(player, CHECK_FOV, &visParts)) continue; +#ifdef REGAMEDLL_ADD + // do we notice this enemy? (always notice current enemy) + if (player != currentThreat) + { + if (!IsNoticable(player, visParts)) + { + continue; + } + } +#endif + // update watch timestamp int idx = player->entindex() - 1; m_watchInfo[idx].timestamp = gpGlobals->time; @@ -739,13 +756,12 @@ CBasePlayer *CCSBot::FindMostDangerousThreat() { // find insertion point int j; - for (j = 0; j < threatCount; ++j) + for (j = 0; j < threatCount; j++) { if (distSq < threat[j].range) break; } - // shift lower half down a notch for (int k = threatCount - 1; k >= j; --k) threat[k + 1] = threat[k]; @@ -755,7 +771,7 @@ CBasePlayer *CCSBot::FindMostDangerousThreat() threat[j].range = distSq; if (threatCount < MAX_THREATS) - ++threatCount; + threatCount++; } } } @@ -766,7 +782,7 @@ CBasePlayer *CCSBot::FindMostDangerousThreat() m_nearbyEnemyCount = 0; m_nearbyFriendCount = 0; - for (i = 0; i < MAX_CLIENTS; ++i) + for (i = 0; i < MAX_CLIENTS; i++) { if (m_watchInfo[i].timestamp <= 0.0f) continue; @@ -775,9 +791,9 @@ CBasePlayer *CCSBot::FindMostDangerousThreat() if (gpGlobals->time - m_watchInfo[i].timestamp < recentTime) { if (m_watchInfo[i].isEnemy) - ++m_nearbyEnemyCount; + m_nearbyEnemyCount++; else - ++m_nearbyFriendCount; + m_nearbyFriendCount++; } } @@ -799,14 +815,14 @@ CBasePlayer *CCSBot::FindMostDangerousThreat() unsigned int place; int count; }; - static PlaceRank placeRank[ MAX_PLACES_PER_MAP ]; + static PlaceRank placeRank[MAX_PLACES_PER_MAP]; int locCount = 0; PlaceRank common; common.place = 0; common.count = 0; - for (i = 0; i < threatCount; ++i) + for (i = 0; i < threatCount; i++) { // find the area the player/bot is standing on CNavArea *area; @@ -821,7 +837,7 @@ CBasePlayer *CCSBot::FindMostDangerousThreat() area = TheNavAreaGrid.GetNearestNavArea(&threat[i].enemy->pev->origin); } - if (area == NULL) + if (!area) continue; unsigned int threatLoc = area->GetPlace(); @@ -830,7 +846,7 @@ CBasePlayer *CCSBot::FindMostDangerousThreat() // if place is already in set, increment count int j; - for (j = 0; j < locCount; ++j) + for (j = 0; j < locCount; j++) { if (placeRank[j].place == threatLoc) break; @@ -841,19 +857,19 @@ CBasePlayer *CCSBot::FindMostDangerousThreat() // new place if (locCount < MAX_PLACES_PER_MAP) { - placeRank[ locCount ].place = threatLoc; - placeRank[ locCount ].count = 1; + placeRank[locCount].place = threatLoc; + placeRank[locCount].count = 1; if (common.count == 0) common = placeRank[locCount]; - ++locCount; + locCount++; } } else { // others are in that place, increment - ++placeRank[j].count; + placeRank[j].count++; // keep track of the most common place if (placeRank[j].count > common.count) @@ -867,11 +883,33 @@ CBasePlayer *CCSBot::FindMostDangerousThreat() { if (threatCount == 0) - return NULL; + return nullptr; + + int t; + +#ifdef REGAMEDLL_ADD + bool sawCloserThreat = false; + bool sawCurrentThreat = false; + for (t = 0; t < threatCount; t++) + { + if (threat[t].enemy == currentThreat) + { + sawCurrentThreat = true; + } + else if (threat[t].enemy != currentThreat && IsSignificantlyCloser(threat[t].enemy, currentThreat)) + { + sawCloserThreat = true; + } + } + + if (sawCurrentThreat && !sawCloserThreat) + { + return currentThreat; + } +#endif // otherwise, find the closest threat that without using shield - int t; - for (t = 0; t < threatCount; ++t) + for (t = 0; t < threatCount; t++) { if (!threat[t].enemy->IsProtectedByShield()) { @@ -896,18 +934,23 @@ void CCSBot::UpdateReactionQueue() int now = m_enemyQueueIndex; +#ifdef REGAMEDLL_ADD + // reset timer + m_attentionInterval.Start(); +#endif + // store a snapshot of its state at the end of the reaction time queue - if (threat != NULL) + if (threat) { - m_enemyQueue[ now ].player = threat; - m_enemyQueue[ now ].isReloading = threat->IsReloading(); - m_enemyQueue[ now ].isProtectedByShield = threat->IsProtectedByShield(); + m_enemyQueue[now].player = threat; + m_enemyQueue[now].isReloading = threat->IsReloading(); + m_enemyQueue[now].isProtectedByShield = threat->IsProtectedByShield(); } else { - m_enemyQueue[ now ].player = NULL; - m_enemyQueue[ now ].isReloading = false; - m_enemyQueue[ now ].isProtectedByShield = false; + m_enemyQueue[now].player = nullptr; + m_enemyQueue[now].isReloading = false; + m_enemyQueue[now].isProtectedByShield = false; } // queue is round-robin @@ -915,7 +958,7 @@ void CCSBot::UpdateReactionQueue() m_enemyQueueIndex = 0; if (m_enemyQueueCount < MAX_ENEMY_QUEUE) - ++m_enemyQueueCount; + m_enemyQueueCount++; // clamp reaction time to enemy queue size float reactionTime = GetProfile()->GetReactionTime(); @@ -937,9 +980,9 @@ void CCSBot::UpdateReactionQueue() CBasePlayer *CCSBot::GetRecognizedEnemy() { if (m_enemyQueueAttendIndex >= m_enemyQueueCount) - return NULL; + return nullptr; - return (CBasePlayer *)m_enemyQueue[ m_enemyQueueAttendIndex ].player; + return m_enemyQueue[m_enemyQueueAttendIndex].player; } // Return true if the enemy we are "conscious" of is reloading @@ -948,7 +991,7 @@ bool CCSBot::IsRecognizedEnemyReloading() if (m_enemyQueueAttendIndex >= m_enemyQueueCount) return false; - return m_enemyQueue[ m_enemyQueueAttendIndex ].isReloading; + return m_enemyQueue[m_enemyQueueAttendIndex].isReloading; } // Return true if the enemy we are "conscious" of is hiding behind a shield @@ -957,17 +1000,17 @@ bool CCSBot::IsRecognizedEnemyProtectedByShield() if (m_enemyQueueAttendIndex >= m_enemyQueueCount) return false; - return m_enemyQueue[ m_enemyQueueAttendIndex ].isProtectedByShield; + return m_enemyQueue[m_enemyQueueAttendIndex].isProtectedByShield; } // Return distance to closest enemy we are "conscious" of float CCSBot::GetRangeToNearestRecognizedEnemy() { - const CBasePlayer *enemy = GetRecognizedEnemy(); + const CBasePlayer *pEnemy = GetRecognizedEnemy(); - if (enemy != NULL) + if (pEnemy) { - return (pev->origin - enemy->pev->origin).Length(); + return (pev->origin - pEnemy->pev->origin).Length(); } return 99999999.9f; @@ -995,3 +1038,139 @@ void CCSBot::Blind(float duration, float holdTime, float fadeTime, int alpha) // no longer safe AdjustSafeTime(); } + +#ifdef REGAMEDLL_ADD +bool CCSBot::IsNoticable(const CBasePlayer *player, unsigned char visibleParts) const +{ + float deltaT = m_attentionInterval.GetElapsedTime(); + + // all chances are specified in terms of a standard "quantum" of time + // in which a normal person would notice something + const float noticeQuantum = 0.25f; + + // determine percentage of player that is visible + float coverRatio = 0.0f; + + if (visibleParts & CHEST) + { + const float chance = 40.0f; + coverRatio += chance; + } + + if (visibleParts & HEAD) + { + const float chance = 10.0f; + coverRatio += chance; + } + + if (visibleParts & LEFT_SIDE) + { + const float chance = 20.0f; + coverRatio += chance; + } + + if (visibleParts & RIGHT_SIDE) + { + const float chance = 20.0f; + coverRatio += chance; + } + + if (visibleParts & FEET) + { + const float chance = 10.0f; + coverRatio += chance; + } + + // compute range modifier - farther away players are harder to notice, depeding on what they are doing + float range = (player->pev->origin - pev->origin).Length(); + const float closeRange = 300.0f; + const float farRange = 1000.0f; + + float rangeModifier; + if (range < closeRange) + { + rangeModifier = 0.0f; + } + else if (range > farRange) + { + rangeModifier = 1.0f; + } + else + { + rangeModifier = (range - closeRange) / (farRange - closeRange); + } + + // harder to notice when crouched + bool isCrouching = (player->pev->flags & FL_DUCKING) == FL_DUCKING; + // moving players are easier to spot + float playerSpeedSq = player->pev->velocity.LengthSquared(); + const float runSpeed = 200.0f; + const float walkSpeed = 30.0f; + float farChance, closeChance; + if (playerSpeedSq > runSpeed * runSpeed) + { + // running players are always easy to spot (must be standing to run) + return true; + } + else if (playerSpeedSq > walkSpeed * walkSpeed) + { + // walking players are less noticable far away + if (isCrouching) + { + closeChance = 90.0f; + farChance = 60.0f; + } + // standing + else + { + closeChance = 100.0f; + farChance = 75.0f; + } + } + else + { + // motionless players are hard to notice + if (isCrouching) + { + // crouching and motionless - very tough to notice + closeChance = 80.0f; + farChance = 5.0f; // takes about three seconds to notice (50% chance) + } + // standing + else + { + closeChance = 100.0f; + farChance = 10.0f; + } + } + + // combine posture, speed, and range chances + float dispositionChance = closeChance + (farChance - closeChance) * rangeModifier; + + // determine actual chance of noticing player + float noticeChance = dispositionChance * coverRatio/100.0f; + + // scale by skill level + noticeChance *= (0.5f + 0.5f * GetProfile()->GetSkill()); + + // if we are alert, our chance of noticing is much higher + //if (IsAlert()) + //{ + // const float alertBonus = 50.0f; + // noticeChance += alertBonus; + //} + + // scale by time quantum + noticeChance *= deltaT / noticeQuantum; + + // there must always be a chance of detecting the enemy + const float minChance = 0.1f; + if (noticeChance < minChance) + { + noticeChance = minChance; + } + + //PrintIfWatched("Notice chance = %3.2f\n", noticeChance); + return (RANDOM_FLOAT(0.0f, 100.0f) < noticeChance); +} +#endif diff --git a/regamedll/dlls/bot/cs_bot_weapon.cpp b/regamedll/dlls/bot/cs_bot_weapon.cpp index c1568a99..c35f9361 100644 --- a/regamedll/dlls/bot/cs_bot_weapon.cpp +++ b/regamedll/dlls/bot/cs_bot_weapon.cpp @@ -4,8 +4,8 @@ // NOTE: Aiming our weapon is handled in RunBotUpkeep() void CCSBot::FireWeaponAtEnemy() { - CBasePlayer *enemy = GetEnemy(); - if (enemy == NULL) + CBasePlayer *pEnemy = GetEnemy(); + if (!pEnemy) { StopRapidFire(); return; @@ -24,7 +24,7 @@ void CCSBot::FireWeaponAtEnemy() { ClearSurpriseDelay(); - if (!(IsRecognizedEnemyProtectedByShield() && IsPlayerFacingMe(enemy)) // dont shoot at enemies behind shields + if (!(IsRecognizedEnemyProtectedByShield() && IsPlayerFacingMe(pEnemy)) // dont shoot at enemies behind shields && !IsActiveWeaponReloading() && !IsActiveWeaponClipEmpty() && IsEnemyVisible()) @@ -76,7 +76,7 @@ void CCSBot::FireWeaponAtEnemy() ForceRun(5.0f); // if our prey is facing away, backstab him! - if (!IsPlayerFacingMe(enemy)) + if (!IsPlayerFacingMe(pEnemy)) { SecondaryAttack(); } @@ -278,9 +278,8 @@ bool isSniperRifle(CBasePlayerItem *item) bool CCSBot::IsUsingAWP() const { - CBasePlayerWeapon *weapon = GetActiveWeapon(); - - if (weapon != NULL && weapon->m_iId == WEAPON_AWP) + CBasePlayerWeapon *pCurrentWeapon = GetActiveWeapon(); + if (pCurrentWeapon && pCurrentWeapon->m_iId == WEAPON_AWP) return true; return false; @@ -289,12 +288,11 @@ bool CCSBot::IsUsingAWP() const // Returns true if we are using a weapon with a removable silencer bool CCSBot::DoesActiveWeaponHaveSilencer() const { - CBasePlayerWeapon *weapon = GetActiveWeapon(); - - if (weapon == NULL) + CBasePlayerWeapon *pCurrentWeapon = GetActiveWeapon(); + if (!pCurrentWeapon) return false; - if (weapon->m_iId == WEAPON_M4A1 || weapon->m_iId == WEAPON_USP) + if (pCurrentWeapon->m_iId == WEAPON_M4A1 || pCurrentWeapon->m_iId == WEAPON_USP) return true; return false; @@ -303,9 +301,8 @@ bool CCSBot::DoesActiveWeaponHaveSilencer() const // Return true if we are using a sniper rifle bool CCSBot::IsUsingSniperRifle() const { - CBasePlayerWeapon *weapon = GetActiveWeapon(); - - if (weapon != NULL && isSniperRifle(weapon)) + CBasePlayerWeapon *pCurrentWeapon = GetActiveWeapon(); + if (pCurrentWeapon && isSniperRifle(pCurrentWeapon)) return true; return false; @@ -314,20 +311,11 @@ bool CCSBot::IsUsingSniperRifle() const // Return true if we have a sniper rifle in our inventory bool CCSBot::IsSniper() const { - for (int i = 0; i < MAX_ITEM_TYPES; ++i) - { - CBasePlayerItem *item = m_rgpPlayerItems[i]; + auto sniperItem = this->ForEachItem([](CBasePlayerItem *pItem) { + return isSniperRifle(pItem); + }); - while (item != NULL) - { - if (isSniperRifle(item)) - return true; - - item = item->m_pNext; - } - } - - return false; + return sniperItem ? true : false; } // Return true if we are actively sniping (moving to sniper spot or settled in) @@ -342,12 +330,11 @@ bool CCSBot::IsSniping() const // Return true if we are using a shotgun bool CCSBot::IsUsingShotgun() const { - CBasePlayerWeapon *weapon = GetActiveWeapon(); - - if (weapon == NULL) + CBasePlayerWeapon *pCurrentWeapon = GetActiveWeapon(); + if (!pCurrentWeapon) return false; - if (weapon->m_iId == WEAPON_XM1014 || weapon->m_iId == WEAPON_M3) + if (pCurrentWeapon->m_iId == WEAPON_XM1014 || pCurrentWeapon->m_iId == WEAPON_M3) return true; return false; @@ -356,9 +343,8 @@ bool CCSBot::IsUsingShotgun() const // Returns true if using the big 'ol machinegun bool CCSBot::IsUsingMachinegun() const { - CBasePlayerWeapon *weapon = GetActiveWeapon(); - - if (weapon != NULL && weapon->m_iId == WEAPON_M249) + CBasePlayerWeapon *pCurrentWeapon = GetActiveWeapon(); + if (pCurrentWeapon && pCurrentWeapon->m_iId == WEAPON_M249) return true; return false; @@ -367,13 +353,12 @@ bool CCSBot::IsUsingMachinegun() const // Return true if primary weapon doesn't exist or is totally out of ammo bool CCSBot::IsPrimaryWeaponEmpty() const { - CBasePlayerWeapon *weapon = static_cast(m_rgpPlayerItems[ PRIMARY_WEAPON_SLOT ]); - - if (weapon == NULL) + CBasePlayerWeapon *pCurrentWeapon = static_cast(m_rgpPlayerItems[PRIMARY_WEAPON_SLOT]); + if (!pCurrentWeapon) return true; // check if gun has any ammo left - if (HasAnyAmmo(weapon)) + if (HasAnyAmmo(pCurrentWeapon)) return false; return true; @@ -382,13 +367,12 @@ bool CCSBot::IsPrimaryWeaponEmpty() const // Return true if pistol doesn't exist or is totally out of ammo bool CCSBot::IsPistolEmpty() const { - CBasePlayerWeapon *weapon = static_cast(m_rgpPlayerItems[ PISTOL_SLOT ]); - - if (weapon == NULL) + CBasePlayerWeapon *pCurrentWeapon = static_cast(m_rgpPlayerItems[ PISTOL_SLOT ]); + if (!pCurrentWeapon) return true; // check if gun has any ammo left - if (HasAnyAmmo(weapon)) + if (HasAnyAmmo(pCurrentWeapon)) { return false; } @@ -397,17 +381,17 @@ bool CCSBot::IsPistolEmpty() const } // Equip the given item -bool CCSBot::DoEquip(CBasePlayerWeapon *gun) +bool CCSBot::DoEquip(CBasePlayerWeapon *pWeapon) { - if (gun == NULL) + if (!pWeapon) return false; // check if weapon has any ammo left - if (!HasAnyAmmo(gun)) + if (!HasAnyAmmo(pWeapon)) return false; // equip it - SelectItem(STRING(gun->pev->classname)); + SelectItem(STRING(pWeapon->pev->classname)); m_equipTimer.Start(); return true; @@ -423,11 +407,10 @@ void CCSBot::EquipBestWeapon(bool mustEquip) if (!mustEquip && m_equipTimer.GetElapsedTime() < minEquipInterval) return; - CBasePlayerWeapon *primary = static_cast(m_rgpPlayerItems[ PRIMARY_WEAPON_SLOT ]); - - if (primary != NULL) + CBasePlayerWeapon *pPrimary = static_cast(m_rgpPlayerItems[ PRIMARY_WEAPON_SLOT ]); + if (pPrimary) { - WeaponClassType weaponClass = WeaponIDToWeaponClass(primary->m_iId); + WeaponClassType weaponClass = WeaponIDToWeaponClass(pPrimary->m_iId); if ((TheCSBots()->AllowShotguns() && weaponClass == WEAPONCLASS_SHOTGUN) || (TheCSBots()->AllowMachineGuns() && weaponClass == WEAPONCLASS_MACHINEGUN) @@ -438,9 +421,9 @@ void CCSBot::EquipBestWeapon(bool mustEquip) #endif || (TheCSBots()->AllowSnipers() && weaponClass == WEAPONCLASS_SNIPERRIFLE) || (TheCSBots()->AllowSubMachineGuns() && weaponClass == WEAPONCLASS_SUBMACHINEGUN) - || (TheCSBots()->AllowTacticalShield() && primary->m_iId == WEAPON_SHIELDGUN)) + || (TheCSBots()->AllowTacticalShield() && pPrimary->m_iId == WEAPON_SHIELDGUN)) { - if (DoEquip(primary)) + if (DoEquip(pPrimary)) return; } } @@ -474,10 +457,10 @@ void CCSBot::EquipKnife() { if (!IsUsingKnife()) { - CBasePlayerWeapon *knife = static_cast(m_rgpPlayerItems[ KNIFE_SLOT ]); - if (knife != NULL) + CBasePlayerWeapon *pKnife = static_cast(m_rgpPlayerItems[ KNIFE_SLOT ]); + if (pKnife) { - SelectItem(STRING(knife->pev->classname)); + SelectItem(STRING(pKnife->pev->classname)); } } } @@ -485,8 +468,8 @@ void CCSBot::EquipKnife() // Return true if we have a grenade in our inventory bool CCSBot::HasGrenade() const { - CBasePlayerWeapon *grenade = static_cast(m_rgpPlayerItems[ GRENADE_SLOT ]); - return grenade != NULL; + CBasePlayerWeapon *pGrenade = static_cast(m_rgpPlayerItems[ GRENADE_SLOT ]); + return pGrenade != nullptr; } // Equip a grenade, return false if we cant @@ -501,14 +484,13 @@ bool CCSBot::EquipGrenade(bool noSmoke) if (HasGrenade()) { - CBasePlayerWeapon *grenade = static_cast(m_rgpPlayerItems[ GRENADE_SLOT ]); - - if (grenade != NULL) + CBasePlayerWeapon *pGrenade = static_cast(m_rgpPlayerItems[ GRENADE_SLOT ]); + if (pGrenade) { - if (noSmoke && grenade->m_iId == WEAPON_SMOKEGRENADE) + if (noSmoke && pGrenade->m_iId == WEAPON_SMOKEGRENADE) return false; - SelectItem(STRING(grenade->pev->classname)); + SelectItem(STRING(pGrenade->pev->classname)); return true; } } @@ -519,9 +501,8 @@ bool CCSBot::EquipGrenade(bool noSmoke) // Returns true if we have knife equipped bool CCSBot::IsUsingKnife() const { - CBasePlayerWeapon *weapon = GetActiveWeapon(); - - if (weapon != NULL && weapon->m_iId == WEAPON_KNIFE) + CBasePlayerWeapon *pCurrentWeapon = GetActiveWeapon(); + if (pCurrentWeapon && pCurrentWeapon->m_iId == WEAPON_KNIFE) return true; return false; @@ -530,9 +511,8 @@ bool CCSBot::IsUsingKnife() const // Returns true if we have pistol equipped bool CCSBot::IsUsingPistol() const { - CBasePlayerWeapon *weapon = GetActiveWeapon(); - - if (weapon != NULL && weapon->IsPistol()) + CBasePlayerWeapon *pCurrentWeapon = GetActiveWeapon(); + if (pCurrentWeapon && pCurrentWeapon->IsPistol()) return true; return false; @@ -541,14 +521,14 @@ bool CCSBot::IsUsingPistol() const // Returns true if we have a grenade equipped bool CCSBot::IsUsingGrenade() const { - CBasePlayerWeapon *weapon = GetActiveWeapon(); + CBasePlayerWeapon *pCurrentWeapon = GetActiveWeapon(); - if (weapon == NULL) + if (!pCurrentWeapon) return false; - if (weapon->m_iId == WEAPON_SMOKEGRENADE - || weapon->m_iId == WEAPON_FLASHBANG - || weapon->m_iId == WEAPON_HEGRENADE) + if (pCurrentWeapon->m_iId == WEAPON_SMOKEGRENADE + || pCurrentWeapon->m_iId == WEAPON_FLASHBANG + || pCurrentWeapon->m_iId == WEAPON_HEGRENADE) return true; return false; @@ -556,9 +536,8 @@ bool CCSBot::IsUsingGrenade() const bool CCSBot::IsUsingHEGrenade() const { - CBasePlayerWeapon *weapon = GetActiveWeapon(); - - if (weapon != NULL && weapon->m_iId == WEAPON_HEGRENADE) + CBasePlayerWeapon *pCurrentWeapon = GetActiveWeapon(); + if (pCurrentWeapon && pCurrentWeapon->m_iId == WEAPON_HEGRENADE) return true; return false; @@ -586,7 +565,7 @@ bool CCSBot::FindGrenadeTossPathTarget(Vector *pos) // find farthest point we can see on the path int i; - for (i = m_pathIndex; i < m_pathLength; ++i) + for (i = m_pathIndex; i < m_pathLength; i++) { if (!FVisible(m_path[i].pos + Vector(0, 0, HalfHumanHeight))) break; @@ -733,7 +712,7 @@ void CCSBot::ReloadCheck() { PrintIfWatched("Retreating to a safe spot to reload!\n"); const Vector *spot = FindNearbyRetreatSpot(this, 1000.0f); - if (spot != NULL) + if (spot) { // ignore enemies for a second to give us time to hide // reaching our hiding spot clears our disposition @@ -769,17 +748,17 @@ void CCSBot::SilencerCheck() // don't touch the silencer if there are enemies nearby if (GetNearbyEnemyCount() == 0) { - CBasePlayerWeapon *myGun = GetActiveWeapon(); - if (myGun == NULL) + CBasePlayerWeapon *pCurrentWeapon = GetActiveWeapon(); + if (!pCurrentWeapon) return; - bool isSilencerOn = (myGun->m_iWeaponState & (WPNSTATE_M4A1_SILENCED | WPNSTATE_USP_SILENCED)) != 0; + bool isSilencerOn = (pCurrentWeapon->m_iWeaponState & (WPNSTATE_M4A1_SILENCED | WPNSTATE_USP_SILENCED)) != 0; #ifndef REGAMEDLL_FIXES if (isSilencerOn != GetProfile()->PrefersSilencer() && !HasShield()) #else - if (myGun->m_flNextSecondaryAttack >= gpGlobals->time) + if (pCurrentWeapon->m_flNextSecondaryAttack >= gpGlobals->time) return; // equip silencer if we want to and we don't have a shield. @@ -787,7 +766,7 @@ void CCSBot::SilencerCheck() #endif { PrintIfWatched("%s silencer!\n", (isSilencerOn) ? "Unequipping" : "Equipping"); - myGun->SecondaryAttack(); + pCurrentWeapon->SecondaryAttack(); } } } @@ -813,7 +792,7 @@ void CCSBot::OnTouchingWeapon(CWeaponBox *box) if (GetTimeSinceLastSawEnemy() >= safeTime) { // we have a primary weapon - drop it if the one on the ground is better - for (int i = 0; i < GetProfile()->GetWeaponPreferenceCount(); ++i) + for (int i = 0; i < GetProfile()->GetWeaponPreferenceCount(); i++) { int prefID = GetProfile()->GetWeaponPreference(i); if (!IsPrimaryWeapon(prefID)) @@ -853,15 +832,12 @@ bool CCSBot::IsFriendInLineOfFire() TraceResult result; UTIL_TraceLine(GetGunPosition(), target + 10000.0f * aimDir, dont_ignore_monsters, ignore_glass, ENT(pev), &result); - if (result.pHit != NULL) + if (result.pHit) { - CBaseEntity *victim = CBaseEntity::Instance(result.pHit); - - if (victim != NULL && victim->IsPlayer() && victim->IsAlive()) + CBasePlayer *pVictim = CBasePlayer::Instance(result.pHit); + if (pVictim && pVictim->IsPlayer() && pVictim->IsAlive()) { - CBasePlayer *player = static_cast(victim); - - if (BotRelationship(player) == BOT_TEAMMATE) + if (BotRelationship(pVictim) == BOT_TEAMMATE) return true; } } diff --git a/regamedll/dlls/bot/cs_gamestate.cpp b/regamedll/dlls/bot/cs_gamestate.cpp index ed2b656e..c077e4f6 100644 --- a/regamedll/dlls/bot/cs_gamestate.cpp +++ b/regamedll/dlls/bot/cs_gamestate.cpp @@ -15,11 +15,11 @@ CSGameState::CSGameState(CCSBot *owner) m_bombsiteCount = 0; m_bombsiteSearchIndex = 0; - for (int i = 0; i < MAX_HOSTAGES; ++i) + for (int i = 0; i < MAX_HOSTAGES; i++) { HostageInfo *info = &m_hostage[i]; - info->hostage = NULL; + info->hostage = nullptr; info->knownPos = Vector(0, 0, 0); info->isValid = false; info->isAlive = false; @@ -42,7 +42,7 @@ void CSGameState::Reset() m_isPlantedBombPosKnown = false; m_plantedBombsite = UNKNOWN; - for (i = 0; i < m_bombsiteCount; ++i) + for (i = 0; i < m_bombsiteCount; i++) { m_isBombsiteClear[i] = false; m_bombsiteSearchOrder[i] = i; @@ -51,7 +51,7 @@ void CSGameState::Reset() // shuffle the bombsite search order // allows T's to plant at random site, and TEAM_CT's to search in a random order // NOTE: VS6 std::random_shuffle() doesn't work well with an array of two elements (most maps) - for (i = 0; i < m_bombsiteCount; ++i) + for (i = 0; i < m_bombsiteCount; i++) { int swap = m_bombsiteSearchOrder[i]; int rnd = RANDOM_LONG(i, m_bombsiteCount - 1); @@ -176,7 +176,7 @@ bool CSGameState::IsAtPlantedBombsite() const const CCSBotManager::Zone *zone = TheCSBots()->GetClosestZone(&m_owner->pev->origin); - if (zone != NULL) + if (zone) { return (m_plantedBombsite == zone->m_index); } @@ -192,7 +192,7 @@ int CSGameState::GetNextBombsiteToSearch() int i; // return next non-cleared bombsite index - for (i = m_bombsiteSearchIndex; i < m_bombsiteCount; ++i) + for (i = m_bombsiteSearchIndex; i < m_bombsiteCount; i++) { int z = m_bombsiteSearchOrder[i]; if (!m_isBombsiteClear[z]) @@ -203,7 +203,7 @@ int CSGameState::GetNextBombsiteToSearch() } // all the bombsites are clear, someone must have been mistaken - start search over - for (i = 0; i < m_bombsiteCount; ++i) + for (i = 0; i < m_bombsiteCount; i++) { m_isBombsiteClear[i] = false; } @@ -221,7 +221,7 @@ const Vector *CSGameState::GetBombPosition() const case MOVING: { if (!m_lastSawBomber.HasStarted()) - return NULL; + return nullptr; return &m_bomberPos; } @@ -230,18 +230,18 @@ const Vector *CSGameState::GetBombPosition() const if (IsLooseBombLocationKnown()) return &m_looseBombPos; - return NULL; + return nullptr; } case PLANTED: { if (IsPlantedBombLocationKnown()) return &m_plantedBombPos; - return NULL; + return nullptr; } } - return NULL; + return nullptr; } // We see the planted bomb at 'pos' @@ -249,7 +249,7 @@ void CSGameState::UpdatePlantedBomb(const Vector *pos) { const CCSBotManager::Zone *zone = TheCSBots()->GetClosestZone(pos); - if (zone == NULL) + if (!zone) { CONSOLE_ECHO("ERROR: Bomb planted outside of a zone!\n"); m_plantedBombsite = UNKNOWN; @@ -292,21 +292,21 @@ void CSGameState::InitializeHostageInfo() m_allHostagesRescued = false; m_haveSomeHostagesBeenTaken = false; - CBaseEntity *hostage = NULL; - while ((hostage = UTIL_FindEntityByClassname(hostage, "hostage_entity"))) + CHostage *pHostage = nullptr; + while ((pHostage = UTIL_FindEntityByClassname(pHostage, "hostage_entity"))) { if (m_hostageCount >= MAX_HOSTAGES) break; - if (!hostage->IsAlive()) + if (!pHostage->IsAlive()) continue; - m_hostage[m_hostageCount].hostage = static_cast(hostage); - m_hostage[m_hostageCount].knownPos = hostage->pev->origin; + m_hostage[m_hostageCount].hostage = pHostage; + m_hostage[m_hostageCount].knownPos = pHostage->pev->origin; m_hostage[m_hostageCount].isValid = true; m_hostage[m_hostageCount].isAlive = true; m_hostage[m_hostageCount].isFree = true; - ++m_hostageCount; + m_hostageCount++; } } @@ -318,22 +318,21 @@ void CSGameState::InitializeHostageInfo() // returned, since CHostages get deleted when they die. CHostage *CSGameState::GetNearestFreeHostage(Vector *knowPos) const { - if (m_owner == NULL) - return NULL; + if (!m_owner) + return nullptr; CNavArea *startArea = m_owner->GetLastKnownArea(); + if (!startArea) + return nullptr; - if (startArea == NULL) - return NULL; - - CHostage *close = NULL; - const Vector *closePos = NULL; + CHostage *close = nullptr; + const Vector *closePos = nullptr; float closeDistance = 9999999999.9f; - for (int i = 0; i < m_hostageCount; ++i) + for (int i = 0; i < m_hostageCount; i++) { - CHostage *hostage = m_hostage[i].hostage; - const Vector *hostagePos = NULL; + CHostage *pHostage = m_hostage[i].hostage; + const Vector *hostagePos = nullptr; if (m_owner->m_iTeam == CT) { @@ -344,7 +343,7 @@ CHostage *CSGameState::GetNearestFreeHostage(Vector *knowPos) const if (m_hostage[i].hostage->IsFollowingSomeone()) continue; - hostagePos = &hostage->pev->origin; + hostagePos = &pHostage->pev->origin; } else { @@ -356,8 +355,7 @@ CHostage *CSGameState::GetNearestFreeHostage(Vector *knowPos) const } CNavArea *hostageArea = TheNavAreaGrid.GetNearestNavArea(hostagePos); - - if (hostageArea != NULL) + if (hostageArea) { ShortestPathCost pc; float travelDistance = NavAreaTravelDistance(startArea, hostageArea, pc); @@ -366,13 +364,13 @@ CHostage *CSGameState::GetNearestFreeHostage(Vector *knowPos) const { closePos = hostagePos; closeDistance = travelDistance; - close = hostage; + close = pHostage; } } } // return where we think the hostage is - if (knowPos != NULL && closePos != NULL) + if (knowPos && closePos) { knowPos = const_cast(closePos); } @@ -387,13 +385,13 @@ const Vector *CSGameState::GetRandomFreeHostagePosition() const Vector *freePos[MAX_HOSTAGES]; int freeCount = 0; - if (m_owner == NULL) - return NULL; + if (!m_owner) + return nullptr; - for (int i = 0; i < m_hostageCount; ++i) + for (int i = 0; i < m_hostageCount; i++) { const HostageInfo *info = &m_hostage[i]; - const Vector *hostagePos = NULL; + const Vector *hostagePos = nullptr; if (m_owner->m_iTeam == CT) { @@ -422,7 +420,7 @@ const Vector *CSGameState::GetRandomFreeHostagePosition() return freePos[RANDOM_LONG(0, freeCount - 1)]; } - return NULL; + return nullptr; } // If we can see any of the positions where we think a hostage is, validate it @@ -437,17 +435,17 @@ CSGameState::ValidateStatusType CSGameState::ValidateHostagePositions() m_validateInterval.Start(validateInterval); // check the status of hostages - ValidateStatusType status = NO_CHANGE; + unsigned char status = NO_CHANGE; int i; int startValidCount = 0; - for (i = 0; i < m_hostageCount; ++i) + for (i = 0; i < m_hostageCount; i++) { if (m_hostage[i].isValid) - ++startValidCount; + startValidCount++; } - for (i = 0; i < m_hostageCount; ++i) + for (i = 0; i < m_hostageCount; i++) { HostageInfo *info = &m_hostage[i]; @@ -525,10 +523,10 @@ CSGameState::ValidateStatusType CSGameState::ValidateHostagePositions() } int endValidCount = 0; - for (i = 0; i < m_hostageCount; ++i) + for (i = 0; i < m_hostageCount; i++) { if (m_hostage[i].isValid) - ++endValidCount; + endValidCount++; } if (endValidCount == 0 && startValidCount > 0) @@ -538,20 +536,20 @@ CSGameState::ValidateStatusType CSGameState::ValidateHostagePositions() status |= HOSTAGES_ALL_GONE; } - return status; + return static_cast(status); } // Return the nearest visible free hostage // Since we can actually see any hostage we return, we know its actual position CHostage *CSGameState::GetNearestVisibleFreeHostage() const { - CHostage *close = NULL; + CHostage *close = nullptr; float closeRangeSq = 999999999.9f; float rangeSq; Vector pos; - for (int i = 0; i < m_hostageCount; ++i) + for (int i = 0; i < m_hostageCount; i++) { const HostageInfo *info = &m_hostage[i]; @@ -591,7 +589,7 @@ bool CSGameState::AreAllHostagesBeingRescued() const return false; bool isAllDead = true; - for (int i = 0; i < m_hostageCount; ++i) + for (int i = 0; i < m_hostageCount; i++) { const HostageInfo *info = &m_hostage[i]; @@ -630,7 +628,7 @@ bool CSGameState::AreAllHostagesGone() const return true; // do we know that all the hostages are dead - for (int i = 0; i < m_hostageCount; ++i) + for (int i = 0; i < m_hostageCount; i++) { const HostageInfo *info = &m_hostage[i]; @@ -653,6 +651,6 @@ bool CSGameState::AreAllHostagesGone() const // Someone told us all the hostages are gone void CSGameState::AllHostagesGone() { - for (int i = 0; i < m_hostageCount; ++i) + for (int i = 0; i < m_hostageCount; i++) m_hostage[i].isValid = false; } diff --git a/regamedll/dlls/bot/cs_gamestate.h b/regamedll/dlls/bot/cs_gamestate.h index 35a72c97..5dfd40d5 100644 --- a/regamedll/dlls/bot/cs_gamestate.h +++ b/regamedll/dlls/bot/cs_gamestate.h @@ -26,11 +26,7 @@ * */ -#ifndef CS_GAMESTATE_H -#define CS_GAMESTATE_H -#ifdef _WIN32 #pragma once -#endif class CCSBot; @@ -94,7 +90,7 @@ public: CHostage *GetNearestVisibleFreeHostage() const; // hostage rescue scenario - enum ValidateStatusType:uint8 + enum ValidateStatusType : uint8 { NO_CHANGE = 0x00, HOSTAGE_DIED = 0x01, @@ -147,5 +143,3 @@ private: bool m_allHostagesRescued; // if true, so every hostages been is rescued bool m_haveSomeHostagesBeenTaken; // true if a hostage has been moved by a CT (and we've seen it) }; - -#endif // CS_GAMESTATE_H diff --git a/regamedll/dlls/bot/states/cs_bot_attack.cpp b/regamedll/dlls/bot/states/cs_bot_attack.cpp index b23530dc..42e88487 100644 --- a/regamedll/dlls/bot/states/cs_bot_attack.cpp +++ b/regamedll/dlls/bot/states/cs_bot_attack.cpp @@ -3,14 +3,14 @@ // Begin attacking void AttackState::OnEnter(CCSBot *me) { - CBasePlayer *enemy = me->GetEnemy(); + CBasePlayer *pEnemy = me->GetEnemy(); // store our posture when the attack began me->PushPostureContext(); me->DestroyPath(); // if we are using a knife, try to sneak up on the enemy - if (enemy != NULL && me->IsUsingKnife() && !me->IsPlayerFacingMe(enemy)) + if (pEnemy && me->IsUsingKnife() && !me->IsPlayerFacingMe(pEnemy)) me->Walk(); else me->Run(); @@ -44,7 +44,7 @@ void AttackState::OnEnter(CCSBot *me) // decide whether to crouch where we are, or run and gun (if we havent already - see CCSBot::Attack()) if (!m_crouchAndHold) { - if (enemy != NULL) + if (pEnemy) { const float crouchFarRange = 750.0f; float crouchChance; @@ -52,7 +52,7 @@ void AttackState::OnEnter(CCSBot *me) // more likely to crouch if using sniper rifle or if enemy is far away if (me->IsUsingSniperRifle()) crouchChance = 50.0f; - else if ((me->pev->origin - enemy->pev->origin).IsLengthGreaterThan(crouchFarRange)) + else if ((me->pev->origin - pEnemy->pev->origin).IsLengthGreaterThan(crouchFarRange)) crouchChance = 50.0f; else crouchChance = 20.0f * (1.0f - me->GetProfile()->GetAggression()); @@ -69,7 +69,7 @@ void AttackState::OnEnter(CCSBot *me) origin.z -= 20.0f; } - UTIL_TraceLine(origin, enemy->EyePosition(), ignore_monsters, ignore_glass, ENT(me->pev), &result); + UTIL_TraceLine(origin, pEnemy->EyePosition(), ignore_monsters, ignore_glass, ENT(me->pev), &result); if (result.flFraction == 1.0f) { @@ -131,20 +131,20 @@ void AttackState::OnUpdate(CCSBot *me) me->ResetStuckMonitor(); me->StopRapidFire(); - CBasePlayerWeapon *weapon = me->GetActiveWeapon(); - if (weapon != NULL) + CBasePlayerWeapon *pWeapon = me->GetActiveWeapon(); + if (pWeapon) { - if (weapon->m_iId == WEAPON_C4 || - weapon->m_iId == WEAPON_HEGRENADE || - weapon->m_iId == WEAPON_FLASHBANG || - weapon->m_iId == WEAPON_SMOKEGRENADE) + if (pWeapon->m_iId == WEAPON_C4 || + pWeapon->m_iId == WEAPON_HEGRENADE || + pWeapon->m_iId == WEAPON_FLASHBANG || + pWeapon->m_iId == WEAPON_SMOKEGRENADE) { me->EquipBestWeapon(); } } - CBasePlayer *enemy = me->GetEnemy(); - if (enemy == NULL) + CBasePlayer *pEnemy = me->GetEnemy(); + if (!pEnemy) { StopAttacking(me); return; @@ -200,7 +200,7 @@ void AttackState::OnUpdate(CCSBot *me) me->StandUp(); // if we are using a knife and our prey is looking towards us, run at him - if (me->IsPlayerFacingMe(enemy)) + if (me->IsPlayerFacingMe(pEnemy)) { me->ForceRun(5.0f); me->Hurry(10.0f); @@ -218,7 +218,7 @@ void AttackState::OnUpdate(CCSBot *me) if (me->HasPath()) { const float repathRange = 100.0f; - if ((me->GetPathEndpoint() - enemy->pev->origin).IsLengthGreaterThan(repathRange)) + if ((me->GetPathEndpoint() - pEnemy->pev->origin).IsLengthGreaterThan(repathRange)) { repath = true; } @@ -230,7 +230,7 @@ void AttackState::OnUpdate(CCSBot *me) if (repath && m_repathTimer.IsElapsed()) { - me->ComputePath(TheNavAreaGrid.GetNearestNavArea(&enemy->pev->origin), &enemy->pev->origin, FASTEST_ROUTE); + me->ComputePath(TheNavAreaGrid.GetNearestNavArea(&pEnemy->pev->origin), &pEnemy->pev->origin, FASTEST_ROUTE); const float repathInterval = 0.5f; m_repathTimer.Start(repathInterval); @@ -250,7 +250,7 @@ void AttackState::OnUpdate(CCSBot *me) { if (me->IsEnemyVisible() && !m_shieldForceOpen) { - if (!me->IsRecognizedEnemyReloading() && !me->IsReloading() && me->IsPlayerLookingAtMe(enemy)) + if (!me->IsRecognizedEnemyReloading() && !me->IsReloading() && me->IsPlayerLookingAtMe(pEnemy)) { // close up - enemy is pointing his gun at us if (!me->IsProtectedByShield()) @@ -285,14 +285,14 @@ void AttackState::OnUpdate(CCSBot *me) // if we have a sniper rifle and our enemy is too close, switch to pistol // NOTE: Must be larger than NO_ZOOM range in AdjustZoom() const float sniperMinRange = 310.0f; - if ((enemy->pev->origin - me->pev->origin).IsLengthLessThan(sniperMinRange)) + if ((pEnemy->pev->origin - me->pev->origin).IsLengthLessThan(sniperMinRange)) me->EquipPistol(); } else if (me->IsUsingShotgun()) { // if we have a shotgun equipped and enemy is too far away, switch to pistol const float shotgunMaxRange = 1000.0f; - if ((enemy->pev->origin - me->pev->origin).IsLengthGreaterThan(shotgunMaxRange)) + if ((pEnemy->pev->origin - me->pev->origin).IsLengthGreaterThan(shotgunMaxRange)) me->EquipPistol(); } @@ -325,9 +325,9 @@ void AttackState::OnUpdate(CCSBot *me) if (me->IsAwareOfEnemyDeath()) { // let team know if we killed the last enemy - if (me->GetLastVictimID() == enemy->entindex() && me->GetNearbyEnemyCount() <= 1) + if (me->GetLastVictimID() == pEnemy->entindex() && me->GetNearbyEnemyCount() <= 1) { - me->GetChatter()->KilledMyEnemy(enemy->entindex()); + me->GetChatter()->KilledMyEnemy(pEnemy->entindex()); } StopAttacking(me); @@ -372,7 +372,7 @@ void AttackState::OnUpdate(CCSBot *me) // hide in ambush nearby // TODO: look towards where we know enemy is const Vector *spot = FindNearbyRetreatSpot(me, 200.0f); - if (spot != NULL) + if (spot) { me->IgnoreEnemies(1.0f); me->Run(); @@ -430,7 +430,7 @@ void AttackState::OnUpdate(CCSBot *me) else { // move to last known position of enemy - me->SetTask(CCSBot::MOVE_TO_LAST_KNOWN_ENEMY_POSITION, enemy); + me->SetTask(CCSBot::MOVE_TO_LAST_KNOWN_ENEMY_POSITION, pEnemy); me->MoveTo(&me->GetLastKnownEnemyPosition()); return; } @@ -441,7 +441,7 @@ void AttackState::OnUpdate(CCSBot *me) const float hurtRecentlyTime = 3.0f; if (!me->IsEnemyVisible() && me->GetTimeSinceAttacked() < hurtRecentlyTime && - me->GetAttacker() != NULL && + me->GetAttacker() && me->GetAttacker() != me->GetEnemy()) { // if we can see them, attack, otherwise panic @@ -460,7 +460,7 @@ void AttackState::OnUpdate(CCSBot *me) // If sniping or crouching, stand still. if (m_dodge && !me->IsUsingSniperRifle() && !m_crouchAndHold) { - Vector toEnemy = enemy->pev->origin - me->pev->origin; + Vector toEnemy = pEnemy->pev->origin - me->pev->origin; float range = toEnemy.Length2D(); const float hysterisRange = 125.0f; // (+/-) m_combatRange @@ -479,7 +479,7 @@ void AttackState::OnUpdate(CCSBot *me) // don't dodge if enemy is facing away const float dodgeRange = 2000.0f; - if (range > dodgeRange || !me->IsPlayerFacingMe(enemy)) + if (range > dodgeRange || !me->IsPlayerFacingMe(pEnemy)) { m_dodgeState = STEADY_ON; m_nextDodgeStateTimestamp = 0.0f; diff --git a/regamedll/dlls/bot/states/cs_bot_buy.cpp b/regamedll/dlls/bot/states/cs_bot_buy.cpp index 29e75540..594ff06e 100644 --- a/regamedll/dlls/bot/states/cs_bot_buy.cpp +++ b/regamedll/dlls/bot/states/cs_bot_buy.cpp @@ -2,15 +2,15 @@ bool HasDefaultPistol(CCSBot *me) { - CBasePlayerWeapon *pistol = static_cast(me->m_rgpPlayerItems[ PISTOL_SLOT ]); + CBasePlayerWeapon *pSecondary = static_cast(me->m_rgpPlayerItems[ PISTOL_SLOT ]); - if (pistol == NULL) + if (!pSecondary) return false; - if (me->m_iTeam == TERRORIST && pistol->m_iId == WEAPON_GLOCK18) + if (me->m_iTeam == TERRORIST && pSecondary->m_iId == WEAPON_GLOCK18) return true; - if (me->m_iTeam == CT && pistol->m_iId == WEAPON_USP) + if (me->m_iTeam == CT && pSecondary->m_iId == WEAPON_USP) return true; return false; @@ -73,21 +73,21 @@ void BuyState::OnEnter(CCSBot *me) if (TheCSBots()->AllowPistols()) { - CBasePlayerWeapon *pistol = static_cast(me->m_rgpPlayerItems[ PISTOL_SLOT ]); + CBasePlayerWeapon *pSecondary = static_cast(me->m_rgpPlayerItems[ PISTOL_SLOT ]); // check if we have a pistol - if (pistol != NULL) + if (pSecondary) { // if we have our default pistol, think about buying a different one if (HasDefaultPistol(me)) { // if everything other than pistols is disallowed, buy a pistol - if (TheCSBots()->AllowShotguns() == false && - TheCSBots()->AllowSubMachineGuns() == false && - TheCSBots()->AllowRifles() == false && - TheCSBots()->AllowMachineGuns() == false && - TheCSBots()->AllowTacticalShield() == false && - TheCSBots()->AllowSnipers() == false) + if (!TheCSBots()->AllowShotguns() + && !TheCSBots()->AllowSubMachineGuns() + && !TheCSBots()->AllowRifles() + && !TheCSBots()->AllowMachineGuns() + && !TheCSBots()->AllowTacticalShield() + && !TheCSBots()->AllowSnipers()) { m_buyPistol = (RANDOM_FLOAT(0, 100) < 75.0f); } @@ -133,7 +133,7 @@ struct BuyInfo #ifndef HOOK_GAMEDLL -BuyInfo primaryWeaponBuyInfoCT[ PRIMARY_WEAPON_BUY_COUNT ] = +BuyInfo primaryWeaponBuyInfoCT[ MAX_BUY_WEAPON_PRIMARY ] = { { SHOTGUN, false, "m3" }, // WEAPON_M3 { SHOTGUN, false, "xm1014" }, // WEAPON_XM1014 @@ -150,7 +150,7 @@ BuyInfo primaryWeaponBuyInfoCT[ PRIMARY_WEAPON_BUY_COUNT ] = { MACHINE_GUN, false, "m249" }, // WEAPON_M249 }; -BuyInfo secondaryWeaponBuyInfoCT[ SECONDARY_WEAPON_BUY_COUNT ] = +BuyInfo secondaryWeaponBuyInfoCT[ MAX_BUY_WEAPON_SECONDARY ] = { // { PISTOL, false, "glock" }, // { PISTOL, false, "usp" }, @@ -159,7 +159,7 @@ BuyInfo secondaryWeaponBuyInfoCT[ SECONDARY_WEAPON_BUY_COUNT ] = { PISTOL, true, "fn57" }, }; -BuyInfo primaryWeaponBuyInfoT[ PRIMARY_WEAPON_BUY_COUNT ] = +BuyInfo primaryWeaponBuyInfoT[ MAX_BUY_WEAPON_PRIMARY ] = { { SHOTGUN, false, "m3" }, // WEAPON_M3 { SHOTGUN, false, "xm1014" }, // WEAPON_XM1014 @@ -176,7 +176,7 @@ BuyInfo primaryWeaponBuyInfoT[ PRIMARY_WEAPON_BUY_COUNT ] = { MACHINE_GUN, false, "m249" }, // WEAPON_M249 }; -BuyInfo secondaryWeaponBuyInfoT[ SECONDARY_WEAPON_BUY_COUNT ] = +BuyInfo secondaryWeaponBuyInfoT[ MAX_BUY_WEAPON_SECONDARY ] = { // { PISTOL, false, "glock" }, // { PISTOL, false, "usp" }, @@ -187,11 +187,11 @@ BuyInfo secondaryWeaponBuyInfoT[ SECONDARY_WEAPON_BUY_COUNT ] = #else // HOOK_GAMEDLL -BuyInfo primaryWeaponBuyInfoCT[ PRIMARY_WEAPON_BUY_COUNT ]; -BuyInfo secondaryWeaponBuyInfoCT[ SECONDARY_WEAPON_BUY_COUNT]; +BuyInfo primaryWeaponBuyInfoCT[ MAX_BUY_WEAPON_PRIMARY ]; +BuyInfo secondaryWeaponBuyInfoCT[ MAX_BUY_WEAPON_SECONDARY]; -BuyInfo primaryWeaponBuyInfoT[ PRIMARY_WEAPON_BUY_COUNT ]; -BuyInfo secondaryWeaponBuyInfoT[ SECONDARY_WEAPON_BUY_COUNT ]; +BuyInfo primaryWeaponBuyInfoT[ MAX_BUY_WEAPON_PRIMARY ]; +BuyInfo secondaryWeaponBuyInfoT[ MAX_BUY_WEAPON_SECONDARY ]; #endif // HOOK_GAMEDLL @@ -199,7 +199,7 @@ BuyInfo secondaryWeaponBuyInfoT[ SECONDARY_WEAPON_BUY_COUNT ]; inline WeaponType GetWeaponType(const char *alias) { int i; - for (i = 0; i < PRIMARY_WEAPON_BUY_COUNT; ++i) + for (i = 0; i < MAX_BUY_WEAPON_PRIMARY; i++) { if (!Q_stricmp(alias, primaryWeaponBuyInfoCT[i].buyAlias)) return primaryWeaponBuyInfoCT[i].type; @@ -208,7 +208,7 @@ inline WeaponType GetWeaponType(const char *alias) return primaryWeaponBuyInfoT[i].type; } - for (i = 0; i < SECONDARY_WEAPON_BUY_COUNT; ++i) + for (i = 0; i < MAX_BUY_WEAPON_SECONDARY; i++) { if (!Q_stricmp(alias, secondaryWeaponBuyInfoCT[i].buyAlias)) return secondaryWeaponBuyInfoCT[i].type; @@ -281,7 +281,7 @@ void BuyState::OnUpdate(CCSBot *me) if (m_prefRetries >= maxPrefRetries) { // try to buy next preferred weapon - ++m_prefIndex; + m_prefIndex++; m_prefRetries = 0; return; } @@ -289,8 +289,8 @@ void BuyState::OnUpdate(CCSBot *me) int weaponPreference = me->GetProfile()->GetWeaponPreference(m_prefIndex); // don't buy it again if we still have one from last round - CBasePlayerWeapon *weapon = me->GetActiveWeapon(); - if (weapon != NULL && weapon->m_iId == weaponPreference) + CBasePlayerWeapon *pCurrentWeapon = me->GetActiveWeapon(); + if (pCurrentWeapon && pCurrentWeapon->m_iId == weaponPreference) { // done with buying preferred weapon m_prefIndex = 9999; @@ -304,8 +304,7 @@ void BuyState::OnUpdate(CCSBot *me) return; } - const char *buyAlias = NULL; - + const char *buyAlias = nullptr; if (weaponPreference == WEAPON_SHIELDGUN) { if (TheCSBots()->AllowTacticalShield()) @@ -320,27 +319,27 @@ void BuyState::OnUpdate(CCSBot *me) { case PISTOL: if (!TheCSBots()->AllowPistols()) - buyAlias = NULL; + buyAlias = nullptr; break; case SHOTGUN: if (!TheCSBots()->AllowShotguns()) - buyAlias = NULL; + buyAlias = nullptr; break; case SUB_MACHINE_GUN: if (!TheCSBots()->AllowSubMachineGuns()) - buyAlias = NULL; + buyAlias = nullptr; break; case RIFLE: if (!TheCSBots()->AllowRifles()) - buyAlias = NULL; + buyAlias = nullptr; break; case MACHINE_GUN: if (!TheCSBots()->AllowMachineGuns()) - buyAlias = NULL; + buyAlias = nullptr; break; case SNIPER_RIFLE: if (!TheCSBots()->AllowSnipers()) - buyAlias = NULL; + buyAlias = nullptr; break; } } @@ -353,7 +352,7 @@ void BuyState::OnUpdate(CCSBot *me) isPreferredAllDisallowed = false; } - ++m_prefRetries; + m_prefRetries++; // bail out so we dont waste money on other equipment // unless everything we prefer has been disallowed, then buy at random @@ -374,14 +373,14 @@ void BuyState::OnUpdate(CCSBot *me) { // build list of allowable weapons to buy BuyInfo *masterPrimary = (me->m_iTeam == TERRORIST) ? primaryWeaponBuyInfoT : primaryWeaponBuyInfoCT; - BuyInfo *stockPrimary[ PRIMARY_WEAPON_BUY_COUNT ]; + BuyInfo *stockPrimary[ MAX_BUY_WEAPON_PRIMARY ]; int stockPrimaryCount = 0; // dont choose sniper rifles as often const float sniperRifleChance = 50.0f; bool wantSniper = (RANDOM_FLOAT(0, 100) < sniperRifleChance) ? true : false; - for (int i = 0; i < PRIMARY_WEAPON_BUY_COUNT; ++i) + for (int i = 0; i < MAX_BUY_WEAPON_PRIMARY; i++) { if ((masterPrimary[i].type == SHOTGUN && TheCSBots()->AllowShotguns()) || (masterPrimary[i].type == SUB_MACHINE_GUN && TheCSBots()->AllowSubMachineGuns()) || @@ -403,16 +402,16 @@ void BuyState::OnUpdate(CCSBot *me) { // count up available preferred weapons int prefCount = 0; - for (which = 0; which < stockPrimaryCount; ++which) + for (which = 0; which < stockPrimaryCount; which++) { if (stockPrimary[which]->preferred) - ++prefCount; + prefCount++; } if (prefCount) { int whichPref = RANDOM_LONG(0, prefCount - 1); - for (which = 0; which < stockPrimaryCount; ++which) + for (which = 0; which < stockPrimaryCount; which++) { if (stockPrimary[which]->preferred && whichPref-- == 0) break; @@ -453,7 +452,7 @@ void BuyState::OnUpdate(CCSBot *me) { if (m_buyPistol) { - int which = RANDOM_LONG(0, SECONDARY_WEAPON_BUY_COUNT - 1); + int which = RANDOM_LONG(0, MAX_BUY_WEAPON_SECONDARY - 1); if (me->m_iTeam == TERRORIST) me->ClientCommand(secondaryWeaponBuyInfoT[ which ].buyAlias); diff --git a/regamedll/dlls/bot/states/cs_bot_escape_from_bomb.cpp b/regamedll/dlls/bot/states/cs_bot_escape_from_bomb.cpp index 86d9485b..81d7bd99 100644 --- a/regamedll/dlls/bot/states/cs_bot_escape_from_bomb.cpp +++ b/regamedll/dlls/bot/states/cs_bot_escape_from_bomb.cpp @@ -14,7 +14,7 @@ void EscapeFromBombState::OnUpdate(CCSBot *me) const Vector *bombPos = me->GetGameState()->GetBombPosition(); // if we don't know where the bomb is, we shouldn't be in this state - if (bombPos == NULL) + if (!bombPos) { me->Idle(); return; @@ -33,7 +33,7 @@ void EscapeFromBombState::OnUpdate(CCSBot *me) CNavArea *goalArea = FindMinimumCostArea(me->GetLastKnownArea(), func); // if this fails, we'll try again next time - me->ComputePath(goalArea, NULL, FASTEST_ROUTE); + me->ComputePath(goalArea, nullptr, FASTEST_ROUTE); } } diff --git a/regamedll/dlls/bot/states/cs_bot_fetch_bomb.cpp b/regamedll/dlls/bot/states/cs_bot_fetch_bomb.cpp index f92f2970..2b8283de 100644 --- a/regamedll/dlls/bot/states/cs_bot_fetch_bomb.cpp +++ b/regamedll/dlls/bot/states/cs_bot_fetch_bomb.cpp @@ -16,13 +16,13 @@ void FetchBombState::OnUpdate(CCSBot *me) return; } - CBaseEntity *bomb = TheCSBots()->GetLooseBomb(); - if (bomb != NULL) + CBaseEntity *pBomb = TheCSBots()->GetLooseBomb(); + if (pBomb) { if (!me->HasPath()) { // build a path to the bomb - if (me->ComputePath(TheNavAreaGrid.GetNavArea(&bomb->pev->origin), &bomb->pev->origin, SAFEST_ROUTE) == false) + if (me->ComputePath(TheNavAreaGrid.GetNavArea(&pBomb->pev->origin), &pBomb->pev->origin, SAFEST_ROUTE) == false) { me->PrintIfWatched("Fetch bomb pathfind failed\n"); diff --git a/regamedll/dlls/bot/states/cs_bot_follow.cpp b/regamedll/dlls/bot/states/cs_bot_follow.cpp index 543da325..055838bd 100644 --- a/regamedll/dlls/bot/states/cs_bot_follow.cpp +++ b/regamedll/dlls/bot/states/cs_bot_follow.cpp @@ -75,7 +75,7 @@ void FollowState::ComputeLeaderMotionState(float leaderSpeed) void FollowState::OnUpdate(CCSBot *me) { // if we lost our leader, give up - if (m_leader == NULL || !m_leader->IsAlive()) + if (!m_leader || !m_leader->IsAlive()) { me->Idle(); return; @@ -159,7 +159,7 @@ void FollowState::OnUpdate(CCSBot *me) if ((m_leader->pev->origin - me->pev->origin).IsLengthLessThan(nearLeaderRange)) { const float hideRange = 250.0f; - if (me->TryToHide(NULL, -1.0f, hideRange, false, USE_NEAREST)) + if (me->TryToHide(nullptr, -1.0f, hideRange, false, USE_NEAREST)) { me->ResetStuckMonitor(); return; @@ -203,14 +203,14 @@ void FollowState::OnUpdate(CCSBot *me) if (cv_bot_debug.value > 0.0f) { - for (int i = 0; i < collector.m_targetAreaCount; ++i) + for (int i = 0; i < collector.m_targetAreaCount; i++) collector.m_targetArea[i]->Draw(255, 0, 0, 2); } // move to one of the collected areas if (collector.m_targetAreaCount) { - CNavArea *target = NULL; + CNavArea *target = nullptr; Vector targetPos; // if we are idle, pick a random area @@ -229,7 +229,7 @@ void FollowState::OnUpdate(CCSBot *me) float closeRangeSq = 9999999999.9f; Vector close; - for (int a = 0; a < collector.m_targetAreaCount; ++a) + for (int a = 0; a < collector.m_targetAreaCount; a++) { area = collector.m_targetArea[a]; area->GetClosestPointOnArea(&me->pev->origin, &close); @@ -244,8 +244,10 @@ void FollowState::OnUpdate(CCSBot *me) } } - if (me->ComputePath(target, NULL, FASTEST_ROUTE) == NULL) + if (!me->ComputePath(target, nullptr, FASTEST_ROUTE)) + { me->PrintIfWatched("Pathfind to leader failed.\n"); + } // throttle how often we repath m_repathInterval.Start(0.5f); diff --git a/regamedll/dlls/bot/states/cs_bot_hide.cpp b/regamedll/dlls/bot/states/cs_bot_hide.cpp index 828ea44d..2cf631d6 100644 --- a/regamedll/dlls/bot/states/cs_bot_hide.cpp +++ b/regamedll/dlls/bot/states/cs_bot_hide.cpp @@ -57,10 +57,10 @@ void HideState::OnUpdate(CCSBot *me) { // if we're guarding a bombsite, continue to guard it but pick a new spot const CCSBotManager::Zone *zone = TheCSBots()->GetClosestZone(&me->pev->origin); - if (zone != NULL) + if (zone) { CNavArea *area = TheCSBots()->GetRandomAreaInZone(zone); - if (area != NULL) + if (area) { me->Hide(area); return; @@ -127,14 +127,14 @@ void HideState::OnUpdate(CCSBot *me) } // if we are guarding the defuser and he dies/gives up, stop hiding (to choose another defuser) - if (me->GetTask() == CCSBot::GUARD_BOMB_DEFUSER && TheCSBots()->GetBombDefuser() == NULL) + if (me->GetTask() == CCSBot::GUARD_BOMB_DEFUSER && !TheCSBots()->GetBombDefuser()) { me->Idle(); return; } // if we are guarding the loose bomb and it is picked up, stop hiding - if (me->GetTask() == CCSBot::GUARD_LOOSE_BOMB && TheCSBots()->GetLooseBomb() == NULL) + if (me->GetTask() == CCSBot::GUARD_LOOSE_BOMB && !TheCSBots()->GetLooseBomb()) { me->GetChatter()->TheyPickedUpTheBomb(); me->Idle(); @@ -197,12 +197,12 @@ void HideState::OnUpdate(CCSBot *me) else if (me->GetTask() == CCSBot::GUARD_HOSTAGE_RESCUE_ZONE) { // if we stumble across a hostage, guard it - CHostage *hostage = me->GetGameState()->GetNearestVisibleFreeHostage(); - if (hostage != NULL) + CHostage *pHostage = me->GetGameState()->GetNearestVisibleFreeHostage(); + if (pHostage) { // we see a free hostage, guard it - CNavArea *area = TheNavAreaGrid.GetNearestNavArea(&hostage->pev->origin); - if (area != NULL) + CNavArea *area = TheNavAreaGrid.GetNearestNavArea(&pHostage->pev->origin); + if (area) { me->SetTask(CCSBot::GUARD_HOSTAGES); me->Hide(area); @@ -300,8 +300,8 @@ void HideState::OnUpdate(CCSBot *me) { if (me->GetNearbyEnemyCount() == 0) { - CHostage *hostage = me->GetGameState()->GetNearestVisibleFreeHostage(); - if (hostage != NULL) + CHostage *pHostage = me->GetGameState()->GetNearestVisibleFreeHostage(); + if (pHostage) { me->GetChatter()->Encourage("WaitingForHumanToRescueHostages", RANDOM_FLOAT(10.0f, 15.0f)); } @@ -314,10 +314,10 @@ void HideState::OnUpdate(CCSBot *me) { // if a Player is using this hiding spot, give up float range; - CBasePlayer *camper = UTIL_GetClosestPlayer(&m_hidingSpot, &range); + CBasePlayer *pCamper = UTIL_GetClosestPlayer(&m_hidingSpot, &range); const float closeRange = 75.0f; - if (camper != NULL && camper != me && range < closeRange && me->IsVisible(camper, CHECK_FOV)) + if (pCamper && pCamper != me && range < closeRange && me->IsVisible(pCamper, CHECK_FOV)) { // player is in our hiding spot me->PrintIfWatched("Someone's in my hiding spot - picking another...\n"); @@ -389,7 +389,7 @@ void HideState::OnUpdate(CCSBot *me) // search from hiding spot, since we know it was valid const Vector *pos = FindNearbyHidingSpot(me, &m_hidingSpot, m_searchFromArea, m_range, me->IsSniper()); - if (pos == NULL) + if (!pos) { // no available hiding spots me->PrintIfWatched("No available hiding spots - hiding where I'm at.\n"); diff --git a/regamedll/dlls/bot/states/cs_bot_hunt.cpp b/regamedll/dlls/bot/states/cs_bot_hunt.cpp index 4b930a92..0f0c7c05 100644 --- a/regamedll/dlls/bot/states/cs_bot_hunt.cpp +++ b/regamedll/dlls/bot/states/cs_bot_hunt.cpp @@ -55,7 +55,7 @@ void HuntState::OnUpdate(CCSBot *me) // if bomb has been planted, and we hear it, move to a hiding spot near the bomb and watch it const Vector *bombPos = me->GetGameState()->GetBombPosition(); - if (!me->IsRogue() && me->GetGameState()->IsBombPlanted() && bombPos != NULL) + if (!me->IsRogue() && me->GetGameState()->IsBombPlanted() && bombPos) { me->SetTask(CCSBot::GUARD_TICKING_BOMB); me->Hide(TheNavAreaGrid.GetNavArea(bombPos)); @@ -105,11 +105,11 @@ void HuntState::OnUpdate(CCSBot *me) // if safe time is up, and we stumble across a hostage, guard it if (!me->IsRogue() && !me->IsSafe()) { - CHostage *hostage = me->GetGameState()->GetNearestVisibleFreeHostage(); - if (hostage != NULL) + CHostage *pHostage = me->GetGameState()->GetNearestVisibleFreeHostage(); + if (pHostage) { - CNavArea *area = TheNavAreaGrid.GetNearestNavArea(&hostage->pev->origin); - if (area != NULL) + CNavArea *area = TheNavAreaGrid.GetNearestNavArea(&pHostage->pev->origin); + if (area) { // we see a free hostage, guard it me->SetTask(CCSBot::GUARD_HOSTAGES); @@ -137,19 +137,14 @@ void HuntState::OnUpdate(CCSBot *me) // if our path fails, pick a new one if (me->GetLastKnownArea() == m_huntArea || me->UpdatePathMovement() != CCSBot::PROGRESSING) { - m_huntArea = NULL; + m_huntArea = nullptr; float oldest = 0.0f; int areaCount = 0; const float minSize = 150.0f; - - NavAreaList::iterator iter; - - for (iter = TheNavAreaList.begin(); iter != TheNavAreaList.end(); ++iter) + for (auto area : TheNavAreaList) { - CNavArea *area = (*iter); - - ++areaCount; + areaCount++; // skip the small areas const Extent *extent = area->GetExtent(); @@ -169,20 +164,20 @@ void HuntState::OnUpdate(CCSBot *me) int which = RANDOM_LONG(0, areaCount - 1); areaCount = 0; - for (iter = TheNavAreaList.begin(); iter != TheNavAreaList.end(); ++iter) + for (auto area : TheNavAreaList) { - m_huntArea = (*iter); + m_huntArea = area; if (which == areaCount) break; - --which; + which--; } - if (m_huntArea != NULL) + if (m_huntArea) { // create a new path to a far away area of the map - me->ComputePath(m_huntArea, NULL, SAFEST_ROUTE); + me->ComputePath(m_huntArea, nullptr, SAFEST_ROUTE); } } } diff --git a/regamedll/dlls/bot/states/cs_bot_idle.cpp b/regamedll/dlls/bot/states/cs_bot_idle.cpp index fdb0977c..28db6c2e 100644 --- a/regamedll/dlls/bot/states/cs_bot_idle.cpp +++ b/regamedll/dlls/bot/states/cs_bot_idle.cpp @@ -9,7 +9,7 @@ const float sniperHideRange = 2000.0f; void IdleState::OnEnter(CCSBot *me) { me->DestroyPath(); - me->SetEnemy(NULL); + me->SetEnemy(nullptr); // lurking death if (me->IsUsingKnife() && me->IsWellPastSafe() && !me->IsHurrying()) @@ -192,7 +192,7 @@ void IdleState::OnUpdate(CCSBot *me) } // if bomb has been planted, and we hear it, move to a hiding spot near the bomb and guard it - if (!me->IsRogue() && me->GetGameState()->IsBombPlanted() && me->GetGameState()->GetBombPosition() != NULL) + if (!me->IsRogue() && me->GetGameState()->IsBombPlanted() && me->GetGameState()->GetBombPosition()) { const Vector *bombPos = me->GetGameState()->GetBombPosition(); @@ -271,7 +271,7 @@ void IdleState::OnUpdate(CCSBot *me) const CCSBotManager::Zone *zone = nullptr; float travelDistance = 9999999.9f; - for (int z = 0; z < TheCSBots()->GetZoneCount(); ++z) + for (int z = 0; z < TheCSBots()->GetZoneCount(); z++) { if (TheCSBots()->GetZone(z)->m_areaCount == 0) continue; @@ -333,7 +333,7 @@ void IdleState::OnUpdate(CCSBot *me) { if (RANDOM_FLOAT(0, 100) <= defenseSniperCampChance) { - CNavArea *snipingArea = NULL; + CNavArea *snipingArea = nullptr; // if the bomb is loose, snipe near it if (me->GetGameState()->IsLooseBombLocationKnown()) @@ -463,7 +463,7 @@ void IdleState::OnUpdate(CCSBot *me) { // if early in round, pick a random zone, otherwise pick closest zone const float earlyTime = 20.0f; - const CCSBotManager::Zone *zone = NULL; + const CCSBotManager::Zone *zone = nullptr; if (TheCSBots()->GetElapsedRoundTime() < earlyTime) { @@ -563,11 +563,11 @@ void IdleState::OnUpdate(CCSBot *me) // if safe time is up, and we stumble across a hostage, guard it if (!me->IsSafe() && !me->IsRogue()) { - CBaseEntity *hostage = me->GetGameState()->GetNearestVisibleFreeHostage(); - if (hostage) + CBaseEntity *pHostage = me->GetGameState()->GetNearestVisibleFreeHostage(); + if (pHostage) { // we see a free hostage, guard it - CNavArea *area = TheNavAreaGrid.GetNearestNavArea(&hostage->pev->origin); + CNavArea *area = TheNavAreaGrid.GetNearestNavArea(&pHostage->pev->origin); if (area) { me->SetTask(CCSBot::GUARD_HOSTAGES); @@ -655,14 +655,14 @@ void IdleState::OnUpdate(CCSBot *me) } // look for free hostages - CT's have radar so they know where hostages are at all times - CHostage *hostage = me->GetGameState()->GetNearestFreeHostage(); + CHostage *pHostage = me->GetGameState()->GetNearestFreeHostage(); // if we are not allowed to do the scenario, guard the hostages to clear the area for the human(s) if (!me->IsDoingScenario()) { - if (hostage) + if (pHostage) { - CNavArea *area = TheNavAreaGrid.GetNearestNavArea(&hostage->pev->origin); + CNavArea *area = TheNavAreaGrid.GetNearestNavArea(&pHostage->pev->origin); if (area) { me->SetTask(CCSBot::GUARD_HOSTAGES); @@ -678,8 +678,8 @@ void IdleState::OnUpdate(CCSBot *me) bool fetchHostages = false; bool rescueHostages = false; - const CCSBotManager::Zone *zone = NULL; - me->SetGoalEntity(NULL); + const CCSBotManager::Zone *zone = nullptr; + me->SetGoalEntity(nullptr); // if we are escorting hostages, determine where to take them if (me->GetHostageEscortCount()) @@ -687,13 +687,13 @@ void IdleState::OnUpdate(CCSBot *me) // if we are escorting hostages and there are more hostages to rescue, // determine whether it's faster to rescue the ones we have, or go get the remaining ones - if (hostage) + if (pHostage) { if (zone) { PathCost pathCost(me, FASTEST_ROUTE); float toZone = NavAreaTravelDistance(me->GetLastKnownArea(), zone->m_area[0], pathCost); - float toHostage = NavAreaTravelDistance(me->GetLastKnownArea(), TheNavAreaGrid.GetNearestNavArea(&hostage->pev->origin), pathCost); + float toHostage = NavAreaTravelDistance(me->GetLastKnownArea(), TheNavAreaGrid.GetNearestNavArea(&pHostage->pev->origin), pathCost); if (toHostage < 0.0f) { @@ -722,12 +722,12 @@ void IdleState::OnUpdate(CCSBot *me) // go get hostages me->SetTask(CCSBot::COLLECT_HOSTAGES); me->Run(); - me->SetGoalEntity(hostage); + me->SetGoalEntity(pHostage); me->ResetWaitForHostagePatience(); // if we already have some hostages, move to the others by the quickest route RouteType route = (me->GetHostageEscortCount()) ? FASTEST_ROUTE : SAFEST_ROUTE; - me->MoveTo(&hostage->pev->origin, route); + me->MoveTo(&pHostage->pev->origin, route); me->PrintIfWatched("I'm collecting hostages\n"); return; } diff --git a/regamedll/dlls/bot/states/cs_bot_move_to.cpp b/regamedll/dlls/bot/states/cs_bot_move_to.cpp index 93cb05ae..92a5fd8a 100644 --- a/regamedll/dlls/bot/states/cs_bot_move_to.cpp +++ b/regamedll/dlls/bot/states/cs_bot_move_to.cpp @@ -41,8 +41,8 @@ void MoveToState::OnUpdate(CCSBot *me) if (me->GetTask() == CCSBot::MOVE_TO_LAST_KNOWN_ENEMY_POSITION) { // TODO: Account for reaction time so we take some time to realized the enemy is dead - CBasePlayer *victim = static_cast(me->GetTaskEntity()); - if (victim == NULL || !victim->IsAlive()) + CBaseEntity *pVictim = me->GetTaskEntity(); + if (!pVictim || !pVictim->IsAlive()) { me->PrintIfWatched("The enemy I was chasing was killed - giving up.\n"); me->Idle(); @@ -77,7 +77,7 @@ void MoveToState::OnUpdate(CCSBot *me) } // check off bombsites that we explore or happen to stumble into - for (int z = 0; z < TheCSBots()->GetZoneCount(); ++z) + for (int z = 0; z < TheCSBots()->GetZoneCount(); z++) { // don't re-check zones if (me->GetGameState()->IsBombsiteClear(z)) @@ -171,8 +171,8 @@ void MoveToState::OnUpdate(CCSBot *me) { // Since CT's have a radar, they can directly look at the actual hostage state // check if someone else collected our hostage, or the hostage died or was rescued - CHostage *hostage = static_cast(me->GetGoalEntity()); - if (!hostage || !hostage->IsAlive() || hostage->IsFollowingSomeone()) + CHostage *pHostage = me->GetGoalEntity(); + if (!pHostage || !pHostage->IsAlive() || pHostage->IsFollowingSomeone()) { me->Idle(); return; @@ -180,17 +180,17 @@ void MoveToState::OnUpdate(CCSBot *me) // if our hostage has moved, repath const float repathToleranceSq = 75.0f * 75.0f; - float error = (hostage->pev->origin - m_goalPosition).LengthSquared(); + float error = (pHostage->pev->origin - m_goalPosition).LengthSquared(); if (error > repathToleranceSq) { - m_goalPosition = hostage->pev->origin; + m_goalPosition = pHostage->pev->origin; me->ComputePath(TheNavAreaGrid.GetNavArea(&m_goalPosition), &m_goalPosition, SAFEST_ROUTE); } // TODO: Generalize ladder priorities over other tasks if (!me->IsUsingLadder()) { - Vector pos = hostage->pev->origin + Vector(0, 0, HumanHeight * 0.75f); + Vector pos = pHostage->pev->origin + Vector(0, 0, HumanHeight * 0.75f); Vector to = pos - me->pev->origin; // look at the hostage as we approach @@ -210,7 +210,7 @@ void MoveToState::OnUpdate(CCSBot *me) } // check if we are close enough to the hostage to talk to him - const float useRange = PLAYER_USE_RADIUS - 14.0f; // shave off a fudge factor to make sure we're within range + const float useRange = MAX_PLAYER_USE_RADIUS - 14.0f; // shave off a fudge factor to make sure we're within range if (to.IsLengthLessThan(useRange)) { me->UseEntity(me->GetGoalEntity()); @@ -254,7 +254,7 @@ void MoveToState::OnUpdate(CCSBot *me) { // if we are near the bomb, defuse it (if we are reloading, don't try to defuse until we finish) const Vector *bombPos = me->GetGameState()->GetBombPosition(); - if (bombPos != NULL) + if (bombPos) { const float defuseRange = 100.0f; Vector toBomb = *bombPos - me->pev->origin; @@ -271,8 +271,8 @@ void MoveToState::OnUpdate(CCSBot *me) } case CCSBot::MOVE_TO_LAST_KNOWN_ENEMY_POSITION: { - CBasePlayer *victim = static_cast(me->GetTaskEntity()); - if (victim != NULL && victim->IsAlive()) + CBaseEntity *pVictim = me->GetTaskEntity(); + if (pVictim && pVictim->IsAlive()) { // if we got here and haven't re-acquired the enemy, we lost him me->GetChatter()->Say("LostEnemy"); diff --git a/regamedll/dlls/bot/states/cs_bot_plant_bomb.cpp b/regamedll/dlls/bot/states/cs_bot_plant_bomb.cpp index cda1fd81..e3e2200f 100644 --- a/regamedll/dlls/bot/states/cs_bot_plant_bomb.cpp +++ b/regamedll/dlls/bot/states/cs_bot_plant_bomb.cpp @@ -16,11 +16,11 @@ void PlantBombState::OnEnter(CCSBot *me) // Plant the bomb. void PlantBombState::OnUpdate(CCSBot *me) { - CBasePlayerWeapon *gun = me->GetActiveWeapon(); + CBasePlayerWeapon *pCurrentWeapon = me->GetActiveWeapon(); bool holdingC4 = false; - if (gun != NULL) + if (pCurrentWeapon) { - if (FStrEq(STRING(gun->pev->classname), "weapon_c4")) + if (FClassnameIs(pCurrentWeapon->pev, "weapon_c4")) holdingC4 = true; } diff --git a/regamedll/dlls/buttons.cpp b/regamedll/dlls/buttons.cpp index 19643b58..5c9bd10b 100644 --- a/regamedll/dlls/buttons.cpp +++ b/regamedll/dlls/buttons.cpp @@ -15,8 +15,8 @@ TYPEDESCRIPTION CEnvGlobal::m_SaveData[] = TYPEDESCRIPTION CMultiSource::m_SaveData[] = { // BUGBUG FIX - DEFINE_ARRAY(CMultiSource, m_rgEntities, FIELD_EHANDLE, MS_MAX_TARGETS), - DEFINE_ARRAY(CMultiSource, m_rgTriggered, FIELD_INTEGER, MS_MAX_TARGETS), + DEFINE_ARRAY(CMultiSource, m_rgEntities, FIELD_EHANDLE, MAX_MS_TARGETS), + DEFINE_ARRAY(CMultiSource, m_rgTriggered, FIELD_INTEGER, MAX_MS_TARGETS), DEFINE_FIELD(CMultiSource, m_iTotal, FIELD_INTEGER), DEFINE_FIELD(CMultiSource, m_globalstate, FIELD_STRING), }; @@ -73,7 +73,9 @@ void CEnvGlobal::KeyValue(KeyValueData *pkvd) m_initialstate = Q_atoi(pkvd->szValue); } else + { CPointEntity::KeyValue(pkvd); + } } void CEnvGlobal::Spawn() @@ -154,7 +156,9 @@ void CMultiSource::KeyValue(KeyValueData *pkvd) pkvd->fHandled = TRUE; } else + { CPointEntity::KeyValue(pkvd); + } } void CMultiSource::Spawn() @@ -244,32 +248,32 @@ BOOL CMultiSource::IsTriggered(CBaseEntity *) void CMultiSource::Register() { m_iTotal = 0; - Q_memset(m_rgEntities, 0, MS_MAX_TARGETS * sizeof(EHANDLE)); + Q_memset(m_rgEntities, 0, MAX_MS_TARGETS * sizeof(EHANDLE)); SetThink(&CMultiSource::SUB_DoNothing); // search for all entities which target this multisource (pev->targetname) #ifdef REGAMEDLL_FIXES CBaseEntity *pTarget = nullptr; - while (m_iTotal < MS_MAX_TARGETS && (pTarget = UTIL_FindEntityByString(pTarget, "target", STRING(pev->targetname)))) { + while (m_iTotal < MAX_MS_TARGETS && (pTarget = UTIL_FindEntityByString(pTarget, "target", STRING(pev->targetname)))) { m_rgEntities[m_iTotal++] = pTarget; } pTarget = nullptr; - while (m_iTotal < MS_MAX_TARGETS && (pTarget = UTIL_FindEntityByClassname(pTarget, "multi_manager"))) + while (m_iTotal < MAX_MS_TARGETS && (pTarget = UTIL_FindEntityByClassname(pTarget, "multi_manager"))) { if (pTarget->HasTarget(pev->targetname)) { m_rgEntities[m_iTotal++] = pTarget; } } #else - edict_t *pentTarget = FIND_ENTITY_BY_STRING(NULL, "target", STRING(pev->targetname)); + edict_t *pentTarget = FIND_ENTITY_BY_STRING(nullptr, "target", STRING(pev->targetname)); - while (!FNullEnt(pentTarget) && m_iTotal < MS_MAX_TARGETS) + while (!FNullEnt(pentTarget) && m_iTotal < MAX_MS_TARGETS) { CBaseEntity *pTarget = CBaseEntity::Instance(pentTarget); - if (pTarget != NULL) + if (pTarget) { m_rgEntities[m_iTotal++] = pTarget; } @@ -277,12 +281,12 @@ void CMultiSource::Register() pentTarget = FIND_ENTITY_BY_STRING(pentTarget, "target", STRING(pev->targetname)); } - pentTarget = FIND_ENTITY_BY_STRING(NULL, "classname", "multi_manager"); + pentTarget = FIND_ENTITY_BY_STRING(nullptr, "classname", "multi_manager"); - while (!FNullEnt(pentTarget) && m_iTotal < MS_MAX_TARGETS) + while (!FNullEnt(pentTarget) && m_iTotal < MAX_MS_TARGETS) { CBaseEntity *pTarget = CBaseEntity::Instance(pentTarget); - if (pTarget != NULL && pTarget->HasTarget(pev->targetname)) + if (pTarget && pTarget->HasTarget(pev->targetname)) { m_rgEntities[m_iTotal++] = pTarget; } @@ -388,7 +392,9 @@ void CBaseButton::KeyValue(KeyValueData *pkvd) pkvd->fHandled = TRUE; } else + { CBaseToggle::KeyValue(pkvd); + } } // ButtonShot @@ -405,7 +411,7 @@ BOOL CBaseButton::TakeDamage(entvars_t *pevInflictor, entvars_t *pevAttacker, fl SetTouch(NULL); m_hActivator = CBaseEntity::Instance(pevAttacker); - if (m_hActivator == NULL) + if (!m_hActivator) return FALSE; if (code == BUTTON_RETURN) @@ -759,7 +765,7 @@ void CBaseButton::ButtonReturn() #ifdef REGAMEDLL_FIXES void CBaseButton::Restart() { - m_hActivator = NULL; + m_hActivator = nullptr; SetMovedir(pev); ButtonReturn(); @@ -793,9 +799,8 @@ void CBaseButton::ButtonBackHome() if (!FStringNull(pev->target)) { - edict_t *pentTarget = NULL; - - while ((pentTarget = FIND_ENTITY_BY_TARGETNAME(pentTarget, STRING(pev->target))) != NULL) + edict_t *pentTarget = nullptr; + while ((pentTarget = FIND_ENTITY_BY_TARGETNAME(pentTarget, STRING(pev->target)))) { if (FNullEnt(pentTarget)) break; @@ -805,7 +810,7 @@ void CBaseButton::ButtonBackHome() CBaseEntity *pTarget = CBaseEntity::Instance(pentTarget); - if (pTarget != NULL) + if (pTarget) { pTarget->Use(m_hActivator, this, USE_TOGGLE, 0); } @@ -859,7 +864,7 @@ void CRotButton::Spawn() CBaseToggle::AxisDir(pev); // check for clockwise rotation - if (pev->spawnflags & SF_DOOR_ROTATE_BACKWARDS) + if (pev->spawnflags & SF_ROTBUTTON_BACKWARDS) { pev->movedir = pev->movedir * -1; } @@ -973,7 +978,9 @@ void CMomentaryRotButton::KeyValue(KeyValueData *pkvd) pkvd->fHandled = TRUE; } else + { CBaseToggle::KeyValue(pkvd); + } } void CMomentaryRotButton::PlaySound() @@ -1002,7 +1009,7 @@ void CMomentaryRotButton::Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE void CMomentaryRotButton::UpdateAllButtons(float value, int start) { // Update all rot buttons attached to the same target - edict_t *pentTarget = NULL; + edict_t *pentTarget = nullptr; while (true) { @@ -1015,7 +1022,7 @@ void CMomentaryRotButton::UpdateAllButtons(float value, int start) { CMomentaryRotButton *pEntity = CMomentaryRotButton::Instance(pentTarget); - if (pEntity != NULL) + if (pEntity) { if (start) pEntity->UpdateSelf(value); @@ -1071,16 +1078,14 @@ void CMomentaryRotButton::UpdateTarget(float value) { if (!FStringNull(pev->target)) { - edict_t *pentTarget = NULL; - - while ((pentTarget = FIND_ENTITY_BY_TARGETNAME(pentTarget, STRING(pev->target))) != NULL) + edict_t *pentTarget = nullptr; + while ((pentTarget = FIND_ENTITY_BY_TARGETNAME(pentTarget, STRING(pev->target)))) { if (FNullEnt(pentTarget)) break; CBaseEntity *pEntity = CBaseEntity::Instance(pentTarget); - - if (pEntity != NULL) + if (pEntity) { pEntity->Use(this, this, USE_SET, value); } @@ -1194,7 +1199,9 @@ void CEnvSpark::KeyValue(KeyValueData *pkvd) || FStrEq(pkvd->szKeyName, "value3")) pkvd->fHandled = TRUE; else + { CBaseEntity::KeyValue(pkvd); + } } void CEnvSpark::SparkThink() diff --git a/regamedll/dlls/buttons.h b/regamedll/dlls/buttons.h index f631d317..7b67aa7f 100644 --- a/regamedll/dlls/buttons.h +++ b/regamedll/dlls/buttons.h @@ -26,33 +26,9 @@ * */ -#ifndef BUTTON_H -#define BUTTON_H -#ifdef _WIN32 #pragma once -#endif -#define SF_BUTTON_DONTMOVE 1 -#define SF_ROTBUTTON_NOTSOLID 1 -#define SF_BUTTON_TOGGLE 32 // button stays pushed until reactivated -#define SF_BUTTON_SPARK_IF_OFF 64 // button sparks in OFF state -#define SF_BUTTON_TOUCH_ONLY 256 // button only fires as a result of USE key. - -#define SF_GLOBAL_SET 1 // Set global state to initial state on spawn - -#define SF_MULTI_INIT 1 - -// Make this button behave like a door (HACKHACK) -// This will disable use and make the button solid -// rotating buttons were made SOLID_NOT by default since their were some -// collision problems with them... -#define SF_MOMENTARY_DOOR 0x0001 - -#define SF_SPARK_TOOGLE 32 -#define SF_SPARK_IF_OFF 64 - -#define SF_BTARGET_USE 0x0001 -#define SF_BTARGET_ON 0x0002 +#define SF_GLOBAL_SET BIT(0) // Set global state to initial state on spawn class CEnvGlobal: public CPointEntity { @@ -71,6 +47,9 @@ public: int m_initialstate; }; +#define SF_ROTBUTTON_NOTSOLID BIT(0) +#define SF_ROTBUTTON_BACKWARDS BIT(1) + class CRotButton: public CBaseButton { public: @@ -87,6 +66,12 @@ public: }; +// Make this button behave like a door (HACKHACK) +// This will disable use and make the button solid +// rotating buttons were made SOLID_NOT by default since their were some +// collision problems with them... +#define SF_MOMENTARY_DOOR BIT(0) + class CMomentaryRotButton: public CBaseToggle { public: @@ -128,6 +113,9 @@ public: int m_sounds; }; +#define SF_SPARK_TOOGLE BIT(5) +#define SF_SPARK_IF_OFF BIT(6) + class CEnvSpark: public CBaseEntity { public: @@ -147,6 +135,9 @@ public: float m_flDelay; }; +#define SF_BTARGET_USE BIT(0) +#define SF_BTARGET_ON BIT(1) + class CButtonTarget: public CBaseEntity { public: @@ -158,5 +149,3 @@ public: char *ButtonSound(int sound); void DoSpark(entvars_t *pev, const Vector &location); - -#endif // BUTTON_H diff --git a/regamedll/dlls/career_tasks.cpp b/regamedll/dlls/career_tasks.cpp index 8a58995d..d8866396 100644 --- a/regamedll/dlls/career_tasks.cpp +++ b/regamedll/dlls/career_tasks.cpp @@ -5,11 +5,11 @@ */ #ifndef HOOK_GAMEDLL -CCareerTaskManager *TheCareerTasks = NULL; +CCareerTaskManager *TheCareerTasks = nullptr; const TaskInfo taskInfo[] = { - { "defuse", EVENT_BOMB_DEFUSED, &CCareerTask::NewTask }, + { "defuse", EVENT_BOMB_DEFUSED, &CCareerTask::NewTask }, { "plant", EVENT_BOMB_PLANTED, &CCareerTask::NewTask }, { "rescue", EVENT_HOSTAGE_RESCUED, &CCareerTask::NewTask }, { "killall", EVENT_KILL_ALL, &CCareerTask::NewTask }, @@ -20,8 +20,8 @@ const TaskInfo taskInfo[] = { "headshot", EVENT_HEADSHOT, &CCareerTask::NewTask }, { "headshotwith", EVENT_HEADSHOT, &CCareerTask::NewTask }, { "winfast", EVENT_ROUND_WIN, &CCareerTask::NewTask }, - { "rescue", EVENT_HOSTAGE_RESCUED, &CCareerTask::NewTask }, - { "rescueall", EVENT_ALL_HOSTAGES_RESCUED, &CCareerTask::NewTask }, + { "rescue", EVENT_HOSTAGE_RESCUED, &CCareerTask::NewTask }, + { "rescueall", EVENT_ALL_HOSTAGES_RESCUED, &CCareerTask::NewTask }, { "injure", EVENT_PLAYER_TOOK_DAMAGE, &CCareerTask::NewTask }, { "injurewith", EVENT_PLAYER_TOOK_DAMAGE, &CCareerTask::NewTask }, { "killdefuser", EVENT_KILL, &CCareerTask::NewTask }, @@ -162,7 +162,7 @@ void CCareerTask::OnWeaponKill(int weaponId, int weaponClassId, bool headshot, b if (m_rescuer) { int hostages_ = 0; - CHostage *hostageEntity = NULL; + CHostage *hostageEntity = nullptr; while ((hostageEntity = (CHostage *)UTIL_FindEntityByClassname(hostageEntity, "hostage_entity"))) { @@ -238,7 +238,7 @@ void CCareerTask::OnEvent(GameEventType event, CBasePlayer *pVictim, CBasePlayer if (m_rescuer) { int hostages_ = 0; - CHostage *hostageEntity = NULL; + CHostage *hostageEntity = nullptr; while ((hostageEntity = (CHostage *)UTIL_FindEntityByClassname(hostageEntity, "hostage_entity"))) { @@ -267,7 +267,7 @@ void CCareerTask::OnEvent(GameEventType event, CBasePlayer *pVictim, CBasePlayer if (!Q_strcmp(m_name, "defendhostages")) { int hostages_ = 0; - CHostage *hostageEntity = NULL; + CHostage *hostageEntity = nullptr; while ((hostageEntity = (CHostage *)UTIL_FindEntityByClassname(hostageEntity, "hostage_entity"))) { @@ -284,7 +284,7 @@ void CCareerTask::OnEvent(GameEventType event, CBasePlayer *pVictim, CBasePlayer else if (!Q_strcmp(m_name, "hostagessurvive")) { int hostages_ = 0; - CHostage *hostageEntity = NULL; + CHostage *hostageEntity = nullptr; while ((hostageEntity = (CHostage *)UTIL_FindEntityByClassname(hostageEntity, "hostage_entity"))) { diff --git a/regamedll/dlls/career_tasks.h b/regamedll/dlls/career_tasks.h index 2e812dc1..d0c4e229 100644 --- a/regamedll/dlls/career_tasks.h +++ b/regamedll/dlls/career_tasks.h @@ -26,11 +26,7 @@ * */ -#ifndef CAREER_TASK_H -#define CAREER_TASK_H -#ifdef _WIN32 #pragma once -#endif #include @@ -148,5 +144,3 @@ struct TaskInfo }; extern CCareerTaskManager *TheCareerTasks; - -#endif // CAREER_TASK_H diff --git a/regamedll/dlls/cbase.cpp b/regamedll/dlls/cbase.cpp index 20dc6f97..49f975db 100644 --- a/regamedll/dlls/cbase.cpp +++ b/regamedll/dlls/cbase.cpp @@ -62,10 +62,10 @@ DLL_FUNCTIONS gFunctionTable = NEW_DLL_FUNCTIONS gNewDLLFunctions = { &OnFreeEntPrivateData, - NULL, - NULL, - NULL, - NULL + nullptr, + nullptr, + nullptr, + nullptr }; // Global Savedata for Delay @@ -112,10 +112,10 @@ void EmptyEntityHashTable() item = &stringsHashTable[i]; temp = item->next; - item->pev = NULL; + item->pev = nullptr; item->pevIndex = 0; item->lastHash = 0; - item->next = NULL; + item->next = nullptr; while (temp) { @@ -126,7 +126,7 @@ void EmptyEntityHashTable() } } -void EXT_FUNC AddEntityHashValue(entvars_t *pev, const char *value, hash_types_e fieldType) +void AddEntityHashValue(entvars_t *pev, const char *value, hash_types_e fieldType) { int count; hash_item_t *item, *next, *temp, *newp; @@ -167,7 +167,7 @@ void EXT_FUNC AddEntityHashValue(entvars_t *pev, const char *value, hash_types_e { pevtemp = item->pev; item->pev = pev; - item->lastHash = NULL; + item->lastHash = nullptr; item->pevIndex = pevIndex; pevIndex = ENTINDEX(ENT(pevtemp)); @@ -182,24 +182,24 @@ void EXT_FUNC AddEntityHashValue(entvars_t *pev, const char *value, hash_types_e item->next = newp; newp->pev = pevtemp; - newp->lastHash = NULL; + newp->lastHash = nullptr; newp->pevIndex = pevIndex; if (next) newp->next = temp; else - newp->next = NULL; + newp->next = nullptr; } } else { item->pev = pev; - item->lastHash = NULL; + item->lastHash = nullptr; item->pevIndex = ENTINDEX(ENT(pev)); } } -void EXT_FUNC RemoveEntityHashValue(entvars_t *pev, const char *value, hash_types_e fieldType) +void RemoveEntityHashValue(entvars_t *pev, const char *value, hash_types_e fieldType) { int hash; hash_item_t *item; @@ -244,20 +244,20 @@ void EXT_FUNC RemoveEntityHashValue(entvars_t *pev, const char *value, hash_type { item->pev = item->next->pev; item->pevIndex = item->next->pevIndex; - item->lastHash = NULL; + item->lastHash = nullptr; item->next = item->next->next; } else { - item->pev = NULL; - item->lastHash = NULL; + item->pev = nullptr; + item->lastHash = nullptr; item->pevIndex = 0; } } else { if (stringsHashTable[hash].lastHash == item) - stringsHashTable[hash].lastHash = NULL; + stringsHashTable[hash].lastHash = nullptr; last->next = item->next; hashItemMemPool.Free(item); @@ -266,25 +266,7 @@ void EXT_FUNC RemoveEntityHashValue(entvars_t *pev, const char *value, hash_type } } -void printEntities() -{ - for (int i = 0; i < stringsHashTable.Count(); ++i) - { - hash_item_t *item = &stringsHashTable[i]; - - if (item->pev) - { - UTIL_LogPrintf("Print: %s %i %p\n", STRING(stringsHashTable[i].pev->classname), ENTINDEX(ENT(item->pev)), item->pev); - } - - for (item = stringsHashTable[i].next; item; item = item->next) - { - UTIL_LogPrintf("Print: %s %i %p\n", STRING(item->pev->classname), ENTINDEX(ENT(item->pev)), item->pev); - } - } -} - -NOINLINE edict_t *EXT_FUNC CREATE_NAMED_ENTITY(string_t iClass) +NOINLINE edict_t *CREATE_NAMED_ENTITY(string_t iClass) { edict_t *named = g_engfuncs.pfnCreateNamedEntity(iClass); if (named) @@ -303,58 +285,6 @@ void REMOVE_ENTITY(edict_t *pEntity) } } -void loopPerformance() -{ - CCounter loopCounter; - loopCounter.Init(); - - double start, end; - int i; - - start = loopCounter.GetCurTime(); - - for (i = 0; i < 100; ++i) - { - CBaseEntity *pSpot; - for (pSpot = UTIL_FindEntityByString_Old(NULL, "classname", "info_player_start"); pSpot; pSpot = UTIL_FindEntityByString_Old(pSpot, "classname", "info_player_start")) - ; - - for (pSpot = UTIL_FindEntityByString_Old(NULL, "classname", "info_player_deathmatch"); pSpot; pSpot = UTIL_FindEntityByString_Old(pSpot, "classname", "info_player_deathmatch")) - ; - - for (pSpot = UTIL_FindEntityByString_Old(NULL, "classname", "player"); pSpot; pSpot = UTIL_FindEntityByString_Old(pSpot, "classname", "player")) - ; - - for (pSpot = UTIL_FindEntityByString_Old(NULL, "classname", "bodyque"); pSpot; pSpot = UTIL_FindEntityByString_Old(pSpot, "classname", "bodyque")) - ; - } - - end = loopCounter.GetCurTime(); - CONSOLE_ECHO(" Time in old search loop %.4f\n", (end - start) * 1000.0); - - // check time new search loop - start = loopCounter.GetCurTime(); - - for (i = 0; i < 100; ++i) - { - CBaseEntity *pSpot; - for (pSpot = UTIL_FindEntityByString(NULL, "classname", "info_player_start"); pSpot; pSpot = UTIL_FindEntityByString(pSpot, "classname", "info_player_start")) - ; - - for (pSpot = UTIL_FindEntityByString(NULL, "classname", "info_player_deathmatch"); pSpot; pSpot = UTIL_FindEntityByString(pSpot, "classname", "info_player_deathmatch")) - ; - - for (pSpot = UTIL_FindEntityByString(NULL, "classname", "player"); pSpot; pSpot = UTIL_FindEntityByString(pSpot, "classname", "player")) - ; - - for (pSpot = UTIL_FindEntityByString(NULL, "classname", "bodyque"); pSpot; pSpot = UTIL_FindEntityByString(pSpot, "classname", "bodyque")) - ; - } - - end = loopCounter.GetCurTime(); - CONSOLE_ECHO(" Time in new search loop %.4f\n", (end - start) * 1000.0); -} - C_DLLEXPORT int GetEntityAPI(DLL_FUNCTIONS *pFunctionTable, int interfaceVersion) { if (!pFunctionTable || interfaceVersion != INTERFACE_VERSION) @@ -364,7 +294,7 @@ C_DLLEXPORT int GetEntityAPI(DLL_FUNCTIONS *pFunctionTable, int interfaceVersion stringsHashTable.AddMultipleToTail(2048); for (int i = 0; i < stringsHashTable.Count(); ++i) { - stringsHashTable[i].next = NULL; + stringsHashTable[i].next = nullptr; } EmptyEntityHashTable(); @@ -395,10 +325,9 @@ C_DLLEXPORT int GetNewDLLFunctions(NEW_DLL_FUNCTIONS *pFunctionTable, int *inter return 1; } -int EXT_FUNC DispatchSpawn(edict_t *pent) +int DispatchSpawn(edict_t *pent) { - CBaseEntity *pEntity = (CBaseEntity *)GET_PRIVATE(pent); - + CBaseEntity *pEntity = GET_PRIVATE(pent); if (pEntity) { // Initialize these or entities who don't link to the world won't have anything in here @@ -455,7 +384,7 @@ int EXT_FUNC DispatchSpawn(edict_t *pent) return 0; } -void EXT_FUNC DispatchKeyValue(edict_t *pentKeyvalue, KeyValueData *pkvd) +void DispatchKeyValue(edict_t *pentKeyvalue, KeyValueData *pkvd) { if (!pkvd || !pentKeyvalue) return; @@ -477,7 +406,7 @@ void EXT_FUNC DispatchKeyValue(edict_t *pentKeyvalue, KeyValueData *pkvd) // HACKHACK -- this is a hack to keep the node graph entity from "touching" things (like triggers) // while it builds the graph -void EXT_FUNC DispatchTouch(edict_t *pentTouched, edict_t *pentOther) +void DispatchTouch(edict_t *pentTouched, edict_t *pentOther) { CBaseEntity *pEntity = (CBaseEntity *)GET_PRIVATE(pentTouched); CBaseEntity *pOther = (CBaseEntity *)GET_PRIVATE(pentOther); @@ -486,7 +415,7 @@ void EXT_FUNC DispatchTouch(edict_t *pentTouched, edict_t *pentOther) pEntity->Touch(pOther); } -void EXT_FUNC DispatchUse(edict_t *pentUsed, edict_t *pentOther) +void DispatchUse(edict_t *pentUsed, edict_t *pentOther) { CBaseEntity *pEntity = (CBaseEntity *)GET_PRIVATE(pentUsed); CBaseEntity *pOther = (CBaseEntity *)GET_PRIVATE(pentOther); @@ -495,7 +424,7 @@ void EXT_FUNC DispatchUse(edict_t *pentUsed, edict_t *pentOther) pEntity->Use(pOther, pOther, USE_TOGGLE, 0); } -void EXT_FUNC DispatchThink(edict_t *pent) +void DispatchThink(edict_t *pent) { CBaseEntity *pEntity = (CBaseEntity *)GET_PRIVATE(pent); @@ -510,7 +439,7 @@ void EXT_FUNC DispatchThink(edict_t *pent) } } -void EXT_FUNC DispatchBlocked(edict_t *pentBlocked, edict_t *pentOther) +void DispatchBlocked(edict_t *pentBlocked, edict_t *pentOther) { CBaseEntity *pEntity = (CBaseEntity *)GET_PRIVATE(pentBlocked); CBaseEntity *pOther = (CBaseEntity *)GET_PRIVATE(pentOther); @@ -521,7 +450,7 @@ void EXT_FUNC DispatchBlocked(edict_t *pentBlocked, edict_t *pentOther) } } -void EXT_FUNC DispatchSave(edict_t *pent, SAVERESTOREDATA *pSaveData) +void DispatchSave(edict_t *pent, SAVERESTOREDATA *pSaveData) { CBaseEntity *pEntity = (CBaseEntity *)GET_PRIVATE(pent); @@ -563,7 +492,7 @@ void EXT_FUNC DispatchSave(edict_t *pent, SAVERESTOREDATA *pSaveData) // different classes with the same global name CBaseEntity *FindGlobalEntity(string_t classname, string_t globalname) { - edict_t *pent = FIND_ENTITY_BY_STRING(NULL, "globalname", STRING(globalname)); + edict_t *pent = FIND_ENTITY_BY_STRING(nullptr, "globalname", STRING(globalname)); CBaseEntity *pReturn = CBaseEntity::Instance(pent); if (pReturn) @@ -571,14 +500,14 @@ CBaseEntity *FindGlobalEntity(string_t classname, string_t globalname) if (!FClassnameIs(pReturn->pev, STRING(classname))) { ALERT(at_console, "Global entity found %s, wrong class %s\n", STRING(globalname), STRING(pReturn->pev->classname)); - pReturn = NULL; + pReturn = nullptr; } } return pReturn; } -int EXT_FUNC DispatchRestore(edict_t *pent, SAVERESTOREDATA *pSaveData, int globalEntity) +int DispatchRestore(edict_t *pent, SAVERESTOREDATA *pSaveData, int globalEntity) { CBaseEntity *pEntity = (CBaseEntity *)GET_PRIVATE(pent); @@ -692,7 +621,7 @@ int EXT_FUNC DispatchRestore(edict_t *pent, SAVERESTOREDATA *pSaveData, int glob return 0; } -void EXT_FUNC DispatchObjectCollsionBox(edict_t *pent) +void DispatchObjectCollsionBox(edict_t *pent) { CBaseEntity *pEntity = (CBaseEntity *)GET_PRIVATE(pent); if (pEntity) @@ -704,67 +633,18 @@ void EXT_FUNC DispatchObjectCollsionBox(edict_t *pent) } -void EXT_FUNC SaveWriteFields(SAVERESTOREDATA *pSaveData, const char *pname, void *pBaseData, TYPEDESCRIPTION *pFields, int fieldCount) +void SaveWriteFields(SAVERESTOREDATA *pSaveData, const char *pname, void *pBaseData, TYPEDESCRIPTION *pFields, int fieldCount) { CSave saveHelper(pSaveData); saveHelper.WriteFields(pname, pBaseData, pFields, fieldCount); } -void EXT_FUNC SaveReadFields(SAVERESTOREDATA *pSaveData, const char *pname, void *pBaseData, TYPEDESCRIPTION *pFields, int fieldCount) +void SaveReadFields(SAVERESTOREDATA *pSaveData, const char *pname, void *pBaseData, TYPEDESCRIPTION *pFields, int fieldCount) { CRestore restoreHelper(pSaveData); restoreHelper.ReadFields(pname, pBaseData, pFields, fieldCount); } -edict_t *EHANDLE::Get() -{ - if (!m_pent || m_pent->serialnumber != m_serialnumber) - return NULL; - - return m_pent; -} - -edict_t *EHANDLE::Set(edict_t *pent) -{ - m_pent = pent; - if (pent) - m_serialnumber = pent->serialnumber; - - return pent; -} - -EHANDLE::operator CBaseEntity *() -{ - return (CBaseEntity *)GET_PRIVATE(Get()); -} - -CBaseEntity *EHANDLE::operator=(CBaseEntity *pEntity) -{ - if (pEntity) - { - m_pent = ENT(pEntity->pev); - if (m_pent) - m_serialnumber = m_pent->serialnumber; - } - else - { - m_pent = NULL; - m_serialnumber = 0; - } - - return pEntity; -} - -EHANDLE::operator int() -{ - return Get() != NULL; -} - -CBaseEntity *EHANDLE::operator->() -{ - return (CBaseEntity *)GET_PRIVATE(Get()); -} - BOOL CBaseEntity::TakeHealth(float flHealth, int bitsDamageType) { if (pev->takedamage == DAMAGE_NO) @@ -844,12 +724,12 @@ void CBaseEntity::Killed(entvars_t *pevAttacker, int iGib) CBaseEntity *CBaseEntity::GetNextTarget() { if (FStringNull(pev->target)) - return NULL; + return nullptr; - edict_t *pTarget = FIND_ENTITY_BY_TARGETNAME(NULL, STRING(pev->target)); + edict_t *pTarget = FIND_ENTITY_BY_TARGETNAME(nullptr, STRING(pev->target)); if (FNullEnt(pTarget)) { - return NULL; + return nullptr; } return Instance(pTarget); @@ -941,16 +821,24 @@ void CBaseEntity::SetObjectCollisionBox() ::SetObjectCollisionBox(pev); } -int CBaseEntity::Intersects(CBaseEntity *pOther) +bool CBaseEntity::Intersects(CBaseEntity *pOther) { - if (pOther->pev->absmin.x > pev->absmax.x - || pOther->pev->absmin.y > pev->absmax.y - || pOther->pev->absmin.z > pev->absmax.z - || pOther->pev->absmax.x < pev->absmin.x - || pOther->pev->absmax.y < pev->absmin.y - || pOther->pev->absmax.z < pev->absmin.z) - return 0; - return 1; + return Intersects(pOther->pev->absmin, pOther->pev->absmax); +} + +bool CBaseEntity::Intersects(const Vector &mins, const Vector &maxs) +{ + if (mins.x > pev->absmax.x + || mins.y > pev->absmax.y + || mins.z > pev->absmax.z + || maxs.x < pev->absmin.x + || maxs.y < pev->absmin.y + || maxs.z < pev->absmin.z) + { + return false; + } + + return true; } void CBaseEntity::MakeDormant() @@ -1025,7 +913,7 @@ CBaseEntity *CBaseEntity::Create(char *szName, const Vector &vecOrigin, const Ve if (FNullEnt(pent)) { ALERT(at_console, "NULL Ent in Create!\n"); - return NULL; + return nullptr; } CBaseEntity *pEntity = Instance(pent); @@ -1039,13 +927,534 @@ CBaseEntity *CBaseEntity::Create(char *szName, const Vector &vecOrigin, const Ve return pEntity; } -void EXT_FUNC OnFreeEntPrivateData(edict_t *pEnt) +// Returns true if a line can be traced from the caller's eyes to the target +BOOL CBaseEntity::FVisible(CBaseEntity *pEntity) { - CBaseEntity *pEntity = CBaseEntity::Instance(pEnt); + TraceResult tr; + Vector vecLookerOrigin; + Vector vecTargetOrigin; + + if (pEntity->pev->flags & FL_NOTARGET) + return FALSE; + + // don't look through water + if ((pev->waterlevel != 3 && pEntity->pev->waterlevel == 3) || (pev->waterlevel == 3 && pEntity->pev->waterlevel == 0)) + return FALSE; + + //look through the caller's 'eyes' + vecLookerOrigin = pev->origin + pev->view_ofs; + vecTargetOrigin = pEntity->EyePosition(); + + UTIL_TraceLine(vecLookerOrigin, vecTargetOrigin, ignore_monsters, ignore_glass, ENT(pev), &tr); + + if (tr.flFraction != 1.0f) + { + // Line of sight is not established + return FALSE; + } + else + { + // line of sight is valid. + return TRUE; + } +} + +// Returns true if a line can be traced from the caller's eyes to the target vector +BOOL CBaseEntity::FVisible(const Vector &vecOrigin) +{ + TraceResult tr; + Vector vecLookerOrigin; + + //look through the caller's 'eyes' + vecLookerOrigin = EyePosition(); + + UTIL_TraceLine(vecLookerOrigin, vecOrigin, ignore_monsters, ignore_glass, ENT(pev), &tr); + + if (tr.flFraction != 1.0f) + { + // Line of sight is not established + return FALSE; + } + else + { + // line of sight is valid. + return TRUE; + } +} + +void CBaseEntity::TraceAttack(entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType) +{ + Vector vecOrigin = ptr->vecEndPos - vecDir * 4; + + if (pev->takedamage != DAMAGE_NO) + { + AddMultiDamage(pevAttacker, this, flDamage, bitsDamageType); + + int blood = BloodColor(); + if (blood != DONT_BLEED) + { + // a little surface blood. + SpawnBlood(vecOrigin, blood, flDamage); + TraceBleed(flDamage, vecDir, ptr, bitsDamageType); + } + } +} + +void CBaseEntity::FireBullets(ULONG cShots, Vector vecSrc, Vector vecDirShooting, Vector vecSpread, float flDistance, int iBulletType, int iTracerFreq, int iDamage, entvars_t *pevAttacker) +{ + static int tracerCount; + int tracer; + + TraceResult tr; + Vector vecRight, vecUp; + bool m_bCreatedShotgunSpark = true; + + vecRight = gpGlobals->v_right; + vecUp = gpGlobals->v_up; + + if (!pevAttacker) + { + // the default attacker is ourselves + pevAttacker = pev; + } + + ClearMultiDamage(); + gMultiDamage.type = (DMG_BULLET | DMG_NEVERGIB); + + for (ULONG iShot = 1; iShot <= cShots; ++iShot) + { + int spark = 0; + + // get circular gaussian spread + float x, y, z; + + do + { + x = RANDOM_FLOAT(-0.5, 0.5) + RANDOM_FLOAT(-0.5, 0.5); + y = RANDOM_FLOAT(-0.5, 0.5) + RANDOM_FLOAT(-0.5, 0.5); + z = x * x + y * y; + } + while (z > 1); + + Vector vecDir, vecEnd; + + vecDir = vecDirShooting + x * vecSpread.x * vecRight + y * vecSpread.y * vecUp; + vecEnd = vecSrc + vecDir * flDistance; + + UTIL_TraceLine(vecSrc, vecEnd, dont_ignore_monsters, ENT(pev), &tr); + tracer = 0; + + if (iTracerFreq != 0 && !(tracerCount++ % iTracerFreq)) + { + Vector vecTracerSrc; + + if (IsPlayer()) + { + // adjust tracer position for player + vecTracerSrc = vecSrc + Vector(0, 0, -4) + gpGlobals->v_right * 2 + gpGlobals->v_forward * 16; + } + else + { + vecTracerSrc = vecSrc; + } + + // guns that always trace also always decal + if (iTracerFreq != 1) + tracer = 1; + + MESSAGE_BEGIN(MSG_PAS, SVC_TEMPENTITY, vecTracerSrc); + WRITE_BYTE(TE_TRACER); + WRITE_COORD(vecTracerSrc.x); + WRITE_COORD(vecTracerSrc.y); + WRITE_COORD(vecTracerSrc.z); + WRITE_COORD(tr.vecEndPos.x); + WRITE_COORD(tr.vecEndPos.y); + WRITE_COORD(tr.vecEndPos.z); + MESSAGE_END(); + } + + // do damage, paint decals + if (tr.flFraction != 1.0f) + { + CBaseEntity *pEntity = CBaseEntity::Instance(tr.pHit); + + if (iDamage) + { + pEntity->TraceAttack(pevAttacker, iDamage, vecDir, &tr, DMG_BULLET | ((iDamage > 16) ? DMG_ALWAYSGIB : DMG_NEVERGIB)); + TEXTURETYPE_PlaySound(&tr, vecSrc, vecEnd, iBulletType); + DecalGunshot(&tr, iBulletType, false, pev, false); + } + else + { + float flDamage; + + switch (iBulletType) + { + case BULLET_PLAYER_MP5: + pEntity->TraceAttack(pevAttacker, gSkillData.plrDmgMP5, vecDir, &tr, DMG_BULLET); + break; + case BULLET_PLAYER_BUCKSHOT: + flDamage = ((1 - tr.flFraction) * 20); + pEntity->TraceAttack(pevAttacker, int(flDamage), vecDir, &tr, DMG_BULLET); + break; + case BULLET_PLAYER_357: + pEntity->TraceAttack(pevAttacker, gSkillData.plrDmg357, vecDir, &tr, DMG_BULLET); + break; + case BULLET_MONSTER_9MM: + pEntity->TraceAttack(pevAttacker, gSkillData.monDmg9MM, vecDir, &tr, DMG_BULLET); + TEXTURETYPE_PlaySound(&tr, vecSrc, vecEnd, iBulletType); + DecalGunshot(&tr, iBulletType, false, pev, false); + break; + case BULLET_MONSTER_MP5: + pEntity->TraceAttack(pevAttacker, gSkillData.monDmgMP5, vecDir, &tr, DMG_BULLET); + TEXTURETYPE_PlaySound(&tr, vecSrc, vecEnd, iBulletType); + DecalGunshot(&tr, iBulletType, false, pev, false); + break; + case BULLET_MONSTER_12MM: + pEntity->TraceAttack(pevAttacker, gSkillData.monDmg12MM, vecDir, &tr, DMG_BULLET); + + if (!tracer) + { + TEXTURETYPE_PlaySound(&tr, vecSrc, vecEnd, iBulletType); + DecalGunshot(&tr, iBulletType, false, pev, false); + } + break; + case BULLET_NONE: + flDamage = 50; + pEntity->TraceAttack(pevAttacker, flDamage, vecDir, &tr, DMG_CLUB); + TEXTURETYPE_PlaySound(&tr, vecSrc, vecEnd, iBulletType); + + // only decal glass + if (!FNullEnt(tr.pHit) && VARS(tr.pHit)->rendermode != kRenderNormal) + { + UTIL_DecalTrace(&tr, DECAL_GLASSBREAK1 + RANDOM_LONG(0, 2)); + } + break; + default: + pEntity->TraceAttack(pevAttacker, gSkillData.monDmg9MM, vecDir, &tr, DMG_BULLET); + break; + } + } + } + + // make bullet trails + UTIL_BubbleTrail(vecSrc, tr.vecEndPos, int((flDistance * tr.flFraction) / 64)); + } + + ApplyMultiDamage(pev, pevAttacker); +} + +// Go to the trouble of combining multiple pellets into a single damage call. +// This version is used by Players, uses the random seed generator to sync client and server side shots. +Vector CBaseEntity::FireBullets3(Vector vecSrc, Vector vecDirShooting, float vecSpread, float flDistance, int iPenetration, int iBulletType, int iDamage, float flRangeModifier, entvars_t *pevAttacker, bool bPistol, int shared_rand) +{ + int iOriginalPenetration = iPenetration; + int iPenetrationPower; + float flPenetrationDistance; + int iCurrentDamage = iDamage; + float flCurrentDistance; + + TraceResult tr, tr2; + Vector vecRight, vecUp; + + bool bHitMetal = false; + int iSparksAmount = 1; + + vecRight = gpGlobals->v_right; + vecUp = gpGlobals->v_up; + + switch (iBulletType) + { + case BULLET_PLAYER_9MM: + iPenetrationPower = 21; + flPenetrationDistance = 800; + break; + case BULLET_PLAYER_45ACP: + iPenetrationPower = 15; + flPenetrationDistance = 500; + break; + case BULLET_PLAYER_50AE: + iPenetrationPower = 30; + flPenetrationDistance = 1000; + break; + case BULLET_PLAYER_762MM: + iPenetrationPower = 39; + flPenetrationDistance = 5000; + break; + case BULLET_PLAYER_556MM: + iPenetrationPower = 35; + flPenetrationDistance = 4000; + break; + case BULLET_PLAYER_338MAG: + iPenetrationPower = 45; + flPenetrationDistance = 8000; + break; + case BULLET_PLAYER_57MM: + iPenetrationPower = 30; + flPenetrationDistance = 2000; + break; + case BULLET_PLAYER_357SIG: + iPenetrationPower = 25; + flPenetrationDistance = 800; + break; + default: + iPenetrationPower = 0; + flPenetrationDistance = 0; + break; + } + + if (!pevAttacker) + { + // the default attacker is ourselves + pevAttacker = pev; + } + + gMultiDamage.type = (DMG_BULLET | DMG_NEVERGIB); + + float x, y, z; + + if (IsPlayer()) + { + // Use player's random seed. + // get circular gaussian spread + x = UTIL_SharedRandomFloat(shared_rand, -0.5, 0.5) + UTIL_SharedRandomFloat(shared_rand + 1, -0.5, 0.5); + y = UTIL_SharedRandomFloat(shared_rand + 2, -0.5, 0.5) + UTIL_SharedRandomFloat(shared_rand + 3, -0.5, 0.5); + } + else + { + do + { + x = RANDOM_FLOAT(-0.5, 0.5) + RANDOM_FLOAT(-0.5, 0.5); + y = RANDOM_FLOAT(-0.5, 0.5) + RANDOM_FLOAT(-0.5, 0.5); + z = x * x + y * y; + } + while (z > 1); + } + + Vector vecDir, vecEnd; + Vector vecOldSrc, vecNewSrc; + + vecDir = vecDirShooting + x * vecSpread * vecRight + y * vecSpread * vecUp; + vecEnd = vecSrc + vecDir * flDistance; + + float flDamageModifier = 0.5; + + while (iPenetration != 0) + { + ClearMultiDamage(); + UTIL_TraceLine(vecSrc, vecEnd, dont_ignore_monsters, ENT(pev), &tr); + + if (TheBots && tr.flFraction != 1.0f) + { + TheBots->OnEvent(EVENT_BULLET_IMPACT, this, (CBaseEntity *)&tr.vecEndPos); + } + + char cTextureType = UTIL_TextureHit(&tr, vecSrc, vecEnd); + bool bSparks = false; + + switch (cTextureType) + { + case CHAR_TEX_METAL: + bHitMetal = true; + bSparks = true; + + iPenetrationPower *= 0.15; + flDamageModifier = 0.2; + break; + case CHAR_TEX_CONCRETE: + iPenetrationPower *= 0.25; + break; + case CHAR_TEX_GRATE: + bHitMetal = true; + bSparks = true; + + iPenetrationPower *= 0.5; + flDamageModifier = 0.4; + break; + case CHAR_TEX_VENT: + bHitMetal = true; + bSparks = true; + + iPenetrationPower *= 0.5; + flDamageModifier = 0.45; + break; + case CHAR_TEX_TILE: + iPenetrationPower *= 0.65; + flDamageModifier = 0.3; + break; + case CHAR_TEX_COMPUTER: + bHitMetal = true; + bSparks = true; + + iPenetrationPower *= 0.4; + flDamageModifier = 0.45; + break; + case CHAR_TEX_WOOD: + flDamageModifier = 0.6; + break; + default: + break; + } + if (tr.flFraction != 1.0f) + { + CBaseEntity *pEntity = CBaseEntity::Instance(tr.pHit); + iPenetration--; + + flCurrentDistance = tr.flFraction * flDistance; + iCurrentDamage *= Q_pow(flRangeModifier, flCurrentDistance / 500); + + if (flCurrentDistance > flPenetrationDistance) + { + iPenetration = 0; + } + + if (tr.iHitgroup == HITGROUP_SHIELD) + { + EMIT_SOUND(pEntity->edict(), CHAN_VOICE, (RANDOM_LONG(0, 1) == 1) ? "weapons/ric_metal-1.wav" : "weapons/ric_metal-2.wav", VOL_NORM, ATTN_NORM); + UTIL_Sparks(tr.vecEndPos); + + pEntity->pev->punchangle.x = iCurrentDamage * RANDOM_FLOAT(-0.15, 0.15); + pEntity->pev->punchangle.z = iCurrentDamage * RANDOM_FLOAT(-0.15, 0.15); + + if (pEntity->pev->punchangle.x < 4) + { + pEntity->pev->punchangle.x = -4; + } + + if (pEntity->pev->punchangle.z < -5) + { + pEntity->pev->punchangle.z = -5; + } + else if (pEntity->pev->punchangle.z > 5) + { + pEntity->pev->punchangle.z = 5; + } + + break; + } + + float flDistanceModifier; + if (VARS(tr.pHit)->solid != SOLID_BSP || !iPenetration) + { + iPenetrationPower = 42; + flDamageModifier = 0.75; + flDistanceModifier = 0.75; + } + else + flDistanceModifier = 0.5; + + DecalGunshot(&tr, iBulletType, (!bPistol && RANDOM_LONG(0, 3)), pev, bHitMetal); + + vecSrc = tr.vecEndPos + (vecDir * iPenetrationPower); + flDistance = (flDistance - flCurrentDistance) * flDistanceModifier; + vecEnd = vecSrc + (vecDir * flDistance); + + pEntity->TraceAttack(pevAttacker, iCurrentDamage, vecDir, &tr, (DMG_BULLET | DMG_NEVERGIB)); + iCurrentDamage *= flDamageModifier; + } + else + iPenetration = 0; + + ApplyMultiDamage(pev, pevAttacker); + } + + return Vector(x * vecSpread, y * vecSpread, 0); +} + +void CBaseEntity::TraceBleed(float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType) +{ + if (BloodColor() == DONT_BLEED) + return; + + if (!flDamage) + return; + + if (!(bitsDamageType & (DMG_CRUSH | DMG_BULLET | DMG_SLASH | DMG_BLAST | DMG_CLUB | DMG_MORTAR))) + return; + + // make blood decal on the wall! + TraceResult Bloodtr; + Vector vecTraceDir; + float flNoise; + int cCount; + int i; + + if (flDamage < 10.0f) + { + flNoise = 0.1f; + cCount = 1; + } + else if (flDamage < 25.0f) + { + flNoise = 0.2f; + cCount = 2; + } + else + { + flNoise = 0.3f; + cCount = 4; + } + + for (i = 0; i < cCount; ++i) + { + // trace in the opposite direction the shot came from (the direction the shot is going) + vecTraceDir = vecDir * -1.0f; + + vecTraceDir.x += RANDOM_FLOAT(-flNoise, flNoise); + vecTraceDir.y += RANDOM_FLOAT(-flNoise, flNoise); + vecTraceDir.z += RANDOM_FLOAT(-flNoise, flNoise); + + UTIL_TraceLine(ptr->vecEndPos, ptr->vecEndPos + vecTraceDir * -172.0f, ignore_monsters, ENT(pev), &Bloodtr); + if (Bloodtr.flFraction != 1.0f) + { + if (!RANDOM_LONG(0, 2)) + { + UTIL_BloodDecalTrace(&Bloodtr, BloodColor()); + } + } + } +} + +void CBaseEntity::SUB_StartFadeOut() +{ + if (pev->rendermode == kRenderNormal) + { + pev->renderamt = 255.0f; + pev->rendermode = kRenderTransTexture; + } + + pev->solid = SOLID_NOT; + pev->avelocity = g_vecZero; + pev->nextthink = gpGlobals->time + 0.1f; + + SetThink(&CBaseEntity::SUB_FadeOut); +} + +void CBaseEntity::SUB_FadeOut() +{ + if (pev->renderamt > 7) + { + pev->renderamt -= 7.0f; + pev->nextthink = gpGlobals->time + 0.1f; + } + else + { + pev->renderamt = 0.0f; + pev->nextthink = gpGlobals->time + 0.2f; + SetThink(&CBaseEntity::SUB_Remove); + } +} + +void OnFreeEntPrivateData(edict_t *pEnt) +{ + CBaseEntity *pEntity = (CBaseEntity *)GET_PRIVATE(pEnt); if (!pEntity) return; - pEntity->UpdateOnRemove(); +#ifdef REGAMEDLL_API + pEntity->OnDestroy(); +#endif + RemoveEntityHashValue(pEntity->pev, STRING(pEntity->pev->classname), CLASSNAME); #ifdef REGAMEDLL_API @@ -1061,3 +1470,14 @@ void EXT_FUNC OnFreeEntPrivateData(edict_t *pEnt) } #endif } + +#ifdef REGAMEDLL_API +void CBaseEntity::OnCreate() +{ +} + +void CBaseEntity::OnDestroy() +{ + UpdateOnRemove(); +} +#endif diff --git a/regamedll/dlls/cbase.h b/regamedll/dlls/cbase.h index 3123946b..3303ffbb 100644 --- a/regamedll/dlls/cbase.h +++ b/regamedll/dlls/cbase.h @@ -26,202 +26,25 @@ * */ -#ifndef CBASE_H -#define CBASE_H -#ifdef _WIN32 #pragma once -#endif -#include "saverestore.h" +#include "util.h" #include "schedule.h" +#include "saverestore.h" +#include "scriptevent.h" #include "monsterevent.h" -#undef CREATE_NAMED_ENTITY -#undef REMOVE_ENTITY - -// These are caps bits to indicate what an object's capabilities (currently used for save/restore and level transitions) -#define FCAP_CUSTOMSAVE 0x00000001 -#define FCAP_ACROSS_TRANSITION 0x00000002 // should transfer between transitions -#define FCAP_MUST_SPAWN 0x00000004 // Spawn after restore -#define FCAP_DONT_SAVE 0x80000000 // Don't save this -#define FCAP_IMPULSE_USE 0x00000008 // can be used by the player -#define FCAP_CONTINUOUS_USE 0x00000010 // can be used by the player -#define FCAP_ONOFF_USE 0x00000020 // can be used by the player -#define FCAP_DIRECTIONAL_USE 0x00000040 // Player sends +/- 1 when using (currently only tracktrains) -#define FCAP_MASTER 0x00000080 // Can be used to "master" other entities (like multisource) -#define FCAP_MUST_RESET 0x00000100 // should reset on the new round -#define FCAP_MUST_RELEASE 0x00000200 // should release on the new round - -// UNDONE: This will ignore transition volumes (trigger_transition), but not the PVS!!! -#define FCAP_FORCE_TRANSITION 0x00000080 // ALWAYS goes across transitions - -#define SetThink(a)\ - m_pfnThink = static_cast(a) -#define SetTouch(a)\ - m_pfnTouch = static_cast(a) -#define SetUse(a)\ - m_pfnUse = static_cast(a) -#define SetBlocked(a)\ - m_pfnBlocked = static_cast(a) - -#define SetMoveDone(a)\ - m_pfnCallWhenMoveDone = static_cast(a) - -// for Classify -#define CLASS_NONE 0 -#define CLASS_MACHINE 1 -#define CLASS_PLAYER 2 -#define CLASS_HUMAN_PASSIVE 3 -#define CLASS_HUMAN_MILITARY 4 -#define CLASS_ALIEN_MILITARY 5 -#define CLASS_ALIEN_PASSIVE 6 -#define CLASS_ALIEN_MONSTER 7 -#define CLASS_ALIEN_PREY 8 -#define CLASS_ALIEN_PREDATOR 9 -#define CLASS_INSECT 10 -#define CLASS_PLAYER_ALLY 11 -#define CLASS_PLAYER_BIOWEAPON 12 // hornets and snarks.launched by players -#define CLASS_ALIEN_BIOWEAPON 13 // hornets and snarks.launched by the alien menace -#define CLASS_VEHICLE 14 -#define CLASS_BARNACLE 99 // special because no one pays attention to it, and it eats a wide cross-section of creatures. - -#define ROUTE_SIZE 8 -#define MAX_OLD_ENEMIES 4 - -#define bits_CAP_DUCK (1<<0) -#define bits_CAP_JUMP (1<<1) -#define bits_CAP_STRAFE (1<<2) -#define bits_CAP_SQUAD (1<<3) -#define bits_CAP_SWIM (1<<4) -#define bits_CAP_CLIMB (1<<5) -#define bits_CAP_USE (1<<6) -#define bits_CAP_HEAR (1<<7) -#define bits_CAP_AUTO_DOORS (1<<8) -#define bits_CAP_OPEN_DOORS (1<<9) -#define bits_CAP_TURN_HEAD (1<<10) -#define bits_CAP_RANGE_ATTACK1 (1<<11) -#define bits_CAP_RANGE_ATTACK2 (1<<12) -#define bits_CAP_MELEE_ATTACK1 (1<<13) -#define bits_CAP_MELEE_ATTACK2 (1<<14) -#define bits_CAP_FLY (1<<15) -#define bits_CAP_DOORS_GROUP (bits_CAP_USE | bits_CAP_AUTO_DOORS | bits_CAP_OPEN_DOORS) - -#define SF_NORESPAWN (1<<30) // set this bit on guns and stuff that should never respawn. - -#define DMG_GENERIC 0 // generic damage was done -#define DMG_CRUSH (1<<0) // crushed by falling or moving object -#define DMG_BULLET (1<<1) // shot -#define DMG_SLASH (1<<2) // cut, clawed, stabbed -#define DMG_BURN (1<<3) // heat burned -#define DMG_FREEZE (1<<4) // frozen -#define DMG_FALL (1<<5) // fell too far -#define DMG_BLAST (1<<6) // explosive blast damage -#define DMG_CLUB (1<<7) // crowbar, punch, headbutt -#define DMG_SHOCK (1<<8) // electric shock -#define DMG_SONIC (1<<9) // sound pulse shockwave -#define DMG_ENERGYBEAM (1<<10) // laser or other high energy beam -#define DMG_NEVERGIB (1<<12) // with this bit OR'd in, no damage type will be able to gib victims upon death -#define DMG_ALWAYSGIB (1<<13) // with this bit OR'd in, any damage type can be made to gib victims upon death -#define DMG_DROWN (1<<14) // Drowning - -// time-based damage -#define DMG_TIMEBASED (~(0x3FFF)) // mask for time-based damage - -#define DMG_PARALYZE (1<<15) // slows affected creature down -#define DMG_NERVEGAS (1<<16) // nerve toxins, very bad -#define DMG_POISON (1<<17) // blood poisioning -#define DMG_RADIATION (1<<18) // radiation exposure -#define DMG_DROWNRECOVER (1<<19) // drowning recovery -#define DMG_ACID (1<<20) // toxic chemicals or acid burns -#define DMG_SLOWBURN (1<<21) // in an oven -#define DMG_SLOWFREEZE (1<<22) // in a subzero freezer -#define DMG_MORTAR (1<<23) // Hit by air raid (done to distinguish grenade from mortar) -#define DMG_EXPLOSION (1<<24) - -// these are the damage types that are allowed to gib corpses -#define DMG_GIB_CORPSE (DMG_CRUSH | DMG_FALL | DMG_BLAST | DMG_SONIC | DMG_CLUB) - -// these are the damage types that have client hud art -#define DMG_SHOWNHUD (DMG_POISON | DMG_ACID | DMG_FREEZE | DMG_SLOWFREEZE | DMG_DROWN | DMG_BURN | DMG_SLOWBURN | DMG_NERVEGAS | DMG_RADIATION | DMG_SHOCK) - -#define AIRTIME 12 // lung full of air lasts this many seconds -#define PARALYZE_DURATION 2 // number of 2 second intervals to take damage -#define PARALYZE_DAMAGE 1.0f // damage to take each 2 second interval - -#define NERVEGAS_DURATION 2 -#define NERVEGAS_DAMAGE 5.0f - -#define POISON_DURATION 5 -#define POISON_DAMAGE 2.0f - -#define RADIATION_DURATION 2 -#define RADIATION_DAMAGE 1.0f - -#define ACID_DURATION 2 -#define ACID_DAMAGE 5.0f - -#define SLOWBURN_DURATION 2 -#define SLOWBURN_DAMAGE 1.0f - -#define SLOWFREEZE_DURATION 2 -#define SLOWFREEZE_DAMAGE 1.0f - -#define itbd_Paralyze 0 -#define itbd_NerveGas 1 -#define itbd_Poison 2 -#define itbd_Radiation 3 -#define itbd_DrownRecover 4 -#define itbd_Acid 5 -#define itbd_SlowBurn 6 -#define itbd_SlowFreeze 7 -#define CDMG_TIMEBASED 8 - -// when calling KILLED(), a value that governs gib behavior is expected to be -// one of these three values -#define GIB_NORMAL 0 // gib if entity was overkilled -#define GIB_NEVER 1 // never gib, no matter how much death damage is done ( freezing, etc ) -#define GIB_ALWAYS 2 // always gib ( Houndeye Shock, Barnacle Bite ) -#define GIB_HEALTH_VALUE -30 - -#define SF_ITEM_USE_ONLY 256 - -#define MAX_MULTI_TARGETS 16 -#define MS_MAX_TARGETS 32 - -#ifdef _WIN32 - #define EXPORT __declspec(dllexport) -#else - #define EXPORT /**/ -#endif // _WIN32 - -class CGrenade; +class CSave; +class CRestore; +class CBasePlayer; class CBaseEntity; class CBaseMonster; class CBasePlayerItem; -class CBasePlayerWeapon; class CSquadMonster; class CCSEntity; -class CCineMonster; -class CSound; - -// EHANDLE. Safe way to point to CBaseEntities who may die between frames -class EHANDLE { -public: - edict_t *Get(); - edict_t *Set(edict_t *pent); - - operator int(); - operator CBaseEntity*(); - operator CBasePlayer*() { return static_cast(GET_PRIVATE(Get())); } - - CBaseEntity *operator=(CBaseEntity *pEntity); - CBaseEntity *operator->(); - -private: - edict_t *m_pent; - int m_serialnumber; -}; +#undef CREATE_NAMED_ENTITY +#undef REMOVE_ENTITY // Base Entity. All entity types derive from this class CBaseEntity { @@ -234,8 +57,14 @@ public: virtual int Restore(CRestore &restore); virtual int ObjectCaps() { return FCAP_ACROSS_TRANSITION; } virtual void Activate() {} + + // Setup the object->object collision box (pev->mins / pev->maxs is the object->world collision box) virtual void SetObjectCollisionBox(); + + // Classify - returns the type of group (i.e, "houndeye", or "human military" so that monsters with different classnames + // still realize that they are teammates. (overridden for monsters that form groups) virtual int Classify() { return CLASS_NONE; } + virtual void DeathNotice(entvars_t *pevChild) {} virtual void TraceAttack(entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType); virtual BOOL TakeDamage(entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType); @@ -244,8 +73,8 @@ public: virtual int BloodColor() { return DONT_BLEED; } virtual void TraceBleed(float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType); virtual BOOL IsTriggered(CBaseEntity *pActivator) { return TRUE; } - virtual CBaseMonster *MyMonsterPointer() { return NULL; } - virtual CSquadMonster *MySquadMonsterPointer() { return NULL; } + virtual CBaseMonster *MyMonsterPointer() { return nullptr; } + virtual CSquadMonster *MySquadMonsterPointer() { return nullptr; } virtual int GetToggleState() { return TS_AT_TOP; } virtual void AddPoints(int score, BOOL bAllowNegativeScore) {} virtual void AddPointsToTeam(int score, BOOL bAllowNegativeScore) {} @@ -256,13 +85,16 @@ public: virtual int IsMoving() { return (pev->velocity != g_vecZero); } virtual void OverrideReset() {} virtual int DamageDecal(int bitsDamageType); - virtual void SetToggleState(int state) {} - virtual void StartSneaking() {} -#ifndef REGAMEDLL_FIXES + // This is ONLY used by the node graph to test movement through a door + virtual void SetToggleState(int state) {} + +#ifndef REGAMEDLL_API + virtual void StartSneaking() {} virtual void StopSneaking() {} #else - virtual void UpdateOnRemove(); + virtual void OnCreate(); + virtual void OnDestroy(); #endif virtual BOOL OnControls(entvars_t *onpev) { return FALSE; } @@ -280,15 +112,17 @@ public: virtual void Touch(CBaseEntity *pOther) { if (m_pfnTouch) (this->*m_pfnTouch)(pOther); } virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType = USE_OFF, float value = 0.0f) { if (m_pfnUse) (this->*m_pfnUse)(pActivator, pCaller, useType, value); } virtual void Blocked(CBaseEntity *pOther) { if (m_pfnBlocked) (this->*m_pfnBlocked)(pOther); } - virtual CBaseEntity *Respawn() { return NULL; } + virtual CBaseEntity *Respawn() { return nullptr; } // used by monsters that are created by the MonsterMaker virtual void UpdateOwner() {} virtual BOOL FBecomeProne() { return FALSE; } - virtual Vector Center() { return (pev->absmax + pev->absmin) * 0.5f; } - virtual Vector EyePosition() { return (pev->origin + pev->view_ofs); } - virtual Vector EarPosition() { return (pev->origin + pev->view_ofs); } - virtual Vector BodyTarget(const Vector &posSrc) { return Center(); } + + virtual Vector Center() { return (pev->absmax + pev->absmin) * 0.5f; } // center point of entity + virtual Vector EyePosition() { return (pev->origin + pev->view_ofs); } // position of eyes + virtual Vector EarPosition() { return (pev->origin + pev->view_ofs); } // position of ears + virtual Vector BodyTarget(const Vector &posSrc) { return Center(); } // position to shoot at + virtual int Illumination() { return GETENTITYILLUM(ENT(pev)); } virtual BOOL FVisible(CBaseEntity *pEntity); @@ -303,9 +137,7 @@ public: void operator delete(void *pMem, entvars_t *pevnew) { pevnew->flags |= FL_KILLME; } #endif -#ifndef REGAMEDLL_FIXES void UpdateOnRemove(); -#endif void EXPORT SUB_Remove(); void EXPORT SUB_DoNothing(); @@ -313,10 +145,11 @@ public: void EXPORT SUB_FadeOut(); void EXPORT SUB_CallUseToggle() { Use(this, this, USE_TOGGLE, 0); } int ShouldToggle(USE_TYPE useType, BOOL currentState); - void FireBullets(ULONG cShots, Vector vecSrc, Vector vecDirShooting, Vector vecSpread, float flDistance, int iBulletType, int iTracerFreq = 4, int iDamage = 0, entvars_t *pevAttacker = NULL); + void FireBullets(ULONG cShots, Vector vecSrc, Vector vecDirShooting, Vector vecSpread, float flDistance, int iBulletType, int iTracerFreq = 4, int iDamage = 0, entvars_t *pevAttacker = nullptr); Vector FireBullets3(Vector vecSrc, Vector vecDirShooting, float vecSpread, float flDistance, int iPenetration, int iBulletType, int iDamage, float flRangeModifier, entvars_t *pevAttacker, bool bPistol, int shared_rand = 0); void SUB_UseTargets(CBaseEntity *pActivator, USE_TYPE useType, float value); - int Intersects(CBaseEntity *pOther); + bool Intersects(CBaseEntity *pOther); + bool Intersects(const Vector &mins, const Vector &maxs); void MakeDormant(); int IsDormant(); BOOL IsLockedByMaster() { return FALSE; } @@ -337,26 +170,30 @@ public: CBaseMonster *GetMonsterPointer(entvars_t *pevMonster) { CBaseEntity *pEntity = Instance(pevMonster); - if (pEntity != NULL) + if (pEntity) { return pEntity->MyMonsterPointer(); + } - return NULL; + return nullptr; } CBaseMonster *GetMonsterPointer(edict_t *pentMonster) { CBaseEntity *pEntity = Instance(pentMonster); - if (pEntity != NULL) + if (pEntity) { return pEntity->MyMonsterPointer(); + } - return NULL; + return nullptr; } - static CBaseEntity *Create(char *szName, const Vector &vecOrigin, const Vector &vecAngles, edict_t *pentOwner = NULL); + static CBaseEntity *Create(char *szName, const Vector &vecOrigin, const Vector &vecAngles, edict_t *pentOwner = nullptr); edict_t *edict() { return ENT(pev); } EOFFSET eoffset() { return OFFSET(pev); } int entindex() { return ENTINDEX(edict()); } public: - entvars_t *pev; // Don't need to save/restore this pointer, the engine resets it + // Constructor. Set engine to use C/C++ callback functions + // pointers to engine data + entvars_t *pev; // Don't need to save/restore this pointer, the engine resets it // path corners CBaseEntity *m_pGoalEnt; // path corner we are heading towards @@ -364,11 +201,32 @@ public: static TYPEDESCRIPTION IMPL(m_SaveData)[5]; + // fundamental callbacks void (CBaseEntity::*m_pfnThink)(); void (CBaseEntity::*m_pfnTouch)(CBaseEntity *pOther); void (CBaseEntity::*m_pfnUse)(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); void (CBaseEntity::*m_pfnBlocked)(CBaseEntity *pOther); + using thinkfn_t = decltype(m_pfnThink); + template + void SetThink(void (T::*pfn)()); + void SetThink(std::nullptr_t); + + using touchfn_t = decltype(m_pfnTouch); + template + void SetTouch(void (T::*pfn)(CBaseEntity *pOther)); + void SetTouch(std::nullptr_t); + + using usefn_t = decltype(m_pfnUse); + template + void SetUse(void (T::*pfn)(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value)); + void SetUse(std::nullptr_t); + + using blockedfn_t = decltype(m_pfnBlocked); + template + void SetBlocked(void (T::*pfn)(CBaseEntity *pOther)); + void SetBlocked(std::nullptr_t); + #ifdef REGAMEDLL_API CCSEntity *m_pEntity; #else @@ -408,8 +266,52 @@ public: bool has_disconnected; }; -inline int FNullEnt(CBaseEntity *ent) { return (ent == NULL || FNullEnt(ent->edict())); } -inline int FNullEnt(EHANDLE hent) { return (hent == NULL || FNullEnt(OFFSET(hent.Get()))); } +// Inlines +inline BOOL FNullEnt(CBaseEntity *ent) { return (ent == NULL || FNullEnt(ent->edict())); } + +template +inline void CBaseEntity::SetThink(void (T::*pfn)()) +{ + m_pfnThink = static_cast(pfn); +} + +inline void CBaseEntity::SetThink(std::nullptr_t) +{ + m_pfnThink = nullptr; +} + +template +inline void CBaseEntity::SetTouch(void (T::*pfn)(CBaseEntity *pOther)) +{ + m_pfnTouch = static_cast(pfn); +} + +inline void CBaseEntity::SetTouch(std::nullptr_t) +{ + m_pfnTouch = nullptr; +} + +template +inline void CBaseEntity::SetUse(void (T::*pfn)(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value)) +{ + m_pfnUse = static_cast(pfn); +} + +inline void CBaseEntity::SetUse(std::nullptr_t) +{ + m_pfnUse = nullptr; +} + +template +inline void CBaseEntity::SetBlocked(void (T::*pfn)(CBaseEntity *pOther)) +{ + m_pfnBlocked = static_cast(pfn); +} + +inline void CBaseEntity::SetBlocked(std::nullptr_t) +{ + m_pfnBlocked = nullptr; +} class CPointEntity: public CBaseEntity { public: @@ -417,33 +319,6 @@ public: virtual int ObjectCaps() { return (CBaseEntity::ObjectCaps() & ~FCAP_ACROSS_TRANSITION); } }; -// MultiSouce -class CMultiSource: public CPointEntity { -public: - virtual void Spawn(); - virtual void KeyValue(KeyValueData *pkvd); - virtual int Save(CSave &save); - virtual int Restore(CRestore &restore); - virtual int ObjectCaps() { return (CPointEntity::ObjectCaps() | FCAP_MASTER); } - virtual BOOL IsTriggered(CBaseEntity *pActivator); - virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); - -#ifdef REGAMEDLL_FIXES - virtual void Restart(); -#endif - -public: - void EXPORT Register(); - -public: - static TYPEDESCRIPTION IMPL(m_SaveData)[4]; - - EHANDLE m_rgEntities[MS_MAX_TARGETS]; - int m_rgTriggered[MS_MAX_TARGETS]; - int m_iTotal; - string_t m_globalstate; -}; - // generic Delay entity. class CBaseDelay: public CBaseEntity { public: @@ -458,7 +333,7 @@ public: static TYPEDESCRIPTION IMPL(m_SaveData)[2]; float m_flDelay; - int m_iszKillTarget; + string_t m_iszKillTarget; }; class CBaseAnimating: public CBaseDelay { @@ -469,7 +344,7 @@ public: public: // Basic Monster Animation functions - float StudioFrameAdvance(float flInterval = 0.0f); // accumulate animation frame time from last time called until now + float StudioFrameAdvance(float flInterval = 0.0f); // accumulate animation frame time from last time called until now int GetSequenceFlags(); int LookupActivity(int activity); int LookupActivityHeaviest(int activity); @@ -498,11 +373,11 @@ public: static TYPEDESCRIPTION IMPL(m_SaveData)[5]; // animation needs - float m_flFrameRate; // computed FPS for current sequence - float m_flGroundSpeed; // computed linear movement rate for current sequence - float m_flLastEventCheck; // last time the event list was checked - BOOL m_fSequenceFinished; // flag set when StudioAdvanceFrame moves across a frame boundry - BOOL m_fSequenceLoops; // true if the sequence loops + float m_flFrameRate; // computed FPS for current sequence + float m_flGroundSpeed; // computed linear movement rate for current sequence + float m_flLastEventCheck; // last time the event list was checked + BOOL m_fSequenceFinished; // flag set when StudioAdvanceFrame moves across a frame boundry + BOOL m_fSequenceLoops; // true if the sequence loops }; // generic Toggle entity. @@ -534,8 +409,8 @@ public: float m_flMoveDistance; // how far a door should slide or rotate float m_flWait; float m_flLip; - float m_flTWidth; // for plats - float m_flTLength; // for plats + float m_flTWidth; // for plats + float m_flTLength; // for plats Vector m_vecPosition1; Vector m_vecPosition2; @@ -544,8 +419,14 @@ public: int m_cTriggersLeft; // trigger_counter only, # of activations remaining float m_flHeight; - EHANDLE m_hActivator; + EHandle m_hActivator; void (CBaseToggle::*m_pfnCallWhenMoveDone)(); + + using movedonefn_t = decltype(m_pfnCallWhenMoveDone); + template + void SetMoveDone(void (T::*pfn)()); + void SetMoveDone(std::nullptr_t); + Vector m_vecFinalDest; Vector m_vecFinalAngle; @@ -558,7 +439,25 @@ public: // deactivated. }; +template +inline void CBaseToggle::SetMoveDone(void (T::*pfn)()) +{ + m_pfnCallWhenMoveDone = static_cast(pfn); +} + +inline void CBaseToggle::SetMoveDone(std::nullptr_t) +{ + m_pfnCallWhenMoveDone = nullptr; +} + +#include "world.h" #include "basemonster.h" +#include "player.h" + +#define SF_BUTTON_DONTMOVE BIT(0) +#define SF_BUTTON_TOGGLE BIT(5) // button stays pushed until reactivated +#define SF_BUTTON_SPARK_IF_OFF BIT(6) // button sparks in OFF state +#define SF_BUTTON_TOUCH_ONLY BIT(8) // button only fires as a result of USE key. // Generic Button class CBaseButton: public CBaseToggle { @@ -569,6 +468,8 @@ public: virtual BOOL TakeDamage(entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType); virtual int Save(CSave &save); virtual int Restore(CRestore &restore); + + // Buttons that don't take damage can be IMPULSE used virtual int ObjectCaps() { if (pev->takedamage == DAMAGE_NO) @@ -602,27 +503,50 @@ public: public: static TYPEDESCRIPTION IMPL(m_SaveData)[8]; - BOOL m_fStayPushed; - BOOL m_fRotating; - string_t m_strChangeTarget; - locksound_t m_ls; - byte m_bLockedSound; + BOOL m_fStayPushed; // button stays pushed in until touched again? + BOOL m_fRotating; // a rotating button? default is a sliding button. + + string_t m_strChangeTarget; // if this field is not null, this is an index into the engine string array. + // when this button is touched, it's target entity's TARGET field will be set + // to the button's ChangeTarget. This allows you to make a func_train switch paths, etc. + + locksound_t m_ls; // door lock sounds + + byte m_bLockedSound; // ordinals from entity selection byte m_bLockedSentence; byte m_bUnlockedSound; byte m_bUnlockedSentence; int m_sounds; }; -#define SF_WORLD_DARK 0x0001 // Fade from black at startup -#define SF_WORLD_TITLE 0x0002 // Display game title at startup -#define SF_WORLD_FORCETEAM 0x0004 // Force teams +// MultiSouce +#define MAX_MS_TARGETS 32 // maximum number of targets a single multisource entity may be assigned. +#define SF_MULTI_INIT BIT(0) -// This spawns first when each level begins. -class CWorld: public CBaseEntity { +class CMultiSource: public CPointEntity { public: virtual void Spawn(); - virtual void Precache(); virtual void KeyValue(KeyValueData *pkvd); + virtual int Save(CSave &save); + virtual int Restore(CRestore &restore); + virtual int ObjectCaps() { return (CPointEntity::ObjectCaps() | FCAP_MASTER); } + virtual BOOL IsTriggered(CBaseEntity *pActivator); + virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); + +#ifdef REGAMEDLL_FIXES + virtual void Restart(); +#endif + +public: + void EXPORT Register(); + +public: + static TYPEDESCRIPTION IMPL(m_SaveData)[4]; + + EHandle m_rgEntities[MAX_MS_TARGETS]; + int m_rgTriggered[MAX_MS_TARGETS]; + int m_iTotal; + string_t m_globalstate; }; // Converts a entvars_t * to a class pointer @@ -646,6 +570,7 @@ T *GetClassPtr(T *a) a->pev = pev; #ifdef REGAMEDLL_API + a->OnCreate(); a->m_pEntity = new W(); a->m_pEntity->m_pContainingEntity = a; #endif @@ -663,27 +588,27 @@ extern CUtlVector stringsHashTable; C_DLLEXPORT int GetEntityAPI(DLL_FUNCTIONS *pFunctionTable, int interfaceVersion); C_DLLEXPORT int GetNewDLLFunctions(NEW_DLL_FUNCTIONS *pFunctionTable, int *interfaceVersion); +void REMOVE_ENTITY(edict_t *pEntity); + int CaseInsensitiveHash(const char *string, int iBounds); void EmptyEntityHashTable(); -void AddEntityHashValue(entvars_t *pev, const char *value, hash_types_e fieldType); -void RemoveEntityHashValue(entvars_t *pev, const char *value, hash_types_e fieldType); -void printEntities(); -edict_t *CREATE_NAMED_ENTITY(string_t iClass); -void REMOVE_ENTITY(edict_t *pEntity); -void loopPerformance(); -int DispatchSpawn(edict_t *pent); -void DispatchKeyValue(edict_t *pentKeyvalue, KeyValueData *pkvd); -void DispatchTouch(edict_t *pentTouched, edict_t *pentOther); -void DispatchUse(edict_t *pentUsed, edict_t *pentOther); -void DispatchThink(edict_t *pent); -void DispatchBlocked(edict_t *pentBlocked, edict_t *pentOther); -void DispatchSave(edict_t *pent, SAVERESTOREDATA *pSaveData); -int DispatchRestore(edict_t *pent, SAVERESTOREDATA *pSaveData, int globalEntity); -CBaseEntity *FindGlobalEntity(string_t classname, string_t globalname); -void DispatchObjectCollsionBox(edict_t *pent); -void SaveWriteFields(SAVERESTOREDATA *pSaveData, const char *pname, void *pBaseData, TYPEDESCRIPTION *pFields, int fieldCount); -void SaveReadFields(SAVERESTOREDATA *pSaveData, const char *pname, void *pBaseData, TYPEDESCRIPTION *pFields, int fieldCount); -void SetObjectCollisionBox(entvars_t *pev); -void OnFreeEntPrivateData(edict_t *pEnt); -#endif // CBASE_H +EXT_FUNC edict_t *CREATE_NAMED_ENTITY(string_t iClass); +EXT_FUNC void AddEntityHashValue(entvars_t *pev, const char *value, hash_types_e fieldType); +EXT_FUNC void RemoveEntityHashValue(entvars_t *pev, const char *value, hash_types_e fieldType); + +EXT_FUNC int DispatchSpawn(edict_t *pent); +EXT_FUNC void DispatchKeyValue(edict_t *pentKeyvalue, KeyValueData *pkvd); +EXT_FUNC void DispatchTouch(edict_t *pentTouched, edict_t *pentOther); +EXT_FUNC void DispatchUse(edict_t *pentUsed, edict_t *pentOther); +EXT_FUNC void DispatchThink(edict_t *pent); +EXT_FUNC void DispatchBlocked(edict_t *pentBlocked, edict_t *pentOther); +EXT_FUNC void DispatchSave(edict_t *pent, SAVERESTOREDATA *pSaveData); +EXT_FUNC int DispatchRestore(edict_t *pent, SAVERESTOREDATA *pSaveData, int globalEntity); +EXT_FUNC void DispatchObjectCollsionBox(edict_t *pent); +EXT_FUNC void SaveWriteFields(SAVERESTOREDATA *pSaveData, const char *pname, void *pBaseData, TYPEDESCRIPTION *pFields, int fieldCount); +EXT_FUNC void SaveReadFields(SAVERESTOREDATA *pSaveData, const char *pname, void *pBaseData, TYPEDESCRIPTION *pFields, int fieldCount); +EXT_FUNC void OnFreeEntPrivateData(edict_t *pEnt); + +void SetObjectCollisionBox(entvars_t *pev); +CBaseEntity *FindGlobalEntity(string_t classname, string_t globalname); diff --git a/regamedll/dlls/cdll_dll.h b/regamedll/dlls/cdll_dll.h index 1a37e0d3..92aee04c 100644 --- a/regamedll/dlls/cdll_dll.h +++ b/regamedll/dlls/cdll_dll.h @@ -26,80 +26,68 @@ * */ -#ifndef CDLL_DLL_H -#define CDLL_DLL_H -#ifdef _WIN32 #pragma once -#endif -#define MAX_WEAPON_SLOTS 5 // hud item selection slots -#define MAX_ITEM_TYPES 6 // hud item selection slots +const int MAX_WEAPON_SLOTS = 5; // hud item selection slots +const int MAX_ITEM_TYPES = 6; // hud item selection slots +const int MAX_AMMO_SLOTS = 32; // not really slots +const int MAX_ITEMS = 4; // hard coded item types -#define MAX_ITEMS 4 // hard coded item types +const int DEFAULT_FOV = 90; // the default field of view -#define DEFAULT_FOV 90 // the default field of view +#define HIDEHUD_WEAPONS BIT(0) +#define HIDEHUD_FLASHLIGHT BIT(1) +#define HIDEHUD_ALL BIT(2) +#define HIDEHUD_HEALTH BIT(3) +#define HIDEHUD_TIMER BIT(4) +#define HIDEHUD_MONEY BIT(5) +#define HIDEHUD_CROSSHAIR BIT(6) +#define HIDEHUD_OBSERVER_CROSSHAIR BIT(7) -#define HIDEHUD_WEAPONS (1<<0) -#define HIDEHUD_FLASHLIGHT (1<<1) -#define HIDEHUD_ALL (1<<2) -#define HIDEHUD_HEALTH (1<<3) -#define HIDEHUD_TIMER (1<<4) -#define HIDEHUD_MONEY (1<<5) -#define HIDEHUD_CROSSHAIR (1<<6) -#define HIDEHUD_OBSERVER_CROSSHAIR (1<<7) +#define STATUSICON_HIDE 0 +#define STATUSICON_SHOW 1 +#define STATUSICON_FLASH 2 -#define STATUSICON_HIDE 0 -#define STATUSICON_SHOW 1 -#define STATUSICON_FLASH 2 +#define HUD_PRINTNOTIFY 1 +#define HUD_PRINTCONSOLE 2 +#define HUD_PRINTTALK 3 +#define HUD_PRINTCENTER 4 +#define HUD_PRINTRADIO 5 -#define HUD_PRINTNOTIFY 1 -#define HUD_PRINTCONSOLE 2 -#define HUD_PRINTTALK 3 -#define HUD_PRINTCENTER 4 -#define HUD_PRINTRADIO 5 +#define STATUS_NIGHTVISION_ON 1 +#define STATUS_NIGHTVISION_OFF 0 -#define STATUS_NIGHTVISION_ON 1 -#define STATUS_NIGHTVISION_OFF 0 +#define ITEM_STATUS_NIGHTVISION BIT(0) +#define ITEM_STATUS_DEFUSER BIT(1) -#define ITEM_STATUS_NIGHTVISION (1<<0) -#define ITEM_STATUS_DEFUSER (1<<1) - -#define SCORE_STATUS_DEAD (1<<0) -#define SCORE_STATUS_BOMB (1<<1) -#define SCORE_STATUS_VIP (1<<2) - -#define SIGNAL_BUY (1<<0) -#define SIGNAL_BOMB (1<<1) -#define SIGNAL_RESCUE (1<<2) -#define SIGNAL_ESCAPE (1<<3) -#define SIGNAL_VIPSAFETY (1<<4) +#define SCORE_STATUS_DEAD BIT(0) +#define SCORE_STATUS_BOMB BIT(1) +#define SCORE_STATUS_VIP BIT(2) // player data iuser3 -#define PLAYER_CAN_SHOOT (1<<0) -#define PLAYER_FREEZE_TIME_OVER (1<<1) -#define PLAYER_IN_BOMB_ZONE (1<<2) -#define PLAYER_HOLDING_SHIELD (1<<3) +#define PLAYER_CAN_SHOOT BIT(0) +#define PLAYER_FREEZE_TIME_OVER BIT(1) +#define PLAYER_IN_BOMB_ZONE BIT(2) +#define PLAYER_HOLDING_SHIELD BIT(3) -#define MENU_KEY_1 (1<<0) -#define MENU_KEY_2 (1<<1) -#define MENU_KEY_3 (1<<2) -#define MENU_KEY_4 (1<<3) -#define MENU_KEY_5 (1<<4) -#define MENU_KEY_6 (1<<5) -#define MENU_KEY_7 (1<<6) -#define MENU_KEY_8 (1<<7) -#define MENU_KEY_9 (1<<8) -#define MENU_KEY_0 (1<<9) +#define MENU_KEY_1 BIT(0) +#define MENU_KEY_2 BIT(1) +#define MENU_KEY_3 BIT(2) +#define MENU_KEY_4 BIT(3) +#define MENU_KEY_5 BIT(4) +#define MENU_KEY_6 BIT(5) +#define MENU_KEY_7 BIT(6) +#define MENU_KEY_8 BIT(7) +#define MENU_KEY_9 BIT(8) +#define MENU_KEY_0 BIT(9) -#define MAX_AMMO_SLOTS 32 // not really slots +#define HUD_PRINTNOTIFY 1 +#define HUD_PRINTCONSOLE 2 +#define HUD_PRINTTALK 3 +#define HUD_PRINTCENTER 4 -#define HUD_PRINTNOTIFY 1 -#define HUD_PRINTCONSOLE 2 -#define HUD_PRINTTALK 3 -#define HUD_PRINTCENTER 4 - -#define WEAPON_SUIT 31 -#define WEAPON_ALLWEAPONS (~(1 << WEAPON_SUIT)) +#define WEAPON_SUIT 31 +#define WEAPON_ALLWEAPONS (~(1<pev); + MESSAGE_BEGIN(MSG_ONE, gmsgBlinkAcct, nullptr, player->pev); WRITE_BYTE(numBlinks); MESSAGE_END(); } @@ -127,7 +324,9 @@ void EXT_FUNC ClientDisconnect(edict_t *pEntity) pEntity->v.flags = FL_DORMANT; if (pPlayer) + { pPlayer->Disconnect(); + } UTIL_SetOrigin(&pEntity->v, pEntity->v.origin); g_pGameRules->ClientDisconnected(pEntity); @@ -199,7 +398,7 @@ LINK_HOOK_VOID_CHAIN(ShowMenu, (CBasePlayer *pPlayer, int bitsValidSlots, int nD void EXT_FUNC __API_HOOK(ShowMenu)(CBasePlayer *pPlayer, int bitsValidSlots, int nDisplayTime, BOOL fNeedMore, char *pszText) { - MESSAGE_BEGIN(MSG_ONE, gmsgShowMenu, NULL, pPlayer->pev); + MESSAGE_BEGIN(MSG_ONE, gmsgShowMenu, nullptr, pPlayer->pev); WRITE_SHORT(bitsValidSlots); WRITE_CHAR(nDisplayTime); WRITE_BYTE(fNeedMore); @@ -227,7 +426,7 @@ void EXT_FUNC __API_HOOK(ShowVGUIMenu)(CBasePlayer *pPlayer, int MenuType, int B if (pPlayer->m_bVGUIMenus || MenuType > VGUI_Menu_Buy_Item) { - MESSAGE_BEGIN(MSG_ONE, gmsgVGUIMenu, NULL, pPlayer->pev); + MESSAGE_BEGIN(MSG_ONE, gmsgVGUIMenu, nullptr, pPlayer->pev); WRITE_BYTE(MenuType); WRITE_SHORT(BitMask); WRITE_CHAR(-1); @@ -242,28 +441,28 @@ void EXT_FUNC __API_HOOK(ShowVGUIMenu)(CBasePlayer *pPlayer, int MenuType, int B NOXREF int CountTeams() { int iNumCT = 0, iNumTerrorist = 0; - CBaseEntity *pPlayer = NULL; + CBaseEntity *pEntity = nullptr; - while ((pPlayer = UTIL_FindEntityByClassname(pPlayer, "player"))) + while ((pEntity = UTIL_FindEntityByClassname(pEntity, "player"))) { - if (FNullEnt(pPlayer->edict())) + if (FNullEnt(pEntity->edict())) break; - CBasePlayer *player = GetClassPtr((CBasePlayer *)pPlayer->pev); + CBasePlayer *pPlayer = GetClassPtr((CBasePlayer *)pEntity->pev); - if (player->m_iTeam == UNASSIGNED) + if (pPlayer->m_iTeam == UNASSIGNED) continue; - if (player->pev->flags & FL_DORMANT) + if (pPlayer->pev->flags & FL_DORMANT) continue; - if (player->m_iTeam == SPECTATOR) + if (pPlayer->m_iTeam == SPECTATOR) continue; - if (player->m_iTeam == CT) + if (pPlayer->m_iTeam == CT) iNumCT++; - else if (player->m_iTeam == TERRORIST) + else if (pPlayer->m_iTeam == TERRORIST) iNumTerrorist++; } @@ -274,23 +473,23 @@ void ListPlayers(CBasePlayer *current) { char message[120] = "", cNumber[12]; - CBaseEntity *pPlayer = NULL; - while ((pPlayer = UTIL_FindEntityByClassname(pPlayer, "player"))) + CBaseEntity *pEntity = nullptr; + while ((pEntity = UTIL_FindEntityByClassname(pEntity, "player"))) { - if (FNullEnt(pPlayer->edict())) + if (FNullEnt(pEntity->edict())) break; - if (pPlayer->pev->flags & FL_DORMANT) + if (pEntity->pev->flags & FL_DORMANT) continue; - CBasePlayer *player = GetClassPtr((CBasePlayer *)pPlayer->pev); - int iUserID = GETPLAYERUSERID(ENT(player->pev)); + CBasePlayer *pPlayer = GetClassPtr((CBasePlayer *)pEntity->pev); + int iUserID = GETPLAYERUSERID(ENT(pPlayer->pev)); Q_sprintf(cNumber, "%d", iUserID); Q_strcpy(message, "\n"); Q_strcat(message, cNumber); Q_strcat(message, " : "); - Q_strcat(message, STRING(player->pev->netname)); + Q_strcat(message, STRING(pPlayer->pev->netname)); ClientPrint(current->pev, HUD_PRINTCONSOLE, message); } @@ -300,22 +499,23 @@ void ListPlayers(CBasePlayer *current) int CountTeamPlayers(int iTeam) { - CBaseEntity *pPlayer = NULL; - int i = 0; - - while ((pPlayer = UTIL_FindEntityByClassname(pPlayer, "player"))) + int nCount = 0; + CBaseEntity *pEntity = nullptr; + while ((pEntity = UTIL_FindEntityByClassname(pEntity, "player"))) { - if (FNullEnt(pPlayer->edict())) + if (FNullEnt(pEntity->edict())) break; - if (pPlayer->pev->flags & FL_DORMANT) + if (pEntity->pev->flags & FL_DORMANT) continue; - if (GetClassPtr((CBasePlayer *)pPlayer->pev)->m_iTeam == iTeam) - ++i; + if (GetClassPtr((CBasePlayer *)pEntity->pev)->m_iTeam == iTeam) + { + nCount++; + } } - return i; + return nCount; } void ProcessKickVote(CBasePlayer *pVotingPlayer, CBasePlayer *pKickPlayer) @@ -336,7 +536,7 @@ void ProcessKickVote(CBasePlayer *pVotingPlayer, CBasePlayer *pKickPlayer) return; iValidVotes = 0; - pTempEntity = NULL; + pTempEntity = nullptr; iVoteID = pVotingPlayer->m_iCurrentKickVote; while ((pTempEntity = UTIL_FindEntityByClassname(pTempEntity, "player"))) @@ -366,7 +566,7 @@ void ProcessKickVote(CBasePlayer *pVotingPlayer, CBasePlayer *pKickPlayer) { UTIL_ClientPrintAll(HUD_PRINTCENTER, "#Game_kicked", STRING(pKickPlayer->pev->netname)); SERVER_COMMAND(UTIL_VarArgs("kick # %d\n", iVoteID)); - pTempEntity = NULL; + pTempEntity = nullptr; while ((pTempEntity = UTIL_FindEntityByClassname(pTempEntity, "player"))) { @@ -457,25 +657,25 @@ void EXT_FUNC ClientPutInServer(edict_t *pEntity) pPlayer->has_disconnected = false; pPlayer->m_iMenu = Menu_OFF; pPlayer->ClearAutoBuyData(); - pPlayer->m_rebuyString = NULL; + pPlayer->m_rebuyString = nullptr; SET_CLIENT_MAXSPEED(ENT(pPlayer->pev), 1); SET_MODEL(ENT(pPlayer->pev), "models/player.mdl"); pPlayer->SetThink(NULL); - CBaseEntity *pTarget = NULL; - pPlayer->m_pIntroCamera = UTIL_FindEntityByClassname(NULL, "trigger_camera"); + CBaseEntity *pTarget = nullptr; + pPlayer->m_pIntroCamera = UTIL_FindEntityByClassname(nullptr, "trigger_camera"); if (g_pGameRules && g_pGameRules->IsMultiplayer()) { - CSGameRules()->m_bMapHasCameras = (pPlayer->m_pIntroCamera != NULL); + CSGameRules()->m_bMapHasCameras = (pPlayer->m_pIntroCamera != nullptr); } if (pPlayer->m_pIntroCamera) { // find the target (by default info_target) for the camera view direction. - pTarget = UTIL_FindEntityByTargetname(NULL, STRING(pPlayer->m_pIntroCamera->pev->target)); + pTarget = UTIL_FindEntityByTargetname(nullptr, STRING(pPlayer->m_pIntroCamera->pev->target)); } if (pPlayer->m_pIntroCamera && pTarget) @@ -599,15 +799,15 @@ void Host_Say(edict_t *pEntity, BOOL teamonly) if (Q_strlen(p) <= 0) return; - const char *placeName = NULL; - char *pszFormat = NULL; - char *pszConsoleFormat = NULL; + const char *placeName = nullptr; + char *pszFormat = nullptr; + char *pszConsoleFormat = nullptr; bool consoleUsesPlaceName = false; // team only if (teamonly) { - if (g_bIsCzeroGame && (player->m_iTeam == CT || player->m_iTeam == TERRORIST)) + if (AreRunningCZero() && (player->m_iTeam == CT || player->m_iTeam == TERRORIST)) { // search the place name where is located the player Place playerPlace = TheNavAreaGrid.GetPlace(&player->pev->origin); @@ -722,7 +922,7 @@ void Host_Say(edict_t *pEntity, BOOL teamonly) // This may return the world in single player if the client types something between levels or during spawn // so check it, or it will infinite loop - client = NULL; + client = nullptr; while ((client = (CBasePlayer *)UTIL_FindEntityByClassname(client, "player"))) { if (FNullEnt(client->edict())) @@ -754,7 +954,7 @@ void Host_Say(edict_t *pEntity, BOOL teamonly) if ((client->m_iIgnoreGlobalChat == IGNOREMSG_ENEMY && client->m_iTeam == player->m_iTeam) || client->m_iIgnoreGlobalChat == IGNOREMSG_NONE) { - MESSAGE_BEGIN(MSG_ONE, gmsgSayText, NULL, client->pev); + MESSAGE_BEGIN(MSG_ONE, gmsgSayText, nullptr, client->pev); WRITE_BYTE(ENTINDEX(pEntity)); WRITE_STRING(pszFormat); WRITE_STRING(""); @@ -772,7 +972,7 @@ void Host_Say(edict_t *pEntity, BOOL teamonly) char *fullText = p; // print to the sending client - MESSAGE_BEGIN(MSG_ONE, gmsgSayText, NULL, &pEntity->v); + MESSAGE_BEGIN(MSG_ONE, gmsgSayText, nullptr, &pEntity->v); WRITE_BYTE(ENTINDEX(pEntity)); WRITE_STRING(pszFormat); WRITE_STRING(""); @@ -968,7 +1168,7 @@ void BuyMachineGun(CBasePlayer *pPlayer, int iSlot) void BuyItem(CBasePlayer *pPlayer, int iSlot) { int iItemPrice = 0; - const char *pszItem = NULL; + const char *pszItem = nullptr; if (!pPlayer->CanPlayerBuy(true)) return; @@ -1208,7 +1408,7 @@ void BuyItem(CBasePlayer *pPlayer, int iSlot) bEnoughMoney = true; pPlayer->m_bHasDefuser = true; - MESSAGE_BEGIN(MSG_ONE, gmsgStatusIcon, NULL, pPlayer->pev); + MESSAGE_BEGIN(MSG_ONE, gmsgStatusIcon, nullptr, pPlayer->pev); WRITE_BYTE(STATUSICON_SHOW); WRITE_STRING("defuser"); WRITE_BYTE(0); @@ -1331,7 +1531,7 @@ LINK_HOOK_VOID_CHAIN(HandleMenu_ChooseAppearance, (CBasePlayer *player, int slot void EXT_FUNC __API_HOOK(HandleMenu_ChooseAppearance)(CBasePlayer *player, int slot) { - int numSkins = g_bIsCzeroGame ? CZ_NUM_SKIN : CS_NUM_SKIN; + int numSkins = AreRunningCZero() ? CZ_NUM_SKIN : CS_NUM_SKIN; struct { @@ -1369,7 +1569,7 @@ void EXT_FUNC __API_HOOK(HandleMenu_ChooseAppearance)(CBasePlayer *player, int s appearance.model_name = "guerilla"; break; case 5: - if (g_bIsCzeroGame) + if (AreRunningCZero()) { appearance.model_id = MODEL_MILITIA; appearance.model_name = "militia"; @@ -1418,7 +1618,7 @@ void EXT_FUNC __API_HOOK(HandleMenu_ChooseAppearance)(CBasePlayer *player, int s appearance.model_name = "gign"; break; case 5: - if (g_bIsCzeroGame) + if (AreRunningCZero()) { appearance.model_id = MODEL_SPETSNAZ; appearance.model_name = "spetsnaz"; @@ -1613,7 +1813,7 @@ BOOL EXT_FUNC __API_HOOK(HandleMenu_ChooseTeam)(CBasePlayer *player, int slot) #else player->m_iAccount = 0; - MESSAGE_BEGIN(MSG_ONE, gmsgMoney, NULL, player->pev); + MESSAGE_BEGIN(MSG_ONE, gmsgMoney, nullptr, player->pev); WRITE_LONG(player->m_iAccount); WRITE_BYTE(0); MESSAGE_END(); @@ -1631,7 +1831,7 @@ BOOL EXT_FUNC __API_HOOK(HandleMenu_ChooseTeam)(CBasePlayer *player, int slot) WRITE_SHORT(0); MESSAGE_END(); - player->m_pIntroCamera = NULL; + player->m_pIntroCamera = nullptr; player->m_bTeamChanged = true; if (TheBots) @@ -1792,14 +1992,14 @@ BOOL EXT_FUNC __API_HOOK(HandleMenu_ChooseTeam)(CBasePlayer *player, int slot) switch (team) { case CT: - if (g_bIsCzeroGame) + if (AreRunningCZero()) ShowVGUIMenu(player, VGUI_Menu_Class_CT, (MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_3 | MENU_KEY_4 | MENU_KEY_5 | MENU_KEY_6), "#CT_Select"); else ShowVGUIMenu(player, VGUI_Menu_Class_CT, (MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_3 | MENU_KEY_4 | MENU_KEY_5), "#CT_Select"); break; case TERRORIST: - if (g_bIsCzeroGame) + if (AreRunningCZero()) ShowVGUIMenu(player, VGUI_Menu_Class_T, (MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_3 | MENU_KEY_4 | MENU_KEY_5 | MENU_KEY_6), "#Terrorist_Select"); else ShowVGUIMenu(player, VGUI_Menu_Class_T, (MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_3 | MENU_KEY_4 | MENU_KEY_5), "#Terrorist_Select"); @@ -2056,7 +2256,7 @@ bool BuyAmmo(CBasePlayer *player, int nSlot, bool bBlinkMoney) CBaseEntity *EntityFromUserID(int userID) { - CBaseEntity *pTempEntity = NULL; + CBaseEntity *pTempEntity = nullptr; while ((pTempEntity = UTIL_FindEntityByClassname(pTempEntity, "player"))) { @@ -2071,13 +2271,13 @@ CBaseEntity *EntityFromUserID(int userID) } } - return NULL; + return nullptr; } NOXREF int CountPlayersInServer() { int count = 0; - CBaseEntity *pTempEntity = NULL; + CBaseEntity *pTempEntity = nullptr; while ((pTempEntity = UTIL_FindEntityByClassname(pTempEntity, "player"))) { @@ -2102,7 +2302,7 @@ BOOL HandleBuyAliasCommands(CBasePlayer *pPlayer, const char *pszCommand) { // Let them buy it if it's got a weapon data string. BOOL bRetVal = FALSE; - const char *pszFailItem = NULL; + const char *pszFailItem = nullptr; WeaponIdType weaponID = WEAPON_NONE; const char *weaponFailName = BuyAliasToWeaponID(pszCommand, weaponID); @@ -2289,7 +2489,7 @@ BOOL HandleRadioAliasCommands(CBasePlayer *pPlayer, const char *pszCommand) void EXT_FUNC InternalCommand(edict_t *pEntity, const char *pcmd, const char *parg1) { - const char *pstr = NULL; + const char *pstr = nullptr; entvars_t *pev = &pEntity->v; CBasePlayer *player = GetClassPtr((CBasePlayer *)pev); @@ -2530,7 +2730,7 @@ void EXT_FUNC InternalCommand(edict_t *pEntity, const char *pcmd, const char *pa } else { - MESSAGE_BEGIN(MSG_ONE, gmsgBuyClose, NULL, player->pev); + MESSAGE_BEGIN(MSG_ONE, gmsgBuyClose, nullptr, player->pev); MESSAGE_END(); } } @@ -2892,7 +3092,7 @@ void EXT_FUNC InternalCommand(edict_t *pEntity, const char *pcmd, const char *pa if (mode == OBS_CHASE_FREE) { - MESSAGE_BEGIN(MSG_ONE, gmsgADStop, NULL, player->pev); + MESSAGE_BEGIN(MSG_ONE, gmsgADStop, nullptr, player->pev); MESSAGE_END(); } } @@ -2989,7 +3189,7 @@ void EXT_FUNC InternalCommand(edict_t *pEntity, const char *pcmd, const char *pa { EMIT_SOUND(ENT(player->pev), CHAN_ITEM, "items/nvg_off.wav", RANDOM_FLOAT(0.92, 1), ATTN_NORM); - MESSAGE_BEGIN(MSG_ONE, gmsgNVGToggle, NULL, player->pev); + MESSAGE_BEGIN(MSG_ONE, gmsgNVGToggle, nullptr, player->pev); WRITE_BYTE(0); // disable nightvision MESSAGE_END(); @@ -3002,7 +3202,7 @@ void EXT_FUNC InternalCommand(edict_t *pEntity, const char *pcmd, const char *pa { EMIT_SOUND(ENT(pObserver->pev), CHAN_ITEM, "items/nvg_off.wav", RANDOM_FLOAT(0.92, 1), ATTN_NORM); - MESSAGE_BEGIN(MSG_ONE, gmsgNVGToggle, NULL, pObserver->pev); + MESSAGE_BEGIN(MSG_ONE, gmsgNVGToggle, nullptr, pObserver->pev); WRITE_BYTE(0); // disable nightvision MESSAGE_END(); @@ -3014,7 +3214,7 @@ void EXT_FUNC InternalCommand(edict_t *pEntity, const char *pcmd, const char *pa { EMIT_SOUND(ENT(player->pev), CHAN_ITEM, "items/nvg_on.wav", RANDOM_FLOAT(0.92, 1), ATTN_NORM); - MESSAGE_BEGIN(MSG_ONE, gmsgNVGToggle, NULL, player->pev); + MESSAGE_BEGIN(MSG_ONE, gmsgNVGToggle, nullptr, player->pev); WRITE_BYTE(1); // enable nightvision MESSAGE_END(); @@ -3027,7 +3227,7 @@ void EXT_FUNC InternalCommand(edict_t *pEntity, const char *pcmd, const char *pa { EMIT_SOUND(ENT(pObserver->pev), CHAN_ITEM, "items/nvg_on.wav", RANDOM_FLOAT(0.92, 1), ATTN_NORM); - MESSAGE_BEGIN(MSG_ONE, gmsgNVGToggle, NULL, pObserver->pev); + MESSAGE_BEGIN(MSG_ONE, gmsgNVGToggle, nullptr, pObserver->pev); WRITE_BYTE(1); // enable nightvision MESSAGE_END(); @@ -3370,7 +3570,6 @@ void EXT_FUNC ServerActivate(edict_t *pEdictList, int edictCount, int clientMax) #ifdef REGAMEDLL_ADD CSGameRules()->ServerActivate(); #endif - } void EXT_FUNC PlayerPreThink(edict_t *pEntity) @@ -3422,7 +3621,7 @@ void EXT_FUNC StartFrame() CLocalNav::Think(); - static cvar_t *skill = NULL; + static cvar_t *skill = nullptr; if (!skill) { skill = CVAR_GET_POINTER("skill"); @@ -3443,11 +3642,6 @@ void EXT_FUNC StartFrame() if (TheTutor) { TheTutor->StartFrame(gpGlobals->time); } - -#ifndef REGAMEDLL_FIXES - // it is noxref - ++g_ulFrameCount; -#endif } void ClientPrecache() @@ -3557,8 +3751,8 @@ void ClientPrecache() PRECACHE_SOUND("debris/glass1.wav"); PRECACHE_SOUND("debris/glass2.wav"); PRECACHE_SOUND("debris/glass3.wav"); - PRECACHE_SOUND("items/flashlight1.wav"); - PRECACHE_SOUND("items/flashlight1.wav"); + PRECACHE_SOUND(SOUND_FLASHLIGHT_ON); + PRECACHE_SOUND(SOUND_FLASHLIGHT_OFF); PRECACHE_SOUND("common/bodysplat.wav"); PRECACHE_SOUND("player/pl_pain2.wav"); PRECACHE_SOUND("player/pl_pain4.wav"); @@ -3567,7 +3761,7 @@ void ClientPrecache() PRECACHE_SOUND("player/pl_pain7.wav"); int numPlayerModels; - if (g_bIsCzeroGame) + if (AreRunningCZero()) numPlayerModels = ARRAYSIZE(sPlayerModelFiles); else numPlayerModels = ARRAYSIZE(sPlayerModelFiles) - 2; @@ -3575,7 +3769,7 @@ void ClientPrecache() for (i = 0; i < numPlayerModels; ++i) PRECACHE_MODEL(sPlayerModelFiles[i]); - if (g_bIsCzeroGame) + if (AreRunningCZero()) { for (i = FirstCustomSkin; i <= LastCustomSkin; ++i) { @@ -3640,7 +3834,7 @@ void ClientPrecache() for (i = 0; i < numPlayerModels; ++i) ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, sPlayerModelFiles[i]); - if (g_bIsCzeroGame) + if (AreRunningCZero()) { for (i = FirstCustomSkin; i <= LastCustomSkin; ++i) { @@ -3664,7 +3858,7 @@ void ClientPrecache() ENGINE_FORCE_UNMODIFIED(force_exactfile, (float *)&temp, (float *)&temp, "sprites/scope_arc_ne.tga"); ENGINE_FORCE_UNMODIFIED(force_exactfile, (float *)&temp, (float *)&temp, "sprites/scope_arc_sw.tga"); - if (g_bIsCzeroGame) + if (AreRunningCZero()) { vMin = Vector(-13, -6, -22); vMax = Vector(13, 6, 22); @@ -3682,7 +3876,7 @@ void ClientPrecache() ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/p_fiveseven.mdl"); ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/p_glock18.mdl"); - if (g_bIsCzeroGame) + if (AreRunningCZero()) { vMin = Vector(-26, -19, -21); vMax = Vector(26, 23, 21); @@ -3696,7 +3890,7 @@ void ClientPrecache() ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/p_xm1014.mdl"); ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/p_m3.mdl"); - if (g_bIsCzeroGame) + if (AreRunningCZero()) { vMin = Vector(-23, -9, -20); vMax = Vector(23, 17, 20); @@ -3713,7 +3907,7 @@ void ClientPrecache() ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/p_tmp.mdl"); ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/p_p90.mdl"); - if (g_bIsCzeroGame) + if (AreRunningCZero()) { vMin = Vector(-38, -33, -22); vMax = Vector(38, 15, 35); @@ -3735,7 +3929,7 @@ void ClientPrecache() ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/p_famas.mdl"); ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/p_galil.mdl"); - if (g_bIsCzeroGame) + if (AreRunningCZero()) { vMin = Vector(-30, -10, -20); vMax = Vector(30, 11, 20); @@ -3756,7 +3950,7 @@ void ClientPrecache() vMin = Vector(-4, -8, -3); vMax = Vector(3, 7, 3); - if (g_bIsCzeroGame) + if (AreRunningCZero()) { vMin = Vector(-17, -8, -3); vMax = Vector(17, 7, 3); @@ -3769,7 +3963,7 @@ void ClientPrecache() ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/w_c4.mdl"); - if (g_bIsCzeroGame) + if (AreRunningCZero()) { vMin = Vector(-7, -3, -18); vMax = Vector(7, 2, 18); @@ -3784,7 +3978,7 @@ void ClientPrecache() ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/p_hegrenade.mdl"); ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/p_smokegrenade.mdl"); - if (g_bIsCzeroGame) + if (AreRunningCZero()) vMin = Vector(-5, -5, -7); else vMin = Vector(-5, -5, -5); @@ -3800,7 +3994,7 @@ void ClientPrecache() ENGINE_FORCE_UNMODIFIED(force_model_specifybounds, (float *)&vMin, (float *)&vMax, "models/p_knife.mdl"); - if (g_bIsCzeroGame) + if (AreRunningCZero()) { vMin = Vector(-21, -25, -54); vMax = Vector(21, 23, 24); @@ -3867,7 +4061,7 @@ const char *EXT_FUNC GetGameDescription() return CSGameRules()->GetGameDescription(); } #else - if (g_bIsCzeroGame) { + if (AreRunningCZero()) { return "Condition Zero"; } #endif @@ -4045,7 +4239,6 @@ int EXT_FUNC AddToFullPack(struct entity_state_s *state, int e, edict_t *ent, ed int i; int hostnum = ENTINDEX(host) - 1; - if (CheckPlayerPVSLeafChanged(host, hostnum)) ResetPlayerPVS(host, hostnum); @@ -4400,10 +4593,10 @@ int EXT_FUNC GetWeaponData(edict_t *player, struct weapon_data_s *info) return 1; // go through all of the weapons and make a list of the ones to pack - for (int i = 0; i < MAX_ITEM_TYPES; ++i) + for (int i = 0; i < MAX_ITEM_TYPES; i++) { auto pPlayerItem = pPlayer->m_rgpPlayerItems[i]; - while (pPlayerItem != nullptr) + while (pPlayerItem) { // there's a weapon here. Should I pack it? auto weapon = (CBasePlayerWeapon *)pPlayerItem->GetWeaponPtr(); diff --git a/regamedll/dlls/client.h b/regamedll/dlls/client.h index 9a1b9bc6..504e84f8 100644 --- a/regamedll/dlls/client.h +++ b/regamedll/dlls/client.h @@ -26,11 +26,7 @@ * */ -#ifndef CLIENT_H -#define CLIENT_H -#ifdef _WIN32 #pragma once -#endif // custom enum enum ChooseTeamMenuSlot @@ -58,8 +54,8 @@ enum BuyItemMenuSlot MENU_SLOT_ITEM_SHIELD, }; -#define CS_NUM_SKIN 4 -#define CZ_NUM_SKIN 5 +#define CS_NUM_SKIN 4 +#define CZ_NUM_SKIN 5 #define FIELD_ORIGIN0 0 #define FIELD_ORIGIN1 1 @@ -78,8 +74,8 @@ enum BuyItemMenuSlot #define CUSTOMFIELD_ANGLES2 5 #define CUSTOMFIELD_SKIN 6 -#define CUSTOMFIELD_SEQUENCE 7 -#define CUSTOMFIELD_ANIMTIME 8 +#define CUSTOMFIELD_SEQUENCE 7 +#define CUSTOMFIELD_ANIMTIME 8 typedef struct { @@ -87,12 +83,13 @@ typedef struct } ENTITYPVSSTATUS; +const int MAX_ENTITIES = 1380; struct PLAYERPVSSTATUS { - ENTITYPVSSTATUS m_Status[1380]; + ENTITYPVSSTATUS m_Status[MAX_ENTITIES]; int headnode; int num_leafs; - short int leafnums[ MAX_ENT_LEAFS ]; + short int leafnums[MAX_ENT_LEAFS]; }; struct entity_field_alias_t @@ -119,6 +116,9 @@ void ShowMenu_OrigFunc(CBasePlayer *pPlayer, int bitsValidSlots, int nDisplayTim void ShowVGUIMenu_OrigFunc(CBasePlayer *pPlayer, int MenuType, int BitMask, char *szOldMenu); #endif +void LinkUserMessages(); +void WriteSigonMessages(); + int CMD_ARGC_(); const char *CMD_ARGV_(int i); void set_suicide_frame(entvars_t *pev); @@ -199,11 +199,91 @@ inline const char *GetTeamName(int team) { switch (team) { - case CT: return "CT"; - case TERRORIST: return "TERRORIST"; - case SPECTATOR: return "SPECTATOR"; - default: return "UNASSIGNED"; + case CT: return "CT"; + case TERRORIST: return "TERRORIST"; + case SPECTATOR: return "SPECTATOR"; + default: return "UNASSIGNED"; } } -#endif // CLIENT_H +extern int giPrecacheGrunt; +extern int gmsgWeapPickup; +extern int gmsgHudText; +extern int gmsgHudTextArgs; +extern int gmsgShake; +extern int gmsgFade; +extern int gmsgFlashlight; +extern int gmsgFlashBattery; +extern int gmsgResetHUD; +extern int gmsgInitHUD; +extern int gmsgViewMode; +extern int gmsgShowGameTitle; +extern int gmsgCurWeapon; +extern int gmsgHealth; +extern int gmsgDamage; +extern int gmsgBattery; +extern int gmsgTrain; +extern int gmsgLogo; +extern int gmsgWeaponList; +extern int gmsgAmmoX; +extern int gmsgDeathMsg; +extern int gmsgScoreAttrib; +extern int gmsgScoreInfo; +extern int gmsgTeamInfo; +extern int gmsgTeamScore; +extern int gmsgGameMode; +extern int gmsgMOTD; +extern int gmsgServerName; +extern int gmsgAmmoPickup; +extern int gmsgItemPickup; +extern int gmsgHideWeapon; +extern int gmsgSayText; +extern int gmsgTextMsg; +extern int gmsgSetFOV; +extern int gmsgShowMenu; +extern int gmsgSendAudio; +extern int gmsgRoundTime; +extern int gmsgMoney; +extern int gmsgBlinkAcct; +extern int gmsgArmorType; +extern int gmsgStatusValue; +extern int gmsgStatusText; +extern int gmsgStatusIcon; +extern int gmsgBarTime; +extern int gmsgReloadSound; +extern int gmsgCrosshair; +extern int gmsgNVGToggle; +extern int gmsgRadar; +extern int gmsgSpectator; +extern int gmsgVGUIMenu; +extern int gmsgCZCareer; +extern int gmsgCZCareerHUD; +extern int gmsgTaskTime; +extern int gmsgTutorText; +extern int gmsgTutorLine; +extern int gmsgShadowIdx; +extern int gmsgTutorState; +extern int gmsgTutorClose; +extern int gmsgAllowSpec; +extern int gmsgBombDrop; +extern int gmsgBombPickup; +extern int gmsgHostagePos; +extern int gmsgHostageK; +extern int gmsgGeigerRange; +extern int gmsgSendCorpse; +extern int gmsgHLTV; +extern int gmsgSpecHealth; +extern int gmsgForceCam; +extern int gmsgADStop; +extern int gmsgReceiveW; +extern int gmsgScenarioIcon; +extern int gmsgBotVoice; +extern int gmsgBuyClose; +extern int gmsgItemStatus; +extern int gmsgLocation; +extern int gmsgSpecHealth2; +extern int gmsgBarTime2; +extern int gmsgBotProgress; +extern int gmsgBrass; +extern int gmsgFog; +extern int gmsgShowTimer; diff --git a/regamedll/dlls/cmdhandler.cpp b/regamedll/dlls/cmdhandler.cpp new file mode 100644 index 00000000..38e94cd8 --- /dev/null +++ b/regamedll/dlls/cmdhandler.cpp @@ -0,0 +1,191 @@ +#include "precompiled.h" + +void InstallCommands() +{ + static bool installedCommands = false; + if (installedCommands) + return; + + if (AreRunningCZero()) + { + ADD_SERVER_COMMAND("career_continue", SV_Continue_f); + ADD_SERVER_COMMAND("career_matchlimit", SV_CareerMatchLimit_f); + ADD_SERVER_COMMAND("career_add_task", SV_CareerAddTask_f); + ADD_SERVER_COMMAND("career_endround", SV_Career_EndRound_f); + ADD_SERVER_COMMAND("career_restart", SV_Career_Restart_f); + ADD_SERVER_COMMAND("tutor_toggle", SV_Tutor_Toggle_f); + } + + ADD_SERVER_COMMAND("perf_test", SV_LoopPerformance_f); + ADD_SERVER_COMMAND("print_ent", SV_PrintEntities_f); + + installedCommands = true; +} + +void SV_Continue_f() +{ + if (CSGameRules()->IsCareer() && CSGameRules()->m_flRestartRoundTime > 100000.0) + { + CSGameRules()->m_flRestartRoundTime = gpGlobals->time; + + // go continue + MESSAGE_BEGIN(MSG_ALL, gmsgCZCareer); + WRITE_STRING("GOGOGO"); + MESSAGE_END(); + + for (int i = 1; i <= gpGlobals->maxClients; i++) + { + CBasePlayer *pPlayer = UTIL_PlayerByIndex(i); + + if (pPlayer && !pPlayer->IsBot()) + { + // at the end of the round is showed window with the proposal surrender or continue + // now of this time HUD is completely hidden + // we must to restore HUD after entered continued + pPlayer->m_iHideHUD &= ~HIDEHUD_ALL; + } + } + } +} + +void SV_CareerMatchLimit_f() +{ + if (CMD_ARGC() != 3) + { + return; + } + + if (CSGameRules()->IsCareer()) + { + CSGameRules()->SetCareerMatchLimit(Q_atoi(CMD_ARGV(1)), Q_atoi(CMD_ARGV(2))); + } +} + +void SV_CareerAddTask_f() +{ + if (CMD_ARGC() != 7) + return; + + const char *taskName = CMD_ARGV(1); + const char *weaponName = CMD_ARGV(2); + + int reps = Q_atoi(CMD_ARGV(3)); + bool mustLive = Q_atoi(CMD_ARGV(4)) != 0; + bool crossRounds = Q_atoi(CMD_ARGV(5)) != 0; + bool isComplete = Q_atoi(CMD_ARGV(6)) != 0; + + if (TheCareerTasks) + { + TheCareerTasks->AddTask(taskName, weaponName, reps, mustLive, crossRounds, isComplete); + } +} + +void SV_Career_EndRound_f() +{ + if (!CSGameRules()->IsCareer() || !CSGameRules()->IsInCareerRound()) + { + return; + } + + CBasePlayer *pLocalPlayer = UTIL_GetLocalPlayer(); + if (pLocalPlayer) + { + SERVER_COMMAND("kill\n"); + + for (int i = 1; i <= gpGlobals->maxClients; i++) + { + CBasePlayer *player = UTIL_PlayerByIndex(i); + + if (!player || FNullEnt(player->pev)) + continue; + + if (player->IsBot() && player->m_iTeam == pLocalPlayer->m_iTeam) + { + SERVER_COMMAND(UTIL_VarArgs("bot_kill \"%s\"\n", STRING(player->pev->netname))); + } + } + } +} + +void SV_Career_Restart_f() +{ + if (CSGameRules()->IsCareer()) + { + CSGameRules()->CareerRestart(); + } +} + +void SV_Tutor_Toggle_f() +{ + CVAR_SET_FLOAT("tutor_enable", (CVAR_GET_FLOAT("tutor_enable") <= 0.0)); +} + +void SV_LoopPerformance_f() +{ + CCounter loopCounter; + loopCounter.Init(); + + double start, end; + int i; + + start = loopCounter.GetCurTime(); + + for (i = 0; i < 100; ++i) + { + CBaseEntity *pSpot; + for (pSpot = UTIL_FindEntityByString_Old(nullptr, "classname", "info_player_start"); pSpot; pSpot = UTIL_FindEntityByString_Old(pSpot, "classname", "info_player_start")) + ; + + for (pSpot = UTIL_FindEntityByString_Old(nullptr, "classname", "info_player_deathmatch"); pSpot; pSpot = UTIL_FindEntityByString_Old(pSpot, "classname", "info_player_deathmatch")) + ; + + for (pSpot = UTIL_FindEntityByString_Old(nullptr, "classname", "player"); pSpot; pSpot = UTIL_FindEntityByString_Old(pSpot, "classname", "player")) + ; + + for (pSpot = UTIL_FindEntityByString_Old(nullptr, "classname", "bodyque"); pSpot; pSpot = UTIL_FindEntityByString_Old(pSpot, "classname", "bodyque")) + ; + } + + end = loopCounter.GetCurTime(); + CONSOLE_ECHO(" Time in old search loop %.4f\n", (end - start) * 1000.0); + + // check time new search loop + start = loopCounter.GetCurTime(); + + for (i = 0; i < 100; ++i) + { + CBaseEntity *pSpot; + for (pSpot = UTIL_FindEntityByString(nullptr, "classname", "info_player_start"); pSpot; pSpot = UTIL_FindEntityByString(pSpot, "classname", "info_player_start")) + ; + + for (pSpot = UTIL_FindEntityByString(nullptr, "classname", "info_player_deathmatch"); pSpot; pSpot = UTIL_FindEntityByString(pSpot, "classname", "info_player_deathmatch")) + ; + + for (pSpot = UTIL_FindEntityByString(nullptr, "classname", "player"); pSpot; pSpot = UTIL_FindEntityByString(pSpot, "classname", "player")) + ; + + for (pSpot = UTIL_FindEntityByString(nullptr, "classname", "bodyque"); pSpot; pSpot = UTIL_FindEntityByString(pSpot, "classname", "bodyque")) + ; + } + + end = loopCounter.GetCurTime(); + CONSOLE_ECHO(" Time in new search loop %.4f\n", (end - start) * 1000.0); +} + +void SV_PrintEntities_f() +{ + for (int i = 0; i < stringsHashTable.Count(); ++i) + { + hash_item_t *item = &stringsHashTable[i]; + + if (item->pev) + { + UTIL_LogPrintf("Print: %s %i %p\n", STRING(stringsHashTable[i].pev->classname), ENTINDEX(ENT(item->pev)), item->pev); + } + + for (item = stringsHashTable[i].next; item; item = item->next) + { + UTIL_LogPrintf("Print: %s %i %p\n", STRING(item->pev->classname), ENTINDEX(ENT(item->pev)), item->pev); + } + } +} diff --git a/regamedll/extra/cssdk/dlls/subs.h b/regamedll/dlls/cmdhandler.h similarity index 80% rename from regamedll/extra/cssdk/dlls/subs.h rename to regamedll/dlls/cmdhandler.h index 8cae347c..f068265d 100644 --- a/regamedll/extra/cssdk/dlls/subs.h +++ b/regamedll/dlls/cmdhandler.h @@ -28,13 +28,14 @@ #pragma once -class CNullEntity: public CBaseEntity { -public: - virtual void Spawn() = 0; -}; +void InstallCommands(); -class CBaseDMStart: public CPointEntity { -public: - virtual void KeyValue(KeyValueData *pkvd) = 0; - virtual BOOL IsTriggered(CBaseEntity *pEntity) = 0; -}; +EXT_FUNC void SV_Continue_f(); +EXT_FUNC void SV_CareerMatchLimit_f(); +EXT_FUNC void SV_CareerAddTask_f(); +EXT_FUNC void SV_Career_EndRound_f(); +EXT_FUNC void SV_Career_Restart_f(); +EXT_FUNC void SV_Tutor_Toggle_f(); + +EXT_FUNC void SV_LoopPerformance_f(); +EXT_FUNC void SV_PrintEntities_f(); diff --git a/regamedll/dlls/combat.cpp b/regamedll/dlls/combat.cpp index 6e8a7aaf..1ac1fb41 100644 --- a/regamedll/dlls/combat.cpp +++ b/regamedll/dlls/combat.cpp @@ -1,904 +1,6 @@ #include "precompiled.h" -void CGib::LimitVelocity() -{ - float length = pev->velocity.Length(); - - // ceiling at 1500. The gib velocity equation is not bounded properly. Rather than tune it - // in 3 separate places again, I'll just limit it here. - if (length > 1500.0) - { - // This should really be sv_maxvelocity * 0.75 or something - pev->velocity = pev->velocity.Normalize() * 1500; - } -} - -NOXREF void CGib::SpawnStickyGibs(entvars_t *pevVictim, Vector vecOrigin, int cGibs) -{ - if (g_Language == LANGUAGE_GERMAN) - { - // no sticky gibs in germany right now! - return; - } - - for (int i = 0; i < cGibs; ++i) - { - CGib *pGib = GetClassPtr((CGib *)NULL); - - pGib->Spawn("models/stickygib.mdl"); - pGib->pev->body = RANDOM_LONG(0, 2); - - if (pevVictim) - { - pGib->pev->origin.x = vecOrigin.x + RANDOM_FLOAT(-3, 3); - pGib->pev->origin.y = vecOrigin.y + RANDOM_FLOAT(-3, 3); - pGib->pev->origin.z = vecOrigin.z + RANDOM_FLOAT(-3, 3); - - // make the gib fly away from the attack vector - pGib->pev->velocity = g_vecAttackDir * -1; - - // mix in some noise - pGib->pev->velocity.x += RANDOM_FLOAT(-0.15, 0.15); - pGib->pev->velocity.y += RANDOM_FLOAT(-0.15, 0.15); - pGib->pev->velocity.z += RANDOM_FLOAT(-0.15, 0.15); - - pGib->pev->velocity = pGib->pev->velocity * 900; - - pGib->pev->avelocity.x = RANDOM_FLOAT(250, 400); - pGib->pev->avelocity.y = RANDOM_FLOAT(250, 400); - - // copy owner's blood color - pGib->m_bloodColor = (CBaseEntity::Instance(pevVictim))->BloodColor(); - - if (pevVictim->health > -50) - { - pGib->pev->velocity = pGib->pev->velocity * 0.7; - } - else if (pevVictim->health > -200) - { - pGib->pev->velocity = pGib->pev->velocity * 2; - } - else - { - pGib->pev->velocity = pGib->pev->velocity * 4; - } - - pGib->pev->movetype = MOVETYPE_TOSS; - pGib->pev->solid = SOLID_BBOX; - UTIL_SetSize(pGib->pev, Vector(0, 0,0), Vector(0, 0, 0)); - pGib->SetTouch(&CGib::StickyGibTouch); - pGib->SetThink(NULL); - } - - pGib->LimitVelocity(); - } -} - -void CGib::SpawnHeadGib(entvars_t *pevVictim) -{ - CGib *pGib = GetClassPtr((CGib *)NULL); - - if (g_Language == LANGUAGE_GERMAN) - { - // throw one head - pGib->Spawn("models/germangibs.mdl"); - pGib->pev->body = 0; - } - else - { - // throw one head - pGib->Spawn("models/hgibs.mdl"); - pGib->pev->body = 0; - } - - if (pevVictim) - { - pGib->pev->origin = pevVictim->origin + pevVictim->view_ofs; - - edict_t *pentPlayer = FIND_CLIENT_IN_PVS(pGib->edict()); - - if (RANDOM_LONG(0, 100) <= 5 && pentPlayer) - { - // 5% chance head will be thrown at player's face. - entvars_t *pevPlayer = VARS(pentPlayer); - - pGib->pev->velocity = ((pevPlayer->origin + pevPlayer->view_ofs) - pGib->pev->origin).Normalize() * 300; - pGib->pev->velocity.z += 100; - } - else - { - // TODO: fix test demo - pGib->pev->velocity.z = RANDOM_FLOAT(200, 300); - pGib->pev->velocity.y = RANDOM_FLOAT(-100, 100); - pGib->pev->velocity.x = RANDOM_FLOAT(-100, 100); - } - - pGib->pev->avelocity.x = RANDOM_FLOAT(100, 200); - pGib->pev->avelocity.y = RANDOM_FLOAT(100, 300); - - // copy owner's blood color - pGib->m_bloodColor = (CBaseEntity::Instance(pevVictim))->BloodColor(); - - if (pevVictim->health > -50) - { - pGib->pev->velocity = pGib->pev->velocity * 0.7; - } - else if (pevVictim->health > -200) - { - pGib->pev->velocity = pGib->pev->velocity * 2; - } - else - pGib->pev->velocity = pGib->pev->velocity * 4; - } - - pGib->LimitVelocity(); -} - -void CGib::SpawnRandomGibs(entvars_t *pevVictim, int cGibs, int human) -{ - int cSplat; - for (cSplat = 0; cSplat < cGibs; ++cSplat) - { - CGib *pGib = GetClassPtr((CGib *)NULL); - - if (g_Language == LANGUAGE_GERMAN) - { - pGib->Spawn("models/germangibs.mdl"); - pGib->pev->body = RANDOM_LONG(0, GERMAN_GIB_COUNT - 1); - } - else - { - if (human) - { - // human pieces - pGib->Spawn("models/hgibs.mdl"); - // start at one to avoid throwing random amounts of skulls (0th gib) - pGib->pev->body = RANDOM_LONG(1, HUMAN_GIB_COUNT - 1); - } - else - { - // aliens - pGib->Spawn("models/agibs.mdl"); - pGib->pev->body = RANDOM_LONG(0, ALIEN_GIB_COUNT - 1); - } - } - - if (pevVictim) - { - // spawn the gib somewhere in the monster's bounding volume - pGib->pev->origin.x = pevVictim->absmin.x + pevVictim->size.x * (RANDOM_FLOAT(0, 1)); - pGib->pev->origin.y = pevVictim->absmin.y + pevVictim->size.y * (RANDOM_FLOAT(0, 1)); - // absmin.z is in the floor because the engine subtracts 1 to enlarge the box - pGib->pev->origin.z = pevVictim->absmin.z + pevVictim->size.z * (RANDOM_FLOAT(0, 1)) + 1; - - // make the gib fly away from the attack vector - pGib->pev->velocity = g_vecAttackDir * -1; - - // mix in some noise - pGib->pev->velocity.x += RANDOM_FLOAT(-0.25, 0.25); - pGib->pev->velocity.y += RANDOM_FLOAT(-0.25, 0.25); - pGib->pev->velocity.z += RANDOM_FLOAT(-0.25, 0.25); - - pGib->pev->velocity = pGib->pev->velocity * RANDOM_FLOAT(300, 400); - - pGib->pev->avelocity.x = RANDOM_FLOAT(100, 200); - pGib->pev->avelocity.y = RANDOM_FLOAT(100, 300); - - // copy owner's blood color - pGib->m_bloodColor = (CBaseEntity::Instance(pevVictim))->BloodColor(); - - if (pevVictim->health > -50) - pGib->pev->velocity = pGib->pev->velocity * 0.7; - - else if (pevVictim->health > -200) - pGib->pev->velocity = pGib->pev->velocity * 2; - else - pGib->pev->velocity = pGib->pev->velocity * 4; - - pGib->pev->solid = SOLID_BBOX; - UTIL_SetSize(pGib->pev, Vector(0, 0, 0), Vector(0, 0, 0)); - } - pGib->LimitVelocity(); - } -} - -BOOL CBaseMonster::HasHumanGibs() -{ - int myClass = Classify(); - - if (myClass == CLASS_HUMAN_MILITARY - || myClass == CLASS_PLAYER_ALLY - || myClass == CLASS_HUMAN_PASSIVE - || myClass == CLASS_PLAYER) - return TRUE; - - return FALSE; -} - -BOOL CBaseMonster::HasAlienGibs() -{ - int myClass = Classify(); - if (myClass == CLASS_ALIEN_MILITARY - || myClass == CLASS_ALIEN_MONSTER - || myClass == CLASS_ALIEN_PASSIVE - || myClass == CLASS_INSECT - || myClass == CLASS_ALIEN_PREDATOR - || myClass == CLASS_ALIEN_PREY) - return TRUE; - - return FALSE; -} - -void CBaseMonster::FadeMonster() -{ - StopAnimation(); - - pev->velocity = g_vecZero; - pev->movetype = MOVETYPE_NONE; - pev->avelocity = g_vecZero; - pev->animtime = gpGlobals->time; - pev->effects |= EF_NOINTERP; - - SUB_StartFadeOut(); -} - -void CBaseMonster::GibMonster() -{ - TraceResult tr; - bool gibbed = false; - - EMIT_SOUND(ENT(pev), CHAN_WEAPON, "common/bodysplat.wav", VOL_NORM, ATTN_NORM); - - // only humans throw skulls UNDONE - eventually monsters will have their own sets of gibs - if (HasHumanGibs()) - { - // Only the player will ever get here - if (CVAR_GET_FLOAT("violence_hgibs") != 0) - { - CGib::SpawnHeadGib(pev); - - // throw some human gibs. - CGib::SpawnRandomGibs(pev, 4, 1); - } - gibbed = true; - } - else if (HasAlienGibs()) - { - // Should never get here, but someone might call it directly - if (CVAR_GET_FLOAT("violence_agibs") != 0) - { - // Throw alien gibs - CGib::SpawnRandomGibs(pev, 4, 0); - } - gibbed = true; - } - - if (!IsPlayer()) - { - if (gibbed) - { - // don't remove players! - SetThink(&CBaseMonster::SUB_Remove); - pev->nextthink = gpGlobals->time; - } - else - FadeMonster(); - } -} - -// GetDeathActivity - determines the best type of death -// anim to play. -Activity CBaseMonster::GetDeathActivity() -{ - Activity deathActivity; - BOOL fTriedDirection; - float flDot; - TraceResult tr; - Vector vecSrc; - - if (pev->deadflag != DEAD_NO) - { - // don't run this while dying. - return m_IdealActivity; - } - - vecSrc = Center(); - - fTriedDirection = FALSE; - - // in case we can't find any special deaths to do. - deathActivity = ACT_DIESIMPLE; - - UTIL_MakeVectors(pev->angles); - flDot = DotProduct(gpGlobals->v_forward, g_vecAttackDir * -1); - - switch (m_LastHitGroup) - { - case HITGROUP_HEAD: - // try to pick a region-specific death. - deathActivity = ACT_DIE_HEADSHOT; - break; - case HITGROUP_STOMACH: - deathActivity = ACT_DIE_GUTSHOT; - break; - case HITGROUP_GENERIC: - // try to pick a death based on attack direction - fTriedDirection = TRUE; - - if (flDot > 0.3) - { - deathActivity = ACT_DIEFORWARD; - } - else if (flDot <= -0.3) - { - deathActivity = ACT_DIEBACKWARD; - } - break; - - default: - // try to pick a death based on attack direction - fTriedDirection = TRUE; - - if (flDot > 0.3) - { - deathActivity = ACT_DIEFORWARD; - } - else if (flDot <= -0.3) - { - deathActivity = ACT_DIEBACKWARD; - } - break; - } - - // can we perform the prescribed death? - if (LookupActivity(deathActivity) == ACT_INVALID) - { - // no! did we fail to perform a directional death? - if (fTriedDirection) - { - // if yes, we're out of options. Go simple. - deathActivity = ACT_DIESIMPLE; - } - else - { - // cannot perform the ideal region-specific death, so try a direction. - if (flDot > 0.3) - { - deathActivity = ACT_DIEFORWARD; - } - else if (flDot <= -0.3) - { - deathActivity = ACT_DIEBACKWARD; - } - } - } - - if (LookupActivity(deathActivity) == ACT_INVALID) - { - // if we're still invalid, simple is our only option. - deathActivity = ACT_DIESIMPLE; - } - - if (deathActivity == ACT_DIEFORWARD) - { - // make sure there's room to fall forward - UTIL_TraceHull(vecSrc, vecSrc + gpGlobals->v_forward * 64, dont_ignore_monsters, head_hull, edict(), &tr); - - if (tr.flFraction != 1.0f) - { - deathActivity = ACT_DIESIMPLE; - } - } - - if (deathActivity == ACT_DIEBACKWARD) - { - // make sure there's room to fall backward - UTIL_TraceHull(vecSrc, vecSrc - gpGlobals->v_forward * 64, dont_ignore_monsters, head_hull, edict(), &tr); - - if (tr.flFraction != 1.0f) - { - deathActivity = ACT_DIESIMPLE; - } - } - - return deathActivity; -} - -// GetSmallFlinchActivity - determines the best type of flinch -// anim to play. -NOXREF Activity CBaseMonster::GetSmallFlinchActivity() -{ - Activity flinchActivity; - BOOL fTriedDirection; - float flDot; - - fTriedDirection = FALSE; - UTIL_MakeVectors(pev->angles); - flDot = DotProduct(gpGlobals->v_forward, g_vecAttackDir * -1); // TODO: noxref - - switch (m_LastHitGroup) - { - case HITGROUP_HEAD: - // pick a region-specific flinch - flinchActivity = ACT_FLINCH_HEAD; - break; - case HITGROUP_STOMACH: - flinchActivity = ACT_FLINCH_STOMACH; - break; - case HITGROUP_LEFTARM: - flinchActivity = ACT_FLINCH_LEFTARM; - break; - case HITGROUP_RIGHTARM: - flinchActivity = ACT_FLINCH_RIGHTARM; - break; - case HITGROUP_LEFTLEG: - flinchActivity = ACT_FLINCH_LEFTLEG; - break; - case HITGROUP_RIGHTLEG: - flinchActivity = ACT_FLINCH_RIGHTLEG; - break; - case HITGROUP_GENERIC: - default: - // just get a generic flinch. - flinchActivity = ACT_SMALL_FLINCH; - break; - } - - // do we have a sequence for the ideal activity? - if (LookupActivity(flinchActivity) == ACT_INVALID) - { - flinchActivity = ACT_SMALL_FLINCH; - } - - return flinchActivity; -} - -void CBaseMonster::BecomeDead() -{ - // don't let autoaim aim at corpses. - pev->takedamage = DAMAGE_YES; - - // give the corpse half of the monster's original maximum health. - pev->health = pev->max_health / 2; - - // max_health now becomes a counter for how many blood decals the corpse can place. - pev->max_health = 5; - - // make the corpse fly away from the attack vector - pev->movetype = MOVETYPE_TOSS; -} - -BOOL CBaseMonster::ShouldGibMonster(int iGib) -{ - if ((iGib == GIB_NORMAL && pev->health < GIB_HEALTH_VALUE) || (iGib == GIB_ALWAYS)) - { - return TRUE; - } - - return FALSE; -} - -void CBaseMonster::CallGibMonster() -{ - BOOL fade = FALSE; - - if (HasHumanGibs()) - { - if (CVAR_GET_FLOAT("violence_hgibs") == 0) - fade = TRUE; - } - else if (HasAlienGibs()) - { - if (CVAR_GET_FLOAT("violence_agibs") == 0) - fade = TRUE; - } - - // do something with the body. while monster blows up - pev->solid = SOLID_NOT; - pev->takedamage = DAMAGE_NO; - - if (fade) - { - FadeMonster(); - } - else - { - // make the model invisible. - pev->effects = EF_NODRAW; - GibMonster(); - } - - pev->deadflag = DEAD_DEAD; - FCheckAITrigger(); - - // don't let the status bar glitch for players.with <0 health. - if (pev->health < -99.0f) - { - pev->health = 0; - } - - if (ShouldFadeOnDeath() && !fade) - UTIL_Remove(this); -} - -void CBaseMonster::Killed(entvars_t *pevAttacker, int iGib) -{ - // unsigned int cCount = 0; - // BOOL fDone = FALSE; - - if (HasMemory(bits_MEMORY_KILLED)) - { - if (ShouldGibMonster(iGib)) - CallGibMonster(); - return; - } - - Remember(bits_MEMORY_KILLED); - - // clear the deceased's sound channels.(may have been firing or reloading when killed) - EMIT_SOUND(ENT(pev), CHAN_WEAPON, "common/null.wav", VOL_NORM, ATTN_NORM); - m_IdealMonsterState = MONSTERSTATE_DEAD; - // Make sure this condition is fired too (TakeDamage breaks out before this happens on death) - SetConditions(bits_COND_LIGHT_DAMAGE); - - // tell owner ( if any ) that we're dead.This is mostly for MonsterMaker functionality. - CBaseEntity *pOwner = CBaseEntity::Instance(pev->owner); - if (pOwner) - { - pOwner->DeathNotice(pev); - } - - if (ShouldGibMonster(iGib)) - { - CallGibMonster(); - return; - } - else if (pev->flags & FL_MONSTER) - { - SetTouch(NULL); - BecomeDead(); - } - - // don't let the status bar glitch for players.with <0 health. - if (pev->health < -99) - { - pev->health = 0; - } - - //pev->enemy = ENT(pevAttacker);//why? (sjb) - m_IdealMonsterState = MONSTERSTATE_DEAD; -} - -void CBaseEntity::SUB_StartFadeOut() -{ - if (pev->rendermode == kRenderNormal) - { - pev->renderamt = 255.0f; - pev->rendermode = kRenderTransTexture; - } - - pev->solid = SOLID_NOT; - pev->avelocity = g_vecZero; - pev->nextthink = gpGlobals->time + 0.1f; - - SetThink(&CBaseEntity::SUB_FadeOut); -} - -void CBaseEntity::SUB_FadeOut() -{ - if (pev->renderamt > 7) - { - pev->renderamt -= 7.0f; - pev->nextthink = gpGlobals->time + 0.1f; - } - else - { - pev->renderamt = 0.0f; - pev->nextthink = gpGlobals->time + 0.2f; - SetThink(&CBaseEntity::SUB_Remove); - } -} - -void CGib::WaitTillLand() -{ - if (!IsInWorld()) - { - UTIL_Remove(this); - return; - } - - if (pev->velocity == g_vecZero) - { - SetThink(&CBaseEntity::SUB_StartFadeOut); - pev->nextthink = gpGlobals->time + m_lifeTime; -#ifndef REGAMEDLL_FIXES - if (m_bloodColor != DONT_BLEED) - CSoundEnt::InsertSound(bits_SOUND_MEAT, pev->origin, 384, 25); -#endif - } - else - pev->nextthink = gpGlobals->time + 0.5f; -} - -void CGib::BounceGibTouch(CBaseEntity *pOther) -{ - if (pev->flags & FL_ONGROUND) - { - pev->velocity = pev->velocity * 0.9; - pev->angles.x = 0; - pev->angles.z = 0; - pev->avelocity.x = 0; - pev->avelocity.z = 0; - } - else - { - if (g_Language != LANGUAGE_GERMAN && m_cBloodDecals > 0 && m_bloodColor != DONT_BLEED) - { - TraceResult tr; - Vector vecSpot = pev->origin + Vector(0, 0, 8); - UTIL_TraceLine(vecSpot, vecSpot + Vector(0, 0, -24), ignore_monsters, ENT(pev), &tr); - UTIL_BloodDecalTrace(&tr, m_bloodColor); - m_cBloodDecals--; - } - - if (m_material != matNone && !RANDOM_LONG(0, 2)) - { - float zvel = Q_fabs(pev->velocity.z); - float volume = 0.8 * Q_min(1.0f, zvel / 450); - - CBreakable::MaterialSoundRandom(edict(), (Materials)m_material, volume); - } - } -} - -// Sticky gib puts blood on the wall and stays put. -void CGib::StickyGibTouch(CBaseEntity *pOther) -{ - Vector vecSpot; - TraceResult tr; - - SetThink(&CBaseEntity::SUB_Remove); - pev->nextthink = gpGlobals->time + 10; - - if (!FClassnameIs(pOther->pev, "worldspawn")) - { - pev->nextthink = gpGlobals->time; - return; - } - - vecSpot = pev->origin + pev->velocity * 32; - - UTIL_TraceLine(pev->origin, vecSpot, ignore_monsters, ENT(pev), &tr); - UTIL_BloodDecalTrace(&tr, m_bloodColor); - - pev->velocity = tr.vecPlaneNormal * -1; - pev->angles = UTIL_VecToAngles(pev->velocity); - pev->velocity = g_vecZero; - pev->avelocity = g_vecZero; - pev->movetype = MOVETYPE_NONE; -} - -void CGib::Spawn(const char *szGibModel) -{ - pev->movetype = MOVETYPE_BOUNCE; - - // deading the bounce a bit - pev->friction = 0.55; - - // sometimes an entity inherits the edict from a former piece of glass, - // and will spawn using the same render FX or rendermode! bad! - pev->renderamt = 255.0; - pev->rendermode = kRenderNormal; - pev->renderfx = kRenderFxNone; - - /// hopefully this will fix the VELOCITY TOO LOW crap - pev->solid = SOLID_SLIDEBOX; - - MAKE_STRING_CLASS("gib", pev); - - SET_MODEL(ENT(pev), szGibModel); - UTIL_SetSize(pev, Vector(0, 0, 0), Vector(0, 0, 0)); - - pev->nextthink = gpGlobals->time + 4.0f; - m_lifeTime = 25.0f; - - SetThink(&CGib::WaitTillLand); - SetTouch(&CGib::BounceGibTouch); - - m_material = matNone; - - // how many blood decals this gib can place (1 per bounce until none remain). - m_cBloodDecals = 5; -} - -BOOL CBaseMonster::TakeHealth(float flHealth, int bitsDamageType) -{ - if (pev->takedamage == DAMAGE_NO) - return FALSE; - - // clear out any damage types we healed. - // UNDONE: generic health should not heal any - // UNDONE: time-based damage - - m_bitsDamageType &= ~(bitsDamageType & ~DMG_TIMEBASED); - return CBaseEntity::TakeHealth(flHealth, bitsDamageType); -} - -// The damage is coming from inflictor, but get mad at attacker -// This should be the only function that ever reduces health. -// bitsDamageType indicates the type of damage sustained, ie: DMG_SHOCK -// -// Time-based damage: only occurs while the monster is within the trigger_hurt. -// When a monster is poisoned via an arrow etc it takes all the poison damage at once. -BOOL CBaseMonster::TakeDamage(entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType) -{ - if (pev->takedamage == DAMAGE_NO) - return FALSE; - - if (!IsAlive()) - { - return DeadTakeDamage(pevInflictor, pevAttacker, flDamage, bitsDamageType); - } - - if (pev->deadflag == DEAD_NO) - { - // no pain sound during death animation. - PainSound(); - } - - // LATER: make armor consideration here! - float flTake = flDamage; - - // set damage type sustained - m_bitsDamageType |= bitsDamageType; - - // grab the vector of the incoming attack. ( pretend that the inflictor is a little lower than it really is, so the body will tend to fly upward a bit). - Vector vecDir(0, 0, 0); - - if (!FNullEnt(pevInflictor)) - { - CBaseEntity *pInflictor = CBaseEntity::Instance(pevInflictor); - - if (pInflictor) - { -#ifndef PLAY_GAMEDLL - vecDir = (pInflictor->Center() - Vector(0, 0, 10) - Center()).Normalize(); -#else - // TODO: fix test demo - vecDir = NormalizeSubtract< - float_precision, float, float_precision, float_precision - >(Center(), pInflictor->Center() - Vector(0, 0, 10)); -#endif - vecDir = g_vecAttackDir = vecDir.Normalize(); - } - } - - // add to the damage total for clients, which will be sent as a single - // message at the end of the frame - // TODO: remove after combining shotgun blasts? - if (IsPlayer()) - { - if (pevInflictor) - { - pev->dmg_inflictor = ENT(pevInflictor); - } - - pev->dmg_take += flTake; - } - - pev->health -= flTake; - - if (m_MonsterState == MONSTERSTATE_SCRIPT) - { - SetConditions(bits_COND_LIGHT_DAMAGE); - return FALSE; - } - - if (pev->health <= 0.0f) - { - g_pevLastInflictor = pevInflictor; - - if (bitsDamageType & DMG_ALWAYSGIB) - Killed(pevAttacker, GIB_ALWAYS); - - else if (bitsDamageType & DMG_NEVERGIB) - Killed(pevAttacker, GIB_NEVER); - else - Killed(pevAttacker, GIB_NORMAL); - - g_pevLastInflictor = NULL; - return FALSE; - } - if ((pev->flags & FL_MONSTER) && !FNullEnt(pevAttacker)) - { - if (pevAttacker->flags & (FL_MONSTER | FL_CLIENT)) - { - if (pevInflictor) - { - if (m_hEnemy == NULL || pevInflictor == m_hEnemy->pev || !HasConditions(bits_COND_SEE_ENEMY)) - m_vecEnemyLKP = pevInflictor->origin; - } - else - { - m_vecEnemyLKP = pev->origin + (g_vecAttackDir * 64); - } - - MakeIdealYaw(m_vecEnemyLKP); - - if (flDamage > 20.0f) - { - SetConditions(bits_COND_LIGHT_DAMAGE); - } - - if (flDamage >= 20.0f) - { - SetConditions(bits_COND_HEAVY_DAMAGE); - } - } - } - - return TRUE; -} - -// DeadTakeDamage - takedamage function called when a monster's corpse is damaged. -BOOL CBaseMonster::DeadTakeDamage(entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType) -{ - // grab the vector of the incoming attack. ( pretend that the inflictor is a little lower than it really is, so the body will tend to fly upward a bit). - Vector vecDir(0, 0, 0); - - if (!FNullEnt(pevInflictor)) - { - CBaseEntity *pInflictor = CBaseEntity::Instance(pevInflictor); - if (pInflictor) - { - vecDir = (pInflictor->Center() - Vector(0, 0, 10) - Center()).Normalize(); - vecDir = g_vecAttackDir = vecDir.Normalize(); - } - } - -// turn this back on when the bounding box issues are resolved. -#if 0 - - pev->flags &= ~FL_ONGROUND; - pev->origin.z += 1; - - // let the damage scoot the corpse around a bit. - if (!FNullEnt(pevInflictor) && (pevAttacker->solid != SOLID_TRIGGER)) - { - pev->velocity = pev->velocity + vecDir * -DamageForce(flDamage); - } - -#endif - - // kill the corpse if enough damage was done to destroy the corpse and the damage is of a type that is allowed to destroy the corpse. - if (bitsDamageType & DMG_GIB_CORPSE) - { - if (pev->health <= flDamage) - { - pev->health = -50; - Killed(pevAttacker, GIB_ALWAYS); - return FALSE; - } - - // Accumulate corpse gibbing damage, so you can gib with multiple hits - pev->health -= flDamage * 0.1; - } - - return TRUE; -} - -float CBaseMonster::DamageForce(float damage) -{ - float_precision force = damage * ((32 * 32 * 72.0) / (pev->size.x * pev->size.y * pev->size.z)) * 5; - - if (force > 1000.0) - { - force = 1000.0; - } - return force; -} - -void EXT_FUNC PlayerBlind(CBasePlayer *pPlayer, entvars_t *pevInflictor, entvars_t *pevAttacker, float fadeTime, float fadeHold, int alpha, Vector &color) +void PlayerBlind(CBasePlayer *pPlayer, entvars_t *pevInflictor, entvars_t *pevAttacker, float fadeTime, float fadeHold, int alpha, Vector &color) { UTIL_ScreenFade(pPlayer, color, fadeTime, fadeHold, alpha, 0); @@ -922,14 +24,14 @@ void EXT_FUNC PlayerBlind(CBasePlayer *pPlayer, entvars_t *pevInflictor, entvars } } -void EXT_FUNC RadiusFlash_TraceLine_hook(CBasePlayer *pPlayer, entvars_t *pevInflictor, entvars_t *pevAttacker, Vector &vecSrc, Vector &vecSpot, TraceResult *tr) +void RadiusFlash_TraceLine_hook(CBasePlayer *pPlayer, entvars_t *pevInflictor, entvars_t *pevAttacker, Vector &vecSrc, Vector &vecSpot, TraceResult *tr) { UTIL_TraceLine(vecSrc, vecSpot, dont_ignore_monsters, ENT(pevInflictor), tr); } void RadiusFlash(Vector vecSrc, entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int iClassIgnore, int bitsDamageType) { - CBaseEntity *pEntity = NULL; + CBaseEntity *pEntity = nullptr; TraceResult tr; float flAdjustedDamage, falloff; Vector vecSpot; @@ -1049,7 +151,7 @@ float GetAmountOfPlayerVisible(Vector vecSrc, CBaseEntity *entity) if (!entity->IsPlayer()) { // the entity is not a player, so the damage is all or nothing. - UTIL_TraceLine(vecSrc, entity->pev->origin, ignore_monsters, NULL, &tr); + UTIL_TraceLine(vecSrc, entity->pev->origin, ignore_monsters, nullptr, &tr); if (tr.flFraction == 1.0f) retval = 1.0f; @@ -1059,14 +161,14 @@ float GetAmountOfPlayerVisible(Vector vecSrc, CBaseEntity *entity) // check chest Vector vecChest = entity->pev->origin; - UTIL_TraceLine(vecSrc, vecChest, ignore_monsters, NULL, &tr); + UTIL_TraceLine(vecSrc, vecChest, ignore_monsters, nullptr, &tr); if (tr.flFraction == 1.0f) retval += damagePercentageChest; // check top of head Vector vecHead = entity->pev->origin + Vector(0, 0, topOfHead); - UTIL_TraceLine(vecSrc, vecHead, ignore_monsters, NULL, &tr); + UTIL_TraceLine(vecSrc, vecHead, ignore_monsters, nullptr, &tr); if (tr.flFraction == 1.0f) retval += damagePercentageHead; @@ -1075,7 +177,7 @@ float GetAmountOfPlayerVisible(Vector vecSrc, CBaseEntity *entity) Vector vecFeet = entity->pev->origin; vecFeet.z -= (entity->pev->flags & FL_DUCKING) ? crouchFeet : standFeet; - UTIL_TraceLine(vecSrc, vecFeet, ignore_monsters, NULL, &tr); + UTIL_TraceLine(vecSrc, vecFeet, ignore_monsters, nullptr, &tr); if (tr.flFraction == 1.0f) retval += damagePercentageFeet; @@ -1088,13 +190,13 @@ float GetAmountOfPlayerVisible(Vector vecSrc, CBaseEntity *entity) Vector vecLeftSide = entity->pev->origin - Vector(perp.x, perp.y, 0); // check right "edge" - UTIL_TraceLine(vecSrc, vecRightSide, ignore_monsters, NULL, &tr); + UTIL_TraceLine(vecSrc, vecRightSide, ignore_monsters, nullptr, &tr); if (tr.flFraction == 1.0f) retval += damagePercentageRightSide; // check left "edge" - UTIL_TraceLine(vecSrc, vecLeftSide, ignore_monsters, NULL, &tr); + UTIL_TraceLine(vecSrc, vecLeftSide, ignore_monsters, nullptr, &tr); if (tr.flFraction == 1.0f) retval += damagePercentageLeftSide; @@ -1104,7 +206,7 @@ float GetAmountOfPlayerVisible(Vector vecSrc, CBaseEntity *entity) void RadiusDamage(Vector vecSrc, entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, float flRadius, int iClassIgnore, int bitsDamageType) { - CBaseEntity *pEntity = NULL; + CBaseEntity *pEntity = nullptr; TraceResult tr; float flAdjustedDamage, falloff; Vector vecSpot; @@ -1141,7 +243,7 @@ void RadiusDamage(Vector vecSrc, entvars_t *pevInflictor, entvars_t *pevAttacker bool useLOS = false; float damageRatio = 1.0f; - if ((bitsDamageType & DMG_EXPLOSION) && g_bIsCzeroGame) + if ((bitsDamageType & DMG_EXPLOSION) && AreRunningCZero()) { useLOS = true; damageRatio = GetAmountOfPlayerVisible(vecSrc, pEntity); @@ -1175,7 +277,7 @@ void RadiusDamage(Vector vecSrc, entvars_t *pevInflictor, entvars_t *pevAttacker // disable grenade damage through walls? if (hegrenade_penetration.string[0] == '1' && (bitsDamageType & DMG_EXPLOSION)) { - UTIL_TraceLine(vecSrc, pEntity->pev->origin, ignore_monsters, NULL, &tr); + UTIL_TraceLine(vecSrc, pEntity->pev->origin, ignore_monsters, nullptr, &tr); if (tr.flFraction != 1.0f) flAdjustedDamage = 0.0f; @@ -1198,7 +300,7 @@ void RadiusDamage(Vector vecSrc, entvars_t *pevInflictor, entvars_t *pevAttacker void RadiusDamage2(Vector vecSrc, entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, float flRadius, int iClassIgnore, int bitsDamageType) { - CBaseEntity *pEntity = NULL; + CBaseEntity *pEntity = nullptr; TraceResult tr; float flAdjustedDamage, falloff; Vector vecSpot; @@ -1264,705 +366,3 @@ void RadiusDamage2(Vector vecSrc, entvars_t *pevInflictor, entvars_t *pevAttacke } } } - -void CBaseMonster::RadiusDamage(entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int iClassIgnore, int bitsDamageType) -{ - if (flDamage > 80) - ::RadiusDamage(pev->origin, pevInflictor, pevAttacker, flDamage, flDamage * 3.5, iClassIgnore, bitsDamageType); - else - ::RadiusDamage2(pev->origin, pevInflictor, pevAttacker, flDamage, flDamage * (RANDOM_FLOAT(0.5, 1.5) + 3), iClassIgnore, bitsDamageType); -} - -NOXREF void CBaseMonster::RadiusDamage(Vector vecSrc, entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int iClassIgnore, int bitsDamageType) -{ - if (flDamage > 80) - ::RadiusDamage(vecSrc, pevInflictor, pevAttacker, flDamage, flDamage * 3.5, iClassIgnore, bitsDamageType); - else - ::RadiusDamage2(vecSrc, pevInflictor, pevAttacker, flDamage, flDamage * (RANDOM_FLOAT(0.5, 1.5) + 3), iClassIgnore, bitsDamageType); -} - -// CheckTraceHullAttack - expects a length to trace, amount -// of damage to do, and damage type. Returns a pointer to -// the damaged entity in case the monster wishes to do -// other stuff to the victim (punchangle, etc) -// -// Used for many contact-range melee attacks. Bites, claws, etc. -NOXREF CBaseEntity *CBaseMonster::CheckTraceHullAttack(float flDist, int iDamage, int iDmgType) -{ - TraceResult tr; - - if (IsPlayer()) - UTIL_MakeVectors(pev->angles); - else - UTIL_MakeAimVectors(pev->angles); - - Vector vecStart = pev->origin; - vecStart.z += pev->size.z * 0.5; - Vector vecEnd = vecStart + (gpGlobals->v_forward * flDist); - - UTIL_TraceHull(vecStart, vecEnd, dont_ignore_monsters, head_hull, ENT(pev), &tr); - - if (tr.pHit) - { - CBaseEntity *pEntity = CBaseEntity::Instance(tr.pHit); - - if (iDamage > 0) - { - pEntity->TakeDamage(pev, pev, iDamage, iDmgType); - } - - return pEntity; - } - - return NULL; -} - -// FInViewCone - returns true is the passed ent is in -// the caller's forward view cone. The dot product is performed -// in 2d, making the view cone infinitely tall. -BOOL CBaseMonster::FInViewCone(CBaseEntity *pEntity) -{ - Vector2D vec2LOS; - float flDot; - - UTIL_MakeVectors(pev->angles); - - vec2LOS = (pEntity->pev->origin - pev->origin).Make2D(); - vec2LOS = vec2LOS.Normalize(); - - flDot = DotProduct(vec2LOS, gpGlobals->v_forward.Make2D()); - - if (flDot > m_flFieldOfView) - { - return TRUE; - } - else - { - return FALSE; - } -} - -// FInViewCone - returns true is the passed vector is in -// the caller's forward view cone. The dot product is performed -// in 2d, making the view cone infinitely tall. -BOOL CBaseMonster::FInViewCone(const Vector *pOrigin) -{ - Vector2D vec2LOS; - float flDot; - - UTIL_MakeVectors(pev->angles); - - vec2LOS = (*pOrigin - pev->origin).Make2D(); - vec2LOS = vec2LOS.Normalize(); - - flDot = DotProduct(vec2LOS, gpGlobals->v_forward.Make2D()); - - if (flDot > m_flFieldOfView) - { - return TRUE; - } - else - { - return FALSE; - } -} - -// FVisible - returns true if a line can be traced from -// the caller's eyes to the target -BOOL CBaseEntity::FVisible(CBaseEntity *pEntity) -{ - TraceResult tr; - Vector vecLookerOrigin; - Vector vecTargetOrigin; - - if (pEntity->pev->flags & FL_NOTARGET) - return FALSE; - - // don't look through water - if ((pev->waterlevel != 3 && pEntity->pev->waterlevel == 3) || (pev->waterlevel == 3 && pEntity->pev->waterlevel == 0)) - return FALSE; - - //look through the caller's 'eyes' - vecLookerOrigin = pev->origin + pev->view_ofs; - vecTargetOrigin = pEntity->EyePosition(); - - UTIL_TraceLine(vecLookerOrigin, vecTargetOrigin, ignore_monsters, ignore_glass, ENT(pev), &tr); - - if (tr.flFraction != 1.0f) - { - // Line of sight is not established - return FALSE; - } - else - { - // line of sight is valid. - return TRUE; - } -} - -// FVisible - returns true if a line can be traced from -// the caller's eyes to the target vector -BOOL CBaseEntity::FVisible(const Vector &vecOrigin) -{ - TraceResult tr; - Vector vecLookerOrigin; - - //look through the caller's 'eyes' - vecLookerOrigin = EyePosition(); - - UTIL_TraceLine(vecLookerOrigin, vecOrigin, ignore_monsters, ignore_glass, ENT(pev), &tr); - - if (tr.flFraction != 1.0f) - { - // Line of sight is not established - return FALSE; - } - else - { - // line of sight is valid. - return TRUE; - } -} - -void CBaseEntity::TraceAttack(entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType) -{ - Vector vecOrigin = ptr->vecEndPos - vecDir * 4; - - if (pev->takedamage != DAMAGE_NO) - { - AddMultiDamage(pevAttacker, this, flDamage, bitsDamageType); - - int blood = BloodColor(); - if (blood != DONT_BLEED) - { - // a little surface blood. - SpawnBlood(vecOrigin, blood, flDamage); - TraceBleed(flDamage, vecDir, ptr, bitsDamageType); - } - } -} - -void CBaseMonster::TraceAttack(entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType) -{ - Vector vecOrigin = ptr->vecEndPos - vecDir * 4; - - if (pev->takedamage != DAMAGE_NO) - { - m_LastHitGroup = ptr->iHitgroup; - - switch (ptr->iHitgroup) - { - case HITGROUP_GENERIC: - break; - case HITGROUP_HEAD: - flDamage *= 3; - break; - case HITGROUP_CHEST: - case HITGROUP_STOMACH: - flDamage *= 1.5; - break; - case HITGROUP_LEFTARM: - case HITGROUP_RIGHTARM: - flDamage *= 1.0; - break; - case HITGROUP_LEFTLEG: - case HITGROUP_RIGHTLEG: - flDamage *= 0.75; - break; - case HITGROUP_SHIELD: - flDamage = 0; - break; - default: - break; - } - - AddMultiDamage(pevAttacker, this, flDamage, bitsDamageType); - - int blood = BloodColor(); - if (blood != DONT_BLEED) - { - // a little surface blood. - SpawnBlood(vecOrigin, blood, flDamage); - } - } -} - -void CBaseEntity::FireBullets(ULONG cShots, Vector vecSrc, Vector vecDirShooting, Vector vecSpread, float flDistance, int iBulletType, int iTracerFreq, int iDamage, entvars_t *pevAttacker) -{ - static int tracerCount; - int tracer; - - TraceResult tr; - Vector vecRight, vecUp; - bool m_bCreatedShotgunSpark = true; - - vecRight = gpGlobals->v_right; - vecUp = gpGlobals->v_up; - - if (!pevAttacker) - { - // the default attacker is ourselves - pevAttacker = pev; - } - - ClearMultiDamage(); - gMultiDamage.type = (DMG_BULLET | DMG_NEVERGIB); - - for (ULONG iShot = 1; iShot <= cShots; ++iShot) - { - int spark = 0; - - // get circular gaussian spread - float x, y, z; - - do - { - x = RANDOM_FLOAT(-0.5, 0.5) + RANDOM_FLOAT(-0.5, 0.5); - y = RANDOM_FLOAT(-0.5, 0.5) + RANDOM_FLOAT(-0.5, 0.5); - z = x * x + y * y; - } - while (z > 1); - - Vector vecDir, vecEnd; - - vecDir = vecDirShooting + x * vecSpread.x * vecRight + y * vecSpread.y * vecUp; - vecEnd = vecSrc + vecDir * flDistance; - - UTIL_TraceLine(vecSrc, vecEnd, dont_ignore_monsters, ENT(pev), &tr); - tracer = 0; - - if (iTracerFreq != 0 && !(tracerCount++ % iTracerFreq)) - { - Vector vecTracerSrc; - - if (IsPlayer()) - { - // adjust tracer position for player - vecTracerSrc = vecSrc + Vector(0, 0, -4) + gpGlobals->v_right * 2 + gpGlobals->v_forward * 16; - } - else - { - vecTracerSrc = vecSrc; - } - - // guns that always trace also always decal - if (iTracerFreq != 1) - tracer = 1; - - MESSAGE_BEGIN(MSG_PAS, SVC_TEMPENTITY, vecTracerSrc); - WRITE_BYTE(TE_TRACER); - WRITE_COORD(vecTracerSrc.x); - WRITE_COORD(vecTracerSrc.y); - WRITE_COORD(vecTracerSrc.z); - WRITE_COORD(tr.vecEndPos.x); - WRITE_COORD(tr.vecEndPos.y); - WRITE_COORD(tr.vecEndPos.z); - MESSAGE_END(); - } - - // do damage, paint decals - if (tr.flFraction != 1.0f) - { - CBaseEntity *pEntity = CBaseEntity::Instance(tr.pHit); - - if (iDamage) - { - pEntity->TraceAttack(pevAttacker, iDamage, vecDir, &tr, DMG_BULLET | ((iDamage > 16) ? DMG_ALWAYSGIB : DMG_NEVERGIB)); - TEXTURETYPE_PlaySound(&tr, vecSrc, vecEnd, iBulletType); - DecalGunshot(&tr, iBulletType, false, pev, false); - } - else - { - float flDamage; - - switch (iBulletType) - { - case BULLET_PLAYER_MP5: - pEntity->TraceAttack(pevAttacker, gSkillData.plrDmgMP5, vecDir, &tr, DMG_BULLET); - break; - case BULLET_PLAYER_BUCKSHOT: - flDamage = ((1 - tr.flFraction) * 20); - pEntity->TraceAttack(pevAttacker, int(flDamage), vecDir, &tr, DMG_BULLET); - break; - case BULLET_PLAYER_357: - pEntity->TraceAttack(pevAttacker, gSkillData.plrDmg357, vecDir, &tr, DMG_BULLET); - break; - case BULLET_MONSTER_9MM: - pEntity->TraceAttack(pevAttacker, gSkillData.monDmg9MM, vecDir, &tr, DMG_BULLET); - TEXTURETYPE_PlaySound(&tr, vecSrc, vecEnd, iBulletType); - DecalGunshot(&tr, iBulletType, false, pev, false); - break; - case BULLET_MONSTER_MP5: - pEntity->TraceAttack(pevAttacker, gSkillData.monDmgMP5, vecDir, &tr, DMG_BULLET); - TEXTURETYPE_PlaySound(&tr, vecSrc, vecEnd, iBulletType); - DecalGunshot(&tr, iBulletType, false, pev, false); - break; - case BULLET_MONSTER_12MM: - pEntity->TraceAttack(pevAttacker, gSkillData.monDmg12MM, vecDir, &tr, DMG_BULLET); - - if (!tracer) - { - TEXTURETYPE_PlaySound(&tr, vecSrc, vecEnd, iBulletType); - DecalGunshot(&tr, iBulletType, false, pev, false); - } - break; - case BULLET_NONE: - flDamage = 50; - pEntity->TraceAttack(pevAttacker, flDamage, vecDir, &tr, DMG_CLUB); - TEXTURETYPE_PlaySound(&tr, vecSrc, vecEnd, iBulletType); - - // only decal glass - if (!FNullEnt(tr.pHit) && VARS(tr.pHit)->rendermode != kRenderNormal) - { - UTIL_DecalTrace(&tr, DECAL_GLASSBREAK1 + RANDOM_LONG(0, 2)); - } - break; - default: - pEntity->TraceAttack(pevAttacker, gSkillData.monDmg9MM, vecDir, &tr, DMG_BULLET); - break; - } - } - } - - // make bullet trails - UTIL_BubbleTrail(vecSrc, tr.vecEndPos, int((flDistance * tr.flFraction) / 64)); - } - - ApplyMultiDamage(pev, pevAttacker); -} - -NOXREF char *vstr(float *v) -{ - static int idx = 0; - static char string[ 16 ][ 1024 ]; - - idx = (idx + 1) % 0xF; - Q_sprintf(string[ idx ], "%.4f %.4f %.4f", v[0], v[1], v[2]); - - return string[ idx ]; -} - -// Go to the trouble of combining multiple pellets into a single damage call. -// This version is used by Players, uses the random seed generator to sync client and server side shots. -Vector CBaseEntity::FireBullets3(Vector vecSrc, Vector vecDirShooting, float vecSpread, float flDistance, int iPenetration, int iBulletType, int iDamage, float flRangeModifier, entvars_t *pevAttacker, bool bPistol, int shared_rand) -{ - int iOriginalPenetration = iPenetration; - int iPenetrationPower; - float flPenetrationDistance; - int iCurrentDamage = iDamage; - float flCurrentDistance; - - TraceResult tr, tr2; - Vector vecRight, vecUp; - - bool bHitMetal = false; - int iSparksAmount = 1; - - vecRight = gpGlobals->v_right; - vecUp = gpGlobals->v_up; - - switch (iBulletType) - { - case BULLET_PLAYER_9MM: - iPenetrationPower = 21; - flPenetrationDistance = 800; - break; - case BULLET_PLAYER_45ACP: - iPenetrationPower = 15; - flPenetrationDistance = 500; - break; - case BULLET_PLAYER_50AE: - iPenetrationPower = 30; - flPenetrationDistance = 1000; - break; - case BULLET_PLAYER_762MM: - iPenetrationPower = 39; - flPenetrationDistance = 5000; - break; - case BULLET_PLAYER_556MM: - iPenetrationPower = 35; - flPenetrationDistance = 4000; - break; - case BULLET_PLAYER_338MAG: - iPenetrationPower = 45; - flPenetrationDistance = 8000; - break; - case BULLET_PLAYER_57MM: - iPenetrationPower = 30; - flPenetrationDistance = 2000; - break; - case BULLET_PLAYER_357SIG: - iPenetrationPower = 25; - flPenetrationDistance = 800; - break; - default: - iPenetrationPower = 0; - flPenetrationDistance = 0; - break; - } - - if (!pevAttacker) - { - // the default attacker is ourselves - pevAttacker = pev; - } - - gMultiDamage.type = (DMG_BULLET | DMG_NEVERGIB); - - float x, y, z; - - if (IsPlayer()) - { - // Use player's random seed. - // get circular gaussian spread - x = UTIL_SharedRandomFloat(shared_rand, -0.5, 0.5) + UTIL_SharedRandomFloat(shared_rand + 1, -0.5, 0.5); - y = UTIL_SharedRandomFloat(shared_rand + 2, -0.5, 0.5) + UTIL_SharedRandomFloat(shared_rand + 3, -0.5, 0.5); - } - else - { - do - { - x = RANDOM_FLOAT(-0.5, 0.5) + RANDOM_FLOAT(-0.5, 0.5); - y = RANDOM_FLOAT(-0.5, 0.5) + RANDOM_FLOAT(-0.5, 0.5); - z = x * x + y * y; - } - while (z > 1); - } - - Vector vecDir, vecEnd; - Vector vecOldSrc, vecNewSrc; - - vecDir = vecDirShooting + x * vecSpread * vecRight + y * vecSpread * vecUp; - vecEnd = vecSrc + vecDir * flDistance; - - float flDamageModifier = 0.5; - - while (iPenetration != 0) - { - ClearMultiDamage(); - UTIL_TraceLine(vecSrc, vecEnd, dont_ignore_monsters, ENT(pev), &tr); - - if (TheBots && tr.flFraction != 1.0f) - { - TheBots->OnEvent(EVENT_BULLET_IMPACT, this, (CBaseEntity *)&tr.vecEndPos); - } - - char cTextureType = UTIL_TextureHit(&tr, vecSrc, vecEnd); - bool bSparks = false; - - switch (cTextureType) - { - case CHAR_TEX_METAL: - bHitMetal = true; - bSparks = true; - - iPenetrationPower *= 0.15; - flDamageModifier = 0.2; - break; - case CHAR_TEX_CONCRETE: - iPenetrationPower *= 0.25; - break; - case CHAR_TEX_GRATE: - bHitMetal = true; - bSparks = true; - - iPenetrationPower *= 0.5; - flDamageModifier = 0.4; - break; - case CHAR_TEX_VENT: - bHitMetal = true; - bSparks = true; - - iPenetrationPower *= 0.5; - flDamageModifier = 0.45; - break; - case CHAR_TEX_TILE: - iPenetrationPower *= 0.65; - flDamageModifier = 0.3; - break; - case CHAR_TEX_COMPUTER: - bHitMetal = true; - bSparks = true; - - iPenetrationPower *= 0.4; - flDamageModifier = 0.45; - break; - case CHAR_TEX_WOOD: - flDamageModifier = 0.6; - break; - default: - break; - } - if (tr.flFraction != 1.0f) - { - CBaseEntity *pEntity = CBaseEntity::Instance(tr.pHit); - iPenetration--; - - flCurrentDistance = tr.flFraction * flDistance; - iCurrentDamage *= Q_pow(flRangeModifier, flCurrentDistance / 500); - - if (flCurrentDistance > flPenetrationDistance) - { - iPenetration = 0; - } - - if (tr.iHitgroup == HITGROUP_SHIELD) - { - EMIT_SOUND(pEntity->edict(), CHAN_VOICE, (RANDOM_LONG(0, 1) == 1) ? "weapons/ric_metal-1.wav" : "weapons/ric_metal-2.wav", VOL_NORM, ATTN_NORM); - UTIL_Sparks(tr.vecEndPos); - - pEntity->pev->punchangle.x = iCurrentDamage * RANDOM_FLOAT(-0.15, 0.15); - pEntity->pev->punchangle.z = iCurrentDamage * RANDOM_FLOAT(-0.15, 0.15); - - if (pEntity->pev->punchangle.x < 4) - { - pEntity->pev->punchangle.x = -4; - } - - if (pEntity->pev->punchangle.z < -5) - { - pEntity->pev->punchangle.z = -5; - } - else if (pEntity->pev->punchangle.z > 5) - { - pEntity->pev->punchangle.z = 5; - } - - break; - } - - float flDistanceModifier; - if (VARS(tr.pHit)->solid != SOLID_BSP || !iPenetration) - { - iPenetrationPower = 42; - flDamageModifier = 0.75; - flDistanceModifier = 0.75; - } - else - flDistanceModifier = 0.5; - - DecalGunshot(&tr, iBulletType, (!bPistol && RANDOM_LONG(0, 3)), pev, bHitMetal); - - vecSrc = tr.vecEndPos + (vecDir * iPenetrationPower); - flDistance = (flDistance - flCurrentDistance) * flDistanceModifier; - vecEnd = vecSrc + (vecDir * flDistance); - - pEntity->TraceAttack(pevAttacker, iCurrentDamage, vecDir, &tr, (DMG_BULLET | DMG_NEVERGIB)); - iCurrentDamage *= flDamageModifier; - } - else - iPenetration = 0; - - ApplyMultiDamage(pev, pevAttacker); - } - - return Vector(x * vecSpread, y * vecSpread, 0); -} - -void CBaseEntity::TraceBleed(float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType) -{ - if (BloodColor() == DONT_BLEED) - return; - - if (!flDamage) - return; - - if (!(bitsDamageType & (DMG_CRUSH | DMG_BULLET | DMG_SLASH | DMG_BLAST | DMG_CLUB | DMG_MORTAR))) - return; - - // make blood decal on the wall! - TraceResult Bloodtr; - Vector vecTraceDir; - float flNoise; - int cCount; - int i; - - if (flDamage < 10.0f) - { - flNoise = 0.1f; - cCount = 1; - } - else if (flDamage < 25.0f) - { - flNoise = 0.2f; - cCount = 2; - } - else - { - flNoise = 0.3f; - cCount = 4; - } - - for (i = 0; i < cCount; ++i) - { - // trace in the opposite direction the shot came from (the direction the shot is going) - vecTraceDir = vecDir * -1.0f; - - vecTraceDir.x += RANDOM_FLOAT(-flNoise, flNoise); - vecTraceDir.y += RANDOM_FLOAT(-flNoise, flNoise); - vecTraceDir.z += RANDOM_FLOAT(-flNoise, flNoise); - - UTIL_TraceLine(ptr->vecEndPos, ptr->vecEndPos + vecTraceDir * -172.0f, ignore_monsters, ENT(pev), &Bloodtr); - if (Bloodtr.flFraction != 1.0f) - { - if (!RANDOM_LONG(0, 2)) - { - UTIL_BloodDecalTrace(&Bloodtr, BloodColor()); - } - } - } -} - -NOXREF void CBaseMonster::MakeDamageBloodDecal(int cCount, float flNoise, TraceResult *ptr, Vector &vecDir) -{ - // make blood decal on the wall! - TraceResult Bloodtr; - Vector vecTraceDir; - int i; - - if (!IsAlive()) - { - // dealing with a dead monster. - if (pev->max_health <= 0) - { - // no blood decal for a monster that has already decalled its limit. - return; - } - else - pev->max_health--; - } - - for (i = 0; i < cCount; ++i) - { - vecTraceDir = vecDir; - - vecTraceDir.x += RANDOM_FLOAT(-flNoise, flNoise); - vecTraceDir.y += RANDOM_FLOAT(-flNoise, flNoise); - vecTraceDir.z += RANDOM_FLOAT(-flNoise, flNoise); - - UTIL_TraceLine(ptr->vecEndPos, ptr->vecEndPos + vecTraceDir * 172, ignore_monsters, ENT(pev), &Bloodtr); - - if (Bloodtr.flFraction != 1.0f) - { - UTIL_BloodDecalTrace(&Bloodtr, BloodColor()); - } - } -} - -void CBaseMonster::BloodSplat(const Vector &vecSrc, const Vector &vecDir, int HitLocation, int iVelocity) -{ - if (HitLocation != HITGROUP_HEAD) - return; - - MESSAGE_BEGIN(MSG_PVS, SVC_TEMPENTITY, vecSrc); - WRITE_BYTE(TE_BLOODSTREAM); - WRITE_COORD(vecSrc.x); - WRITE_COORD(vecSrc.y); - WRITE_COORD(vecSrc.z); - WRITE_COORD(vecDir.x); - WRITE_COORD(vecDir.y); - WRITE_COORD(vecDir.z); - WRITE_BYTE(223); - WRITE_BYTE(iVelocity + RANDOM_LONG(0, 100)); - MESSAGE_END(); -} diff --git a/regamedll/dlls/h_ai.h b/regamedll/dlls/combat.h similarity index 63% rename from regamedll/dlls/h_ai.h rename to regamedll/dlls/combat.h index ed3a50df..b0b29f6d 100644 --- a/regamedll/dlls/h_ai.h +++ b/regamedll/dlls/combat.h @@ -1,42 +1,36 @@ -/* -* -* This program is free software; you can redistribute it and/or modify it -* under the terms of the GNU General Public License as published by the -* Free Software Foundation; either version 2 of the License, or (at -* your option) any later version. -* -* This program 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 -* General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* -*/ - -#ifndef H_AI_H -#define H_AI_H -#ifdef _WIN32 -#pragma once -#endif - -#define NUM_LATERAL_CHECKS 13 // how many checks are made on each side of a monster looking for lateral cover -#define NUM_LATERAL_LOS_CHECKS 6 // how many checks are made on each side of a monster looking for lateral cover - -BOOL FBoxVisible(entvars_t *pevLooker, entvars_t *pevTarget, Vector &vecTargetOrigin, float flSize); -Vector VecCheckToss(entvars_t *pev, const Vector &vecSpot1, Vector vecSpot2, float flGravityAdj); -Vector VecCheckThrow(entvars_t *pev, const Vector &vecSpot1, Vector vecSpot2, float flSpeed, float flGravityAdj); - -#endif // H_AI_H +/* +* +* This program is free software; you can redistribute it and/or modify it +* under the terms of the GNU General Public License as published by the +* Free Software Foundation; either version 2 of the License, or (at +* your option) any later version. +* +* This program 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 +* General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software Foundation, +* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +* +* In addition, as a special exception, the author gives permission to +* link the code of this program with the Half-Life Game Engine ("HL +* Engine") and Modified Game Libraries ("MODs") developed by Valve, +* L.L.C ("Valve"). You must obey the GNU General Public License in all +* respects for all of the code used other than the HL Engine and MODs +* from Valve. If you modify this file, you may extend this exception +* to your version of the file, but you are not obligated to do so. If +* you do not wish to do so, delete this exception statement from your +* version. +* +*/ + +#pragma once + +EXT_FUNC void PlayerBlind(CBasePlayer *pPlayer, entvars_t *pevInflictor, entvars_t *pevAttacker, float fadeTime, float fadeHold, int alpha, Vector &color); +EXT_FUNC void RadiusFlash_TraceLine_hook(CBasePlayer *pPlayer, entvars_t *pevInflictor, entvars_t *pevAttacker, Vector &vecSrc, Vector &vecSpot, TraceResult *tr); + +void RadiusFlash(Vector vecSrc, entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int iClassIgnore = 0, int bitsDamageType = 0); +void RadiusDamage(Vector vecSrc, entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, float flRadius, int iClassIgnore, int bitsDamageType); +void RadiusDamage2(Vector vecSrc, entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, float flRadius, int iClassIgnore, int bitsDamageType); diff --git a/regamedll/dlls/debug.cpp b/regamedll/dlls/debug.cpp index e9fce38a..cc1cc043 100644 --- a/regamedll/dlls/debug.cpp +++ b/regamedll/dlls/debug.cpp @@ -5,18 +5,18 @@ */ #ifndef HOOK_GAMEDLL -DebugOutputLevel outputLevel[ NUM_LEVELS ] = +DebugOutputLevel outputLevel[] = { - { "bot", DEBUG_BOT }, - { "career", DEBUG_CAREER }, - { "tutor", DEBUG_TUTOR }, - { "stats", DEBUG_STATS }, + { "bot", DEBUG_BOT }, + { "career", DEBUG_CAREER }, + { "tutor", DEBUG_TUTOR }, + { "stats", DEBUG_STATS }, { "hostage", DEBUG_HOSTAGE }, - { "all", DEBUG_ALL } + { "all", DEBUG_ALL }, }; unsigned int theDebugOutputTypes; -static char theDebugBuffer[ DebugBufferSize ]; +static char theDebugBuffer[MAX_DEBUG_BUFF_SIZE]; #endif @@ -57,7 +57,7 @@ void UTIL_DPrintf(char *pszMsg, ...) void PrintDebugFlags() { char *tmp; - int remainder = DebugBufferSize; + int remainder = MAX_DEBUG_BUFF_SIZE; theDebugBuffer[0] = '\0'; tmp = BufPrintf(theDebugBuffer, remainder, "mp_debug:\n"); diff --git a/regamedll/dlls/debug.h b/regamedll/dlls/debug.h index 7915e32d..26b8ba12 100644 --- a/regamedll/dlls/debug.h +++ b/regamedll/dlls/debug.h @@ -26,26 +26,18 @@ * */ -#ifndef DEBUG_H -#define DEBUG_H -#ifdef _WIN32 #pragma once -#endif -const int NUM_LEVELS = 6; -const int DebugBufferSize = 1024; - -typedef enum +enum DebugOutputType { - DEBUG_NONE = 0, - DEBUG_BOT = (1 << 0), - DEBUG_CAREER = (1 << 1), - DEBUG_TUTOR = (1 << 2), - DEBUG_STATS = (1 << 3), - DEBUG_HOSTAGE = (1 << 4), - DEBUG_ALL = 0xFFFFFFFF, - -} DebugOutputType; + DEBUG_NONE = 0, + DEBUG_BOT = BIT(0), + DEBUG_CAREER = BIT(1), + DEBUG_TUTOR = BIT(2), + DEBUG_STATS = BIT(3), + DEBUG_HOSTAGE = BIT(4), + DEBUG_ALL = 0xFFFFFFFF, +}; struct DebugOutputLevel { @@ -53,6 +45,8 @@ struct DebugOutputLevel DebugOutputType value; }; +const int MAX_DEBUG_BUFF_SIZE = 1024; + bool IsDeveloper(); void UTIL_DPrintf(DebugOutputType outputType, char *pszMsg, ...); void UTIL_DPrintf(char *pszMsg, ...); @@ -67,5 +61,3 @@ void UTIL_CareerDPrintf(char *pszMsg, ...); void UTIL_TutorDPrintf(char *pszMsg, ...); void UTIL_StatsDPrintf(char *pszMsg, ...); void UTIL_HostageDPrintf(char *pszMsg, ...); - -#endif // DEBUG_H diff --git a/regamedll/dlls/decals.h b/regamedll/dlls/decals.h index a00587e8..7814b875 100644 --- a/regamedll/dlls/decals.h +++ b/regamedll/dlls/decals.h @@ -26,11 +26,10 @@ * */ -#ifndef DECALS_H -#define DECALS_H -#ifdef _WIN32 #pragma once -#endif + +#define DEFINE_DECAL(name)\ + { name, 0 } enum decal_e { @@ -69,13 +68,14 @@ enum decal_e DECAL_BIGSHOT5, DECAL_SPIT1, DECAL_SPIT2, - DECAL_BPROOF1, // Bulletproof glass decal - DECAL_GARGSTOMP1, // Gargantua stomp crack - DECAL_SMALLSCORCH1, // Small scorch mark - DECAL_SMALLSCORCH2, // Small scorch mark - DECAL_SMALLSCORCH3, // Small scorch mark - DECAL_MOMMABIRTH, // Big momma birth splatter + DECAL_BPROOF1, // Bulletproof glass decal + DECAL_GARGSTOMP1, // Gargantua stomp crack + DECAL_SMALLSCORCH1, // Small scorch mark + DECAL_SMALLSCORCH2, // Small scorch mark + DECAL_SMALLSCORCH3, // Small scorch mark + DECAL_MOMMABIRTH, // Big momma birth splatter DECAL_MOMMASPLAT, + DECAL_END }; typedef struct @@ -85,6 +85,4 @@ typedef struct } DLL_DECALLIST; -extern DLL_DECALLIST gDecals[42]; - -#endif // DECALS_H +extern DLL_DECALLIST gDecals[DECAL_END]; diff --git a/regamedll/dlls/doors.cpp b/regamedll/dlls/doors.cpp index 2584ab99..dd806751 100644 --- a/regamedll/dlls/doors.cpp +++ b/regamedll/dlls/doors.cpp @@ -162,7 +162,9 @@ void CBaseDoor::KeyValue(KeyValueData *pkvd) pkvd->fHandled = TRUE; } else + { CBaseToggle::KeyValue(pkvd); + } } // QUAKED func_door (0 .5 .8) ? START_OPEN x DOOR_DONT_LINK TOGGLE @@ -210,7 +212,7 @@ void CBaseDoor::Spawn() pev->solid = SOLID_NOT; // water is silent for now - pev->spawnflags |= SF_DOOR_SILENT; + pev->spawnflags |= SF_DOOR_ACTUALLY_WATER; } pev->movetype = MOVETYPE_PUSH; @@ -482,7 +484,7 @@ int CBaseDoor::DoorActivate() else // door should open { // give health if player opened the door (medikit) - if (m_hActivator != NULL && m_hActivator->IsPlayer()) + if (m_hActivator && m_hActivator->IsPlayer()) { // VARS(m_eoActivator)->health += m_bHealthValue; m_hActivator->TakeHealth(m_bHealthValue, DMG_GENERIC); @@ -510,14 +512,15 @@ void CBaseDoor::DoorGoUp() // filter them out and leave a client stuck with looping door sounds! if (!isReversing) { - if (!(pev->spawnflags & SF_DOOR_SILENT)) + // water is silent + if (!(pev->spawnflags & SF_DOOR_ACTUALLY_WATER)) { if (m_toggle_state != TS_GOING_UP && m_toggle_state != TS_GOING_DOWN) { EMIT_SOUND(ENT(pev), CHAN_STATIC, (char *)STRING(pev->noiseMoving), VOL_NORM, ATTN_NORM); } - if (TheBots != NULL) + if (TheBots) { TheBots->OnEvent(EVENT_DOOR, m_hActivator); } @@ -533,12 +536,12 @@ void CBaseDoor::DoorGoUp() { float sign = 1.0; - if (m_hActivator != NULL) + if (m_hActivator) { pevActivator = m_hActivator->pev; // Y axis rotation, move away from the player - if (!(pev->spawnflags & SF_DOOR_ONEWAY) && pev->movedir.y) + if (!(pev->spawnflags & SF_DOOR_ROTATE_ONEWAY) && pev->movedir.y) { Vector2D toActivator = pevActivator->origin.Make2D(); @@ -613,7 +616,8 @@ void CBaseDoor::DoorGoUp() // The door has reached the "up" position. Either go back down, or wait for another activation. void CBaseDoor::DoorHitTop() { - if (!(pev->spawnflags & SF_DOOR_SILENT)) + // water is silent + if (!(pev->spawnflags & SF_DOOR_ACTUALLY_WATER)) { STOP_SOUND(ENT(pev), CHAN_STATIC, (char *)STRING(pev->noiseMoving)); EMIT_SOUND(ENT(pev), CHAN_STATIC, (char *)STRING(pev->noiseArrived), VOL_NORM, ATTN_NORM); @@ -660,14 +664,15 @@ void CBaseDoor::DoorGoDown() if (!isReversing) { - if (!(pev->spawnflags & SF_DOOR_SILENT)) + // water is silent + if (!(pev->spawnflags & SF_DOOR_ACTUALLY_WATER)) { if (m_toggle_state != TS_GOING_UP && m_toggle_state != TS_GOING_DOWN) { EMIT_SOUND(ENT(pev), CHAN_STATIC, (char *)STRING(pev->noiseMoving), VOL_NORM, ATTN_NORM); } - if (TheBots != NULL) + if (TheBots) { TheBots->OnEvent(EVENT_DOOR, m_hActivator); } @@ -694,7 +699,8 @@ void CBaseDoor::DoorGoDown() // The door has reached the "down" position. Back to quiescence. void CBaseDoor::DoorHitBottom() { - if (!(pev->spawnflags & SF_DOOR_SILENT)) + // water is silent + if (!(pev->spawnflags & SF_DOOR_ACTUALLY_WATER)) { STOP_SOUND(ENT(pev), CHAN_STATIC, (char *)STRING(pev->noiseMoving)); EMIT_SOUND(ENT(pev), CHAN_STATIC, (char *)STRING(pev->noiseArrived), VOL_NORM, ATTN_NORM); @@ -727,8 +733,8 @@ void CBaseDoor::DoorHitBottom() void CBaseDoor::Blocked(CBaseEntity *pOther) { - edict_t *pentTarget = NULL; - CBaseDoor *pDoor = NULL; + edict_t *pentTarget = nullptr; + CBaseDoor *pDoor = nullptr; const float checkBlockedInterval = 0.25f; // Hurt the blocker a little. @@ -795,7 +801,7 @@ void CBaseDoor::Blocked(CBaseEntity *pOther) } } - if (!(pev->spawnflags & SF_DOOR_SILENT)) + if (!(pev->spawnflags & SF_DOOR_ACTUALLY_WATER)) { STOP_SOUND(ENT(pev), CHAN_STATIC, (char *)STRING(pev->noiseMoving)); } diff --git a/regamedll/dlls/doors.h b/regamedll/dlls/doors.h index e315eff3..1c0be5d1 100644 --- a/regamedll/dlls/doors.h +++ b/regamedll/dlls/doors.h @@ -26,28 +26,18 @@ * */ -#ifndef DOORS_H -#define DOORS_H -#ifdef _WIN32 #pragma once -#endif -#define DOOR_SENTENCEWAIT 6 -#define DOOR_SOUNDWAIT 3 -#define BUTTON_SOUNDWAIT 0.5 +const float DOOR_SENTENCEWAIT = 6.0f; +const float DOOR_SOUNDWAIT = 3.0f; +const float BUTTON_SOUNDWAIT = 0.5f; -#define SF_DOOR_ROTATE_Y 0 -#define SF_DOOR_START_OPEN 1 -#define SF_DOOR_ROTATE_BACKWARDS 2 -#define SF_DOOR_PASSABLE 8 -#define SF_DOOR_ONEWAY 16 -#define SF_DOOR_NO_AUTO_RETURN 32 -#define SF_DOOR_ROTATE_Z 64 -#define SF_DOOR_ROTATE_X 128 -#define SF_DOOR_USE_ONLY 256 // door must be opened by player's use button. -#define SF_DOOR_NOMONSTERS 512 // Monster can't open -#define SF_DOOR_TOUCH_ONLY_CLIENTS 1024 // Only clients can touch -#define SF_DOOR_SILENT 0x80000000 +#define SF_DOOR_START_OPEN BIT(0) +#define SF_DOOR_PASSABLE BIT(3) +#define SF_DOOR_NO_AUTO_RETURN BIT(5) +#define SF_DOOR_USE_ONLY BIT(8) // Door must be opened by player's use button. +#define SF_DOOR_TOUCH_ONLY_CLIENTS BIT(10) // Only clients can touch +#define SF_DOOR_ACTUALLY_WATER BIT(31) // This bit marks that func_door are actually func_water class CBaseDoor: public CBaseToggle { @@ -60,7 +50,7 @@ public: virtual int Restore(CRestore &restore); virtual int ObjectCaps() { - if (pev->spawnflags & SF_ITEM_USE_ONLY) + if (pev->spawnflags & SF_DOOR_USE_ONLY) return (CBaseToggle::ObjectCaps() & ~FCAP_ACROSS_TRANSITION) | FCAP_IMPULSE_USE; else return (CBaseToggle::ObjectCaps() & ~FCAP_ACROSS_TRANSITION); @@ -82,7 +72,6 @@ public: public: byte m_bHealthValue; // some doors are medi-kit doors, they give players health - byte m_bMoveSnd; // sound a door makes while moving byte m_bStopSnd; // sound a door makes when it stops @@ -96,6 +85,11 @@ public: float m_lastBlockedTimestamp; }; +#define SF_DOOR_ROTATE_BACKWARDS BIT(1) +#define SF_DOOR_ROTATE_ONEWAY BIT(4) +#define SF_DOOR_ROTATE_Z BIT(6) +#define SF_DOOR_ROTATE_X BIT(7) + class CRotDoor: public CBaseDoor { public: @@ -122,5 +116,3 @@ public: }; void PlayLockSounds(entvars_t *pev, locksound_t *pls, int flocked, int fbutton); - -#endif // DOORS_H diff --git a/regamedll/dlls/effects.cpp b/regamedll/dlls/effects.cpp index 4c5c6a4d..be7734b7 100644 --- a/regamedll/dlls/effects.cpp +++ b/regamedll/dlls/effects.cpp @@ -136,7 +136,9 @@ void CBubbling::KeyValue(KeyValueData *pkvd) pkvd->fHandled = TRUE; } else + { CBaseEntity::KeyValue(pkvd); + } } void CBubbling::FizzThink() @@ -207,7 +209,7 @@ const Vector &CBeam::GetEndPos() } edict_t *pent = INDEXENT(GetEndEntity()); - if (pent != NULL) + if (pent) { return pent->v.origin; } @@ -218,7 +220,7 @@ const Vector &CBeam::GetEndPos() CBeam *CBeam::BeamCreate(const char *pSpriteName, int width) { // Create a new entity with CBeam private data - CBeam *pBeam = GetClassPtr((CBeam *)NULL); + CBeam *pBeam = GetClassPtr((CBeam *)nullptr); MAKE_STRING_CLASS("beam", pBeam->pev); pBeam->BeamInit(pSpriteName, width); @@ -321,10 +323,10 @@ CBaseEntity *CBeam::RandomTargetname(const char *szName) { int total = 0; - CBaseEntity *pEntity = NULL; - CBaseEntity *pNewEntity = NULL; + CBaseEntity *pEntity = nullptr; + CBaseEntity *pNewEntity = nullptr; - while ((pNewEntity = UTIL_FindEntityByTargetname(pNewEntity, szName)) != NULL) + while ((pNewEntity = UTIL_FindEntityByTargetname(pNewEntity, szName))) { total++; @@ -475,7 +477,9 @@ void CLightning::KeyValue(KeyValueData *pkvd) pkvd->fHandled = TRUE; } else + { CBeam::KeyValue(pkvd); + } } void CLightning::ToggleUse(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) @@ -557,7 +561,7 @@ void CLightning::StrikeThink() else { CBaseEntity *pStart = RandomTargetname(STRING(m_iszStartEntity)); - if (pStart != NULL) + if (pStart) RandomPoint(pStart->pev->origin); else ALERT(at_console, "env_beam: unknown entity \"%s\"\n", STRING(m_iszStartEntity)); @@ -568,7 +572,7 @@ void CLightning::StrikeThink() CBaseEntity *pStart = RandomTargetname(STRING(m_iszStartEntity)); CBaseEntity *pEnd = RandomTargetname(STRING(m_iszEndEntity)); - if (pStart != NULL && pEnd != NULL) + if (pStart && pEnd) { if (IsPointEntity(pStart) || IsPointEntity(pEnd)) { @@ -642,7 +646,7 @@ void CLightning::StrikeThink() if (pev->dmg > 0) { TraceResult tr; - UTIL_TraceLine(pStart->pev->origin, pEnd->pev->origin, dont_ignore_monsters, NULL, &tr); + UTIL_TraceLine(pStart->pev->origin, pEnd->pev->origin, dont_ignore_monsters, nullptr, &tr); BeamDamageInstant(&tr, pev->dmg); } } @@ -652,11 +656,11 @@ void CBeam::BeamDamage(TraceResult *ptr) { RelinkBeam(); - if (ptr->flFraction != 1.0f && ptr->pHit != NULL) + if (ptr->flFraction != 1.0f && ptr->pHit) { CBaseEntity *pHit = CBaseEntity::Instance(ptr->pHit); - if (pHit != NULL) + if (pHit) { ClearMultiDamage(); pHit->TraceAttack(pev, pev->dmg * (gpGlobals->time - pev->dmgtime), (ptr->vecEndPos - pev->origin).Normalize(), ptr, DMG_ENERGYBEAM); @@ -680,7 +684,7 @@ void CLightning::DamageThink() pev->nextthink = gpGlobals->time + 0.1f; TraceResult tr; - UTIL_TraceLine(GetStartPos(), GetEndPos(), dont_ignore_monsters, NULL, &tr); + UTIL_TraceLine(GetStartPos(), GetEndPos(), dont_ignore_monsters, nullptr, &tr); BeamDamage(&tr); } @@ -778,8 +782,8 @@ void CLightning::BeamUpdateVars() int beamType; int pointStart, pointEnd; - edict_t *pStart = FIND_ENTITY_BY_TARGETNAME(NULL, STRING(m_iszStartEntity)); - edict_t *pEnd = FIND_ENTITY_BY_TARGETNAME(NULL, STRING(m_iszEndEntity)); + edict_t *pStart = FIND_ENTITY_BY_TARGETNAME(nullptr, STRING(m_iszStartEntity)); + edict_t *pEnd = FIND_ENTITY_BY_TARGETNAME(nullptr, STRING(m_iszEndEntity)); pointStart = IsPointEntity(CBaseEntity::Instance(pStart)); pointEnd = IsPointEntity(CBaseEntity::Instance(pEnd)); @@ -869,7 +873,7 @@ void CLaser::Spawn() if (!m_pSprite && m_iszSpriteName) m_pSprite = CSprite::SpriteCreate(STRING(m_iszSpriteName), pev->origin, TRUE); else - m_pSprite = NULL; + m_pSprite = nullptr; if (m_pSprite) m_pSprite->SetTransparency(kRenderGlow, pev->rendercolor.x, pev->rendercolor.y, pev->rendercolor.z, pev->renderamt, pev->renderfx); @@ -933,7 +937,9 @@ void CLaser::KeyValue(KeyValueData *pkvd) pkvd->fHandled = TRUE; } else + { CBeam::KeyValue(pkvd); + } } int CLaser::IsOn() @@ -1000,7 +1006,7 @@ void CLaser::StrikeThink() m_firePosition = pEnd->pev->origin; TraceResult tr; - UTIL_TraceLine(pev->origin, m_firePosition, dont_ignore_monsters, NULL, &tr); + UTIL_TraceLine(pev->origin, m_firePosition, dont_ignore_monsters, nullptr, &tr); FireAtPoint(tr); pev->nextthink = gpGlobals->time + 0.1f; } @@ -1160,7 +1166,7 @@ void CSprite::SpriteInit(const char *pSpriteName, const Vector &origin) CSprite *CSprite::SpriteCreate(const char *pSpriteName, const Vector &origin, BOOL animate) { - CSprite *pSprite = GetClassPtr((CSprite *)NULL); + CSprite *pSprite = GetClassPtr((CSprite *)nullptr); pSprite->SpriteInit(pSpriteName, origin); MAKE_STRING_CLASS("env_sprite", pSprite->pev); @@ -1310,7 +1316,9 @@ void CGibShooter::KeyValue(KeyValueData *pkvd) pkvd->fHandled = TRUE; } else + { CBaseDelay::KeyValue(pkvd); + } } void CGibShooter::Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) @@ -1343,9 +1351,9 @@ void CGibShooter::Spawn() CGib *CGibShooter::CreateGib() { if (CVAR_GET_FLOAT("violence_hgibs") == 0) - return NULL; + return nullptr; - CGib *pGib = GetClassPtr((CGib *)NULL); + CGib *pGib = GetClassPtr((CGib *)nullptr); pGib->Spawn("models/hgibs.mdl"); pGib->m_bloodColor = BLOOD_COLOR_RED; @@ -1463,7 +1471,9 @@ void CEnvShooter::KeyValue(KeyValueData *pkvd) } } else + { CGibShooter::KeyValue(pkvd); + } } void CEnvShooter::Precache() @@ -1474,7 +1484,7 @@ void CEnvShooter::Precache() CGib *CEnvShooter::CreateGib() { - CGib *pGib = GetClassPtr((CGib *)NULL); + CGib *pGib = GetClassPtr((CGib *)nullptr); pGib->Spawn(STRING(pev->model)); @@ -1606,7 +1616,9 @@ void CBlood::KeyValue(KeyValueData *pkvd) pkvd->fHandled = TRUE; } else + { CPointEntity::KeyValue(pkvd); + } } Vector CBlood::Direction() @@ -1628,7 +1640,7 @@ Vector CBlood::BloodPosition(CBaseEntity *pActivator) else pPlayer = INDEXENT(1); - if (pPlayer != NULL) + if (pPlayer) { return (pPlayer->v.origin + pPlayer->v.view_ofs) + Vector(RANDOM_FLOAT(-10, 10), RANDOM_FLOAT(-10, 10), RANDOM_FLOAT(-10, 10)); } @@ -1650,7 +1662,7 @@ void CBlood::Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType Vector start = BloodPosition(pActivator); TraceResult tr; - UTIL_TraceLine(start, start + forward * BloodAmount() * 2, ignore_monsters, NULL, &tr); + UTIL_TraceLine(start, start + forward * BloodAmount() * 2, ignore_monsters, nullptr, &tr); if (tr.flFraction != 1.0f) { @@ -1695,7 +1707,9 @@ void CShake::KeyValue(KeyValueData *pkvd) pkvd->fHandled = TRUE; } else + { CPointEntity::KeyValue(pkvd); + } } void CShake::Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) @@ -1726,7 +1740,9 @@ void CFade::KeyValue(KeyValueData *pkvd) pkvd->fHandled = TRUE; } else + { CPointEntity::KeyValue(pkvd); + } } void CFade::Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) @@ -1813,12 +1829,14 @@ void CMessage::KeyValue(KeyValueData *pkvd) pkvd->fHandled = TRUE; } else + { CPointEntity::KeyValue(pkvd); + } } void CMessage::Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) { - CBaseEntity *pPlayer = NULL; + CBaseEntity *pPlayer = nullptr; if (pev->spawnflags & SF_MESSAGE_ALL) UTIL_ShowMessageAll(STRING(pev->message)); @@ -1831,7 +1849,7 @@ void CMessage::Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useTy pPlayer = CBaseEntity::Instance(INDEXENT(1)); } - if (pPlayer != NULL) + if (pPlayer) UTIL_ShowMessage(STRING(pev->message), pPlayer); } diff --git a/regamedll/dlls/effects.h b/regamedll/dlls/effects.h index 1507bfe0..397aa805 100644 --- a/regamedll/dlls/effects.h +++ b/regamedll/dlls/effects.h @@ -26,47 +26,11 @@ * */ -#ifndef EFFECTS_H -#define EFFECTS_H -#ifdef _WIN32 #pragma once -#endif -#define SF_BEAM_STARTON 0x0001 -#define SF_BEAM_TOGGLE 0x0002 -#define SF_BEAM_RANDOM 0x0004 -#define SF_BEAM_RING 0x0008 -#define SF_BEAM_SPARKSTART 0x0010 -#define SF_BEAM_SPARKEND 0x0020 -#define SF_BEAM_DECALS 0x0040 -#define SF_BEAM_SHADEIN 0x0080 -#define SF_BEAM_SHADEOUT 0x0100 -#define SF_BEAM_TEMPORARY 0x8000 - -#define SF_GIBSHOOTER_REPEATABLE 1 -#define SF_FUNNEL_REVERSE 1 - -#define SF_BUBBLES_STARTOFF 0x0001 - -#define SF_BLOOD_RANDOM 0x0001 -#define SF_BLOOD_STREAM 0x0002 -#define SF_BLOOD_PLAYER 0x0004 -#define SF_BLOOD_DECAL 0x0008 - -#define SF_SHAKE_EVERYONE 0x0001 -#define SF_SHAKE_DISRUPT 0x0002 -#define SF_SHAKE_INAIR 0x0004 - -#define SF_FADE_IN 0x0001 -#define SF_FADE_MODULATE 0x0002 -#define SF_FADE_ONLYONE 0x0004 - -#define SF_SPRITE_STARTON 0x0001 -#define SF_SPRITE_ONCE 0x0002 -#define SF_SPRITE_TEMPORARY 0x8000 - -#define SF_MESSAGE_ONCE 0x0001 // Fade in, not out -#define SF_MESSAGE_ALL 0x0002 // Send to all clients +#define SF_SPRITE_STARTON BIT(0) +#define SF_SPRITE_ONCE BIT(1) +#define SF_SPRITE_TEMPORARY BIT(15) class CSprite: public CPointEntity { @@ -96,7 +60,7 @@ public: void SetAttachment(edict_t *pEntity, int attachment) { - if (pEntity != NULL) + if (pEntity) { pev->skin = ENTINDEX(pEntity); pev->body = attachment; @@ -142,6 +106,17 @@ private: float m_maxFrame; }; +#define SF_BEAM_STARTON BIT(0) +#define SF_BEAM_TOGGLE BIT(1) +#define SF_BEAM_RANDOM BIT(2) +#define SF_BEAM_RING BIT(3) +#define SF_BEAM_SPARKSTART BIT(4) +#define SF_BEAM_SPARKEND BIT(5) +#define SF_BEAM_DECALS BIT(6) +#define SF_BEAM_SHADEIN BIT(7) +#define SF_BEAM_SHADEOUT BIT(8) +#define SF_BEAM_TEMPORARY BIT(15) + class CBeam: public CBaseEntity { public: @@ -243,6 +218,8 @@ public: Vector m_firePosition; }; +#define SF_BUBBLES_STARTOFF BIT(0) + class CBubbling: public CBaseEntity { public: @@ -341,6 +318,8 @@ public: bool m_bSetModel; }; +#define SF_GIBSHOOTER_REPEATABLE BIT(0) // Allows a gibshooter to be refired + class CGibShooter: public CBaseDelay { public: @@ -376,7 +355,7 @@ public: virtual CGib *CreateGib(); }; -#define MAX_BEAM 24 +const int MAX_BEAM = 24; class CTestEffect: public CBaseDelay { @@ -392,12 +371,17 @@ public: int m_iLoop; int m_iBeam; - CBeam *m_pBeam[ MAX_BEAM ]; + CBeam *m_pBeam[MAX_BEAM]; - float m_flBeamTime[ MAX_BEAM ]; + float m_flBeamTime[MAX_BEAM]; float m_flStartTime; }; +#define SF_BLOOD_RANDOM BIT(0) +#define SF_BLOOD_STREAM BIT(1) +#define SF_BLOOD_PLAYER BIT(2) +#define SF_BLOOD_DECAL BIT(3) + class CBlood: public CPointEntity { public: @@ -417,6 +401,10 @@ public: Vector BloodPosition(CBaseEntity *pActivator); }; +#define SF_SHAKE_EVERYONE BIT(0) // Don't check radius +#define SF_SHAKE_DISRUPT BIT(1) // Disrupt controls +#define SF_SHAKE_INAIR BIT(2) // Shake players in air + class CShake: public CPointEntity { public: @@ -436,6 +424,10 @@ public: void SetRadius(float radius) { pev->dmg = radius; } }; +#define SF_FADE_IN BIT(0) // Fade in, not out +#define SF_FADE_MODULATE BIT(1) // Modulate, don't blend +#define SF_FADE_ONLYONE BIT(2) + class CFade: public CPointEntity { public: @@ -451,6 +443,9 @@ public: void SetHoldTime(float hold) { pev->dmg_save = hold; } }; +#define SF_MESSAGE_ONCE BIT(0) // Fade in, not out +#define SF_MESSAGE_ALL BIT(1) // Send to all clients + class CMessage: public CPointEntity { public: @@ -460,6 +455,8 @@ public: virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); }; +#define SF_FUNNEL_REVERSE BIT(0) // Funnel effect repels particles instead of attracting them + class CEnvFunnel: public CBaseDelay { public: @@ -491,5 +488,3 @@ public: }; int IsPointEntity(CBaseEntity *pEnt); - -#endif // EFFECTS_H diff --git a/regamedll/dlls/ehandle.h b/regamedll/dlls/ehandle.h new file mode 100644 index 00000000..28bcd21b --- /dev/null +++ b/regamedll/dlls/ehandle.h @@ -0,0 +1,226 @@ +/* +* +* This program is free software; you can redistribute it and/or modify it +* under the terms of the GNU General Public License as published by the +* Free Software Foundation; either version 2 of the License, or (at +* your option) any later version. +* +* This program 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 +* General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software Foundation, +* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +* +* In addition, as a special exception, the author gives permission to +* link the code of this program with the Half-Life Game Engine ("HL +* Engine") and Modified Game Libraries ("MODs") developed by Valve, +* L.L.C ("Valve"). You must obey the GNU General Public License in all +* respects for all of the code used other than the HL Engine and MODs +* from Valve. If you modify this file, you may extend this exception +* to your version of the file, but you are not obligated to do so. If +* you do not wish to do so, delete this exception statement from your +* version. +* +*/ + +#pragma once + +// Safe way to point to CBaseEntities who may die between frames. +template +class EntityHandle +{ +public: + EntityHandle() : m_edict(nullptr), m_serialnumber(0) {} + EntityHandle(const EntityHandle &other); + EntityHandle(const T *pEntity); + EntityHandle(const edict_t *pEdict); + + // cast to base class + // NOTE: this is a unsafe method + template + R *Get() const; + + edict_t *Get() const; + edict_t *Set(edict_t *pEdict); + + bool IsValid() const; + int GetSerialNumber() const; + + bool operator==(T *pEntity) const; + operator bool() const; + operator T *() const; + + T *operator=(T *pEntity); + T *operator->(); + + // Copy the ehandle. + EntityHandle& operator=(const EntityHandle &other); + +private: + edict_t *m_edict; + int m_serialnumber; +}; + +// Short alias +using EHandle = EntityHandle<>; +using EHANDLE = EHandle; + +// Inlines +template +inline bool FNullEnt(EntityHandle &hent) +{ + return (!hent || FNullEnt(OFFSET(hent.Get()))); +} + +// Copy constructor +template +EntityHandle::EntityHandle(const EntityHandle &other) +{ + m_edict = other.m_edict; + m_serialnumber = other.m_serialnumber; +} + +template +EntityHandle::EntityHandle(const T *pEntity) +{ + if (pEntity) + { + Set(ENT(pEntity->pev)); + } + else + { + m_edict = nullptr; + m_serialnumber = 0; + } +} + +template +EntityHandle::EntityHandle(const edict_t *pEdict) +{ + Set(const_cast(pEdict)); +} + +template +template +inline R *EntityHandle::Get() const +{ + return GET_PRIVATE(Get()); +} + +template +inline edict_t *EntityHandle::Get() const +{ + if (!m_edict || m_edict->serialnumber != m_serialnumber || m_edict->free) + { + return nullptr; + } + + return m_edict; +} + +template +inline edict_t *EntityHandle::Set(edict_t *pEdict) +{ + m_edict = pEdict; + if (pEdict) + { + m_serialnumber = pEdict->serialnumber; + } + + return pEdict; +} + +// Returns whether this handle is valid. +template +inline bool EntityHandle::IsValid() const +{ + edict_t *pEdict = Get(); + if (!pEdict) + { + return false; + } + + CBaseEntity *pEntity = GET_PRIVATE(pEdict); + if (!pEntity) + { + return false; + } + + return true; +} + +// CBaseEntity serial number. +// Used to determine if the entity is still valid. +template +inline int EntityHandle::GetSerialNumber() const +{ + return m_serialnumber; +} + +template +inline bool EntityHandle::operator==(T *pEntity) const +{ + assert(("EntityHandle::operator==: got a nullptr pointer!", pEntity != nullptr)); + + if (m_serialnumber != pEntity->edict()->serialnumber) + { + return false; + } + + return m_edict == pEntity->edict(); +} + +template +inline EntityHandle::operator bool() const +{ + return Get() != nullptr; +} + +// Gets the Entity this handle refers to. +// Returns null if invalid. +template +inline EntityHandle::operator T *() const +{ + return GET_PRIVATE(Get()); +} + +// Assigns the given entity to this handle. +template +inline T *EntityHandle::operator=(T *pEntity) +{ + if (pEntity) + { + Set(ENT(pEntity->pev)); + } + else + { + m_edict = nullptr; + m_serialnumber = 0; + } + + return static_cast(pEntity); +} + +template +inline T *EntityHandle::operator->() +{ + edict_t *pEdict = Get(); + assert(("EntityHandle::operator->: pointer is nullptr!", pEdict != nullptr)); + + T *pEntity = GET_PRIVATE(pEdict); + assert(("EntityHandle::operator->: pvPrivateData is nullptr!", pEntity != nullptr)); + return pEntity; +} + +// Makes this handle refer to the same entity as the given handle. +template +inline EntityHandle& EntityHandle::operator=(const EntityHandle &other) +{ + m_edict = other.m_edict; + m_serialnumber = other.m_serialnumber; + + return (*this); +} diff --git a/regamedll/dlls/enginecallback.h b/regamedll/dlls/enginecallback.h index def9217c..2220c988 100644 --- a/regamedll/dlls/enginecallback.h +++ b/regamedll/dlls/enginecallback.h @@ -26,161 +26,161 @@ * */ -#ifndef ENGINECALLBACK_H -#define ENGINECALLBACK_H -#ifdef _WIN32 #pragma once -#endif #include "event_flags.h" +// Must be provided by user of this code extern enginefuncs_t g_engfuncs; -#define GETPLAYERUSERID (*g_engfuncs.pfnGetPlayerUserId) -#define PRECACHE_MODEL (*g_engfuncs.pfnPrecacheModel) -#define PRECACHE_SOUND (*g_engfuncs.pfnPrecacheSound) -#define PRECACHE_GENERIC (*g_engfuncs.pfnPrecacheGeneric) -#define SET_MODEL (*g_engfuncs.pfnSetModel) -#define MODEL_INDEX (*g_engfuncs.pfnModelIndex) -#define MODEL_FRAMES (*g_engfuncs.pfnModelFrames) -#define SET_SIZE (*g_engfuncs.pfnSetSize) -#define CHANGE_LEVEL (*g_engfuncs.pfnChangeLevel) -#define GET_SPAWN_PARMS (*g_engfuncs.pfnGetSpawnParms) -#define SAVE_SPAWN_PARMS (*g_engfuncs.pfnSaveSpawnParms) -#define VEC_TO_YAW (*g_engfuncs.pfnVecToYaw) -#define VEC_TO_ANGLES (*g_engfuncs.pfnVecToAngles) -#define MOVE_TO_ORIGIN (*g_engfuncs.pfnMoveToOrigin) -#define oldCHANGE_YAW (*g_engfuncs.pfnChangeYaw) -#define CHANGE_PITCH (*g_engfuncs.pfnChangePitch) -#define MAKE_VECTORS (*g_engfuncs.pfnMakeVectors) -#define CREATE_ENTITY (*g_engfuncs.pfnCreateEntity) -#define REMOVE_ENTITY (*g_engfuncs.pfnRemoveEntity) -#define CREATE_NAMED_ENTITY (*g_engfuncs.pfnCreateNamedEntity) -#define MAKE_STATIC (*g_engfuncs.pfnMakeStatic) -#define ENT_IS_ON_FLOOR (*g_engfuncs.pfnEntIsOnFloor) -#define DROP_TO_FLOOR (*g_engfuncs.pfnDropToFloor) -#define WALK_MOVE (*g_engfuncs.pfnWalkMove) -#define SET_ORIGIN (*g_engfuncs.pfnSetOrigin) -#define EMIT_SOUND_DYN2 (*g_engfuncs.pfnEmitSound) -#define BUILD_SOUND_MSG (*g_engfuncs.pfnBuildSoundMsg) -#define TRACE_LINE (*g_engfuncs.pfnTraceLine) -#define TRACE_TOSS (*g_engfuncs.pfnTraceToss) -#define TRACE_MONSTER_HULL (*g_engfuncs.pfnTraceMonsterHull) -#define TRACE_HULL (*g_engfuncs.pfnTraceHull) -#define TRACE_MODEL (*g_engfuncs.pfnTraceModel) -#define GET_AIM_VECTOR (*g_engfuncs.pfnGetAimVector) -#define SERVER_COMMAND (*g_engfuncs.pfnServerCommand) -#define SERVER_EXECUTE (*g_engfuncs.pfnServerExecute) -#define CLIENT_COMMAND (*g_engfuncs.pfnClientCommand) -#define PARTICLE_EFFECT (*g_engfuncs.pfnParticleEffect) -#define LIGHT_STYLE (*g_engfuncs.pfnLightStyle) -#define DECAL_INDEX (*g_engfuncs.pfnDecalIndex) -#define POINT_CONTENTS (*g_engfuncs.pfnPointContents) -#define CRC32_INIT (*g_engfuncs.pfnCRC32_Init) -#define CRC32_PROCESS_BUFFER (*g_engfuncs.pfnCRC32_ProcessBuffer) -#define CRC32_PROCESS_BYTE (*g_engfuncs.pfnCRC32_ProcessByte) -#define CRC32_FINAL (*g_engfuncs.pfnCRC32_Final) -#define RANDOM_LONG (*g_engfuncs.pfnRandomLong) -#define RANDOM_FLOAT (*g_engfuncs.pfnRandomFloat) -#define ADD_SERVER_COMMAND (*g_engfuncs.pfnAddServerCommand) -#define SET_CLIENT_LISTENING (*g_engfuncs.pfnVoice_SetClientListening) -#define GETPLAYERAUTHID (*g_engfuncs.pfnGetPlayerAuthId) -#define GET_FILE_SIZE (*g_engfuncs.pfnGetFileSize) -#define GET_APPROX_WAVE_PLAY_LEN (*g_engfuncs.pfnGetApproxWavePlayLen) -#define IS_CAREER_MATCH (*g_engfuncs.pfnIsCareerMatch) -#define GET_LOCALIZED_STRING_LENGTH (*g_engfuncs.pfnGetLocalizedStringLength) +// The actual engine callbacks +#define GETPLAYERUSERID (*g_engfuncs.pfnGetPlayerUserId) +#define PRECACHE_MODEL (*g_engfuncs.pfnPrecacheModel) +#define PRECACHE_SOUND (*g_engfuncs.pfnPrecacheSound) +#define PRECACHE_GENERIC (*g_engfuncs.pfnPrecacheGeneric) +#define SET_MODEL (*g_engfuncs.pfnSetModel) +#define MODEL_INDEX (*g_engfuncs.pfnModelIndex) +#define MODEL_FRAMES (*g_engfuncs.pfnModelFrames) +#define SET_SIZE (*g_engfuncs.pfnSetSize) +#define CHANGE_LEVEL (*g_engfuncs.pfnChangeLevel) +#define GET_SPAWN_PARMS (*g_engfuncs.pfnGetSpawnParms) +#define SAVE_SPAWN_PARMS (*g_engfuncs.pfnSaveSpawnParms) +#define VEC_TO_YAW (*g_engfuncs.pfnVecToYaw) +#define VEC_TO_ANGLES (*g_engfuncs.pfnVecToAngles) +#define MOVE_TO_ORIGIN (*g_engfuncs.pfnMoveToOrigin) +#define oldCHANGE_YAW (*g_engfuncs.pfnChangeYaw) +#define CHANGE_PITCH (*g_engfuncs.pfnChangePitch) +#define MAKE_VECTORS (*g_engfuncs.pfnMakeVectors) +#define CREATE_ENTITY (*g_engfuncs.pfnCreateEntity) +#define REMOVE_ENTITY (*g_engfuncs.pfnRemoveEntity) +#define CREATE_NAMED_ENTITY (*g_engfuncs.pfnCreateNamedEntity) +#define MAKE_STATIC (*g_engfuncs.pfnMakeStatic) +#define ENT_IS_ON_FLOOR (*g_engfuncs.pfnEntIsOnFloor) +#define DROP_TO_FLOOR (*g_engfuncs.pfnDropToFloor) +#define WALK_MOVE (*g_engfuncs.pfnWalkMove) +#define SET_ORIGIN (*g_engfuncs.pfnSetOrigin) +#define EMIT_SOUND_DYN2 (*g_engfuncs.pfnEmitSound) +#define BUILD_SOUND_MSG (*g_engfuncs.pfnBuildSoundMsg) +#define TRACE_LINE (*g_engfuncs.pfnTraceLine) +#define TRACE_TOSS (*g_engfuncs.pfnTraceToss) +#define TRACE_MONSTER_HULL (*g_engfuncs.pfnTraceMonsterHull) +#define TRACE_HULL (*g_engfuncs.pfnTraceHull) +#define TRACE_MODEL (*g_engfuncs.pfnTraceModel) +#define GET_AIM_VECTOR (*g_engfuncs.pfnGetAimVector) +#define SERVER_COMMAND (*g_engfuncs.pfnServerCommand) +#define SERVER_EXECUTE (*g_engfuncs.pfnServerExecute) +#define CLIENT_COMMAND (*g_engfuncs.pfnClientCommand) +#define PARTICLE_EFFECT (*g_engfuncs.pfnParticleEffect) +#define LIGHT_STYLE (*g_engfuncs.pfnLightStyle) +#define DECAL_INDEX (*g_engfuncs.pfnDecalIndex) +#define POINT_CONTENTS (*g_engfuncs.pfnPointContents) +#define CRC32_INIT (*g_engfuncs.pfnCRC32_Init) +#define CRC32_PROCESS_BUFFER (*g_engfuncs.pfnCRC32_ProcessBuffer) +#define CRC32_PROCESS_BYTE (*g_engfuncs.pfnCRC32_ProcessByte) +#define CRC32_FINAL (*g_engfuncs.pfnCRC32_Final) +#define RANDOM_LONG (*g_engfuncs.pfnRandomLong) +#define RANDOM_FLOAT (*g_engfuncs.pfnRandomFloat) +#define ADD_SERVER_COMMAND (*g_engfuncs.pfnAddServerCommand) +#define SET_CLIENT_LISTENING (*g_engfuncs.pfnVoice_SetClientListening) +#define GETPLAYERAUTHID (*g_engfuncs.pfnGetPlayerAuthId) +#define GET_FILE_SIZE (*g_engfuncs.pfnGetFileSize) +#define GET_APPROX_WAVE_PLAY_LEN (*g_engfuncs.pfnGetApproxWavePlayLen) +#define IS_CAREER_MATCH (*g_engfuncs.pfnIsCareerMatch) +#define GET_LOCALIZED_STRING_LENGTH (*g_engfuncs.pfnGetLocalizedStringLength) #define REGISTER_TUTOR_MESSAGE_SHOWN (*g_engfuncs.pfnRegisterTutorMessageShown) #define GET_TIMES_TUTOR_MESSAGE_SHOWN (*g_engfuncs.pfnGetTimesTutorMessageShown) -#define ENG_CHECK_PARM (*g_engfuncs.pfnEngCheckParm) +#define ENG_CHECK_PARM (*g_engfuncs.pfnEngCheckParm) -inline void MESSAGE_BEGIN(int msg_dest, int msg_type, const float *pOrigin = NULL, edict_t *ed = NULL) +inline void MESSAGE_BEGIN(int msg_dest, int msg_type, const float *pOrigin = nullptr, edict_t *ed = nullptr) { - (*g_engfuncs.pfnMessageBegin)(msg_dest,msg_type,pOrigin,ed); + (*g_engfuncs.pfnMessageBegin)(msg_dest, msg_type, pOrigin, ed); } -inline void *GET_PRIVATE(edict_t *pent) +template +inline T *GET_PRIVATE(edict_t *pEdict) { - if (pent) - return pent->pvPrivateData; - return NULL; + if (pEdict) + { + return static_cast(pEdict->pvPrivateData); + } + + return nullptr; } -#define MESSAGE_END (*g_engfuncs.pfnMessageEnd) -#define WRITE_BYTE (*g_engfuncs.pfnWriteByte) -#define WRITE_CHAR (*g_engfuncs.pfnWriteChar) -#define WRITE_SHORT (*g_engfuncs.pfnWriteShort) -#define WRITE_LONG (*g_engfuncs.pfnWriteLong) -#define WRITE_ANGLE (*g_engfuncs.pfnWriteAngle) -#define WRITE_COORD (*g_engfuncs.pfnWriteCoord) -#define WRITE_STRING (*g_engfuncs.pfnWriteString) -#define WRITE_ENTITY (*g_engfuncs.pfnWriteEntity) -#define CVAR_REGISTER (*g_engfuncs.pfnCVarRegister) -#define CVAR_GET_FLOAT (*g_engfuncs.pfnCVarGetFloat) -#define CVAR_GET_STRING (*g_engfuncs.pfnCVarGetString) -#define CVAR_SET_FLOAT (*g_engfuncs.pfnCVarSetFloat) -#define CVAR_SET_STRING (*g_engfuncs.pfnCVarSetString) -#define CVAR_GET_POINTER (*g_engfuncs.pfnCVarGetPointer) -#define ALERT (*g_engfuncs.pfnAlertMessage) -#define ENGINE_FPRINTF (*g_engfuncs.pfnEngineFprintf) -#define ALLOC_PRIVATE (*g_engfuncs.pfnPvAllocEntPrivateData) -#define FREE_PRIVATE (*g_engfuncs.pfnFreeEntPrivateData) -//#define STRING (*g_engfuncs.pfnSzFromIndex) -#define ALLOC_STRING (*g_engfuncs.pfnAllocString) +#define MESSAGE_END (*g_engfuncs.pfnMessageEnd) +#define WRITE_BYTE (*g_engfuncs.pfnWriteByte) +#define WRITE_CHAR (*g_engfuncs.pfnWriteChar) +#define WRITE_SHORT (*g_engfuncs.pfnWriteShort) +#define WRITE_LONG (*g_engfuncs.pfnWriteLong) +#define WRITE_ANGLE (*g_engfuncs.pfnWriteAngle) +#define WRITE_COORD (*g_engfuncs.pfnWriteCoord) +#define WRITE_STRING (*g_engfuncs.pfnWriteString) +#define WRITE_ENTITY (*g_engfuncs.pfnWriteEntity) +#define CVAR_REGISTER (*g_engfuncs.pfnCVarRegister) +#define CVAR_GET_FLOAT (*g_engfuncs.pfnCVarGetFloat) +#define CVAR_GET_STRING (*g_engfuncs.pfnCVarGetString) +#define CVAR_SET_FLOAT (*g_engfuncs.pfnCVarSetFloat) +#define CVAR_SET_STRING (*g_engfuncs.pfnCVarSetString) +#define CVAR_GET_POINTER (*g_engfuncs.pfnCVarGetPointer) +#define ALERT (*g_engfuncs.pfnAlertMessage) +#define ENGINE_FPRINTF (*g_engfuncs.pfnEngineFprintf) +#define ALLOC_PRIVATE (*g_engfuncs.pfnPvAllocEntPrivateData) +#define FREE_PRIVATE (*g_engfuncs.pfnFreeEntPrivateData) +//#define STRING (*g_engfuncs.pfnSzFromIndex) +#define ALLOC_STRING (*g_engfuncs.pfnAllocString) #define FIND_ENTITY_BY_STRING (*g_engfuncs.pfnFindEntityByString) -#define GETENTITYILLUM (*g_engfuncs.pfnGetEntityIllum) +#define GETENTITYILLUM (*g_engfuncs.pfnGetEntityIllum) #define FIND_ENTITY_IN_SPHERE (*g_engfuncs.pfnFindEntityInSphere) -#define FIND_CLIENT_IN_PVS (*g_engfuncs.pfnFindClientInPVS) -#define FIND_ENTITY_IN_PVS (*g_engfuncs.pfnEntitiesInPVS) -#define EMIT_AMBIENT_SOUND (*g_engfuncs.pfnEmitAmbientSound) -#define GET_MODEL_PTR (*g_engfuncs.pfnGetModelPtr) -#define REG_USER_MSG (*g_engfuncs.pfnRegUserMsg) -#define GET_BONE_POSITION (*g_engfuncs.pfnGetBonePosition) -#define FUNCTION_FROM_NAME (*g_engfuncs.pfnFunctionFromName) -#define NAME_FOR_FUNCTION (*g_engfuncs.pfnNameForFunction) -#define TRACE_TEXTURE (*g_engfuncs.pfnTraceTexture) -#define CLIENT_PRINTF (*g_engfuncs.pfnClientPrintf) -#define SERVER_PRINT (*g_engfuncs.pfnServerPrint) -#define CMD_ARGS (*g_engfuncs.pfnCmd_Args) -#define CMD_ARGC (*g_engfuncs.pfnCmd_Argc) -#define CMD_ARGV (*g_engfuncs.pfnCmd_Argv) -#define GET_ATTACHMENT (*g_engfuncs.pfnGetAttachment) -#define SET_VIEW (*g_engfuncs.pfnSetView) -#define SET_CROSSHAIRANGLE (*g_engfuncs.pfnCrosshairAngle) -#define LOAD_FILE_FOR_ME (*g_engfuncs.pfnLoadFileForMe) -#define FREE_FILE (*g_engfuncs.pfnFreeFile) -#define END_SECTION (*g_engfuncs.pfnEndSection) -#define COMPARE_FILE_TIME (*g_engfuncs.pfnCompareFileTime) -#define GET_GAME_DIR (*g_engfuncs.pfnGetGameDir) -#define SET_CLIENT_MAXSPEED (*g_engfuncs.pfnSetClientMaxspeed) -#define CREATE_FAKE_CLIENT (*g_engfuncs.pfnCreateFakeClient) -#define PLAYER_RUN_MOVE (*g_engfuncs.pfnRunPlayerMove) -#define NUMBER_OF_ENTITIES (*g_engfuncs.pfnNumberOfEntities) -#define GET_INFO_BUFFER (*g_engfuncs.pfnGetInfoKeyBuffer) -#define GET_KEY_VALUE (*g_engfuncs.pfnInfoKeyValue) -#define SET_KEY_VALUE (*g_engfuncs.pfnSetKeyValue) +#define FIND_CLIENT_IN_PVS (*g_engfuncs.pfnFindClientInPVS) +#define FIND_ENTITY_IN_PVS (*g_engfuncs.pfnEntitiesInPVS) +#define EMIT_AMBIENT_SOUND (*g_engfuncs.pfnEmitAmbientSound) +#define GET_MODEL_PTR (*g_engfuncs.pfnGetModelPtr) +#define REG_USER_MSG (*g_engfuncs.pfnRegUserMsg) +#define GET_BONE_POSITION (*g_engfuncs.pfnGetBonePosition) +#define FUNCTION_FROM_NAME (*g_engfuncs.pfnFunctionFromName) +#define NAME_FOR_FUNCTION (*g_engfuncs.pfnNameForFunction) +#define TRACE_TEXTURE (*g_engfuncs.pfnTraceTexture) +#define CLIENT_PRINTF (*g_engfuncs.pfnClientPrintf) +#define SERVER_PRINT (*g_engfuncs.pfnServerPrint) +#define CMD_ARGS (*g_engfuncs.pfnCmd_Args) +#define CMD_ARGC (*g_engfuncs.pfnCmd_Argc) +#define CMD_ARGV (*g_engfuncs.pfnCmd_Argv) +#define GET_ATTACHMENT (*g_engfuncs.pfnGetAttachment) +#define SET_VIEW (*g_engfuncs.pfnSetView) +#define SET_CROSSHAIRANGLE (*g_engfuncs.pfnCrosshairAngle) +#define LOAD_FILE_FOR_ME (*g_engfuncs.pfnLoadFileForMe) +#define FREE_FILE (*g_engfuncs.pfnFreeFile) +#define END_SECTION (*g_engfuncs.pfnEndSection) +#define COMPARE_FILE_TIME (*g_engfuncs.pfnCompareFileTime) +#define GET_GAME_DIR (*g_engfuncs.pfnGetGameDir) +#define SET_CLIENT_MAXSPEED (*g_engfuncs.pfnSetClientMaxspeed) +#define CREATE_FAKE_CLIENT (*g_engfuncs.pfnCreateFakeClient) +#define PLAYER_RUN_MOVE (*g_engfuncs.pfnRunPlayerMove) +#define NUMBER_OF_ENTITIES (*g_engfuncs.pfnNumberOfEntities) +#define GET_INFO_BUFFER (*g_engfuncs.pfnGetInfoKeyBuffer) +#define GET_KEY_VALUE (*g_engfuncs.pfnInfoKeyValue) +#define SET_KEY_VALUE (*g_engfuncs.pfnSetKeyValue) #define SET_CLIENT_KEY_VALUE (*g_engfuncs.pfnSetClientKeyValue) -#define IS_MAP_VALID (*g_engfuncs.pfnIsMapValid) -#define STATIC_DECAL (*g_engfuncs.pfnStaticDecal) -#define IS_DEDICATED_SERVER (*g_engfuncs.pfnIsDedicatedServer) -#define PRECACHE_EVENT (*g_engfuncs.pfnPrecacheEvent) -#define PLAYBACK_EVENT_FULL (*g_engfuncs.pfnPlaybackEvent) -#define ENGINE_SET_PVS (*g_engfuncs.pfnSetFatPVS) -#define ENGINE_SET_PAS (*g_engfuncs.pfnSetFatPAS) +#define IS_MAP_VALID (*g_engfuncs.pfnIsMapValid) +#define STATIC_DECAL (*g_engfuncs.pfnStaticDecal) +#define IS_DEDICATED_SERVER (*g_engfuncs.pfnIsDedicatedServer) +#define PRECACHE_EVENT (*g_engfuncs.pfnPrecacheEvent) +#define PLAYBACK_EVENT_FULL (*g_engfuncs.pfnPlaybackEvent) +#define ENGINE_SET_PVS (*g_engfuncs.pfnSetFatPVS) +#define ENGINE_SET_PAS (*g_engfuncs.pfnSetFatPAS) #define ENGINE_CHECK_VISIBILITY (*g_engfuncs.pfnCheckVisibility) -#define DELTA_SET (*g_engfuncs.pfnDeltaSetField) -#define DELTA_UNSET (*g_engfuncs.pfnDeltaUnsetField) -#define DELTA_ADDENCODER (*g_engfuncs.pfnDeltaAddEncoder) +#define DELTA_SET (*g_engfuncs.pfnDeltaSetField) +#define DELTA_UNSET (*g_engfuncs.pfnDeltaUnsetField) +#define DELTA_ADDENCODER (*g_engfuncs.pfnDeltaAddEncoder) #define ENGINE_CURRENT_PLAYER (*g_engfuncs.pfnGetCurrentPlayer) -#define ENGINE_CANSKIP (*g_engfuncs.pfnCanSkipPlayer) -#define DELTA_FINDFIELD (*g_engfuncs.pfnDeltaFindField) -#define DELTA_SETBYINDEX (*g_engfuncs.pfnDeltaSetFieldByIndex) -#define DELTA_UNSETBYINDEX (*g_engfuncs.pfnDeltaUnsetFieldByIndex) -#define REMOVE_KEY_VALUE (*g_engfuncs.pfnInfo_RemoveKey) +#define ENGINE_CANSKIP (*g_engfuncs.pfnCanSkipPlayer) +#define DELTA_FINDFIELD (*g_engfuncs.pfnDeltaFindField) +#define DELTA_SETBYINDEX (*g_engfuncs.pfnDeltaSetFieldByIndex) +#define DELTA_UNSETBYINDEX (*g_engfuncs.pfnDeltaUnsetFieldByIndex) +#define REMOVE_KEY_VALUE (*g_engfuncs.pfnInfo_RemoveKey) #define SET_PHYSICS_KEY_VALUE (*g_engfuncs.pfnSetPhysicsKeyValue) -#define ENGINE_GETPHYSINFO (*g_engfuncs.pfnGetPhysicsInfoString) -#define ENGINE_SETGROUPMASK (*g_engfuncs.pfnSetGroupMask) +#define ENGINE_GETPHYSINFO (*g_engfuncs.pfnGetPhysicsInfoString) +#define ENGINE_SETGROUPMASK (*g_engfuncs.pfnSetGroupMask) #define ENGINE_INSTANCE_BASELINE (*g_engfuncs.pfnCreateInstancedBaseline) #define ENGINE_FORCE_UNMODIFIED (*g_engfuncs.pfnForceUnmodified) -#define PLAYER_CNX_STATS (*g_engfuncs.pfnGetPlayerStats) - -#endif // ENGINECALLBACK_H +#define PLAYER_CNX_STATS (*g_engfuncs.pfnGetPlayerStats) diff --git a/regamedll/dlls/explode.cpp b/regamedll/dlls/explode.cpp index 23360c27..4d07199c 100644 --- a/regamedll/dlls/explode.cpp +++ b/regamedll/dlls/explode.cpp @@ -78,7 +78,9 @@ void CEnvExplosion::KeyValue(KeyValueData *pkvd) pkvd->fHandled = TRUE; } else + { CBaseEntity::KeyValue(pkvd); + } } void CEnvExplosion::Spawn() @@ -173,7 +175,7 @@ void CEnvExplosion::Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE for (int i = 0; i < sparkCount; ++i) { - Create("spark_shower", pev->origin, tr.vecPlaneNormal, NULL); + Create("spark_shower", pev->origin, tr.vecPlaneNormal, nullptr); } } } @@ -220,5 +222,5 @@ void ExplosionCreate(const Vector ¢er, Vector &angles, edict_t *pOwner, int } pExplosion->Spawn(); - pExplosion->Use(NULL, NULL, USE_TOGGLE, 0); + pExplosion->Use(nullptr, nullptr, USE_TOGGLE, 0); } diff --git a/regamedll/dlls/explode.h b/regamedll/dlls/explode.h index 82222a44..9b32d8d8 100644 --- a/regamedll/dlls/explode.h +++ b/regamedll/dlls/explode.h @@ -26,18 +26,7 @@ * */ -#ifndef EXPLODE_H -#define EXPLODE_H -#ifdef _WIN32 #pragma once -#endif - -#define SF_ENVEXPLOSION_NODAMAGE (1<<0) // when set, ENV_EXPLOSION will not actually inflict damage -#define SF_ENVEXPLOSION_REPEATABLE (1<<1) // can this entity be refired? -#define SF_ENVEXPLOSION_NOFIREBALL (1<<2) // don't draw the fireball -#define SF_ENVEXPLOSION_NOSMOKE (1<<3) // don't draw the smoke -#define SF_ENVEXPLOSION_NODECAL (1<<4) // don't make a scorch mark -#define SF_ENVEXPLOSION_NOSPARKS (1<<5) // don't make a scorch mark class CShower: public CBaseEntity { @@ -48,6 +37,13 @@ public: virtual void Touch(CBaseEntity *pOther); }; +#define SF_ENVEXPLOSION_NODAMAGE BIT(0) // when set, ENV_EXPLOSION will not actually inflict damage +#define SF_ENVEXPLOSION_REPEATABLE BIT(1) // can this entity be refired? +#define SF_ENVEXPLOSION_NOFIREBALL BIT(2) // don't draw the fireball +#define SF_ENVEXPLOSION_NOSMOKE BIT(3) // don't draw the smoke +#define SF_ENVEXPLOSION_NODECAL BIT(4) // don't make a scorch mark +#define SF_ENVEXPLOSION_NOSPARKS BIT(5) // don't make a scorch mark + class CEnvExplosion: public CBaseMonster { public: @@ -68,5 +64,3 @@ public: }; void ExplosionCreate(const Vector ¢er, Vector &angles, edict_t *pOwner, int magnitude, BOOL doDamage); - -#endif // EXPLODE_H diff --git a/regamedll/dlls/extdef.h b/regamedll/dlls/extdef.h index 1ba12d7a..ed204fe5 100644 --- a/regamedll/dlls/extdef.h +++ b/regamedll/dlls/extdef.h @@ -25,8 +25,11 @@ * version. * */ + #pragma once +#include "regamedll_const.h" + #undef DLLEXPORT #ifdef _WIN32 // Attributes to specify an "exported" function, visible from outside the @@ -51,6 +54,8 @@ #define unlikely(x) __builtin_expect(!!(x), 0) #endif +const int MAX_MAPNAME_LENGHT = 32; + // Simplified macro for declaring/defining exported DLL functions. They // need to be 'extern "C"' so that the C++ compiler enforces parameter // type-matching, rather than considering routines with mis-matched @@ -105,7 +110,6 @@ typedef struct hudtextparms_s } hudtextparms_t; enum USE_TYPE { USE_OFF, USE_ON, USE_SET, USE_TOGGLE }; -enum TRAIN_CODE { TRAIN_SAFE, TRAIN_BLOCKING, TRAIN_FOLLOWING }; enum IGNORE_MONSTERS { ignore_monsters = 1, dont_ignore_monsters = 0, missile = 2 }; enum IGNORE_GLASS { ignore_glass = 1, dont_ignore_glass = 0 }; enum { point_hull = 0, human_hull = 1, large_hull = 2, head_hull = 3 }; diff --git a/regamedll/dlls/extdll.h b/regamedll/dlls/extdll.h index 0ffbe684..4eb56473 100644 --- a/regamedll/dlls/extdll.h +++ b/regamedll/dlls/extdll.h @@ -36,7 +36,7 @@ #include "archtypes.h" #include "maintypes.h" -#include "regamedll_common.h" +#include "strtools.h" #ifdef _WIN32 #define WIN32_LEAN_AND_MEAN @@ -61,15 +61,17 @@ // Header file containing definition of globalvars_t and entvars_t typedef unsigned int func_t; -typedef unsigned int string_t; // from engine's pr_comp.h; typedef float vec_t; // needed before including progdefs.h // Vector class #include "vector.h" // Defining it as a (bogus) struct helps enforce type-checking #define vec3_t Vector -// Shared engine/DLL constants +// QString class +#include "qstring.h" + +// Shared engine/DLL constants #include "const.h" #include "edict.h" diff --git a/regamedll/dlls/func_break.cpp b/regamedll/dlls/func_break.cpp index 6a3a820d..b14f0c4a 100644 --- a/regamedll/dlls/func_break.cpp +++ b/regamedll/dlls/func_break.cpp @@ -10,7 +10,7 @@ // be spawned, and still remain fairly flexible const char *CBreakable::pSpawnObjects[] = { - NULL, + nullptr, "item_battery", "item_healthkit", "weapon_9mmhandgun", @@ -126,7 +126,6 @@ void CBreakable::KeyValue(KeyValueData *pkvd) Materials type = (Materials)Q_atoi(pkvd->szValue); // 0:glass, 1:wood, 2:metal, 3:flesh etc - if (type < 0 || type >= matLastMaterial) m_Material = matWood; else @@ -164,9 +163,13 @@ void CBreakable::KeyValue(KeyValueData *pkvd) pkvd->fHandled = TRUE; } else if (FStrEq(pkvd->szKeyName, "lip")) + { pkvd->fHandled = TRUE; + } else + { CBaseDelay::KeyValue(pkvd); + } } LINK_ENTITY_TO_CLASS(func_breakable, CBreakable, CCSBreakable) @@ -318,7 +321,7 @@ void CBreakable::MaterialSoundRandom(edict_t *pEdict, Materials soundMaterial, f void CBreakable::Precache() { - const char *pGibName = NULL; + const char *pGibName = nullptr; switch (m_Material) { @@ -658,7 +661,7 @@ void CBreakable::Die() { Vector vecSpot; // shard origin Vector vecVelocity; // shard velocity - CBaseEntity *pEntity = NULL; + CBaseEntity *pEntity = nullptr; char cFlag = 0; int pitch; float fvol; @@ -798,11 +801,11 @@ void CBreakable::Die() WRITE_COORD(vecVelocity.x); // velocity WRITE_COORD(vecVelocity.y); WRITE_COORD(vecVelocity.z); - WRITE_BYTE(10); // randomization + WRITE_BYTE(10); // randomization WRITE_SHORT(m_idShard); // model id# - WRITE_BYTE(0); // # of shards, let client decide - WRITE_BYTE(25); // duration, 2.5 seconds - WRITE_BYTE(cFlag); // flags + WRITE_BYTE(0); // # of shards, let client decide + WRITE_BYTE(25); // duration, 2.5 seconds + WRITE_BYTE(cFlag); // flags MESSAGE_END(); float size = pev->size.x; @@ -824,7 +827,7 @@ void CBreakable::Die() for (int i = 0; i < count; ++i) { pList[i]->pev->flags &= ~FL_ONGROUND; - pList[i]->pev->groundentity = NULL; + pList[i]->pev->groundentity = nullptr; } pev->solid = SOLID_NOT; @@ -968,7 +971,9 @@ void CPushable::KeyValue(KeyValueData *pkvd) pkvd->fHandled = TRUE; } else + { CBreakable::KeyValue(pkvd); + } } // Pull the func_pushable diff --git a/regamedll/dlls/func_break.h b/regamedll/dlls/func_break.h index f0c73158..259836ce 100644 --- a/regamedll/dlls/func_break.h +++ b/regamedll/dlls/func_break.h @@ -26,32 +26,15 @@ * */ -#ifndef FUNC_BREAK_H -#define FUNC_BREAK_H -#ifdef _WIN32 #pragma once -#endif -// this many shards spawned when breakable objects break; -#define NUM_SHARDS 6 - -// func breakable -#define SF_BREAK_TRIGGER_ONLY 1 // may only be broken by trigger -#define SF_BREAK_TOUCH 2 // can be 'crashed through' by running player (plate glass) -#define SF_BREAK_PRESSURE 4 // can be broken by a player standing on it -#define SF_BREAK_CROWBAR 256 // instant break if hit with crowbar - -// func_pushable (it's also func_breakable, so don't collide with those flags) -#define SF_PUSH_BREAKABLE 128 - -typedef enum +enum Explosions { expRandom = 0, expDirected, +}; -} Explosions; - -typedef enum +enum Materials { matGlass = 0, matWood, @@ -64,8 +47,16 @@ typedef enum matRocks, matNone, matLastMaterial, +}; -} Materials; +// this many shards spawned when breakable objects break +#define NUM_SHARDS 6 // this many shards spawned when breakable objects break + +// func breakable +#define SF_BREAK_TRIGGER_ONLY BIT(0) // may only be broken by trigger +#define SF_BREAK_TOUCH BIT(1) // can be 'crashed through' by running player (plate glass) +#define SF_BREAK_PRESSURE BIT(2) // can be broken by a player standing on it +#define SF_BREAK_CROWBAR BIT(8) // instant break if hit with crowbar class CBreakable: public CBaseDelay { @@ -125,6 +116,8 @@ public: float m_flHealth; }; +#define SF_PUSH_BREAKABLE BIT(7) // func_pushable (it's also func_breakable, so don't collide with those flags) + class CPushable: public CBreakable { public: @@ -163,5 +156,3 @@ public: float m_maxSpeed; float m_soundTime; }; - -#endif // FUNC_BREAK_H diff --git a/regamedll/dlls/func_tank.cpp b/regamedll/dlls/func_tank.cpp index b512eb58..2860d3af 100644 --- a/regamedll/dlls/func_tank.cpp +++ b/regamedll/dlls/func_tank.cpp @@ -48,11 +48,11 @@ TYPEDESCRIPTION CFuncTankControls::m_SaveData[] = Vector gTankSpread[] = { - Vector(0, 0, 0), // perfect + Vector(0, 0, 0), // perfect Vector(0.025, 0.025, 0.025), // small cone - Vector(0.05, 0.05, 0.05), // medium cone - Vector(0.1, 0.1, 0.1), // large cone - Vector(0.25, 0.25, 0.25), // extra-large cone + Vector(0.05, 0.05, 0.05), // medium cone + Vector(0.1, 0.1, 0.1), // large cone + Vector(0.25, 0.25, 0.25), // extra-large cone }; #endif // HOOK_GAMEDLL @@ -216,7 +216,9 @@ void CFuncTank::KeyValue(KeyValueData *pkvd) pkvd->fHandled = TRUE; } else + { CBaseEntity::KeyValue(pkvd); + } } BOOL CFuncTank::OnControls(entvars_t *pevTest) @@ -225,7 +227,6 @@ BOOL CFuncTank::OnControls(entvars_t *pevTest) return FALSE; Vector offset = pevTest->origin - pev->origin; - if ((m_vecControllerUsePos - pevTest->origin).Length() < 30.0f) { return TRUE; @@ -236,7 +237,7 @@ BOOL CFuncTank::OnControls(entvars_t *pevTest) BOOL CFuncTank::StartControl(CBasePlayer *pController) { - if (m_pController != NULL) + if (m_pController) return FALSE; // Team only or disabled? @@ -252,7 +253,7 @@ BOOL CFuncTank::StartControl(CBasePlayer *pController) m_pController = pController; - if (m_pController->m_pActiveItem != NULL) + if (m_pController->m_pActiveItem) { m_pController->m_pActiveItem->Holster(); m_pController->pev->weaponmodel = 0; @@ -276,7 +277,7 @@ void CFuncTank::StopControl() if (!m_pController) return; - if (m_pController->m_pActiveItem != NULL) + if (m_pController->m_pActiveItem) { m_pController->m_pActiveItem->Deploy(); @@ -291,7 +292,7 @@ void CFuncTank::StopControl() m_pController->m_iHideHUD &= ~HIDEHUD_WEAPONS; pev->nextthink = 0; - m_pController = NULL; + m_pController = nullptr; if (IsActive()) { @@ -301,7 +302,7 @@ void CFuncTank::StopControl() void CFuncTank::ControllerPostFrame() { - assert(m_pController != NULL); + assert(m_pController != nullptr); if (gpGlobals->time < m_flNextAttack) return; @@ -309,7 +310,7 @@ void CFuncTank::ControllerPostFrame() if (m_pController->pev->button & IN_ATTACK) { Vector vecForward; - UTIL_MakeVectorsPrivate(pev->angles, vecForward, NULL, NULL); + UTIL_MakeVectorsPrivate(pev->angles, vecForward, nullptr, nullptr); m_fireLast = gpGlobals->time - (1.0f / m_fireRate) - 0.01f; Fire(BarrelPosition(), vecForward, m_pController->pev); @@ -390,10 +391,10 @@ void CFuncTank::TrackTarget() edict_t *pPlayer = FIND_CLIENT_IN_PVS(edict()); bool updateTime = false, lineOfSight = false; Vector angles, direction, targetPosition, barrelEnd; - edict_t *pTarget = NULL; + edict_t *pTarget = nullptr; // Get a position to aim for - if (m_pController != NULL) + if (m_pController) { // Tanks attempt to mirror the player's angles angles = m_pController->pev->v_angle; @@ -520,7 +521,7 @@ void CFuncTank::TrackTarget() pev->avelocity.x = -m_pitchRate; } - if (m_pController != NULL) + if (m_pController) { return; } @@ -529,7 +530,7 @@ void CFuncTank::TrackTarget() { bool fire = false; Vector forward; - UTIL_MakeVectorsPrivate(pev->angles, forward, NULL, NULL); + UTIL_MakeVectorsPrivate(pev->angles, forward, nullptr, nullptr); if (pev->spawnflags & SF_TANK_LINEOFSIGHT) { @@ -603,7 +604,7 @@ void CFuncTank::Fire(const Vector &barrelEnd, const Vector &forward, entvars_t * pSprite->SetScale(m_spriteScale); // Hack Hack, make it stick around for at least 100 ms. - pSprite->pev->nextthink += 0.1; + pSprite->pev->nextthink += 0.1f; } SUB_UseTargets(this, USE_TOGGLE, 0); @@ -667,7 +668,7 @@ void CFuncTankGun::Fire(const Vector &barrelEnd, const Vector &forward, entvars_ if (bulletCount > 0) { - for (int i = 0; i < bulletCount; ++i) + for (int i = 0; i < bulletCount; i++) { switch (m_bulletType) { @@ -690,7 +691,9 @@ void CFuncTankGun::Fire(const Vector &barrelEnd, const Vector &forward, entvars_ } } else + { CFuncTank::Fire(barrelEnd, forward, pevAttacker); + } } LINK_ENTITY_TO_CLASS(func_tanklaser, CFuncTankLaser, CCSFuncTankLaser) @@ -717,17 +720,19 @@ void CFuncTankLaser::KeyValue(KeyValueData *pkvd) pkvd->fHandled = TRUE; } else + { CFuncTank::KeyValue(pkvd); + } } CLaser *CFuncTankLaser::GetLaser() { - if (m_pLaser != NULL) + if (m_pLaser) { return m_pLaser; } - edict_t *pentLaser = FIND_ENTITY_BY_TARGETNAME(NULL, STRING(pev->message)); + edict_t *pentLaser = FIND_ENTITY_BY_TARGETNAME(nullptr, STRING(pev->message)); while (!FNullEnt(pentLaser)) { @@ -746,7 +751,7 @@ CLaser *CFuncTankLaser::GetLaser() void CFuncTankLaser::Think() { - if (m_pLaser != NULL && gpGlobals->time > m_laserTime) + if (m_pLaser && gpGlobals->time > m_laserTime) { m_pLaser->TurnOff(); } @@ -768,7 +773,7 @@ void CFuncTankLaser::Fire(const Vector &barrelEnd, const Vector &forward, entvar if (bulletCount) { - for (i = 0; i < bulletCount; ++i) + for (i = 0; i < bulletCount; i++) { m_pLaser->pev->origin = barrelEnd; TankTrace(barrelEnd, forward, gTankSpread[m_spread], tr); @@ -804,10 +809,9 @@ void CFuncTankRocket::Fire(const Vector &barrelEnd, const Vector &forward, entva if (m_fireLast != 0.0f) { int bulletCount = int((gpGlobals->time - m_fireLast) * m_fireRate); - if (bulletCount > 0) { - for (i = 0; i < bulletCount; ++i) + for (i = 0; i < bulletCount; i++) { CBaseEntity *pRocket = CBaseEntity::Create("rpg_rocket", barrelEnd, pev->angles, edict()); } @@ -816,7 +820,9 @@ void CFuncTankRocket::Fire(const Vector &barrelEnd, const Vector &forward, entva } } else + { CFuncTank::Fire(barrelEnd, forward, pev); + } } LINK_ENTITY_TO_CLASS(func_tankmortar, CFuncTankMortar, CCSFuncTankMortar) @@ -829,7 +835,9 @@ void CFuncTankMortar::KeyValue(KeyValueData *pkvd) pkvd->fHandled = TRUE; } else + { CFuncTank::KeyValue(pkvd); + } } void CFuncTankMortar::Fire(const Vector &barrelEnd, const Vector &forward, entvars_t *pevAttacker) @@ -852,7 +860,9 @@ void CFuncTankMortar::Fire(const Vector &barrelEnd, const Vector &forward, entva } } else + { CFuncTank::Fire(barrelEnd, forward, pev); + } } LINK_ENTITY_TO_CLASS(func_tankcontrols, CFuncTankControls, CCSFuncTankControls) @@ -861,18 +871,18 @@ IMPLEMENT_SAVERESTORE(CFuncTankControls, CBaseEntity) void CFuncTankControls::Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) { // pass the Use command onto the controls - if (m_pTank != NULL) + if (m_pTank) { m_pTank->Use(pActivator, pCaller, useType, value); } // if this fails, most likely means save/restore hasn't worked properly - assert(m_pTank != NULL); + assert(m_pTank != nullptr); } void CFuncTankControls::Think() { - edict_t *pTarget = NULL; + edict_t *pTarget = nullptr; do { diff --git a/regamedll/dlls/func_tank.h b/regamedll/dlls/func_tank.h index 96db109b..0df7ba84 100644 --- a/regamedll/dlls/func_tank.h +++ b/regamedll/dlls/func_tank.h @@ -26,28 +26,25 @@ * */ -#ifndef FUNC_TANK_H -#define FUNC_TANK_H -#ifdef _WIN32 #pragma once -#endif - -#define SF_TANK_ACTIVE 0x0001 -#define SF_TANK_PLAYER 0x0002 -#define SF_TANK_HUMANS 0x0004 -#define SF_TANK_ALIENS 0x0008 -#define SF_TANK_LINEOFSIGHT 0x0010 -#define SF_TANK_CANCONTROL 0x0020 -#define SF_TANK_SOUNDON 0x8000 enum TANKBULLET { TANK_BULLET_NONE = 0, // Custom damage - TANK_BULLET_9MM, // env_laser (duration is 0.5 rate of fire) - TANK_BULLET_MP5, // rockets - TANK_BULLET_12MM, // explosion? + TANK_BULLET_9MM, // env_laser (duration is 0.5 rate of fire) + TANK_BULLET_MP5, // rockets + TANK_BULLET_12MM, // explosion? }; +#define SF_TANK_ACTIVE BIT(0) +#define SF_TANK_PLAYER BIT(1) +#define SF_TANK_HUMANS BIT(2) +#define SF_TANK_ALIENS BIT(3) +#define SF_TANK_LINEOFSIGHT BIT(4) +#define SF_TANK_CANCONTROL BIT(5) + +#define SF_TANK_SOUNDON BIT(15) + class CFuncTank: public CBaseEntity { public: @@ -114,30 +111,30 @@ protected: float m_yawCenter; // "Center" yaw float m_yawRate; // Max turn rate to track targets float m_yawRange; // Range of turning motion (one-sided: 30 is +/- 30 degress from center) - // Zero is full rotation + // Zero is full rotation - float m_yawTolerance; // Tolerance angle + float m_yawTolerance; // Tolerance angle - float m_pitchCenter; // "Center" pitch + float m_pitchCenter; // "Center" pitch float m_pitchRate; // Max turn rate on pitch float m_pitchRange; // Range of pitch motion as above - float m_pitchTolerance; // Tolerance angle + float m_pitchTolerance; // Tolerance angle float m_fireLast; // Last time I fired float m_fireRate; // How many rounds/second - float m_lastSightTime; // Last time I saw target + float m_lastSightTime; // Last time I saw target float m_persist; // Persistence of firing (how long do I shoot when I can't see) float m_minRange; // Minimum range to aim/track float m_maxRange; // Max range to aim/track Vector m_barrelPos; // Length of the freakin barrel - float m_spriteScale; // Scale of any sprites we shoot + float m_spriteScale; // Scale of any sprites we shoot int m_iszSpriteSmoke; int m_iszSpriteFlash; - TANKBULLET m_bulletType; // Bullet type - int m_iBulletDamage; // 0 means use Bullet type's default damage + TANKBULLET m_bulletType;// Bullet type + int m_iBulletDamage; // 0 means use Bullet type's default damage - Vector m_sightOrigin; // Last sight of target + Vector m_sightOrigin; // Last sight of target int m_spread; // firing spread int m_iszMaster; // Master entity (game_team_master or multisource) }; @@ -196,5 +193,3 @@ public: static TYPEDESCRIPTION IMPL(m_SaveData)[1]; CFuncTank *m_pTank; }; - -#endif // FUNC_TANK_H diff --git a/regamedll/dlls/game.cpp b/regamedll/dlls/game.cpp index 34dad1c7..ffb4f165 100644 --- a/regamedll/dlls/game.cpp +++ b/regamedll/dlls/game.cpp @@ -111,8 +111,8 @@ cvar_t max_teamkills = { "mp_max_teamkills", "3", 0, 3.0f, nullptr }; cvar_t fraglimit = { "mp_fraglimit", "0", FCVAR_SERVER, 0.0f, nullptr }; cvar_t round_restart_delay = { "mp_round_restart_delay", "5", FCVAR_SERVER, 0.0f, nullptr }; -cvar_t showtriggers = { "showtriggers", "0", 0, 0.0f, nullptr }; // debug cvar shows triggers - // TODO: Maybe it's better to register in the engine? +cvar_t showtriggers = { "showtriggers", "0", 0, 0.0f, nullptr }; // debug cvar shows triggers + // TODO: Maybe it's better to register in the engine? cvar_t hostagehurtable = { "mp_hostage_hurtable", "1", FCVAR_SERVER, 0.0f, nullptr }; cvar_t roundover = { "mp_roundover", "0", FCVAR_SERVER, 0.0f, nullptr }; diff --git a/regamedll/dlls/game.h b/regamedll/dlls/game.h index 25dccd34..c838be13 100644 --- a/regamedll/dlls/game.h +++ b/regamedll/dlls/game.h @@ -26,23 +26,19 @@ * */ -#ifndef GAME_H -#define GAME_H -#ifdef _WIN32 #pragma once -#endif -#define LOG_ENEMYATTACK 1 -#define LOG_TEAMMATEATTACK 2 +#define LOG_ENEMYATTACK 1 +#define LOG_TEAMMATEATTACK 2 // playerid -#define PLAYERID_MODE_EVERYONE 0 -#define PLAYERID_MODE_TEAMONLY 1 -#define PLAYERID_MODE_OFF 2 +#define PLAYERID_MODE_EVERYONE 0 +#define PLAYERID_MODE_TEAMONLY 1 +#define PLAYERID_MODE_OFF 2 -#define PLAYERID_EVERYONE 0 -#define PLAYERID_TEAMONLY 1 -#define PLAYERID_OFF 2 +#define PLAYERID_EVERYONE 0 +#define PLAYERID_TEAMONLY 1 +#define PLAYERID_OFF 2 extern cvar_t *g_psv_gravity; extern cvar_t *g_psv_aim; @@ -155,5 +151,3 @@ extern cvar_t show_radioicon; #endif void GameDLLInit(); - -#endif // GAME_H diff --git a/regamedll/dlls/gamerules.cpp b/regamedll/dlls/gamerules.cpp index 06e5dc72..e4d4781f 100644 --- a/regamedll/dlls/gamerules.cpp +++ b/regamedll/dlls/gamerules.cpp @@ -5,7 +5,7 @@ */ #ifndef HOOK_GAMEDLL -CGameRules *g_pGameRules = NULL; +CGameRules *g_pGameRules = nullptr; #endif @@ -86,7 +86,7 @@ BOOL CGameRules::CanHavePlayerItem(CBasePlayer *pPlayer, CBasePlayerItem *pWeapo return FALSE; } - if (pPlayer->IsBot() && TheCSBots() != NULL && !TheCSBots()->IsWeaponUseable(pWeapon)) + if (pPlayer->IsBot() && TheCSBots() && !TheCSBots()->IsWeaponUseable(pWeapon)) { return FALSE; } diff --git a/regamedll/dlls/gamerules.h b/regamedll/dlls/gamerules.h index 16eac2a2..e70eee4a 100644 --- a/regamedll/dlls/gamerules.h +++ b/regamedll/dlls/gamerules.h @@ -26,49 +26,44 @@ * */ -#ifndef GAMERULES_H -#define GAMERULES_H -#ifdef _WIN32 #pragma once -#endif #include "game_shared/voice_gamemgr.h" +#include "cmdhandler.h" -#define MAX_RULE_BUFFER 1024 -#define MAX_VOTE_MAPS 100 -#define MAX_VIP_QUEUES 5 +const int MAX_RULE_BUFFER = 1024; +const int MAX_VOTE_MAPS = 100; +const int MAX_VIP_QUEUES = 5; -#define MAX_BOMB_RADIUS 2048 +const int MAX_MOTD_CHUNK = 60; +const int MAX_MOTD_LENGTH = 1536; // (MAX_MOTD_CHUNK * 4) -#define ITEM_RESPAWN_TIME 30 -#define WEAPON_RESPAWN_TIME 20 -#define AMMO_RESPAWN_TIME 20 -#define ROUND_RESPAWN_TIME 20 -#define ROUND_BEGIN_DELAY 5 // delay before beginning new round +const float ITEM_RESPAWN_TIME = 30; +const float WEAPON_RESPAWN_TIME = 20; +const float AMMO_RESPAWN_TIME = 20; +const float ROUND_RESPAWN_TIME = 20; +const float ROUND_BEGIN_DELAY = 5; // delay before beginning new round -// longest the intermission can last, in seconds -#define MAX_INTERMISSION_TIME 120 +const int MAX_INTERMISSION_TIME = 120; // longest the intermission can last, in seconds -// when we are within this close to running out of entities, items +// when we are within this close to running out of entities, items // marked with the ITEM_FLAG_LIMITINWORLD will delay their respawn -#define ENTITY_INTOLERANCE 100 - -#define MAX_MOTD_CHUNK 60 -#define MAX_MOTD_LENGTH 1536 // (MAX_MOTD_CHUNK * 4) +const int ENTITY_INTOLERANCE = 100; // custom enum -#define WINNER_NONE 0 -#define WINNER_DRAW 1 +#define WINNER_NONE 0 +#define WINNER_DRAW 1 enum { - WINSTATUS_CTS = 1, + WINSTATUS_NONE = 0, + WINSTATUS_CTS, WINSTATUS_TERRORISTS, WINSTATUS_DRAW, }; -// custom enum -// used for EndRoundMessage() logged messages +// Custom enum +// Used for EndRoundMessage() logged messages enum ScenarioEventEndRound { ROUND_NONE, @@ -197,13 +192,13 @@ enum // custom enum enum { - SCENARIO_BLOCK_TIME_EXPRIRED = (1 << 0), // flag "a" - SCENARIO_BLOCK_NEED_PLAYERS = (1 << 1), // flag "b" - SCENARIO_BLOCK_VIP_ESCAPE = (1 << 2), // flag "c" - SCENARIO_BLOCK_PRISON_ESCAPE = (1 << 3), // flag "d" - SCENARIO_BLOCK_BOMB = (1 << 4), // flag "e" - SCENARIO_BLOCK_TEAM_EXTERMINATION = (1 << 5), // flag "f" - SCENARIO_BLOCK_HOSTAGE_RESCUE = (1 << 6), // flag "g" + SCENARIO_BLOCK_TIME_EXPRIRED = BIT(0), // flag "a" + SCENARIO_BLOCK_NEED_PLAYERS = BIT(1), // flag "b" + SCENARIO_BLOCK_VIP_ESCAPE = BIT(2), // flag "c" + SCENARIO_BLOCK_PRISON_ESCAPE = BIT(3), // flag "d" + SCENARIO_BLOCK_BOMB = BIT(4), // flag "e" + SCENARIO_BLOCK_TEAM_EXTERMINATION = BIT(5), // flag "f" + SCENARIO_BLOCK_HOSTAGE_RESCUE = BIT(6), // flag "g" }; // Player relationship return codes @@ -519,6 +514,7 @@ public: // Teamplay stuff virtual const char *GetTeamID(CBaseEntity *pEntity) { return ""; } virtual int PlayerRelationship(CBasePlayer *pPlayer, CBaseEntity *pTarget); + virtual void ChangePlayerTeam(CBasePlayer *pPlayer, const char *pTeamName, BOOL bKill, BOOL bGib); virtual BOOL PlayTextureSounds() { return FALSE; } @@ -591,31 +587,33 @@ public: // for internal functions API void OnRoundFreezeEnd(); + bool OnRoundEnd(int winStatus, ScenarioEventEndRound event, float tmDelay); + bool OnRoundEnd_Intercept(int winStatus, ScenarioEventEndRound event, float tmDelay); - bool RoundOver_internal(int winStatus, ScenarioEventEndRound event, float tmDelay); - bool NeededPlayersCheck_internal(int winStatus, ScenarioEventEndRound event, float tmDelay); - bool RestartRoundCheck_internal(int winStatus, ScenarioEventEndRound event, float tmDelay); + bool RoundOver(float tmDelay); + bool NeededPlayersCheck(float tmDelay); + bool RestartRoundCheck(float tmDelay); - bool VIP_Escaped_internal(int winStatus, ScenarioEventEndRound event, float tmDelay); - bool VIP_Died_internal(int winStatus, ScenarioEventEndRound event, float tmDelay); - bool VIP_NotEscaped_internal(int winStatus, ScenarioEventEndRound event, float tmDelay); + bool VIP_Escaped(float tmDelay); + bool VIP_Died(float tmDelay); + bool VIP_NotEscaped(float tmDelay); - bool Prison_Escaped_internal(int winStatus, ScenarioEventEndRound event, float tmDelay); - bool Prison_PreventEscape_internal(int winStatus, ScenarioEventEndRound event, float tmDelay); - bool Prison_NotEscaped_internal(int winStatus, ScenarioEventEndRound event, float tmDelay); - bool Prison_Neutralized_internal(int winStatus, ScenarioEventEndRound event, float tmDelay); + bool Prison_Escaped(float tmDelay); + bool Prison_PreventEscape(float tmDelay); + bool Prison_NotEscaped(float tmDelay); + bool Prison_Neutralized(float tmDelay); - bool Target_Bombed_internal(int winStatus, ScenarioEventEndRound event, float tmDelay); - bool Target_Saved_internal(int winStatus, ScenarioEventEndRound event, float tmDelay); - bool Target_Defused_internal(int winStatus, ScenarioEventEndRound event, float tmDelay); + bool Target_Bombed(float tmDelay); + bool Target_Saved(float tmDelay); + bool Target_Defused(float tmDelay); // Team extermination - bool Round_Cts_internal(int winStatus, ScenarioEventEndRound event, float tmDelay); - bool Round_Ts_internal(int winStatus, ScenarioEventEndRound event, float tmDelay); - bool Round_Draw_internal(int winStatus, ScenarioEventEndRound event, float tmDelay); + bool Round_Cts(float tmDelay); + bool Round_Ts(float tmDelay); + bool Round_Draw(float tmDelay); - bool Hostage_Rescue_internal(int winStatus, ScenarioEventEndRound event, float tmDelay); - bool Hostage_NotRescued_internal(int winStatus, ScenarioEventEndRound event, float tmDelay); + bool Hostage_Rescue(float tmDelay); + bool Hostage_NotRescued(float tmDelay); // Check various conditions to end the map. bool CheckGameOver(); @@ -785,7 +783,7 @@ protected: typedef struct mapcycle_item_s { struct mapcycle_item_s *next; - char mapname[32]; + char mapname[MAX_MAPNAME_LENGHT]; int minplayers; int maxplayers; char rulebuffer[MAX_RULE_BUFFER]; @@ -886,14 +884,7 @@ void Broadcast(const char *sentence); char *GetTeam(int team); void EndRoundMessage(const char *sentence, int event); void DestroyMapCycle(mapcycle_t *cycle); - -char *MP_COM_GetToken(); -char *MP_COM_Parse(char *data); -int MP_COM_TokenWaiting(char *buffer); - int ReloadMapCycleFile(char *filename, mapcycle_t *cycle); int CountPlayers(); void ExtractCommandString(char *s, char *szCommand); int GetMapCount(); - -#endif // GAMERULES_H diff --git a/regamedll/dlls/ggrenade.cpp b/regamedll/dlls/ggrenade.cpp index 761eab0f..8a3bb2d0 100644 --- a/regamedll/dlls/ggrenade.cpp +++ b/regamedll/dlls/ggrenade.cpp @@ -41,7 +41,7 @@ void CGrenade::Explode(TraceResult *pTrace, int bitsDamageType) float flRndSound; // sound randomizer pev->model = iStringNull; // invisible - pev->solid = SOLID_NOT; // intangible + pev->solid = SOLID_NOT; // intangible pev->takedamage = DAMAGE_NO; // Pull out of the wall a bit @@ -63,7 +63,7 @@ void CGrenade::Explode(TraceResult *pTrace, int bitsDamageType) } // can't traceline attack owner if this is set - pev->owner = NULL; + pev->owner = nullptr; RadiusFlash(pev->origin, pev, pevOwner, 4, CLASS_NONE, bitsDamageType); @@ -89,9 +89,10 @@ void CGrenade::Explode(TraceResult *pTrace, int bitsDamageType) if (iContents != CONTENTS_WATER) { int sparkCount = RANDOM_LONG(0, 3); - - for (int i = 0; i < sparkCount; ++i) - Create("spark_shower", pev->origin, pTrace->vecPlaneNormal, NULL); + for (int i = 0; i < sparkCount; i++) + { + Create("spark_shower", pev->origin, pTrace->vecPlaneNormal, nullptr); + } } } @@ -100,7 +101,7 @@ void CGrenade::Explode2(TraceResult *pTrace, int bitsDamageType) float flRndSound; // sound randomizer pev->model = iStringNull; // invisible - pev->solid = SOLID_NOT; // intangible + pev->solid = SOLID_NOT; // intangible pev->takedamage = DAMAGE_NO; UTIL_ScreenShake(pTrace->vecEndPos, 25, 150, 1, 3000); @@ -174,7 +175,7 @@ void CGrenade::Explode2(TraceResult *pTrace, int bitsDamageType) #endif entvars_t *pevOwner = VARS(pev->owner); - pev->owner = NULL; + pev->owner = nullptr; RadiusDamage(pev, pevOwner, CSGameRules()->m_flBombRadius, CLASS_NONE, bitsDamageType); if (CSGameRules()->IsCareer()) @@ -219,19 +220,19 @@ void CGrenade::Explode2(TraceResult *pTrace, int bitsDamageType) if (iContents != CONTENTS_WATER) { int sparkCount = RANDOM_LONG(0, 3); - - for (int i = 0; i < sparkCount; ++i) - Create("spark_shower", pev->origin, pTrace->vecPlaneNormal, NULL); + for (int i = 0; i < sparkCount; i++) + { + Create("spark_shower", pev->origin, pTrace->vecPlaneNormal, nullptr); + } } } void CGrenade::Explode3(TraceResult *pTrace, int bitsDamageType) { float flRndSound; // sound randomizer - //float damage; pev->model = iStringNull; // invisible - pev->solid = SOLID_NOT; // intangible + pev->solid = SOLID_NOT; // intangible pev->takedamage = DAMAGE_NO; if (pTrace->flFraction != 1.0f) @@ -271,7 +272,7 @@ void CGrenade::Explode3(TraceResult *pTrace, int bitsDamageType) TheBots->OnEvent(EVENT_HE_GRENADE_EXPLODED, CBaseEntity::Instance(pev->owner)); } - pev->owner = NULL; + pev->owner = nullptr; RadiusDamage(pev, pevOwner, pev->dmg, CLASS_NONE, bitsDamageType); if (RANDOM_FLOAT(0, 1) < 0.5f) @@ -293,19 +294,20 @@ void CGrenade::Explode3(TraceResult *pTrace, int bitsDamageType) SetThink(&CGrenade::Smoke3_C); pev->velocity = g_vecZero; pev->nextthink = gpGlobals->time + 0.55f; - int sparkCount = RANDOM_LONG(0, 3); - for (int i = 0; i < sparkCount; ++i) - Create("spark_shower", pev->origin, pTrace->vecPlaneNormal, NULL); + int sparkCount = RANDOM_LONG(0, 3); + for (int i = 0; i < sparkCount; i++) + { + Create("spark_shower", pev->origin, pTrace->vecPlaneNormal, nullptr); + } } NOXREF void CGrenade::SG_Explode(TraceResult *pTrace, int bitsDamageType) { float flRndSound; // sound randomizer - //entvars_t *pevOwner; pev->model = iStringNull; // invisible - pev->solid = SOLID_NOT; // intangible + pev->solid = SOLID_NOT; // intangible pev->takedamage = DAMAGE_NO; @@ -321,7 +323,7 @@ NOXREF void CGrenade::SG_Explode(TraceResult *pTrace, int bitsDamageType) #endif // can't traceline attack owner if this is set - pev->owner = NULL; + pev->owner = nullptr; if (RANDOM_FLOAT(0, 1) < 0.5f) UTIL_DecalTrace(pTrace, DECAL_SCORCH1); @@ -346,8 +348,10 @@ NOXREF void CGrenade::SG_Explode(TraceResult *pTrace, int bitsDamageType) { int sparkCount = RANDOM_LONG(0, 3); - for (int i = 0; i < sparkCount; ++i) - Create("spark_shower", pev->origin, pTrace->vecPlaneNormal, NULL); + for (int i = 0; i < sparkCount; i++) + { + Create("spark_shower", pev->origin, pTrace->vecPlaneNormal, nullptr); + } } } @@ -453,7 +457,7 @@ void CGrenade::Smoke() WRITE_COORD(pev->origin.z); WRITE_SHORT(g_sModelIndexSmoke); WRITE_BYTE(25); // scale * 10 - WRITE_BYTE(6); // framerate + WRITE_BYTE(6); // framerate MESSAGE_END(); } @@ -490,14 +494,14 @@ void CGrenade::SG_Smoke() m_angle = (m_angle + 30) % 360; - PLAYBACK_EVENT_FULL(0, NULL, m_usEvent, 0, pev->origin, m_vSmokeDetonate, angle.x, angle.y, flSmokeInterval, 4, m_bLightSmoke, 6); + PLAYBACK_EVENT_FULL(0, nullptr, m_usEvent, 0, pev->origin, m_vSmokeDetonate, angle.x, angle.y, flSmokeInterval, 4, m_bLightSmoke, 6); } if (m_SGSmoke <= 20) { pev->nextthink = gpGlobals->time + 1.0f; SetThink(&CGrenade::SG_Smoke); - ++m_SGSmoke; + m_SGSmoke++; } else { @@ -547,7 +551,7 @@ void CGrenade::SG_Detonate() { TraceResult tr; Vector vecSpot; - edict_t *pentFind = NULL; + edict_t *pentFind = nullptr; vecSpot = pev->origin + Vector(0, 0, 8); @@ -570,7 +574,6 @@ void CGrenade::SG_Detonate() if (pEnt) { float fDistance = (pEnt->pev->origin - pev->origin).Length(); - if (fDistance != 0.0f && fDistance <= 250.0f) { if (gpGlobals->time > pEnt->pev->dmgtime) @@ -582,7 +585,7 @@ void CGrenade::SG_Detonate() } m_bDetonated = true; - PLAYBACK_EVENT_FULL(0, NULL, m_usEvent, 0, pev->origin, (float *)&g_vecZero, 0, 0, 0, 1, m_bLightSmoke, FALSE); + PLAYBACK_EVENT_FULL(0, nullptr, m_usEvent, 0, pev->origin, (float *)&g_vecZero, 0, 0, 0, 1, m_bLightSmoke, FALSE); m_vSmokeDetonate = pev->origin; pev->velocity.x = RANDOM_FLOAT(-175, 175); @@ -681,7 +684,7 @@ void CGrenade::BounceTouch(CBaseEntity *pOther) { // add a bit of static friction pev->velocity = pev->velocity * 0.8f; - pev->sequence = RANDOM_LONG(1, 1); // TODO: what? + pev->sequence = RANDOM_LONG(1, 1); // TODO: what? } else { @@ -698,7 +701,7 @@ void CGrenade::BounceTouch(CBaseEntity *pOther) pev->velocity = g_vecZero; } - ++m_iBounceCount; + m_iBounceCount++; } pev->framerate = pev->velocity.Length() / 200.0f; @@ -771,7 +774,9 @@ void CGrenade::TumbleThink() SetThink(&CGrenade::Detonate); } else + { SetThink(&CGrenade::Detonate3); + } } if (pev->waterlevel != 0) @@ -838,11 +843,11 @@ void CGrenade::Spawn() NOXREF CGrenade *CGrenade::ShootContact(entvars_t *pevOwner, Vector vecStart, Vector vecVelocity) { - CGrenade *pGrenade = GetClassPtr((CGrenade *)NULL); + CGrenade *pGrenade = GetClassPtr((CGrenade *)nullptr); pGrenade->Spawn(); // contact grenades arc lower - pGrenade->pev->gravity = 0.5f; // lower gravity since grenade is aerodynamic and engine doesn't know it. + pGrenade->pev->gravity = 0.5f; // lower gravity since grenade is aerodynamic and engine doesn't know it. UTIL_SetOrigin(pGrenade->pev, vecStart); pGrenade->pev->velocity = vecVelocity; @@ -866,7 +871,7 @@ NOXREF CGrenade *CGrenade::ShootContact(entvars_t *pevOwner, Vector vecStart, Ve CGrenade *CGrenade::ShootTimed2(entvars_t *pevOwner, Vector vecStart, Vector vecVelocity, float time, int iTeam, unsigned short usEvent) { - CGrenade *pGrenade = GetClassPtr((CGrenade *)NULL); + CGrenade *pGrenade = GetClassPtr((CGrenade *)nullptr); pGrenade->Spawn(); UTIL_SetOrigin(pGrenade->pev, vecStart); @@ -900,7 +905,7 @@ CGrenade *CGrenade::ShootTimed2(entvars_t *pevOwner, Vector vecStart, Vector vec CGrenade *CGrenade::ShootTimed(entvars_t *pevOwner, Vector vecStart, Vector vecVelocity, float time) { - CGrenade *pGrenade = GetClassPtr((CGrenade *)NULL); + CGrenade *pGrenade = GetClassPtr((CGrenade *)nullptr); pGrenade->Spawn(); UTIL_SetOrigin(pGrenade->pev, vecStart); @@ -944,6 +949,7 @@ void CGrenade::Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useTy if (!m_bIsC4) return; + // TODO: We must be sure that the activator is a player. CBasePlayer *player = GetClassPtr((CBasePlayer *)pActivator->pev); // For CTs to defuse the c4 @@ -988,7 +994,7 @@ void CGrenade::Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useTy #endif player->m_bIsDefusing = true; - m_pBombDefuser = pActivator; + m_pBombDefuser = static_cast(pActivator); m_bStartDefuse = true; m_flDefuseCountDown = gpGlobals->time + 5.0f; m_fNextDefuse = gpGlobals->time + 0.5f; @@ -1007,10 +1013,10 @@ void CGrenade::Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useTy ClientPrint(player->pev, HUD_PRINTCENTER, "#Defusing_Bomb_Without_Defuse_Kit"); #ifndef REGAMEDLL_FIXES EMIT_SOUND(ENT(player->pev), CHAN_ITEM, "weapons/c4_disarm.wav", VOL_NORM, ATTN_NORM); -#endif +#endif player->m_bIsDefusing = true; - m_pBombDefuser = pActivator; + m_pBombDefuser = static_cast(pActivator); m_bStartDefuse = true; m_flDefuseCountDown = gpGlobals->time + 10.0f; m_fNextDefuse = gpGlobals->time + 0.5f; @@ -1026,7 +1032,7 @@ void CGrenade::Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useTy CGrenade *CGrenade::ShootSatchelCharge(entvars_t *pevOwner, Vector vecStart, Vector vecAngles) { - CGrenade *pGrenade = GetClassPtr((CGrenade *)NULL); + CGrenade *pGrenade = GetClassPtr((CGrenade *)nullptr); pGrenade->pev->movetype = MOVETYPE_TOSS; MAKE_STRING_CLASS("grenade", pGrenade->pev); @@ -1056,7 +1062,7 @@ CGrenade *CGrenade::ShootSatchelCharge(entvars_t *pevOwner, Vector vecStart, Vec pGrenade->m_iCurWave = 0; pGrenade->m_fAttenu = 0; - pGrenade->m_sBeepName = NULL; + pGrenade->m_sBeepName = nullptr; pGrenade->m_flNextBeep = gpGlobals->time + 0.5f; pGrenade->m_bIsC4 = true; pGrenade->m_fNextDefuse = 0; @@ -1072,14 +1078,16 @@ CGrenade *CGrenade::ShootSatchelCharge(entvars_t *pevOwner, Vector vecStart, Vec pGrenade->m_pentCurBombTarget = pOwner->m_pentCurBombTarget; } else - pGrenade->m_pentCurBombTarget = NULL; + { + pGrenade->m_pentCurBombTarget = nullptr; + } return pGrenade; } CGrenade *CGrenade::ShootSmokeGrenade(entvars_t *pevOwner, Vector vecStart, Vector vecVelocity, float time, unsigned short usEvent) { - CGrenade *pGrenade = GetClassPtr((CGrenade *)NULL); + CGrenade *pGrenade = GetClassPtr((CGrenade *)nullptr); pGrenade->Spawn(); UTIL_SetOrigin(pGrenade->pev, vecStart); @@ -1115,7 +1123,7 @@ CGrenade *CGrenade::ShootSmokeGrenade(entvars_t *pevOwner, Vector vecStart, Vect void AnnounceFlashInterval(float interval, float offset) { - if (!g_bIsCzeroGame) + if (!AreRunningCZero()) return; MESSAGE_BEGIN(MSG_ALL, gmsgScenarioIcon); @@ -1176,7 +1184,7 @@ void CGrenade::C4Think() break; } - ++m_iCurWave; + m_iCurWave++; } if (gpGlobals->time >= m_flNextBeep) @@ -1258,7 +1266,7 @@ void CGrenade::C4Think() // if the defusing process has started if (m_bStartDefuse && m_pBombDefuser) { - CBasePlayer *pPlayer = (CBasePlayer *)m_pBombDefuser; + CBasePlayer *pPlayer = m_pBombDefuser; // if the defusing process has not ended yet if (gpGlobals->time < m_flDefuseCountDown) @@ -1279,7 +1287,7 @@ void CGrenade::C4Think() // cancel the progress bar pPlayer->SetProgressBarTime(0); - m_pBombDefuser = NULL; + m_pBombDefuser = nullptr; m_bStartDefuse = false; m_flDefuseCountDown = 0; @@ -1345,7 +1353,7 @@ void CGrenade::C4Think() MESSAGE_END(); g_pGameRules->m_bBombDropped = FALSE; - m_pBombDefuser = NULL; + m_pBombDefuser = nullptr; m_bStartDefuse = false; } else @@ -1356,7 +1364,7 @@ void CGrenade::C4Think() pPlayer->m_bIsDefusing = false; m_bStartDefuse = false; - m_pBombDefuser = NULL; + m_pBombDefuser = nullptr; // tell the bots someone has aborted defusing if (TheBots) @@ -1377,7 +1385,7 @@ NOXREF void CGrenade::UseSatchelCharges(entvars_t *pevOwner, SATCHELCODE code) if (!pevOwner) return; - edict_t *pentFind = NULL; + edict_t *pentFind = nullptr; CBaseEntity *pOwner = CBaseEntity::Instance(pevOwner); while ((pentFind = FIND_ENTITY_BY_CLASSNAME(pentFind, "grenade"))) @@ -1395,7 +1403,7 @@ NOXREF void CGrenade::UseSatchelCharges(entvars_t *pevOwner, SATCHELCODE code) else { // SATCHEL_RELEASE - pEnt->pev->owner = NULL; + pEnt->pev->owner = nullptr; } } } diff --git a/regamedll/dlls/gib.cpp b/regamedll/dlls/gib.cpp new file mode 100644 index 00000000..28499c79 --- /dev/null +++ b/regamedll/dlls/gib.cpp @@ -0,0 +1,295 @@ +#include "precompiled.h" + +void CGib::LimitVelocity() +{ + float length = pev->velocity.Length(); + + // ceiling at 1500. The gib velocity equation is not bounded properly. Rather than tune it + // in 3 separate places again, I'll just limit it here. + if (length > 1500.0) + { + // This should really be sv_maxvelocity * 0.75 or something + pev->velocity = pev->velocity.Normalize() * 1500; + } +} + +NOXREF void CGib::SpawnStickyGibs(entvars_t *pevVictim, Vector vecOrigin, int cGibs) +{ + if (g_Language == LANGUAGE_GERMAN) + { + // no sticky gibs in germany right now! + return; + } + + for (int i = 0; i < cGibs; ++i) + { + CGib *pGib = GetClassPtr((CGib *)nullptr); + + pGib->Spawn("models/stickygib.mdl"); + pGib->pev->body = RANDOM_LONG(0, 2); + + if (pevVictim) + { + pGib->pev->origin.x = vecOrigin.x + RANDOM_FLOAT(-3, 3); + pGib->pev->origin.y = vecOrigin.y + RANDOM_FLOAT(-3, 3); + pGib->pev->origin.z = vecOrigin.z + RANDOM_FLOAT(-3, 3); + + // make the gib fly away from the attack vector + pGib->pev->velocity = g_vecAttackDir * -1; + + // mix in some noise + pGib->pev->velocity.x += RANDOM_FLOAT(-0.15, 0.15); + pGib->pev->velocity.y += RANDOM_FLOAT(-0.15, 0.15); + pGib->pev->velocity.z += RANDOM_FLOAT(-0.15, 0.15); + + pGib->pev->velocity = pGib->pev->velocity * 900; + + pGib->pev->avelocity.x = RANDOM_FLOAT(250, 400); + pGib->pev->avelocity.y = RANDOM_FLOAT(250, 400); + + // copy owner's blood color + pGib->m_bloodColor = (CBaseEntity::Instance(pevVictim))->BloodColor(); + + if (pevVictim->health > -50) + { + pGib->pev->velocity = pGib->pev->velocity * 0.7; + } + else if (pevVictim->health > -200) + { + pGib->pev->velocity = pGib->pev->velocity * 2; + } + else + { + pGib->pev->velocity = pGib->pev->velocity * 4; + } + + pGib->pev->movetype = MOVETYPE_TOSS; + pGib->pev->solid = SOLID_BBOX; + UTIL_SetSize(pGib->pev, Vector(0, 0,0), Vector(0, 0, 0)); + pGib->SetTouch(&CGib::StickyGibTouch); + pGib->SetThink(NULL); + } + + pGib->LimitVelocity(); + } +} + +void CGib::SpawnHeadGib(entvars_t *pevVictim) +{ + CGib *pGib = GetClassPtr((CGib *)nullptr); + + if (g_Language == LANGUAGE_GERMAN) + { + // throw one head + pGib->Spawn("models/germangibs.mdl"); + pGib->pev->body = 0; + } + else + { + // throw one head + pGib->Spawn("models/hgibs.mdl"); + pGib->pev->body = 0; + } + + if (pevVictim) + { + pGib->pev->origin = pevVictim->origin + pevVictim->view_ofs; + + edict_t *pentPlayer = FIND_CLIENT_IN_PVS(pGib->edict()); + + if (RANDOM_LONG(0, 100) <= 5 && pentPlayer) + { + // 5% chance head will be thrown at player's face. + entvars_t *pevPlayer = VARS(pentPlayer); + + pGib->pev->velocity = ((pevPlayer->origin + pevPlayer->view_ofs) - pGib->pev->origin).Normalize() * 300; + pGib->pev->velocity.z += 100; + } + else + { + // TODO: fix test demo + pGib->pev->velocity.z = RANDOM_FLOAT(200, 300); + pGib->pev->velocity.y = RANDOM_FLOAT(-100, 100); + pGib->pev->velocity.x = RANDOM_FLOAT(-100, 100); + } + + pGib->pev->avelocity.x = RANDOM_FLOAT(100, 200); + pGib->pev->avelocity.y = RANDOM_FLOAT(100, 300); + + // copy owner's blood color + pGib->m_bloodColor = (CBaseEntity::Instance(pevVictim))->BloodColor(); + + if (pevVictim->health > -50) + { + pGib->pev->velocity = pGib->pev->velocity * 0.7; + } + else if (pevVictim->health > -200) + { + pGib->pev->velocity = pGib->pev->velocity * 2; + } + else + pGib->pev->velocity = pGib->pev->velocity * 4; + } + + pGib->LimitVelocity(); +} + +void CGib::SpawnRandomGibs(entvars_t *pevVictim, int cGibs, int human) +{ + int cSplat; + for (cSplat = 0; cSplat < cGibs; ++cSplat) + { + CGib *pGib = GetClassPtr((CGib *)nullptr); + + if (g_Language == LANGUAGE_GERMAN) + { + pGib->Spawn("models/germangibs.mdl"); + pGib->pev->body = RANDOM_LONG(0, GERMAN_GIB_COUNT - 1); + } + else + { + if (human) + { + // human pieces + pGib->Spawn("models/hgibs.mdl"); + // start at one to avoid throwing random amounts of skulls (0th gib) + pGib->pev->body = RANDOM_LONG(1, HUMAN_GIB_COUNT - 1); + } + else + { + // aliens + pGib->Spawn("models/agibs.mdl"); + pGib->pev->body = RANDOM_LONG(0, ALIEN_GIB_COUNT - 1); + } + } + + if (pevVictim) + { + // spawn the gib somewhere in the monster's bounding volume + pGib->pev->origin.x = pevVictim->absmin.x + pevVictim->size.x * (RANDOM_FLOAT(0, 1)); + pGib->pev->origin.y = pevVictim->absmin.y + pevVictim->size.y * (RANDOM_FLOAT(0, 1)); + + // absmin.z is in the floor because the engine subtracts 1 to enlarge the box + pGib->pev->origin.z = pevVictim->absmin.z + pevVictim->size.z * (RANDOM_FLOAT(0, 1)) + 1; + + // make the gib fly away from the attack vector + pGib->pev->velocity = g_vecAttackDir * -1; + + // mix in some noise + pGib->pev->velocity.x += RANDOM_FLOAT(-0.25, 0.25); + pGib->pev->velocity.y += RANDOM_FLOAT(-0.25, 0.25); + pGib->pev->velocity.z += RANDOM_FLOAT(-0.25, 0.25); + + pGib->pev->velocity = pGib->pev->velocity * RANDOM_FLOAT(300, 400); + + pGib->pev->avelocity.x = RANDOM_FLOAT(100, 200); + pGib->pev->avelocity.y = RANDOM_FLOAT(100, 300); + + // copy owner's blood color + pGib->m_bloodColor = (CBaseEntity::Instance(pevVictim))->BloodColor(); + + if (pevVictim->health > -50) + pGib->pev->velocity = pGib->pev->velocity * 0.7; + + else if (pevVictim->health > -200) + pGib->pev->velocity = pGib->pev->velocity * 2; + else + pGib->pev->velocity = pGib->pev->velocity * 4; + + pGib->pev->solid = SOLID_BBOX; + UTIL_SetSize(pGib->pev, Vector(0, 0, 0), Vector(0, 0, 0)); + } + pGib->LimitVelocity(); + } +} + +void CGib::BounceGibTouch(CBaseEntity *pOther) +{ + if (pev->flags & FL_ONGROUND) + { + pev->velocity = pev->velocity * 0.9; + pev->angles.x = 0; + pev->angles.z = 0; + pev->avelocity.x = 0; + pev->avelocity.z = 0; + } + else + { + if (g_Language != LANGUAGE_GERMAN && m_cBloodDecals > 0 && m_bloodColor != DONT_BLEED) + { + TraceResult tr; + Vector vecSpot = pev->origin + Vector(0, 0, 8); + UTIL_TraceLine(vecSpot, vecSpot + Vector(0, 0, -24), ignore_monsters, ENT(pev), &tr); + UTIL_BloodDecalTrace(&tr, m_bloodColor); + m_cBloodDecals--; + } + + if (m_material != matNone && !RANDOM_LONG(0, 2)) + { + float zvel = Q_fabs(pev->velocity.z); + float volume = 0.8 * Q_min(1.0f, zvel / 450); + + CBreakable::MaterialSoundRandom(edict(), (Materials)m_material, volume); + } + } +} + +// Sticky gib puts blood on the wall and stays put. +void CGib::StickyGibTouch(CBaseEntity *pOther) +{ + Vector vecSpot; + TraceResult tr; + + SetThink(&CBaseEntity::SUB_Remove); + pev->nextthink = gpGlobals->time + 10; + + if (!FClassnameIs(pOther->pev, "worldspawn")) + { + pev->nextthink = gpGlobals->time; + return; + } + + vecSpot = pev->origin + pev->velocity * 32; + + UTIL_TraceLine(pev->origin, vecSpot, ignore_monsters, ENT(pev), &tr); + UTIL_BloodDecalTrace(&tr, m_bloodColor); + + pev->velocity = tr.vecPlaneNormal * -1; + pev->angles = UTIL_VecToAngles(pev->velocity); + pev->velocity = g_vecZero; + pev->avelocity = g_vecZero; + pev->movetype = MOVETYPE_NONE; +} + +void CGib::Spawn(const char *szGibModel) +{ + pev->movetype = MOVETYPE_BOUNCE; + + // deading the bounce a bit + pev->friction = 0.55; + + // sometimes an entity inherits the edict from a former piece of glass, + // and will spawn using the same render FX or rendermode! bad! + pev->renderamt = 255.0; + pev->rendermode = kRenderNormal; + pev->renderfx = kRenderFxNone; + + /// hopefully this will fix the VELOCITY TOO LOW crap + pev->solid = SOLID_SLIDEBOX; + + MAKE_STRING_CLASS("gib", pev); + + SET_MODEL(ENT(pev), szGibModel); + UTIL_SetSize(pev, Vector(0, 0, 0), Vector(0, 0, 0)); + + pev->nextthink = gpGlobals->time + 4.0f; + m_lifeTime = 25.0f; + + SetThink(&CGib::WaitTillLand); + SetTouch(&CGib::BounceGibTouch); + + m_material = matNone; + + // how many blood decals this gib can place (1 per bounce until none remain). + m_cBloodDecals = 5; +} diff --git a/regamedll/extra/cssdk/dlls/mortar.h b/regamedll/dlls/gib.h similarity index 69% rename from regamedll/extra/cssdk/dlls/mortar.h rename to regamedll/dlls/gib.h index e74636c1..686fad8d 100644 --- a/regamedll/extra/cssdk/dlls/mortar.h +++ b/regamedll/dlls/gib.h @@ -25,31 +25,29 @@ * version. * */ + #pragma once -class CFuncMortarField: public CBaseToggle { +class CGib: public CBaseEntity +{ public: - virtual void Spawn() = 0; - virtual void Precache() = 0; - virtual void KeyValue(KeyValueData *pkvd) = 0; - virtual int Save(CSave &save) = 0; - virtual int Restore(CRestore &restore) = 0; + virtual int ObjectCaps() { return (CBaseEntity::ObjectCaps() & ~FCAP_ACROSS_TRANSITION) | FCAP_DONT_SAVE; } - // Bmodels don't go across transitions - virtual int ObjectCaps() = 0; public: - int m_iszXController; - int m_iszYController; - float m_flSpread; - float m_flDelay; - int m_iCount; - int m_fControl; -}; + void Spawn(const char *szGibModel); + void EXPORT BounceGibTouch(CBaseEntity *pOther); + void EXPORT StickyGibTouch(CBaseEntity *pOther); + void EXPORT WaitTillLand(); + void LimitVelocity(); -class CMortar: public CGrenade { public: - virtual void Spawn() = 0; - virtual void Precache() = 0; + static void SpawnHeadGib(entvars_t *pevVictim); + static void SpawnRandomGibs(entvars_t *pevVictim, int cGibs, int human); + static void SpawnStickyGibs(entvars_t *pevVictim, Vector vecOrigin, int cGibs); + public: - int m_spriteTexture; + int m_bloodColor; + int m_cBloodDecals; + int m_material; + float m_lifeTime; }; diff --git a/regamedll/dlls/globals.cpp b/regamedll/dlls/globals.cpp index d48b4528..59b259ac 100644 --- a/regamedll/dlls/globals.cpp +++ b/regamedll/dlls/globals.cpp @@ -6,16 +6,15 @@ #ifndef HOOK_GAMEDLL const Vector g_vecZero(0, 0, 0); -NOXREF u_long g_ulFrameCount = 0; #endif int g_Language; - -NOXREF u_long g_ulModelIndexEyes; -Vector g_vecAttackDir; int g_iSkillLevel; -int gDisplayTitle; + +Vector g_vecAttackDir; +BOOL gDisplayTitle; + bool g_bIsCzeroGame = false; bool g_bAllowedCSBot = false; bool g_bHostageImprov = false; diff --git a/regamedll/dlls/globals.h b/regamedll/dlls/globals.h index 874e024e..20e0cc33 100644 --- a/regamedll/dlls/globals.h +++ b/regamedll/dlls/globals.h @@ -26,23 +26,15 @@ * */ -#ifndef GLOBALS_H -#define GLOBALS_H -#ifdef _WIN32 #pragma once -#endif extern const Vector g_vecZero; extern int g_Language; - -extern u_long g_ulFrameCount; -extern u_long g_ulModelIndexEyes; +extern int g_iSkillLevel; extern Vector g_vecAttackDir; -extern int g_iSkillLevel; -extern int gDisplayTitle; + +extern BOOL gDisplayTitle; extern bool g_bIsCzeroGame; extern bool g_bAllowedCSBot; extern bool g_bHostageImprov; - -#endif // GLOBALS_H diff --git a/regamedll/dlls/h_ai.cpp b/regamedll/dlls/h_ai.cpp deleted file mode 100644 index 173f025b..00000000 --- a/regamedll/dlls/h_ai.cpp +++ /dev/null @@ -1,162 +0,0 @@ -#include "precompiled.h" - -BOOL g_fDrawLines = FALSE; - -NOXREF BOOL FBoxVisible(entvars_t *pevLooker, entvars_t *pevTarget, Vector &vecTargetOrigin, float flSize) -{ - // don't look through water - if ((pevLooker->waterlevel != 3 && pevTarget->waterlevel == 3) || (pevLooker->waterlevel == 3 && pevTarget->waterlevel == 0)) - { - return FALSE; - } - - TraceResult tr; - - //look through the monster's 'eyes' - Vector vecLookerOrigin = pevLooker->origin + pevLooker->view_ofs; - - for (int i = 0; i < 5; ++i) - { - Vector vecTarget = pevTarget->origin; - - vecTarget.x += RANDOM_FLOAT(pevTarget->mins.x + flSize, pevTarget->maxs.x - flSize); - vecTarget.y += RANDOM_FLOAT(pevTarget->mins.y + flSize, pevTarget->maxs.y - flSize); - vecTarget.z += RANDOM_FLOAT(pevTarget->mins.z + flSize, pevTarget->maxs.z - flSize); - - UTIL_TraceLine(vecLookerOrigin, vecTarget, ignore_monsters, ignore_glass, ENT(pevLooker), &tr); - - if (tr.flFraction == 1.0f) - { - vecTargetOrigin = vecTarget; - - // line of sight is valid. - return TRUE; - } - } - - // Line of sight is not established - return FALSE; -} - -// VecCheckToss - returns the velocity at which an object should be lobbed from vecspot1 to land near vecspot2. -// returns g_vecZero if toss is not feasible. -NOXREF Vector VecCheckToss(entvars_t *pev, const Vector &vecSpot1, Vector vecSpot2, float flGravityAdj) -{ - TraceResult tr; - Vector vecMidPoint; // halfway point between Spot1 and Spot2 - Vector vecApex; // highest point - Vector vecScale; - Vector vecGrenadeVel; - Vector vecTemp; - float flGravity = g_psv_gravity->value * flGravityAdj; - - if (vecSpot2.z - vecSpot1.z > 500) - { - // to high, fail - return g_vecZero; - } - - UTIL_MakeVectors(pev->angles); - - // toss a little bit to the left or right, not right down on the enemy's bean (head). - vecSpot2 = vecSpot2 + gpGlobals->v_right * (RANDOM_FLOAT(-8, 8) + RANDOM_FLOAT(-16, 16)); - vecSpot2 = vecSpot2 + gpGlobals->v_forward * (RANDOM_FLOAT(-8, 8) + RANDOM_FLOAT(-16, 16)); - - // calculate the midpoint and apex of the 'triangle' - // UNDONE: normalize any Z position differences between spot1 and spot2 so that triangle is always RIGHT - - // How much time does it take to get there? - - // get a rough idea of how high it can be thrown - vecMidPoint = vecSpot1 + (vecSpot2 - vecSpot1) * 0.5f; - UTIL_TraceLine(vecMidPoint, vecMidPoint + Vector(0, 0, 500), ignore_monsters, ENT(pev), &tr); - vecMidPoint = tr.vecEndPos; - - // (subtract 15 so the grenade doesn't hit the ceiling) - vecMidPoint.z -= 15; - - if (vecMidPoint.z < vecSpot1.z || vecMidPoint.z < vecSpot2.z) - { - // to not enough space, fail - return g_vecZero; - } - - // How high should the grenade travel to reach the apex - float distance1 = (vecMidPoint.z - vecSpot1.z); - float distance2 = (vecMidPoint.z - vecSpot2.z); - - // How long will it take for the grenade to travel this distance - float time1 = Q_sqrt(distance1 / (0.5f * flGravity)); - float time2 = Q_sqrt(distance2 / (0.5f * flGravity)); - - if (time1 < 0.1f) - { - // too close - return g_vecZero; - } - - // how hard to throw sideways to get there in time. - vecGrenadeVel = (vecSpot2 - vecSpot1) / (time1 + time2); - - // how hard upwards to reach the apex at the right time. - vecGrenadeVel.z = flGravity * time1; - - // find the apex - vecApex = vecSpot1 + vecGrenadeVel * time1; - vecApex.z = vecMidPoint.z; - - UTIL_TraceLine(vecSpot1, vecApex, dont_ignore_monsters, ENT(pev), &tr); - if (tr.flFraction != 1.0f) - { - // fail! - return g_vecZero; - } - - // UNDONE: either ignore monsters or change it to not care if we hit our enemy - UTIL_TraceLine(vecSpot2, vecApex, ignore_monsters, ENT(pev), &tr); - if (tr.flFraction != 1.0) - { - // fail! - return g_vecZero; - } - - return vecGrenadeVel; -} - -// VecCheckThrow - returns the velocity vector at which an object should be thrown from vecspot1 to hit vecspot2. -// returns g_vecZero if throw is not feasible. -NOXREF Vector VecCheckThrow(entvars_t *pev, const Vector &vecSpot1, Vector vecSpot2, float flSpeed, float flGravityAdj) -{ - float flGravity = g_psv_gravity->value * flGravityAdj; - - Vector vecGrenadeVel = (vecSpot2 - vecSpot1); - - // throw at a constant time - float time = vecGrenadeVel.Length() / flSpeed; - vecGrenadeVel = vecGrenadeVel * (1.0f / time); - - // adjust upward toss to compensate for gravity loss - vecGrenadeVel.z += flGravity * time * 0.5f; - - Vector vecApex = vecSpot1 + (vecSpot2 - vecSpot1) * 0.5f; - vecApex.z += 0.5f * flGravity * (time * 0.5f) * (time * 0.5f); - - TraceResult tr; - UTIL_TraceLine(vecSpot1, vecApex, dont_ignore_monsters, ENT(pev), &tr); - - if (tr.flFraction != 1.0f) - { - // fail! - return g_vecZero; - } - - UTIL_TraceLine(vecSpot2, vecApex, ignore_monsters, ENT(pev), &tr); - - if (tr.flFraction != 1.0f) - { - // fail! - return g_vecZero; - } - - return vecGrenadeVel; -} diff --git a/regamedll/dlls/h_battery.cpp b/regamedll/dlls/h_battery.cpp index 22c8e5de..9a75a507 100644 --- a/regamedll/dlls/h_battery.cpp +++ b/regamedll/dlls/h_battery.cpp @@ -35,7 +35,9 @@ void CRecharge::KeyValue(KeyValueData *pkvd) pkvd->fHandled = TRUE; } else + { CBaseToggle::KeyValue(pkvd); + } } void CRecharge::Spawn() @@ -50,7 +52,14 @@ void CRecharge::Spawn() UTIL_SetSize(pev, pev->mins, pev->maxs); SET_MODEL(ENT(pev), STRING(pev->model)); - m_iJuice = int(gSkillData.suitchargerCapacity); + int armorValue = (int)gSkillData.suitchargerCapacity; +#ifdef REGAMEDLL_FIXES + if (pev->armorvalue != 0.0f) { + armorValue = (int)pev->armorvalue; + } +#endif + + m_iJuice = armorValue; pev->frame = 0; } @@ -120,6 +129,12 @@ void CRecharge::Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useT // charge the player if (m_hActivator->pev->armorvalue < 100) { +#ifdef REGAMEDLL_FIXES + CBasePlayer *pPlayer = m_hActivator.Get(); + if (pPlayer->m_iKevlar == ARMOR_NONE) + pPlayer->m_iKevlar = ARMOR_KEVLAR; +#endif + m_iJuice--; m_hActivator->pev->armorvalue += 1.0f; @@ -133,7 +148,15 @@ void CRecharge::Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useT void CRecharge::Recharge() { - m_iJuice = gSkillData.suitchargerCapacity; + int armorValue = (int)gSkillData.suitchargerCapacity; +#ifdef REGAMEDLL_FIXES + if (pev->armorvalue != 0.0f) { + armorValue = (int)pev->armorvalue; + } +#endif + + m_iJuice = armorValue; + pev->frame = 0; SetThink(&CRecharge::SUB_DoNothing); } @@ -152,5 +175,7 @@ void CRecharge::Off() SetThink(&CRecharge::Recharge); } else + { SetThink(&CRecharge::SUB_DoNothing); + } } diff --git a/regamedll/dlls/h_battery.h b/regamedll/dlls/h_battery.h index 71a8d4c3..5cfe15a9 100644 --- a/regamedll/dlls/h_battery.h +++ b/regamedll/dlls/h_battery.h @@ -26,11 +26,7 @@ * */ -#ifndef H_BATTERY_H -#define H_BATTERY_H -#ifdef _WIN32 #pragma once -#endif class CRecharge: public CBaseToggle { @@ -56,5 +52,3 @@ public: int m_iOn; float m_flSoundTime; }; - -#endif // H_BATTERY_H diff --git a/regamedll/dlls/h_cycler.cpp b/regamedll/dlls/h_cycler.cpp index b8100e9f..295b384b 100644 --- a/regamedll/dlls/h_cycler.cpp +++ b/regamedll/dlls/h_cycler.cpp @@ -351,17 +351,16 @@ void CWreckage::Think() } } - Vector VecSrc; + Vector vecSrc; + vecSrc.x = RANDOM_FLOAT(pev->absmin.x, pev->absmax.x); + vecSrc.y = RANDOM_FLOAT(pev->absmin.y, pev->absmax.y); + vecSrc.z = RANDOM_FLOAT(pev->absmin.z, pev->absmax.z); - VecSrc.x = RANDOM_FLOAT(pev->absmin.x, pev->absmax.x); - VecSrc.y = RANDOM_FLOAT(pev->absmin.y, pev->absmax.y); - VecSrc.z = RANDOM_FLOAT(pev->absmin.z, pev->absmax.z); - - MESSAGE_BEGIN(MSG_PVS, SVC_TEMPENTITY, VecSrc); + MESSAGE_BEGIN(MSG_PVS, SVC_TEMPENTITY, vecSrc); WRITE_BYTE(TE_SMOKE); - WRITE_COORD(VecSrc.x); - WRITE_COORD(VecSrc.y); - WRITE_COORD(VecSrc.z); + WRITE_COORD(vecSrc.x); + WRITE_COORD(vecSrc.y); + WRITE_COORD(vecSrc.z); WRITE_SHORT(g_sModelIndexSmoke); WRITE_BYTE(RANDOM_LONG(0, 49) + 50); // scale * 10 WRITE_BYTE(RANDOM_LONG(0, 3) + 8); // framerate diff --git a/regamedll/dlls/h_cycler.h b/regamedll/dlls/h_cycler.h index 7ed076dc..5991c223 100644 --- a/regamedll/dlls/h_cycler.h +++ b/regamedll/dlls/h_cycler.h @@ -26,11 +26,7 @@ * */ -#ifndef H_CYCLER_H -#define H_CYCLER_H -#ifdef _WIN32 #pragma once -#endif class CCycler: public CBaseMonster { @@ -55,7 +51,7 @@ public: int m_animate; }; -// we should get rid of all the other cyclers and replace them with this. +// We should get rid of all the other cyclers and replace them with this. class CGenericCycler: public CCycler { public: @@ -128,5 +124,3 @@ public: int m_flStartTime; }; - -#endif // H_CYCLER_H diff --git a/regamedll/dlls/healthkit.cpp b/regamedll/dlls/healthkit.cpp index f5a4e6bb..c4acd7af 100644 --- a/regamedll/dlls/healthkit.cpp +++ b/regamedll/dlls/healthkit.cpp @@ -39,9 +39,17 @@ BOOL CHealthKit::MyTouch(CBasePlayer *pPlayer) return FALSE; #endif - if (pPlayer->TakeHealth(gSkillData.healthkitCapacity, DMG_GENERIC)) + auto healthValue = gSkillData.healthkitCapacity; + +#ifdef REGAMEDLL_FIXES + if (pev->health != 0.0f) { + healthValue = pev->health; + } +#endif + + if (pPlayer->TakeHealth(healthValue, DMG_GENERIC)) { - MESSAGE_BEGIN(MSG_ONE, gmsgItemPickup, NULL, pPlayer->pev); + MESSAGE_BEGIN(MSG_ONE, gmsgItemPickup, nullptr, pPlayer->pev); WRITE_STRING(STRING(pev->classname)); MESSAGE_END(); @@ -73,7 +81,9 @@ void CWallHealth::KeyValue(KeyValueData *pkvd) pkvd->fHandled = TRUE; } else + { CBaseToggle::KeyValue(pkvd); + } } void CWallHealth::Spawn() @@ -89,7 +99,14 @@ void CWallHealth::Spawn() SET_MODEL(ENT(pev), STRING(pev->model)); - m_iJuice = int(gSkillData.healthchargerCapacity); + int healthValue = (int)gSkillData.healthchargerCapacity; +#ifdef REGAMEDLL_FIXES + if (pev->health != 0.0f) { + healthValue = (int)pev->health; + } +#endif + + m_iJuice = healthValue; pev->frame = 0.0f; } @@ -160,7 +177,16 @@ void CWallHealth::Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE us void CWallHealth::Recharge() { EMIT_SOUND(ENT(pev), CHAN_ITEM, "items/medshot4.wav", VOL_NORM, ATTN_NORM); - m_iJuice = gSkillData.healthchargerCapacity; + + int healthValue = (int)gSkillData.healthchargerCapacity; +#ifdef REGAMEDLL_FIXES + if (pev->health != 0.0f) { + healthValue = (int)pev->health; + } +#endif + + m_iJuice = healthValue; + pev->frame = 0.0f; SetThink(&CWallHealth::SUB_DoNothing); } @@ -173,11 +199,13 @@ void CWallHealth::Off() m_iOn = 0; - if (!m_iJuice && ((m_iReactivate = g_pGameRules->FlHealthChargerRechargeTime()) > 0)) + if (!m_iJuice && ((m_iReactivate = g_pGameRules->FlHealthChargerRechargeTime()) > 0)) { pev->nextthink = pev->ltime + m_iReactivate; SetThink(&CWallHealth::Recharge); } else + { SetThink(&CWallHealth::SUB_DoNothing); + } } diff --git a/regamedll/dlls/healthkit.h b/regamedll/dlls/healthkit.h index e588a39e..e57d4a2d 100644 --- a/regamedll/dlls/healthkit.h +++ b/regamedll/dlls/healthkit.h @@ -26,11 +26,7 @@ * */ -#ifndef HEALTKIT_H -#define HEALTKIT_H -#ifdef _WIN32 #pragma once -#endif class CHealthKit: public CItem { @@ -63,5 +59,3 @@ public: int m_iOn; float m_flSoundTime; }; - -#endif // HEALTKIT_H diff --git a/regamedll/dlls/hintmessage.cpp b/regamedll/dlls/hintmessage.cpp index 449ce440..a28f60c7 100644 --- a/regamedll/dlls/hintmessage.cpp +++ b/regamedll/dlls/hintmessage.cpp @@ -8,14 +8,14 @@ CHintMessage::CHintMessage(const char *hintString, bool isHint, CUtlVectorCount(); ++i) + for (int i = 0; i < args->Count(); i++) m_args.AddToTail(CloneString((*args)[i])); } } CHintMessage::~CHintMessage() { - for (int i = 0; i < m_args.Count(); ++i) + for (int i = 0; i < m_args.Count(); i++) delete[] m_args[i]; m_args.RemoveAll(); @@ -30,7 +30,7 @@ void CHintMessageQueue::Reset() { m_tmMessageEnd = 0; - for (int i = 0; i < m_messages.Count(); ++i) + for (int i = 0; i < m_messages.Count(); i++) delete m_messages[i]; m_messages.RemoveAll(); diff --git a/regamedll/dlls/hintmessage.h b/regamedll/dlls/hintmessage.h index 4a46221b..9659fe0f 100644 --- a/regamedll/dlls/hintmessage.h +++ b/regamedll/dlls/hintmessage.h @@ -26,35 +26,33 @@ * */ -#ifndef HINTMESSAGE_H -#define HINTMESSAGE_H -#ifdef _WIN32 #pragma once -#endif -#define DHF_ROUND_STARTED (1<<1) -#define DHF_HOSTAGE_SEEN_FAR (1<<2) -#define DHF_HOSTAGE_SEEN_NEAR (1<<3) -#define DHF_HOSTAGE_USED (1<<4) -#define DHF_HOSTAGE_INJURED (1<<5) -#define DHF_HOSTAGE_KILLED (1<<6) -#define DHF_FRIEND_SEEN (1<<7) -#define DHF_ENEMY_SEEN (1<<8) -#define DHF_FRIEND_INJURED (1<<9) -#define DHF_FRIEND_KILLED (1<<10) -#define DHF_ENEMY_KILLED (1<<11) -#define DHF_BOMB_RETRIEVED (1<<12) -#define DHF_AMMO_EXHAUSTED (1<<15) -#define DHF_IN_TARGET_ZONE (1<<16) -#define DHF_IN_RESCUE_ZONE (1<<17) -#define DHF_IN_ESCAPE_ZONE (1<<18) -#define DHF_IN_VIPSAFETY_ZONE (1<<19) -#define DHF_NIGHTVISION (1<<20) -#define DHF_HOSTAGE_CTMOVE (1<<21) -#define DHF_SPEC_DUCK (1<<22) +#include "utlvector.h" -#define DHM_ROUND_CLEAR (DHF_ROUND_STARTED | DHF_HOSTAGE_KILLED | DHF_FRIEND_KILLED | DHF_BOMB_RETRIEVED) -#define DHM_CONNECT_CLEAR (DHF_HOSTAGE_SEEN_FAR | DHF_HOSTAGE_SEEN_NEAR | DHF_HOSTAGE_USED | DHF_HOSTAGE_INJURED | DHF_FRIEND_SEEN | DHF_ENEMY_SEEN | DHF_FRIEND_INJURED | DHF_ENEMY_KILLED | DHF_AMMO_EXHAUSTED | DHF_IN_TARGET_ZONE | DHF_IN_RESCUE_ZONE | DHF_IN_ESCAPE_ZONE | DHF_IN_VIPSAFETY_ZONE | DHF_HOSTAGE_CTMOVE | DHF_SPEC_DUCK) +#define DHF_ROUND_STARTED BIT(1) +#define DHF_HOSTAGE_SEEN_FAR BIT(2) +#define DHF_HOSTAGE_SEEN_NEAR BIT(3) +#define DHF_HOSTAGE_USED BIT(4) +#define DHF_HOSTAGE_INJURED BIT(5) +#define DHF_HOSTAGE_KILLED BIT(6) +#define DHF_FRIEND_SEEN BIT(7) +#define DHF_ENEMY_SEEN BIT(8) +#define DHF_FRIEND_INJURED BIT(9) +#define DHF_FRIEND_KILLED BIT(10) +#define DHF_ENEMY_KILLED BIT(11) +#define DHF_BOMB_RETRIEVED BIT(12) +#define DHF_AMMO_EXHAUSTED BIT(15) +#define DHF_IN_TARGET_ZONE BIT(16) +#define DHF_IN_RESCUE_ZONE BIT(17) +#define DHF_IN_ESCAPE_ZONE BIT(18) +#define DHF_IN_VIPSAFETY_ZONE BIT(19) +#define DHF_NIGHTVISION BIT(20) +#define DHF_HOSTAGE_CTMOVE BIT(21) +#define DHF_SPEC_DUCK BIT(22) + +#define DHM_ROUND_CLEAR (DHF_ROUND_STARTED | DHF_HOSTAGE_KILLED | DHF_FRIEND_KILLED | DHF_BOMB_RETRIEVED) +#define DHM_CONNECT_CLEAR (DHF_HOSTAGE_SEEN_FAR | DHF_HOSTAGE_SEEN_NEAR | DHF_HOSTAGE_USED | DHF_HOSTAGE_INJURED | DHF_FRIEND_SEEN | DHF_ENEMY_SEEN | DHF_FRIEND_INJURED | DHF_ENEMY_KILLED | DHF_AMMO_EXHAUSTED | DHF_IN_TARGET_ZONE | DHF_IN_RESCUE_ZONE | DHF_IN_ESCAPE_ZONE | DHF_IN_VIPSAFETY_ZONE | DHF_HOSTAGE_CTMOVE | DHF_SPEC_DUCK) class CHintMessage { @@ -85,5 +83,3 @@ private: float m_tmMessageEnd; CUtlVector m_messages; }; - -#endif // HINTMESSAGE_H diff --git a/regamedll/dlls/hostage/hostage.cpp b/regamedll/dlls/hostage/hostage.cpp index 8bfaabf3..4673eedf 100644 --- a/regamedll/dlls/hostage/hostage.cpp +++ b/regamedll/dlls/hostage/hostage.cpp @@ -5,10 +5,10 @@ */ #ifndef HOOK_GAMEDLL -cvar_t cv_hostage_debug = { "hostage_debug", "0", FCVAR_SERVER, 0.0f, NULL }; -cvar_t cv_hostage_stop = { "hostage_stop", "0", FCVAR_SERVER, 0.0f, NULL }; +cvar_t cv_hostage_debug = { "hostage_debug", "0", FCVAR_SERVER, 0.0f, nullptr }; +cvar_t cv_hostage_stop = { "hostage_stop", "0", FCVAR_SERVER, 0.0f, nullptr }; -CHostageManager *g_pHostages = NULL; +CHostageManager *g_pHostages = nullptr; int g_iHostageNumber = 0; #endif @@ -205,8 +205,8 @@ void CHostage::Spawn() m_flNextChange = 0; m_State = STAND; - m_hTargetEnt = NULL; - m_hStoppedTargetEnt = NULL; + m_hTargetEnt = nullptr; + m_hStoppedTargetEnt = nullptr; m_vPathToFollow[0] = Vector(0, 0, 0); m_flFlinchTime = 0; m_bRescueMe = FALSE; @@ -242,7 +242,7 @@ void CHostage::Spawn() m_LocalNav = new CLocalNav(this); m_bStuck = FALSE; m_flStuckTime = 0; - m_improv = NULL; + m_improv = nullptr; } void CHostage::Precache() @@ -332,10 +332,10 @@ void CHostage::IdleThink() } else { - if (m_improv != NULL) + if (m_improv) { delete m_improv; - m_improv = NULL; + m_improv = nullptr; } } @@ -344,7 +344,7 @@ void CHostage::IdleThink() flInterval = StudioFrameAdvance(); DispatchAnimEvents(flInterval); - if (m_improv != NULL) + if (m_improv) { m_improv->OnUpkeep(upkeepRate); } @@ -362,36 +362,36 @@ void CHostage::IdleThink() return; } - if (m_hTargetEnt != NULL && (m_bStuck && gpGlobals->time - m_flStuckTime > 5.0f || m_hTargetEnt->pev->deadflag != DEAD_NO)) + if (m_hTargetEnt && (m_bStuck && gpGlobals->time - m_flStuckTime > 5.0f || m_hTargetEnt->pev->deadflag != DEAD_NO)) { m_State = STAND; - m_hTargetEnt = NULL; + m_hTargetEnt = nullptr; m_bStuck = FALSE; } - if (m_hTargetEnt != NULL || m_improv != NULL) + if (m_hTargetEnt || m_improv) { - CBasePlayer *player = NULL; + CBasePlayer *pPlayer = nullptr; - if (m_improv != NULL) + if (m_improv) { if (m_improv->IsFollowing()) - player = (CBasePlayer *)m_improv->GetFollowLeader(); + pPlayer = m_improv->GetFollowLeader(); } else - player = GetClassPtr((CBasePlayer *)m_hTargetEnt->pev); + pPlayer = GetClassPtr((CBasePlayer *)m_hTargetEnt->pev); - if (player == NULL || player->m_iTeam == CT) + if (!pPlayer || pPlayer->m_iTeam == CT) { if (!CSGameRules()->m_bMapHasRescueZone) { bool bResHostagePt = false; - if (UTIL_FindEntityByClassname(NULL, "info_hostage_rescue")) + if (UTIL_FindEntityByClassname(nullptr, "info_hostage_rescue")) bResHostagePt = true; - CBaseEntity *pSpot = NULL; - while ((pSpot = UTIL_FindEntityByClassname(pSpot, "info_hostage_rescue")) != NULL) + CBaseEntity *pSpot = nullptr; + while ((pSpot = UTIL_FindEntityByClassname(pSpot, "info_hostage_rescue"))) { if ((pSpot->pev->origin - pev->origin).Length() < RESCUE_HOSTAGES_RADIUS) { @@ -402,7 +402,7 @@ void CHostage::IdleThink() if (!bResHostagePt) { - pSpot = NULL; + pSpot = nullptr; while ((pSpot = UTIL_FindEntityByClassname(pSpot, "info_player_start"))) { @@ -419,21 +419,21 @@ void CHostage::IdleThink() { if (TheBots) { - TheBots->OnEvent(EVENT_HOSTAGE_RESCUED, player, this); + TheBots->OnEvent(EVENT_HOSTAGE_RESCUED, pPlayer, this); } - if (TheCareerTasks && CSGameRules()->IsCareer() && player && !player->IsBot()) + if (TheCareerTasks && CSGameRules()->IsCareer() && pPlayer && !pPlayer->IsBot()) { - TheCareerTasks->HandleEvent(EVENT_HOSTAGE_RESCUED, player); + TheCareerTasks->HandleEvent(EVENT_HOSTAGE_RESCUED, pPlayer); } pev->deadflag = DEAD_RESPAWNABLE; - if (player) + if (pPlayer) { - player->AddAccount(REWARD_TAKEN_HOSTAGE, RT_HOSTAGE_RESCUED); - UTIL_LogPrintf("\"%s<%i><%s>\" triggered \"Rescued_A_Hostage\"\n", STRING(player->pev->netname), - GETPLAYERUSERID(player->edict()), GETPLAYERAUTHID(player->edict())); + pPlayer->AddAccount(REWARD_TAKEN_HOSTAGE, RT_HOSTAGE_RESCUED); + UTIL_LogPrintf("\"%s<%i><%s>\" triggered \"Rescued_A_Hostage\"\n", STRING(pPlayer->pev->netname), + GETPLAYERUSERID(pPlayer->edict()), GETPLAYERAUTHID(pPlayer->edict())); } SendHostageEventMsg(); @@ -441,7 +441,7 @@ void CHostage::IdleThink() MESSAGE_BEGIN(MSG_SPEC, SVC_DIRECTOR); WRITE_BYTE(9); WRITE_BYTE(DRC_CMD_EVENT); - WRITE_SHORT(player != NULL ? player->entindex() : 0); + WRITE_SHORT(pPlayer ? pPlayer->entindex() : 0); WRITE_SHORT(entindex()); WRITE_LONG(15); MESSAGE_END(); @@ -452,12 +452,12 @@ void CHostage::IdleThink() CSGameRules()->m_iHostagesRescued++; CSGameRules()->CheckWinConditions(); - Broadcast((player != NULL) ? "rescued" : "escaped"); + Broadcast(pPlayer ? "rescued" : "escaped"); } } } - if (m_improv != NULL) + if (m_improv) { m_improv->OnUpdate(updateRate); } @@ -529,8 +529,8 @@ void CHostage::RePosition() pev->angles = m_vStartAngles; pev->effects &= ~EF_NODRAW; - m_hTargetEnt = NULL; - m_hStoppedTargetEnt = NULL; + m_hTargetEnt = nullptr; + m_hStoppedTargetEnt = nullptr; m_bTouched = FALSE; m_bRescueMe = FALSE; @@ -587,7 +587,7 @@ BOOL CHostage::TakeDamage(entvars_t *pevInflictor, entvars_t *pevAttacker, float PlayPainSound(); - CBasePlayer *pAttacker = NULL; + CBasePlayer *pAttacker = nullptr; if (pevAttacker) { CBaseEntity *pAttackingEnt = GetClassPtr((CBaseEntity *)pevAttacker); @@ -704,7 +704,7 @@ void CHostage::SetFlinchActivity() { Activity activity = ACT_SMALL_FLINCH; - if (m_improv != NULL) + if (m_improv) { m_improv->Flinch(activity); return; @@ -715,7 +715,7 @@ void CHostage::SetFlinchActivity() void CHostage::SetDeathActivity() { - if (m_improv != NULL && m_improv->IsCrouching()) + if (m_improv && m_improv->IsCrouching()) { m_improv->CrouchDie(); return; @@ -809,11 +809,11 @@ void CHostage::ApplyHostagePenalty(CBasePlayer *pAttacker) } else if (pAttacker->m_iHostagesKilled >= iHostagePenalty) { - #ifdef REGAMEDLL_FIXES +#ifdef REGAMEDLL_FIXES SERVER_COMMAND(UTIL_VarArgs("kick #%d\n", GETPLAYERUSERID(pAttacker->edict()))); - #else +#else CLIENT_COMMAND(pAttacker->edict(), "disconnect\n"); - #endif +#endif } } } @@ -832,7 +832,6 @@ void CHostage::Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useTy #endif CBasePlayer *pPlayer = (CBasePlayer *)pActivator; - if (pPlayer->m_iTeam != CT) { if (!(pPlayer->m_flDisplayHistory & DHF_HOSTAGE_CTMOVE)) @@ -848,7 +847,7 @@ void CHostage::Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useTy { m_flNextChange = gpGlobals->time + 1.0f; - if (m_improv != NULL) + if (m_improv) { if (m_improv->IsFollowing() && pActivator == m_improv->GetFollowLeader()) { @@ -860,7 +859,7 @@ void CHostage::Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useTy { m_improv->Follow(pPlayer); - if (TheBots != NULL) + if (TheBots) { TheBots->OnEvent(EVENT_HOSTAGE_USED, pActivator); } @@ -874,12 +873,12 @@ void CHostage::Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useTy { m_State = FOLLOW; m_hTargetEnt = pActivator; - m_hStoppedTargetEnt = NULL; + m_hStoppedTargetEnt = nullptr; } else if (m_State == FOLLOW) { m_State = STAND; - m_hTargetEnt = NULL; + m_hTargetEnt = nullptr; m_hStoppedTargetEnt = pActivator; } else @@ -888,7 +887,7 @@ void CHostage::Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useTy if (m_State == FOLLOW) { PlayFollowRescueSound(); - if (TheBots != NULL) + if (TheBots) { TheBots->OnEvent(EVENT_HOSTAGE_USED, pActivator); } @@ -934,7 +933,7 @@ void CHostage::Touch(CBaseEntity *pOther) Vector2D vPush; const float pushForce = 50.0f; - if (m_improv != NULL) + if (m_improv) { m_improv->OnTouch(pOther); return; @@ -972,14 +971,14 @@ void CHostage::DoFollow() float flRadius = 0; float flDistToDest; - if (m_hTargetEnt == NULL) + if (!m_hTargetEnt) return; if (cv_hostage_stop.value > 0.0f) { m_State = STAND; - m_hTargetEnt = NULL; - m_hStoppedTargetEnt = NULL; + m_hTargetEnt = nullptr; + m_hStoppedTargetEnt = nullptr; return; } @@ -1079,7 +1078,7 @@ void CHostage::MoveToward(const Vector &vecLoc) vecMove = vecLoc - pev->origin; Vector vecAng(0, UTIL_VecToAngles(vecMove).y, 0); - UTIL_MakeVectorsPrivate(vecAng, vecFwd, NULL, NULL); + UTIL_MakeVectorsPrivate(vecAng, vecFwd, nullptr, nullptr); if ((vecFwd * s_flStepSize_LocalNav).Length2D() <= (vecLoc - pev->origin).Length2D()) flDist = (vecFwd * s_flStepSize_LocalNav).Length2D(); @@ -1184,8 +1183,8 @@ void CHostage::NavReady() void CHostage::SendHostagePositionMsg() { - CBaseEntity *pEntity = NULL; - while ((pEntity = UTIL_FindEntityByClassname(pEntity, "player")) != NULL) + CBaseEntity *pEntity = nullptr; + while ((pEntity = UTIL_FindEntityByClassname(pEntity, "player"))) { if (FNullEnt(pEntity->edict())) break; @@ -1200,7 +1199,7 @@ void CHostage::SendHostagePositionMsg() if (pTempPlayer->pev->deadflag == DEAD_NO && pTempPlayer->m_iTeam == CT) { - MESSAGE_BEGIN(MSG_ONE, gmsgHostagePos, NULL, pTempPlayer->pev); + MESSAGE_BEGIN(MSG_ONE, gmsgHostagePos, nullptr, pTempPlayer->pev); WRITE_BYTE(0); WRITE_BYTE(m_iHostageIndex); WRITE_COORD(pev->origin.x); @@ -1213,8 +1212,8 @@ void CHostage::SendHostagePositionMsg() void CHostage::SendHostageEventMsg() { - CBaseEntity *pEntity = NULL; - while ((pEntity = UTIL_FindEntityByClassname(pEntity, "player")) != NULL) + CBaseEntity *pEntity = nullptr; + while ((pEntity = UTIL_FindEntityByClassname(pEntity, "player"))) { if (FNullEnt(pEntity->edict())) break; @@ -1229,7 +1228,7 @@ void CHostage::SendHostageEventMsg() if (pTempPlayer->pev->deadflag == DEAD_NO && pTempPlayer->m_iTeam == CT) { - MESSAGE_BEGIN(MSG_ONE, gmsgHostageK, NULL, pTempPlayer->pev); + MESSAGE_BEGIN(MSG_ONE, gmsgHostageK, nullptr, pTempPlayer->pev); WRITE_BYTE(m_iHostageIndex); MESSAGE_END(); } @@ -1281,7 +1280,7 @@ void CHostage::PreThink() float flRaisedDist; float flInterval; - if (m_improv != NULL) + if (m_improv) { return; } @@ -1358,10 +1357,10 @@ void Hostage_RegisterCVars() void InstallHostageManager() { - if (g_pHostages != NULL) + if (g_pHostages) { delete g_pHostages; - g_pHostages = NULL; + g_pHostages = nullptr; } g_pHostages = new CHostageManager; @@ -1377,7 +1376,7 @@ void CHostageManager::ServerActivate() { m_hostageCount = 0; - CBaseEntity *pEntity = NULL; + CBaseEntity *pEntity = nullptr; while ((pEntity = UTIL_FindEntityByClassname(pEntity, "hostage_entity"))) { AddHostage((CHostage *)pEntity); @@ -1403,9 +1402,9 @@ void CHostageManager::ServerDeactivate() void CHostageManager::RestartRound() { - for (int i = 0; i < m_hostageCount; ++i) + for (int i = 0; i < m_hostageCount; i++) { - if (m_hostage[i]->m_improv != NULL) + if (m_hostage[i]->m_improv) { m_hostage[i]->m_improv->OnReset(); } @@ -1418,7 +1417,7 @@ void CHostageManager::AddHostage(CHostage *hostage) return; int i; - for (i = 0; i < m_hostageCount; ++i) + for (i = 0; i < m_hostageCount; i++) { if (m_hostage[i] == hostage) { @@ -1435,12 +1434,12 @@ void CHostageManager::AddHostage(CHostage *hostage) bool CHostageManager::IsNearbyHostageTalking(CHostageImprov *improv) { - for (int i = 0; i < m_hostageCount; ++i) + for (int i = 0; i < m_hostageCount; i++) { const float closeRange = 500.0f; const CHostageImprov *other = m_hostage[i]->m_improv; - if (other == NULL) + if (!other) continue; if (!other->IsAlive() || other == improv) @@ -1457,11 +1456,11 @@ bool CHostageManager::IsNearbyHostageTalking(CHostageImprov *improv) bool CHostageManager::IsNearbyHostageJumping(CHostageImprov *improv) { - for (int i = 0; i < m_hostageCount; ++i) + for (int i = 0; i < m_hostageCount; i++) { const CHostageImprov *other = m_hostage[i]->m_improv; - if (other == NULL) + if (!other) continue; if (!other->IsAlive() || other == improv) @@ -1479,11 +1478,10 @@ bool CHostageManager::IsNearbyHostageJumping(CHostageImprov *improv) void CHostageManager::OnEvent(GameEventType event, CBaseEntity *entity, CBaseEntity *other) { - for (int i = 0; i < m_hostageCount; ++i) + for (int i = 0; i < m_hostageCount; i++) { CHostageImprov *improv = m_hostage[ i ]->m_improv; - - if (improv != NULL) + if (improv) { improv->OnGameEvent(event, entity, other); } @@ -1533,7 +1531,7 @@ void SimpleChatter::Shuffle(ChatterSet *chatter) if (!chatter->needsShuffle) return; - for (int i = 1; i < chatter->count; ++i) + for (int i = 1; i < chatter->count; i++) { for (int j = i; j < chatter->count; j++) { @@ -1581,7 +1579,7 @@ float SimpleChatter::PlaySound(CBaseEntity *entity, HostageChatterType type) sound = GetSound(type, &duration); hostage = static_cast(entity); - if (sound == NULL) + if (!sound) { return 0; } @@ -1607,7 +1605,7 @@ float SimpleChatter::PlaySound(CBaseEntity *entity, HostageChatterType type) if (type == HOSTAGE_CHATTER_CALL_TO_RESCUER) { - if (TheBots != NULL) + if (TheBots) { TheBots->OnEvent(EVENT_HOSTAGE_CALLED_FOR_HELP, hostage); } diff --git a/regamedll/dlls/hostage/hostage.h b/regamedll/dlls/hostage/hostage.h index 741ced5b..6ec034e7 100644 --- a/regamedll/dlls/hostage/hostage.h +++ b/regamedll/dlls/hostage/hostage.h @@ -26,11 +26,7 @@ * */ -#ifndef HOSTAGE_H -#define HOSTAGE_H -#ifdef _WIN32 #pragma once -#endif #define MAX_NODES 100 #define MAX_HOSTAGES 12 @@ -298,5 +294,3 @@ inline bool AreImprovAllowed() void Hostage_RegisterCVars(); void InstallHostageManager(); - -#endif // HOSTAGE_H diff --git a/regamedll/dlls/hostage/hostage_improv.cpp b/regamedll/dlls/hostage/hostage_improv.cpp index 5413fb07..7bd18dcc 100644 --- a/regamedll/dlls/hostage/hostage_improv.cpp +++ b/regamedll/dlls/hostage/hostage_improv.cpp @@ -112,7 +112,7 @@ void CHostageImprov::MoveTowards(const Vector &pos, float deltaT) // TODO: Look ahead *along path* instead of straight line ClearPath(); - if ((m_lastKnownArea == NULL || !(m_lastKnownArea->GetAttributes() & NAV_NO_JUMP)) + if ((!m_lastKnownArea || !(m_lastKnownArea->GetAttributes() & NAV_NO_JUMP)) && !IsUsingLadder() && !IsJumping() && IsOnGround() && !IsCrouching()) { float ground; @@ -540,16 +540,16 @@ CBasePlayer *CHostageImprov::IsAnyPlayerLookingAtMe(int team, float cosTolerance } } - return NULL; + return nullptr; } CBasePlayer *CHostageImprov::GetClosestPlayerByTravelDistance(int team, float *range) const { - CBasePlayer *close = NULL; + CBasePlayer *close = nullptr; float closeRange = 9.9999998e10f; - if (GetLastKnownArea() == NULL) - return NULL; + if (!GetLastKnownArea()) + return nullptr; for (int i = 1; i <= gpGlobals->maxClients; ++i) { @@ -591,7 +591,7 @@ void CHostageImprov::OnReset() m_actualVel = Vector(0, 0, 0); m_checkNearbyTerroristTimer.Invalidate(); - m_lastKnownArea = NULL; + m_lastKnownArea = nullptr; m_hasKnownGoodPos = false; m_hasPriorKnownGoodPos = false; m_isTerroristNearby = false; @@ -1038,29 +1038,31 @@ void CHostageImprov::UpdateGrenadeReactions() if (m_grenadeTimer.IsElapsed()) { - CBaseEntity *entity = NULL; + CBaseEntity *pEntity = nullptr; const float watchGrenadeRadius = 500.0f; m_grenadeTimer.Start(RANDOM_FLOAT(0.4f, 0.6f)); - while ((entity = UTIL_FindEntityInSphere(entity, GetCentroid(), watchGrenadeRadius))) + while ((pEntity = UTIL_FindEntityInSphere(pEntity, GetCentroid(), watchGrenadeRadius))) { - CGrenade *grenade = static_cast(entity); + CGrenade *pGrenade = static_cast(pEntity); - if (!FClassnameIs(grenade->pev, "grenade") || grenade->m_SGSmoke > 1) + if (!FClassnameIs(pGrenade->pev, "grenade") || pGrenade->m_SGSmoke > 1) continue; - if (IsVisible(grenade->Center())) + if (IsVisible(pGrenade->Center())) { Chatter(HOSTAGE_CHATTER_SAW_HE_GRENADE); - if (grenade->pev->dmg > 50.0f) + if (pGrenade->pev->dmg > 50.0f) { m_idleState.OnInjury(); Frighten(TERRIFIED); } else + { Frighten(SCARED); + } m_grenadeTimer.Start(10); break; @@ -1480,22 +1482,22 @@ bool CHostageImprov::CanSeeRescueZone() const CBasePlayer *CHostageImprov::GetClosestVisiblePlayer(int team) { - CBasePlayer *close = NULL; + CBasePlayer *close = nullptr; float closeRangeSq = 1e8f; for (int i = 0; i < m_visiblePlayerCount; ++i) { - CBasePlayer *player = (CBasePlayer *)m_visiblePlayer[i]; + CBasePlayer *pPlayer = m_visiblePlayer[i]; - if (player == NULL || (team > 0 && player->m_iTeam != team)) + if (!pPlayer || (team > 0 && pPlayer->m_iTeam != team)) continue; - float_precision rangeSq = (GetCentroid() - player->pev->origin).LengthSquared(); + float_precision rangeSq = (GetCentroid() - pPlayer->pev->origin).LengthSquared(); if (rangeSq < closeRangeSq) { closeRangeSq = rangeSq; - close = player; + close = pPlayer; } } diff --git a/regamedll/dlls/hostage/hostage_improv.h b/regamedll/dlls/hostage/hostage_improv.h index 72896a8e..791d3ca0 100644 --- a/regamedll/dlls/hostage/hostage_improv.h +++ b/regamedll/dlls/hostage/hostage_improv.h @@ -26,11 +26,7 @@ * */ -#ifndef HOSTAGE_IMPROV_H -#define HOSTAGE_IMPROV_H -#ifdef _WIN32 #pragma once -#endif #include "hostage/hostage.h" #include "hostage/hostage_states.h" @@ -152,7 +148,7 @@ public: bool IsAtHome() const; bool CanSeeRescueZone() const; - CBaseEntity *GetFollowLeader() const { return m_followState.GetLeader(); } + CBasePlayer *GetFollowLeader() const { return m_followState.GetLeader(); } CBasePlayer *GetClosestVisiblePlayer(int team); float GetTimeSinceLastSawPlayer(int team); float GetTimeSinceLastInjury(); @@ -261,7 +257,7 @@ private: Vector m_jumpTarget; CountdownTimer m_clearPathTimer; bool m_traversingLadder; - EHANDLE m_visiblePlayer[MAX_CLIENTS]; + EntityHandle m_visiblePlayer[MAX_CLIENTS]; int m_visiblePlayerCount; CountdownTimer m_visionTimer; }; @@ -445,6 +441,7 @@ inline void CHostageImprov::ApplyForce2(float_precision x, float_precision y) m_vel.y += y; } #endif + inline void CHostageImprov::ResetJump() { if (m_hasJumpedIntoAir) @@ -459,5 +456,3 @@ inline void CHostageImprov::ResetJump() m_hasJumpedIntoAir = true; } } - -#endif // HOSTAGE_IMPROV_H diff --git a/regamedll/dlls/hostage/hostage_localnav.cpp b/regamedll/dlls/hostage/hostage_localnav.cpp index 3cc1a363..444099f7 100644 --- a/regamedll/dlls/hostage/hostage_localnav.cpp +++ b/regamedll/dlls/hostage/hostage_localnav.cpp @@ -20,7 +20,7 @@ int CLocalNav::tot_hostages; CLocalNav::CLocalNav(CHostage *pOwner) { m_pOwner = pOwner; - m_pTargetEnt = NULL; + m_pTargetEnt = nullptr; m_nodeArr = new localnode_t[MAX_NODES]; if (tot_hostages >= MAX_HOSTAGES_NAV) @@ -33,8 +33,11 @@ CLocalNav::CLocalNav(CHostage *pOwner) CLocalNav::~CLocalNav() { - delete[] m_nodeArr; - m_nodeArr = NULL; + if (m_nodeArr) + { + delete[] m_nodeArr; + m_nodeArr = nullptr; + } } node_index_t CLocalNav::AddNode(node_index_t nindexParent, Vector &vecLoc, int offsetX, int offsetY, byte bDepth) @@ -654,11 +657,8 @@ BOOL CLocalNav::StepJumpable(Vector &vecSource, Vector &vecDest, int fNoMonsters { Vector vecStepStart; Vector vecStepDest; - //BOOL fFwdTrace = FALSE; // unused? float flFwdFraction; float flJumpHeight = s_flStepSize + 1.0f; - //BOOL fJumpClear = FALSE; // unused? - //edict_t *hit = NULL; // unused? vecStepStart = vecSource; vecStepStart.z += flJumpHeight; @@ -747,11 +747,11 @@ BOOL CLocalNav::LadderHit(Vector &vecSource, Vector &vecDest, TraceResult &tr) void CLocalNav::Think() { EHANDLE hCallback; - static cvar_t *sv_stepsize = NULL; + static cvar_t *sv_stepsize = nullptr; if (gpGlobals->time >= flNextCvarCheck) { - if (sv_stepsize != NULL) + if (sv_stepsize) s_flStepSize = sv_stepsize->value; else { @@ -788,7 +788,7 @@ void CLocalNav::Think() tot_inqueue--; if (!tot_inqueue) { - hCallback = NULL; + hCallback = nullptr; break; } @@ -857,7 +857,7 @@ void CLocalNav::HostagePrethink() { for (int iCount = 0; iCount < tot_hostages; ++iCount) { - if (hostages[ iCount ] != NULL) + if (hostages[ iCount ]) { GetClassPtr((CHostage *)hostages[ iCount ]->pev)->PreThink(); } diff --git a/regamedll/dlls/hostage/hostage_localnav.h b/regamedll/dlls/hostage/hostage_localnav.h index ceb4dd7a..d3661afa 100644 --- a/regamedll/dlls/hostage/hostage_localnav.h +++ b/regamedll/dlls/hostage/hostage_localnav.h @@ -26,18 +26,14 @@ * */ -#ifndef HOSTAGE_LOCALNAV_H -#define HOSTAGE_LOCALNAV_H -#ifdef _WIN32 #pragma once -#endif -#define NODE_INVALID_EMPTY -1 +#define NODE_INVALID_EMPTY -1 -#define PATH_TRAVERSABLE_EMPTY 0 -#define PATH_TRAVERSABLE_SLOPE 1 -#define PATH_TRAVERSABLE_STEP 2 -#define PATH_TRAVERSABLE_STEPJUMPABLE 3 +#define PATH_TRAVERSABLE_EMPTY 0 +#define PATH_TRAVERSABLE_SLOPE 1 +#define PATH_TRAVERSABLE_STEP 2 +#define PATH_TRAVERSABLE_STEPJUMPABLE 3 typedef int node_index_t; @@ -64,10 +60,10 @@ public: void SetTargetEnt(CBaseEntity *pTarget) { - if (pTarget != NULL) + if (pTarget) m_pTargetEnt = pTarget->edict(); else - m_pTargetEnt = NULL; + m_pTargetEnt = nullptr; } node_index_t FindPath(Vector &vecStart, Vector &vecDest, float flTargetRadius, int fNoMonsters); @@ -116,5 +112,3 @@ private: node_index_t m_nindexAvailableNode; Vector m_vecStartingLoc; }; - -#endif // HOSTAGE_LOCALNAV_H diff --git a/regamedll/dlls/hostage/hostage_states.h b/regamedll/dlls/hostage/hostage_states.h index fb5faf55..9e4017ae 100644 --- a/regamedll/dlls/hostage/hostage_states.h +++ b/regamedll/dlls/hostage/hostage_states.h @@ -26,11 +26,7 @@ * */ -#ifndef HOSTAGE_STATES_H -#define HOSTAGE_STATES_H -#ifdef _WIN32 #pragma once -#endif class CHostageImprov; @@ -185,11 +181,11 @@ public: virtual void UpdateStationaryAnimation(CHostageImprov *improv); public: - void SetLeader(CBaseEntity *leader) { m_leader = leader; } - CBaseEntity *GetLeader() const { return m_leader; } + void SetLeader(CBasePlayer *leader) { m_leader = leader; } + CBasePlayer *GetLeader() const { return m_leader; } private: - mutable EHANDLE m_leader; + mutable EntityHandle m_leader; Vector m_lastLeaderPos; bool m_isWaiting; float m_stopRange; @@ -259,5 +255,3 @@ private: bool m_isHolding; CountdownTimer m_holdTimer; }; - -#endif // HOSTAGE_STATES_H diff --git a/regamedll/dlls/hostage/states/hostage_animate.cpp b/regamedll/dlls/hostage/states/hostage_animate.cpp index bbec560d..bce50a30 100644 --- a/regamedll/dlls/hostage/states/hostage_animate.cpp +++ b/regamedll/dlls/hostage/states/hostage_animate.cpp @@ -30,14 +30,16 @@ void HostageAnimateState::AddSequence(CHostageImprov *improv, const char *seqNam if (m_sequenceCount >= MAX_SEQUENCES) return; - if (seqName != NULL) + if (seqName) seqIndex = hostage->LookupSequence(seqName); else seqIndex = -1; m_sequence[m_sequenceCount].seqID = seqIndex; m_sequence[m_sequenceCount].holdTime = holdTime; - m_sequence[m_sequenceCount++].rate = rate; + m_sequence[m_sequenceCount].rate = rate; + + m_sequenceCount++; m_currentSequence = 0; StartSequence(improv, m_sequence); @@ -46,13 +48,15 @@ void HostageAnimateState::AddSequence(CHostageImprov *improv, const char *seqNam void HostageAnimateState::AddSequence(CHostageImprov *improv, int activity, float holdTime, float rate) { CHostage *hostage = improv->GetEntity(); - void *model = GET_MODEL_PTR(hostage->edict()); - if (model != NULL) + void *model = GET_MODEL_PTR(hostage->edict()); + if (model) { m_sequence[m_sequenceCount].seqID = LookupActivity(model, hostage->pev, activity); m_sequence[m_sequenceCount].holdTime = holdTime; - m_sequence[m_sequenceCount++].rate = rate; + m_sequence[m_sequenceCount].rate = rate; + + m_sequenceCount++; m_currentSequence = 0; } diff --git a/regamedll/dlls/hostage/states/hostage_escape.cpp b/regamedll/dlls/hostage/states/hostage_escape.cpp index 14c04c37..53f23242 100644 --- a/regamedll/dlls/hostage/states/hostage_escape.cpp +++ b/regamedll/dlls/hostage/states/hostage_escape.cpp @@ -18,14 +18,15 @@ void HostageEscapeToCoverState::OnEnter(CHostageImprov *improv) return; if (idx < path.GetSegmentCount() - 1) - ++idx; + idx++; Vector pathPos = path[idx]->pos; const float hidingRange = 450.0f; const Vector *spot = FindNearbyHidingSpot(improv->GetEntity(), &pathPos, TheNavAreaGrid.GetNearestNavArea(&pathPos), hidingRange); - - if (spot == NULL) + if (!spot) + { spot = &pathPos; + } m_spot = *spot; @@ -48,7 +49,7 @@ void HostageEscapeToCoverState::OnUpdate(CHostageImprov *improv) const float emergencyHidingRange = 300.0f; const Vector *spot = FindNearbyHidingSpot(improv->GetEntity(), &improv->GetFeet(), improv->GetLastKnownArea(), emergencyHidingRange); - if (spot == NULL) + if (!spot) { HostageEscapeState *escape = static_cast(GetParent()); escape->LookAround(); @@ -105,8 +106,7 @@ void HostageEscapeLookAroundState::OnExit(CHostageImprov *improv) void HostageEscapeState::OnEnter(CHostageImprov *improv) { const CCSBotManager::Zone *zone = TheCSBots()->GetRandomZone(); - - if (zone != NULL) + if (zone) { m_toCoverState.SetRescueGoal(zone->m_center); @@ -132,8 +132,7 @@ void HostageEscapeState::OnUpdate(CHostageImprov *improv) improv->Run(); CBasePlayer *player = improv->GetClosestVisiblePlayer(UNASSIGNED); - - if (player != NULL) + if (player) { if (player->m_iTeam != TERRORIST) { @@ -143,7 +142,7 @@ void HostageEscapeState::OnUpdate(CHostageImprov *improv) } const float farRange = 750.0f; - if ((player->pev->origin - improv->GetCentroid().IsLengthGreaterThan(farRange))) + if ((player->pev->origin - improv->GetCentroid()).IsLengthGreaterThan(farRange)) { improv->Frighten(CHostageImprov::NERVOUS); diff --git a/regamedll/dlls/hostage/states/hostage_follow.cpp b/regamedll/dlls/hostage/states/hostage_follow.cpp index ea16aca7..95a6f33d 100644 --- a/regamedll/dlls/hostage/states/hostage_follow.cpp +++ b/regamedll/dlls/hostage/states/hostage_follow.cpp @@ -24,7 +24,7 @@ void HostageFollowState::OnEnter(CHostageImprov *improv) void HostageFollowState::OnUpdate(CHostageImprov *improv) { // if we lost our leader, give up - if (m_leader == NULL) + if (!m_leader) { improv->Idle(); return; @@ -180,11 +180,10 @@ void HostageFollowState::OnUpdate(CHostageImprov *improv) improv->Stop(); - CBasePlayer *terrorist = improv->GetClosestVisiblePlayer(TERRORIST); - - if (terrorist != NULL) + CBasePlayer *pTerrorist = improv->GetClosestVisiblePlayer(TERRORIST); + if (pTerrorist) { - improv->LookAt(terrorist->EyePosition()); + improv->LookAt(pTerrorist->EyePosition()); } else { diff --git a/regamedll/dlls/hostage/states/hostage_idle.cpp b/regamedll/dlls/hostage/states/hostage_idle.cpp index 9f0b91a1..93e43261 100644 --- a/regamedll/dlls/hostage/states/hostage_idle.cpp +++ b/regamedll/dlls/hostage/states/hostage_idle.cpp @@ -31,9 +31,8 @@ void HostageIdleState::OnUpdate(CHostageImprov *improv) { m_mustFlee = false; - const Vector *spot = FindNearbyRetreatSpot(NULL, &improv->GetFeet(), improv->GetLastKnownArea(), 500.0, TERRORIST, false); - - if (spot != NULL) + const Vector *spot = FindNearbyRetreatSpot(nullptr, &improv->GetFeet(), improv->GetLastKnownArea(), 500.0, TERRORIST, false); + if (spot) { improv->MoveTo(*spot); improv->Run(); @@ -80,30 +79,30 @@ void HostageIdleState::OnUpdate(CHostageImprov *improv) return; } - CBasePlayer *rescuer = improv->GetClosestVisiblePlayer(CT); - CBasePlayer *captor = improv->GetClosestVisiblePlayer(TERRORIST); + CBasePlayer *pRescuer = improv->GetClosestVisiblePlayer(CT); + CBasePlayer *pCaptor = improv->GetClosestVisiblePlayer(TERRORIST); - if (rescuer != NULL) + if (pRescuer) { - improv->LookAt(rescuer->EyePosition()); + improv->LookAt(pRescuer->EyePosition()); improv->Stop(); - if (captor != NULL) + if (pCaptor) { const float attentionRange = 700.0f; - float rangeT = (improv->GetCentroid() - captor->pev->origin).Length(); + float rangeT = (improv->GetCentroid() - pCaptor->pev->origin).Length(); if (rangeT < attentionRange) { const float cosTolerance = 0.95f; if (improv->IsAnyPlayerLookingAtMe(TERRORIST, cosTolerance)) { - improv->LookAt(captor->EyePosition()); + improv->LookAt(pCaptor->EyePosition()); } else { TraceResult result; - UTIL_TraceLine(rescuer->pev->origin, captor->pev->origin, ignore_monsters, ignore_glass, captor->edict(), &result); + UTIL_TraceLine(pRescuer->pev->origin, pCaptor->pev->origin, ignore_monsters, ignore_glass, pCaptor->edict(), &result); if (result.flFraction != 1.0f && m_disagreeTimer.IsElapsed()) { @@ -118,9 +117,9 @@ void HostageIdleState::OnUpdate(CHostageImprov *improv) else if (!TheCSBots()->IsRoundOver() && m_askTimer.IsElapsed()) { const float closeRange = 200.0f; - if ((rescuer->pev->origin - improv->GetCentroid()).IsLengthLessThan(closeRange)) + if ((pRescuer->pev->origin - improv->GetCentroid()).IsLengthLessThan(closeRange)) { - if (improv->IsPlayerLookingAtMe(rescuer, 0.99)) + if (improv->IsPlayerLookingAtMe(pRescuer, 0.99)) { HostageChatterType say; if (improv->IsTerroristNearby()) @@ -139,12 +138,12 @@ void HostageIdleState::OnUpdate(CHostageImprov *improv) CHostage *hostage = improv->GetEntity(); const float waveRange = 250.0f; - if ((rescuer->pev->origin - hostage->pev->origin).IsLengthGreaterThan(waveRange)) + if ((pRescuer->pev->origin - hostage->pev->origin).IsLengthGreaterThan(waveRange)) { improv->Stop(); improv->Wave(); - improv->LookAt(rescuer->EyePosition()); + improv->LookAt(pRescuer->EyePosition()); improv->Chatter(HOSTAGE_CHATTER_CALL_TO_RESCUER, false); m_moveState = NotMoving; @@ -152,13 +151,13 @@ void HostageIdleState::OnUpdate(CHostageImprov *improv) } } } - else if (captor != NULL) + else if (pCaptor) { - improv->LookAt(captor->EyePosition()); + improv->LookAt(pCaptor->EyePosition()); improv->Stop(); const float closeRange = 200.0f; - if ((captor->pev->origin - improv->GetCentroid()).IsLengthLessThan(closeRange) && improv->IsPlayerLookingAtMe(captor, 0.99)) + if ((pCaptor->pev->origin - improv->GetCentroid()).IsLengthLessThan(closeRange) && improv->IsPlayerLookingAtMe(pCaptor, 0.99)) { if (!m_intimidatedTimer.HasStarted()) { @@ -248,5 +247,7 @@ void HostageIdleState::UpdateStationaryAnimation(CHostageImprov *improv) improv->UpdateIdleActivity(ACT_IDLE, ACT_IDLE_FIDGET); } else + { improv->UpdateIdleActivity(ACT_IDLE_SNEAKY, ACT_IDLE_SNEAKY_FIDGET); + } } diff --git a/regamedll/dlls/hostage/states/hostage_retreat.cpp b/regamedll/dlls/hostage/states/hostage_retreat.cpp index a6d14f4a..52cff04c 100644 --- a/regamedll/dlls/hostage/states/hostage_retreat.cpp +++ b/regamedll/dlls/hostage/states/hostage_retreat.cpp @@ -15,14 +15,13 @@ void HostageRetreatState::OnUpdate(CHostageImprov *improv) return; } - CBasePlayer *player = improv->GetClosestVisiblePlayer(UNASSIGNED); - - if (player != NULL) + CBasePlayer *pPlayer = improv->GetClosestVisiblePlayer(UNASSIGNED); + if (pPlayer) { const float farRange = 400.0f; - if ((player->pev->origin - improv->GetCentroid()).IsLengthGreaterThan(farRange)) + if ((pPlayer->pev->origin - improv->GetCentroid()).IsLengthGreaterThan(farRange)) { - if (player->m_iTeam == CT && !improv->IsScared()) + if (pPlayer->m_iTeam == CT && !improv->IsScared()) { improv->Stop(); improv->Idle(); diff --git a/regamedll/dlls/items.cpp b/regamedll/dlls/items.cpp index efd491aa..7948d45d 100644 --- a/regamedll/dlls/items.cpp +++ b/regamedll/dlls/items.cpp @@ -1,45 +1,45 @@ #include "precompiled.h" ItemInfo itemInfo[] = { - DEFINE_ITEMINFO(ITEM_SHIELDGUN, "weapon_shield"), - DEFINE_ITEMINFO(ITEM_P228, "weapon_p228"), - DEFINE_ITEMINFO(ITEM_GLOCK, "weapon_glock"), - DEFINE_ITEMINFO(ITEM_SCOUT, "weapon_scout"), - DEFINE_ITEMINFO(ITEM_HEGRENADE, "weapon_hegrenade"), - DEFINE_ITEMINFO(ITEM_XM1014, "weapon_xm1014"), - DEFINE_ITEMINFO(ITEM_C4, "weapon_c4"), - DEFINE_ITEMINFO(ITEM_MAC10, "weapon_mac10"), - DEFINE_ITEMINFO(ITEM_AUG, "weapon_aug"), - DEFINE_ITEMINFO(ITEM_SMOKEGRENADE, "weapon_smokegrenade"), - DEFINE_ITEMINFO(ITEM_ELITE, "weapon_elite"), - DEFINE_ITEMINFO(ITEM_FIVESEVEN, "weapon_fiveseven"), - DEFINE_ITEMINFO(ITEM_UMP45, "weapon_ump45"), - DEFINE_ITEMINFO(ITEM_SG550, "weapon_sg550"), - DEFINE_ITEMINFO(ITEM_GALIL, "weapon_galil"), - DEFINE_ITEMINFO(ITEM_FAMAS, "weapon_famas"), - DEFINE_ITEMINFO(ITEM_USP, "weapon_usp"), - DEFINE_ITEMINFO(ITEM_GLOCK18, "weapon_glock18"), - DEFINE_ITEMINFO(ITEM_AWP, "weapon_awp"), - DEFINE_ITEMINFO(ITEM_MP5N, "weapon_mp5navy"), - DEFINE_ITEMINFO(ITEM_M249, "weapon_m249"), - DEFINE_ITEMINFO(ITEM_M3, "weapon_m3"), - DEFINE_ITEMINFO(ITEM_M4A1, "weapon_m4a1"), - DEFINE_ITEMINFO(ITEM_TMP, "weapon_tmp"), - DEFINE_ITEMINFO(ITEM_G3SG1, "weapon_g3sg1"), - DEFINE_ITEMINFO(ITEM_FLASHBANG, "weapon_flashbang"), - DEFINE_ITEMINFO(ITEM_DEAGLE, "weapon_deagle"), - DEFINE_ITEMINFO(ITEM_SG552, "weapon_sg552"), - DEFINE_ITEMINFO(ITEM_AK47, "weapon_ak47"), - DEFINE_ITEMINFO(ITEM_KNIFE, "weapon_knife"), - DEFINE_ITEMINFO(ITEM_P90, "weapon_p90"), - DEFINE_ITEMINFO(ITEM_NVG, ""), - DEFINE_ITEMINFO(ITEM_DEFUSEKIT, "item_thighpack"), - DEFINE_ITEMINFO(ITEM_KEVLAR, "item_kevlar"), - DEFINE_ITEMINFO(ITEM_ASSAULT, "item_assaultsuit"), - DEFINE_ITEMINFO(ITEM_LONGJUMP, "item_longjump"), - DEFINE_ITEMINFO(ITEM_HEALTHKIT, "item_healthkit"), - DEFINE_ITEMINFO(ITEM_ANTIDOTE, "item_antidote"), - DEFINE_ITEMINFO(ITEM_BATTERY, "item_battery"), + DEFINE_ITEMINFO(ITEM_SHIELDGUN, "weapon_shield"), + DEFINE_ITEMINFO(ITEM_P228, "weapon_p228"), + DEFINE_ITEMINFO(ITEM_GLOCK, "weapon_glock"), + DEFINE_ITEMINFO(ITEM_SCOUT, "weapon_scout"), + DEFINE_ITEMINFO(ITEM_HEGRENADE, "weapon_hegrenade"), + DEFINE_ITEMINFO(ITEM_XM1014, "weapon_xm1014"), + DEFINE_ITEMINFO(ITEM_C4, "weapon_c4"), + DEFINE_ITEMINFO(ITEM_MAC10, "weapon_mac10"), + DEFINE_ITEMINFO(ITEM_AUG, "weapon_aug"), + DEFINE_ITEMINFO(ITEM_SMOKEGRENADE, "weapon_smokegrenade"), + DEFINE_ITEMINFO(ITEM_ELITE, "weapon_elite"), + DEFINE_ITEMINFO(ITEM_FIVESEVEN, "weapon_fiveseven"), + DEFINE_ITEMINFO(ITEM_UMP45, "weapon_ump45"), + DEFINE_ITEMINFO(ITEM_SG550, "weapon_sg550"), + DEFINE_ITEMINFO(ITEM_GALIL, "weapon_galil"), + DEFINE_ITEMINFO(ITEM_FAMAS, "weapon_famas"), + DEFINE_ITEMINFO(ITEM_USP, "weapon_usp"), + DEFINE_ITEMINFO(ITEM_GLOCK18, "weapon_glock18"), + DEFINE_ITEMINFO(ITEM_AWP, "weapon_awp"), + DEFINE_ITEMINFO(ITEM_MP5N, "weapon_mp5navy"), + DEFINE_ITEMINFO(ITEM_M249, "weapon_m249"), + DEFINE_ITEMINFO(ITEM_M3, "weapon_m3"), + DEFINE_ITEMINFO(ITEM_M4A1, "weapon_m4a1"), + DEFINE_ITEMINFO(ITEM_TMP, "weapon_tmp"), + DEFINE_ITEMINFO(ITEM_G3SG1, "weapon_g3sg1"), + DEFINE_ITEMINFO(ITEM_FLASHBANG, "weapon_flashbang"), + DEFINE_ITEMINFO(ITEM_DEAGLE, "weapon_deagle"), + DEFINE_ITEMINFO(ITEM_SG552, "weapon_sg552"), + DEFINE_ITEMINFO(ITEM_AK47, "weapon_ak47"), + DEFINE_ITEMINFO(ITEM_KNIFE, "weapon_knife"), + DEFINE_ITEMINFO(ITEM_P90, "weapon_p90"), + DEFINE_ITEMINFO(ITEM_NVG, ""), + DEFINE_ITEMINFO(ITEM_DEFUSEKIT, "item_thighpack"), + DEFINE_ITEMINFO(ITEM_KEVLAR, "item_kevlar"), + DEFINE_ITEMINFO(ITEM_ASSAULT, "item_assaultsuit"), + DEFINE_ITEMINFO(ITEM_LONGJUMP, "item_longjump"), + DEFINE_ITEMINFO(ITEM_HEALTHKIT, "item_healthkit"), + DEFINE_ITEMINFO(ITEM_ANTIDOTE, "item_antidote"), + DEFINE_ITEMINFO(ITEM_BATTERY, "item_battery"), }; // NOTE: useless thing @@ -54,12 +54,14 @@ void CWorldItem::KeyValue(KeyValueData *pkvd) pkvd->fHandled = TRUE; } else + { CBaseEntity::KeyValue(pkvd); + } } void CWorldItem::Spawn() { - CBaseEntity *pEntity = NULL; + CBaseEntity *pEntity = nullptr; switch (m_iType) { @@ -129,7 +131,9 @@ void CItem::ItemTouch(CBaseEntity *pOther) UTIL_Remove(this); } else if (gEvilImpulse101) + { UTIL_Remove(this); + } } CBaseEntity *CItem::Respawn() @@ -214,31 +218,41 @@ BOOL CItemBattery::MyTouch(CBasePlayer *pPlayer) if (pPlayer->pev->armorvalue < MAX_NORMAL_BATTERY && (pPlayer->pev->weapons & (1 << WEAPON_SUIT))) { - int pct; - char szcharge[64]; + auto armorValue = gSkillData.batteryCapacity; - pPlayer->pev->armorvalue += gSkillData.batteryCapacity; +#ifdef REGAMEDLL_FIXES + if (pev->armorvalue != 0.0f) { + armorValue = pev->armorvalue; + } + + if (pPlayer->m_iKevlar == ARMOR_NONE) + pPlayer->m_iKevlar = ARMOR_KEVLAR; +#endif + + pPlayer->pev->armorvalue += armorValue; pPlayer->pev->armorvalue = Q_min(pPlayer->pev->armorvalue, MAX_NORMAL_BATTERY); EMIT_SOUND(pPlayer->edict(), CHAN_ITEM, "items/gunpickup2.wav", VOL_NORM, ATTN_NORM); - MESSAGE_BEGIN(MSG_ONE, gmsgItemPickup, NULL, pPlayer->pev); + MESSAGE_BEGIN(MSG_ONE, gmsgItemPickup, nullptr, pPlayer->pev); WRITE_STRING(STRING(pev->classname)); MESSAGE_END(); // Suit reports new power level // For some reason this wasn't working in release build -- round it. - pct = int(float(pPlayer->pev->armorvalue * 100.0f) * (1.0f / MAX_NORMAL_BATTERY) + 0.5f); + int pct = int(float(pPlayer->pev->armorvalue * 100.0f) * (1.0f / MAX_NORMAL_BATTERY) + 0.5f); pct = (pct / 5); if (pct > 0) pct--; + char szcharge[64]; Q_sprintf(szcharge,"!HEV_%1dP", pct); - pPlayer->SetSuitUpdate(szcharge, FALSE, SUIT_NEXT_IN_30SEC); + pPlayer->SetSuitUpdate(szcharge, SUIT_SENTENCE, SUIT_NEXT_IN_30SEC); return TRUE; } + return FALSE; } @@ -263,7 +277,7 @@ BOOL CItemAntidote::MyTouch(CBasePlayer *pPlayer) return FALSE; #endif - pPlayer->SetSuitUpdate("!HEV_DET4", FALSE, SUIT_NEXT_IN_1MIN); + pPlayer->SetSuitUpdate("!HEV_DET4", SUIT_SENTENCE, SUIT_NEXT_IN_1MIN); pPlayer->m_rgItems[ ITEM_ID_ANTIDOTE ] += 1; return TRUE; @@ -322,7 +336,7 @@ BOOL CItemLongJump::MyTouch(CBasePlayer *pPlayer) pPlayer->m_fLongJump = TRUE; SET_PHYSICS_KEY_VALUE(pPlayer->edict(), "slj", "1"); - MESSAGE_BEGIN(MSG_ONE, gmsgItemPickup, NULL, pPlayer->pev); + MESSAGE_BEGIN(MSG_ONE, gmsgItemPickup, nullptr, pPlayer->pev); WRITE_STRING(STRING(pev->classname)); MESSAGE_END(); @@ -361,11 +375,11 @@ BOOL CItemKevlar::MyTouch(CBasePlayer *pPlayer) pPlayer->pev->armorvalue = 100; EMIT_SOUND(pPlayer->edict(), CHAN_ITEM, "items/ammopickup2.wav", VOL_NORM, ATTN_NORM); - MESSAGE_BEGIN(MSG_ONE, gmsgItemPickup, NULL, pPlayer->pev); + MESSAGE_BEGIN(MSG_ONE, gmsgItemPickup, nullptr, pPlayer->pev); WRITE_STRING(STRING(pev->classname)); MESSAGE_END(); - MESSAGE_BEGIN(MSG_ONE, gmsgArmorType, NULL, pPlayer->pev); + MESSAGE_BEGIN(MSG_ONE, gmsgArmorType, nullptr, pPlayer->pev); WRITE_BYTE(0); MESSAGE_END(); @@ -403,11 +417,11 @@ BOOL CItemAssaultSuit::MyTouch(CBasePlayer *pPlayer) EMIT_SOUND(pPlayer->edict(), CHAN_ITEM, "items/ammopickup2.wav", VOL_NORM, ATTN_NORM); - MESSAGE_BEGIN(MSG_ONE, gmsgItemPickup, NULL, pPlayer->pev); + MESSAGE_BEGIN(MSG_ONE, gmsgItemPickup, nullptr, pPlayer->pev); WRITE_STRING(STRING(pev->classname)); MESSAGE_END(); - MESSAGE_BEGIN(MSG_ONE, gmsgArmorType, NULL, pPlayer->pev); + MESSAGE_BEGIN(MSG_ONE, gmsgArmorType, nullptr, pPlayer->pev); WRITE_BYTE(1); MESSAGE_END(); @@ -448,7 +462,7 @@ BOOL CItemThighPack::MyTouch(CBasePlayer *pPlayer) ClientPrint(pPlayer->pev, HUD_PRINTCENTER, "#Got_defuser"); - MESSAGE_BEGIN(MSG_ONE, gmsgStatusIcon, NULL, pPlayer->pev); + MESSAGE_BEGIN(MSG_ONE, gmsgStatusIcon, nullptr, pPlayer->pev); WRITE_BYTE(STATUSICON_SHOW); WRITE_STRING("defuser"); WRITE_BYTE(0); diff --git a/regamedll/dlls/items.h b/regamedll/dlls/items.h index 4e1a06dd..f8eeb23a 100644 --- a/regamedll/dlls/items.h +++ b/regamedll/dlls/items.h @@ -25,6 +25,7 @@ * version. * */ + #pragma once #define DEFINE_ITEMINFO(id, classname)\ @@ -32,14 +33,14 @@ enum ItemRestType { - ITEM_TYPE_BUYING, // when a player buying items - ITEM_TYPE_TOUCHED, // when the player touches with a weaponbox or armoury_entity - ITEM_TYPE_EQUIPPED // when an entity game_player_equip gives item to player or default item's on player spawn + ITEM_TYPE_BUYING, // When a player is buying items + ITEM_TYPE_TOUCHED, // When the player touches with a weaponbox or armoury_entity + ITEM_TYPE_EQUIPPED // When an entity game_player_equip gives item to player or default items on player spawn }; // constant items -#define ITEM_ID_ANTIDOTE 2 -#define ITEM_ID_SECURITY 3 +#define ITEM_ID_ANTIDOTE 2 +#define ITEM_ID_SECURITY 3 enum ItemID { diff --git a/regamedll/dlls/lights.cpp b/regamedll/dlls/lights.cpp index 59fad171..c7f3eda8 100644 --- a/regamedll/dlls/lights.cpp +++ b/regamedll/dlls/lights.cpp @@ -35,7 +35,9 @@ void CLight::KeyValue(KeyValueData *pkvd) pkvd->fHandled = TRUE; } else + { CPointEntity::KeyValue(pkvd); + } } void CLight::Spawn() @@ -114,7 +116,7 @@ void CEnvLight::KeyValue(KeyValueData *pkvd) if (FStrEq(pkvd->szKeyName, "_light")) { int r, g, b, v, j; - j = Q_sscanf(pkvd->szValue, "%d %d %d %d\n", &r, &g, &b, &v); + j = sscanf(pkvd->szValue, "%d %d %d %d\n", &r, &g, &b, &v); if (j == 1) g = b = r; @@ -142,7 +144,9 @@ void CEnvLight::KeyValue(KeyValueData *pkvd) CVAR_SET_STRING("sv_skycolor_b", szColor); } else + { CLight::KeyValue(pkvd); + } } void CEnvLight::Spawn() diff --git a/regamedll/dlls/lights.h b/regamedll/dlls/lights.h index e3eb78b0..5f7f61d8 100644 --- a/regamedll/dlls/lights.h +++ b/regamedll/dlls/lights.h @@ -26,13 +26,9 @@ * */ -#ifndef LIGHT_H -#define LIGHT_H -#ifdef _WIN32 #pragma once -#endif -#define SF_LIGHT_START_OFF 1 +#define SF_LIGHT_START_OFF BIT(0) class CLight: public CPointEntity { @@ -58,5 +54,3 @@ public: virtual void Spawn(); virtual void KeyValue(KeyValueData *pkvd); }; - -#endif // LIGHT_H diff --git a/regamedll/dlls/mapinfo.h b/regamedll/dlls/mapinfo.h index 0686f525..bae405c1 100644 --- a/regamedll/dlls/mapinfo.h +++ b/regamedll/dlls/mapinfo.h @@ -28,6 +28,8 @@ #pragma once +const float MAX_BOMB_RADIUS = 2048.0f; + class CMapInfo: public CPointEntity { public: diff --git a/regamedll/dlls/maprules.cpp b/regamedll/dlls/maprules.cpp index 3c75e669..a2e2911c 100644 --- a/regamedll/dlls/maprules.cpp +++ b/regamedll/dlls/maprules.cpp @@ -44,20 +44,19 @@ void CRuleEntity::KeyValue(KeyValueData *pkvd) pkvd->fHandled = TRUE; } else + { CBaseEntity::KeyValue(pkvd); + } } -BOOL CRuleEntity::CanFireForActivator(CBaseEntity *pActivator) +bool CRuleEntity::CanFireForActivator(CBaseEntity *pActivator) { if (!FStringNull(m_iszMaster)) { - if (UTIL_IsMasterTriggered(m_iszMaster, pActivator)) - return TRUE; - else - return FALSE; + return UTIL_IsMasterTriggered(m_iszMaster, pActivator); } - return TRUE; + return true; } void CRulePointEntity::Spawn() @@ -88,12 +87,14 @@ void CGameScore::KeyValue(KeyValueData *pkvd) pkvd->fHandled = TRUE; } else + { CRulePointEntity::KeyValue(pkvd); + } } void CGameScore::Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) { - if (!CanFireForActivator(pActivator)) + if (!pActivator || !CanFireForActivator(pActivator)) return; // Only players can use this @@ -190,7 +191,9 @@ void CGameText::KeyValue(KeyValueData *pkvd) pkvd->fHandled = TRUE; } else + { CRulePointEntity::KeyValue(pkvd); + } } void CGameText::Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) @@ -201,14 +204,28 @@ void CGameText::Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useT if (MessageToAll()) { UTIL_HudMessageAll(m_textParms, MessageGet()); + ALERT(at_aiconsole, "HUD-MSG to all: \"%s\"\n", MessageGet()); } else { +#ifdef REGAMEDLL_FIXES + if (FNullEnt(pActivator)) + { + ALERT(at_console, "Game_text \"%s\" got no activator for activator-only message.\n", STRING(pev->targetname)); + } + else +#endif if (pActivator->IsNetClient()) { UTIL_HudMessage(pActivator, m_textParms, MessageGet()); + ALERT(at_aiconsole, "HUD-MSG to \"%s\": \"%s\"\n", STRING(pActivator->pev->netname), MessageGet()); } } + +#ifdef REGAMEDLL_FIXES + SUB_UseTargets(pActivator, USE_TOGGLE, 0); +#endif + } LINK_ENTITY_TO_CLASS(game_team_master, CGameTeamMaster, CCSGameTeamMaster) @@ -223,29 +240,30 @@ void CGameTeamMaster::KeyValue(KeyValueData *pkvd) else if (FStrEq(pkvd->szKeyName, "triggerstate")) { int type = Q_atoi(pkvd->szValue); - switch (type) { case 0: - triggerType = USE_OFF; + m_triggerType = USE_OFF; break; case 2: - triggerType = USE_TOGGLE; + m_triggerType = USE_TOGGLE; break; default: - triggerType = USE_ON; + m_triggerType = USE_ON; break; } pkvd->fHandled = TRUE; } else + { CRulePointEntity::KeyValue(pkvd); + } } void CGameTeamMaster::Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) { - if (!CanFireForActivator(pActivator)) + if (!pActivator || !CanFireForActivator(pActivator)) return; if (useType == USE_SET) @@ -257,9 +275,8 @@ void CGameTeamMaster::Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYP else { #ifdef REGAMEDLL_FIXES - CBasePlayer *pPlayer = static_cast(pActivator); - if (pPlayer->IsPlayer()) - m_teamIndex = pPlayer->m_iTeam; + if (pActivator->IsPlayer()) + m_teamIndex = ((CBasePlayer *)pActivator)->m_iTeam; else m_teamIndex = -1; #else @@ -272,7 +289,7 @@ void CGameTeamMaster::Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYP if (TeamMatch(pActivator)) { - SUB_UseTargets(pActivator, triggerType, value); + SUB_UseTargets(pActivator, m_triggerType, value); if (RemoveOnFire()) { @@ -302,18 +319,18 @@ const char *CGameTeamMaster::TeamID() #endif } -BOOL CGameTeamMaster::TeamMatch(CBaseEntity *pActivator) +bool CGameTeamMaster::TeamMatch(CBaseEntity *pActivator) { if (m_teamIndex < 0 && AnyTeam()) - return TRUE; + return true; if (!pActivator) - return FALSE; + return false; #ifdef REGAMEDLL_FIXES CBasePlayer *pPlayer = static_cast(pActivator); if (!pPlayer->IsPlayer()) - return FALSE; + return false; return pPlayer->m_iTeam == m_teamIndex; #else @@ -371,7 +388,42 @@ void CGamePlayerZone::KeyValue(KeyValueData *pkvd) pkvd->fHandled = TRUE; } else + { CRuleBrushEntity::KeyValue(pkvd); + } +} + +class CGameZonePlayerVolumeListener: public CPlayerInVolumeAdapter +{ +public: + CGameZonePlayerVolumeListener(CGamePlayerZone *pBrushEntity, CBaseEntity *pActivator, USE_TYPE useType, float value); + + void PlayerDetected(const bool fInVolume, CBasePlayer *pPlayer) override + { + string_t targetName = fInVolume ? m_iszInTarget : m_iszOutTarget; + if (FStringNull(targetName)) + return; + + FireTargets(STRING(targetName), pPlayer, m_hActivator, m_useType, m_value); + } + +private: + string_t m_iszInTarget; + string_t m_iszOutTarget; + + EHANDLE m_hActivator; + USE_TYPE m_useType; + float m_value; +}; + +CGameZonePlayerVolumeListener::CGameZonePlayerVolumeListener(CGamePlayerZone *pBrushEntity, CBaseEntity *pActivator, USE_TYPE useType, float value) +{ + m_iszInTarget = pBrushEntity->m_iszInTarget; + m_iszOutTarget = pBrushEntity->m_iszOutTarget; + + m_hActivator = pActivator; + m_useType = useType; + m_value = value; } void CGamePlayerZone::Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) @@ -382,7 +434,27 @@ void CGamePlayerZone::Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYP if (!CanFireForActivator(pActivator)) return; - for (int i = 1; i <= gpGlobals->maxClients; ++i) + CGameZonePlayerVolumeListener adapter(this, pActivator, useType, value); + UTIL_CountPlayersInBrushVolume(HasOnlyAlive(), this, playersInCount, playersOutCount, &adapter); + + if (!FStringNull(m_iszInCount)) + { + FireTargets(STRING(m_iszInCount), pActivator, this, USE_SET, playersInCount); + } + + if (!FStringNull(m_iszOutCount)) + { + FireTargets(STRING(m_iszOutCount), pActivator, this, USE_SET, playersOutCount); + } + +/* + int playersInCount = 0; + int playersOutCount = 0; + + if (!CanFireForActivator(pActivator)) + return; + + for (int i = 1; i <= gpGlobals->maxClients; i++) { CBaseEntity *pPlayer = UTIL_PlayerByIndex(i); @@ -402,7 +474,7 @@ void CGamePlayerZone::Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYP if (trace.fStartSolid) { - ++playersInCount; + playersInCount++; if (!FStringNull(m_iszInTarget)) { FireTargets(STRING(m_iszInTarget), pPlayer, pActivator, useType, value); @@ -410,7 +482,7 @@ void CGamePlayerZone::Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYP } else { - ++playersOutCount; + playersOutCount++; if (!FStringNull(m_iszOutTarget)) { FireTargets(STRING(m_iszOutTarget), pPlayer, pActivator, useType, value); @@ -427,14 +499,14 @@ void CGamePlayerZone::Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYP { FireTargets(STRING(m_iszOutCount), pActivator, this, USE_SET, playersOutCount); } - +*/ } LINK_ENTITY_TO_CLASS(game_player_hurt, CGamePlayerHurt, CCSGamePlayerHurt) void CGamePlayerHurt::Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) { - if (!CanFireForActivator(pActivator)) + if (!pActivator || !CanFireForActivator(pActivator)) return; if (pActivator->IsPlayer()) @@ -522,7 +594,7 @@ void CGamePlayerEquip::KeyValue(KeyValueData *pkvd) if (!pkvd->fHandled) { - for (int i = 0; i < MAX_EQUIP; ++i) + for (int i = 0; i < MAX_EQUIP; i++) { if (FStringNull(m_weaponNames[i])) { @@ -553,17 +625,11 @@ void CGamePlayerEquip::Touch(CBaseEntity *pOther) void CGamePlayerEquip::EquipPlayer(CBaseEntity *pEntity) { - CBasePlayer *pPlayer = NULL; - - if (pEntity->IsPlayer()) - { - pPlayer = static_cast(pEntity); - } - - if (!pPlayer) + if (!pEntity || !pEntity->IsPlayer()) return; - for (int i = 0; i < MAX_EQUIP; ++i) + CBasePlayer *pPlayer = static_cast(pEntity); + for (int i = 0; i < MAX_EQUIP; i++) { if (FStringNull(m_weaponNames[i])) break; @@ -574,7 +640,7 @@ void CGamePlayerEquip::EquipPlayer(CBaseEntity *pEntity) continue; #endif - for (int j = 0; j < m_weaponCount[i]; ++j) + for (int j = 0; j < m_weaponCount[i]; j++) { pPlayer->GiveNamedItemEx(STRING(m_weaponNames[i])); } @@ -590,15 +656,14 @@ LINK_ENTITY_TO_CLASS(game_player_team, CGamePlayerTeam, CCSGamePlayerTeam) const char *CGamePlayerTeam::TargetTeamName(const char *pszTargetName) { - CBaseEntity *pTeamEntity = NULL; - - while ((pTeamEntity = UTIL_FindEntityByTargetname(pTeamEntity, pszTargetName)) != NULL) + CBaseEntity *pTeamEntity = nullptr; + while ((pTeamEntity = UTIL_FindEntityByTargetname(pTeamEntity, pszTargetName))) { if (FClassnameIs(pTeamEntity->pev, "game_team_master")) return pTeamEntity->TeamID(); } - return NULL; + return nullptr; } void CGamePlayerTeam::Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) @@ -609,8 +674,7 @@ void CGamePlayerTeam::Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYP if (pActivator->IsPlayer()) { const char *pszTargetTeam = TargetTeamName(STRING(pev->target)); - - if (pszTargetTeam != NULL) + if (pszTargetTeam) { CBasePlayer *pPlayer = static_cast(pActivator); g_pGameRules->ChangePlayerTeam(pPlayer, pszTargetTeam, ShouldKillPlayer(), ShouldGibPlayer()); diff --git a/regamedll/dlls/maprules.h b/regamedll/dlls/maprules.h index 9f367f39..c977b577 100644 --- a/regamedll/dlls/maprules.h +++ b/regamedll/dlls/maprules.h @@ -26,36 +26,7 @@ * */ -#ifndef MAPRULES_H -#define MAPRULES_H -#ifdef _WIN32 #pragma once -#endif - -#define MAX_EQUIP 32 -#define SF_SCORE_NEGATIVE 0x0001 -#define SF_SCORE_TEAM 0x0002 - -#define SF_ENVTEXT_ALLPLAYERS 0x0001 - -#define SF_TEAMMASTER_FIREONCE 0x0001 -#define SF_TEAMMASTER_ANYTEAM 0x0002 - -#define SF_TEAMSET_FIREONCE 0x0001 -#define SF_TEAMSET_CLEARTEAM 0x0002 - -#define SF_PKILL_FIREONCE 0x0001 - -#define SF_GAMECOUNT_FIREONCE 0x0001 -#define SF_GAMECOUNT_RESET 0x0002 - -#define SF_GAMECOUNTSET_FIREONCE 0x0001 - -#define SF_PLAYEREQUIP_USEONLY 0x0001 - -#define SF_PTEAM_FIREONCE 0x0001 -#define SF_PTEAM_KILL 0x0002 -#define SF_PTEAM_GIB 0x0004 class CRuleEntity: public CBaseEntity { @@ -68,23 +39,23 @@ public: public: static TYPEDESCRIPTION IMPL(m_SaveData)[1]; - void SetMaster(int iszMaster) { m_iszMaster = iszMaster; } + void SetMaster(string_t iszMaster) { m_iszMaster = iszMaster; } protected: - BOOL CanFireForActivator(CBaseEntity *pActivator); + bool CanFireForActivator(CBaseEntity *pActivator); private: string_t m_iszMaster; }; -// CRulePointEntity -- base class for all rule "point" entities (not brushes) +// Base class for all rule "point" entities (not brushes) class CRulePointEntity: public CRuleEntity { public: virtual void Spawn(); }; -// CRuleBrushEntity -- base class for all rule "brush" entities (not brushes) +// Base class for all rule "brush" entities (not brushes) // Default behavior is to set up like a trigger, invisible, but keep the model for volume testing class CRuleBrushEntity: public CRuleEntity { @@ -92,10 +63,11 @@ public: virtual void Spawn(); }; -// CGameScore / game_score -- award points to player / team -// Points +/- total -// Flag: Allow negative scores SF_SCORE_NEGATIVE -// Flag: Award points to team in teamplay SF_SCORE_TEAM +#define SF_SCORE_NEGATIVE BIT(0) // Allow negative scores +#define SF_SCORE_TEAM BIT(1) // Award points to team in teamplay + +// Award points to player / team +// Points +/- total class CGameScore: public CRulePointEntity { public: @@ -105,21 +77,22 @@ public: public: int Points() const { return int(pev->frags); } - BOOL AllowNegativeScore() { return pev->spawnflags & SF_SCORE_NEGATIVE; } - BOOL AwardToTeam() const { return pev->spawnflags & SF_SCORE_TEAM; } + bool AllowNegativeScore() { return (pev->spawnflags & SF_SCORE_NEGATIVE) == SF_SCORE_NEGATIVE; } + bool AwardToTeam() const { return (pev->spawnflags & SF_SCORE_TEAM) == SF_SCORE_TEAM; } void SetPoints(int points) { pev->frags = points; } }; -// CGameEnd / game_end -- Ends the game in MP +// Ends the game in Multiplayer class CGameEnd: public CRulePointEntity { public: virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); }; -// CGameText / game_text -- NON-Localized HUD Message (use env_message to display a titles.txt message) -// Flag: All players SF_ENVTEXT_ALLPLAYERS +#define SF_ENVTEXT_ALLPLAYERS BIT(0) // Message will be displayed to all players instead of just the activator. + +// NON-Localized HUD Message (use env_message to display a titles.txt message) class CGameText: public CRulePointEntity { public: @@ -129,7 +102,7 @@ public: virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); public: - BOOL MessageToAll() const { return (pev->spawnflags & SF_ENVTEXT_ALLPLAYERS) == SF_ENVTEXT_ALLPLAYERS; } + bool MessageToAll() const { return (pev->spawnflags & SF_ENVTEXT_ALLPLAYERS) == SF_ENVTEXT_ALLPLAYERS; } void MessageSet(const char *pMessage) { pev->message = ALLOC_STRING(pMessage); } const char *MessageGet() const { return STRING(pev->message); } @@ -140,12 +113,13 @@ private: hudtextparms_t m_textParms; }; -// CGameTeamMaster / game_team_master -- "Masters" like multisource, but based on the team of the activator +#define SF_TEAMMASTER_FIREONCE BIT(0) // Remove on Fire +#define SF_TEAMMASTER_ANYTEAM BIT(1) // Any team until set? -- Any team can use this until the team is set (otherwise no teams can use it) + +// "Masters" like multisource, but based on the team of the activator // Only allows mastered entity to fire if the team matches my team // // team index (pulled from server team list "mp_teamlist" -// Flag: Remove on Fire -// Flag: Any team until set? -- Any team can use this until the team is set (otherwise no teams can use it) class CGameTeamMaster: public CRulePointEntity { public: @@ -156,31 +130,34 @@ public: virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); public: - BOOL RemoveOnFire() const { return (pev->spawnflags & SF_TEAMMASTER_FIREONCE) == SF_TEAMMASTER_FIREONCE; } - BOOL AnyTeam() const { return (pev->spawnflags & SF_TEAMMASTER_ANYTEAM) == SF_TEAMMASTER_ANYTEAM; } + bool RemoveOnFire() const { return (pev->spawnflags & SF_TEAMMASTER_FIREONCE) == SF_TEAMMASTER_FIREONCE; } + bool AnyTeam() const { return (pev->spawnflags & SF_TEAMMASTER_ANYTEAM) == SF_TEAMMASTER_ANYTEAM; } private: - BOOL TeamMatch(CBaseEntity *pActivator); + bool TeamMatch(CBaseEntity *pActivator); public: int m_teamIndex; - USE_TYPE triggerType; + USE_TYPE m_triggerType; }; -// CGameTeamSet / game_team_set -- Changes the team of the entity it targets to the activator's team -// Flag: Fire once -// Flag: Clear team -- Sets the team to "NONE" instead of activator +#define SF_TEAMSET_FIREONCE BIT(0) // Remove entity after firing. +#define SF_TEAMSET_CLEARTEAM BIT(1) // Clear team -- Sets the team to "NONE" instead of activator + +// Changes the team of the entity it targets to the activator's team class CGameTeamSet: public CRulePointEntity { public: virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); public: - BOOL RemoveOnFire() const { return (pev->spawnflags & SF_TEAMSET_FIREONCE) == SF_TEAMSET_FIREONCE; } - BOOL ShouldClearTeam() const { return (pev->spawnflags & SF_TEAMSET_CLEARTEAM) == SF_TEAMSET_CLEARTEAM; } + bool RemoveOnFire() const { return (pev->spawnflags & SF_TEAMSET_FIREONCE) == SF_TEAMSET_FIREONCE; } + bool ShouldClearTeam() const { return (pev->spawnflags & SF_TEAMSET_CLEARTEAM) == SF_TEAMSET_CLEARTEAM; } }; -// CGamePlayerZone / game_player_zone -- players in the zone fire my target when I'm fired +#define SF_GAME_PZONE_ONLY_ALIVE BIT(0) // Only Alive Players + +// Players in the zone fire my target when I'm fired // Needs master? class CGamePlayerZone: public CRuleBrushEntity { @@ -192,28 +169,34 @@ public: public: static TYPEDESCRIPTION IMPL(m_SaveData)[4]; + bool HasOnlyAlive() const { return (pev->spawnflags & SF_GAME_PZONE_ONLY_ALIVE) == SF_GAME_PZONE_ONLY_ALIVE; } private: + friend class CGameZonePlayerVolumeListener; + string_t m_iszInTarget; string_t m_iszOutTarget; string_t m_iszInCount; string_t m_iszOutCount; }; -// CGamePlayerHurt / game_player_hurt -- Damages the player who fires it -// Flag: Fire once +#define SF_PKILL_FIREONCE BIT(0) // Remove entity after firing. + +// Damages the player who fires it class CGamePlayerHurt: public CRulePointEntity { public: virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); public: - BOOL RemoveOnFire() const { return (pev->spawnflags & SF_PKILL_FIREONCE) == SF_PKILL_FIREONCE; } + bool RemoveOnFire() const { return (pev->spawnflags & SF_PKILL_FIREONCE) == SF_PKILL_FIREONCE; } }; -// CGameCounter / game_counter -- Counts events and fires target -// Flag: Fire once -// Flag: Reset on Fire +#define SF_GAMECOUNT_FIREONCE BIT(0) // Remove entity after firing. +#define SF_GAMECOUNT_RESET BIT(1) // Reset entity Initial value after fired. +#define SF_GAMECOUNT_OVER_LIMIT BIT(2) // Fire a target when initial value is higher than limit value. + +// Counts events and fires target class CGameCounter: public CRulePointEntity { public: @@ -221,8 +204,8 @@ public: virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); public: - BOOL RemoveOnFire() const { return (pev->spawnflags & SF_GAMECOUNT_FIREONCE) == SF_GAMECOUNT_FIREONCE; } - BOOL ResetOnFire() const { return (pev->spawnflags & SF_GAMECOUNT_RESET) == SF_GAMECOUNT_RESET; } + bool RemoveOnFire() const { return (pev->spawnflags & SF_GAMECOUNT_FIREONCE) == SF_GAMECOUNT_FIREONCE; } + bool ResetOnFire() const { return (pev->spawnflags & SF_GAMECOUNT_RESET) == SF_GAMECOUNT_RESET; } void CountUp() { pev->frags++; } void CountDown() { pev->frags--; } @@ -230,26 +213,39 @@ public: int CountValue() const { return int(pev->frags); } int LimitValue() const { return int(pev->health); } - BOOL HitLimit() const { return CountValue() == LimitValue(); } + bool HitLimit() const + { +#ifdef REGAMEDLL_FIXES + if (pev->spawnflags & SF_GAMECOUNT_OVER_LIMIT) { + return CountValue() >= LimitValue(); + } +#endif + + return CountValue() == LimitValue(); + } private: void SetCountValue(int value) { pev->frags = value; } void SetInitialValue(int value) { pev->dmg = value; } }; -// CGameCounterSet / game_counter_set -- Sets the counter's value -// Flag: Fire once +#define SF_GAMECOUNTSET_FIREONCE BIT(0) // Remove entity after firing. + +// Sets the counter's value class CGameCounterSet: public CRulePointEntity { public: virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); public: - BOOL RemoveOnFire() const { return (pev->spawnflags & SF_GAMECOUNTSET_FIREONCE) == SF_GAMECOUNTSET_FIREONCE; } + bool RemoveOnFire() const { return (pev->spawnflags & SF_GAMECOUNTSET_FIREONCE) == SF_GAMECOUNTSET_FIREONCE; } }; -// CGamePlayerEquip / game_playerequip -- Sets the default player equipment -// Flag: USE Only +#define MAX_EQUIP 32 +#define SF_PLAYEREQUIP_USEONLY BIT(0) // If set, the game_player_equip entity will not equip respawning players, + // but only react to direct triggering, equipping its activator. This makes its master obsolete. + +// Sets the default player equipment class CGamePlayerEquip: public CRulePointEntity { public: @@ -258,31 +254,29 @@ public: virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); public: - BOOL UseOnly() const { return (pev->spawnflags & SF_PLAYEREQUIP_USEONLY) == SF_PLAYEREQUIP_USEONLY; } + bool UseOnly() const { return (pev->spawnflags & SF_PLAYEREQUIP_USEONLY) == SF_PLAYEREQUIP_USEONLY; } private: void EquipPlayer(CBaseEntity *pPlayer); -public: - string_t m_weaponNames[ MAX_EQUIP ]; - int m_weaponCount[ MAX_EQUIP ]; + string_t m_weaponNames[MAX_EQUIP]; + int m_weaponCount[MAX_EQUIP]; }; -// CGamePlayerTeam / game_player_team -- Changes the team of the player who fired it -// Flag: Fire once -// Flag: Kill Player -// Flag: Gib Player +#define SF_PTEAM_FIREONCE BIT(0) // Remove entity after firing. +#define SF_PTEAM_KILL BIT(1) // Kill Player. +#define SF_PTEAM_GIB BIT(2) // Gib Player. + +// Changes the team of the player who fired it class CGamePlayerTeam: public CRulePointEntity { public: virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); private: - BOOL RemoveOnFire() const { return (pev->spawnflags & SF_PTEAM_FIREONCE) == SF_PTEAM_FIREONCE; } - BOOL ShouldKillPlayer() const { return (pev->spawnflags & SF_PTEAM_KILL) == SF_PTEAM_KILL; } - BOOL ShouldGibPlayer() const { return (pev->spawnflags & SF_PTEAM_GIB) == SF_PTEAM_GIB; } + bool RemoveOnFire() const { return (pev->spawnflags & SF_PTEAM_FIREONCE) == SF_PTEAM_FIREONCE; } + bool ShouldKillPlayer() const { return (pev->spawnflags & SF_PTEAM_KILL) == SF_PTEAM_KILL; } + bool ShouldGibPlayer() const { return (pev->spawnflags & SF_PTEAM_GIB) == SF_PTEAM_GIB; } const char *TargetTeamName(const char *pszTargetName); }; - -#endif // MAPRULES_H diff --git a/regamedll/dlls/monsterevent.h b/regamedll/dlls/monsterevent.h index 43529c30..ab022d5b 100644 --- a/regamedll/dlls/monsterevent.h +++ b/regamedll/dlls/monsterevent.h @@ -26,11 +26,7 @@ * */ -#ifndef MONSTEREVENT_H -#define MONSTEREVENT_H -#ifdef _WIN32 #pragma once -#endif typedef struct MonsterEvent_s { @@ -39,13 +35,11 @@ typedef struct MonsterEvent_s } MonsterEvent_t; -#define EVENT_SPECIFIC 0 -#define EVENT_SCRIPTED 1000 -#define EVENT_SHARED 2000 -#define EVENT_CLIENT 5000 +#define EVENT_SPECIFIC 0 +#define EVENT_SCRIPTED 1000 +#define EVENT_SHARED 2000 +#define EVENT_CLIENT 5000 -#define MONSTER_EVENT_BODYDROP_LIGHT 2001 -#define MONSTER_EVENT_BODYDROP_HEAVY 2002 -#define MONSTER_EVENT_SWISHSOUND 2010 - -#endif // MONSTEREVENT_H +#define MONSTER_EVENT_BODYDROP_LIGHT 2001 +#define MONSTER_EVENT_BODYDROP_HEAVY 2002 +#define MONSTER_EVENT_SWISHSOUND 2010 diff --git a/regamedll/dlls/monsters.h b/regamedll/dlls/monsters.h index 29079e08..75dd0091 100644 --- a/regamedll/dlls/monsters.h +++ b/regamedll/dlls/monsters.h @@ -26,74 +26,48 @@ * */ -#ifndef MONSTERS_H -#define MONSTERS_H -#ifdef _WIN32 #pragma once -#endif #include "skill.h" -#define LOCALMOVE_INVALID 0 // move is not possible -#define LOCALMOVE_INVALID_DONT_TRIANGULATE 1 // move is not possible, don't try to triangulate -#define LOCALMOVE_VALID 2 // move is possible +#define R_AL -2 // (ALLY) pals. Good alternative to R_NO when applicable. +#define R_FR -1 // (FEAR) will run +#define R_NO 0 // (NO RELATIONSHIP) disregard +#define R_DL 1 // (DISLIKE) will attack +#define R_HT 2 // (HATE) will attack this character instead of any visible DISLIKEd characters +#define R_NM 3 // (NEMESIS) A monster Will ALWAYS attack its nemsis, no matter what -#define SF_MONSTER_WAIT_TILL_SEEN 1 // spawnflag that makes monsters wait until player can see them before attacking. -#define SF_MONSTER_GAG 2 // no idle noises from this monster -#define SF_MONSTER_HITMONSTERCLIP 4 -#define SF_MONSTER_PRISONER 16 // monster won't attack anyone, no one will attacke him. +#define SF_MONSTER_WAIT_TILL_SEEN BIT(0) // spawnflag that makes monsters wait until player can see them before attacking. +#define SF_MONSTER_GAG BIT(1) // no idle noises from this monster +#define SF_MONSTER_HITMONSTERCLIP BIT(2) +#define SF_MONSTER_PRISONER BIT(4) // monster won't attack anyone, no one will attacks him. -#define SF_MONSTER_WAIT_FOR_SCRIPT 128 //spawnflag that makes monsters wait to check for attacking until the script is done or they've been attacked -#define SF_MONSTER_PREDISASTER 256 //this is a predisaster scientist or barney. Influences how they speak. -#define SF_MONSTER_FADECORPSE 512 // Fade out corpse after death -#define SF_MONSTER_FALL_TO_GROUND 0x80000000 +#define SF_MONSTER_WAIT_FOR_SCRIPT BIT(7) //spawnflag that makes monsters wait to check for attacking until the script is done or they've been attacked +#define SF_MONSTER_PREDISASTER BIT(8) //this is a predisaster scientist or barney. Influences how they speak. +#define SF_MONSTER_FADECORPSE BIT(9) // Fade out corpse after death +#define SF_MONSTER_FALL_TO_GROUND BIT(31) -#define SF_MONSTER_TURRET_AUTOACTIVATE 32 -#define SF_MONSTER_TURRET_STARTINACTIVE 64 -#define SF_MONSTER_WAIT_UNTIL_PROVOKED 64 // don't attack the player unless provoked +// These bits represent the monster's memory +#define MEMORY_CLEAR 0 +#define bits_MEMORY_PROVOKED BIT(0) // right now only used for houndeyes. +#define bits_MEMORY_INCOVER BIT(1) // monster knows it is in a covered position. +#define bits_MEMORY_SUSPICIOUS BIT(2) // Ally is suspicious of the player, and will move to provoked more easily +#define bits_MEMORY_PATH_FINISHED BIT(3) // Finished monster path (just used by big momma for now) +#define bits_MEMORY_ON_PATH BIT(4) // Moving on a path +#define bits_MEMORY_MOVE_FAILED BIT(5) // Movement has already failed +#define bits_MEMORY_FLINCHED BIT(6) // Has already flinched +#define bits_MEMORY_KILLED BIT(7) // HACKHACK -- remember that I've already called my Killed() +#define bits_MEMORY_CUSTOM4 BIT(28) // Monster-specific memory +#define bits_MEMORY_CUSTOM3 BIT(29) // Monster-specific memory +#define bits_MEMORY_CUSTOM2 BIT(30) // Monster-specific memory +#define bits_MEMORY_CUSTOM1 BIT(31) // Monster-specific memory -#define MOVE_START_TURN_DIST 64 // when this far away from moveGoal, start turning to face next goal -#define MOVE_STUCK_DIST 32 // if a monster can't step this far, it is stuck. +// MoveToOrigin stuff +#define MOVE_START_TURN_DIST 64 // when this far away from moveGoal, start turning to face next goal +#define MOVE_STUCK_DIST 32 // if a monster can't step this far, it is stuck. -#define MOVE_NORMAL 0 // normal move in the direction monster is facing -#define MOVE_STRAFE 1 // moves in direction specified, no matter which way monster is facing - -#define R_AL -2 // (ALLY) pals. Good alternative to R_NO when applicable. -#define R_FR -1 // (FEAR)will run -#define R_NO 0 // (NO RELATIONSHIP) disregard -#define R_DL 1 // (DISLIKE) will attack -#define R_HT 2 // (HATE)will attack this character instead of any visible DISLIKEd characters -#define R_NM 3 // (NEMESIS) A monster Will ALWAYS attack its nemsis, no matter what - -#define MEMORY_CLEAR 0 -#define bits_MEMORY_PROVOKED (1 << 0) // right now only used for houndeyes. -#define bits_MEMORY_INCOVER (1 << 1) // monster knows it is in a covered position. -#define bits_MEMORY_SUSPICIOUS (1 << 2) // Ally is suspicious of the player, and will move to provoked more easily -#define bits_MEMORY_PATH_FINISHED (1 << 3) // Finished monster path (just used by big momma for now) -#define bits_MEMORY_ON_PATH (1 << 4) // Moving on a path -#define bits_MEMORY_MOVE_FAILED (1 << 5) // Movement has already failed -#define bits_MEMORY_FLINCHED (1 << 6) // Has already flinched -#define bits_MEMORY_KILLED (1 << 7) // HACKHACK -- remember that I've already called my Killed() -#define bits_MEMORY_CUSTOM4 (1 << 28) // Monster-specific memory -#define bits_MEMORY_CUSTOM3 (1 << 29) // Monster-specific memory -#define bits_MEMORY_CUSTOM2 (1 << 30) // Monster-specific memory -#define bits_MEMORY_CUSTOM1 (1 << 31) // Monster-specific memory - -enum -{ - AITRIGGER_NONE = 0, - AITRIGGER_SEEPLAYER_ANGRY_AT_PLAYER, - AITRIGGER_TAKEDAMAGE, - AITRIGGER_HALFHEALTH, - AITRIGGER_DEATH, - AITRIGGER_SQUADMEMBERDIE, - AITRIGGER_SQUADLEADERDIE, - AITRIGGER_HEARWORLD, - AITRIGGER_HEARPLAYER, - AITRIGGER_HEARCOMBAT, - AITRIGGER_SEEPLAYER_UNCONDITIONAL, - AITRIGGER_SEEPLAYER_NOT_IN_COMBAT, -}; +#define MOVE_NORMAL 0 // normal move in the direction monster is facing +#define MOVE_STRAFE 1 // moves in direction specified, no matter which way monster is facing enum HitBoxGroup { @@ -108,45 +82,3 @@ enum HitBoxGroup HITGROUP_SHIELD, NUM_HITGROUPS, }; - -class CGib: public CBaseEntity -{ -public: - virtual int ObjectCaps() { return (CBaseEntity::ObjectCaps() & ~FCAP_ACROSS_TRANSITION) | FCAP_DONT_SAVE; } - -public: - void Spawn(const char *szGibModel); - void EXPORT BounceGibTouch(CBaseEntity *pOther); - void EXPORT StickyGibTouch(CBaseEntity *pOther); - void EXPORT WaitTillLand(); - void LimitVelocity(); - -public: - static void SpawnHeadGib(entvars_t *pevVictim); - static void SpawnRandomGibs(entvars_t *pevVictim, int cGibs, int human); - static void SpawnStickyGibs(entvars_t *pevVictim, Vector vecOrigin, int cGibs); - -public: - int m_bloodColor; - int m_cBloodDecals; - int m_material; - float m_lifeTime; -}; - -#define CUSTOM_SCHEDULES\ - virtual Schedule_t *ScheduleFromName(const char *pName);\ - static Schedule_t *m_scheduleList[]; - -#define DEFINE_CUSTOM_SCHEDULES(derivedClass)\ - Schedule_t *derivedClass::m_scheduleList[] = - -#define IMPLEMENT_CUSTOM_SCHEDULES(derivedClass, baseClass)\ - Schedule_t *derivedClass::ScheduleFromName(const char *pName)\ - {\ - Schedule_t *pSchedule = ScheduleInList(pName, m_scheduleList, ARRAYSIZE(m_scheduleList));\ - if (!pSchedule)\ - return baseClass::ScheduleFromName(pName);\ - return pSchedule;\ - } - -#endif // MONSTERS_H diff --git a/regamedll/dlls/mortar.cpp b/regamedll/dlls/mortar.cpp index 0f907e67..a70c31bc 100644 --- a/regamedll/dlls/mortar.cpp +++ b/regamedll/dlls/mortar.cpp @@ -87,7 +87,7 @@ void CFuncMortarField::FieldUse(CBaseEntity *pActivator, CBaseEntity *pCaller, U // Trigger Activator case 1: { - if (pActivator != NULL) + if (pActivator) { vecStart.x = pActivator->pev->origin.x; vecStart.y = pActivator->pev->origin.y; @@ -101,18 +101,18 @@ void CFuncMortarField::FieldUse(CBaseEntity *pActivator, CBaseEntity *pCaller, U if (!FStringNull(m_iszXController)) { - pController = UTIL_FindEntityByTargetname(NULL, STRING(m_iszXController)); + pController = UTIL_FindEntityByTargetname(nullptr, STRING(m_iszXController)); - if (pController != NULL) + if (pController) { vecStart.x = pev->mins.x + pController->pev->ideal_yaw * pev->size.x; } } if (!FStringNull(m_iszYController)) { - pController = UTIL_FindEntityByTargetname(NULL, STRING(m_iszYController)); + pController = UTIL_FindEntityByTargetname(nullptr, STRING(m_iszYController)); - if (pController != NULL) + if (pController) { vecStart.y = pev->mins.y + pController->pev->ideal_yaw * pev->size.y; } @@ -126,7 +126,7 @@ void CFuncMortarField::FieldUse(CBaseEntity *pActivator, CBaseEntity *pCaller, U EMIT_SOUND_DYN(ENT(pev), CHAN_VOICE, "weapons/mortar.wav", VOL_NORM, ATTN_NONE, 0, pitch); float t = 2.5f; - for (int i = 0; i < m_iCount; ++i) + for (int i = 0; i < m_iCount; i++) { Vector vecSpot = vecStart; vecSpot.x += RANDOM_FLOAT(-m_flSpread, m_flSpread); @@ -135,7 +135,7 @@ void CFuncMortarField::FieldUse(CBaseEntity *pActivator, CBaseEntity *pCaller, U TraceResult tr; UTIL_TraceLine(vecSpot, vecSpot + Vector(0, 0, -1) * 4096, ignore_monsters, ENT(pev), &tr); - edict_t *pentOwner = NULL; + edict_t *pentOwner = nullptr; if (pActivator) { pentOwner = pActivator->edict(); @@ -183,16 +183,16 @@ void CMortar::MortarExplode() WRITE_COORD(pev->origin.y); WRITE_COORD(pev->origin.z + 1024); WRITE_SHORT(m_spriteTexture); - WRITE_BYTE(0); // framerate - WRITE_BYTE(0); // framerate - WRITE_BYTE(1); // life - WRITE_BYTE(40); // width - WRITE_BYTE(0); // noise - WRITE_BYTE(255); // r, g, b - WRITE_BYTE(160); // r, g, b - WRITE_BYTE(100); // r, g, b - WRITE_BYTE(128); // brightness - WRITE_BYTE(0); // speed + WRITE_BYTE(0); // framerate + WRITE_BYTE(0); // framerate + WRITE_BYTE(1); // life + WRITE_BYTE(40); // width + WRITE_BYTE(0); // noise + WRITE_BYTE(255); // r, g, b + WRITE_BYTE(160); // r, g, b + WRITE_BYTE(100); // r, g, b + WRITE_BYTE(128); // brightness + WRITE_BYTE(0); // speed MESSAGE_END(); TraceResult tr; diff --git a/regamedll/dlls/mortar.h b/regamedll/dlls/mortar.h index f1feca54..b839d427 100644 --- a/regamedll/dlls/mortar.h +++ b/regamedll/dlls/mortar.h @@ -26,11 +26,7 @@ * */ -#ifndef MORTAR_H -#define MORTAR_H -#ifdef _WIN32 #pragma once -#endif class CFuncMortarField: public CBaseToggle { @@ -69,5 +65,3 @@ public: public: int m_spriteTexture; }; - -#endif // MORTAR_H diff --git a/regamedll/dlls/mpstubb.cpp b/regamedll/dlls/mpstubb.cpp deleted file mode 100644 index 94608ef0..00000000 --- a/regamedll/dlls/mpstubb.cpp +++ /dev/null @@ -1,263 +0,0 @@ -#include "precompiled.h" - -CGraph WorldGraph; - -void CGraph::InitGraph() -{ - ; -} - -int CGraph::FLoadGraph(char *szMapName) -{ - return 0; -} - -int CGraph::AllocNodes() -{ - return 0; -} - -int CGraph::CheckNODFile(char *szMapName) -{ - return 0; -} - -int CGraph::FSetGraphPointers() -{ - return 0; -} - -void CGraph::ShowNodeConnections(int iNode) -{ - ; -} - -int CGraph::FindNearestNode(const Vector &vecOrigin, int afNodeTypes) -{ - return 0; -} - -int CGraph::FindNearestNode(const Vector &vecOrigin, CBaseEntity *pEntity) -{ - return 0; -} - -float CBaseMonster::ChangeYaw(int speed) -{ - return 0.0f; -} - -void CBaseMonster::MakeIdealYaw(Vector vecTarget) -{ - ; -} - -NOXREF void CBaseMonster::CorpseFallThink() -{ - if (pev->flags & FL_ONGROUND) - { - SetThink(NULL); - SetSequenceBox(); - - // link into world. - UTIL_SetOrigin(pev, pev->origin); - } - else - pev->nextthink = gpGlobals->time + 0.1f; -} - -void CBaseMonster::MonsterInitDead() -{ - InitBoneControllers(); - - pev->solid = SOLID_BBOX; - pev->movetype = MOVETYPE_TOSS; - - pev->frame = 0; - ResetSequenceInfo(); - pev->framerate = 0; - - pev->max_health = pev->health; - pev->deadflag = DEAD_DEAD; - - UTIL_SetSize(pev, g_vecZero, g_vecZero); - UTIL_SetOrigin(pev, pev->origin); - - BecomeDead(); - SetThink(&CBaseEntity::SUB_Remove); - pev->nextthink = gpGlobals->time + 0.5f; -} - -BOOL CBaseMonster::ShouldFadeOnDeath() -{ - return FALSE; -} - -BOOL CBaseMonster::FCheckAITrigger() -{ - return FALSE; -} - -void CBaseMonster::KeyValue(KeyValueData *pkvd) -{ - CBaseToggle::KeyValue(pkvd); -} - -int CBaseMonster::IRelationship(CBaseEntity *pTarget) -{ - static int const iEnemy[14][14] = - { - // NONE MACH PLYR HPASS HMIL AMIL APASS AMONST APREY APRED INSECT PLRALY PBWPN ABWPN - { R_NO, R_NO, R_NO, R_NO, R_NO, R_NO, R_NO, R_NO, R_NO, R_NO, R_NO, R_NO, R_NO, R_NO }, // NONE - { R_NO, R_NO, R_DL, R_DL, R_NO, R_DL, R_DL, R_DL, R_DL, R_DL, R_NO, R_DL, R_DL, R_DL }, // MACHINE - { R_NO, R_DL, R_NO, R_NO, R_DL, R_DL, R_DL, R_DL, R_DL, R_DL, R_NO, R_NO, R_DL, R_DL }, // PLAYER - { R_NO, R_NO, R_AL, R_AL, R_HT, R_FR, R_NO, R_HT, R_DL, R_FR, R_NO, R_AL, R_NO, R_NO }, // HUMANPASSIVE - { R_NO, R_NO, R_HT, R_DL, R_NO, R_HT, R_DL, R_DL, R_DL, R_DL, R_NO, R_HT, R_NO, R_NO }, // HUMANMILITAR - { R_NO, R_DL, R_HT, R_DL, R_HT, R_NO, R_NO, R_NO, R_NO, R_NO, R_NO, R_DL, R_NO, R_NO }, // ALIENMILITAR - { R_NO, R_NO, R_NO, R_NO, R_NO, R_NO, R_NO, R_NO, R_NO, R_NO, R_NO, R_NO, R_NO, R_NO }, // ALIENPASSIVE - { R_NO, R_DL, R_DL, R_DL, R_DL, R_NO, R_NO, R_NO, R_NO, R_NO, R_NO, R_DL, R_NO, R_NO }, // ALIENMONSTER - { R_NO, R_NO, R_DL, R_DL, R_DL, R_NO, R_NO, R_NO, R_NO, R_FR, R_NO, R_DL, R_NO, R_NO }, // ALIENPREY - { R_NO, R_NO, R_DL, R_DL, R_DL, R_NO, R_NO, R_NO, R_HT, R_DL, R_NO, R_DL, R_NO, R_NO }, // ALIENPREDATO - { R_FR, R_FR, R_FR, R_FR, R_FR, R_NO, R_FR, R_FR, R_FR, R_FR, R_NO, R_FR, R_NO, R_NO }, // INSECT - { R_NO, R_DL, R_AL, R_AL, R_DL, R_DL, R_DL, R_DL, R_DL, R_DL, R_NO, R_NO, R_NO, R_NO }, // PLAYERALLY - { R_NO, R_NO, R_DL, R_DL, R_DL, R_DL, R_DL, R_DL, R_DL, R_DL, R_NO, R_DL, R_NO, R_DL }, // PBIOWEAPON - { R_NO, R_NO, R_DL, R_DL, R_DL, R_AL, R_NO, R_DL, R_DL, R_NO, R_NO, R_DL, R_DL, R_NO } // ABIOWEAPON - }; - - return iEnemy[ Classify() ][ pTarget->Classify() ]; -} - -// Look - Base class monster function to find enemies or -// food by sight. iDistance is distance (in units) that the -// monster can see. -// -// Sets the sight bits of the m_afConditions mask to indicate -// which types of entities were sighted. -// Function also sets the Looker's m_pLink -// to the head of a link list that contains all visible ents. -// (linked via each ent's m_pLink field) -void CBaseMonster::Look(int iDistance) -{ - int iSighted = 0; - - // DON'T let visibility information from last frame sit around! - ClearConditions(bits_COND_SEE_HATE | bits_COND_SEE_DISLIKE | bits_COND_SEE_ENEMY | bits_COND_SEE_FEAR | bits_COND_SEE_NEMESIS | bits_COND_SEE_CLIENT); - - m_pLink = NULL; - - // the current visible entity that we're dealing with - CBaseEntity *pSightEnt = NULL; - CBaseEntity *pList[100]; - - Vector delta(iDistance, iDistance, iDistance); - - // Find only monsters/clients in box, NOT limited to PVS - int count = UTIL_EntitiesInBox(pList, ARRAYSIZE(pList), pev->origin - delta, pev->origin + delta, (FL_CLIENT | FL_MONSTER)); - for (int i = 0; i < count; ++i) - { - pSightEnt = pList[i]; - if (pSightEnt != this && pSightEnt->pev->health > 0) - { - // the looker will want to consider this entity - // don't check anything else about an entity that can't be seen, or an entity that you don't care about. - if (IRelationship(pSightEnt) != R_NO && FInViewCone(pSightEnt) && !(pSightEnt->pev->flags & FL_NOTARGET) && FVisible(pSightEnt)) - { - if (pSightEnt->IsPlayer()) - { - // if we see a client, remember that (mostly for scripted AI) - iSighted |= bits_COND_SEE_CLIENT; - } - - pSightEnt->m_pLink = m_pLink; - m_pLink = pSightEnt; - - if (pSightEnt == m_hEnemy) - { - // we know this ent is visible, so if it also happens to be our enemy, store that now. - iSighted |= bits_COND_SEE_ENEMY; - } - - // don't add the Enemy's relationship to the conditions. We only want to worry about conditions when - // we see monsters other than the Enemy. - switch (IRelationship (pSightEnt)) - { - case R_NM: - iSighted |= bits_COND_SEE_NEMESIS; - break; - case R_HT: - iSighted |= bits_COND_SEE_HATE; - break; - case R_DL: - iSighted |= bits_COND_SEE_DISLIKE; - break; - case R_FR: - iSighted |= bits_COND_SEE_FEAR; - break; - case R_AL: - break; - default: - ALERT(at_aiconsole, "%s can't assess %s\n", STRING(pev->classname), STRING(pSightEnt->pev->classname)); - break; - } - } - } - } - - SetConditions(iSighted); -} - -// BestVisibleEnemy - this functions searches the link -// list whose head is the caller's m_pLink field, and returns -// a pointer to the enemy entity in that list that is nearest the -// caller. -// -// UNDONE: currently, this only returns the closest enemy. -// we'll want to consider distance, relationship, attack types, back turned, etc. -CBaseEntity *CBaseMonster::BestVisibleEnemy() -{ - CBaseEntity *pReturn; - CBaseEntity *pNextEnt; - int iNearest; - int iDist; - int iBestRelationship; - - // so first visible entity will become the closest. - iNearest = 8192; - pNextEnt = m_pLink; - pReturn = NULL; - iBestRelationship = R_NO; - - while (pNextEnt != NULL) - { - if (pNextEnt->IsAlive()) - { - if (IRelationship(pNextEnt) > iBestRelationship) - { - // this entity is disliked MORE than the entity that we - // currently think is the best visible enemy. No need to do - // a distance check, just get mad at this one for now. - iBestRelationship = IRelationship(pNextEnt); - iNearest = (pNextEnt->pev->origin - pev->origin).Length(); - pReturn = pNextEnt; - } - else if (IRelationship(pNextEnt) == iBestRelationship) - { - // this entity is disliked just as much as the entity that - // we currently think is the best visible enemy, so we only - // get mad at it if it is closer. - iDist = (pNextEnt->pev->origin - pev->origin).Length(); - - if (iDist <= iNearest) - { - iNearest = iDist; - iBestRelationship = IRelationship(pNextEnt); - pReturn = pNextEnt; - } - } - } - - pNextEnt = pNextEnt->m_pLink; - } - - return pReturn; -} diff --git a/regamedll/dlls/multiplay_gamerules.cpp b/regamedll/dlls/multiplay_gamerules.cpp index 535f2baa..069f942b 100644 --- a/regamedll/dlls/multiplay_gamerules.cpp +++ b/regamedll/dlls/multiplay_gamerules.cpp @@ -5,8 +5,7 @@ */ #ifndef HOOK_GAMEDLL -static char mp_com_token[ 1500 ]; -cvar_t *sv_clienttrace = NULL; +cvar_t *sv_clienttrace = nullptr; #endif @@ -14,33 +13,33 @@ CCStrikeGameMgrHelper g_GameMgrHelper; CHalfLifeMultiplay *g_pMPGameRules = nullptr; RewardAccount CHalfLifeMultiplay::m_rgRewardAccountRules[RR_END]; RewardAccount m_rgRewardAccountRules_default[] = { - REWARD_CTS_WIN, // RR_CTS_WIN - REWARD_TERRORISTS_WIN, // RR_TERRORISTS_WIN - REWARD_TARGET_BOMB, // RR_TARGET_BOMB - REWARD_VIP_ESCAPED, // RR_VIP_ESCAPED - REWARD_VIP_ASSASSINATED, // RR_VIP_ASSASSINATED - REWARD_TERRORISTS_ESCAPED, // RR_TERRORISTS_ESCAPED - REWARD_CTS_PREVENT_ESCAPE, // RR_CTS_PREVENT_ESCAPE - REWARD_ESCAPING_TERRORISTS_NEUTRALIZED, // RR_ESCAPING_TERRORISTS_NEUTRALIZED - REWARD_BOMB_DEFUSED, // RR_BOMB_DEFUSED - REWARD_BOMB_PLANTED, // RR_BOMB_PLANTED - REWARD_BOMB_EXPLODED, // RR_BOMB_EXPLODED - REWARD_ALL_HOSTAGES_RESCUED, // RR_ALL_HOSTAGES_RESCUED - REWARD_TARGET_BOMB_SAVED, // RR_TARGET_BOMB_SAVED - REWARD_HOSTAGE_NOT_RESCUED, // RR_HOSTAGE_NOT_RESCUED - REWARD_VIP_NOT_ESCAPED, // RR_VIP_NOT_ESCAPED - REWARD_LOSER_BONUS_DEFAULT, // RR_LOSER_BONUS_DEFAULT - REWARD_LOSER_BONUS_MIN, // RR_LOSER_BONUS_MIN - REWARD_LOSER_BONUS_MAX, // RR_LOSER_BONUS_MAX - REWARD_LOSER_BONUS_ADD, // RR_LOSER_BONUS_ADD - REWARD_RESCUED_HOSTAGE, // RR_RESCUED_HOSTAGE - REWARD_TOOK_HOSTAGE_ACC, // RR_TOOK_HOSTAGE_ACC - REWARD_TOOK_HOSTAGE, // RR_TOOK_HOSTAGE + REWARD_CTS_WIN, // RR_CTS_WIN + REWARD_TERRORISTS_WIN, // RR_TERRORISTS_WIN + REWARD_TARGET_BOMB, // RR_TARGET_BOMB + REWARD_VIP_ESCAPED, // RR_VIP_ESCAPED + REWARD_VIP_ASSASSINATED, // RR_VIP_ASSASSINATED + REWARD_TERRORISTS_ESCAPED, // RR_TERRORISTS_ESCAPED + REWARD_CTS_PREVENT_ESCAPE, // RR_CTS_PREVENT_ESCAPE + REWARD_ESCAPING_TERRORISTS_NEUTRALIZED, // RR_ESCAPING_TERRORISTS_NEUTRALIZED + REWARD_BOMB_DEFUSED, // RR_BOMB_DEFUSED + REWARD_BOMB_PLANTED, // RR_BOMB_PLANTED + REWARD_BOMB_EXPLODED, // RR_BOMB_EXPLODED + REWARD_ALL_HOSTAGES_RESCUED, // RR_ALL_HOSTAGES_RESCUED + REWARD_TARGET_BOMB_SAVED, // RR_TARGET_BOMB_SAVED + REWARD_HOSTAGE_NOT_RESCUED, // RR_HOSTAGE_NOT_RESCUED + REWARD_VIP_NOT_ESCAPED, // RR_VIP_NOT_ESCAPED + REWARD_LOSER_BONUS_DEFAULT, // RR_LOSER_BONUS_DEFAULT + REWARD_LOSER_BONUS_MIN, // RR_LOSER_BONUS_MIN + REWARD_LOSER_BONUS_MAX, // RR_LOSER_BONUS_MAX + REWARD_LOSER_BONUS_ADD, // RR_LOSER_BONUS_ADD + REWARD_RESCUED_HOSTAGE, // RR_RESCUED_HOSTAGE + REWARD_TOOK_HOSTAGE_ACC, // RR_TOOK_HOSTAGE_ACC + REWARD_TOOK_HOSTAGE, // RR_TOOK_HOSTAGE }; bool IsBotSpeaking() { - for (int i = 1; i <= gpGlobals->maxClients; ++i) + for (int i = 1; i <= gpGlobals->maxClients; i++) { CBasePlayer *pPlayer = UTIL_PlayerByIndex(i); @@ -56,109 +55,12 @@ bool IsBotSpeaking() return false; } -void SV_Continue_f() -{ - if (CSGameRules()->IsCareer() && CSGameRules()->m_flRestartRoundTime > 100000.0) - { - CSGameRules()->m_flRestartRoundTime = gpGlobals->time; - - // go continue - MESSAGE_BEGIN(MSG_ALL, gmsgCZCareer); - WRITE_STRING("GOGOGO"); - MESSAGE_END(); - - for (int i = 1; i <= gpGlobals->maxClients; ++i) - { - CBasePlayer *pPlayer = UTIL_PlayerByIndex(i); - - if (pPlayer && !pPlayer->IsBot()) - { - // at the end of the round is showed window with the proposal surrender or continue - // now of this time HUD is completely hidden - // we must to restore HUD after entered continued - pPlayer->m_iHideHUD &= ~HIDEHUD_ALL; - } - } - } -} - -void SV_Tutor_Toggle_f() -{ - CVAR_SET_FLOAT("tutor_enable", (CVAR_GET_FLOAT("tutor_enable") <= 0.0)); -} - -void SV_Career_Restart_f() -{ - if (CSGameRules()->IsCareer()) - { - CSGameRules()->CareerRestart(); - } -} - -void SV_Career_EndRound_f() -{ - if (!CSGameRules()->IsCareer() || !CSGameRules()->IsInCareerRound()) - { - return; - } - - CBasePlayer *localPlayer = UTIL_GetLocalPlayer(); - if (localPlayer) - { - SERVER_COMMAND("kill\n"); - - for (int i = 1; i <= gpGlobals->maxClients; ++i) - { - CBasePlayer *player = UTIL_PlayerByIndex(i); - - if (!player || FNullEnt(player->pev)) - continue; - - if (player->IsBot() && player->m_iTeam == localPlayer->m_iTeam) - { - SERVER_COMMAND(UTIL_VarArgs("bot_kill \"%s\"\n", STRING(player->pev->netname))); - } - } - } -} bool CHalfLifeMultiplay::IsInCareerRound() { return IsMatchStarted() ? false : true; } -void SV_CareerAddTask_f() -{ - if (CMD_ARGC() != 7) - return; - - const char *taskName = CMD_ARGV(1); - const char *weaponName = CMD_ARGV(2); - - int reps = Q_atoi(CMD_ARGV(3)); - bool mustLive = Q_atoi(CMD_ARGV(4)) != 0; - bool crossRounds = Q_atoi(CMD_ARGV(5)) != 0; - bool isComplete = Q_atoi(CMD_ARGV(6)) != 0; - - if (TheCareerTasks) - { - TheCareerTasks->AddTask(taskName, weaponName, reps, mustLive, crossRounds, isComplete); - } -} - -void SV_CareerMatchLimit_f() -{ - if (CMD_ARGC() != 3) - { - return; - } - - if (CSGameRules()->IsCareer()) - { - CSGameRules()->SetCareerMatchLimit(Q_atoi(CMD_ARGV(1)), Q_atoi(CMD_ARGV(2))); - } -} - void CHalfLifeMultiplay::SetCareerMatchLimit(int minWins, int winDifference) { if (!IsCareer()) @@ -248,16 +150,16 @@ char *GetTeam(int team) { switch (team) { - case CT: return "CT"; + case CT: return "CT"; case TERRORIST: return "TERRORIST"; case SPECTATOR: return "SPECTATOR"; - default: return ""; + default: return ""; } } void CHalfLifeMultiplay::EndRoundMessage(const char *sentence, int event) { - char *team = NULL; + char *team = nullptr; const char *message = sentence; bool bTeamTriggered = true; @@ -429,7 +331,7 @@ CHalfLifeMultiplay::CHalfLifeMultiplay() m_iRoundWinStatus = WINNER_NONE; m_iNumCTWins = 0; m_iNumTerroristWins = 0; - m_pVIP = NULL; + m_pVIP = nullptr; m_iNumCT = 0; m_iNumTerrorist = 0; m_iNumSpawnableCT = 0; @@ -490,9 +392,9 @@ CHalfLifeMultiplay::CHalfLifeMultiplay() m_bMapHasRescueZone = false; m_iStoredSpectValue = int(allow_spectators.value); - for (int j = 0; j < MAX_VIP_QUEUES; ++j) + for (int j = 0; j < MAX_VIP_QUEUES; j++) { - m_pVIPQueue[j] = NULL; + m_pVIPQueue[j] = nullptr; } #ifdef REGAMEDLL_FIXES @@ -565,27 +467,10 @@ CHalfLifeMultiplay::CHalfLifeMultiplay() #endif InstallHostageManager(); + InstallCommands(); m_bSkipSpawn = m_bInCareerGame; - static bool installedCommands = false; - if (!installedCommands) - { - installedCommands = true; - if (g_bIsCzeroGame) - { - ADD_SERVER_COMMAND("career_continue", SV_Continue_f); - ADD_SERVER_COMMAND("career_matchlimit", SV_CareerMatchLimit_f); - ADD_SERVER_COMMAND("career_add_task", SV_CareerAddTask_f); - ADD_SERVER_COMMAND("career_endround", SV_Career_EndRound_f); - ADD_SERVER_COMMAND("career_restart", SV_Career_Restart_f); - ADD_SERVER_COMMAND("tutor_toggle", SV_Tutor_Toggle_f); - } - - ADD_SERVER_COMMAND("perf_test", loopPerformance); - ADD_SERVER_COMMAND("print_ent", printEntities); - } - m_fCareerRoundMenuTime = 0; m_fCareerMatchMenuTime = 0; m_iCareerMatchWins = 0; @@ -620,40 +505,32 @@ void CHalfLifeMultiplay::RefreshSkillData() // override some values for multiplay. - // Glock Round - gSkillData.plrDmg9MM = 12; + gSkillData.plrDmg9MM = 12; // Glock Round + gSkillData.plrDmgMP5 = 12; // MP5 Round + gSkillData.plrDmg357 = 40; // 357 Round + gSkillData.plrDmgRPG = 120; // RPG - // MP5 Round - gSkillData.plrDmgMP5 = 12; - - // suitcharger - gSkillData.suitchargerCapacity = 30; - // 357 Round - gSkillData.plrDmg357 = 40; - // M203 grenade - gSkillData.plrDmgM203Grenade = 100; + gSkillData.plrDmgM203Grenade = 100; // M203 grenade + gSkillData.plrDmgCrossbowClient = 20; // Crossbow // Shotgun buckshot // fewer pellets in deathmatch gSkillData.plrDmgBuckshot = 20; - // Crossbow - gSkillData.plrDmgCrossbowClient = 20; - - // RPG - gSkillData.plrDmgRPG = 120; + // suitcharger + gSkillData.suitchargerCapacity = 30; } LINK_HOOK_CLASS_VOID_CUSTOM_CHAIN2(CHalfLifeMultiplay, CSGameRules, RemoveGuns) void EXT_FUNC CHalfLifeMultiplay::__API_HOOK(RemoveGuns)() { - CBaseEntity *toremove = NULL; + CBaseEntity *toremove = nullptr; while ((toremove = UTIL_FindEntityByClassname(toremove, "weaponbox"))) ((CWeaponBox *)toremove)->Kill(); - toremove = NULL; + toremove = nullptr; while ((toremove = UTIL_FindEntityByClassname(toremove, "weapon_shield"))) { @@ -743,12 +620,12 @@ void EXT_FUNC CHalfLifeMultiplay::__API_HOOK(GiveC4)() int humansPresent = 0; iTeamCount = m_iNumTerrorist; - ++m_iC4Guy; + m_iC4Guy++; bool giveToHumans = (cv_bot_defer_to_human.value > 0.0); if (giveToHumans) { - for (int i = 1; i <= gpGlobals->maxClients; ++i) + for (int i = 1; i <= gpGlobals->maxClients; i++) { CBasePlayer *player = UTIL_PlayerByIndex(i); @@ -759,7 +636,7 @@ void EXT_FUNC CHalfLifeMultiplay::__API_HOOK(GiveC4)() continue; if (!player->IsBot()) - ++humansPresent; + humansPresent++; } if (humansPresent) @@ -775,7 +652,7 @@ void EXT_FUNC CHalfLifeMultiplay::__API_HOOK(GiveC4)() } // Give the C4 to the specified T player.. - CBaseEntity *pPlayer = NULL; + CBaseEntity *pPlayer = nullptr; while ((pPlayer = UTIL_FindEntityByClassname(pPlayer, "player"))) { if (FNullEnt(pPlayer->edict())) @@ -807,7 +684,7 @@ void EXT_FUNC CHalfLifeMultiplay::__API_HOOK(GiveC4)() if (!IsThereABomber()) { m_iC4Guy = 0; - pPlayer = NULL; + pPlayer = nullptr; while ((pPlayer = UTIL_FindEntityByClassname(pPlayer, "player"))) { @@ -844,7 +721,7 @@ void CHalfLifeMultiplay::QueueCareerRoundEndMenu(float tmDelay, int iWinStatus) bool humansAreCTs = (Q_strcmp(humans_join_team.string, "CT") == 0); if (humansAreCTs) { - CBaseEntity *hostage = NULL; + CBaseEntity *hostage = nullptr; int numHostagesInMap = 0; int numHostagesFollowingHumans = 0; @@ -852,25 +729,25 @@ void CHalfLifeMultiplay::QueueCareerRoundEndMenu(float tmDelay, int iWinStatus) while ((hostage = UTIL_FindEntityByClassname(hostage, "hostage_entity"))) { - ++numHostagesInMap; + numHostagesInMap++; CHostage *pHostage = static_cast(hostage); if (!pHostage->IsAlive()) continue; - CBasePlayer *pLeader = NULL; + CBasePlayer *pLeader = nullptr; if (pHostage->IsFollowingSomeone()) pLeader = static_cast(pHostage->GetLeader()); - if (pLeader == NULL) + if (pLeader == nullptr) { - ++numHostagesAlive; + numHostagesAlive++; } else { if (!pLeader->IsBot()) { - ++numHostagesFollowingHumans; + numHostagesFollowingHumans++; TheCareerTasks->HandleEvent(EVENT_HOSTAGE_RESCUED, pLeader, 0); } } @@ -992,7 +869,7 @@ void CHalfLifeMultiplay::InitializePlayerCounts(int &NumAliveTerrorist, int &Num // initialize count dead/alive players // Count how many dead players there are on each team. - CBaseEntity *pPlayer = NULL; + CBaseEntity *pPlayer = nullptr; while ((pPlayer = UTIL_FindEntityByClassname(pPlayer, "player"))) { if (FNullEnt(pPlayer->edict())) @@ -1020,41 +897,41 @@ void CHalfLifeMultiplay::InitializePlayerCounts(int &NumAliveTerrorist, int &Num { case CT: { - ++m_iNumCT; + m_iNumCT++; if (player->m_iMenu != Menu_ChooseAppearance) { - ++m_iNumSpawnableCT; + m_iNumSpawnableCT++; //player->IsBot(); } //player->IsBot(); if (player->pev->deadflag != DEAD_NO) - ++NumDeadCT; + NumDeadCT++; else - ++NumAliveCT; + NumAliveCT++; break; } case TERRORIST: { - ++m_iNumTerrorist; + m_iNumTerrorist++; if (player->m_iMenu != Menu_ChooseAppearance) { - ++m_iNumSpawnableTerrorist; + m_iNumSpawnableTerrorist++; //player->IsBot(); } //player->IsBot(); if (player->pev->deadflag != DEAD_NO) - ++NumDeadTerrorist; + NumDeadTerrorist++; else - ++NumAliveTerrorist; + NumAliveTerrorist++; // Check to see if this guy escaped. if (player->m_bEscaped) - ++m_iHaveEscaped; + m_iHaveEscaped++; break; } @@ -1064,7 +941,42 @@ void CHalfLifeMultiplay::InitializePlayerCounts(int &NumAliveTerrorist, int &Num } } -bool EXT_FUNC CHalfLifeMultiplay::NeededPlayersCheck_internal(int winStatus, ScenarioEventEndRound event, float tmDelay) +bool CHalfLifeMultiplay::OnRoundEnd_Intercept(int winStatus, ScenarioEventEndRound event, float tmDelay) +{ + return g_ReGameHookchains.m_RoundEnd.callChain(&CHalfLifeMultiplay::OnRoundEnd, this, winStatus, event, tmDelay); +} + +bool EXT_FUNC CHalfLifeMultiplay::OnRoundEnd(int winStatus, ScenarioEventEndRound event, float tmDelay) +{ + switch (event) + { + case ROUND_TARGET_BOMB: return Target_Bombed(tmDelay); + case ROUND_VIP_ESCAPED: return VIP_Escaped(tmDelay); + case ROUND_VIP_ASSASSINATED: return VIP_Died(tmDelay); + case ROUND_TERRORISTS_ESCAPED: return Prison_Escaped(tmDelay); + case ROUND_CTS_PREVENT_ESCAPE: return Prison_PreventEscape(tmDelay); + case ROUND_ESCAPING_TERRORISTS_NEUTRALIZED: return Prison_Neutralized(tmDelay); + case ROUND_BOMB_DEFUSED: return Target_Defused(tmDelay); + case ROUND_CTS_WIN: return Round_Cts(tmDelay); + case ROUND_TERRORISTS_WIN: return Round_Ts(tmDelay); + case ROUND_END_DRAW: return Round_Draw(tmDelay); + case ROUND_ALL_HOSTAGES_RESCUED: return Hostage_Rescue(tmDelay); + case ROUND_TARGET_SAVED: return Target_Saved(tmDelay); + case ROUND_HOSTAGE_NOT_RESCUED: return Hostage_NotRescued(tmDelay); + case ROUND_TERRORISTS_NOT_ESCAPED: return Prison_NotEscaped(tmDelay); + case ROUND_VIP_NOT_ESCAPED: return VIP_NotEscaped(tmDelay); + case ROUND_GAME_COMMENCE: return NeededPlayersCheck(tmDelay); + case ROUND_GAME_RESTART: return RestartRoundCheck(tmDelay); + case ROUND_GAME_OVER: return RoundOver(tmDelay); + case ROUND_NONE: + default: + break; + } + + return false; +} + +bool EXT_FUNC CHalfLifeMultiplay::NeededPlayersCheck(float tmDelay) { // Start the round immediately when the first person joins UTIL_LogPrintf("World triggered \"Game_Commencing\"\n"); @@ -1073,8 +985,8 @@ bool EXT_FUNC CHalfLifeMultiplay::NeededPlayersCheck_internal(int winStatus, Sce m_bFreezePeriod = FALSE; m_bCompleteReset = true; - EndRoundMessage("#Game_Commencing", event); - TerminateRound(tmDelay, winStatus); + EndRoundMessage("#Game_Commencing", ROUND_GAME_COMMENCE); + TerminateRound(tmDelay, WINSTATUS_DRAW); m_bGameStarted = true; if (TheBots) @@ -1108,73 +1020,73 @@ bool EXT_FUNC CHalfLifeMultiplay::NeededPlayersCheck() } } - return g_ReGameHookchains.m_RoundEnd.callChain(&CHalfLifeMultiplay::NeededPlayersCheck_internal, this, WINSTATUS_DRAW, ROUND_GAME_COMMENCE, IsCareer() ? 0 : 3); + return OnRoundEnd_Intercept(WINSTATUS_DRAW, ROUND_GAME_COMMENCE, IsCareer() ? 0 : 3); } return false; } -bool EXT_FUNC CHalfLifeMultiplay::VIP_Escaped_internal(int winStatus, ScenarioEventEndRound event, float tmDelay) +bool EXT_FUNC CHalfLifeMultiplay::VIP_Escaped(float tmDelay) { Broadcast("ctwin"); m_iAccountCT += m_rgRewardAccountRules[RR_VIP_ESCAPED]; if (!m_bNeededPlayers) { - ++m_iNumCTWins; + m_iNumCTWins++; // Update the clients team score UpdateTeamScores(); } MESSAGE_BEGIN(MSG_SPEC, SVC_DIRECTOR); - WRITE_BYTE(9); // command length in bytes - WRITE_BYTE(DRC_CMD_EVENT); // VIP rescued + WRITE_BYTE(9); // command length in bytes + WRITE_BYTE(DRC_CMD_EVENT); // VIP rescued WRITE_SHORT(ENTINDEX(m_pVIP->edict())); // index number of primary entity - WRITE_SHORT(0); // index number of secondary entity - WRITE_LONG(15 | DRC_FLAG_FINAL); // eventflags (priority and flags) + WRITE_SHORT(0); // index number of secondary entity + WRITE_LONG(15 | DRC_FLAG_FINAL); // eventflags (priority and flags) MESSAGE_END(); - EndRoundMessage("#VIP_Escaped", event); + EndRoundMessage("#VIP_Escaped", ROUND_VIP_ESCAPED); + TerminateRound(tmDelay, WINSTATUS_CTS); // tell the bots the VIP got out if (TheBots) { TheBots->OnEvent(EVENT_VIP_ESCAPED); } - TerminateRound(tmDelay, winStatus); if (IsCareer()) { - QueueCareerRoundEndMenu(tmDelay, winStatus); + QueueCareerRoundEndMenu(tmDelay, WINSTATUS_CTS); } return true; } -bool EXT_FUNC CHalfLifeMultiplay::VIP_Died_internal(int winStatus, ScenarioEventEndRound event, float tmDelay) +bool EXT_FUNC CHalfLifeMultiplay::VIP_Died(float tmDelay) { Broadcast("terwin"); m_iAccountTerrorist += m_rgRewardAccountRules[RR_VIP_ASSASSINATED]; if (!m_bNeededPlayers) { - ++m_iNumTerroristWins; + m_iNumTerroristWins++; // Update the clients team score UpdateTeamScores(); } - EndRoundMessage("#VIP_Assassinated", event); + EndRoundMessage("#VIP_Assassinated", ROUND_VIP_ASSASSINATED); + TerminateRound(tmDelay, WINSTATUS_TERRORISTS); // tell the bots the VIP was killed if (TheBots) { TheBots->OnEvent(EVENT_VIP_ASSASSINATED); } - TerminateRound(tmDelay, winStatus); if (IsCareer()) { - QueueCareerRoundEndMenu(tmDelay, winStatus); + QueueCareerRoundEndMenu(tmDelay, WINSTATUS_TERRORISTS); } return true; @@ -1187,42 +1099,42 @@ bool EXT_FUNC CHalfLifeMultiplay::VIPRoundEndCheck() { if (m_pVIP->m_bEscaped) { - return g_ReGameHookchains.m_RoundEnd.callChain(&CHalfLifeMultiplay::VIP_Escaped_internal, this, WINSTATUS_CTS, ROUND_VIP_ESCAPED, GetRoundRestartDelay()); + return OnRoundEnd_Intercept(WINSTATUS_CTS, ROUND_VIP_ESCAPED, GetRoundRestartDelay()); } // The VIP is dead else if (m_pVIP->pev->deadflag != DEAD_NO) { - return g_ReGameHookchains.m_RoundEnd.callChain(&CHalfLifeMultiplay::VIP_Died_internal, this, WINSTATUS_TERRORISTS, ROUND_VIP_ASSASSINATED, GetRoundRestartDelay()); + return OnRoundEnd_Intercept(WINSTATUS_TERRORISTS, ROUND_VIP_ASSASSINATED, GetRoundRestartDelay()); } } return false; } -bool EXT_FUNC CHalfLifeMultiplay::Prison_Escaped_internal(int winStatus, ScenarioEventEndRound event, float tmDelay) +bool EXT_FUNC CHalfLifeMultiplay::Prison_Escaped(float tmDelay) { Broadcast("terwin"); m_iAccountTerrorist += m_rgRewardAccountRules[RR_TERRORISTS_ESCAPED]; if (!m_bNeededPlayers) { - ++m_iNumTerroristWins; + m_iNumTerroristWins++; // Update the clients team score UpdateTeamScores(); } - EndRoundMessage("#Terrorists_Escaped", event); - TerminateRound(tmDelay, winStatus); + EndRoundMessage("#Terrorists_Escaped", ROUND_TERRORISTS_ESCAPED); + TerminateRound(tmDelay, WINSTATUS_TERRORISTS); if (IsCareer()) { - QueueCareerRoundEndMenu(tmDelay, winStatus); + QueueCareerRoundEndMenu(tmDelay, WINSTATUS_TERRORISTS); } return true; } -bool EXT_FUNC CHalfLifeMultiplay::Prison_PreventEscape_internal(int winStatus, ScenarioEventEndRound event, float tmDelay) +bool EXT_FUNC CHalfLifeMultiplay::Prison_PreventEscape(float tmDelay) { Broadcast("ctwin"); // CTs are rewarded based on how many terrorists have escaped... @@ -1230,23 +1142,23 @@ bool EXT_FUNC CHalfLifeMultiplay::Prison_PreventEscape_internal(int winStatus, S if (!m_bNeededPlayers) { - ++m_iNumCTWins; + m_iNumCTWins++; // Update the clients team score UpdateTeamScores(); } - EndRoundMessage("#CTs_PreventEscape", event); - TerminateRound(tmDelay, winStatus); + EndRoundMessage("#CTs_PreventEscape", ROUND_CTS_PREVENT_ESCAPE); + TerminateRound(tmDelay, WINSTATUS_CTS); if (IsCareer()) { - QueueCareerRoundEndMenu(tmDelay, winStatus); + QueueCareerRoundEndMenu(tmDelay, WINSTATUS_CTS); } return true; } -bool EXT_FUNC CHalfLifeMultiplay::Prison_Neutralized_internal(int winStatus, ScenarioEventEndRound event, float tmDelay) +bool EXT_FUNC CHalfLifeMultiplay::Prison_Neutralized(float tmDelay) { Broadcast("ctwin"); // CTs are rewarded based on how many terrorists have escaped... @@ -1254,17 +1166,17 @@ bool EXT_FUNC CHalfLifeMultiplay::Prison_Neutralized_internal(int winStatus, Sce if (!m_bNeededPlayers) { - ++m_iNumCTWins; + m_iNumCTWins++; // Update the clients team score UpdateTeamScores(); } - EndRoundMessage("#Escaping_Terrorists_Neutralized", event); - TerminateRound(tmDelay, winStatus); + EndRoundMessage("#Escaping_Terrorists_Neutralized", ROUND_ESCAPING_TERRORISTS_NEUTRALIZED); + TerminateRound(tmDelay, WINSTATUS_CTS); if (IsCareer()) { - QueueCareerRoundEndMenu(tmDelay, winStatus); + QueueCareerRoundEndMenu(tmDelay, WINSTATUS_CTS); } return true; @@ -1279,15 +1191,15 @@ bool EXT_FUNC CHalfLifeMultiplay::PrisonRoundEndCheck(int NumAliveTerrorist, int if (m_flEscapeRatio >= m_flRequiredEscapeRatio) { - return g_ReGameHookchains.m_RoundEnd.callChain(&CHalfLifeMultiplay::Prison_Escaped_internal, this, WINSTATUS_TERRORISTS, ROUND_TERRORISTS_ESCAPED, GetRoundRestartDelay()); + return OnRoundEnd_Intercept(WINSTATUS_TERRORISTS, ROUND_TERRORISTS_ESCAPED, GetRoundRestartDelay()); } else if (NumAliveTerrorist == 0 && m_flEscapeRatio < m_flRequiredEscapeRatio) { - return g_ReGameHookchains.m_RoundEnd.callChain(&CHalfLifeMultiplay::Prison_PreventEscape_internal, this, WINSTATUS_CTS, ROUND_CTS_PREVENT_ESCAPE, GetRoundRestartDelay()); + return OnRoundEnd_Intercept(WINSTATUS_CTS, ROUND_CTS_PREVENT_ESCAPE, GetRoundRestartDelay()); } else if (NumAliveTerrorist == 0 && NumDeadTerrorist != 0 && m_iNumSpawnableCT > 0) { - return g_ReGameHookchains.m_RoundEnd.callChain(&CHalfLifeMultiplay::Prison_Neutralized_internal, this, WINSTATUS_CTS, ROUND_ESCAPING_TERRORISTS_NEUTRALIZED, GetRoundRestartDelay()); + return OnRoundEnd_Intercept(WINSTATUS_CTS, ROUND_ESCAPING_TERRORISTS_NEUTRALIZED, GetRoundRestartDelay()); } // else return true; } @@ -1295,48 +1207,48 @@ bool EXT_FUNC CHalfLifeMultiplay::PrisonRoundEndCheck(int NumAliveTerrorist, int return false; } -bool CHalfLifeMultiplay::Target_Bombed_internal(int winStatus, ScenarioEventEndRound event, float tmDelay) { - +bool CHalfLifeMultiplay::Target_Bombed(float tmDelay) +{ Broadcast("terwin"); m_iAccountTerrorist += m_rgRewardAccountRules[RR_TARGET_BOMB]; if (!m_bNeededPlayers) { - ++m_iNumTerroristWins; + m_iNumTerroristWins++; // Update the clients team score UpdateTeamScores(); } - EndRoundMessage("#Target_Bombed", event); - TerminateRound(tmDelay, winStatus); + EndRoundMessage("#Target_Bombed", ROUND_TARGET_BOMB); + TerminateRound(tmDelay, WINSTATUS_TERRORISTS); if (IsCareer()) { - QueueCareerRoundEndMenu(tmDelay, winStatus); + QueueCareerRoundEndMenu(tmDelay, WINSTATUS_TERRORISTS); } return true; } -bool CHalfLifeMultiplay::Target_Defused_internal(int winStatus, ScenarioEventEndRound event, float tmDelay) { - +bool CHalfLifeMultiplay::Target_Defused(float tmDelay) +{ Broadcast("ctwin"); m_iAccountCT += m_rgRewardAccountRules[RR_BOMB_DEFUSED]; m_iAccountTerrorist += m_rgRewardAccountRules[RR_BOMB_PLANTED]; if (!m_bNeededPlayers) { - ++m_iNumCTWins; + m_iNumCTWins++; // Update the clients team score UpdateTeamScores(); } - EndRoundMessage("#Bomb_Defused", event); - TerminateRound(tmDelay, winStatus); + EndRoundMessage("#Bomb_Defused", ROUND_BOMB_DEFUSED); + TerminateRound(tmDelay, WINSTATUS_CTS); if (IsCareer()) { - QueueCareerRoundEndMenu(tmDelay, winStatus); + QueueCareerRoundEndMenu(tmDelay, WINSTATUS_CTS); } return true; @@ -1347,67 +1259,67 @@ bool CHalfLifeMultiplay::BombRoundEndCheck() // Check to see if the bomb target was hit or the bomb defused.. if so, then let's end the round! if (m_bTargetBombed && m_bMapHasBombTarget) { - return g_ReGameHookchains.m_RoundEnd.callChain(&CHalfLifeMultiplay::Target_Bombed_internal, this, WINSTATUS_TERRORISTS, ROUND_TARGET_BOMB, GetRoundRestartDelay()); + return OnRoundEnd_Intercept(WINSTATUS_TERRORISTS, ROUND_TARGET_BOMB, GetRoundRestartDelay()); } else if (m_bBombDefused && m_bMapHasBombTarget) { - return g_ReGameHookchains.m_RoundEnd.callChain(&CHalfLifeMultiplay::Target_Defused_internal, this, WINSTATUS_CTS, ROUND_BOMB_DEFUSED, GetRoundRestartDelay()); + return OnRoundEnd_Intercept(WINSTATUS_CTS, ROUND_BOMB_DEFUSED, GetRoundRestartDelay()); } return false; } -bool CHalfLifeMultiplay::Round_Cts_internal(int winStatus, ScenarioEventEndRound event, float tmDelay) { - +bool CHalfLifeMultiplay::Round_Cts(float tmDelay) +{ Broadcast("ctwin"); m_iAccountCT += m_rgRewardAccountRules[m_bMapHasBombTarget ? RR_BOMB_DEFUSED : RR_CTS_WIN]; if (!m_bNeededPlayers) { - ++m_iNumCTWins; + m_iNumCTWins++; // Update the clients team score UpdateTeamScores(); } - EndRoundMessage("#CTs_Win", event); - TerminateRound(tmDelay, winStatus); + EndRoundMessage("#CTs_Win", ROUND_CTS_WIN); + TerminateRound(tmDelay, WINSTATUS_CTS); if (IsCareer()) { - QueueCareerRoundEndMenu(tmDelay, winStatus); + QueueCareerRoundEndMenu(tmDelay, WINSTATUS_CTS); } return true; } -bool CHalfLifeMultiplay::Round_Ts_internal(int winStatus, ScenarioEventEndRound event, float tmDelay) { - +bool CHalfLifeMultiplay::Round_Ts(float tmDelay) +{ Broadcast("terwin"); m_iAccountTerrorist += m_rgRewardAccountRules[m_bMapHasBombTarget ? RR_BOMB_EXPLODED : RR_TERRORISTS_WIN]; if (!m_bNeededPlayers) { - ++m_iNumTerroristWins; + m_iNumTerroristWins++; // Update the clients team score UpdateTeamScores(); } - EndRoundMessage("#Terrorists_Win", event); - TerminateRound(tmDelay, winStatus); + EndRoundMessage("#Terrorists_Win", ROUND_TERRORISTS_WIN); + TerminateRound(tmDelay, WINSTATUS_TERRORISTS); if (IsCareer()) { - QueueCareerRoundEndMenu(tmDelay, winStatus); + QueueCareerRoundEndMenu(tmDelay, WINSTATUS_TERRORISTS); } return true; } -bool CHalfLifeMultiplay::Round_Draw_internal(int winStatus, ScenarioEventEndRound event, float tmDelay) { - - EndRoundMessage("#Round_Draw", event); +bool CHalfLifeMultiplay::Round_Draw(float tmDelay) +{ + EndRoundMessage("#Round_Draw", ROUND_END_DRAW); Broadcast("rounddraw"); - TerminateRound(tmDelay, winStatus); + TerminateRound(tmDelay, WINSTATUS_DRAW); return true; } @@ -1417,7 +1329,7 @@ bool CHalfLifeMultiplay::TeamExterminationCheck(int NumAliveTerrorist, int NumAl { if (NumAliveTerrorist == 0 && NumDeadTerrorist != 0 && NumAliveCT > 0) { - CGrenade *pBomb = NULL; + CGrenade *pBomb = nullptr; bool nowin = false; while ((pBomb = (CGrenade *)UTIL_FindEntityByClassname(pBomb, "grenade"))) @@ -1433,26 +1345,26 @@ bool CHalfLifeMultiplay::TeamExterminationCheck(int NumAliveTerrorist, int NumAl if (!nowin) { - return g_ReGameHookchains.m_RoundEnd.callChain(&CHalfLifeMultiplay::Round_Cts_internal, this, WINSTATUS_CTS, ROUND_CTS_WIN, GetRoundRestartDelay()); + return OnRoundEnd_Intercept(WINSTATUS_CTS, ROUND_CTS_WIN, GetRoundRestartDelay()); } } // Terrorists WON else if (NumAliveCT == 0 && NumDeadCT != 0) { - return g_ReGameHookchains.m_RoundEnd.callChain(&CHalfLifeMultiplay::Round_Ts_internal, this, WINSTATUS_TERRORISTS, ROUND_TERRORISTS_WIN, GetRoundRestartDelay()); + return OnRoundEnd_Intercept(WINSTATUS_TERRORISTS, ROUND_TERRORISTS_WIN, GetRoundRestartDelay()); } } else if (NumAliveCT == 0 && NumAliveTerrorist == 0) { - return g_ReGameHookchains.m_RoundEnd.callChain(&CHalfLifeMultiplay::Round_Draw_internal, this, WINSTATUS_DRAW, ROUND_END_DRAW, GetRoundRestartDelay()); + return OnRoundEnd_Intercept(WINSTATUS_DRAW, ROUND_END_DRAW, GetRoundRestartDelay()); } return false; } -bool CHalfLifeMultiplay::Hostage_Rescue_internal(int winStatus, ScenarioEventEndRound event, float tmDelay) { - +bool CHalfLifeMultiplay::Hostage_Rescue(float tmDelay) +{ Broadcast("ctwin"); m_iAccountCT += m_rgRewardAccountRules[RR_ALL_HOSTAGES_RESCUED]; @@ -1463,7 +1375,8 @@ bool CHalfLifeMultiplay::Hostage_Rescue_internal(int winStatus, ScenarioEventEnd UpdateTeamScores(); } - EndRoundMessage("#All_Hostages_Rescued", event); + EndRoundMessage("#All_Hostages_Rescued", ROUND_ALL_HOSTAGES_RESCUED); + TerminateRound(tmDelay, WINSTATUS_CTS); // tell the bots all the hostages have been rescued if (TheBots) @@ -1479,10 +1392,9 @@ bool CHalfLifeMultiplay::Hostage_Rescue_internal(int winStatus, ScenarioEventEnd } } - TerminateRound(tmDelay, winStatus); if (IsCareer()) { - QueueCareerRoundEndMenu(tmDelay, winStatus); + QueueCareerRoundEndMenu(tmDelay, WINSTATUS_CTS); } return true; @@ -1491,7 +1403,7 @@ bool CHalfLifeMultiplay::Hostage_Rescue_internal(int winStatus, ScenarioEventEnd bool CHalfLifeMultiplay::HostageRescueRoundEndCheck() { // Check to see if 50% of the hostages have been rescued. - CBaseEntity *hostage = NULL; + CBaseEntity *hostage = nullptr; int iHostages = 0; // Assume that all hostages are either rescued or dead.. @@ -1499,7 +1411,7 @@ bool CHalfLifeMultiplay::HostageRescueRoundEndCheck() while ((hostage = UTIL_FindEntityByClassname(hostage, "hostage_entity"))) { - ++iHostages; + iHostages++; // We've found a live hostage. don't end the round if (hostage->IsAlive()) @@ -1513,7 +1425,7 @@ bool CHalfLifeMultiplay::HostageRescueRoundEndCheck() { if (m_iHostagesRescued >= (iHostages * 0.5f)) { - return g_ReGameHookchains.m_RoundEnd.callChain(&CHalfLifeMultiplay::Hostage_Rescue_internal, this, WINSTATUS_CTS, ROUND_ALL_HOSTAGES_RESCUED, GetRoundRestartDelay()); + return OnRoundEnd_Intercept(WINSTATUS_CTS, ROUND_ALL_HOSTAGES_RESCUED, GetRoundRestartDelay()); } } @@ -1522,7 +1434,7 @@ bool CHalfLifeMultiplay::HostageRescueRoundEndCheck() void CHalfLifeMultiplay::SwapAllPlayers() { - CBaseEntity *pPlayer = NULL; + CBaseEntity *pPlayer = nullptr; while ((pPlayer = UTIL_FindEntityByClassname(pPlayer, "player"))) { @@ -1603,14 +1515,14 @@ void EXT_FUNC CHalfLifeMultiplay::__API_HOOK(BalanceTeams)() // last person to join the server int iHighestUserID = 0; - CBasePlayer *toSwap = NULL; + CBasePlayer *toSwap = nullptr; - for (int i = 1; i <= iNumToSwap; ++i) + for (int i = 1; i <= iNumToSwap; i++) { iHighestUserID = 0; - toSwap = NULL; + toSwap = nullptr; - CBaseEntity *pPlayer = NULL; + CBaseEntity *pPlayer = nullptr; // search for player with highest UserID = most recently joined to switch over while ((pPlayer = UTIL_FindEntityByClassname(pPlayer, "player"))) @@ -1641,12 +1553,12 @@ LINK_HOOK_CLASS_VOID_CUSTOM_CHAIN2(CHalfLifeMultiplay, CSGameRules, CheckMapCond void EXT_FUNC CHalfLifeMultiplay::__API_HOOK(CheckMapConditions)() { // Check to see if this map has a bomb target in it - if (UTIL_FindEntityByClassname(NULL, "func_bomb_target")) + if (UTIL_FindEntityByClassname(nullptr, "func_bomb_target")) { m_bMapHasBombTarget = true; m_bMapHasBombZone = true; } - else if (UTIL_FindEntityByClassname(NULL, "info_bomb_target")) + else if (UTIL_FindEntityByClassname(nullptr, "info_bomb_target")) { m_bMapHasBombTarget = true; m_bMapHasBombZone = false; @@ -1658,17 +1570,17 @@ void EXT_FUNC CHalfLifeMultiplay::__API_HOOK(CheckMapConditions)() } // Check to see if this map has hostage rescue zones - m_bMapHasRescueZone = (UTIL_FindEntityByClassname(NULL, "func_hostage_rescue") != NULL); + m_bMapHasRescueZone = (UTIL_FindEntityByClassname(nullptr, "func_hostage_rescue") != nullptr); // See if the map has func_buyzone entities // Used by CBasePlayer::HandleSignals() to support maps without these entities - m_bMapHasBuyZone = (UTIL_FindEntityByClassname(NULL, "func_buyzone") != NULL); + m_bMapHasBuyZone = (UTIL_FindEntityByClassname(nullptr, "func_buyzone") != nullptr); // GOOSEMAN : See if this map has func_escapezone entities - m_bMapHasEscapeZone = (UTIL_FindEntityByClassname(NULL, "func_escapezone") != NULL); + m_bMapHasEscapeZone = (UTIL_FindEntityByClassname(nullptr, "func_escapezone") != nullptr); // Check to see if this map has VIP safety zones - m_bMapHasVIPSafetyZone = (UTIL_FindEntityByClassname(NULL, "func_vip_safetyzone") != NULL); + m_bMapHasVIPSafetyZone = (UTIL_FindEntityByClassname(nullptr, "func_vip_safetyzone") != nullptr); } LINK_HOOK_CLASS_VOID_CUSTOM_CHAIN2(CHalfLifeMultiplay, CSGameRules, RestartRound) @@ -1723,7 +1635,7 @@ void EXT_FUNC CHalfLifeMultiplay::__API_HOOK(RestartRound)() // reset all players health for HLTV MESSAGE_BEGIN(MSG_SPEC, gmsgHLTV); - WRITE_BYTE(0); // 0 = all players + WRITE_BYTE(0); // 0 = all players WRITE_BYTE(100 | DRC_FLAG_FACEPLAYER); // 100 health + msg flag MESSAGE_END(); @@ -1808,7 +1720,7 @@ void EXT_FUNC CHalfLifeMultiplay::__API_HOOK(RestartRound)() UpdateTeamScores(); // Reset the player stats - for (int i = 1; i <= gpGlobals->maxClients; ++i) + for (int i = 1; i <= gpGlobals->maxClients; i++) { CBasePlayer *plr = UTIL_PlayerByIndex(i); @@ -1860,17 +1772,17 @@ void EXT_FUNC CHalfLifeMultiplay::__API_HOOK(RestartRound)() } // Increment the number of rounds played... After 8 rounds, the players will do a whole sale switch.. - ++m_iNumEscapeRounds; + m_iNumEscapeRounds++; } if (m_bMapHasVIPSafetyZone) { PickNextVIP(); - ++m_iConsecutiveVIP; + m_iConsecutiveVIP++; } int acct_tmp = 0; - CBaseEntity *hostage = NULL; + CBaseEntity *hostage = nullptr; while ((hostage = UTIL_FindEntityByClassname(hostage, "hostage_entity"))) { @@ -1903,7 +1815,7 @@ void EXT_FUNC CHalfLifeMultiplay::__API_HOOK(RestartRound)() } m_iNumConsecutiveTerroristLoses = 0; // starting fresh - m_iNumConsecutiveCTLoses++; // increment the number of wins the CTs have had + m_iNumConsecutiveCTLoses++; // increment the number of wins the CTs have had } else if (m_iRoundWinStatus == WINSTATUS_CTS) { @@ -1958,7 +1870,7 @@ void EXT_FUNC CHalfLifeMultiplay::__API_HOOK(RestartRound)() // Adrian - No cash for anyone at first rounds! ( well, only the default. ) if (m_bCompleteReset) { - // No extra cash!. + // No extra cash! m_iAccountTerrorist = m_iAccountCT = 0; // We are starting fresh. So it's like no one has ever won or lost. @@ -1975,7 +1887,7 @@ void EXT_FUNC CHalfLifeMultiplay::__API_HOOK(RestartRound)() #endif // tell bots that the round is restarting - CBaseEntity *pPlayer = NULL; + CBaseEntity *pPlayer = nullptr; while ((pPlayer = UTIL_FindEntityByClassname(pPlayer, "player"))) { if (FNullEnt(pPlayer->edict())) @@ -2007,7 +1919,7 @@ void EXT_FUNC CHalfLifeMultiplay::__API_HOOK(RestartRound)() else if (player->m_iTeam == TERRORIST) { // Add another potential escaper to the mix! - ++m_iNumEscapers; + m_iNumEscapers++; if (!player->m_bReceivesNoMoneyNextRound) { @@ -2075,7 +1987,7 @@ void EXT_FUNC CHalfLifeMultiplay::__API_HOOK(RestartRound)() BOOL CHalfLifeMultiplay::IsThereABomber() { - CBasePlayer *pPlayer = NULL; + CBasePlayer *pPlayer = nullptr; while ((pPlayer = (CBasePlayer *)UTIL_FindEntityByClassname(pPlayer, "player"))) { @@ -2095,8 +2007,8 @@ BOOL CHalfLifeMultiplay::IsThereABomber() BOOL CHalfLifeMultiplay::IsThereABomb() { - CGrenade *pC4 = NULL; - CBaseEntity *pWeaponC4 = NULL; + CGrenade *pC4 = nullptr; + CBaseEntity *pWeaponC4 = nullptr; bool bFoundBomb = false; while ((pWeaponC4 = UTIL_FindEntityByClassname(pWeaponC4, "grenade"))) @@ -2113,7 +2025,7 @@ BOOL CHalfLifeMultiplay::IsThereABomb() } } - if (bFoundBomb || (UTIL_FindEntityByClassname(NULL, "weapon_c4"))) + if (bFoundBomb || (UTIL_FindEntityByClassname(nullptr, "weapon_c4"))) return TRUE; return FALSE; @@ -2170,26 +2082,26 @@ void CHalfLifeMultiplay::StackVIPQueue() if (!m_pVIPQueue[i]) { m_pVIPQueue[i] = m_pVIPQueue[i + 1]; - m_pVIPQueue[i + 1] = NULL; + m_pVIPQueue[i + 1] = nullptr; } } else { m_pVIPQueue[i - 1] = m_pVIPQueue[i]; m_pVIPQueue[i] = m_pVIPQueue[i + 1]; - m_pVIPQueue[i + 1] = NULL; + m_pVIPQueue[i + 1] = nullptr; } } } bool CHalfLifeMultiplay::IsVIPQueueEmpty() { - for (int i = 0; i < MAX_VIP_QUEUES; ++i) + for (int i = 0; i < MAX_VIP_QUEUES; i++) { CBasePlayer *toCheck = m_pVIPQueue[i]; if (toCheck && toCheck->m_iTeam != CT) { - m_pVIPQueue[i] = NULL; + m_pVIPQueue[i] = nullptr; } } @@ -2199,12 +2111,12 @@ bool CHalfLifeMultiplay::IsVIPQueueEmpty() bool CHalfLifeMultiplay::AddToVIPQueue(CBasePlayer *toAdd) { - for (int i = 0; i < MAX_VIP_QUEUES; ++i) + for (int i = 0; i < MAX_VIP_QUEUES; i++) { CBasePlayer *toCheck = m_pVIPQueue[i]; if (toCheck && toCheck->m_iTeam != CT) { - m_pVIPQueue[i] = NULL; + m_pVIPQueue[i] = nullptr; } } @@ -2213,7 +2125,7 @@ bool CHalfLifeMultiplay::AddToVIPQueue(CBasePlayer *toAdd) if (toAdd->m_iTeam == CT) { int j; - for (j = 0; j < MAX_VIP_QUEUES; ++j) + for (j = 0; j < MAX_VIP_QUEUES; j++) { if (m_pVIPQueue[j] == toAdd) { @@ -2222,7 +2134,7 @@ bool CHalfLifeMultiplay::AddToVIPQueue(CBasePlayer *toAdd) } } - for (j = 0; j < MAX_VIP_QUEUES; ++j) + for (j = 0; j < MAX_VIP_QUEUES; j++) { if (!m_pVIPQueue[j]) { @@ -2243,7 +2155,7 @@ bool CHalfLifeMultiplay::AddToVIPQueue(CBasePlayer *toAdd) void CHalfLifeMultiplay::ResetCurrentVIP() { char *infobuffer = GET_INFO_BUFFER(m_pVIP->edict()); - int numSkins = g_bIsCzeroGame ? CZ_NUM_SKIN : CS_NUM_SKIN; + int numSkins = AreRunningCZero() ? CZ_NUM_SKIN : CS_NUM_SKIN; switch (RANDOM_LONG(0, numSkins)) { @@ -2260,7 +2172,7 @@ void CHalfLifeMultiplay::ResetCurrentVIP() m_pVIP->SetClientUserInfoModel(infobuffer, "gign"); break; case 4: - if (g_bIsCzeroGame) + if (AreRunningCZero()) { m_pVIP->m_iModelName = MODEL_SPETSNAZ; m_pVIP->SetClientUserInfoModel(infobuffer, "spetsnaz"); @@ -2286,15 +2198,15 @@ void CHalfLifeMultiplay::PickNextVIP() ResetCurrentVIP(); } - for (int i = 0; i < MAX_VIP_QUEUES; ++i) + for (int i = 0; i < MAX_VIP_QUEUES; i++) { if (m_pVIPQueue[i]) { m_pVIP = m_pVIPQueue[i]; m_pVIP->MakeVIP(); - m_pVIPQueue[i] = NULL; // remove this player from the VIP queue - StackVIPQueue(); // and re-organize the queue + m_pVIPQueue[i] = nullptr; // remove this player from the VIP queue + StackVIPQueue(); // and re-organize the queue m_iConsecutiveVIP = 0; return; } @@ -2308,9 +2220,9 @@ void CHalfLifeMultiplay::PickNextVIP() int iCount = 1; - CBaseEntity *pPlayer = NULL; - CBasePlayer *player = NULL; - CBasePlayer *pLastPlayer = NULL; + CBaseEntity *pPlayer = nullptr; + CBasePlayer *player = nullptr; + CBasePlayer *pLastPlayer = nullptr; pPlayer = UTIL_FindEntityByClassname(pPlayer, "player"); @@ -2337,7 +2249,7 @@ void CHalfLifeMultiplay::PickNextVIP() return; } else if (player->m_iTeam == CT) - ++iCount; + iCount++; if (player->m_iTeam != SPECTATOR) pLastPlayer = player; @@ -2347,10 +2259,10 @@ void CHalfLifeMultiplay::PickNextVIP() } } // There is no VIP and there is no one waiting to be the VIP.. therefore just pick the first CT player we can find. - else if (m_pVIP == NULL) + else if (m_pVIP == nullptr) { - CBaseEntity *pPlayer = NULL; - CBasePlayer *player = NULL; + CBaseEntity *pPlayer = nullptr; + CBasePlayer *player = nullptr; pPlayer = UTIL_FindEntityByClassname(pPlayer, "player"); while (pPlayer && !FNullEnt(pPlayer->edict())) @@ -2497,13 +2409,13 @@ void CHalfLifeMultiplay::Think() m_bFreezePeriod = TRUE; - for (int i = 1; i <= gpGlobals->maxClients; ++i) + for (int i = 1; i <= gpGlobals->maxClients; i++) { CBasePlayer *pPlayer = UTIL_PlayerByIndex(i); if (pPlayer && !pPlayer->IsBot()) { - MESSAGE_BEGIN(MSG_ONE, gmsgCZCareerHUD, NULL, pPlayer->pev); + MESSAGE_BEGIN(MSG_ONE, gmsgCZCareerHUD, nullptr, pPlayer->pev); WRITE_STRING("ROUND"); WRITE_LONG(m_iNumCTWins); WRITE_LONG(m_iNumTerroristWins); @@ -2615,7 +2527,7 @@ bool CHalfLifeMultiplay::CheckGameOver() // check to see if we should change levels now if (m_flIntermissionEndTime < gpGlobals->time && !IsCareer()) { - if (!UTIL_HumansInGame() // if only bots, just change immediately + if (!UTIL_HumansInGame() // if only bots, just change immediately || m_iEndIntermissionButtonHit // check that someone has pressed a key, or the max intermission time is over || ((m_flIntermissionStartTime + MAX_INTERMISSION_TIME) < gpGlobals->time)) { @@ -2800,7 +2712,7 @@ void EXT_FUNC CHalfLifeMultiplay::OnRoundFreezeEnd() TheCareerTasks->HandleEvent(EVENT_ROUND_START); } - for (int i = 1; i <= gpGlobals->maxClients; ++i) + for (int i = 1; i <= gpGlobals->maxClients; i++) { CBasePlayer *plr = UTIL_PlayerByIndex(i); if (!plr || plr->pev->flags == FL_DORMANT) @@ -2848,8 +2760,8 @@ void CHalfLifeMultiplay::CheckFreezePeriodExpired() g_ReGameHookchains.m_CSGameRules_OnRoundFreezeEnd.callChain(&CHalfLifeMultiplay::OnRoundFreezeEnd, this); } -bool CHalfLifeMultiplay::Target_Saved_internal(int winStatus, ScenarioEventEndRound event, float tmDelay) { - +bool CHalfLifeMultiplay::Target_Saved(float tmDelay) +{ Broadcast("ctwin"); m_iAccountCT += m_rgRewardAccountRules[RR_TARGET_BOMB_SAVED]; @@ -2865,23 +2777,24 @@ bool CHalfLifeMultiplay::Target_Saved_internal(int winStatus, ScenarioEventEndRo m_iNumCTWins++; #endif - EndRoundMessage("#Target_Saved", event); - TerminateRound(tmDelay, winStatus); + EndRoundMessage("#Target_Saved", ROUND_TARGET_SAVED); + TerminateRound(tmDelay, WINSTATUS_CTS); if (IsCareer()) { - QueueCareerRoundEndMenu(tmDelay, winStatus); + QueueCareerRoundEndMenu(tmDelay, WINSTATUS_CTS); } #ifndef REGAMEDLL_FIXES UpdateTeamScores(); #endif + MarkLivingPlayersOnTeamAsNotReceivingMoneyNextRound(TERRORIST); return true; } -bool CHalfLifeMultiplay::Hostage_NotRescued_internal(int winStatus, ScenarioEventEndRound event, float tmDelay) { - +bool CHalfLifeMultiplay::Hostage_NotRescued(float tmDelay) +{ Broadcast("terwin"); m_iAccountTerrorist += m_rgRewardAccountRules[RR_HOSTAGE_NOT_RESCUED]; @@ -2897,23 +2810,24 @@ bool CHalfLifeMultiplay::Hostage_NotRescued_internal(int winStatus, ScenarioEven m_iNumTerroristWins++; #endif - EndRoundMessage("#Hostages_Not_Rescued", event); - TerminateRound(tmDelay, winStatus); + EndRoundMessage("#Hostages_Not_Rescued", ROUND_HOSTAGE_NOT_RESCUED); + TerminateRound(tmDelay, WINSTATUS_TERRORISTS); if (IsCareer()) { - QueueCareerRoundEndMenu(tmDelay, winStatus); + QueueCareerRoundEndMenu(tmDelay, WINSTATUS_TERRORISTS); } #ifndef REGAMEDLL_FIXES UpdateTeamScores(); #endif + MarkLivingPlayersOnTeamAsNotReceivingMoneyNextRound(CT); return true; } -bool CHalfLifeMultiplay::Prison_NotEscaped_internal(int winStatus, ScenarioEventEndRound event, float tmDelay) { - +bool CHalfLifeMultiplay::Prison_NotEscaped(float tmDelay) +{ Broadcast("ctwin"); #ifdef REGAMEDLL_FIXES @@ -2928,12 +2842,12 @@ bool CHalfLifeMultiplay::Prison_NotEscaped_internal(int winStatus, ScenarioEvent m_iNumCTWins++; #endif - EndRoundMessage("#Terrorists_Not_Escaped", event); - TerminateRound(tmDelay, winStatus); + EndRoundMessage("#Terrorists_Not_Escaped", ROUND_TERRORISTS_NOT_ESCAPED); + TerminateRound(tmDelay, WINSTATUS_CTS); if (IsCareer()) { - QueueCareerRoundEndMenu(tmDelay, winStatus); + QueueCareerRoundEndMenu(tmDelay, WINSTATUS_CTS); } #ifndef REGAMEDLL_FIXES @@ -2942,8 +2856,8 @@ bool CHalfLifeMultiplay::Prison_NotEscaped_internal(int winStatus, ScenarioEvent return true; } -bool CHalfLifeMultiplay::VIP_NotEscaped_internal(int winStatus, ScenarioEventEndRound event, float tmDelay) { - +bool CHalfLifeMultiplay::VIP_NotEscaped(float tmDelay) +{ Broadcast("terwin"); m_iAccountTerrorist += m_rgRewardAccountRules[RR_VIP_NOT_ESCAPED]; @@ -2959,25 +2873,26 @@ bool CHalfLifeMultiplay::VIP_NotEscaped_internal(int winStatus, ScenarioEventEnd m_iNumTerroristWins++; #endif - EndRoundMessage("#VIP_Not_Escaped", event); - TerminateRound(tmDelay, winStatus); + EndRoundMessage("#VIP_Not_Escaped", ROUND_VIP_NOT_ESCAPED); + TerminateRound(tmDelay, WINSTATUS_TERRORISTS); if (IsCareer()) { - QueueCareerRoundEndMenu(tmDelay, winStatus); + QueueCareerRoundEndMenu(tmDelay, WINSTATUS_TERRORISTS); } #ifndef REGAMEDLL_FIXES UpdateTeamScores(); #endif + return true; } -bool CHalfLifeMultiplay::RoundOver_internal(int winStatus, ScenarioEventEndRound event, float tmDelay) +bool CHalfLifeMultiplay::RoundOver(float tmDelay) { - EndRoundMessage("Round is Over!", event); + EndRoundMessage("Round is Over!", ROUND_GAME_OVER); Broadcast("rounddraw"); - TerminateRound(tmDelay, winStatus); + TerminateRound(tmDelay, WINSTATUS_DRAW); return true; } @@ -2994,7 +2909,7 @@ void CHalfLifeMultiplay::CheckRoundTimeExpired() float flEndRoundTime; // Check to see if there's still a live C4 hanging around.. if so, wait until this C4 blows before ending the round - CGrenade *pBomb = (CGrenade *)UTIL_FindEntityByClassname(NULL, "grenade"); + CGrenade *pBomb = (CGrenade *)UTIL_FindEntityByClassname(nullptr, "grenade"); if (pBomb) { @@ -3008,29 +2923,29 @@ void CHalfLifeMultiplay::CheckRoundTimeExpired() // New code to get rid of round draws!! if (m_bMapHasBombTarget) { - if (!g_ReGameHookchains.m_RoundEnd.callChain(&CHalfLifeMultiplay::Target_Saved_internal, this, WINSTATUS_CTS, ROUND_TARGET_SAVED, GetRoundRestartDelay())) + if (!OnRoundEnd_Intercept(WINSTATUS_CTS, ROUND_TARGET_SAVED, GetRoundRestartDelay())) return; } - else if (UTIL_FindEntityByClassname(NULL, "hostage_entity")) + else if (UTIL_FindEntityByClassname(nullptr, "hostage_entity")) { - if (!g_ReGameHookchains.m_RoundEnd.callChain(&CHalfLifeMultiplay::Hostage_NotRescued_internal, this, WINSTATUS_TERRORISTS, ROUND_HOSTAGE_NOT_RESCUED, GetRoundRestartDelay())) + if (!OnRoundEnd_Intercept(WINSTATUS_TERRORISTS, ROUND_HOSTAGE_NOT_RESCUED, GetRoundRestartDelay())) return; } else if (m_bMapHasEscapeZone) { - if (!g_ReGameHookchains.m_RoundEnd.callChain(&CHalfLifeMultiplay::Prison_NotEscaped_internal, this, WINSTATUS_CTS, ROUND_TERRORISTS_NOT_ESCAPED, GetRoundRestartDelay())) + if (!OnRoundEnd_Intercept(WINSTATUS_CTS, ROUND_TERRORISTS_NOT_ESCAPED, GetRoundRestartDelay())) return; } else if (m_bMapHasVIPSafetyZone) { - if (!g_ReGameHookchains.m_RoundEnd.callChain(&CHalfLifeMultiplay::VIP_NotEscaped_internal, this, WINSTATUS_TERRORISTS, ROUND_VIP_NOT_ESCAPED, GetRoundRestartDelay())) + if (!OnRoundEnd_Intercept(WINSTATUS_TERRORISTS, ROUND_VIP_NOT_ESCAPED, GetRoundRestartDelay())) return; } #ifdef REGAMEDLL_ADD else if (roundover.value) { // round is over - if (!g_ReGameHookchains.m_RoundEnd.callChain(&CHalfLifeMultiplay::RoundOver_internal, this, WINSTATUS_DRAW, ROUND_GAME_OVER, GetRoundRestartDelay())) + if (!OnRoundEnd_Intercept(WINSTATUS_DRAW, ROUND_GAME_OVER, GetRoundRestartDelay())) return; } #endif @@ -3045,22 +2960,39 @@ void CHalfLifeMultiplay::CheckLevelInitialized() { // Count the number of spawn points for each team // This determines the maximum number of players allowed on each - CBaseEntity *ent = NULL; + CBaseEntity *pEnt = nullptr; m_iSpawnPointCount_Terrorist = 0; m_iSpawnPointCount_CT = 0; - while ((ent = UTIL_FindEntityByClassname(ent, "info_player_deathmatch"))) - ++m_iSpawnPointCount_Terrorist; + while ((pEnt = UTIL_FindEntityByClassname(pEnt, "info_player_deathmatch"))) + m_iSpawnPointCount_Terrorist++; - while ((ent = UTIL_FindEntityByClassname(ent, "info_player_start"))) - ++m_iSpawnPointCount_CT; + while ((pEnt = UTIL_FindEntityByClassname(pEnt, "info_player_start"))) + m_iSpawnPointCount_CT++; m_bLevelInitialized = true; } } -bool CHalfLifeMultiplay::RestartRoundCheck_internal(int winStatus, ScenarioEventEndRound event, float tmDelay) { +bool CHalfLifeMultiplay::RestartRoundCheck(float tmDelay) +{ + // log the restart + UTIL_LogPrintf("World triggered \"Restart_Round_(%i_%s)\"\n", (int)tmDelay, (tmDelay == 1) ? "second" : "seconds"); + UTIL_LogPrintf("Team \"CT\" scored \"%i\" with \"%i\" players\n", m_iNumCTWins, m_iNumCT); + UTIL_LogPrintf("Team \"TERRORIST\" scored \"%i\" with \"%i\" players\n", m_iNumTerroristWins, m_iNumTerrorist); + + // let the players know + UTIL_ClientPrintAll(HUD_PRINTCENTER, "#Game_will_restart_in", UTIL_dtos1(tmDelay), (tmDelay == 1) ? "SECOND" : "SECONDS"); + UTIL_ClientPrintAll(HUD_PRINTCONSOLE, "#Game_will_restart_in_console", UTIL_dtos1(tmDelay), (tmDelay == 1) ? "SECOND" : "SECONDS"); + + m_flRestartRoundTime = gpGlobals->time + tmDelay; + m_bCompleteReset = true; + + CVAR_SET_FLOAT("sv_restartround", 0); + CVAR_SET_FLOAT("sv_restart", 0); + + CareerRestart(); return true; } @@ -3068,7 +3000,6 @@ void CHalfLifeMultiplay::CheckRestartRound() { // Restart the round if specified by the server int iRestartDelay = int(restartround.value); - if (!iRestartDelay) { iRestartDelay = sv_restart.value; @@ -3080,25 +3011,8 @@ void CHalfLifeMultiplay::CheckRestartRound() if (iRestartDelay > 60) iRestartDelay = 60; #endif - if (!g_ReGameHookchains.m_RoundEnd.callChain(&CHalfLifeMultiplay::RestartRoundCheck_internal, this, 0, ROUND_GAME_RESTART, iRestartDelay)) - return; - // log the restart - UTIL_LogPrintf("World triggered \"Restart_Round_(%i_%s)\"\n", iRestartDelay, (iRestartDelay == 1) ? "second" : "seconds"); - UTIL_LogPrintf("Team \"CT\" scored \"%i\" with \"%i\" players\n", m_iNumCTWins, m_iNumCT); - UTIL_LogPrintf("Team \"TERRORIST\" scored \"%i\" with \"%i\" players\n", m_iNumTerroristWins, m_iNumTerrorist); - - // let the players know - UTIL_ClientPrintAll(HUD_PRINTCENTER, "#Game_will_restart_in", UTIL_dtos1(iRestartDelay), (iRestartDelay == 1) ? "SECOND" : "SECONDS"); - UTIL_ClientPrintAll(HUD_PRINTCONSOLE, "#Game_will_restart_in_console", UTIL_dtos1(iRestartDelay), (iRestartDelay == 1) ? "SECOND" : "SECONDS"); - - m_flRestartRoundTime = gpGlobals->time + iRestartDelay; - m_bCompleteReset = true; - - CVAR_SET_FLOAT("sv_restartround", 0); - CVAR_SET_FLOAT("sv_restart", 0); - - CareerRestart(); + OnRoundEnd_Intercept(WINSTATUS_NONE, ROUND_GAME_RESTART, iRestartDelay); } } @@ -3149,7 +3063,7 @@ bool CHalfLifeMultiplay::IsBombPlanted() // next round. void CHalfLifeMultiplay::MarkLivingPlayersOnTeamAsNotReceivingMoneyNextRound(int iTeam) { - for (int i = 1; i <= gpGlobals->maxClients; ++i) + for (int i = 1; i <= gpGlobals->maxClients; i++) { CBasePlayer *player = UTIL_PlayerByIndex(i); @@ -3187,7 +3101,7 @@ void CHalfLifeMultiplay::CareerRestart() m_bSkipSpawn = false; - for (int i = 1; i <= gpGlobals->maxClients; ++i) + for (int i = 1; i <= gpGlobals->maxClients; i++) { CBasePlayer *player = UTIL_PlayerByIndex(i); @@ -3221,16 +3135,25 @@ LINK_HOOK_CLASS_CUSTOM_CHAIN(BOOL, CHalfLifeMultiplay, CSGameRules, FShouldSwitc BOOL EXT_FUNC CHalfLifeMultiplay::__API_HOOK(FShouldSwitchWeapon)(CBasePlayer *pPlayer, CBasePlayerItem *pWeapon) { if (!pWeapon->CanDeploy()) + { + // that weapon can't deploy anyway. return FALSE; + } if (!pPlayer->m_pActiveItem) + { + // player doesn't have an active item! return TRUE; + } if (!pPlayer->m_iAutoWepSwitch) return FALSE; if (!pPlayer->m_pActiveItem->CanHolster()) + { + // can't put away the active item. return FALSE; + } if (pWeapon->iWeight() > pPlayer->m_pActiveItem->iWeight()) return TRUE; @@ -3254,9 +3177,9 @@ BOOL EXT_FUNC CHalfLifeMultiplay::__API_HOOK(GetNextBestWeapon)(CBasePlayer *pPl } iBestWeight = -1; // no weapon lower than -1 can be autoswitched to - pBest = NULL; + pBest = nullptr; - for (i = 0; i < MAX_ITEM_TYPES; ++i) + for (i = 0; i < MAX_ITEM_TYPES; i++) { pCheck = pPlayer->m_rgpPlayerItems[i]; @@ -3267,8 +3190,7 @@ BOOL EXT_FUNC CHalfLifeMultiplay::__API_HOOK(GetNextBestWeapon)(CBasePlayer *pPl { //ALERT (at_console, "Considering %s\n", STRING(pCheck->pev->classname)); // we keep updating the 'best' weapon just in case we can't find a weapon of the same weight - // that the player was using. This will end up leaving the player with his heaviest-weighted - // weapon. + // that the player was using. This will end up leaving the player with his heaviest-weighted weapon. if (pCheck->CanDeploy()) { @@ -3314,7 +3236,7 @@ BOOL CHalfLifeMultiplay::ClientConnected(edict_t *pEntity, const char *pszName, void CHalfLifeMultiplay::UpdateGameMode(CBasePlayer *pPlayer) { - MESSAGE_BEGIN(MSG_ONE, gmsgGameMode, NULL, pPlayer->edict()); + MESSAGE_BEGIN(MSG_ONE, gmsgGameMode, nullptr, pPlayer->edict()); WRITE_BYTE(1); MESSAGE_END(); } @@ -3330,13 +3252,13 @@ void CHalfLifeMultiplay::InitHUD(CBasePlayer *pl) if (!g_flWeaponCheat) { - MESSAGE_BEGIN(MSG_ONE, gmsgViewMode, NULL, pl->edict()); + MESSAGE_BEGIN(MSG_ONE, gmsgViewMode, nullptr, pl->edict()); MESSAGE_END(); } // sending just one score makes the hud scoreboard active; otherwise // it is just disabled for single play - MESSAGE_BEGIN(MSG_ONE, gmsgScoreInfo, NULL, pl->edict()); + MESSAGE_BEGIN(MSG_ONE, gmsgScoreInfo, nullptr, pl->edict()); WRITE_BYTE(ENTINDEX(pl->edict())); WRITE_SHORT(0); WRITE_SHORT(0); @@ -3344,13 +3266,13 @@ void CHalfLifeMultiplay::InitHUD(CBasePlayer *pl) WRITE_SHORT(pl->m_iTeam); MESSAGE_END(); - MESSAGE_BEGIN(MSG_ONE, gmsgShadowIdx, NULL, pl->edict()); + MESSAGE_BEGIN(MSG_ONE, gmsgShadowIdx, nullptr, pl->edict()); WRITE_LONG(g_iShadowSprite); MESSAGE_END(); if (IsCareer()) { - MESSAGE_BEGIN(MSG_ONE, gmsgCZCareer, NULL, pl->edict()); + MESSAGE_BEGIN(MSG_ONE, gmsgCZCareer, nullptr, pl->edict()); WRITE_STRING("START"); WRITE_SHORT(m_iRoundTime); MESSAGE_END(); @@ -3359,7 +3281,7 @@ void CHalfLifeMultiplay::InitHUD(CBasePlayer *pl) SendMOTDToClient(pl->edict()); // loop through all active players and send their score info to the new client - for (i = 1; i <= gpGlobals->maxClients; ++i) + for (i = 1; i <= gpGlobals->maxClients; i++) { // FIXME: Probably don't need to cast this just to read m_iDeaths CBasePlayer *plr = UTIL_PlayerByIndex(i); @@ -3370,7 +3292,7 @@ void CHalfLifeMultiplay::InitHUD(CBasePlayer *pl) if (plr->IsDormant()) continue; #endif - MESSAGE_BEGIN(MSG_ONE, gmsgScoreInfo, NULL, pl->edict()); + MESSAGE_BEGIN(MSG_ONE, gmsgScoreInfo, nullptr, pl->edict()); WRITE_BYTE(i); // client number WRITE_SHORT(int(plr->pev->frags)); WRITE_SHORT(plr->m_iDeaths); @@ -3379,21 +3301,21 @@ void CHalfLifeMultiplay::InitHUD(CBasePlayer *pl) MESSAGE_END(); } - MESSAGE_BEGIN(MSG_ONE, gmsgTeamScore, NULL, pl->edict()); + MESSAGE_BEGIN(MSG_ONE, gmsgTeamScore, nullptr, pl->edict()); WRITE_STRING("TERRORIST"); WRITE_SHORT(m_iNumTerroristWins); MESSAGE_END(); - MESSAGE_BEGIN(MSG_ONE, gmsgTeamScore, NULL, pl->edict()); + MESSAGE_BEGIN(MSG_ONE, gmsgTeamScore, nullptr, pl->edict()); WRITE_STRING("CT"); WRITE_SHORT(m_iNumCTWins); MESSAGE_END(); - MESSAGE_BEGIN(MSG_ONE, gmsgAllowSpec, NULL, pl->edict()); + MESSAGE_BEGIN(MSG_ONE, gmsgAllowSpec, nullptr, pl->edict()); WRITE_BYTE(int(allow_spectators.value)); MESSAGE_END(); - MESSAGE_BEGIN(MSG_ONE, gmsgForceCam, NULL, pl->edict()); + MESSAGE_BEGIN(MSG_ONE, gmsgForceCam, nullptr, pl->edict()); WRITE_BYTE(forcecamera.value != 0); WRITE_BYTE(forcechasecam.value != 0); WRITE_BYTE(fadetoblack.value != 0); @@ -3401,11 +3323,11 @@ void CHalfLifeMultiplay::InitHUD(CBasePlayer *pl) if (m_bGameOver) { - MESSAGE_BEGIN(MSG_ONE, SVC_INTERMISSION, NULL, pl->edict()); + MESSAGE_BEGIN(MSG_ONE, SVC_INTERMISSION, nullptr, pl->edict()); MESSAGE_END(); } - for (i = 1; i <= gpGlobals->maxClients; ++i) + for (i = 1; i <= gpGlobals->maxClients; i++) { CBasePlayer *plr = UTIL_PlayerByIndex(i); if (!plr) @@ -3416,7 +3338,7 @@ void CHalfLifeMultiplay::InitHUD(CBasePlayer *pl) continue; #endif - MESSAGE_BEGIN(MSG_ONE, gmsgTeamInfo, NULL, pl->edict()); + MESSAGE_BEGIN(MSG_ONE, gmsgTeamInfo, nullptr, pl->edict()); WRITE_BYTE(plr->entindex()); WRITE_STRING(GetTeamName(plr->m_iTeam)); MESSAGE_END(); @@ -3431,7 +3353,7 @@ void CHalfLifeMultiplay::InitHUD(CBasePlayer *pl) #endif if (plr->pev->deadflag == DEAD_NO) { - MESSAGE_BEGIN(MSG_ONE, gmsgRadar, NULL, pl->edict()); + MESSAGE_BEGIN(MSG_ONE, gmsgRadar, nullptr, pl->edict()); WRITE_BYTE(plr->entindex()); WRITE_COORD(plr->pev->origin.x); WRITE_COORD(plr->pev->origin.y); @@ -3443,7 +3365,7 @@ void CHalfLifeMultiplay::InitHUD(CBasePlayer *pl) auto SendMsgBombDrop = [&pl](const int flag, const Vector& pos) { - MESSAGE_BEGIN(MSG_ONE, gmsgBombDrop, NULL, pl->edict()); + MESSAGE_BEGIN(MSG_ONE, gmsgBombDrop, nullptr, pl->edict()); WRITE_COORD(pos.x); WRITE_COORD(pos.y); WRITE_COORD(pos.z); @@ -3453,7 +3375,7 @@ void CHalfLifeMultiplay::InitHUD(CBasePlayer *pl) if (m_bBombDropped) { - CBaseEntity *pWeaponC4 = UTIL_FindEntityByClassname(NULL, "weapon_c4"); + CBaseEntity *pWeaponC4 = UTIL_FindEntityByClassname(nullptr, "weapon_c4"); if (pWeaponC4) { SendMsgBombDrop(BOMB_FLAG_DROPPED, pWeaponC4->pev->origin); @@ -3472,14 +3394,14 @@ void CHalfLifeMultiplay::InitHUD(CBasePlayer *pl) if (m_iRoundTime > 0 || GetRoundRemainingTime() >= 1.0f) { - MESSAGE_BEGIN(MSG_ONE, gmsgShowTimer, NULL, pl->pev); + MESSAGE_BEGIN(MSG_ONE, gmsgShowTimer, nullptr, pl->pev); MESSAGE_END(); } else { // HACK HACK, we need to hide only the timer. SendMsgBombDrop(BOMB_FLAG_PLANTED, g_vecZero); - MESSAGE_BEGIN(MSG_ONE, gmsgBombPickup, NULL, pl->pev); + MESSAGE_BEGIN(MSG_ONE, gmsgBombPickup, nullptr, pl->pev); MESSAGE_END(); } break; @@ -3493,8 +3415,7 @@ void CHalfLifeMultiplay::ClientDisconnected(edict_t *pClient) { if (pClient) { - CBasePlayer *pPlayer = static_cast(CBaseEntity::Instance(pClient)); - + CBasePlayer *pPlayer = CBasePlayer::Instance(pClient); if (pPlayer) { pPlayer->has_disconnected = true; @@ -3516,7 +3437,7 @@ void CHalfLifeMultiplay::ClientDisconnected(edict_t *pClient) if (pPlayer->m_bIsVIP) { - m_pVIP = NULL; + m_pVIP = nullptr; } pPlayer->m_iCurrentKickVote = 0; @@ -3562,8 +3483,7 @@ void CHalfLifeMultiplay::ClientDisconnected(edict_t *pClient) pPlayer->m_pObserver->SUB_Remove(); } - CBasePlayer *client = NULL; - + CBasePlayer *client = nullptr; while ((client = (CBasePlayer *)UTIL_FindEntityByClassname(client, "player"))) { if (FNullEnt(client->edict())) @@ -3572,6 +3492,7 @@ void CHalfLifeMultiplay::ClientDisconnected(edict_t *pClient) if (!client->pev || client == pPlayer) continue; + // If a spectator was chasing this player, move him/her onto the next player if (client->m_hObserverTarget == pPlayer) { int iMode = client->pev->iuser1; @@ -3590,7 +3511,7 @@ LINK_HOOK_CLASS_CUSTOM_CHAIN(float, CHalfLifeMultiplay, CSGameRules, FlPlayerFal float EXT_FUNC CHalfLifeMultiplay::__API_HOOK(FlPlayerFallDamage)(CBasePlayer *pPlayer) { - pPlayer->m_flFallVelocity -= PLAYER_MAX_SAFE_FALL_SPEED; + pPlayer->m_flFallVelocity -= MAX_PLAYER_SAFE_FALL_SPEED; return pPlayer->m_flFallVelocity * DAMAGE_FOR_FALL_SPEED * 1.25; } @@ -3790,8 +3711,7 @@ BOOL CHalfLifeMultiplay::AllowAutoTargetCrosshair() return FALSE; } -// IPointsForKill - how many points awarded to anyone -// that kills this player? +// How many points awarded to anyone that kills this player? int CHalfLifeMultiplay::IPointsForKill(CBasePlayer *pAttacker, CBasePlayer *pKilled) { return 1; @@ -3799,6 +3719,7 @@ int CHalfLifeMultiplay::IPointsForKill(CBasePlayer *pAttacker, CBasePlayer *pKil LINK_HOOK_CLASS_VOID_CUSTOM_CHAIN(CHalfLifeMultiplay, CSGameRules, PlayerKilled, (CBasePlayer *pVictim, entvars_t *pKiller, entvars_t *pInflictor), pVictim, pKiller, pInflictor) +// Someone/something killed this player void EXT_FUNC CHalfLifeMultiplay::__API_HOOK(PlayerKilled)(CBasePlayer *pVictim, entvars_t *pKiller, entvars_t *pInflictor) { DeathNotice(pVictim, pKiller, pInflictor); @@ -3810,7 +3731,7 @@ void EXT_FUNC CHalfLifeMultiplay::__API_HOOK(PlayerKilled)(CBasePlayer *pVictim, pVictim->m_iTrain = (TRAIN_NEW | TRAIN_OFF); SET_VIEW(ENT(pVictim->pev), ENT(pVictim->pev)); - CBasePlayer *peKiller = NULL; + CBasePlayer *peKiller = nullptr; CBaseEntity *ktmp = CBaseEntity::Instance(pKiller); if (ktmp && ktmp->Classify() == CLASS_PLAYER) @@ -3953,9 +3874,6 @@ LINK_HOOK_CLASS_VOID_CUSTOM_CHAIN(CHalfLifeMultiplay, CSGameRules, DeathNotice, void EXT_FUNC CHalfLifeMultiplay::__API_HOOK(DeathNotice)(CBasePlayer *pVictim, entvars_t *pKiller, entvars_t *pevInflictor) { - // Work out what killed the player, and send a message to all clients about it - // CBaseEntity *Killer = CBaseEntity::Instance(pKiller); - // by default, the player is killed by the world const char *killer_weapon_name = "world"; int killer_index = 0; @@ -3980,7 +3898,9 @@ void EXT_FUNC CHalfLifeMultiplay::__API_HOOK(DeathNotice)(CBasePlayer *pVictim, if (pAttacker && pAttacker->IsPlayer()) { if (pAttacker->m_pActiveItem) + { killer_weapon_name = pAttacker->m_pActiveItem->pszName(); + } } } else @@ -4003,6 +3923,7 @@ void EXT_FUNC CHalfLifeMultiplay::__API_HOOK(DeathNotice)(CBasePlayer *pVictim, const char cut_monster[] = "monster_"; const char cut_func[] = "func_"; + // replace the code names with the 'real' names if (!Q_strncmp(killer_weapon_name, cut_weapon, sizeof(cut_weapon) - 1)) killer_weapon_name += sizeof(cut_weapon) - 1; @@ -4015,16 +3936,15 @@ void EXT_FUNC CHalfLifeMultiplay::__API_HOOK(DeathNotice)(CBasePlayer *pVictim, if (!TheTutor) { MESSAGE_BEGIN(MSG_ALL, gmsgDeathMsg); - WRITE_BYTE(killer_index); // the killer - WRITE_BYTE(ENTINDEX(pVictim->edict())); // the victim - WRITE_BYTE(pVictim->m_bHeadshotKilled); // is killed headshot + WRITE_BYTE(killer_index); // the killer + WRITE_BYTE(ENTINDEX(pVictim->edict())); // the victim + WRITE_BYTE(pVictim->m_bHeadshotKilled); // is killed headshot WRITE_STRING(killer_weapon_name); // what they were killed by (should this be a string?) MESSAGE_END(); } // This weapons from HL isn't it? #ifndef REGAMEDLL_FIXES - // replace the code names with the 'real' names if (!Q_strcmp(killer_weapon_name, "egon")) killer_weapon_name = gluon; @@ -4063,38 +3983,36 @@ void EXT_FUNC CHalfLifeMultiplay::__API_HOOK(DeathNotice)(CBasePlayer *pVictim, CheckWinConditions(); MESSAGE_BEGIN(MSG_SPEC, SVC_DIRECTOR); - WRITE_BYTE(9); // command length in bytes - WRITE_BYTE(DRC_CMD_EVENT); // player killed + WRITE_BYTE(9); // command length in bytes + WRITE_BYTE(DRC_CMD_EVENT); // player killed WRITE_SHORT(ENTINDEX(pVictim->edict())); // index number of primary entity if (pevInflictor) WRITE_SHORT(ENTINDEX(ENT(pevInflictor))); // index number of secondary entity else - WRITE_SHORT(ENTINDEX(ENT(pKiller))); // index number of secondary entity + WRITE_SHORT(ENTINDEX(ENT(pKiller))); // index number of secondary entity if (pVictim->m_bHeadshotKilled) WRITE_LONG(9 | DRC_FLAG_DRAMATIC | DRC_FLAG_SLOWMOTION); else - WRITE_LONG(7 | DRC_FLAG_DRAMATIC); // eventflags (priority and flags) + WRITE_LONG(7 | DRC_FLAG_DRAMATIC); // eventflags (priority and flags) MESSAGE_END(); } -// PlayerGotWeapon - player has grabbed a weapon that was -// sitting in the world +// Player has grabbed a weapon that was sitting in the world void CHalfLifeMultiplay::PlayerGotWeapon(CBasePlayer *pPlayer, CBasePlayerItem *pWeapon) { ; } -// FlWeaponRespawnTime - what is the time in the future -// at which this weapon may spawn? +// What is the time in the future at which this weapon may spawn? float CHalfLifeMultiplay::FlWeaponRespawnTime(CBasePlayerItem *pWeapon) { return gpGlobals->time + WEAPON_RESPAWN_TIME; } -// FlWeaponRespawnTime - Returns 0 if the weapon can respawn now, +// Returns 0 if the weapon can respawn now, // otherwise it returns the time at which it can try to spawn again. float CHalfLifeMultiplay::FlWeaponTryRespawn(CBasePlayerItem *pWeapon) { @@ -4110,11 +4028,14 @@ float CHalfLifeMultiplay::FlWeaponTryRespawn(CBasePlayerItem *pWeapon) return 0; } +// Where should this weapon spawn? +// Some game variations may choose to randomize spawn locations Vector CHalfLifeMultiplay::VecWeaponRespawnSpot(CBasePlayerItem *pWeapon) { return pWeapon->pev->origin; } +// Any conditions inhibiting the respawning of this weapon? int CHalfLifeMultiplay::WeaponShouldRespawn(CBasePlayerItem *pWeapon) { if (pWeapon->pev->spawnflags & SF_NORESPAWN) @@ -4127,6 +4048,7 @@ int CHalfLifeMultiplay::WeaponShouldRespawn(CBasePlayerItem *pWeapon) LINK_HOOK_CLASS_CUSTOM_CHAIN(BOOL, CHalfLifeMultiplay, CSGameRules, CanHavePlayerItem, (CBasePlayer *pPlayer, CBasePlayerItem *pItem), pPlayer, pItem) +// Returns FALSE if the player is not allowed to pick up this weapon BOOL EXT_FUNC CHalfLifeMultiplay::__API_HOOK(CanHavePlayerItem)(CBasePlayer *pPlayer, CBasePlayerItem *pItem) { return CGameRules::CanHavePlayerItem(pPlayer, pItem); @@ -4152,11 +4074,14 @@ int CHalfLifeMultiplay::ItemShouldRespawn(CItem *pItem) return GR_ITEM_RESPAWN_YES; } +// At what time in the future may this Item respawn? float CHalfLifeMultiplay::FlItemRespawnTime(CItem *pItem) { return gpGlobals->time + ITEM_RESPAWN_TIME; } +// Where should this item respawn? +// Some game variations may choose to randomize spawn locations Vector CHalfLifeMultiplay::VecItemRespawnSpot(CItem *pItem) { return pItem->pev->origin; @@ -4264,7 +4189,7 @@ int CHalfLifeMultiplay::PlayerRelationship(CBasePlayer *pPlayer, CBaseEntity *pT BOOL CHalfLifeMultiplay::FAllowFlashlight() { - static cvar_t *mp_flashlight = NULL; + static cvar_t *mp_flashlight = nullptr; if (!mp_flashlight) mp_flashlight = CVAR_GET_POINTER("mp_flashlight"); @@ -4289,7 +4214,10 @@ LINK_HOOK_CLASS_VOID_CUSTOM_CHAIN2(CHalfLifeMultiplay, CSGameRules, GoToIntermis void EXT_FUNC CHalfLifeMultiplay::__API_HOOK(GoToIntermission)() { if (m_bGameOver) + { + // intermission has already been triggered, so ignore. return; + } UTIL_LogPrintf("Team \"CT\" scored \"%i\" with \"%i\" players\n", m_iNumCTWins, m_iNumCT); UTIL_LogPrintf("Team \"TERRORIST\" scored \"%i\" with \"%i\" players\n", m_iNumTerroristWins, m_iNumTerrorist); @@ -4325,11 +4253,10 @@ void EXT_FUNC CHalfLifeMultiplay::__API_HOOK(GoToIntermission)() SERVER_COMMAND("setpause\n"); } + // bounds check int time = int(CVAR_GET_FLOAT("mp_chattime")); - if (time < 1) CVAR_SET_STRING("mp_chattime", "1"); - else if (time > MAX_INTERMISSION_TIME) CVAR_SET_STRING("mp_chattime", UTIL_dtos1(MAX_INTERMISSION_TIME)); @@ -4363,143 +4290,46 @@ void DestroyMapCycle(mapcycle_t *cycle) delete cycle->items; } - cycle->items = NULL; - cycle->next_item = NULL; -} - -char *MP_COM_GetToken() -{ - return mp_com_token; -} - -char *MP_COM_Parse(char *data) -{ - int c; - int len; - - len = 0; - mp_com_token[0] = '\0'; - - if (!data) - { - return NULL; - } - -skipwhite: - // skip whitespace - while (*data <= ' ') - { - if (!data[0]) - return NULL; - - ++data; - } - - c = *data; - - // skip // comments till the next line - if (c == '/' && data[1] == '/') - { - while (*data && *data != '\n') - ++data; - - goto skipwhite; // start over new line - } - - // handle quoted strings specially: copy till the end or another quote - if (c == '\"') - { - ++data; // skip starting quote - - while (true) - { - // get char and advance - c = *data++; - - if (c == '\"' || !c) - { - mp_com_token[ len ] = '\0'; - return data; - } - - mp_com_token[ len++ ] = c; - } - } - - // parse single characters - if (c == '{' || c == '}'|| c == ')'|| c == '(' || c == '\'' || c == ',') - { - mp_com_token[ len++ ] = c; - mp_com_token[ len ] = '\0'; - - return data + 1; - } - - // parse a regular word - do - { - mp_com_token[ len++ ] = c; - ++data; - c = *data; - - if (c == '{' || c == '}'|| c == ')'|| c == '(' || c == '\'' || c == ',') - break; - } - while (c > 32); - - mp_com_token[ len ] = '\0'; - return data; -} - -int MP_COM_TokenWaiting(char *buffer) -{ - char *p; - - p = buffer; - while (*p && *p != '\n') - { - if (!Q_isspace(*p) || Q_isalnum(*p)) - return 1; - - ++p; - } - - return 0; + cycle->items = nullptr; + cycle->next_item = nullptr; } +// Parses mapcycle.txt file into mapcycle_t structure int ReloadMapCycleFile(char *filename, mapcycle_t *cycle) { - char szBuffer[ MAX_RULE_BUFFER ]; - char szMap[ 32 ]; + char szBuffer[MAX_RULE_BUFFER]; + char szMap[MAX_MAPNAME_LENGHT]; int length; + char *pToken; char *pFileList; char *aFileList = pFileList = (char *)LOAD_FILE_FOR_ME(filename, &length); - int hasbuffer; - mapcycle_item_s *item, *newlist = NULL, *next; + bool hasBuffer; + mapcycle_item_s *item, *newlist = nullptr, *next; if (pFileList && length) { // the first map name in the file becomes the default while (true) { - hasbuffer = 0; + hasBuffer = false; Q_memset(szBuffer, 0, sizeof(szBuffer)); - pFileList = MP_COM_Parse(pFileList); + pFileList = SharedParse(pFileList); + pToken = SharedGetToken(); - if (Q_strlen(mp_com_token) <= 0) + if (Q_strlen(pToken) <= 0) break; - Q_strcpy(szMap, mp_com_token); + Q_strcpy(szMap, pToken); // Any more tokens on this line? - if (MP_COM_TokenWaiting(pFileList)) + if (SharedTokenWaiting(pFileList)) { - pFileList = MP_COM_Parse(pFileList); - if (Q_strlen(mp_com_token) > 0) + pFileList = SharedParse(pFileList); + if (Q_strlen(pToken) > 0) { - hasbuffer = 1; - Q_strcpy(szBuffer, mp_com_token); + hasBuffer = true; + Q_strcpy(szBuffer, pToken); } } @@ -4518,7 +4348,7 @@ int ReloadMapCycleFile(char *filename, mapcycle_t *cycle) Q_memset(item->rulebuffer, 0, sizeof(item->rulebuffer)); - if (hasbuffer) + if (hasBuffer) { s = GET_KEY_VALUE(szBuffer, "minplayers"); @@ -4548,7 +4378,9 @@ int ReloadMapCycleFile(char *filename, mapcycle_t *cycle) cycle->items = item; } else + { ALERT(at_console, "Skipping %s from mapcycle, not a valid map\n", szMap); + } } FREE_FILE(aFileList); @@ -4590,7 +4422,7 @@ int ReloadMapCycleFile(char *filename, mapcycle_t *cycle) int CountPlayers() { int nCount = 0; - for (int i = 1; i <= gpGlobals->maxClients; ++i) + for (int i = 1; i <= gpGlobals->maxClients; i++) { CBasePlayer *pPlayer = UTIL_PlayerByIndex(i); if (pPlayer) @@ -4613,7 +4445,7 @@ void ExtractCommandString(char *s, char *szCommand) char *o; if (*s == '\\') - ++s; + s++; while (true) { @@ -4629,7 +4461,7 @@ void ExtractCommandString(char *s, char *szCommand) } *o = '\0'; - ++s; + s++; o = value; @@ -4658,13 +4490,13 @@ void ExtractCommandString(char *s, char *szCommand) return; } - ++s; + s++; } } void CHalfLifeMultiplay::ResetAllMapVotes() { - CBaseEntity *pTempEntity = NULL; + CBaseEntity *pTempEntity = nullptr; while ((pTempEntity = UTIL_FindEntityByClassname(pTempEntity, "player"))) { @@ -4679,7 +4511,7 @@ void CHalfLifeMultiplay::ResetAllMapVotes() } } - for (int j = 0; j < MAX_VOTE_MAPS; ++j) + for (int j = 0; j < MAX_VOTE_MAPS; j++) m_iMapVotes[j] = 0; } @@ -4710,7 +4542,7 @@ void CHalfLifeMultiplay::DisplayMaps(CBasePlayer *player, int iVote) { static mapcycle_t mapcycle2; char *mapcfile = (char *)CVAR_GET_STRING("mapcyclefile"); - char *pszNewMap = NULL; + char *pszNewMap = nullptr; int iCount = 0, done = 0; @@ -4750,7 +4582,7 @@ void CHalfLifeMultiplay::DisplayMaps(CBasePlayer *player, int iVote) if (Q_strcmp(pszNewMap, STRING(gpGlobals->mapname)) != 0) { - CHANGE_LEVEL(pszNewMap, NULL); + CHANGE_LEVEL(pszNewMap, nullptr); return; } @@ -4765,7 +4597,7 @@ void CHalfLifeMultiplay::DisplayMaps(CBasePlayer *player, int iVote) void CHalfLifeMultiplay::ProcessMapVote(CBasePlayer *player, int iVote) { - CBaseEntity *pTempEntity = NULL; + CBaseEntity *pTempEntity = nullptr; int iValidVotes = 0, iNumPlayers = 0; while ((pTempEntity = UTIL_FindEntityByClassname(pTempEntity, "player"))) @@ -4810,7 +4642,7 @@ void CHalfLifeMultiplay::ProcessMapVote(CBasePlayer *player, int iVote) ClientPrint(player->pev, HUD_PRINTCONSOLE, "#Game_required_votes", UTIL_dtos1(iRequiredVotes)); } else - DisplayMaps(NULL, iVote); + DisplayMaps(nullptr, iVote); } LINK_HOOK_CLASS_VOID_CUSTOM_CHAIN2(CHalfLifeMultiplay, CSGameRules, ChangeLevel); @@ -4821,8 +4653,8 @@ void EXT_FUNC CHalfLifeMultiplay::__API_HOOK(ChangeLevel)() static char szPreviousMapCycleFile[256]; static mapcycle_t mapcycle; - char szNextMap[32]; - char szFirstMapInList[32]; + char szNextMap[MAX_MAPNAME_LENGHT]; + char szFirstMapInList[MAX_MAPNAME_LENGHT]; char szCommands[1500]; char szRules[1500]; int minplayers = 0, maxplayers = 0; @@ -4840,7 +4672,7 @@ void EXT_FUNC CHalfLifeMultiplay::__API_HOOK(ChangeLevel)() // find the map to change to char *mapcfile = (char *)CVAR_GET_STRING("mapcyclefile"); - assert(mapcfile != NULL); + assert(mapcfile != nullptr); szCommands[0] = '\0'; szRules[0] = '\0'; @@ -4876,7 +4708,7 @@ void EXT_FUNC CHalfLifeMultiplay::__API_HOOK(ChangeLevel)() { keeplooking = false; - assert(item != NULL); + assert(item != nullptr); if (item->minplayers != 0) { @@ -4945,7 +4777,7 @@ void EXT_FUNC CHalfLifeMultiplay::__API_HOOK(ChangeLevel)() ALERT(at_console, "RULES: %s\n", szRules); } - CHANGE_LEVEL(szNextMap, NULL); + CHANGE_LEVEL(szNextMap, nullptr); if (Q_strlen(szCommands) > 0) { SERVER_COMMAND(szCommands); @@ -4960,7 +4792,7 @@ void CHalfLifeMultiplay::SendMOTDToClient(edict_t *client) char *aFileList = pFileList = (char *)LOAD_FILE_FOR_ME((char *)CVAR_GET_STRING("motdfile"), &length); // send the server name - MESSAGE_BEGIN(MSG_ONE, gmsgServerName, NULL, client); + MESSAGE_BEGIN(MSG_ONE, gmsgServerName, nullptr, client); WRITE_STRING(CVAR_GET_STRING("hostname")); MESSAGE_END(); @@ -4988,7 +4820,7 @@ void CHalfLifeMultiplay::SendMOTDToClient(edict_t *client) else *pFileList = '\0'; - MESSAGE_BEGIN(MSG_ONE, gmsgMOTD, NULL, client); + MESSAGE_BEGIN(MSG_ONE, gmsgMOTD, nullptr, client); WRITE_BYTE((*pFileList != '\0') ? FALSE : TRUE); // FALSE means there is still more message to come WRITE_STRING(chunk); MESSAGE_END(); @@ -5055,3 +4887,51 @@ TeamName CHalfLifeMultiplay::SelectDefaultTeam() return team; } + +void CHalfLifeMultiplay::ChangePlayerTeam(CBasePlayer *pPlayer, const char *pTeamName, BOOL bKill, BOOL bGib) +{ + if (!pTeamName || !pTeamName[0]) + return; + + if (!pPlayer->IsAlive() || pPlayer->m_iJoiningState != JOINED) + return; + + TeamName newTeam; + if (!Q_stricmp(pTeamName, "CT")) + { + newTeam = CT; + } + else if (!Q_stricmp(pTeamName, "TERRORIST")) + { + newTeam = TERRORIST; + } + else if (!Q_stricmp(pTeamName, "SPECTATOR")) + { + newTeam = SPECTATOR; + } + else + { + return; + } + + if (pPlayer->m_iTeam != UNASSIGNED && pPlayer->m_iTeam != newTeam) + { + if (bKill) + { + pPlayer->m_LastHitGroup = HITGROUP_GENERIC; + + // have the player kill themself + pPlayer->pev->health = 0; + pPlayer->Killed(pPlayer->pev, bGib ? GIB_ALWAYS : GIB_NEVER); + + // add 1 to frags to balance out the 1 subtracted for killing yourself + pPlayer->pev->frags++; + } + + pPlayer->m_iTeam = newTeam; + pPlayer->SetPlayerModel(pPlayer->m_bHasC4); + pPlayer->TeamChangeUpdate(); + + CSGameRules()->CheckWinConditions(); + } +} diff --git a/regamedll/dlls/nodes.h b/regamedll/dlls/nodes.h deleted file mode 100644 index f33b590d..00000000 --- a/regamedll/dlls/nodes.h +++ /dev/null @@ -1,69 +0,0 @@ -/* -* -* This program is free software; you can redistribute it and/or modify it -* under the terms of the GNU General Public License as published by the -* Free Software Foundation; either version 2 of the License, or (at -* your option) any later version. -* -* This program 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 -* General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* -*/ - -#ifndef NODES_H -#define NODES_H -#ifdef _WIN32 -#pragma once -#endif - -#define bits_NODE_LAND (1 << 0) // Land node, so nudge if necessary. -#define bits_NODE_AIR (1 << 1) // Air node, don't nudge. -#define bits_NODE_WATER (1 << 2) // Water node, don't nudge. -#define bits_NODE_GROUP_REALM (bits_NODE_LAND | bits_NODE_AIR | bits_NODE_WATER) - -class CBaseEntity; - -class CLink -{ -public: - entvars_t *m_pLinkEnt; -}; - -class CGraph -{ -public: - void InitGraph(); - int AllocNodes(); - int CheckNODFile(char *szMapName); - int FLoadGraph(char *szMapName); - int FSetGraphPointers(); - void ShowNodeConnections(int iNode); - int FindNearestNode(const Vector &vecOrigin, CBaseEntity *pEntity); - int FindNearestNode(const Vector &vecOrigin, int afNodeTypes); - -public: - BOOL m_fGraphPresent; - BOOL m_fGraphPointersSet; - int m_cLinks; - CLink *m_pLinkPool; -}; - -extern CGraph WorldGraph; - -#endif // NODES_H diff --git a/regamedll/dlls/observer.cpp b/regamedll/dlls/observer.cpp index a03b1c0c..ed1b3328 100644 --- a/regamedll/dlls/observer.cpp +++ b/regamedll/dlls/observer.cpp @@ -2,7 +2,7 @@ LINK_HOOK_CHAIN(int, GetForceCamera, (CBasePlayer *pObserver), pObserver) -int EXT_FUNC __API_HOOK(GetForceCamera)(CBasePlayer *pObserver) +int __API_HOOK(GetForceCamera)(CBasePlayer *pObserver) { int retVal; @@ -21,16 +21,16 @@ int EXT_FUNC __API_HOOK(GetForceCamera)(CBasePlayer *pObserver) LINK_HOOK_CLASS_CHAIN(CBasePlayer *, CBasePlayer, Observer_IsValidTarget, (int iPlayerIndex, bool bSameTeam), iPlayerIndex, bSameTeam) -CBasePlayer *EXT_FUNC CBasePlayer::__API_HOOK(Observer_IsValidTarget)(int iPlayerIndex, bool bSameTeam) +CBasePlayer *CBasePlayer::__API_HOOK(Observer_IsValidTarget)(int iPlayerIndex, bool bSameTeam) { if (iPlayerIndex > gpGlobals->maxClients || iPlayerIndex < 1) - return NULL; + return nullptr; CBasePlayer *pPlayer = UTIL_PlayerByIndex(iPlayerIndex); // Don't spec observers or players who haven't picked a class yet if (!pPlayer || pPlayer == this || pPlayer->has_disconnected || pPlayer->IsObserver() || (pPlayer->pev->effects & EF_NODRAW) || pPlayer->m_iTeam == UNASSIGNED || (bSameTeam && pPlayer->m_iTeam != m_iTeam)) - return NULL; + return nullptr; return pPlayer; } @@ -93,7 +93,7 @@ void UpdateClientEffects(CBasePlayer *pObserver, int oldMode) if (pPlayer->m_bNightVisionOn != pObserver->m_bNightVisionOn) { - MESSAGE_BEGIN(MSG_ONE, gmsgNVGToggle, NULL, pObserver->pev); + MESSAGE_BEGIN(MSG_ONE, gmsgNVGToggle, nullptr, pObserver->pev); WRITE_BYTE(pPlayer->m_bNightVisionOn ? STATUS_NIGHTVISION_ON : STATUS_NIGHTVISION_OFF); MESSAGE_END(); @@ -117,7 +117,7 @@ void UpdateClientEffects(CBasePlayer *pObserver, int oldMode) if (clearNightvision) { - MESSAGE_BEGIN(MSG_ONE, gmsgNVGToggle, NULL, pObserver->pev); + MESSAGE_BEGIN(MSG_ONE, gmsgNVGToggle, nullptr, pObserver->pev); WRITE_BYTE(STATUS_NIGHTVISION_OFF); MESSAGE_END(); @@ -141,7 +141,7 @@ void CBasePlayer::Observer_FindNextPlayer(bool bReverse, const char *name) iStart = m_hObserverTarget ? ENTINDEX(m_hObserverTarget->edict()) : ENTINDEX(edict()); iCurrent = iStart; - m_hObserverTarget = NULL; + m_hObserverTarget = nullptr; iDir = bReverse ? -1 : 1; @@ -181,7 +181,7 @@ void CBasePlayer::Observer_FindNextPlayer(bool bReverse, const char *name) if (m_hObserverTarget->pev->health < 0.0f) m_hObserverTarget->pev->health = 0.0f; - MESSAGE_BEGIN(MSG_ONE, gmsgSpecHealth2, NULL, pev); + MESSAGE_BEGIN(MSG_ONE, gmsgSpecHealth2, nullptr, pev); WRITE_BYTE(int(m_hObserverTarget->pev->health)); WRITE_BYTE(ENTINDEX(m_hObserverTarget->edict())); MESSAGE_END(); @@ -316,14 +316,14 @@ void CBasePlayer::Observer_CheckProperties() m_iClientFOV = m_iFOV = target->m_iFOV; // write fov before wepon data, so zoomed crosshair is set correctly - MESSAGE_BEGIN(MSG_ONE, gmsgSetFOV, NULL, pev); + MESSAGE_BEGIN(MSG_ONE, gmsgSetFOV, nullptr, pev); WRITE_BYTE(m_iFOV); MESSAGE_END(); m_iObserverWeapon = weapon; //send weapon update - MESSAGE_BEGIN(MSG_ONE, gmsgCurWeapon, NULL, pev); + MESSAGE_BEGIN(MSG_ONE, gmsgCurWeapon, nullptr, pev); WRITE_BYTE(1); // 1 = current weapon, not on target WRITE_BYTE(m_iObserverWeapon); WRITE_BYTE(0); // clip @@ -344,7 +344,7 @@ void CBasePlayer::Observer_CheckProperties() if (targetBombState) { - MESSAGE_BEGIN(MSG_ONE, gmsgStatusIcon, NULL, pev); + MESSAGE_BEGIN(MSG_ONE, gmsgStatusIcon, nullptr, pev); WRITE_BYTE(m_iObserverC4State); WRITE_STRING("c4"); WRITE_BYTE(0); @@ -354,7 +354,7 @@ void CBasePlayer::Observer_CheckProperties() } else { - MESSAGE_BEGIN(MSG_ONE, gmsgStatusIcon, NULL, pev); + MESSAGE_BEGIN(MSG_ONE, gmsgStatusIcon, nullptr, pev); WRITE_BYTE(STATUSICON_HIDE); WRITE_STRING("c4"); MESSAGE_END(); @@ -367,7 +367,7 @@ void CBasePlayer::Observer_CheckProperties() if (target->m_bHasDefuser) { - MESSAGE_BEGIN(MSG_ONE, gmsgStatusIcon, NULL, pev); + MESSAGE_BEGIN(MSG_ONE, gmsgStatusIcon, nullptr, pev); WRITE_BYTE(STATUSICON_SHOW); WRITE_STRING("defuser"); WRITE_BYTE(0); @@ -377,7 +377,7 @@ void CBasePlayer::Observer_CheckProperties() } else { - MESSAGE_BEGIN(MSG_ONE, gmsgStatusIcon, NULL, pev); + MESSAGE_BEGIN(MSG_ONE, gmsgStatusIcon, nullptr, pev); WRITE_BYTE(STATUSICON_HIDE); WRITE_STRING("defuser"); MESSAGE_END(); @@ -392,7 +392,7 @@ void CBasePlayer::Observer_CheckProperties() { m_iObserverWeapon = 0; - MESSAGE_BEGIN(MSG_ONE, gmsgCurWeapon, NULL, pev); + MESSAGE_BEGIN(MSG_ONE, gmsgCurWeapon, nullptr, pev); WRITE_BYTE(1); // 1 = current weapon WRITE_BYTE(m_iObserverWeapon); WRITE_BYTE(0); // clip @@ -403,7 +403,7 @@ void CBasePlayer::Observer_CheckProperties() { m_iObserverC4State = 0; - MESSAGE_BEGIN(MSG_ONE, gmsgStatusIcon, NULL, pev); + MESSAGE_BEGIN(MSG_ONE, gmsgStatusIcon, nullptr, pev); WRITE_BYTE(0); WRITE_STRING("c4"); MESSAGE_END(); @@ -413,7 +413,7 @@ void CBasePlayer::Observer_CheckProperties() { m_bObserverHasDefuser = false; - MESSAGE_BEGIN(MSG_ONE, gmsgStatusIcon, NULL, pev); + MESSAGE_BEGIN(MSG_ONE, gmsgStatusIcon, nullptr, pev); WRITE_BYTE(0); WRITE_STRING("defuser"); MESSAGE_END(); @@ -451,24 +451,24 @@ void CBasePlayer::Observer_SetMode(int iMode) } // verify observer target again - if (m_hObserverTarget != NULL) + if (m_hObserverTarget) { CBaseEntity *pEnt = m_hObserverTarget; if (pEnt == this || !pEnt || pEnt->has_disconnected || ((CBasePlayer *)pEnt)->IsObserver() || (pEnt->pev->effects & EF_NODRAW) || (_forcecamera != CAMERA_MODE_SPEC_ANYONE && ((CBasePlayer *)pEnt)->m_iTeam != m_iTeam)) - m_hObserverTarget = NULL; + m_hObserverTarget = nullptr; } // set spectator mode pev->iuser1 = iMode; // if we are not roaming, we need a valid target to track - if (iMode != OBS_ROAMING && m_hObserverTarget == NULL) + if (iMode != OBS_ROAMING && !m_hObserverTarget) { Observer_FindNextPlayer(false); // if we didn't find a valid target switch to roaming - if (m_hObserverTarget == NULL) + if (!m_hObserverTarget) { ClientPrint(pev, HUD_PRINTCENTER, "#Spec_NoTarget"); pev->iuser1 = OBS_ROAMING; @@ -484,11 +484,13 @@ void CBasePlayer::Observer_SetMode(int iMode) // clear second target from death cam pev->iuser3 = 0; - if (m_hObserverTarget != NULL) + if (m_hObserverTarget) + { UTIL_SetOrigin(pev, m_hObserverTarget->pev->origin); + } #ifndef REGAMEDLL_FIXES - MESSAGE_BEGIN(MSG_ONE, gmsgCrosshair, NULL, pev); + MESSAGE_BEGIN(MSG_ONE, gmsgCrosshair, nullptr, pev); WRITE_BYTE((iMode == OBS_ROAMING) != 0); MESSAGE_END(); #endif diff --git a/regamedll/dlls/observer.h b/regamedll/dlls/observer.h index 0846b8a4..59897b37 100644 --- a/regamedll/dlls/observer.h +++ b/regamedll/dlls/observer.h @@ -26,21 +26,15 @@ * */ -#ifndef OBSERVER_H -#define OBSERVER_H -#ifdef _WIN32 #pragma once -#endif -#define CAMERA_MODE_SPEC_ANYONE 0 -#define CAMERA_MODE_SPEC_ONLY_TEAM 1 -#define CAMERA_MODE_SPEC_ONLY_FRIST_PERSON 2 +#define CAMERA_MODE_SPEC_ANYONE 0 +#define CAMERA_MODE_SPEC_ONLY_TEAM 1 +#define CAMERA_MODE_SPEC_ONLY_FRIST_PERSON 2 int GetForceCamera(CBasePlayer *pObserver); void UpdateClientEffects(CBasePlayer *pObserver, int oldMode); #ifdef REGAMEDLL_API -int GetForceCamera_OrigFunc(CBasePlayer *pObserver); +EXT_FUNC int GetForceCamera_OrigFunc(CBasePlayer *pObserver); #endif - -#endif // OBSERVER_H diff --git a/regamedll/dlls/pathcorner.cpp b/regamedll/dlls/pathcorner.cpp index 23e298a1..b43893c6 100644 --- a/regamedll/dlls/pathcorner.cpp +++ b/regamedll/dlls/pathcorner.cpp @@ -32,7 +32,9 @@ void CPathCorner::KeyValue(KeyValueData *pkvd) pkvd->fHandled = TRUE; } else + { CPointEntity::KeyValue(pkvd); + } } void CPathCorner::Spawn() @@ -51,7 +53,9 @@ void CPathTrack::KeyValue(KeyValueData *pkvd) pkvd->fHandled = TRUE; } else + { CPointEntity::KeyValue(pkvd); + } } void CPathTrack::Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) @@ -85,31 +89,33 @@ void CPathTrack::Link() if (!FStringNull(pev->target)) { - pentTarget = FIND_ENTITY_BY_TARGETNAME(NULL, STRING(pev->target)); + pentTarget = FIND_ENTITY_BY_TARGETNAME(nullptr, STRING(pev->target)); if (!FNullEnt(pentTarget)) { m_pnext = CPathTrack::Instance(pentTarget); // If no next pointer, this is the end of a path - if (m_pnext != NULL) + if (m_pnext) { m_pnext->SetPrevious(this); } } else + { ALERT(at_console, "Dead end link %s\n", STRING(pev->target)); + } } // Find "alternate" path if (!FStringNull(m_altName)) { - pentTarget = FIND_ENTITY_BY_TARGETNAME(NULL, STRING(m_altName)); + pentTarget = FIND_ENTITY_BY_TARGETNAME(nullptr, STRING(m_altName)); if (!FNullEnt(pentTarget)) { m_paltpath = CPathTrack::Instance(pentTarget); // If no next pointer, this is the end of a path - if (m_paltpath != NULL) + if (m_paltpath) { m_paltpath->SetPrevious(this); } @@ -122,8 +128,8 @@ void CPathTrack::Spawn() pev->solid = SOLID_TRIGGER; UTIL_SetSize(pev, Vector(-8, -8, -8), Vector(8, 8, 8)); - m_pnext = NULL; - m_pprevious = NULL; + m_pnext = nullptr; + m_pprevious = nullptr; } void CPathTrack::Activate() @@ -138,10 +144,10 @@ void CPathTrack::Activate() CPathTrack *CPathTrack::ValidPath(CPathTrack *ppath, int testFlag) { if (!ppath) - return NULL; + return nullptr; if (testFlag && (ppath->pev->spawnflags & SF_PATH_DISABLED)) - return NULL; + return nullptr; return ppath; } @@ -159,7 +165,7 @@ void CPathTrack::Project(CPathTrack *pstart, CPathTrack *pend, Vector *origin, f CPathTrack *CPathTrack::GetNext() { - if (m_paltpath != NULL && (pev->spawnflags & SF_PATH_ALTERNATE) && !(pev->spawnflags & SF_PATH_ALTREVERSE)) + if (m_paltpath && (pev->spawnflags & SF_PATH_ALTERNATE) && !(pev->spawnflags & SF_PATH_ALTREVERSE)) { return m_paltpath; } @@ -169,7 +175,7 @@ CPathTrack *CPathTrack::GetNext() CPathTrack *CPathTrack::GetPrevious() { - if (m_paltpath != NULL && (pev->spawnflags & SF_PATH_ALTERNATE) && (pev->spawnflags & SF_PATH_ALTREVERSE)) + if (m_paltpath && (pev->spawnflags & SF_PATH_ALTERNATE) && (pev->spawnflags & SF_PATH_ALTREVERSE)) { return m_paltpath; } @@ -180,7 +186,7 @@ CPathTrack *CPathTrack::GetPrevious() void CPathTrack::SetPrevious(CPathTrack *pprev) { // Only set previous if this isn't my alternate path - if (pprev != NULL && !FStrEq(STRING(pprev->pev->targetname), STRING(m_altName))) + if (pprev && !FStrEq(STRING(pprev->pev->targetname), STRING(m_altName))) { m_pprevious = pprev; } @@ -214,7 +220,7 @@ CPathTrack *CPathTrack::LookAhead(Vector *origin, float dist, int move) Project(pcurrent->GetNext(), pcurrent, origin, dist); } - return NULL; + return nullptr; } pcurrent = pcurrent->GetPrevious(); @@ -234,7 +240,7 @@ CPathTrack *CPathTrack::LookAhead(Vector *origin, float dist, int move) // If there is no previous node, or it's disabled, return now. if (!ValidPath(pcurrent->GetPrevious(), move)) { - return NULL; + return nullptr; } pcurrent = pcurrent->GetPrevious(); @@ -257,7 +263,7 @@ CPathTrack *CPathTrack::LookAhead(Vector *origin, float dist, int move) Project(pcurrent->GetPrevious(), pcurrent, origin, dist); } - return NULL; + return nullptr; } Vector dir = pcurrent->GetNext()->pev->origin - currentPos; @@ -265,9 +271,9 @@ CPathTrack *CPathTrack::LookAhead(Vector *origin, float dist, int move) if (!length && !ValidPath(pcurrent->GetNext()->GetNext(), move)) { - // HACK -- up against a dead end + // HACK: up against a dead end if (dist == originalDist) - return NULL; + return nullptr; return pcurrent; } @@ -310,12 +316,12 @@ CPathTrack *CPathTrack::Nearest(Vector origin) // Hey, I could use the old 2 racing pointers solution to this, but I'm lazy :) deadCount = 0; - while (ppath != NULL && ppath != this) + while (ppath && ppath != this) { if (++deadCount > 9999) { ALERT(at_error, "Bad sequence of path_tracks from %s", STRING(pev->targetname)); - return NULL; + return nullptr; } delta = origin - ppath->pev->origin; @@ -341,5 +347,5 @@ CPathTrack *CPathTrack::Instance(edict_t *pent) return (CPathTrack *)GET_PRIVATE(pent); } - return NULL; + return nullptr; } diff --git a/regamedll/dlls/pathcorner.h b/regamedll/dlls/pathcorner.h index 93217804..0bd1f0dd 100644 --- a/regamedll/dlls/pathcorner.h +++ b/regamedll/dlls/pathcorner.h @@ -26,11 +26,11 @@ * */ -#ifndef PATHCORNER_H -#define PATHCORNER_H -#ifdef _WIN32 #pragma once -#endif + +#define SF_CORNER_WAITFORTRIG BIT(0) +#define SF_CORNER_TELEPORT BIT(1) +#define SF_CORNER_FIREONCE BIT(2) class CPathCorner: public CPointEntity { @@ -47,5 +47,3 @@ public: private: float m_flWait; }; - -#endif // PATHCORNER_H diff --git a/regamedll/dlls/plane.cpp b/regamedll/dlls/plane.cpp deleted file mode 100644 index 88eb5c9f..00000000 --- a/regamedll/dlls/plane.cpp +++ /dev/null @@ -1,30 +0,0 @@ -#include "precompiled.h" - -CPlane::CPlane() -{ - m_fInitialized = FALSE; -} - -NOXREF void CPlane::InitializePlane(const Vector &vecNormal, const Vector &vecPoint) -{ - m_vecNormal = vecNormal; - m_fInitialized = TRUE; - m_flDist = DotProduct(m_vecNormal, vecPoint); -} - -NOXREF BOOL CPlane::PointInFront(const Vector &vecPoint) -{ - if (!m_fInitialized) - { - return FALSE; - } - - float flFace = DotProduct(m_vecNormal, vecPoint) - m_flDist; - - if (flFace >= 0.0f) - { - return TRUE; - } - - return FALSE; -} diff --git a/regamedll/dlls/plane.h b/regamedll/dlls/plane.h deleted file mode 100644 index 52a410ba..00000000 --- a/regamedll/dlls/plane.h +++ /dev/null @@ -1,49 +0,0 @@ -/* -* -* This program is free software; you can redistribute it and/or modify it -* under the terms of the GNU General Public License as published by the -* Free Software Foundation; either version 2 of the License, or (at -* your option) any later version. -* -* This program 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 -* General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* -*/ - -#ifndef PLANE_H -#define PLANE_H -#ifdef _WIN32 -#pragma once -#endif - -class CPlane -{ -public: - CPlane(); - - void InitializePlane(const Vector &vecNormal, const Vector &vecPoint); - BOOL PointInFront(const Vector &vecPoint); - -private: - Vector m_vecNormal; - float m_flDist; - BOOL m_fInitialized; -}; - -#endif // PLANE_H diff --git a/regamedll/dlls/plats.cpp b/regamedll/dlls/plats.cpp index 0253ee43..71e2b324 100644 --- a/regamedll/dlls/plats.cpp +++ b/regamedll/dlls/plats.cpp @@ -101,7 +101,9 @@ void CBasePlatTrain::KeyValue(KeyValueData *pkvd) pkvd->fHandled = TRUE; } else + { CBaseToggle::KeyValue(pkvd); + } } #define noiseMoving noise @@ -292,13 +294,18 @@ void CFuncPlat::Setup() } } +void PlatSpawnInsideTrigger(entvars_t *pevPlatform) +{ + GetClassPtr((CPlatTrigger *)nullptr)->SpawnInsideTrigger(GetClassPtr((CFuncPlat *)pevPlatform)); +} + void CFuncPlat::Precache() { CBasePlatTrain::Precache(); if (!IsTogglePlat()) { - // the "start moving" trigger + // The "start moving" trigger PlatSpawnInsideTrigger(pev); } } @@ -323,11 +330,6 @@ void CFuncPlat::Spawn() } } -void PlatSpawnInsideTrigger(entvars_t *pevPlatform) -{ - GetClassPtr((CPlatTrigger *)NULL)->SpawnInsideTrigger(GetClassPtr((CFuncPlat *)pevPlatform)); -} - // Create a trigger entity for a platform. void CPlatTrigger::SpawnInsideTrigger(CFuncPlat *pPlatform) { @@ -599,7 +601,9 @@ void CFuncTrain::KeyValue(KeyValueData *pkvd) pkvd->fHandled = TRUE; } else + { CBasePlatTrain::KeyValue(pkvd); + } } void CFuncTrain::Blocked(CBaseEntity *pOther) @@ -771,7 +775,7 @@ void CFuncTrain::Activate() if (!m_activated) { m_activated = TRUE; - entvars_t *pevTarg = VARS(FIND_ENTITY_BY_TARGETNAME(NULL, STRING(pev->target))); + entvars_t *pevTarg = VARS(FIND_ENTITY_BY_TARGETNAME(nullptr, STRING(pev->target))); pev->target = pevTarg->target; @@ -820,7 +824,7 @@ void CFuncTrain::Spawn() m_pevFirstTarget = m_pevCurrentTarget; #else // keep track of this since path corners change our target for us. - m_pevFirstTarget = VARS(FIND_ENTITY_BY_TARGETNAME(NULL, STRING(pev->target))); + m_pevFirstTarget = VARS(FIND_ENTITY_BY_TARGETNAME(nullptr, STRING(pev->target))); #endif // TODO: brush-entity is always zero origin, use (mins+max)*0.5f @@ -957,7 +961,9 @@ void CFuncTrackTrain::KeyValue(KeyValueData *pkvd) pkvd->fHandled = TRUE; } else + { CBaseEntity::KeyValue(pkvd); + } } void CFuncTrackTrain::NextThink(float thinkTime, BOOL alwaysThink) @@ -1050,26 +1056,6 @@ void CFuncTrackTrain::Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYP } } -float_precision Fix(float_precision v) -{ - float_precision angle = v; - - while (angle < 0) - angle += 360; - - while (angle > 360) - angle -= 360; - - return angle; -} - -void FixupAngles(Vector &v) -{ - v.x = Fix(v.x); - v.y = Fix(v.y); - v.z = Fix(v.z); -} - void CFuncTrackTrain::StopSound() { // if sound playing, stop it @@ -1177,18 +1163,16 @@ void CFuncTrackTrain::Next() angles.y += 180.0f; // TODO: All of this crap has to be done to make the angles not wrap around, revisit this. - FixupAngles(angles); - FixupAngles(pev->angles); + UTIL_FixupAngles(angles); #else float_precision fixAngleY = angles.y + 180.0f; - angles.x = Fix(angles.x); - angles.y = Fix(fixAngleY); // TODO: fix test demo - angles.z = Fix(angles.z); - - FixupAngles(pev->angles); + angles.x = UTIL_FixupAngle(angles.x); + angles.y = UTIL_FixupAngle(fixAngleY); // TODO: fix test demo + angles.z = UTIL_FixupAngle(angles.z); #endif + UTIL_FixupAngles(pev->angles); if (!pnext || (delta.x == 0 && delta.y == 0)) angles = pev->angles; @@ -1302,40 +1286,38 @@ void CFuncTrackTrain::DeadEnd() // Find the dead end path node // HACKHACK -- This is bugly, but the train can actually stop moving at a different node depending on it's speed // so we have to traverse the list to it's end. - if (pTrack != NULL) + if (pTrack) { if (m_oldSpeed < 0) { do { pNext = pTrack->ValidPath(pTrack->GetPrevious(), TRUE); - if (pNext) { pTrack = pNext; } } - while (pNext != NULL); + while (pNext); } else { do { pNext = pTrack->ValidPath(pTrack->GetNext(), TRUE); - - if (pNext != NULL) + if (pNext) { pTrack = pNext; } } - while (pNext != NULL); + while (pNext); } } pev->velocity = g_vecZero; pev->avelocity = g_vecZero; - if (pTrack != NULL) + if (pTrack) { ALERT(at_aiconsole, "at %s\n", STRING(pTrack->pev->targetname)); @@ -1380,7 +1362,7 @@ BOOL CFuncTrackTrain::OnControls(entvars_t *pevTest) void CFuncTrackTrain::Find() { - m_ppath = CPathTrack::Instance(FIND_ENTITY_BY_TARGETNAME(NULL, STRING(pev->target))); + m_ppath = CPathTrack::Instance(FIND_ENTITY_BY_TARGETNAME(nullptr, STRING(pev->target))); if (!m_ppath) { @@ -1391,7 +1373,7 @@ void CFuncTrackTrain::Find() if (!FClassnameIs(pevTarget, "path_track")) { ALERT(at_error, "func_track_train must be on a path of path_track\n"); - m_ppath = NULL; + m_ppath = nullptr; return; } @@ -1423,14 +1405,12 @@ void CFuncTrackTrain::Find() void CFuncTrackTrain::NearestPath() { - CBaseEntity *pTrack = NULL; - CBaseEntity *pNearest = NULL; + CBaseEntity *pTrack = nullptr; + CBaseEntity *pNearest = nullptr; float_precision dist; - float closest; + float closest = 1024; - closest = 1024; - - while ((pTrack = UTIL_FindEntityInSphere(pTrack, pev->origin, 1024)) != NULL) + while ((pTrack = UTIL_FindEntityInSphere(pTrack, pev->origin, 1024))) { // filter out non-tracks if (!(pTrack->pev->flags & (FL_CLIENT | FL_MONSTER)) && FClassnameIs(pTrack->pev, "path_track")) @@ -1457,7 +1437,7 @@ void CFuncTrackTrain::NearestPath() // If I'm closer to the next path_track on this path, then it's my real path pTrack = ((CPathTrack *)pNearest)->GetNext(); - if (pTrack != NULL) + if (pTrack) { if ((pev->origin - pTrack->pev->origin).Length() < (pev->origin - pNearest->pev->origin).Length()) { @@ -1487,7 +1467,7 @@ CFuncTrackTrain *CFuncTrackTrain::Instance(edict_t *pent) return (CFuncTrackTrain *)GET_PRIVATE(pent); } - return NULL; + return nullptr; } void CFuncTrackTrain::Spawn() @@ -1584,7 +1564,7 @@ LINK_ENTITY_TO_CLASS(func_traincontrols, CFuncTrainControls, CCSFuncTrainControl void CFuncTrainControls::Find() { - edict_t *pTarget = NULL; + edict_t *pTarget = nullptr; do { @@ -1707,20 +1687,20 @@ void CFuncTrackChange::Find() // Find track entities edict_t *target; - target = FIND_ENTITY_BY_TARGETNAME(NULL, STRING(m_trackTopName)); + target = FIND_ENTITY_BY_TARGETNAME(nullptr, STRING(m_trackTopName)); if (!FNullEnt(target)) { m_trackTop = CPathTrack::Instance(target); - target = FIND_ENTITY_BY_TARGETNAME(NULL, STRING(m_trackBottomName)); + target = FIND_ENTITY_BY_TARGETNAME(nullptr, STRING(m_trackBottomName)); if (!FNullEnt(target)) { m_trackBottom = CPathTrack::Instance(target); - target = FIND_ENTITY_BY_TARGETNAME(NULL, STRING(m_trainName)); + target = FIND_ENTITY_BY_TARGETNAME(nullptr, STRING(m_trainName)); if (!FNullEnt(target)) { - m_train = CFuncTrackTrain::Instance(FIND_ENTITY_BY_TARGETNAME(NULL, STRING(m_trainName))); + m_train = CFuncTrackTrain::Instance(FIND_ENTITY_BY_TARGETNAME(nullptr, STRING(m_trainName))); if (!m_train) { @@ -1738,7 +1718,7 @@ void CFuncTrackChange::Find() else { ALERT(at_error, "Can't find train for track change! %s\n", STRING(m_trainName)); - target = FIND_ENTITY_BY_TARGETNAME(NULL, STRING(m_trainName)); + target = FIND_ENTITY_BY_TARGETNAME(nullptr, STRING(m_trainName)); } } else @@ -1832,7 +1812,7 @@ void CFuncTrackChange::GoDown() if (m_code == TRAIN_FOLLOWING) { UpdateTrain(m_start); - m_train->m_ppath = NULL; + m_train->m_ppath = nullptr; } } @@ -1866,7 +1846,7 @@ void CFuncTrackChange::GoUp() if (m_code == TRAIN_FOLLOWING) { UpdateTrain(m_end); - m_train->m_ppath = NULL; + m_train->m_ppath = nullptr; } } @@ -1979,7 +1959,7 @@ void CFuncTrackAuto::UpdateAutoTargets(int toggleState) pNextTarget = m_trackTop->GetNext(); } - if (pTarget != NULL) + if (pTarget) { pTarget->pev->spawnflags &= ~SF_PATH_DISABLED; @@ -1989,7 +1969,7 @@ void CFuncTrackAuto::UpdateAutoTargets(int toggleState) } } - if (pNextTarget != NULL) + if (pNextTarget) { pNextTarget->pev->spawnflags |= SF_PATH_DISABLED; } @@ -2011,7 +1991,7 @@ void CFuncTrackAuto::Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE pTarget = m_trackBottom; break; default: - pTarget = NULL; + pTarget = nullptr; break; } @@ -2032,12 +2012,12 @@ void CFuncTrackAuto::Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE } else { - if (pTarget != NULL) + if (pTarget) { pTarget = pTarget->GetNext(); } - if (pTarget != NULL && m_train->m_ppath != pTarget && ShouldToggle(useType, m_targetState)) + if (pTarget && m_train->m_ppath != pTarget && ShouldToggle(useType, m_targetState)) { if (m_targetState == TS_AT_TOP) m_targetState = TS_AT_BOTTOM; @@ -2072,7 +2052,7 @@ void CGunTarget::Spawn() m_on = FALSE; pev->max_health = pev->health; - if (pev->spawnflags & FGUNTARGET_START_ON) + if (pev->spawnflags & SF_GUNTARGET_START_ON) { SetThink(&CGunTarget::Start); pev->nextthink = pev->ltime + 0.3f; @@ -2086,7 +2066,7 @@ void CGunTarget::Activate() // now find our next target pTarg = GetNextTarget(); - if (pTarg != NULL) + if (pTarg) { m_hTargetEnt = pTarg; UTIL_SetOrigin(pev, pTarg->pev->origin - (pev->mins + pev->maxs) * 0.5f); @@ -2193,7 +2173,7 @@ void CGunTarget::Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE use { pev->takedamage = DAMAGE_AIM; m_hTargetEnt = GetNextTarget(); - if (m_hTargetEnt == NULL) + if (!m_hTargetEnt) return; pev->health = pev->max_health; diff --git a/regamedll/dlls/plats.h b/regamedll/dlls/plats.h index e06b6c83..04b9fcb9 100644 --- a/regamedll/dlls/plats.h +++ b/regamedll/dlls/plats.h @@ -26,25 +26,10 @@ * */ -#ifndef PLATS_H -#define PLATS_H -#ifdef _WIN32 #pragma once -#endif -#define SF_PLAT_TOGGLE 0x0001 - -#define TRAIN_STARTPITCH 60 -#define TRAIN_MAXPITCH 200 -#define TRAIN_MAXSPEED 1000 - -#define SF_TRACK_ACTIVATETRAIN 0x00000001 -#define SF_TRACK_RELINK 0x00000002 -#define SF_TRACK_ROTMOVE 0x00000004 -#define SF_TRACK_STARTBOTTOM 0x00000008 -#define SF_TRACK_DONT_MOVE 0x00000010 - -#define FGUNTARGET_START_ON 0x0001 +#define SF_PLAT_TOGGLE BIT(0) // The lift is no more automatically called from top and activated by stepping on it. + // It required trigger to do so. class CBasePlatTrain: public CBaseToggle { @@ -120,6 +105,10 @@ public: Vector m_start; }; +#define SF_TRAIN_WAIT_RETRIGGER BIT(0) +#define SF_TRAIN_START_ON BIT(2) // Train is initially moving +#define SF_TRAIN_PASSABLE BIT(3) // Train is not solid -- used to make water trains + class CFuncTrain: public CBasePlatTrain { public: @@ -148,6 +137,7 @@ public: BOOL m_activated; }; +// This class defines the volume of space that the player must stand in to control the train class CFuncTrainControls: public CBaseEntity { public: @@ -158,6 +148,17 @@ public: void EXPORT Find(); }; +#define SF_TRACK_ACTIVATETRAIN BIT(0) +#define SF_TRACK_RELINK BIT(1) +#define SF_TRACK_ROTMOVE BIT(2) +#define SF_TRACK_STARTBOTTOM BIT(3) +#define SF_TRACK_DONT_MOVE BIT(4) + +enum TRAIN_CODE { TRAIN_SAFE, TRAIN_BLOCKING, TRAIN_FOLLOWING }; + +// This entity is a rotating/moving platform that will carry a train to a new track. +// It must be larger in X-Y planar area than the train, since it must contain the +// train within these dimensions in order to operate when the train is near it. class CFuncTrackChange: public CFuncPlatRot { public: @@ -211,6 +212,12 @@ public: virtual void UpdateAutoTargets(int toggleState); }; +// pev->speed is the travel speed +// pev->health is current health +// pev->max_health is the amount to reset to each time it starts + +#define SF_GUNTARGET_START_ON BIT(0) + class CGunTarget: public CBaseMonster { public: @@ -237,8 +244,3 @@ public: private: BOOL m_on; }; - -void PlatSpawnInsideTrigger(entvars_t *pevPlatform); -void FixupAngles(Vector &v); - -#endif // PLATS_H diff --git a/regamedll/dlls/player.cpp b/regamedll/dlls/player.cpp index 210b05bd..71c2d9ed 100644 --- a/regamedll/dlls/player.cpp +++ b/regamedll/dlls/player.cpp @@ -5,93 +5,11 @@ */ #ifndef HOOK_GAMEDLL -int giPrecacheGrunt = 0; -int gmsgWeapPickup = 0; -int gmsgHudText = 0; -int gmsgHudTextArgs = 0; -int gmsgShake = 0; -int gmsgFade = 0; -int gmsgFlashlight = 0; -int gmsgFlashBattery = 0; -int gmsgResetHUD = 0; -int gmsgInitHUD = 0; -int gmsgViewMode = 0; -int gmsgShowGameTitle = 0; -int gmsgCurWeapon = 0; -int gmsgHealth = 0; -int gmsgDamage = 0; -int gmsgBattery = 0; -int gmsgTrain = 0; -int gmsgLogo = 0; -int gmsgWeaponList = 0; -int gmsgAmmoX = 0; -int gmsgDeathMsg = 0; -int gmsgScoreAttrib = 0; -int gmsgScoreInfo = 0; -int gmsgTeamInfo = 0; -int gmsgTeamScore = 0; -int gmsgGameMode = 0; -int gmsgMOTD = 0; -int gmsgServerName = 0; -int gmsgAmmoPickup = 0; -int gmsgItemPickup = 0; -int gmsgHideWeapon = 0; -int gmsgSayText = 0; -int gmsgTextMsg = 0; -int gmsgSetFOV = 0; -int gmsgShowMenu = 0; -int gmsgSendAudio = 0; -int gmsgRoundTime = 0; -int gmsgMoney = 0; -int gmsgBlinkAcct = 0; -int gmsgArmorType = 0; -int gmsgStatusValue = 0; -int gmsgStatusText = 0; -int gmsgStatusIcon = 0; -int gmsgBarTime = 0; -int gmsgReloadSound = 0; -int gmsgCrosshair = 0; -int gmsgNVGToggle = 0; -int gmsgRadar = 0; -int gmsgSpectator = 0; -int gmsgVGUIMenu = 0; -int gmsgCZCareer = 0; -int gmsgCZCareerHUD = 0; -int gmsgTaskTime = 0; -int gmsgTutorText = 0; -int gmsgTutorLine = 0; -int gmsgShadowIdx = 0; -int gmsgTutorState = 0; -int gmsgTutorClose = 0; -int gmsgAllowSpec = 0; -int gmsgBombDrop = 0; -int gmsgBombPickup = 0; -int gmsgHostagePos = 0; -int gmsgHostageK = 0; -int gmsgGeigerRange = 0; -int gmsgSendCorpse = 0; -int gmsgHLTV = 0; -int gmsgSpecHealth = 0; -int gmsgForceCam = 0; -int gmsgADStop = 0; -int gmsgReceiveW = 0; -int gmsgScenarioIcon = 0; -int gmsgBotVoice = 0; -int gmsgBuyClose = 0; -int gmsgItemStatus = 0; -int gmsgLocation = 0; -int gmsgSpecHealth2 = 0; -int gmsgBarTime2 = 0; -int gmsgBotProgress = 0; -int gmsgBrass = 0; -int gmsgFog = 0; -int gmsgShowTimer = 0; - BOOL gInitHUD = TRUE; TYPEDESCRIPTION CRevertSaved::m_SaveData[] = { - DEFINE_FIELD(CRevertSaved, m_messageTime, FIELD_FLOAT), // These are not actual times, but durations, so save as floats + DEFINE_FIELD(CRevertSaved, m_messageTime, FIELD_FLOAT), // These are not actual times, but durations, so save as floats DEFINE_FIELD(CRevertSaved, m_loadTime, FIELD_FLOAT), }; @@ -110,10 +28,10 @@ TYPEDESCRIPTION CBasePlayer::m_playerSaveData[] = DEFINE_FIELD(CBasePlayer, m_flDuckTime, FIELD_TIME), DEFINE_FIELD(CBasePlayer, m_flWallJumpTime, FIELD_TIME), DEFINE_FIELD(CBasePlayer, m_flSuitUpdate, FIELD_TIME), - DEFINE_ARRAY(CBasePlayer, m_rgSuitPlayList, FIELD_INTEGER, CSUITPLAYLIST), + DEFINE_ARRAY(CBasePlayer, m_rgSuitPlayList, FIELD_INTEGER, MAX_SUIT_PLAYLIST), DEFINE_FIELD(CBasePlayer, m_iSuitPlayNext, FIELD_INTEGER), - DEFINE_ARRAY(CBasePlayer, m_rgiSuitNoRepeat, FIELD_INTEGER, CSUITNOREPEAT), - DEFINE_ARRAY(CBasePlayer, m_rgflSuitNoRepeatTime, FIELD_TIME, CSUITNOREPEAT), + DEFINE_ARRAY(CBasePlayer, m_rgiSuitNoRepeat, FIELD_INTEGER, MAX_SUIT_NOREPEAT), + DEFINE_ARRAY(CBasePlayer, m_rgflSuitNoRepeatTime, FIELD_TIME, MAX_SUIT_NOREPEAT), DEFINE_FIELD(CBasePlayer, m_lastDamageAmount, FIELD_INTEGER), DEFINE_ARRAY(CBasePlayer, m_rgpPlayerItems, FIELD_CLASSPTR, MAX_ITEM_TYPES), DEFINE_FIELD(CBasePlayer, m_pActiveItem, FIELD_CLASSPTR), @@ -152,134 +70,6 @@ char *CDeadHEV::m_szPoses[] = int gEvilImpulse101; entvars_t *g_pevLastInflictor; -CBaseEntity *g_pLastSpawn; -CBaseEntity *g_pLastCTSpawn; -CBaseEntity *g_pLastTerroristSpawn; - -struct ZombieSpawn -{ - CBaseEntity *entity; - CountdownTimer useableTimer; -}; - -ZombieSpawn zombieSpawn[256]; -int zombieSpawnCount; - -void LinkUserMessages() -{ - if (gmsgCurWeapon) - return; - - gmsgCurWeapon = REG_USER_MSG("CurWeapon", 3); - gmsgGeigerRange = REG_USER_MSG("Geiger", 1); - gmsgFlashlight = REG_USER_MSG("Flashlight", 2); - gmsgFlashBattery = REG_USER_MSG("FlashBat", 1); - gmsgHealth = REG_USER_MSG("Health", 1); - gmsgDamage = REG_USER_MSG("Damage", 12); - gmsgBattery = REG_USER_MSG("Battery", 2); - gmsgTrain = REG_USER_MSG("Train", 1); - gmsgHudText = REG_USER_MSG("HudTextPro", -1); - REG_USER_MSG("HudText", -1); - gmsgSayText = REG_USER_MSG("SayText", -1); - gmsgTextMsg = REG_USER_MSG("TextMsg", -1); - gmsgWeaponList = REG_USER_MSG("WeaponList", -1); - gmsgResetHUD = REG_USER_MSG("ResetHUD", 0); - gmsgInitHUD = REG_USER_MSG("InitHUD", 0); - gmsgViewMode = REG_USER_MSG("ViewMode", 0); - gmsgShowGameTitle = REG_USER_MSG("GameTitle", 1); - gmsgDeathMsg = REG_USER_MSG("DeathMsg", -1); - gmsgScoreAttrib = REG_USER_MSG("ScoreAttrib", 2); - gmsgScoreInfo = REG_USER_MSG("ScoreInfo", 9); - gmsgTeamInfo = REG_USER_MSG("TeamInfo", -1); - gmsgTeamScore = REG_USER_MSG("TeamScore", -1); - gmsgGameMode = REG_USER_MSG("GameMode", 1); - gmsgMOTD = REG_USER_MSG("MOTD", -1); - gmsgServerName = REG_USER_MSG("ServerName", -1); - gmsgAmmoPickup = REG_USER_MSG("AmmoPickup", 2); - gmsgWeapPickup = REG_USER_MSG("WeapPickup", 1); - gmsgItemPickup = REG_USER_MSG("ItemPickup", -1); - gmsgHideWeapon = REG_USER_MSG("HideWeapon", 1); - gmsgSetFOV = REG_USER_MSG("SetFOV", 1); - gmsgShowMenu = REG_USER_MSG("ShowMenu", -1); - gmsgShake = REG_USER_MSG("ScreenShake", 6); - gmsgFade = REG_USER_MSG("ScreenFade", 10); - gmsgAmmoX = REG_USER_MSG("AmmoX", 2); - gmsgSendAudio = REG_USER_MSG("SendAudio", -1); - gmsgRoundTime = REG_USER_MSG("RoundTime", 2); - gmsgMoney = REG_USER_MSG("Money", 5); - gmsgArmorType = REG_USER_MSG("ArmorType", 1); - gmsgBlinkAcct = REG_USER_MSG("BlinkAcct", 1); - gmsgStatusValue = REG_USER_MSG("StatusValue", -1); - gmsgStatusText = REG_USER_MSG("StatusText", -1); - gmsgStatusIcon = REG_USER_MSG("StatusIcon", -1); - gmsgBarTime = REG_USER_MSG("BarTime", 2); - gmsgReloadSound = REG_USER_MSG("ReloadSound", 2); - gmsgCrosshair = REG_USER_MSG("Crosshair", 1); - gmsgNVGToggle = REG_USER_MSG("NVGToggle", 1); - gmsgRadar = REG_USER_MSG("Radar", 7); - gmsgSpectator = REG_USER_MSG("Spectator", 2); - gmsgVGUIMenu = REG_USER_MSG("VGUIMenu", -1); - gmsgTutorText = REG_USER_MSG("TutorText", -1); - gmsgTutorLine = REG_USER_MSG("TutorLine", -1); - gmsgTutorState = REG_USER_MSG("TutorState", -1); - gmsgTutorClose = REG_USER_MSG("TutorClose", -1); - gmsgAllowSpec = REG_USER_MSG("AllowSpec", 1); - gmsgBombDrop = REG_USER_MSG("BombDrop", 7); - gmsgBombPickup = REG_USER_MSG("BombPickup", 0); - gmsgSendCorpse = REG_USER_MSG("ClCorpse", -1); - gmsgHostagePos = REG_USER_MSG("HostagePos", 8); - gmsgHostageK = REG_USER_MSG("HostageK", 1); - gmsgHLTV = REG_USER_MSG("HLTV", 2); - gmsgSpecHealth = REG_USER_MSG("SpecHealth", 1); - gmsgForceCam = REG_USER_MSG("ForceCam", 3); - gmsgADStop = REG_USER_MSG("ADStop", 0); - gmsgReceiveW = REG_USER_MSG("ReceiveW", 1); - gmsgCZCareer = REG_USER_MSG("CZCareer", -1); - gmsgCZCareerHUD = REG_USER_MSG("CZCareerHUD", -1); - gmsgShadowIdx = REG_USER_MSG("ShadowIdx", 4); - gmsgTaskTime = REG_USER_MSG("TaskTime", 4); - gmsgScenarioIcon = REG_USER_MSG("Scenario", -1); - gmsgBotVoice = REG_USER_MSG("BotVoice", 2); - gmsgBuyClose = REG_USER_MSG("BuyClose", 0); - gmsgSpecHealth2 = REG_USER_MSG("SpecHealth2", 2); - gmsgBarTime2 = REG_USER_MSG("BarTime2", 4); - gmsgItemStatus = REG_USER_MSG("ItemStatus", 1); - gmsgLocation = REG_USER_MSG("Location", -1); - gmsgBotProgress = REG_USER_MSG("BotProgress", -1); - gmsgBrass = REG_USER_MSG("Brass", -1); - gmsgFog = REG_USER_MSG("Fog", 7); - gmsgShowTimer = REG_USER_MSG("ShowTimer", 0); - gmsgHudTextArgs = REG_USER_MSG("HudTextArgs", -1); -} - -void WriteSigonMessages() -{ - for (int i = 0; i < MAX_WEAPONS; ++i) - { - ItemInfo &II = IMPL_CLASS(CBasePlayerItem, ItemInfoArray)[i]; - - if (!II.iId) - continue; - - const char *pszName; - if (!II.pszName) - pszName = "Empty"; - else - pszName = II.pszName; - - MESSAGE_BEGIN(MSG_INIT, gmsgWeaponList); - WRITE_STRING(pszName); - WRITE_BYTE(CBasePlayer::GetAmmoIndex(II.pszAmmo1)); - WRITE_BYTE(II.iMaxAmmo1); - WRITE_BYTE(CBasePlayer::GetAmmoIndex(II.pszAmmo2)); - WRITE_BYTE(II.iMaxAmmo2); - WRITE_BYTE(II.iSlot); - WRITE_BYTE(II.iPosition); - WRITE_BYTE(II.iId); - WRITE_BYTE(II.iFlags); - MESSAGE_END(); - } -} LINK_ENTITY_TO_CLASS(player, CBasePlayer, CCSPlayer) @@ -299,39 +89,39 @@ void CBasePlayer::SendItemStatus() const char *GetCSModelName(int item_id) { - const char *modelName = NULL; + const char *modelName = nullptr; switch (item_id) { - case WEAPON_P228: modelName = "models/w_p228.mdl"; break; - case WEAPON_SCOUT: modelName = "models/w_scout.mdl"; break; - case WEAPON_HEGRENADE: modelName = "models/w_hegrenade.mdl"; break; - case WEAPON_XM1014: modelName = "models/w_xm1014.mdl"; break; - case WEAPON_C4: modelName = "models/w_backpack.mdl"; break; - case WEAPON_MAC10: modelName = "models/w_mac10.mdl"; break; - case WEAPON_AUG: modelName = "models/w_aug.mdl"; break; - case WEAPON_SMOKEGRENADE: modelName = "models/w_smokegrenade.mdl"; break; - case WEAPON_ELITE: modelName = "models/w_elite.mdl"; break; - case WEAPON_FIVESEVEN: modelName = "models/w_fiveseven.mdl"; break; - case WEAPON_UMP45: modelName = "models/w_ump45.mdl"; break; - case WEAPON_SG550: modelName = "models/w_sg550.mdl"; break; - case WEAPON_GALIL: modelName = "models/w_galil.mdl"; break; - case WEAPON_FAMAS: modelName = "models/w_famas.mdl"; break; - case WEAPON_USP: modelName = "models/w_usp.mdl"; break; - case WEAPON_GLOCK18: modelName = "models/w_glock18.mdl"; break; - case WEAPON_AWP: modelName = "models/w_awp.mdl"; break; - case WEAPON_MP5N: modelName = "models/w_mp5.mdl"; break; - case WEAPON_M249: modelName = "models/w_m249.mdl"; break; - case WEAPON_M3: modelName = "models/w_m3.mdl"; break; - case WEAPON_M4A1: modelName = "models/w_m4a1.mdl"; break; - case WEAPON_TMP: modelName = "models/w_tmp.mdl"; break; - case WEAPON_G3SG1: modelName = "models/w_g3sg1.mdl"; break; - case WEAPON_FLASHBANG: modelName = "models/w_flashbang.mdl"; break; - case WEAPON_DEAGLE: modelName = "models/w_deagle.mdl"; break; - case WEAPON_SG552: modelName = "models/w_sg552.mdl"; break; - case WEAPON_AK47: modelName = "models/w_ak47.mdl"; break; - case WEAPON_KNIFE: modelName = "models/w_knife.mdl"; break; - case WEAPON_P90: modelName = "models/w_p90.mdl"; break; - case WEAPON_SHIELDGUN: modelName = "models/w_shield.mdl"; break; + case WEAPON_P228: modelName = "models/w_p228.mdl"; break; + case WEAPON_SCOUT: modelName = "models/w_scout.mdl"; break; + case WEAPON_HEGRENADE: modelName = "models/w_hegrenade.mdl"; break; + case WEAPON_XM1014: modelName = "models/w_xm1014.mdl"; break; + case WEAPON_C4: modelName = "models/w_backpack.mdl"; break; + case WEAPON_MAC10: modelName = "models/w_mac10.mdl"; break; + case WEAPON_AUG: modelName = "models/w_aug.mdl"; break; + case WEAPON_SMOKEGRENADE: modelName = "models/w_smokegrenade.mdl"; break; + case WEAPON_ELITE: modelName = "models/w_elite.mdl"; break; + case WEAPON_FIVESEVEN: modelName = "models/w_fiveseven.mdl"; break; + case WEAPON_UMP45: modelName = "models/w_ump45.mdl"; break; + case WEAPON_SG550: modelName = "models/w_sg550.mdl"; break; + case WEAPON_GALIL: modelName = "models/w_galil.mdl"; break; + case WEAPON_FAMAS: modelName = "models/w_famas.mdl"; break; + case WEAPON_USP: modelName = "models/w_usp.mdl"; break; + case WEAPON_GLOCK18: modelName = "models/w_glock18.mdl"; break; + case WEAPON_AWP: modelName = "models/w_awp.mdl"; break; + case WEAPON_MP5N: modelName = "models/w_mp5.mdl"; break; + case WEAPON_M249: modelName = "models/w_m249.mdl"; break; + case WEAPON_M3: modelName = "models/w_m3.mdl"; break; + case WEAPON_M4A1: modelName = "models/w_m4a1.mdl"; break; + case WEAPON_TMP: modelName = "models/w_tmp.mdl"; break; + case WEAPON_G3SG1: modelName = "models/w_g3sg1.mdl"; break; + case WEAPON_FLASHBANG: modelName = "models/w_flashbang.mdl"; break; + case WEAPON_DEAGLE: modelName = "models/w_deagle.mdl"; break; + case WEAPON_SG552: modelName = "models/w_sg552.mdl"; break; + case WEAPON_AK47: modelName = "models/w_ak47.mdl"; break; + case WEAPON_KNIFE: modelName = "models/w_knife.mdl"; break; + case WEAPON_P90: modelName = "models/w_p90.mdl"; break; + case WEAPON_SHIELDGUN: modelName = "models/w_shield.mdl"; break; default: ALERT(at_console, "CBasePlayer::PackDeadPlayerItems(): Unhandled item- not creating weaponbox\n"); } @@ -413,7 +203,7 @@ void CBasePlayer::SetPlayerModel(BOOL HasC4) model = "vip"; break; case MODEL_SPETSNAZ: - if (g_bIsCzeroGame) + if (AreRunningCZero()) { model = "spetsnaz"; break; @@ -450,7 +240,7 @@ void CBasePlayer::SetPlayerModel(BOOL HasC4) model = "guerilla"; break; case MODEL_MILITIA: - if (g_bIsCzeroGame) + if (AreRunningCZero()) { model = "militia"; break; @@ -590,7 +380,7 @@ void EXT_FUNC CBasePlayer::__API_HOOK(Radio)(const char *msg_id, const char *msg { // search the place name where is located the player const char *placeName = NULL; - if (g_bIsCzeroGame && TheBotPhrases) + if (AreRunningCZero() && TheBotPhrases) { Place playerPlace = TheNavAreaGrid.GetPlace(&pev->origin); const BotPhraseList *placeList = TheBotPhrases->GetPlaceList(); @@ -1126,7 +916,7 @@ BOOL EXT_FUNC CBasePlayer::__API_HOOK(TakeDamage)(entvars_t *pevInflictor, entva { // reset damage time countdown for each type of time based damage player just sustained - for (int i = 0; i < CDMG_TIMEBASED; ++i) + for (int i = 0; i < ITBD_END; ++i) { if (bitsDamageType & (DMG_PARALYZE << i)) m_rgbTimeBasedDamage[i] = 0; @@ -1241,24 +1031,36 @@ BOOL EXT_FUNC CBasePlayer::__API_HOOK(TakeDamage)(entvars_t *pevInflictor, entva switch (iGunType) { case WEAPON_AUG: - case WEAPON_M4A1: flRatio *= 1.4; break; - case WEAPON_AWP: flRatio *= 1.95; break; - case WEAPON_G3SG1: flRatio *= 1.65; break; - case WEAPON_SG550: flRatio *= 1.45; break; - case WEAPON_M249: flRatio *= 1.5; break; - case WEAPON_ELITE: flRatio *= 1.05; break; - case WEAPON_DEAGLE: flRatio *= 1.5; break; + case WEAPON_M4A1: flRatio *= 1.4; break; + case WEAPON_AWP: flRatio *= 1.95; break; + case WEAPON_G3SG1: flRatio *= 1.65; break; + case WEAPON_SG550: flRatio *= 1.45; break; + case WEAPON_M249: flRatio *= 1.5; break; + case WEAPON_ELITE: flRatio *= 1.05; break; + case WEAPON_DEAGLE: flRatio *= 1.5; break; case WEAPON_GLOCK18: flRatio *= 1.05; break; case WEAPON_FIVESEVEN: - case WEAPON_P90: flRatio *= 1.5; break; - case WEAPON_MAC10: flRatio *= 0.95; break; - case WEAPON_P228: flRatio *= 1.25; break; + case WEAPON_P90: + flRatio *= 1.5; + break; + case WEAPON_MAC10: + flRatio *= 0.95; + break; + case WEAPON_P228: + flRatio *= 1.25; + break; case WEAPON_SCOUT: - case WEAPON_KNIFE: flRatio *= 1.7; break; + case WEAPON_KNIFE: + flRatio *= 1.7; + break; case WEAPON_FAMAS: - case WEAPON_SG552: flRatio *= 1.4; break; + case WEAPON_SG552: + flRatio *= 1.4; + break; case WEAPON_GALIL: - case WEAPON_AK47: flRatio *= 1.55; break; + case WEAPON_AK47: + flRatio *= 1.55; + break; } } @@ -1362,7 +1164,7 @@ BOOL EXT_FUNC CBasePlayer::__API_HOOK(TakeDamage)(entvars_t *pevInflictor, entva { // reset damage time countdown for each type of time based damage player just sustained - for (int i = 0; i < CDMG_TIMEBASED; ++i) + for (int i = 0; i < ITBD_END; ++i) { if (bitsDamageType & (DMG_PARALYZE << i)) m_rgbTimeBasedDamage[i] = 0; @@ -1551,7 +1353,7 @@ void CBasePlayer::PackDeadPlayerItems() // drop a grenade after death else if (pPlayerItem->iItemSlot() == GRENADE_SLOT) { - if (g_bIsCzeroGame) + if (AreRunningCZero()) packPlayerItem(this, pPlayerItem, true); #ifdef REGAMEDLL_ADD else @@ -2246,7 +2048,7 @@ void EXT_FUNC CBasePlayer::__API_HOOK(Killed)(entvars_t *pevAttacker, int iGib) m_iThrowDirection = THROW_NONE; } - SetSuitUpdate(NULL, FALSE, 0); + SetSuitUpdate(NULL, SUIT_SENTENCE, SUIT_REPEAT_OK); m_iClientHealth = 0; MESSAGE_BEGIN(MSG_ONE, gmsgHealth, NULL, pev); @@ -2949,7 +2751,7 @@ void CBasePlayer::WaterMove() // NOTE: this actually causes the count to continue restarting // until all drowning damage is healed. - m_rgbTimeBasedDamage[ itbd_DrownRecover ] = 0; + m_rgbTimeBasedDamage[ ITBD_DROWN_RECOVER ] = 0; m_bitsDamageType |= DMG_DROWNRECOVER; m_bitsDamageType &= ~DMG_DROWN; } @@ -2958,7 +2760,7 @@ void CBasePlayer::WaterMove() { // fully under water // stop restoring damage while underwater - m_rgbTimeBasedDamage[ itbd_DrownRecover ] = 0; + m_rgbTimeBasedDamage[ ITBD_DROWN_RECOVER ] = 0; m_bitsDamageType &= ~DMG_DROWNRECOVER; // drown! @@ -3076,12 +2878,12 @@ void CWShield::Touch(CBaseEntity *pOther) if (pPlayer->pev->deadflag != DEAD_NO) return; - if (m_hEntToIgnoreTouchesFrom && pPlayer == (CBasePlayer *)m_hEntToIgnoreTouchesFrom) + if (m_hEntToIgnoreTouchesFrom && m_hEntToIgnoreTouchesFrom == pPlayer) { if (m_flTimeToIgnoreTouches > gpGlobals->time) return; - m_hEntToIgnoreTouchesFrom = NULL; + m_hEntToIgnoreTouchesFrom = nullptr; } if (!pPlayer->m_bHasPrimary) @@ -3148,15 +2950,15 @@ void CBasePlayer::RemoveShield() } } -LINK_HOOK_CLASS_VOID_CHAIN(CBasePlayer, DropShield, (bool bDeploy), bDeploy) +LINK_HOOK_CLASS_CHAIN(CBaseEntity *, CBasePlayer, DropShield, (bool bDeploy), bDeploy) -void EXT_FUNC CBasePlayer::__API_HOOK(DropShield)(bool bDeploy) +CBaseEntity *EXT_FUNC CBasePlayer::__API_HOOK(DropShield)(bool bDeploy) { if (!HasShield()) - return; + return nullptr; if (m_pActiveItem && !m_pActiveItem->CanHolster()) - return; + return nullptr; CBasePlayerWeapon *pWeapon = static_cast(m_pActiveItem); @@ -3201,6 +3003,8 @@ void EXT_FUNC CBasePlayer::__API_HOOK(DropShield)(bool bDeploy) pShield->SetThink(&CBaseEntity::SUB_Remove); pShield->pev->nextthink = gpGlobals->time + 300; pShield->SetCantBePickedUpByUser(this, 2.0); + + return pShield; } bool CBasePlayer::HasShield() @@ -3547,7 +3351,7 @@ void EXT_FUNC CBasePlayer::__API_HOOK(Disappear)() pev->solid = SOLID_NOT; pev->flags &= ~FL_ONGROUND; - SetSuitUpdate(NULL, FALSE, 0); + SetSuitUpdate(NULL, SUIT_SENTENCE, SUIT_REPEAT_OK); m_iClientHealth = 0; MESSAGE_BEGIN(MSG_ONE, gmsgHealth, NULL, pev); @@ -3791,7 +3595,7 @@ void EXT_FUNC CBasePlayer::__API_HOOK(StartObserver)(Vector &vecPosition, Vector } // clear out the suit message cache so we don't keep chattering - SetSuitUpdate(NULL, FALSE, 0); + SetSuitUpdate(NULL, SUIT_SENTENCE, SUIT_REPEAT_OK); // Tell Ammo Hud that the player is dead MESSAGE_BEGIN(MSG_ONE, gmsgCurWeapon, NULL, pev); @@ -3985,7 +3789,7 @@ void CBasePlayer::PlayerUse() if (!pClosest) { - while ((pObject = UTIL_FindEntityInSphere(pObject, pev->origin, PLAYER_USE_RADIUS))) + while ((pObject = UTIL_FindEntityInSphere(pObject, pev->origin, MAX_PLAYER_USE_RADIUS))) { if (pObject->ObjectCaps() & (FCAP_IMPULSE_USE | FCAP_CONTINUOUS_USE | FCAP_ONOFF_USE)) { @@ -4555,27 +4359,27 @@ void CBasePlayer::CheckTimeBasedDamage() m_tbdPrev = gpGlobals->time; - for (i = 0; i < CDMG_TIMEBASED; ++i) + for (i = 0; i < ITBD_END; ++i) { // make sure bit is set for damage type if (m_bitsDamageType & (DMG_PARALYZE << i)) { switch (i) { - case itbd_Paralyze: + case ITBD_PARALLYZE: // UNDONE - flag movement as half-speed bDuration = PARALYZE_DURATION; break; - case itbd_NerveGas: + case ITBD_NERVE_GAS: bDuration = NERVEGAS_DURATION; break; - case itbd_Poison: + case ITBD_POISON: { TakeDamage(pev, pev, POISON_DAMAGE, DMG_GENERIC); bDuration = POISON_DURATION; break; } - case itbd_DrownRecover: + case ITBD_DROWN_RECOVER: { // NOTE: this hack is actually used to RESTORE health // after the player has been drowning and finally takes a breath @@ -4590,16 +4394,16 @@ void CBasePlayer::CheckTimeBasedDamage() bDuration = 4; break; } - case itbd_Radiation: + case ITBD_RADIATION: bDuration = RADIATION_DURATION; break; - case itbd_Acid: + case ITBD_ACID: bDuration = ACID_DURATION; break; - case itbd_SlowBurn: + case ITBD_SLOW_BURN: bDuration = SLOWBURN_DURATION; break; - case itbd_SlowFreeze: + case ITBD_SLOW_FREEZE: bDuration = SLOWFREEZE_DURATION; break; default: @@ -4610,13 +4414,13 @@ void CBasePlayer::CheckTimeBasedDamage() if (m_rgbTimeBasedDamage[i]) { // use up an antitoxin on poison or nervegas after a few seconds of damage - if ((i == itbd_NerveGas && m_rgbTimeBasedDamage[i] < NERVEGAS_DURATION) || (i == itbd_Poison && m_rgbTimeBasedDamage[i] < POISON_DURATION)) + if ((i == ITBD_NERVE_GAS && m_rgbTimeBasedDamage[i] < NERVEGAS_DURATION) || (i == ITBD_POISON && m_rgbTimeBasedDamage[i] < POISON_DURATION)) { if (m_rgItems[ ITEM_ID_ANTIDOTE ]) { m_rgbTimeBasedDamage[i] = 0; m_rgItems[ ITEM_ID_ANTIDOTE ]--; - SetSuitUpdate("!HEV_HEAL4", FALSE, SUIT_REPEAT_OK); + SetSuitUpdate("!HEV_HEAL4", SUIT_SENTENCE, SUIT_REPEAT_OK); } } @@ -4686,12 +4490,12 @@ void CBasePlayer::CheckSuitUpdate() if (gpGlobals->time >= m_flSuitUpdate && m_flSuitUpdate > 0) { // play a sentence off of the end of the queue - for (i = 0; i < CSUITPLAYLIST; ++i) + for (i = 0; i < MAX_SUIT_NOREPEAT; ++i) { if ((isentence = m_rgSuitPlayList[ isearch ])) break; - if (++isearch == CSUITPLAYLIST) + if (++isearch == MAX_SUIT_NOREPEAT) isearch = 0; } @@ -4702,8 +4506,7 @@ void CBasePlayer::CheckSuitUpdate() if (isentence > 0) { // play sentence number - - char sentence[CBSENTENCENAME_MAX + 1]; + char sentence[MAX_SENTENCE_NAME + 1]; Q_strcpy(sentence, "!"); Q_strcat(sentence, gszallsentencenames[isentence]); EMIT_SOUND_SUIT(ENT(pev), sentence); @@ -4713,7 +4516,8 @@ void CBasePlayer::CheckSuitUpdate() // play sentence group EMIT_GROUPID_SUIT(ENT(pev), -isentence); } - m_flSuitUpdate = gpGlobals->time + SUITUPDATETIME; + + m_flSuitUpdate = gpGlobals->time + SUIT_UPDATE_TIME; } else // queue is empty, don't check @@ -4721,12 +4525,12 @@ void CBasePlayer::CheckSuitUpdate() } } -// add sentence to suit playlist queue. if fgroup is true, then +// add sentence to suit playlist queue. if group is true, then // name is a sentence group (HEV_AA), otherwise name is a specific // sentence name ie: !HEV_AA0. If iNoRepeat is specified in // seconds, then we won't repeat playback of this word or sentence // for at least that number of seconds. -void CBasePlayer::SetSuitUpdate(char *name, int fgroup, int iNoRepeatTime) +void CBasePlayer::SetSuitUpdate(char *name, bool group, int iNoRepeatTime) { ; } @@ -4900,7 +4704,7 @@ void EXT_FUNC CBasePlayer::__API_HOOK(PostThink)() if (pev->watertype != CONTENT_WATER) { // after this point, we start doing damage - if (m_flFallVelocity > PLAYER_MAX_SAFE_FALL_SPEED) + if (m_flFallVelocity > MAX_PLAYER_SAFE_FALL_SPEED) { float flFallDamage = g_pGameRules->FlPlayerFallDamage(this); @@ -5031,25 +4835,6 @@ BOOL IsSpawnPointValid(CBaseEntity *pPlayer, CBaseEntity *pSpot) return TRUE; } -NOXREF void InitZombieSpawns() -{ - CBaseEntity *spot = NULL; - - g_pSelectedZombieSpawn = NULL; - zombieSpawnCount = 0; - - while ((spot = UTIL_FindEntityByClassname(spot, "info_player_start"))) - { - if (spot->pev->origin != Vector(0, 0, 0)) - { - zombieSpawn[ zombieSpawnCount ].entity = spot; - zombieSpawn[ zombieSpawnCount ].useableTimer.Invalidate(); - - zombieSpawnCount++; - } - } -} - NOXREF CBaseEntity *FindZombieSpawn(CBaseEntity *player, bool forceSpawn) { return NULL; @@ -5112,6 +4897,10 @@ bool CBasePlayer::SelectSpawnSpot(const char *pEntClassName, CBaseEntity *&pSpot return false; } +CBaseEntity *g_pLastSpawn; +CBaseEntity *g_pLastCTSpawn; +CBaseEntity *g_pLastTerroristSpawn; + edict_t *CBasePlayer::EntSelectSpawnPoint() { CBaseEntity *pSpot; @@ -5330,7 +5119,7 @@ void EXT_FUNC CBasePlayer::__API_HOOK(Spawn)() m_lastLocation[0] = '\0'; m_bitsDamageType &= ~(DMG_DROWN | DMG_DROWNRECOVER); - m_rgbTimeBasedDamage[ itbd_DrownRecover ] = 0; + m_rgbTimeBasedDamage[ ITBD_DROWN_RECOVER ] = 0; m_idrowndmg = 0; m_idrownrestored = 0; @@ -5577,23 +5366,6 @@ LINK_HOOK_CLASS_VOID_CHAIN2(CBasePlayer, Precache) void EXT_FUNC CBasePlayer::__API_HOOK(Precache)() { -#ifndef REGAMEDLL_FIXES - // in the event that the player JUST spawned, and the level node graph - // was loaded, fix all of the node graph pointers before the game starts. - - // TODO: (BUGBUG) now that we have multiplayer, this needs to be moved! - if (WorldGraph.m_fGraphPresent && !WorldGraph.m_fGraphPointersSet) - { - if (!WorldGraph.FSetGraphPointers()) - { - ALERT(at_console, "**Graph pointers were not set!\n"); - } - else - { - ALERT(at_console, "**Graph Pointers Set!\n"); - } - } -#endif // SOUNDS / MODELS ARE PRECACHED in ClientPrecache() (game specific) // because they need to precache before any clients have connected @@ -5723,7 +5495,7 @@ void CBasePlayer::Reset() NOXREF void CBasePlayer::SelectNextItem(int iItem) { - CBasePlayerItem *pItem = m_rgpPlayerItems[ iItem ]; + CBasePlayerItem *pItem = m_rgpPlayerItems[iItem]; if (!pItem) { @@ -5746,7 +5518,7 @@ NOXREF void CBasePlayer::SelectNextItem(int iItem) pLast->m_pNext = m_pActiveItem; m_pActiveItem->m_pNext = NULL; - m_rgpPlayerItems[ iItem ] = pItem; + m_rgpPlayerItems[iItem] = pItem; } ResetAutoaim(); @@ -5766,15 +5538,12 @@ NOXREF void CBasePlayer::SelectNextItem(int iItem) m_pLastItem = m_pActiveItem; m_pActiveItem = pItem; - if (m_pActiveItem) - { - UpdateShieldCrosshair(true); + UpdateShieldCrosshair(true); - m_pActiveItem->Deploy(); - m_pActiveItem->UpdateItemInfo(); + m_pActiveItem->Deploy(); + m_pActiveItem->UpdateItemInfo(); - ResetMaxSpeed(); - } + ResetMaxSpeed(); } void CBasePlayer::SelectItem(const char *pstr) @@ -5799,19 +5568,16 @@ void CBasePlayer::SelectItem(const char *pstr) m_pLastItem = m_pActiveItem; m_pActiveItem = pItem; - if (m_pActiveItem) - { - CBasePlayerWeapon *pWeapon = (CBasePlayerWeapon *)m_pActiveItem; - pWeapon->m_iWeaponState &= ~WPNSTATE_SHIELD_DRAWN; + CBasePlayerWeapon *pWeapon = (CBasePlayerWeapon *)m_pActiveItem; + pWeapon->m_iWeaponState &= ~WPNSTATE_SHIELD_DRAWN; - m_bShieldDrawn = false; - UpdateShieldCrosshair(true); + m_bShieldDrawn = false; + UpdateShieldCrosshair(true); - m_pActiveItem->Deploy(); - m_pActiveItem->UpdateItemInfo(); + m_pActiveItem->Deploy(); + m_pActiveItem->UpdateItemInfo(); - ResetMaxSpeed(); - } + ResetMaxSpeed(); } void CBasePlayer::SelectLastItem() @@ -5838,7 +5604,9 @@ void CBasePlayer::SelectLastItem() ResetAutoaim(); if (m_pActiveItem) + { m_pActiveItem->Holster(); + } if (HasShield()) { @@ -5893,6 +5661,7 @@ void CSprayCan::Spawn(entvars_t *pevOwner) #else pev->origin = pevOwner->origin + Vector(0, 0, 32); #endif + pev->angles = pevOwner->v_angle; pev->owner = ENT(pevOwner); pev->frame = 0; @@ -6002,16 +5771,19 @@ CBaseEntity *CBasePlayer::GiveNamedItemEx(const char *pszName) DispatchSpawn(pent); DispatchTouch(pent, ENT(pev)); + CBaseEntity *pEntity = (CBaseEntity *)GET_PRIVATE(pent); + #ifdef REGAMEDLL_FIXES // not allow the item to fall to the ground. if (FNullEnt(pent->v.owner) || pent->v.owner != edict()) { pent->v.flags |= FL_KILLME; + UTIL_Remove(pEntity); return nullptr; } #endif - return (CBaseEntity *)GET_PRIVATE(pent); + return pEntity; } CBaseEntity *FindEntityForward(CBaseEntity *pEntity) @@ -6083,7 +5855,7 @@ void CBasePlayer::ForceClientDllUpdate() m_fWeapon = FALSE; // Force weapon send m_fInitHUD = TRUE; // Force HUD gmsgResetHUD message - m_iTrain |= TRAIN_NEW; // Force new train message. + m_iTrain |= TRAIN_NEW; // Force new train message. // Now force all the necessary messages to be sent. UpdateClientData(); @@ -6280,13 +6052,6 @@ void CBasePlayer::CheatImpulseCommands(int iImpulse) // show shortest paths for entire level to nearest node Create("node_viewer_human", pev->origin, pev->angles); break; -#ifndef REGAMEDLL_FIXES - case 199: - // show nearest node and all connections - ALERT(at_console, "%d\n", WorldGraph.FindNearestNode(pev->origin, bits_NODE_LAND)); - WorldGraph.ShowNodeConnections(WorldGraph.FindNearestNode(pev->origin, bits_NODE_LAND)); - break; -#endif case 202: { // Random blood splatter @@ -6732,7 +6497,7 @@ void CBasePlayer::SendHostageIcons() int numHostages = 0; char buf[16]; - if (!g_bIsCzeroGame) + if (!AreRunningCZero()) return; while ((pHostage = UTIL_FindEntityByClassname(pHostage, "hostage_entity"))) @@ -7352,8 +7117,8 @@ void CBasePlayer::InitStatusBar() void CBasePlayer::UpdateStatusBar() { - int newSBarState[ SBAR_END ]; - char sbuf0[ SBAR_STRING_SIZE ]; + int newSBarState[SBAR_END]; + char sbuf0[MAX_SBAR_STRING]; Q_memset(newSBarState, 0, sizeof(newSBarState)); Q_strcpy(sbuf0, m_SbarString0); @@ -7363,7 +7128,7 @@ void CBasePlayer::UpdateStatusBar() UTIL_MakeVectors(pev->v_angle + pev->punchangle); Vector vecSrc = EyePosition(); - Vector vecEnd = vecSrc + (gpGlobals->v_forward * ((pev->flags & FL_SPECTATOR) != 0 ? MAX_SPECTATOR_ID_RANGE : MAX_ID_RANGE)); + Vector vecEnd = vecSrc + (gpGlobals->v_forward * ((pev->flags & FL_SPECTATOR) != 0 ? MAX_SPEC_ID_RANGE : MAX_ID_RANGE)); UTIL_TraceLine(vecSrc, vecEnd, dont_ignore_monsters, edict(), &tr); @@ -7480,10 +7245,10 @@ void CBasePlayer::UpdateStatusBar() } } -LINK_HOOK_CLASS_VOID_CHAIN(CBasePlayer, DropPlayerItem, (const char *pszItemName), pszItemName) +LINK_HOOK_CLASS_CHAIN(CBaseEntity *, CBasePlayer, DropPlayerItem, (const char *pszItemName), pszItemName) // DropPlayerItem - drop the named item, or if no name, the active item. -void EXT_FUNC CBasePlayer::__API_HOOK(DropPlayerItem)(const char *pszItemName) +CBaseEntity *EXT_FUNC CBasePlayer::__API_HOOK(DropPlayerItem)(const char *pszItemName) { if (!Q_strlen(pszItemName)) { @@ -7496,12 +7261,12 @@ void EXT_FUNC CBasePlayer::__API_HOOK(DropPlayerItem)(const char *pszItemName) if (m_bIsVIP) { ClientPrint(pev, HUD_PRINTCENTER, "#Weapon_Cannot_Be_Dropped"); - return; + return nullptr; } else if (!pszItemName && HasShield()) { DropShield(); - return; + return nullptr; } #ifndef REGAMEDLL_FIXES @@ -7536,7 +7301,7 @@ void EXT_FUNC CBasePlayer::__API_HOOK(DropPlayerItem)(const char *pszItemName) if (!pWeapon->CanDrop()) { ClientPrint(pev, HUD_PRINTCENTER, "#Weapon_Cannot_Be_Dropped"); - return; + return nullptr; } // take item off hud @@ -7630,7 +7395,11 @@ void EXT_FUNC CBasePlayer::__API_HOOK(DropPlayerItem)(const char *pszItemName) { SET_MODEL(ENT(pWeaponBox->pev), modelname); } + + return pWeaponBox; } + + return nullptr; } // Does the player already have this item? @@ -7694,7 +7463,7 @@ void CBasePlayer::SwitchTeam() szNewModel = "arctic"; break; case MODEL_SPETSNAZ: - if (g_bIsCzeroGame) + if (AreRunningCZero()) { m_iModelName = MODEL_MILITIA; szNewModel = "militia"; @@ -7731,7 +7500,7 @@ void CBasePlayer::SwitchTeam() break; case MODEL_MILITIA: - if (g_bIsCzeroGame) + if (AreRunningCZero()) { m_iModelName = MODEL_SPETSNAZ; szNewModel = "spetsnaz"; @@ -7900,7 +7669,9 @@ void CDeadHEV::KeyValue(KeyValueData *pkvd) pkvd->fHandled = TRUE; } else + { CBaseMonster::KeyValue(pkvd); + } } LINK_ENTITY_TO_CLASS(monster_hevsuit_dead, CDeadHEV, CCSDeadHEV) @@ -7978,7 +7749,9 @@ void CRevertSaved::KeyValue(KeyValueData *pkvd) pkvd->fHandled = TRUE; } else + { CPointEntity::KeyValue(pkvd); + } } void CRevertSaved::Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) @@ -8099,7 +7872,6 @@ void CBasePlayer::StudioEstimateGait() m_flGaityaw += flYawDiff; m_flGaityaw -= int64(m_flGaityaw / 360) * 360; - m_flGaitMovement = 0; } else @@ -9076,7 +8848,7 @@ void CBasePlayer::ParseAutoBuyString(const char *string, bool &boughtPrimary, bo command[i] = '\0'; break; } - ++i; + i++; } // make sure we actually have a command. @@ -9228,9 +9000,9 @@ void CBasePlayer::BuildRebuyStruct() else m_rebuyStruct.m_smokeGrenade = 0; - m_rebuyStruct.m_defuser = m_bHasDefuser; // defuser + m_rebuyStruct.m_defuser = m_bHasDefuser; // defuser m_rebuyStruct.m_nightVision = m_bHasNightVision; // night vision - m_rebuyStruct.m_armor = m_iKevlar; // check for armor. + m_rebuyStruct.m_armor = m_iKevlar; // check for armor. } void CBasePlayer::Rebuy() @@ -9242,8 +9014,8 @@ void CBasePlayer::Rebuy() while (true) { - fileData = MP_COM_Parse(fileData); - token = MP_COM_GetToken(); + fileData = SharedParse(fileData); + token = SharedGetToken(); if (!fileData) break; @@ -9409,7 +9181,7 @@ void CBasePlayer::UpdateLocation(bool forceUpdate) const char *placeName = ""; - if (pev->deadflag == DEAD_NO && g_bIsCzeroGame) + if (pev->deadflag == DEAD_NO && AreRunningCZero()) { // search the place name where is located the player Place playerPlace = TheNavAreaGrid.GetPlace(&pev->origin); diff --git a/regamedll/dlls/player.h b/regamedll/dlls/player.h index 748d18da..a5a98667 100644 --- a/regamedll/dlls/player.h +++ b/regamedll/dlls/player.h @@ -26,121 +26,119 @@ * */ -#ifndef PLAYER_H -#define PLAYER_H -#ifdef _WIN32 #pragma once -#endif +#include "weapons.h" #include "pm_materials.h" #include "hintmessage.h" #include "unisignals.h" -#include "weapons.h" -#ifdef REGAMEDLL_ADD -#define MIN_BUY_TIME 0 +#define SOUND_FLASHLIGHT_ON "items/flashlight1.wav" +#define SOUND_FLASHLIGHT_OFF "items/flashlight1.wav" + +#ifdef REGAMEDLL_FIXES +const int MIN_BUY_TIME = 0; #else -#define MIN_BUY_TIME 15 // the minimum threshold values for cvar mp_buytime 15 sec's +const int MIN_BUY_TIME = 15; // the minimum threshold values for cvar mp_buytime 15 sec's #endif -#define MAX_BUFFER_MENU 175 -#define MAX_BUFFER_MENU_BRIEFING 50 +const int MAX_PLAYER_NAME_LENGTH = 32; +const int MAX_AUTOBUY_LENGTH = 256; +const int MAX_REBUY_LENGTH = 256; -#define MAX_PLAYER_NAME_LENGTH 32 -#define MAX_AUTOBUY_LENGTH 256 -#define MAX_REBUY_LENGTH 256 +const int MAX_RECENT_PATH = 20; +const int MAX_HOSTAGE_ICON = 4; // the maximum number of icons of the hostages in the HUD -#define MAX_RECENT_PATH 20 -#define MAX_HOSTAGE_ICON 4 // the maximum number of icons of the hostages in the HUD +const int MAX_SUIT_NOREPEAT = 32; +const int MAX_SUIT_PLAYLIST = 4; // max of 4 suit sentences queued up at any time -#define SUITUPDATETIME 3.5 -#define SUITFIRSTUPDATETIME 0.1 +const int MAX_BUFFER_MENU = 175; +const int MAX_BUFFER_MENU_BRIEFING = 50; -#define PLAYER_FATAL_FALL_SPEED 1100.0f -#define PLAYER_MAX_SAFE_FALL_SPEED 500.0f -#define PLAYER_USE_RADIUS 64.0f +const float SUIT_UPDATE_TIME = 3.5f; +const float SUIT_FIRST_UPDATE_TIME = 0.1f; -#define ARMOR_RATIO 0.5 // Armor Takes 50% of the damage -#define ARMOR_BONUS 0.5 // Each Point of Armor is work 1/x points of health +const float MAX_PLAYER_FATAL_FALL_SPEED = 1100.0f; +const float MAX_PLAYER_SAFE_FALL_SPEED = 500.0f; +const float MAX_PLAYER_USE_RADIUS = 64.0f; -#define FLASH_DRAIN_TIME 1.2 // 100 units/3 minutes -#define FLASH_CHARGE_TIME 0.2 // 100 units/20 seconds (seconds per unit) +const float ARMOR_RATIO = 0.5f; // Armor Takes 50% of the damage +const float ARMOR_BONUS = 0.5f; // Each Point of Armor is work 1/x points of health + +const float FLASH_DRAIN_TIME = 1.2f; // 100 units/3 minutes +const float FLASH_CHARGE_TIME = 0.2f; // 100 units/20 seconds (seconds per unit) // damage per unit per second. -#define DAMAGE_FOR_FALL_SPEED 100.0f / (PLAYER_FATAL_FALL_SPEED - PLAYER_MAX_SAFE_FALL_SPEED) -#define PLAYER_MIN_BOUNCE_SPEED 350.0f +const float DAMAGE_FOR_FALL_SPEED = 100.0f / (MAX_PLAYER_FATAL_FALL_SPEED - MAX_PLAYER_SAFE_FALL_SPEED); +const float PLAYER_MIN_BOUNCE_SPEED = 350.0f; // won't punch player's screen/make scrape noise unless player falling at least this fast. -#define PLAYER_FALL_PUNCH_THRESHHOLD 250.0f +const float PLAYER_FALL_PUNCH_THRESHHOLD = 250.0f; // Money blinks few of times on the freeze period // NOTE: It works for CZ -#define MONEY_BLINK_AMOUNT 30 +const int MONEY_BLINK_AMOUNT = 30; + +// Player time based damage +#define AIRTIME 12 // lung full of air lasts this many seconds +#define PARALYZE_DURATION 2 // number of 2 second intervals to take damage +#define PARALYZE_DAMAGE 1.0f // damage to take each 2 second interval + +#define NERVEGAS_DURATION 2 +#define NERVEGAS_DAMAGE 5.0f + +#define POISON_DURATION 5 +#define POISON_DAMAGE 2.0f + +#define RADIATION_DURATION 2 +#define RADIATION_DAMAGE 1.0f + +#define ACID_DURATION 2 +#define ACID_DAMAGE 5.0f + +#define SLOWBURN_DURATION 2 +#define SLOWBURN_DAMAGE 1.0f + +#define SLOWFREEZE_DURATION 2 +#define SLOWFREEZE_DAMAGE 1.0f // Player physics flags bits // CBasePlayer::m_afPhysicsFlags -#define PFLAG_ONLADDER (1<<0) -#define PFLAG_ONSWING (1<<0) -#define PFLAG_ONTRAIN (1<<1) -#define PFLAG_ONBARNACLE (1<<2) -#define PFLAG_DUCKING (1<<3) // In the process of ducking, but totally squatted yet -#define PFLAG_USING (1<<4) // Using a continuous entity -#define PFLAG_OBSERVER (1<<5) // player is locked in stationary cam mode. Spectators can move, observers can't. +#define PFLAG_ONLADDER BIT(0) +#define PFLAG_ONSWING BIT(0) +#define PFLAG_ONTRAIN BIT(1) +#define PFLAG_ONBARNACLE BIT(2) +#define PFLAG_DUCKING BIT(3) // In the process of ducking, but not totally squatted yet +#define PFLAG_USING BIT(4) // Using a continuous entity +#define PFLAG_OBSERVER BIT(5) // Player is locked in stationary cam mode. Spectators can move, observers can't. -#define TRAIN_OFF 0x00 -#define TRAIN_NEUTRAL 0x01 -#define TRAIN_SLOW 0x02 -#define TRAIN_MEDIUM 0x03 -#define TRAIN_FAST 0x04 -#define TRAIN_BACK 0x05 +#define TRAIN_OFF 0x00 +#define TRAIN_NEUTRAL 0x01 +#define TRAIN_SLOW 0x02 +#define TRAIN_MEDIUM 0x03 +#define TRAIN_FAST 0x04 +#define TRAIN_BACK 0x05 -#define TRAIN_ACTIVE 0x80 -#define TRAIN_NEW 0xc0 +#define TRAIN_ACTIVE 0x80 +#define TRAIN_NEW 0xc0 -#define SIGNAL_BUY (1<<0) -#define SIGNAL_BOMB (1<<1) -#define SIGNAL_RESCUE (1<<2) -#define SIGNAL_ESCAPE (1<<3) -#define SIGNAL_VIPSAFETY (1<<4) +const bool SUIT_GROUP = true; +const bool SUIT_SENTENCE = false; -#define IGNOREMSG_NONE 0 -#define IGNOREMSG_ENEMY 1 -#define IGNOREMSG_TEAM 2 +const int SUIT_REPEAT_OK = 0; +const int SUIT_NEXT_IN_30SEC = 30; +const int SUIT_NEXT_IN_1MIN = 60; +const int SUIT_NEXT_IN_5MIN = 300; +const int SUIT_NEXT_IN_10MIN = 600; +const int SUIT_NEXT_IN_30MIN = 1800; +const int SUIT_NEXT_IN_1HOUR = 3600; -// max of 4 suit sentences queued up at any time -#define CSUITPLAYLIST 4 +const int MAX_TEAM_NAME_LENGTH = 16; -#define SUIT_GROUP TRUE -#define SUIT_SENTENCE FALSE - -#define SUIT_REPEAT_OK 0 -#define SUIT_NEXT_IN_30SEC 30 -#define SUIT_NEXT_IN_1MIN 60 -#define SUIT_NEXT_IN_5MIN 300 -#define SUIT_NEXT_IN_10MIN 600 -#define SUIT_NEXT_IN_30MIN 1800 -#define SUIT_NEXT_IN_1HOUR 3600 - -#define TEAM_NAME_LENGTH 16 - -#define MAX_ID_RANGE 2048.0f -#define MAX_SPECTATOR_ID_RANGE 8192.0f -#define SBAR_STRING_SIZE 128 - -#define SBAR_TARGETTYPE_TEAMMATE 1 -#define SBAR_TARGETTYPE_ENEMY 2 -#define SBAR_TARGETTYPE_HOSTAGE 3 - -#define CHAT_INTERVAL 1.0f -#define CSUITNOREPEAT 32 - -#define AUTOAIM_2DEGREES 0.0348994967025 -#define AUTOAIM_5DEGREES 0.08715574274766 -#define AUTOAIM_8DEGREES 0.1391731009601 -#define AUTOAIM_10DEGREES 0.1736481776669 - -#define SOUND_FLASHLIGHT_ON "items/flashlight1.wav" -#define SOUND_FLASHLIGHT_OFF "items/flashlight1.wav" +const auto AUTOAIM_2DEGREES = 0.0348994967025; +const auto AUTOAIM_5DEGREES = 0.08715574274766; +const auto AUTOAIM_8DEGREES = 0.1391731009601; +const auto AUTOAIM_10DEGREES = 0.1736481776669; // custom enum enum RewardType @@ -244,6 +242,13 @@ enum TrackCommands COMMANDS_TO_TRACK, }; +enum IgnoreChatMsg : int +{ + IGNOREMSG_NONE, // Nothing to do + IGNOREMSG_ENEMY, // To ignore any chat messages from the enemy + IGNOREMSG_TEAM // Same as IGNOREMSG_ENEMY but ignore teammates +}; + struct RebuyStruct { int m_primaryWeapon; @@ -269,6 +274,14 @@ enum ThrowDirection THROW_HITVEL_MINUS_AIRVEL }; +const float MAX_ID_RANGE = 2048.0f; +const float MAX_SPEC_ID_RANGE = 8192.0f; +const int MAX_SBAR_STRING = 128; + +const int SBAR_TARGETTYPE_TEAMMATE = 1; +const int SBAR_TARGETTYPE_ENEMY = 2; +const int SBAR_TARGETTYPE_HOSTAGE = 3; + enum sbar_data { SBAR_ID_TARGETTYPE = 1, @@ -391,8 +404,8 @@ public: void ImpulseCommands_OrigFunc(); void RoundRespawn_OrigFunc(); void Blind_OrigFunc(float flUntilTime, float flHoldTime, float flFadeTime, int iAlpha); - CBasePlayer *Observer_IsValidTarget_OrigFunc(int iPlayerIndex, bool bSameTeam); - void Radio_OrigFunc(const char *msg_id, const char *msg_verbose = NULL, short pitch = 100, bool showIcon = true); + EXT_FUNC CBasePlayer *Observer_IsValidTarget_OrigFunc(int iPlayerIndex, bool bSameTeam); + void Radio_OrigFunc(const char *msg_id, const char *msg_verbose = nullptr, short pitch = 100, bool showIcon = true); void AddAccount_OrigFunc(int amount, RewardType type = RT_NONE, bool bTrackChange = true); void Disappear_OrigFunc(); void MakeVIP_OrigFunc(); @@ -400,9 +413,9 @@ public: bool SetClientUserInfoName_OrigFunc(char *infobuffer, char *szNewName); void SetAnimation_OrigFunc(PLAYER_ANIM playerAnim); void StartObserver_OrigFunc(Vector &vecPosition, Vector &vecViewAngle); - void DropPlayerItem_OrigFunc(const char *pszItemName); + CBaseEntity *DropPlayerItem_OrigFunc(const char *pszItemName); CBaseEntity *GiveNamedItem_OrigFunc(const char *pszName); - void DropShield_OrigFunc(bool bDeploy = true); + CBaseEntity *DropShield_OrigFunc(bool bDeploy = true); void GiveShield_OrigFunc(bool bDeploy = true); bool HasRestrictItem_OrigFunc(ItemID item, ItemRestType type); void OnSpawnEquip_OrigFunc(bool addDefault = true, bool equipGame = true); @@ -419,7 +432,7 @@ public: static CBasePlayer *Instance(int offset) { return Instance(ENT(offset)); } void SpawnClientSideCorpse(); - void Observer_FindNextPlayer(bool bReverse, const char *name = NULL); + void Observer_FindNextPlayer(bool bReverse, const char *name = nullptr); CBasePlayer *Observer_IsValidTarget(int iPlayerIndex, bool bSameTeam); void Disconnect(); void Observer_Think(); @@ -429,7 +442,7 @@ public: void Observer_CheckProperties(); int IsObserver() { return pev->iuser1; } void PlantC4(); - void Radio(const char *msg_id, const char *msg_verbose = NULL, short pitch = 100, bool showIcon = true); + void Radio(const char *msg_id, const char *msg_verbose = nullptr, short pitch = 100, bool showIcon = true); CBasePlayer *GetNextRadioRecipient(CBasePlayer *pStartPlayer); void SmartRadio(); void ThrowWeapon(char *pszItemName); @@ -444,7 +457,7 @@ public: BOOL IsBombGuy(); bool IsLookingAtPosition(Vector *pos, float angleTolerance = 20.0f); void Reset(); - void SetScoreboardAttributes(CBasePlayer *destination = NULL); + void SetScoreboardAttributes(CBasePlayer *destination = nullptr); void RenewItems(); void PackDeadPlayerItems(); void GiveDefaultItems(); @@ -482,7 +495,7 @@ public: void StartDeathCam(); void StartObserver(Vector &vecPosition, Vector &vecViewAngle); void HandleSignals(); - void DropPlayerItem(const char *pszItemName); + CBaseEntity *DropPlayerItem(const char *pszItemName); bool HasPlayerItem(CBasePlayerItem *pCheckItem); bool HasNamedPlayerItem(const char *pszItemName); bool HasWeapons(); @@ -509,7 +522,7 @@ public: void ResetMenu(); void SyncRoundTimer(); void CheckSuitUpdate(); - void SetSuitUpdate(char *name = NULL, int fgroup = 0, int iNoRepeatTime = 0); + void SetSuitUpdate(char *name = nullptr, bool group = SUIT_SENTENCE, int iNoRepeatTime = SUIT_REPEAT_OK); void UpdateGeigerCounter(); void CheckTimeBasedDamage(); void BarnacleVictimBitten(entvars_t *pevBarnacle); @@ -540,7 +553,7 @@ public: bool HasShield(); bool IsProtectedByShield() { return HasShield() && m_bShieldDrawn; } void RemoveShield(); - void DropShield(bool bDeploy = true); + CBaseEntity *DropShield(bool bDeploy = true); void GiveShield(bool bDeploy = true); bool IsHittingShield(Vector &vecDirection, TraceResult *ptr); bool SelectSpawnSpot(const char *pEntClassName, CBaseEntity* &pSpot); @@ -552,7 +565,7 @@ public: void ClearAutoBuyData(); void AddAutoBuyData(const char *str); void AutoBuy(); - void ClientCommand(const char *cmd, const char *arg1 = NULL, const char *arg2 = NULL, const char *arg3 = NULL); + void ClientCommand(const char *cmd, const char *arg1 = nullptr, const char *arg2 = nullptr, const char *arg3 = nullptr); void PrioritizeAutoBuyString(char *autobuyString, const char *priorityString); const char *PickPrimaryCareerTaskWeapon(); const char *PickSecondaryCareerTaskWeapon(); @@ -597,34 +610,60 @@ public: CBasePlayerItem *GetItemById(WeaponIdType weaponID); // templates - template - CBasePlayerItem *ForEachItem(int slot, const Functor &func) + template + T *ForEachItem(int slot, const Functor &func) const { auto item = m_rgpPlayerItems[ slot ]; while (item) { - if (func(item)) - return item; + if (func(static_cast(item))) + return static_cast(item); item = item->m_pNext; } + return nullptr; } - template - CBasePlayerItem *ForEachItem(const Functor &func) + + template + T *ForEachItem(const Functor &func) const { for (auto item : m_rgpPlayerItems) { while (item) { - if (func(item)) - return item; + if (func(static_cast(item))) + return static_cast(item); item = item->m_pNext; } } + return nullptr; } + + template + T *ForEachItem(const char *pszItemName, const Functor &func) const + { + if (!pszItemName) { + return nullptr; + } + + for (auto item : m_rgpPlayerItems) + { + while (item) + { + if (FClassnameIs(pszItemName, STRING(item->pev->classname)) && func(static_cast(item))) { + return static_cast(item); + } + + item = item->m_pNext; + } + } + + return nullptr; + } + public: enum { MaxLocationLen = 32 }; @@ -661,7 +700,7 @@ public: bool m_bTeamChanged; ModelName m_iModelName; int m_iTeamKills; - int m_iIgnoreGlobalChat; + IgnoreChatMsg m_iIgnoreGlobalChat; bool m_bHasNightVision; bool m_bNightVisionOn; Vector m_vRecentPath[MAX_RECENT_PATH]; @@ -727,10 +766,10 @@ public: float m_flDuckTime; float m_flWallJumpTime; float m_flSuitUpdate; - int m_rgSuitPlayList[CSUITPLAYLIST]; + int m_rgSuitPlayList[MAX_SUIT_PLAYLIST]; int m_iSuitPlayNext; - int m_rgiSuitNoRepeat[CSUITNOREPEAT]; - float m_rgflSuitNoRepeatTime[CSUITNOREPEAT]; + int m_rgiSuitNoRepeat[MAX_SUIT_NOREPEAT]; + float m_rgflSuitNoRepeatTime[MAX_SUIT_NOREPEAT]; int m_lastDamageAmount; float m_tbdPrev; float m_flgeigerRange; @@ -772,12 +811,12 @@ public: int m_izSBarState[SBAR_END]; float m_flNextSBarUpdateTime; float m_flStatusBarDisappearDelay; - char m_SbarString0[SBAR_STRING_SIZE]; + char m_SbarString0[MAX_SBAR_STRING]; int m_lastx; int m_lasty; int m_nCustomSprayFrames; float m_flNextDecalTime; - char m_szTeamName[TEAM_NAME_LENGTH]; + char m_szTeamName[MAX_TEAM_NAME_LENGTH]; static TYPEDESCRIPTION IMPL(m_playerSaveData)[40]; @@ -830,14 +869,14 @@ public: virtual void EXPORT Touch(CBaseEntity *pOther); public: - void SetCantBePickedUpByUser(CBaseEntity *pEntity, float time) + void SetCantBePickedUpByUser(CBasePlayer *pPlayer, float time) { - m_hEntToIgnoreTouchesFrom = pEntity; + m_hEntToIgnoreTouchesFrom = pPlayer; m_flTimeToIgnoreTouches = gpGlobals->time + time; } public: - EHANDLE m_hEntToIgnoreTouchesFrom; + EntityHandle m_hEntToIgnoreTouchesFrom; float m_flTimeToIgnoreTouches; }; @@ -884,88 +923,6 @@ extern CBaseEntity *g_pLastTerroristSpawn; extern BOOL gInitHUD; extern cvar_t *sv_aim; -extern int giPrecacheGrunt; -extern int gmsgWeapPickup; -extern int gmsgHudText; -extern int gmsgHudTextArgs; -extern int gmsgShake; -extern int gmsgFade; -extern int gmsgFlashlight; -extern int gmsgFlashBattery; -extern int gmsgResetHUD; -extern int gmsgInitHUD; -extern int gmsgViewMode; -extern int gmsgShowGameTitle; -extern int gmsgCurWeapon; -extern int gmsgHealth; -extern int gmsgDamage; -extern int gmsgBattery; -extern int gmsgTrain; -extern int gmsgLogo; -extern int gmsgWeaponList; -extern int gmsgAmmoX; -extern int gmsgDeathMsg; -extern int gmsgScoreAttrib; -extern int gmsgScoreInfo; -extern int gmsgTeamInfo; -extern int gmsgTeamScore; -extern int gmsgGameMode; -extern int gmsgMOTD; -extern int gmsgServerName; -extern int gmsgAmmoPickup; -extern int gmsgItemPickup; -extern int gmsgHideWeapon; -extern int gmsgSayText; -extern int gmsgTextMsg; -extern int gmsgSetFOV; -extern int gmsgShowMenu; -extern int gmsgSendAudio; -extern int gmsgRoundTime; -extern int gmsgMoney; -extern int gmsgBlinkAcct; -extern int gmsgArmorType; -extern int gmsgStatusValue; -extern int gmsgStatusText; -extern int gmsgStatusIcon; -extern int gmsgBarTime; -extern int gmsgReloadSound; -extern int gmsgCrosshair; -extern int gmsgNVGToggle; -extern int gmsgRadar; -extern int gmsgSpectator; -extern int gmsgVGUIMenu; -extern int gmsgCZCareer; -extern int gmsgCZCareerHUD; -extern int gmsgTaskTime; -extern int gmsgTutorText; -extern int gmsgTutorLine; -extern int gmsgShadowIdx; -extern int gmsgTutorState; -extern int gmsgTutorClose; -extern int gmsgAllowSpec; -extern int gmsgBombDrop; -extern int gmsgBombPickup; -extern int gmsgHostagePos; -extern int gmsgHostageK; -extern int gmsgGeigerRange; -extern int gmsgSendCorpse; -extern int gmsgHLTV; -extern int gmsgSpecHealth; -extern int gmsgForceCam; -extern int gmsgADStop; -extern int gmsgReceiveW; -extern int gmsgScenarioIcon; -extern int gmsgBotVoice; -extern int gmsgBuyClose; -extern int gmsgItemStatus; -extern int gmsgLocation; -extern int gmsgSpecHealth2; -extern int gmsgBarTime2; -extern int gmsgBotProgress; -extern int gmsgBrass; -extern int gmsgFog; -extern int gmsgShowTimer; - void OLD_CheckBuyZone(CBasePlayer *player); void OLD_CheckBombTarget(CBasePlayer *player); void OLD_CheckRescueZone(CBasePlayer *player); @@ -983,8 +940,6 @@ void EscapeZoneIcon_Clear(CBasePlayer *player); void VIP_SafetyZoneIcon_Set(CBasePlayer *player); void VIP_SafetyZoneIcon_Clear(CBasePlayer *player); -void LinkUserMessages(); -void WriteSigonMessages(); void SendItemStatus(CBasePlayer *pPlayer); const char *GetCSModelName(int item_id); Vector VecVelocityForDamage(float flDamage); @@ -995,7 +950,6 @@ void packPlayerItem(CBasePlayer *pPlayer, CBasePlayerItem *pItem, bool packAmmo) bool CanSeeUseable(CBasePlayer *me, CBaseEntity *entity); void FixPlayerCrouchStuck(edict_t *pPlayer); BOOL IsSpawnPointValid(CBaseEntity *pPlayer, CBaseEntity *pSpot); -void InitZombieSpawns(); CBaseEntity *FindZombieSpawn(CBaseEntity *player, bool forceSpawn); CBaseEntity *FindEntityForward(CBaseEntity *pMe); float_precision GetPlayerPitch(const edict_t *pEdict); @@ -1008,5 +962,3 @@ bool IsSecondaryWeaponClass(int classId); bool IsSecondaryWeaponId(int id); const char *GetWeaponAliasFromName(const char *weaponName); bool CurrentWeaponSatisfies(CBasePlayerWeapon *pWeapon, int id, int classId); - -#endif // PLAYER_H diff --git a/regamedll/extra/cssdk/dlls/extdll.h b/regamedll/dlls/qstring.h similarity index 50% rename from regamedll/extra/cssdk/dlls/extdll.h rename to regamedll/dlls/qstring.h index e81fcd1e..13223e9d 100644 --- a/regamedll/extra/cssdk/dlls/extdll.h +++ b/regamedll/dlls/qstring.h @@ -28,55 +28,75 @@ #pragma once -#pragma warning(disable:4244) // int or float down-conversion -#pragma warning(disable:4305) // int or float data truncation -#pragma warning(disable:4201) // nameless struct/union -#pragma warning(disable:4514) // unreferenced inline function removed -#pragma warning(disable:4100) // unreferenced formal parameter +#define QSTRING_DEFINE -#include "archtypes.h" -#include "maintypes.h" -#include "regamedll_common.h" +// Quake string (helper class) +template +class QString final +{ +public: + QString(): m_string(0) {}; + QString(T string): m_string(string) {}; -#ifdef _WIN32 - #define WIN32_LEAN_AND_MEAN - #define NOWINRES - #define NOSERVICE - #define NOMCX - #define NOIME - #include "winsani_in.h" - #include "windows.h" - #include "winsani_out.h" - #undef PlaySound -#else - #include - #include - #include -#endif // _WIN32 + bool operator==(T string) const; + bool operator==(const QString &s) const; + bool operator==(const char *pszString) const; -// Misc C-runtime library headers -#include "stdio.h" -#include "stdlib.h" -#include "math.h" + operator const char *() const; + operator unsigned int() const; + const char *str() const; -// Header file containing definition of globalvars_t and entvars_t -typedef int EOFFSET; // More explicit than "int" -typedef unsigned int func_t; -typedef unsigned int string_t; // from engine's pr_comp.h; -typedef float vec_t; // needed before including progdefs.h +private: + T m_string; +}; -// Vector class -#include "vector.h" -//#include "vector.h" -// Defining it as a (bogus) struct helps enforce type-checking -#define vec3_t Vector -// Shared engine/DLL constants +#ifdef USE_QSTRING +#define string_t QString<> +#endif #include "const.h" #include "edict.h" - -// Shared header describing protocol between engine and DLLs #include "eiface.h" -// Shared header between the client DLL and the game DLLs -#include "cdll_dll.h" -#include "extdef.h" +#include "enginecallback.h" + +extern globalvars_t *gpGlobals; + +#define STRING(offset) ((const char *)(gpGlobals->pStringBase + (unsigned int)(offset))) +#define MAKE_STRING(str) ((unsigned int)(str) - (unsigned int)(STRING(0))) + +// Inlines +template +inline bool QString::operator==(T string) const +{ + return m_string == string; +} + +template +inline bool QString::operator==(const QString &s) const +{ + return m_string == s.m_string; +} + +template +inline bool QString::operator==(const char *pszString) const +{ + return FStrEq(&gpGlobals->pStringBase[m_string], pszString); +} + +template +inline const char *QString::str() const +{ + return &gpGlobals->pStringBase[m_string]; +} + +template +inline QString::operator const char *() const +{ + return str(); +} + +template +inline QString::operator unsigned int() const +{ + return m_string; +} diff --git a/regamedll/dlls/revert_saved.h b/regamedll/dlls/revert_saved.h index 3c41a1f1..4666ab92 100644 --- a/regamedll/dlls/revert_saved.h +++ b/regamedll/dlls/revert_saved.h @@ -26,11 +26,7 @@ * */ -#ifndef REVERT_SAVED_H -#define REVERT_SAVED_H -#ifdef _WIN32 #pragma once -#endif class CRevertSaved: public CPointEntity { @@ -61,5 +57,3 @@ public: float m_messageTime; float m_loadTime; }; - -#endif // REVERT_SAVED_H diff --git a/regamedll/dlls/saverestore.h b/regamedll/dlls/saverestore.h index a6612bd7..7870586f 100644 --- a/regamedll/dlls/saverestore.h +++ b/regamedll/dlls/saverestore.h @@ -26,11 +26,7 @@ * */ -#ifndef SAVERESTORE_H -#define SAVERESTORE_H -#ifdef _WIN32 #pragma once -#endif #define MAX_ENTITY_ARRAY 64 @@ -194,5 +190,3 @@ private: globalentity_t *m_pList; int m_listCount; }; - -#endif // SAVERESTORE_H diff --git a/regamedll/dlls/schedule.h b/regamedll/dlls/schedule.h index 4dc735e5..67cb43c0 100644 --- a/regamedll/dlls/schedule.h +++ b/regamedll/dlls/schedule.h @@ -26,76 +26,72 @@ * */ -#ifndef SCHEDULE_H -#define SCHEDULE_H -#ifdef _WIN32 #pragma once -#endif // these MoveFlag values are assigned to a WayPoint's TYPE in order to demonstrate the // type of movement the monster should use to get there. -#define bits_MF_TO_TARGETENT (1 << 0) // local move to targetent. -#define bits_MF_TO_ENEMY (1 << 1) // local move to enemy -#define bits_MF_TO_COVER (1 << 2) // local move to a hiding place -#define bits_MF_TO_DETOUR (1 << 3) // local move to detour point. -#define bits_MF_TO_PATHCORNER (1 << 4) // local move to a path corner -#define bits_MF_TO_NODE (1 << 5) // local move to a node -#define bits_MF_TO_LOCATION (1 << 6) // local move to an arbitrary point -#define bits_MF_IS_GOAL (1 << 7) // this waypoint is the goal of the whole move. -#define bits_MF_DONT_SIMPLIFY (1 << 8) // Don't let the route code simplify this waypoint +#define bits_MF_TO_TARGETENT BIT(0) // local move to targetent. +#define bits_MF_TO_ENEMY BIT(1) // local move to enemy +#define bits_MF_TO_COVER BIT(2) // local move to a hiding place +#define bits_MF_TO_DETOUR BIT(3) // local move to detour point. +#define bits_MF_TO_PATHCORNER BIT(4) // local move to a path corner +#define bits_MF_TO_NODE BIT(5) // local move to a node +#define bits_MF_TO_LOCATION BIT(6) // local move to an arbitrary point +#define bits_MF_IS_GOAL BIT(7) // this waypoint is the goal of the whole move. +#define bits_MF_DONT_SIMPLIFY BIT(8) // Don't let the route code simplify this waypoint // If you define any flags that aren't _TO_ flags, add them here so we can mask // them off when doing compares. -#define bits_MF_NOT_TO_MASK (bits_MF_IS_GOAL | bits_MF_DONT_SIMPLIFY) +#define bits_MF_NOT_TO_MASK (bits_MF_IS_GOAL | bits_MF_DONT_SIMPLIFY) -#define MOVEGOAL_NONE (0) -#define MOVEGOAL_TARGETENT (bits_MF_TO_TARGETENT) -#define MOVEGOAL_ENEMY (bits_MF_TO_ENEMY) -#define MOVEGOAL_PATHCORNER (bits_MF_TO_PATHCORNER) -#define MOVEGOAL_LOCATION (bits_MF_TO_LOCATION) -#define MOVEGOAL_NODE (bits_MF_TO_NODE) +#define MOVEGOAL_NONE (0) +#define MOVEGOAL_TARGETENT (bits_MF_TO_TARGETENT) +#define MOVEGOAL_ENEMY (bits_MF_TO_ENEMY) +#define MOVEGOAL_PATHCORNER (bits_MF_TO_PATHCORNER) +#define MOVEGOAL_LOCATION (bits_MF_TO_LOCATION) +#define MOVEGOAL_NODE (bits_MF_TO_NODE) // these bits represent conditions that may befall the monster, of which some are allowed // to interrupt certain schedules. -#define bits_COND_NO_AMMO_LOADED (1 << 0) // weapon needs to be reloaded! -#define bits_COND_SEE_HATE (1 << 1) // see something that you hate -#define bits_COND_SEE_FEAR (1 << 2) // see something that you are afraid of -#define bits_COND_SEE_DISLIKE (1 << 3) // see something that you dislike -#define bits_COND_SEE_ENEMY (1 << 4) // target entity is in full view. -#define bits_COND_ENEMY_OCCLUDED (1 << 5) // target entity occluded by the world -#define bits_COND_SMELL_FOOD (1 << 6) -#define bits_COND_ENEMY_TOOFAR (1 << 7) -#define bits_COND_LIGHT_DAMAGE (1 << 8) // hurt a little -#define bits_COND_HEAVY_DAMAGE (1 << 9) // hurt a lot -#define bits_COND_CAN_RANGE_ATTACK1 (1 << 10) -#define bits_COND_CAN_MELEE_ATTACK1 (1 << 11) -#define bits_COND_CAN_RANGE_ATTACK2 (1 << 12) -#define bits_COND_CAN_MELEE_ATTACK2 (1 << 13) -//#define bits_COND_CAN_RANGE_ATTACK3 (1 << 14) +#define bits_COND_NO_AMMO_LOADED BIT(0) // weapon needs to be reloaded! +#define bits_COND_SEE_HATE BIT(1) // see something that you hate +#define bits_COND_SEE_FEAR BIT(2) // see something that you are afraid of +#define bits_COND_SEE_DISLIKE BIT(3) // see something that you dislike +#define bits_COND_SEE_ENEMY BIT(4) // target entity is in full view. +#define bits_COND_ENEMY_OCCLUDED BIT(5) // target entity occluded by the world +#define bits_COND_SMELL_FOOD BIT(6) +#define bits_COND_ENEMY_TOOFAR BIT(7) +#define bits_COND_LIGHT_DAMAGE BIT(8) // hurt a little +#define bits_COND_HEAVY_DAMAGE BIT(9) // hurt a lot +#define bits_COND_CAN_RANGE_ATTACK1 BIT(10) +#define bits_COND_CAN_MELEE_ATTACK1 BIT(11) +#define bits_COND_CAN_RANGE_ATTACK2 BIT(12) +#define bits_COND_CAN_MELEE_ATTACK2 BIT(13) +//#define bits_COND_CAN_RANGE_ATTACK3 BIT(14) -#define bits_COND_PROVOKED (1 << 15) -#define bits_COND_NEW_ENEMY (1 << 16) -#define bits_COND_HEAR_SOUND (1 << 17) // there is an interesting sound -#define bits_COND_SMELL (1 << 18) // there is an interesting scent -#define bits_COND_ENEMY_FACING_ME (1 << 19) // enemy is facing me -#define bits_COND_ENEMY_DEAD (1 << 20) // enemy was killed. If you get this in combat, try to find another enemy. If you get it in alert, victory dance. -#define bits_COND_SEE_CLIENT (1 << 21) // see a client -#define bits_COND_SEE_NEMESIS (1 << 22) // see my nemesis +#define bits_COND_PROVOKED BIT(15) +#define bits_COND_NEW_ENEMY BIT(16) +#define bits_COND_HEAR_SOUND BIT(17) // there is an interesting sound +#define bits_COND_SMELL BIT(18) // there is an interesting scent +#define bits_COND_ENEMY_FACING_ME BIT(19) // enemy is facing me +#define bits_COND_ENEMY_DEAD BIT(20) // enemy was killed. If you get this in combat, try to find another enemy. If you get it in alert, victory dance. +#define bits_COND_SEE_CLIENT BIT(21) // see a client +#define bits_COND_SEE_NEMESIS BIT(22) // see my nemesis -#define bits_COND_SPECIAL1 (1 << 28) // Defined by individual monster -#define bits_COND_SPECIAL2 (1 << 29) // Defined by individual monster +#define bits_COND_SPECIAL1 BIT(28) // Defined by individual monster +#define bits_COND_SPECIAL2 BIT(29) // Defined by individual monster -#define bits_COND_TASK_FAILED (1 << 30) -#define bits_COND_SCHEDULE_DONE (1 << 31) +#define bits_COND_TASK_FAILED BIT(30) +#define bits_COND_SCHEDULE_DONE BIT(31) -#define bits_COND_ALL_SPECIAL (bits_COND_SPECIAL1 | bits_COND_SPECIAL2) -#define bits_COND_CAN_ATTACK (bits_COND_CAN_RANGE_ATTACK1 | bits_COND_CAN_MELEE_ATTACK1 | bits_COND_CAN_RANGE_ATTACK2 | bits_COND_CAN_MELEE_ATTACK2) +#define bits_COND_ALL_SPECIAL (bits_COND_SPECIAL1 | bits_COND_SPECIAL2) +#define bits_COND_CAN_ATTACK (bits_COND_CAN_RANGE_ATTACK1 | bits_COND_CAN_MELEE_ATTACK1 | bits_COND_CAN_RANGE_ATTACK2 | bits_COND_CAN_MELEE_ATTACK2) -#define TASKSTATUS_NEW 0 // Just started -#define TASKSTATUS_RUNNING 1 // Running task & movement -#define TASKSTATUS_RUNNING_MOVEMENT 2 // Just running movement -#define TASKSTATUS_RUNNING_TASK 3 // Just running task -#define TASKSTATUS_COMPLETE 4 // Completed, get next task +#define TASKSTATUS_NEW 0 // Just started +#define TASKSTATUS_RUNNING 1 // Running task & movement +#define TASKSTATUS_RUNNING_MOVEMENT 2 // Just running movement +#define TASKSTATUS_RUNNING_TASK 3 // Just running task +#define TASKSTATUS_COMPLETE 4 // Completed, get next task // These are the schedule types typedef enum @@ -121,7 +117,7 @@ typedef enum SCHED_TAKE_COVER_FROM_ENEMY, SCHED_TAKE_COVER_FROM_BEST_SOUND, SCHED_TAKE_COVER_FROM_ORIGIN, - SCHED_COWER, // usually a last resort! + SCHED_COWER, // usually a last resort! SCHED_MELEE_ATTACK1, SCHED_MELEE_ATTACK2, SCHED_RANGE_ATTACK1, @@ -218,8 +214,8 @@ typedef enum TASK_SOUND_WAKE, TASK_SOUND_PAIN, TASK_SOUND_DIE, - TASK_FIND_COVER_FROM_BEST_SOUND, // tries lateral cover first, then node cover - TASK_FIND_COVER_FROM_ENEMY, // tries lateral cover first, then node cover + TASK_FIND_COVER_FROM_BEST_SOUND, // tries lateral cover first, then node cover + TASK_FIND_COVER_FROM_ENEMY, // tries lateral cover first, then node cover TASK_FIND_LATERAL_COVER_FROM_ENEMY, TASK_FIND_NODE_COVER_FROM_ENEMY, TASK_FIND_NEAR_NODE_COVER_FROM_ENEMY, // data for this one is the MAXIMUM acceptable distance to the cover. @@ -240,7 +236,7 @@ typedef enum TASK_REMEMBER, TASK_FORGET, TASK_WAIT_FOR_MOVEMENT, // wait until MovementIsComplete() - LAST_COMMON_TASK, // LEAVE THIS AT THE BOTTOM (sjb) + LAST_COMMON_TASK, // LEAVE THIS AT THE BOTTOM (sjb) } SHARED_TASKS; @@ -274,10 +270,9 @@ struct Task_t struct Schedule_t { - Task_t *pTasklist; int cTasks; - int iInterruptMask;// a bit mask of conditions that can interrupt this schedule + int iInterruptMask; // a bit mask of conditions that can interrupt this schedule // a more specific mask that indicates which TYPES of sounds will interrupt the schedule in the // event that the schedule is broken by COND_HEAR_SOUND @@ -292,5 +287,3 @@ struct WayPoint_t Vector vecLocation; int iType; }; - -#endif // SCHEDULE_H diff --git a/regamedll/dlls/scriptevent.h b/regamedll/dlls/scriptevent.h index 5fb778c7..2e9aeb5b 100644 --- a/regamedll/dlls/scriptevent.h +++ b/regamedll/dlls/scriptevent.h @@ -26,22 +26,16 @@ * */ -#ifndef SCRIPTEVENT_H -#define SCRIPTEVENT_H -#ifdef _WIN32 #pragma once -#endif -#define SCRIPT_EVENT_DEAD 1000 // character is now dead -#define SCRIPT_EVENT_NOINTERRUPT 1001 // does not allow interrupt -#define SCRIPT_EVENT_CANINTERRUPT 1002 // will allow interrupt -#define SCRIPT_EVENT_FIREEVENT 1003 // event now fires -#define SCRIPT_EVENT_SOUND 1004 // Play named wave file (on CHAN_BODY) -#define SCRIPT_EVENT_SENTENCE 1005 // Play named sentence -#define SCRIPT_EVENT_INAIR 1006 // Leave the character in air at the end of the sequence (don't find the floor) -#define SCRIPT_EVENT_ENDANIMATION 1007 // Set the animation by name after the sequence completes -#define SCRIPT_EVENT_SOUND_VOICE 1008 // Play named wave file (on CHAN_VOICE) -#define SCRIPT_EVENT_SENTENCE_RND1 1009 // Play sentence group 25% of the time -#define SCRIPT_EVENT_NOT_DEAD 1010 // Bring back to life (for life/death sequences) - -#endif // SCRIPTEVENT_H +#define SCRIPT_EVENT_DEAD 1000 // character is now dead +#define SCRIPT_EVENT_NOINTERRUPT 1001 // does not allow interrupt +#define SCRIPT_EVENT_CANINTERRUPT 1002 // will allow interrupt +#define SCRIPT_EVENT_FIREEVENT 1003 // event now fires +#define SCRIPT_EVENT_SOUND 1004 // Play named wave file (on CHAN_BODY) +#define SCRIPT_EVENT_SENTENCE 1005 // Play named sentence +#define SCRIPT_EVENT_INAIR 1006 // Leave the character in air at the end of the sequence (don't find the floor) +#define SCRIPT_EVENT_ENDANIMATION 1007 // Set the animation by name after the sequence completes +#define SCRIPT_EVENT_SOUND_VOICE 1008 // Play named wave file (on CHAN_VOICE) +#define SCRIPT_EVENT_SENTENCE_RND1 1009 // Play sentence group 25% of the time +#define SCRIPT_EVENT_NOT_DEAD 1010 // Bring back to life (for life/death sequences) diff --git a/regamedll/dlls/singleplay_gamerules.cpp b/regamedll/dlls/singleplay_gamerules.cpp index 7652029f..50a796fd 100644 --- a/regamedll/dlls/singleplay_gamerules.cpp +++ b/regamedll/dlls/singleplay_gamerules.cpp @@ -66,7 +66,7 @@ float CHalfLifeRules::FlPlayerFallDamage(CBasePlayer *pPlayer) { // subtract off the speed at which a player is allowed to fall without being hurt, // so damage will be based on speed beyond that, not the entire fall - pPlayer->m_flFallVelocity -= PLAYER_MAX_SAFE_FALL_SPEED; + pPlayer->m_flFallVelocity -= MAX_PLAYER_SAFE_FALL_SPEED; return pPlayer->m_flFallVelocity * DAMAGE_FOR_FALL_SPEED; } @@ -140,8 +140,7 @@ Vector CHalfLifeRules::VecWeaponRespawnSpot(CBasePlayerItem *pWeapon) edict_t *CHalfLifeRules::GetPlayerSpawnSpot(CBasePlayer *pPlayer) { - CBaseEntity *pSpot = UTIL_FindEntityByClassname(NULL, "info_player_start"); - + CBaseEntity *pSpot = UTIL_FindEntityByClassname(nullptr, "info_player_start"); if (!pSpot) { ALERT(at_error, "PutClientInServer: no info_player_start on level"); diff --git a/regamedll/dlls/skill.h b/regamedll/dlls/skill.h index 88ca0bbc..6f504530 100644 --- a/regamedll/dlls/skill.h +++ b/regamedll/dlls/skill.h @@ -26,15 +26,11 @@ * */ -#ifndef SKILL_H -#define SKILL_H -#ifdef _WIN32 #pragma once -#endif -#define SKILL_EASY 1 -#define SKILL_MEDIUM 2 -#define SKILL_HARD 3 +#define SKILL_EASY 1 +#define SKILL_MEDIUM 2 +#define SKILL_HARD 3 struct skilldata_t { @@ -58,5 +54,3 @@ struct skilldata_t extern skilldata_t gSkillData; float GetSkillCvar(char *pName); - -#endif // SKILL_H diff --git a/regamedll/dlls/sound.cpp b/regamedll/dlls/sound.cpp index 8a984f21..1cc409a0 100644 --- a/regamedll/dlls/sound.cpp +++ b/regamedll/dlls/sound.cpp @@ -3,36 +3,36 @@ #ifndef HOOK_GAMEDLL // presets for runtime pitch and vol modulation of ambient sounds -UNTESTED dynpitchvol_t rgdpvpreset[CDPVPRESETMAX] = +dynpitchvol_t rgdpvpreset[MAX_SENTENCE_DPV_RESET] = { - // pitch prun pstart spinup spindwn volrun volstrt fadein fadeout lfotype lforate lfomodp modvol cspnup cspnct pitch spupsv spdwnsv pfrac vol fdinsv fdotsv volfrac lfofrac lfomult - { 1, 255, 75, 95, 95, 10, 1, 50, 95, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 2, 255, 85, 70, 88, 10, 1, 20, 88, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 3, 255, 100, 50, 75, 10, 1, 10, 75, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 4, 100, 100, 0, 0, 10, 1, 90, 90, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 5, 100, 100, 0, 0, 10, 1, 80, 80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 6, 100, 100, 0, 0, 10, 1, 50, 70, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 7, 100, 100, 0, 0, 5, 1, 40, 50, 1, 50, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 8, 100, 100, 0, 0, 5, 1, 40, 50, 1, 150, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 9, 100, 100, 0, 0, 5, 1, 40, 50, 1, 750, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 10, 128, 100, 50, 75, 10, 1, 30, 40, 2, 8, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 11, 128, 100, 50, 75, 10, 1, 30, 40, 2, 25, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 12, 128, 100, 50, 75, 10, 1, 30, 40, 2, 70, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 13, 50, 50, 0, 0, 10, 1, 20, 50, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 14, 70, 70, 0, 0, 10, 1, 20, 50, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 15, 90, 90, 0, 0, 10, 1, 20, 50, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 16, 120, 120, 0, 0, 10, 1, 20, 50, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 17, 180, 180, 0, 0, 10, 1, 20, 50, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 18, 255, 255, 0, 0, 10, 1, 20, 50, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 19, 200, 75, 90, 90, 10, 1, 50, 90, 2, 100, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 20, 255, 75, 97, 90, 10, 1, 50, 90, 1, 40, 50, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 21, 100, 100, 0, 0, 10, 1, 30, 50, 3, 15, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 22, 160, 160, 0, 0, 10, 1, 50, 50, 3, 500, 25, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 23, 255, 75, 88, 0, 10, 1, 40, 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 24, 200, 20, 95, 70, 10, 1, 70, 70, 3, 20, 50, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 25, 180, 100, 50, 60, 10, 1, 40, 60, 2, 90, 100, 100, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 26, 60, 60, 0, 0, 10, 1, 40, 70, 3, 80, 20, 50, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 27, 128, 90, 10, 10, 10, 1, 20, 40, 1, 5, 10, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } + // pitch prun pstart spinup spindwn volrun volstrt fadein fadeout lfotype lforate lfomodp modvol cspnup cspnct pitch spupsv spdwnsv pfrac vol fdinsv fdotsv volfrac lfofrac lfomult + { 1, 255, 75, 95, 95, 10, 1, 50, 95, LFO_OFF, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 2, 255, 85, 70, 88, 10, 1, 20, 88, LFO_OFF, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 3, 255, 100, 50, 75, 10, 1, 10, 75, LFO_OFF, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 4, 100, 100, 0, 0, 10, 1, 90, 90, LFO_OFF, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 5, 100, 100, 0, 0, 10, 1, 80, 80, LFO_OFF, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 6, 100, 100, 0, 0, 10, 1, 50, 70, LFO_OFF, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 7, 100, 100, 0, 0, 5, 1, 40, 50, LFO_SQUARE, 50, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 8, 100, 100, 0, 0, 5, 1, 40, 50, LFO_SQUARE, 150, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 9, 100, 100, 0, 0, 5, 1, 40, 50, LFO_SQUARE, 750, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 10, 128, 100, 50, 75, 10, 1, 30, 40, LFO_TRIANGLE, 8, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 11, 128, 100, 50, 75, 10, 1, 30, 40, LFO_TRIANGLE, 25, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 12, 128, 100, 50, 75, 10, 1, 30, 40, LFO_TRIANGLE, 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 13, 50, 50, 0, 0, 10, 1, 20, 50, LFO_OFF, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 14, 70, 70, 0, 0, 10, 1, 20, 50, LFO_OFF, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 15, 90, 90, 0, 0, 10, 1, 20, 50, LFO_OFF, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 16, 120, 120, 0, 0, 10, 1, 20, 50, LFO_OFF, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 17, 180, 180, 0, 0, 10, 1, 20, 50, LFO_OFF, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 18, 255, 255, 0, 0, 10, 1, 20, 50, LFO_OFF, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 19, 200, 75, 90, 90, 10, 1, 50, 90, LFO_TRIANGLE, 100, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 20, 255, 75, 97, 90, 10, 1, 50, 90, LFO_SQUARE, 40, 50, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 21, 100, 100, 0, 0, 10, 1, 30, 50, LFO_RANDOM, 15, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 22, 160, 160, 0, 0, 10, 1, 50, 50, LFO_RANDOM, 500, 25, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 23, 255, 75, 88, 0, 10, 1, 40, 0, LFO_OFF, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 24, 200, 20, 95, 70, 10, 1, 70, 70, LFO_RANDOM, 20, 50, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 25, 180, 100, 50, 60, 10, 1, 40, 60, LFO_TRIANGLE, 90, 100, 100, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 26, 60, 60, 0, 0, 10, 1, 40, 70, LFO_RANDOM, 80, 20, 50, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 27, 128, 90, 10, 10, 10, 1, 20, 40, LFO_SQUARE, 5, 10, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, }; TYPEDESCRIPTION CAmbientGeneric::m_SaveData[] = @@ -71,8 +71,8 @@ BOOL fTextureTypeInit = FALSE; // time delay until it's ok to speak: used so that two NPCs don't talk at once float CTalkMonster::g_talkWaitTime = 0; -char gszallsentencenames[CVOXFILESENTENCEMAX][CBSENTENCENAME_MAX]; -sentenceg rgsentenceg[CSENTENCEG_MAX]; +char gszallsentencenames[MAX_SENTENCE_VOXFILE][MAX_SENTENCE_NAME]; +sentenceg rgsentenceg[MAX_SENTENCE_GROUPS]; // Used to detect the texture the player is standing on, map the // texture name to a material type. Play footstep sound based on material type. @@ -89,19 +89,19 @@ IMPLEMENT_SAVERESTORE(CAmbientGeneric, CBaseEntity) // 80 : "Large Radius" void CAmbientGeneric::Spawn() { - if (pev->spawnflags & AMBIENT_SOUND_EVERYWHERE) + if (pev->spawnflags & SF_AMBIENT_SOUND_EVERYWHERE) { m_flAttenuation = ATTN_NONE; } - else if (pev->spawnflags & AMBIENT_SOUND_SMALLRADIUS) + else if (pev->spawnflags & SF_AMBIENT_SOUND_SMALLRADIUS) { m_flAttenuation = ATTN_IDLE; } - else if (pev->spawnflags & AMBIENT_SOUND_MEDIUMRADIUS) + else if (pev->spawnflags & SF_AMBIENT_SOUND_MEDIUMRADIUS) { m_flAttenuation = ATTN_STATIC; } - else if (pev->spawnflags & AMBIENT_SOUND_LARGERADIUS) + else if (pev->spawnflags & SF_AMBIENT_SOUND_LARGERADIUS) { m_flAttenuation = ATTN_NORM; } @@ -136,7 +136,7 @@ void CAmbientGeneric::Spawn() m_fActive = FALSE; - if (pev->spawnflags & AMBIENT_SOUND_NOT_LOOPING) + if (pev->spawnflags & SF_AMBIENT_SOUND_NOT_LOOPING) m_fLooping = FALSE; else m_fLooping = TRUE; @@ -146,19 +146,19 @@ void CAmbientGeneric::Spawn() void CAmbientGeneric::Restart() { - if (pev->spawnflags & AMBIENT_SOUND_EVERYWHERE) + if (pev->spawnflags & SF_AMBIENT_SOUND_EVERYWHERE) { m_flAttenuation = ATTN_NONE; } - else if (pev->spawnflags & AMBIENT_SOUND_SMALLRADIUS) + else if (pev->spawnflags & SF_AMBIENT_SOUND_SMALLRADIUS) { m_flAttenuation = ATTN_IDLE; } - else if (pev->spawnflags & AMBIENT_SOUND_MEDIUMRADIUS) + else if (pev->spawnflags & SF_AMBIENT_SOUND_MEDIUMRADIUS) { m_flAttenuation = ATTN_STATIC; } - else if (pev->spawnflags & AMBIENT_SOUND_LARGERADIUS) + else if (pev->spawnflags & SF_AMBIENT_SOUND_LARGERADIUS) { m_flAttenuation = ATTN_NORM; } @@ -196,7 +196,7 @@ void CAmbientGeneric::Restart() InitModulationParms(); pev->nextthink = gpGlobals->time + 0.1f; - if (!(pev->spawnflags & AMBIENT_SOUND_NOT_LOOPING)) + if (!(pev->spawnflags & SF_AMBIENT_SOUND_NOT_LOOPING)) { m_fLooping = TRUE; m_fActive = TRUE; @@ -225,7 +225,7 @@ void CAmbientGeneric::Precache() // init all dynamic modulation parms InitModulationParms(); - if (!(pev->spawnflags & AMBIENT_SOUND_START_SILENT)) + if (!(pev->spawnflags & SF_AMBIENT_SOUND_START_SILENT)) { // start the sound ASAP if (m_fLooping) @@ -471,7 +471,7 @@ void CAmbientGeneric::InitModulationParms() m_dpv.volrun = 0; // get presets - if (m_dpv.preset != 0 && m_dpv.preset <= CDPVPRESETMAX) + if (m_dpv.preset != 0 && m_dpv.preset <= MAX_SENTENCE_DPV_RESET) { // load preset values m_dpv = rgdpvpreset[m_dpv.preset - 1]; @@ -619,7 +619,7 @@ void CAmbientGeneric::ToggleUse(CBaseEntity *pActivator, CBaseEntity *pCaller, U m_fActive = FALSE; // HACKHACK - this makes the code in Precache() work properly after a save/restore - pev->spawnflags |= AMBIENT_SOUND_START_SILENT; + pev->spawnflags |= SF_AMBIENT_SOUND_START_SILENT; if (m_dpv.spindownsav || m_dpv.fadeoutsav) { // spin it down (or fade it) before shutoff if spindown is set @@ -787,7 +787,7 @@ void CAmbientGeneric::KeyValue(KeyValueData *pkvd) // lfotype else if (FStrEq(pkvd->szKeyName, "lfotype")) { - m_dpv.lfotype = Q_atoi(pkvd->szValue); + m_dpv.lfotype = (LowFreqOsc)Q_atoi(pkvd->szValue); if (m_dpv.lfotype > 4) m_dpv.lfotype = LFO_TRIANGLE; @@ -851,7 +851,9 @@ void CAmbientGeneric::KeyValue(KeyValueData *pkvd) pkvd->fHandled = TRUE; } else + { CBaseEntity::KeyValue(pkvd); + } } LINK_ENTITY_TO_CLASS(env_sound, CEnvSound, CCSEnvSound) @@ -980,8 +982,8 @@ void CEnvSound::Think() // only! //CLIENT_COMMAND(pentPlayer, "room_type %f", m_flRoomtype); - MESSAGE_BEGIN(MSG_ONE, SVC_ROOMTYPE, NULL, pentPlayer); // use the magic #1 for "one client" - WRITE_SHORT((short)m_flRoomtype); // sequence number + MESSAGE_BEGIN(MSG_ONE, SVC_ROOMTYPE, nullptr, pentPlayer); // use the magic #1 for "one client" + WRITE_SHORT((short)m_flRoomtype); // sequence number MESSAGE_END(); // crank up nextthink rate for new active sound entity @@ -1021,8 +1023,8 @@ void USENTENCEG_InitLRU(unsigned char *plru, int count) if (!fSentencesInit) return; - if (count > CSENTENCE_LRU_MAX) - count = CSENTENCE_LRU_MAX; + if (count > MAX_SENTENCE_LRU) + count = MAX_SENTENCE_LRU; for (i = 0; i < count; ++i) plru[i] = (unsigned char)i; @@ -1154,7 +1156,7 @@ int SENTENCEG_GetIndex(const char *szgroupname) if (!Q_strcmp(szgroupname, rgsentenceg[i].szgroupname)) return i; - ++i; + i++; } return -1; @@ -1279,7 +1281,7 @@ void SENTENCEG_Init() Q_memset(gszallsentencenames, 0, sizeof(gszallsentencenames)); gcallsentences = 0; - Q_memset(rgsentenceg, 0, CSENTENCEG_MAX * sizeof(sentenceg)); + Q_memset(rgsentenceg, 0, MAX_SENTENCE_GROUPS * sizeof(sentenceg)); Q_memset(buffer, 0, sizeof(buffer)); Q_memset(szgroup, 0, sizeof(szgroup)); @@ -1291,17 +1293,17 @@ void SENTENCEG_Init() return; // for each line in the file... - while (memfgets(pMemFile, fileSize, filePos, buffer, sizeof(buffer) - 1) != NULL) + while (memfgets(pMemFile, fileSize, filePos, buffer, sizeof(buffer) - 1)) { // skip whitespace i = 0; while (buffer[i] && buffer[i] == ' ') - ++i; + i++; if (!buffer[i]) continue; - if (buffer[i] == '/' || !Q_isalpha(buffer[i])) + if (buffer[i] == '/' || !isalpha(buffer[i])) continue; // get sentence name @@ -1312,7 +1314,7 @@ void SENTENCEG_Init() if (!buffer[j]) continue; - if (gcallsentences > CVOXFILESENTENCEMAX) + if (gcallsentences > MAX_SENTENCE_VOXFILE) { ALERT(at_error, "Too many sentences in sentences.txt!\n"); break; @@ -1322,9 +1324,9 @@ void SENTENCEG_Init() buffer[j] = 0; const char *pString = buffer + i; - if (Q_strlen(pString) >= CBSENTENCENAME_MAX) + if (Q_strlen(pString) >= MAX_SENTENCE_NAME) { - ALERT(at_warning, "Sentence %s longer than %d letters\n", pString, CBSENTENCENAME_MAX - 1); + ALERT(at_warning, "Sentence %s longer than %d letters\n", pString, MAX_SENTENCE_NAME - 1); } Q_strcpy(gszallsentencenames[gcallsentences++], pString); @@ -1352,7 +1354,7 @@ void SENTENCEG_Init() // name doesn't match with prev name, // copy name into group, init count to 1 isentencegs++; - if (isentencegs >= CSENTENCEG_MAX) + if (isentencegs >= MAX_SENTENCE_GROUPS) { ALERT(at_error, "Too many sentence groups in sentences.txt!\n"); break; @@ -1381,10 +1383,10 @@ void SENTENCEG_Init() i = 0; - while (rgsentenceg[i].count && i < CSENTENCEG_MAX) + while (rgsentenceg[i].count && i < MAX_SENTENCE_GROUPS) { USENTENCEG_InitLRU(&(rgsentenceg[i].rgblru[0]), rgsentenceg[i].count); - ++i; + i++; } } @@ -1396,7 +1398,7 @@ int SENTENCEG_Lookup(const char *sample, char *sentencenum) // this is a sentence name; lookup sentence number // and give to engine as string. - for (i = 0; i < gcallsentences; ++i) + for (i = 0; i < gcallsentences; i++) { if (!Q_stricmp(gszallsentencenames[i], sample + 1)) { @@ -1483,10 +1485,10 @@ char *memfgets(byte *pMemFile, int fileSize, int &filePos, char *pBuffer, int bu { // Bullet-proofing if (!pMemFile || !pBuffer) - return NULL; + return nullptr; if (filePos >= fileSize) - return NULL; + return nullptr; int i = filePos; int last = fileSize; @@ -1502,7 +1504,7 @@ char *memfgets(byte *pMemFile, int fileSize, int &filePos, char *pBuffer, int bu { if (pMemFile[i] == '\n') stop = 1; - ++i; + i++; } // If we actually advanced the pointer, copy it over @@ -1523,7 +1525,7 @@ char *memfgets(byte *pMemFile, int fileSize, int &filePos, char *pBuffer, int bu } // No data read, bail - return NULL; + return nullptr; } void TEXTURETYPE_Init() @@ -1548,33 +1550,33 @@ void TEXTURETYPE_Init() return; // for each line in the file... - while (memfgets(pMemFile, fileSize, filePos, buffer, sizeof(buffer) - 1) != NULL && (gcTextures < CTEXTURESMAX)) + while (memfgets(pMemFile, fileSize, filePos, buffer, sizeof(buffer) - 1) && (gcTextures < CTEXTURESMAX)) { // skip whitespace i = 0; - while (buffer[i] && Q_isspace(buffer[i])) - ++i; + while (buffer[i] && isspace(buffer[i])) + i++; if (!buffer[i]) continue; // skip comment lines - if (buffer[i] == '/' || !Q_isalpha(buffer[i])) + if (buffer[i] == '/' || !isalpha(buffer[i])) continue; // get texture type - grgchTextureType[gcTextures] = Q_toupper(buffer[i++]); + grgchTextureType[gcTextures] = toupper(buffer[i++]); // skip whitespace - while (buffer[i] && Q_isspace(buffer[i])) - ++i; + while (buffer[i] && isspace(buffer[i])) + i++; if (!buffer[i]) continue; // get sentence name j = i; - while (buffer[j] && !Q_isspace(buffer[j])) + while (buffer[j] && !isspace(buffer[j])) j++; if (!buffer[j]) @@ -1845,7 +1847,7 @@ void CSpeaker::Spawn() void CSpeaker::Precache() { - if (!(pev->spawnflags & SPEAKER_START_SILENT)) + if (!(pev->spawnflags & SF_SPEAKER_START_SILENT)) { // set first announcement time for random n second pev->nextthink = gpGlobals->time + RANDOM_FLOAT(5, 15); @@ -1854,7 +1856,7 @@ void CSpeaker::Precache() void CSpeaker::SpeakerThink() { - char *szSoundFile = NULL; + char *szSoundFile = nullptr; float flvolume = pev->health * 0.1f; float flattenuation = 0.3f; int flags = 0; @@ -1890,7 +1892,7 @@ void CSpeaker::SpeakerThink() szSoundFile = (char *)STRING(pev->message); #ifdef REGAMEDLL_FIXES - if (szSoundFile == NULL) + if (szSoundFile == nullptr) { // if is null - return; return; @@ -1915,7 +1917,7 @@ void CSpeaker::SpeakerThink() } // set next announcement time for random 5 to 10 minute delay - pev->nextthink = gpGlobals->time + RANDOM_FLOAT(ANNOUNCE_MINUTES_MIN * 60.0f, ANNOUNCE_MINUTES_MAX * 60.0f); + pev->nextthink = gpGlobals->time + RANDOM_FLOAT(MIN_ANNOUNCE_MINS * 60.0f, MAX_ANNOUNCE_MINS * 60.0f); // time delay until it's ok to speak: used so that two NPCs don't talk at once CTalkMonster::g_talkWaitTime = gpGlobals->time + 5.0f; @@ -1979,5 +1981,7 @@ void CSpeaker::KeyValue(KeyValueData *pkvd) pkvd->fHandled = TRUE; } else + { CBaseEntity::KeyValue(pkvd); + } } diff --git a/regamedll/dlls/sound.h b/regamedll/dlls/sound.h index aa2b5883..1aa0ca19 100644 --- a/regamedll/dlls/sound.h +++ b/regamedll/dlls/sound.h @@ -26,40 +26,32 @@ * */ -#ifndef SOUND_H -#define SOUND_H -#ifdef _WIN32 #pragma once -#endif -#define CSENTENCEG_MAX 200 // max number of sentence groups -#define CSENTENCE_LRU_MAX 32 // max number of elements per sentence group -#define CDPVPRESETMAX 27 +const int MAX_SENTENCE_NAME = 16; +const int MAX_SENTENCE_VOXFILE = 1536; // Max number of sentences in game. NOTE: this must match CVOXFILESENTENCEMAX in engine\sound.h -// spawnflags -#define AMBIENT_SOUND_STATIC 0 // medium radius attenuation -#define AMBIENT_SOUND_EVERYWHERE 1 -#define AMBIENT_SOUND_SMALLRADIUS 2 -#define AMBIENT_SOUND_MEDIUMRADIUS 4 -#define AMBIENT_SOUND_LARGERADIUS 8 -#define AMBIENT_SOUND_START_SILENT 16 -#define AMBIENT_SOUND_NOT_LOOPING 32 +const int MAX_SENTENCE_GROUPS = 200; // Max number of sentence groups +const int MAX_SENTENCE_LRU = 32; // Max number of elements per sentence group +const int MAX_SENTENCE_DPV_RESET = 27; // Max number of dynamic pitch volumes -#define ANNOUNCE_MINUTES_MIN 0.25 -#define ANNOUNCE_MINUTES_MAX 2.25 +const float MAX_ANNOUNCE_MINS = 2.25f; +const float MIN_ANNOUNCE_MINS = 0.25f; -#define SPEAKER_START_SILENT 1 // wait for trigger 'on' to start announcements - -#define LFO_SQUARE 1 // square -#define LFO_TRIANGLE 2 // triangle -#define LFO_RANDOM 3 // random +enum LowFreqOsc : int +{ + LFO_OFF = 0, + LFO_SQUARE, // Square + LFO_TRIANGLE, // Triangle + LFO_RANDOM, // Random +}; // group of related sentences struct sentenceg { char szgroupname[16]; int count; - unsigned char rgblru[ CSENTENCE_LRU_MAX ]; + unsigned char rgblru[MAX_SENTENCE_LRU]; }; // runtime pitch shift and volume fadein/out structure @@ -72,24 +64,24 @@ typedef struct dynpitchvol // NOTE: unless you also change order of rgdpvpreset array elements! int preset; - int pitchrun; // pitch shift % when sound is running 0 - 255 - int pitchstart; // pitch shift % when sound stops or starts 0 - 255 - int spinup; // spinup time 0 - 100 - int spindown; // spindown time 0 - 100 + int pitchrun; // Pitch shift % when sound is running 0 - 255 + int pitchstart; // Pitch shift % when sound stops or starts 0 - 255 + int spinup; // Spinup time 0 - 100 + int spindown; // Spindown time 0 - 100 - int volrun; // volume change % when sound is running 0 - 10 - int volstart; // volume change % when sound stops or starts 0 - 10 - int fadein; // volume fade in time 0 - 100 - int fadeout; // volume fade out time 0 - 100 + int volrun; // Volume change % when sound is running 0 - 10 + int volstart; // Volume change % when sound stops or starts 0 - 10 + int fadein; // Volume fade in time 0 - 100 + int fadeout; // Volume fade out time 0 - 100 // Low Frequency Oscillator - int lfotype; // 0) off 1) square 2) triangle 3) random + LowFreqOsc lfotype; // 0) off 1) square 2) triangle 3) random int lforate; // 0 - 1000, how fast lfo osciallates int lfomodpitch; // 0-100 mod of current pitch. 0 is off. int lfomodvol; // 0-100 mod of current volume. 0 is off. - int cspinup; // each trigger hit increments counter and spinup pitch + int cspinup; // Each trigger hit increments counter and spinup pitch int cspincount; int pitch; @@ -105,6 +97,14 @@ typedef struct dynpitchvol } dynpitchvol_t; +#define SF_AMBIENT_SOUND_STATIC 0 // Medium radius attenuation +#define SF_AMBIENT_SOUND_EVERYWHERE BIT(0) +#define SF_AMBIENT_SOUND_SMALLRADIUS BIT(1) +#define SF_AMBIENT_SOUND_MEDIUMRADIUS BIT(2) +#define SF_AMBIENT_SOUND_LARGERADIUS BIT(3) +#define SF_AMBIENT_SOUND_START_SILENT BIT(4) +#define SF_AMBIENT_SOUND_NOT_LOOPING BIT(5) + class CAmbientGeneric: public CBaseEntity { public: @@ -124,10 +124,10 @@ public: public: static TYPEDESCRIPTION IMPL(m_SaveData)[4]; - float m_flAttenuation; // attenuation value + float m_flAttenuation; // Attenuation value dynpitchvol_t m_dpv; - BOOL m_fActive; // only TRUE when the entity is playing a looping sound - BOOL m_fLooping; // TRUE when the sound played will loop + BOOL m_fActive; // Only TRUE when the entity is playing a looping sound + BOOL m_fLooping; // TRUE when the sound played will loop }; class CEnvSound: public CPointEntity @@ -146,6 +146,8 @@ public: float m_flRoomtype; }; +#define SF_SPEAKER_START_SILENT BIT(0) // Wait for trigger 'on' to start announcements + class CSpeaker: public CBaseEntity { public: @@ -163,7 +165,7 @@ public: public: static TYPEDESCRIPTION IMPL(m_SaveData)[1]; - int m_preset; // preset number + int m_preset; // Preset number }; BOOL FEnvSoundInRange(entvars_t *pev, entvars_t *pevTarget, float *pflRange); @@ -186,7 +188,5 @@ void TEXTURETYPE_Init(); char TEXTURETYPE_Find(char *name); float TEXTURETYPE_PlaySound(TraceResult *ptr, Vector vecSrc, Vector vecEnd, int iBulletType); -extern char gszallsentencenames[CVOXFILESENTENCEMAX][CBSENTENCENAME_MAX]; +extern char gszallsentencenames[MAX_SENTENCE_VOXFILE][MAX_SENTENCE_NAME]; extern int gcTextures; - -#endif // SOUND_H diff --git a/regamedll/dlls/soundent.cpp b/regamedll/dlls/soundent.cpp index c580102b..f1a3056f 100644 --- a/regamedll/dlls/soundent.cpp +++ b/regamedll/dlls/soundent.cpp @@ -5,10 +5,12 @@ */ #ifndef HOOK_GAMEDLL -CSoundEnt *pSoundEnt = NULL; +CSoundEnt *pSoundEnt = nullptr; #endif +// The entity that spawns when the world spawns, +// and handles the world's active and free sound lists. LINK_ENTITY_TO_CLASS(soundent, CSoundEnt, CCSSoundEnt) // CSound - Clear - zeros all fields for a sound @@ -267,7 +269,7 @@ int CSoundEnt::ISoundsInList(int iListType) while (iThisSound != SOUNDLIST_EMPTY) { - ++i; + i++; iThisSound = m_SoundPool[ iThisSound ].m_iNext; } @@ -302,19 +304,19 @@ CSound *CSoundEnt::SoundPointerForIndex(int iIndex) { if (!pSoundEnt) { - return NULL; + return nullptr; } if (iIndex > (MAX_WORLD_SOUNDS - 1)) { ALERT(at_console, "SoundPointerForIndex() - Index too large!\n"); - return NULL; + return nullptr; } if (iIndex < 0) { ALERT(at_console, "SoundPointerForIndex() - Index < 0!\n"); - return NULL; + return nullptr; } return &pSoundEnt->m_SoundPool[ iIndex ]; diff --git a/regamedll/dlls/soundent.h b/regamedll/dlls/soundent.h index 95bb2a99..5ffadaa3 100644 --- a/regamedll/dlls/soundent.h +++ b/regamedll/dlls/soundent.h @@ -26,35 +26,28 @@ * */ -#ifndef SOUNDENT_H -#define SOUNDENT_H -#ifdef _WIN32 #pragma once -#endif -// Soundent.h - the entity that spawns when the world -// spawns, and handles the world's active and free sound -// lists. +#define MAX_WORLD_SOUNDS 64 // maximum number of sounds handled by the world at one time. -#define MAX_WORLD_SOUNDS 64 // maximum number of sounds handled by the world at one time. +#define bits_SOUND_NONE 0 +#define bits_SOUND_COMBAT BIT(0) // gunshots, explosions +#define bits_SOUND_WORLD BIT(1) // door opening/closing, glass breaking +#define bits_SOUND_PLAYER BIT(2) // all noises generated by player. walking, shooting, falling, splashing +#define bits_SOUND_CARCASS BIT(3) // dead body +#define bits_SOUND_MEAT BIT(4) // gib or pork chop +#define bits_SOUND_DANGER BIT(5) // pending danger. Grenade that is about to explode, explosive barrel that is damaged, falling crate +#define bits_SOUND_GARBAGE BIT(6) // trash cans, banana peels, old fast food bags. +#define bits_ALL_SOUNDS 0xFFFFFFFF -#define bits_SOUND_NONE 0 -#define bits_SOUND_COMBAT (1 << 0) // gunshots, explosions -#define bits_SOUND_WORLD (1 << 1) // door opening/closing, glass breaking -#define bits_SOUND_PLAYER (1 << 2) // all noises generated by player. walking, shooting, falling, splashing -#define bits_SOUND_CARCASS (1 << 3) // dead body -#define bits_SOUND_MEAT (1 << 4) // gib or pork chop -#define bits_SOUND_DANGER (1 << 5) // pending danger. Grenade that is about to explode, explosive barrel that is damaged, falling crate -#define bits_SOUND_GARBAGE (1 << 6) // trash cans, banana peels, old fast food bags. -#define bits_ALL_SOUNDS 0xFFFFFFFF +#define SOUNDLIST_EMPTY -1 +#define SOUNDLISTTYPE_FREE 1 // identifiers passed to functions that can operate on either list, to indicate which list to operate on. +#define SOUNDLISTTYPE_ACTIVE 2 -#define SOUNDLIST_EMPTY -1 -#define SOUNDLISTTYPE_FREE 1 // identifiers passed to functions that can operate on either list, to indicate which list to operate on. -#define SOUNDLISTTYPE_ACTIVE 2 -#define SOUND_NEVER_EXPIRE -1 // with this set as a sound's ExpireTime, the sound will never expire. +#define SOUND_NEVER_EXPIRE -1 // with this set as a sound's ExpireTime, the sound will never expire. -// CSound - an instance of a sound in the world. +// An instance of a sound in the world. class CSound { public: @@ -68,12 +61,12 @@ public: Vector m_vecOrigin; // sound's location in space int m_iType; // what type of sound this is int m_iVolume; // how loud the sound is - float m_flExpireTime; // when the sound should be purged from the list + float m_flExpireTime; // when the sound should be purged from the list int m_iNext; // index of next sound in this list ( Active or Free ) int m_iNextAudible; // temporary link that monsters use to build a list of audible sounds }; -// CSoundEnt - a single instance of this entity spawns when +// A single instance of this entity spawns when // the world spawns. The SoundEnt's job is to update the // world's Free and Active sound lists. class CSoundEnt: public CBaseEntity @@ -108,7 +101,7 @@ public: public: int m_iFreeSound; // index of the first sound in the free sound list int m_iActiveSound; // indes of the first sound in the active sound list - int m_cLastActiveSounds; // keeps track of the number of active sounds at the last update. (for diagnostic work) + int m_cLastActiveSounds; // keeps track of the number of active sounds at the last update. (for diagnostic work) BOOL m_fShowReport; // if true, dump information about free/active sounds. private: @@ -116,5 +109,3 @@ private: }; extern CSoundEnt *pSoundEnt; - -#endif // SOUNDENT_H diff --git a/regamedll/dlls/spectator.cpp b/regamedll/dlls/spectator.cpp index bd66205b..472952bf 100644 --- a/regamedll/dlls/spectator.cpp +++ b/regamedll/dlls/spectator.cpp @@ -6,7 +6,7 @@ void CBaseSpectator::SpectatorConnect() pev->solid = SOLID_NOT; pev->movetype = MOVETYPE_NOCLIP; - m_pGoalEnt = NULL; + m_pGoalEnt = nullptr; } void CBaseSpectator::SpectatorDisconnect() @@ -16,7 +16,7 @@ void CBaseSpectator::SpectatorDisconnect() void CBaseSpectator::SpectatorImpulseCommand() { - static edict_t *pGoal = NULL; + static edict_t *pGoal = nullptr; edict_t *pPreviousGoal; edict_t *pCurrentGoal; @@ -95,5 +95,5 @@ void CBaseSpectator::Spawn() pev->solid = SOLID_NOT; pev->movetype = MOVETYPE_NOCLIP; - m_pGoalEnt = NULL; + m_pGoalEnt = nullptr; } diff --git a/regamedll/dlls/spectator.h b/regamedll/dlls/spectator.h index c56e4151..479ed7ab 100644 --- a/regamedll/dlls/spectator.h +++ b/regamedll/dlls/spectator.h @@ -26,11 +26,7 @@ * */ -#ifndef SPECTATOR_H -#define SPECTATOR_H -#ifdef _WIN32 #pragma once -#endif class CBaseSpectator: public CBaseEntity { @@ -45,5 +41,3 @@ public: private: void SpectatorImpulseCommand(); }; - -#endif // SPECTATOR_H diff --git a/regamedll/dlls/subs.cpp b/regamedll/dlls/subs.cpp index 77d32f17..04dc055a 100644 --- a/regamedll/dlls/subs.cpp +++ b/regamedll/dlls/subs.cpp @@ -68,7 +68,9 @@ void CBaseDMStart::KeyValue(KeyValueData *pkvd) pkvd->fHandled = TRUE; } else + { CPointEntity::KeyValue(pkvd); + } } BOOL CBaseDMStart::IsTriggered(CBaseEntity *pEntity) @@ -81,22 +83,6 @@ BOOL CBaseDMStart::IsTriggered(CBaseEntity *pEntity) // This updates global tables that need to know about entities being removed void CBaseEntity::UpdateOnRemove() { -#ifndef REGAMEDLL_FIXES - if (pev->flags & FL_GRAPHED) - { - // this entity was a LinkEnt in the world node graph, so we must remove it from - // the graph since we are removing it from the world. - for (int i = 0; i < WorldGraph.m_cLinks; ++i) - { - if (WorldGraph.m_pLinkPool[i].m_pLinkEnt == pev) - { - // if this link has a link ent which is the same ent that is removing itself, remove it! - WorldGraph.m_pLinkPool[i].m_pLinkEnt = NULL; - } - } - } -#endif - if (pev->globalname) { gGlobalState.EntitySetState(pev->globalname, GLOBAL_DEAD); @@ -106,7 +92,10 @@ void CBaseEntity::UpdateOnRemove() // Convenient way to delay removing oneself void CBaseEntity::SUB_Remove() { +#ifndef REGAMEDLL_FIXES UpdateOnRemove(); +#endif + if (pev->health > 0) { // this situation can screw up monsters who can't tell their entity pointers are invalid. @@ -138,7 +127,9 @@ void CBaseDelay::KeyValue(KeyValueData *pkvd) pkvd->fHandled = TRUE; } else + { CBaseEntity::KeyValue(pkvd); + } } // If self.delay is set, a DelayedUse entity will be created that will actually @@ -160,10 +151,15 @@ void CBaseEntity::SUB_UseTargets(CBaseEntity *pActivator, USE_TYPE useType, floa void FireTargets(const char *targetName, CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) { - edict_t *pentTarget = NULL; + edict_t *pentTarget = nullptr; if (!targetName) return; +#ifdef REGAMEDLL_FIXES + if (targetName[0] == '\0') + return; +#endif + ALERT(at_aiconsole, "Firing: (%s)\n", targetName); while (true) { @@ -174,7 +170,7 @@ void FireTargets(const char *targetName, CBaseEntity *pActivator, CBaseEntity *p CBaseEntity *pTarget = CBaseEntity::Instance(pentTarget); // Don't use dying ents - if (pTarget != NULL && !(pTarget->pev->flags & FL_KILLME)) + if (pTarget && !(pTarget->pev->flags & FL_KILLME)) { ALERT(at_aiconsole, "Found: %s, firing (%s)\n", STRING(pTarget->pev->classname), targetName); pTarget->Use(pActivator, pCaller, useType, value); @@ -194,7 +190,7 @@ void CBaseDelay::SUB_UseTargets(CBaseEntity *pActivator, USE_TYPE useType, float if (m_flDelay != 0) { // create a temp object to fire at a later time - CBaseDelay *pTemp = GetClassPtr((CBaseDelay *)NULL); + CBaseDelay *pTemp = GetClassPtr((CBaseDelay *)nullptr); MAKE_STRING_CLASS("DelayedUse", pTemp->pev); @@ -221,7 +217,7 @@ void CBaseDelay::SUB_UseTargets(CBaseEntity *pActivator, USE_TYPE useType, float } else { - pTemp->pev->owner = NULL; + pTemp->pev->owner = nullptr; } return; @@ -230,10 +226,10 @@ void CBaseDelay::SUB_UseTargets(CBaseEntity *pActivator, USE_TYPE useType, float // kill the killtargets if (m_iszKillTarget) { - edict_t *pentKillTarget = NULL; + edict_t *pentKillTarget = nullptr; ALERT(at_aiconsole, "KillTarget: %s\n", STRING(m_iszKillTarget)); - pentKillTarget = FIND_ENTITY_BY_TARGETNAME(NULL, STRING(m_iszKillTarget)); + pentKillTarget = FIND_ENTITY_BY_TARGETNAME(nullptr, STRING(m_iszKillTarget)); while (!FNullEnt(pentKillTarget)) { @@ -274,10 +270,10 @@ void SetMovedir(entvars_t *pev) void CBaseDelay::DelayThink() { - CBaseEntity *pActivator = NULL; + CBaseEntity *pActivator = nullptr; // A player activated this on delay - if (pev->owner != NULL) + if (pev->owner) { pActivator = CBaseEntity::Instance(pev->owner); } @@ -312,7 +308,9 @@ void CBaseToggle::KeyValue(KeyValueData *pkvd) pkvd->fHandled = TRUE; } else + { CBaseDelay::KeyValue(pkvd); + } } // calculate pev->velocity and pev->nextthink to reach vecDest from @@ -320,7 +318,7 @@ void CBaseToggle::KeyValue(KeyValueData *pkvd) void CBaseToggle::LinearMove(Vector vecDest, float flSpeed) { assert(("LinearMove: no speed is defined!", flSpeed != 0)); - //assert(("LinearMove: no post-move function defined", m_pfnCallWhenMoveDone != NULL)); + //assert(("LinearMove: no post-move function defined", m_pfnCallWhenMoveDone != nullptr)); m_vecFinalDest = vecDest; @@ -372,7 +370,7 @@ NOXREF BOOL CBaseToggle::IsLockedByMaster() void CBaseToggle::AngularMove(Vector vecDestAngle, float flSpeed) { assert(("AngularMove: no speed is defined!", flSpeed != 0)); - //assert(("AngularMove: no post-move function defined", m_pfnCallWhenMoveDone != NULL)); + //assert(("AngularMove: no post-move function defined", m_pfnCallWhenMoveDone != nullptr)); m_vecFinalAngle = vecDestAngle; @@ -410,7 +408,7 @@ void CBaseToggle::AngularMoveDone() } } -float CBaseToggle::AxisValue(int flags, const Vector &angles) +NOXREF float CBaseToggle::AxisValue(int flags, const Vector &angles) { if (flags & SF_DOOR_ROTATE_Z) return angles.z; diff --git a/regamedll/dlls/subs.h b/regamedll/dlls/subs.h index 4c44bcf8..a3630c63 100644 --- a/regamedll/dlls/subs.h +++ b/regamedll/dlls/subs.h @@ -26,11 +26,7 @@ * */ -#ifndef SUBS_H -#define SUBS_H -#ifdef _WIN32 #pragma once -#endif class CNullEntity: public CBaseEntity { @@ -48,5 +44,3 @@ public: void FireTargets(const char *targetName, CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); void SetMovedir(entvars_t *pev); BOOL FEntIsVisible(entvars_t *pev, entvars_t *pevTarget); - -#endif // SUBS_H diff --git a/regamedll/dlls/talkmonster.h b/regamedll/dlls/talkmonster.h index 47a6fa79..ad8ed171 100644 --- a/regamedll/dlls/talkmonster.h +++ b/regamedll/dlls/talkmonster.h @@ -26,16 +26,10 @@ * */ -#ifndef TALKMONSTER_H -#define TALKMONSTER_H -#ifdef _WIN32 #pragma once -#endif class CTalkMonster: public CBaseMonster { public: static float g_talkWaitTime; }; - -#endif // TALKMONSTER_H diff --git a/regamedll/dlls/training_gamerules.cpp b/regamedll/dlls/training_gamerules.cpp index 91b7ade5..2e0724e1 100644 --- a/regamedll/dlls/training_gamerules.cpp +++ b/regamedll/dlls/training_gamerules.cpp @@ -10,8 +10,8 @@ TYPEDESCRIPTION CFuncWeaponCheck::m_SaveData[] = DEFINE_FIELD(CFuncWeaponCheck, sTriggerWithItems, FIELD_STRING), DEFINE_FIELD(CFuncWeaponCheck, sTriggerNoItems, FIELD_STRING), DEFINE_FIELD(CFuncWeaponCheck, iItemCount, FIELD_INTEGER), - DEFINE_ARRAY(CFuncWeaponCheck, sMaster, FIELD_STRING, MAX_ITEM_COUNTS), - DEFINE_FIELD(CFuncWeaponCheck, sItemName, FIELD_STRING), + DEFINE_FIELD(CFuncWeaponCheck, sMaster, FIELD_STRING), + DEFINE_ARRAY(CFuncWeaponCheck, sItemName, FIELD_STRING, MAX_ITEM_COUNTS), DEFINE_FIELD(CFuncWeaponCheck, iAnyWeapon, FIELD_INTEGER), }; @@ -53,7 +53,7 @@ void CHalfLifeTraining::HostageDied() edict_t *CHalfLifeTraining::GetPlayerSpawnSpot(CBasePlayer *pPlayer) { - CBaseEntity *pSpot = UTIL_FindEntityByClassname(NULL, "info_player_start"); + CBaseEntity *pSpot = UTIL_FindEntityByClassname(nullptr, "info_player_start"); if (FNullEnt(pSpot)) { @@ -133,7 +133,7 @@ void CHalfLifeTraining::PlayerThink(CBasePlayer *pPlayer) } } - CGrenade *pBomb = NULL; + CGrenade *pBomb = nullptr; while ((pBomb = (CGrenade *)UTIL_FindEntityByClassname(pBomb, "grenade"))) { if (pBomb->m_pentCurBombTarget) @@ -148,7 +148,7 @@ void CHalfLifeTraining::PlayerThink(CBasePlayer *pPlayer) if (!fVisitedBuyArea) { - MESSAGE_BEGIN(MSG_ONE, gmsgStatusIcon, NULL, pPlayer->pev); + MESSAGE_BEGIN(MSG_ONE, gmsgStatusIcon, nullptr, pPlayer->pev); WRITE_BYTE(STATUSICON_FLASH); WRITE_STRING("buyzone"); WRITE_BYTE(0); @@ -167,11 +167,11 @@ void CHalfLifeTraining::PlayerThink(CBasePlayer *pPlayer) { if (!fVisitedBuyArea) { - MESSAGE_BEGIN(MSG_ONE, gmsgBlinkAcct, NULL, pPlayer->pev); + MESSAGE_BEGIN(MSG_ONE, gmsgBlinkAcct, nullptr, pPlayer->pev); WRITE_BYTE(3); MESSAGE_END(); - MESSAGE_BEGIN(MSG_ONE, gmsgStatusIcon, NULL, pPlayer->pev); + MESSAGE_BEGIN(MSG_ONE, gmsgStatusIcon, nullptr, pPlayer->pev); WRITE_BYTE(STATUSICON_SHOW); WRITE_STRING("buyzone"); WRITE_BYTE(0); @@ -218,7 +218,7 @@ void CHalfLifeTraining::PlayerSpawn(CBasePlayer *pPlayer) fVGUIMenus = pPlayer->m_bVGUIMenus; SET_MODEL(ENT(pPlayer->pev), "models/player.mdl"); - CBaseEntity *pWeaponEntity = NULL; + CBaseEntity *pWeaponEntity = nullptr; while ((pWeaponEntity = UTIL_FindEntityByClassname(pWeaponEntity, "game_player_equip"))) { @@ -255,7 +255,7 @@ void CHalfLifeTraining::CheckWinConditions() { if (m_bBombDefused) { - CGrenade *pBomb = NULL; + CGrenade *pBomb = nullptr; while ((pBomb = (CGrenade *)UTIL_FindEntityByClassname(pBomb, "grenade"))) { @@ -270,7 +270,7 @@ void CHalfLifeTraining::CheckWinConditions() } else if (m_bTargetBombed) { - CGrenade *pBomb = NULL; + CGrenade *pBomb = nullptr; while ((pBomb = (CGrenade *)UTIL_FindEntityByClassname(pBomb, "grenade"))) { @@ -287,7 +287,7 @@ void CHalfLifeTraining::CheckWinConditions() } } - CBaseEntity *pHostage = NULL; + CBaseEntity *pHostage = nullptr; while ((pHostage = UTIL_FindEntityByClassname(pHostage, "hostage_entity"))) { if (pHostage->pev->deadflag != DEAD_RESPAWNABLE || !FStringNull(pHostage->pev->noise1)) @@ -295,7 +295,7 @@ void CHalfLifeTraining::CheckWinConditions() UTIL_SetSize(pHostage->pev, Vector(-16, -16, 0), Vector(16, 16, 72)); - CBaseEntity *pRescueArea = NULL; + CBaseEntity *pRescueArea = nullptr; while ((pRescueArea = UTIL_FindEntityByClassname(pRescueArea, "func_hostage_rescue"))) { if (!pRescueArea->Intersects(pHostage)) @@ -305,7 +305,7 @@ void CHalfLifeTraining::CheckWinConditions() if (pRescueArea) { pHostage->pev->noise1 = 1; - FireTargets(STRING(pRescueArea->pev->target), NULL, NULL, USE_TOGGLE, 0); + FireTargets(STRING(pRescueArea->pev->target), nullptr, nullptr, USE_TOGGLE, 0); } } } @@ -330,7 +330,7 @@ void CBaseGrenCatch::Touch(CBaseEntity *pOther) return; } - if (Q_strstr(STRING(pev->model), "flash") != NULL) + if (Q_strstr(STRING(pev->model), "flash")) { m_fFlashTouched = true; } @@ -345,7 +345,7 @@ void CBaseGrenCatch::Think() m_fSmokeTouchingLastFrame = m_fSmokeTouching; m_fSmokeTouching = false; - pGrenade = NULL; + pGrenade = nullptr; while ((pGrenade = (CGrenade *)UTIL_FindEntityByClassname(pGrenade, "grenade"))) { @@ -354,7 +354,7 @@ void CBaseGrenCatch::Think() UTIL_SetSize(pGrenade->pev, Vector(-8, -8, 0), Vector(8, 8, 0)); - if (pGrenade->Intersects(this) && Q_strstr(STRING(pGrenade->pev->model), "smoke") != NULL) + if (pGrenade->Intersects(this) && Q_strstr(STRING(pGrenade->pev->model), "smoke")) { if (pGrenade->pev->velocity.Length() == 0) m_fSmokeTouching = true; @@ -371,7 +371,7 @@ void CBaseGrenCatch::Think() if (m_NeedGrenadeType == GRENADETYPE_SMOKE) { - pTrigger = NULL; + pTrigger = nullptr; while ((pTrigger = UTIL_FindEntityByTargetname(pTrigger, STRING(sDisableOnGrenade)))) { @@ -381,12 +381,14 @@ void CBaseGrenCatch::Think() } } else if (m_NeedGrenadeType == GRENADETYPE_FLASH) + { pev->flags |= FL_KILLME; + } } if (m_fSmokeTouchingLastFrame && !m_fSmokeTouching) { - pTrigger = NULL; + pTrigger = nullptr; while ((pTrigger = UTIL_FindEntityByTargetname(pTrigger, STRING(sDisableOnGrenade)))) { @@ -426,7 +428,9 @@ void CBaseGrenCatch::KeyValue(KeyValueData *pkvd) } } else + { CBaseEntity::KeyValue(pkvd); + } } void CFuncWeaponCheck::Spawn() @@ -505,7 +509,7 @@ void CFuncWeaponCheck::KeyValue(KeyValueData *pkvd) pev->speed = Q_atof(pkvd->szValue); pkvd->fHandled = TRUE; } - else if (Q_strstr(pkvd->szKeyName, "item") != NULL) + else if (Q_strstr(pkvd->szKeyName, "item")) { if (iItemCount < MAX_ITEM_COUNTS) { @@ -525,5 +529,7 @@ void CFuncWeaponCheck::KeyValue(KeyValueData *pkvd) pkvd->fHandled = TRUE; } else + { CBaseEntity::KeyValue(pkvd); + } } diff --git a/regamedll/dlls/training_gamerules.h b/regamedll/dlls/training_gamerules.h index 735f2b2c..e6effd0d 100644 --- a/regamedll/dlls/training_gamerules.h +++ b/regamedll/dlls/training_gamerules.h @@ -26,11 +26,7 @@ * */ -#ifndef TRAINING_GAMERULES_H -#define TRAINING_GAMERULES_H -#ifdef _WIN32 #pragma once -#endif class CHalfLifeTraining: public CHalfLifeMultiplay { @@ -61,6 +57,13 @@ public: bool fVGUIMenus; }; +enum GrenCatchType : int +{ + GRENADETYPE_NONE = 0, + GRENADETYPE_SMOKE, + GRENADETYPE_FLASH, +}; + class CBaseGrenCatch: public CBaseEntity { public: @@ -75,13 +78,15 @@ public: public: static TYPEDESCRIPTION IMPL(m_SaveData)[5]; - int m_NeedGrenadeType; + GrenCatchType m_NeedGrenadeType; string_t sTriggerOnGrenade; string_t sDisableOnGrenade; bool m_fSmokeTouching; bool m_fFlashTouched; }; +const int MAX_ITEM_COUNTS = 32; + class CFuncWeaponCheck: public CBaseEntity { public: @@ -98,9 +103,7 @@ private: string_t sTriggerWithItems; string_t sTriggerNoItems; string_t sMaster; - unsigned int sItemName[32]; + string_t sItemName[MAX_ITEM_COUNTS]; int iItemCount; int iAnyWeapon; }; - -#endif // TRAINING_GAMERULES_H diff --git a/regamedll/dlls/trains.h b/regamedll/dlls/trains.h index c06d7b23..c383aa38 100644 --- a/regamedll/dlls/trains.h +++ b/regamedll/dlls/trains.h @@ -26,29 +26,13 @@ * */ -#ifndef TRAINS_H -#define TRAINS_H -#ifdef _WIN32 #pragma once -#endif -// Tracktrain spawn flags -#define SF_TRACKTRAIN_NOPITCH 0x0001 -#define SF_TRACKTRAIN_NOCONTROL 0x0002 -#define SF_TRACKTRAIN_FORWARDONLY 0x0004 -#define SF_TRACKTRAIN_PASSABLE 0x0008 - -// Spawnflag for CPathTrack -#define SF_PATH_DISABLED 0x00000001 -#define SF_PATH_FIREONCE 0x00000002 -#define SF_PATH_ALTREVERSE 0x00000004 -#define SF_PATH_DISABLE_TRAIN 0x00000008 -#define SF_PATH_ALTERNATE 0x00008000 - -// Spawnflags of CPathCorner -#define SF_CORNER_WAITFORTRIG 0x001 -#define SF_CORNER_TELEPORT 0x002 -#define SF_CORNER_FIREONCE 0x004 +#define SF_PATH_DISABLED BIT(0) +#define SF_PATH_FIREONCE BIT(1) +#define SF_PATH_ALTREVERSE BIT(2) +#define SF_PATH_DISABLE_TRAIN BIT(3) +#define SF_PATH_ALTERNATE BIT(15) class CPathTrack: public CPointEntity { @@ -85,6 +69,15 @@ public: CPathTrack *m_paltpath; }; +const float TRAIN_STARTPITCH = 60.0f; +const float TRAIN_MAXPITCH = 200.0f; +const float TRAIN_MAXSPEED = 1000.0f; + +#define SF_TRACKTRAIN_NOPITCH BIT(0) +#define SF_TRACKTRAIN_NOCONTROL BIT(1) +#define SF_TRACKTRAIN_FORWARDONLY BIT(2) +#define SF_TRACKTRAIN_PASSABLE BIT(3) + class CFuncTrackTrain: public CBaseEntity { public: @@ -209,5 +202,3 @@ public: private: unsigned short m_usAdjustPitch; }; - -#endif // TRAINS_H diff --git a/regamedll/dlls/triggers.cpp b/regamedll/dlls/triggers.cpp index 9531f57a..1acdf868 100644 --- a/regamedll/dlls/triggers.cpp +++ b/regamedll/dlls/triggers.cpp @@ -14,12 +14,12 @@ TYPEDESCRIPTION CFrictionModifier::m_SaveData[] = TYPEDESCRIPTION CAutoTrigger::m_SaveData[] = { DEFINE_FIELD(CAutoTrigger, m_globalstate, FIELD_STRING), - DEFINE_FIELD(CAutoTrigger, triggerType, FIELD_INTEGER), + DEFINE_FIELD(CAutoTrigger, m_triggerType, FIELD_INTEGER), }; TYPEDESCRIPTION CTriggerRelay::m_SaveData[1] = { - DEFINE_FIELD(CTriggerRelay, triggerType, FIELD_INTEGER), + DEFINE_FIELD(CTriggerRelay, m_triggerType, FIELD_INTEGER), }; // Global Savedata for multi_manager @@ -28,18 +28,19 @@ TYPEDESCRIPTION CMultiManager::m_SaveData[] = DEFINE_FIELD(CMultiManager, m_cTargets, FIELD_INTEGER), DEFINE_FIELD(CMultiManager, m_index, FIELD_INTEGER), DEFINE_FIELD(CMultiManager, m_startTime, FIELD_TIME), - DEFINE_ARRAY(CMultiManager, m_iTargetName, FIELD_STRING, MAX_MULTI_TARGETS), - DEFINE_ARRAY(CMultiManager, m_flTargetDelay, FIELD_FLOAT, MAX_MULTI_TARGETS), + DEFINE_ARRAY(CMultiManager, m_iTargetName, FIELD_STRING, MAX_MM_TARGETS), + DEFINE_ARRAY(CMultiManager, m_flTargetDelay, FIELD_FLOAT, MAX_MM_TARGETS), }; // Global Savedata for changelevel trigger TYPEDESCRIPTION CChangeLevel::m_SaveData[] = { - DEFINE_ARRAY(CChangeLevel, m_szMapName, FIELD_CHARACTER, cchMapNameMost), - DEFINE_ARRAY(CChangeLevel, m_szLandmarkName, FIELD_CHARACTER, cchMapNameMost), + DEFINE_ARRAY(CChangeLevel, m_szMapName, FIELD_CHARACTER, MAX_MAPNAME_LENGHT), + DEFINE_ARRAY(CChangeLevel, m_szLandmarkName, FIELD_CHARACTER, MAX_MAPNAME_LENGHT), DEFINE_FIELD(CChangeLevel, m_changeTarget, FIELD_STRING), DEFINE_FIELD(CChangeLevel, m_changeTargetDelay, FIELD_FLOAT), }; + TYPEDESCRIPTION CTriggerChangeTarget::m_SaveData[] = { DEFINE_FIELD(CTriggerChangeTarget, m_iszNewTarget, FIELD_STRING), @@ -65,9 +66,6 @@ TYPEDESCRIPTION CTriggerCamera::m_SaveData[] = #endif // HOOK_GAMEDLL -char st_szNextMap[cchMapNameMost]; -char st_szNextSpot[cchMapNameMost]; - LINK_ENTITY_TO_CLASS(func_friction, CFrictionModifier, CCSFrictionModifier) IMPLEMENT_SAVERESTORE(CFrictionModifier, CBaseEntity) @@ -100,7 +98,9 @@ void CFrictionModifier::KeyValue(KeyValueData *pkvd) pkvd->fHandled = TRUE; } else + { CBaseEntity::KeyValue(pkvd); + } } LINK_ENTITY_TO_CLASS(trigger_auto, CAutoTrigger, CCSAutoTrigger) @@ -119,19 +119,21 @@ void CAutoTrigger::KeyValue(KeyValueData *pkvd) switch (type) { case 0: - triggerType = USE_OFF; + m_triggerType = USE_OFF; break; case 2: - triggerType = USE_TOGGLE; + m_triggerType = USE_TOGGLE; break; default: - triggerType = USE_ON; + m_triggerType = USE_ON; break; } pkvd->fHandled = TRUE; } else + { CBaseDelay::KeyValue(pkvd); + } } void CAutoTrigger::Spawn() @@ -148,10 +150,10 @@ void CAutoTrigger::Think() { if (!m_globalstate || gGlobalState.EntityGetState(m_globalstate) == GLOBAL_ON) { - SUB_UseTargets(this, triggerType, 0); + SUB_UseTargets(this, m_triggerType, 0); #ifdef REGAMEDLL_FIXES - if (pev->spawnflags & SF_AUTO_NO_RESET) + if (pev->spawnflags & SF_AUTO_NORESET) #else if (pev->spawnflags & SF_AUTO_FIREONCE) #endif @@ -164,7 +166,7 @@ void CAutoTrigger::Think() #ifdef REGAMEDLL_FIXES void CAutoTrigger::Restart() { - if (pev->spawnflags & SF_AUTO_NO_RESET) + if (pev->spawnflags & SF_AUTO_NORESET) return; pev->nextthink = gpGlobals->time + 0.1f; @@ -182,19 +184,21 @@ void CTriggerRelay::KeyValue(KeyValueData *pkvd) switch (type) { case 0: - triggerType = USE_OFF; + m_triggerType = USE_OFF; break; case 2: - triggerType = USE_TOGGLE; + m_triggerType = USE_TOGGLE; break; default: - triggerType = USE_ON; + m_triggerType = USE_ON; break; } pkvd->fHandled = TRUE; } else + { CBaseDelay::KeyValue(pkvd); + } } void CTriggerRelay::Spawn() @@ -204,7 +208,7 @@ void CTriggerRelay::Spawn() void CTriggerRelay::Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) { - SUB_UseTargets(this, triggerType, 0); + SUB_UseTargets(this, m_triggerType, 0); if (pev->spawnflags & SF_RELAY_FIREONCE) { UTIL_Remove(this); @@ -224,7 +228,7 @@ void CMultiManager::KeyValue(KeyValueData *pkvd) else // add this field to the target list { // this assumes that additional fields are targetnames and their values are delay values. - if (m_cTargets < MAX_MULTI_TARGETS) + if (m_cTargets < MAX_MM_TARGETS) { char tmp[128]; @@ -246,11 +250,11 @@ void CMultiManager::Spawn() // Sort targets // Quick and dirty bubble sort - int swapped = 1; + bool bSwapped = true; - while (swapped) + while (bSwapped) { - swapped = 0; + bSwapped = false; for (int i = 1; i < m_cTargets; ++i) { if (m_flTargetDelay[i] < m_flTargetDelay[i - 1]) @@ -263,7 +267,7 @@ void CMultiManager::Spawn() m_flTargetDelay[i] = m_flTargetDelay[i - 1]; m_iTargetName[i - 1] = name; m_flTargetDelay[i - 1] = delay; - swapped = 1; + bSwapped = true; } } } @@ -272,7 +276,7 @@ void CMultiManager::Spawn() void CMultiManager::Restart() { #ifndef REGAMEDLL_FIXES - edict_t *pentTarget = NULL; + edict_t *pentTarget = nullptr; for (int i = 0; i < m_cTargets; ++i) { @@ -287,8 +291,7 @@ void CMultiManager::Restart() break; CBaseEntity *pTarget = static_cast(CBaseEntity::Instance(pentTarget)); - - if (pTarget != NULL && !(pTarget->pev->flags & FL_KILLME)) + if (pTarget && !(pTarget->pev->flags & FL_KILLME)) { pTarget->Restart(); } @@ -352,7 +355,7 @@ void CMultiManager::ManagerThink() CMultiManager *CMultiManager::Clone() { - CMultiManager *pMulti = GetClassPtr((CMultiManager *)NULL); + CMultiManager *pMulti = GetClassPtr((CMultiManager *)nullptr); edict_t *pEdict = pMulti->pev->pContainingEntity; Q_memcpy(pMulti->pev, pev, sizeof(*pev)); @@ -529,7 +532,9 @@ void CBaseTrigger::KeyValue(KeyValueData *pkvd) pkvd->fHandled = TRUE; } else + { CBaseToggle::KeyValue(pkvd); + } } LINK_ENTITY_TO_CLASS(trigger_monsterjump, CTriggerMonsterJump, CCSTriggerMonsterJump) @@ -699,7 +704,9 @@ void CTargetCDAudio::KeyValue(KeyValueData *pkvd) pkvd->fHandled = TRUE; } else + { CPointEntity::KeyValue(pkvd); + } } void CTargetCDAudio::Spawn() @@ -787,7 +794,7 @@ void CTriggerHurt::Restart() void CTriggerHurt::RadiationThink() { edict_t *pentPlayer; - CBasePlayer *pPlayer = NULL; + CBasePlayer *pPlayer = nullptr; float_precision flRange; entvars_t *pevTarget; Vector vecSpot1; @@ -997,7 +1004,7 @@ void CTriggerMultiple::Spawn() //if (pev->health > 0) //{ - // if (pev->spawnflags & SPAWNFLAG_NOTOUCH) + // if (pev->spawnflags & SF_TRIGGER_MULTIPLE_NOTOUCH) // { // ALERT(at_error, "trigger_multiple spawn: health and notouch don't make sense"); // } @@ -1067,7 +1074,7 @@ void CBaseTrigger::ActivateMultiTrigger(CBaseEntity *pActivator) if (FClassnameIs(pev, "trigger_secret")) { - if (pev->enemy == NULL || !FClassnameIs(pev->enemy, "player")) + if (pev->enemy == nullptr || !FClassnameIs(pev->enemy, "player")) return; gpGlobals->found_secrets++; @@ -1101,7 +1108,7 @@ void CBaseTrigger::ActivateMultiTrigger(CBaseEntity *pActivator) pev->nextthink = gpGlobals->time + 0.1f; #ifdef REGAMEDLL_FIXES - if (!(pev->spawnflags & SF_TRIGGER_NO_RESET) && m_flWait == -2) + if (!(pev->spawnflags & SF_TRIGGER_NORESET) && m_flWait == -2) SetThink(NULL); else #endif @@ -1125,7 +1132,7 @@ void CBaseTrigger::CounterUse(CBaseEntity *pActivator, CBaseEntity *pCaller, USE return; } - BOOL fTellActivator = (m_hActivator != 0 && FClassnameIs(m_hActivator->pev, "player") && !(pev->spawnflags & SPAWNFLAG_NOMESSAGE)); + BOOL fTellActivator = (m_hActivator && FClassnameIs(m_hActivator->pev, "player") && !(pev->spawnflags & SF_TRIGGER_COUNTER_NOMESSAGE)); if (m_cTriggersLeft != 0) { @@ -1134,9 +1141,9 @@ void CBaseTrigger::CounterUse(CBaseEntity *pActivator, CBaseEntity *pCaller, USE // UNDONE: I don't think we want these Quakesque messages switch (m_cTriggersLeft) { - case 1: ALERT(at_console, "Only 1 more to go..."); break; - case 2: ALERT(at_console, "Only 2 more to go..."); break; - case 3: ALERT(at_console, "Only 3 more to go..."); break; + case 1: ALERT(at_console, "Only 1 more to go..."); break; + case 2: ALERT(at_console, "Only 2 more to go..."); break; + case 3: ALERT(at_console, "Only 3 more to go..."); break; default: ALERT(at_console, "There are more to go..."); break; } } @@ -1211,7 +1218,7 @@ void CChangeLevel::KeyValue(KeyValueData *pkvd) { if (FStrEq(pkvd->szKeyName, "map")) { - if (Q_strlen(pkvd->szValue) >= cchMapNameMost) + if (Q_strlen(pkvd->szValue) >= MAX_MAPNAME_LENGHT) { ALERT(at_error, "Map name '%s' too long (32 chars)\n", pkvd->szValue); } @@ -1221,7 +1228,7 @@ void CChangeLevel::KeyValue(KeyValueData *pkvd) } else if (FStrEq(pkvd->szKeyName, "landmark")) { - if (Q_strlen(pkvd->szValue) >= cchMapNameMost) + if (Q_strlen(pkvd->szValue) >= MAX_MAPNAME_LENGHT) { ALERT(at_error, "Landmark name '%s' too long (32 chars)\n", pkvd->szValue); } @@ -1240,7 +1247,9 @@ void CChangeLevel::KeyValue(KeyValueData *pkvd) pkvd->fHandled = TRUE; } else + { CBaseTrigger::KeyValue(pkvd); + } } void CChangeLevel::Spawn() @@ -1280,7 +1289,7 @@ void CChangeLevel::ExecuteChangeLevel() edict_t *CChangeLevel::FindLandmark(const char *pLandmarkName) { - edict_t *pentLandmark = FIND_ENTITY_BY_STRING(NULL, "targetname", pLandmarkName); + edict_t *pentLandmark = FIND_ENTITY_BY_STRING(nullptr, "targetname", pLandmarkName); while (!FNullEnt(pentLandmark)) { // Found the landmark @@ -1291,7 +1300,7 @@ edict_t *CChangeLevel::FindLandmark(const char *pLandmarkName) } ALERT(at_error, "Can't find landmark %s\n", pLandmarkName); - return NULL; + return nullptr; } // CChangeLevel::Use - allows level transitions to be @@ -1301,6 +1310,9 @@ void CChangeLevel::UseChangeLevel(CBaseEntity *pActivator, CBaseEntity *pCaller, ChangeLevelNow(pActivator); } +char st_szNextMap[MAX_MAPNAME_LENGHT]; +char st_szNextSpot[MAX_MAPNAME_LENGHT]; + void CChangeLevel::ChangeLevelNow(CBaseEntity *pActivator) { edict_t *pentLandmark; @@ -1330,7 +1342,7 @@ void CChangeLevel::ChangeLevelNow(CBaseEntity *pActivator) // Create an entity to fire the changetarget if (m_changeTarget) { - CFireAndDie *pFireAndDie = GetClassPtr((CFireAndDie *)NULL); + CFireAndDie *pFireAndDie = GetClassPtr((CFireAndDie *)nullptr); if (pFireAndDie) { @@ -1350,7 +1362,7 @@ void CChangeLevel::ChangeLevelNow(CBaseEntity *pActivator) m_hActivator = pActivator; SUB_UseTargets(pActivator, USE_TOGGLE, 0); - // Init landmark to NULL + // Init landmark to nullptr st_szNextSpot[0] = '\0'; // look for a landmark entity @@ -1416,7 +1428,7 @@ int CChangeLevel::InTransitionVolume(CBaseEntity *pEntity, char *pVolumeName) // If you're following another entity, follow it through the transition (weapons follow the player) if (pEntity->pev->movetype == MOVETYPE_FOLLOW) { - if (pEntity->pev->aiment != NULL) + if (pEntity->pev->aiment) { pEntity = CBaseEntity::Instance(pEntity->pev->aiment); } @@ -1425,7 +1437,7 @@ int CChangeLevel::InTransitionVolume(CBaseEntity *pEntity, char *pVolumeName) // Unless we find a trigger_transition, everything is in the volume int inVolume = 1; - edict_t *pentVolume = FIND_ENTITY_BY_TARGETNAME(NULL, pVolumeName); + edict_t *pentVolume = FIND_ENTITY_BY_TARGETNAME(nullptr, pVolumeName); while (!FNullEnt(pentVolume)) { CBaseEntity *pVolume = CBaseEntity::Instance(pentVolume); @@ -1458,7 +1470,7 @@ int CChangeLevel::ChangeList(LEVELLIST *pLevelList, int maxList) int i, count = 0; // Find all of the possible level changes on this BSP - pentChangelevel = FIND_ENTITY_BY_STRING(NULL, "classname", "trigger_changelevel"); + pentChangelevel = FIND_ENTITY_BY_STRING(nullptr, "classname", "trigger_changelevel"); if (FNullEnt(pentChangelevel)) return 0; @@ -1466,8 +1478,7 @@ int CChangeLevel::ChangeList(LEVELLIST *pLevelList, int maxList) while (!FNullEnt(pentChangelevel)) { CChangeLevel *pTrigger = GetClassPtr((CChangeLevel *)VARS(pentChangelevel)); - - if (pTrigger != NULL) + if (pTrigger) { // Find the corresponding landmark pentLandmark = FindLandmark(pTrigger->m_szLandmarkName); @@ -1492,11 +1503,14 @@ int CChangeLevel::ChangeList(LEVELLIST *pLevelList, int maxList) { CSave saveHelper((SAVERESTOREDATA *)gpGlobals->pSaveData); - for (i = 0; i < count; ++i) + for (i = 0; i < count; i++) { + // We can only ever move 512 entities across a transition + const int MAX_ENTITY = 512; + int j, entityCount = 0; - CBaseEntity *pEntList[ MAX_ENTITY ]; - int entityFlags[ MAX_ENTITY ]; + CBaseEntity *pEntList[MAX_ENTITY]; + int entityFlags[MAX_ENTITY]; // Follow the linked list of entities in the PVS of the transition landmark edict_t *pent = FIND_ENTITY_IN_PVS(pLevelList[i].pentLandmark); @@ -1505,7 +1519,7 @@ int CChangeLevel::ChangeList(LEVELLIST *pLevelList, int maxList) while (!FNullEnt(pent)) { CBaseEntity *pEntity = CBaseEntity::Instance(pent); - if (pEntity != NULL) + if (pEntity) { int caps = pEntity->ObjectCaps(); @@ -1561,13 +1575,13 @@ NOXREF void NextLevel() CChangeLevel *pChange; // find a trigger_changelevel - pent = FIND_ENTITY_BY_CLASSNAME(NULL, "trigger_changelevel"); + pent = FIND_ENTITY_BY_CLASSNAME(nullptr, "trigger_changelevel"); // go back to start if no trigger_changelevel if (FNullEnt(pent)) { gpGlobals->mapname = ALLOC_STRING("start"); - pChange = GetClassPtr((CChangeLevel *)NULL); + pChange = GetClassPtr((CChangeLevel *)nullptr); Q_strcpy(pChange->m_szMapName, "start"); } else @@ -1703,7 +1717,7 @@ void CTriggerPush::Touch(CBaseEntity *pOther) void CBaseTrigger::TeleportTouch(CBaseEntity *pOther) { entvars_t *pevToucher = pOther->pev; - edict_t *pentTarget = NULL; + edict_t *pentTarget = nullptr; // Only teleport monsters or clients if (!(pevToucher->flags & (FL_CLIENT | FL_MONSTER))) @@ -1832,7 +1846,7 @@ void CBombTarget::BombTargetTouch(CBaseEntity *pOther) void CBombTarget::BombTargetUse(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) { - SUB_UseTargets(NULL, USE_TOGGLE, 0); + SUB_UseTargets(nullptr, USE_TOGGLE, 0); } LINK_ENTITY_TO_CLASS(func_hostage_rescue, CHostageRescue, CCSHostageRescue) @@ -2016,7 +2030,9 @@ void CTriggerEndSection::KeyValue(KeyValueData *pkvd) pkvd->fHandled = TRUE; } else + { CBaseTrigger::KeyValue(pkvd); + } } LINK_ENTITY_TO_CLASS(trigger_gravity, CTriggerGravity, CCSTriggerGravity) @@ -2047,7 +2063,9 @@ void CTriggerChangeTarget::KeyValue(KeyValueData *pkvd) pkvd->fHandled = TRUE; } else + { CBaseDelay::KeyValue(pkvd); + } } void CTriggerChangeTarget::Spawn() @@ -2057,17 +2075,15 @@ void CTriggerChangeTarget::Spawn() void CTriggerChangeTarget::Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) { - CBaseEntity *pTarget = UTIL_FindEntityByString(NULL, "targetname", STRING(pev->target)); - - if (pTarget != NULL) + CBaseEntity *pTarget = UTIL_FindEntityByString(nullptr, "targetname", STRING(pev->target)); + if (pTarget) { pTarget->pev->target = m_iszNewTarget; CBaseMonster *pMonster = pTarget->MyMonsterPointer(); - - if (pMonster != NULL) + if (pMonster) { - pMonster->m_pGoalEnt = NULL; + pMonster->m_pGoalEnt = nullptr; } } } @@ -2121,7 +2137,9 @@ void CTriggerCamera::KeyValue(KeyValueData *pkvd) pkvd->fHandled = TRUE; } else + { CBaseDelay::KeyValue(pkvd); + } } void CTriggerCamera::Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) @@ -2135,7 +2153,7 @@ void CTriggerCamera::Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE { m_flReturnTime = gpGlobals->time; - if (pActivator != NULL && pActivator->IsPlayer()) + if (pActivator && pActivator->IsPlayer()) { ((CBasePlayer *)pActivator)->ResetMaxSpeed(); } @@ -2148,7 +2166,7 @@ void CTriggerCamera::Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE pActivator = CBaseEntity::Instance(INDEXENT(1)); } - m_hPlayer = pActivator; + m_hPlayer = static_cast(pActivator); m_flReturnTime = gpGlobals->time + m_flWait; pev->speed = m_initialSpeed; @@ -2164,7 +2182,7 @@ void CTriggerCamera::Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE } // Nothing to look at! - if (m_hTarget == NULL) + if (!m_hTarget) { return; } @@ -2181,11 +2199,11 @@ void CTriggerCamera::Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE if (m_sPath) { - m_pentPath = Instance(FIND_ENTITY_BY_TARGETNAME(NULL, STRING(m_sPath))); + m_pentPath = Instance(FIND_ENTITY_BY_TARGETNAME(nullptr, STRING(m_sPath))); } else { - m_pentPath = NULL; + m_pentPath = nullptr; } m_flStopTime = gpGlobals->time; @@ -2225,16 +2243,17 @@ void CTriggerCamera::Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE void CTriggerCamera::FollowTarget() { - if (m_hPlayer == NULL) + if (!m_hPlayer) return; - if (m_hTarget == NULL || m_flReturnTime < gpGlobals->time) + if (!m_hTarget || m_flReturnTime < gpGlobals->time) { if (m_hPlayer->IsAlive()) { SET_VIEW(m_hPlayer->edict(), m_hPlayer->edict()); - ((CBasePlayer *)m_hPlayer)->EnableControl(TRUE); - ((CBasePlayer *)m_hPlayer)->ResetMaxSpeed(); + + m_hPlayer->EnableControl(TRUE); + m_hPlayer->ResetMaxSpeed(); } SUB_UseTargets(this, USE_TOGGLE, 0); @@ -2375,7 +2394,9 @@ void CClientFog::KeyValue(KeyValueData *pkvd) pkvd->fHandled = TRUE; } else + { CBaseEntity::KeyValue(pkvd); + } } void CClientFog::Spawn() diff --git a/regamedll/dlls/triggers.h b/regamedll/dlls/triggers.h index 7a390352..4ba2ae36 100644 --- a/regamedll/dlls/triggers.h +++ b/regamedll/dlls/triggers.h @@ -26,59 +26,10 @@ * */ -#ifndef TRIGGERS_H -#define TRIGGERS_H -#ifdef _WIN32 #pragma once -#endif #include "utlmap.h" -#define GRENADETYPE_SMOKE 1 -#define GRENADETYPE_FLASH 2 - -#define SPAWNFLAG_NOMESSAGE 1 -#define SPAWNFLAG_NOTOUCH 1 -#define SPAWNFLAG_DROIDONLY 4 - -#define MAX_ITEM_COUNTS 32 -#define MAX_ENTITY 512 // We can only ever move 512 entities across a transition - -// triggers -#define SF_TRIGGER_ALLOWMONSTERS 1 // monsters allowed to fire this trigger -#define SF_TRIGGER_NOCLIENTS 2 // players not allowed to fire this trigger -#define SF_TRIGGER_PUSHABLES 4 // only pushables can fire this trigger -#define SF_TRIGGER_NO_RESET 64 // it is not allowed to be resetting on a new round - -#define SF_TRIGGER_PUSH_ONCE 1 -#define SF_TRIGGER_PUSH_START_OFF 2 // spawnflag that makes trigger_push spawn turned OFF - -#define SF_TRIGGER_HURT_TARGETONCE 1 // Only fire hurt target once -#define SF_TRIGGER_HURT_START_OFF 2 // spawnflag that makes trigger_push spawn turned OFF -#define SF_TRIGGER_HURT_NO_CLIENTS 8 // spawnflag that makes trigger_push spawn turned OFF -#define SF_TRIGGER_HURT_CLIENTONLYFIRE 16 // trigger hurt will only fire its target if it is hurting a client -#define SF_TRIGGER_HURT_CLIENTONLYTOUCH 32 // only clients may touch this trigger. - -#define SF_AUTO_FIREONCE 0x0001 -#define SF_AUTO_NO_RESET 0x0002 - -#define SF_RELAY_FIREONCE 0x0001 -#define SF_ENDSECTION_USEONLY 0x0001 - -#define SF_MULTIMAN_CLONE 0x80000000 -#define SF_MULTIMAN_THREAD 0x00000001 - -#define SF_CHANGELEVEL_USEONLY 0x0002 -#define SF_CAMERA_PLAYER_POSITION 1 -#define SF_CAMERA_PLAYER_TARGET 2 -#define SF_CAMERA_PLAYER_TAKECONTROL 4 - -// Flags to indicate masking off various render parameters that are normally copied to the targets -#define SF_RENDER_MASKFX (1 << 0) -#define SF_RENDER_MASKAMT (1 << 1) -#define SF_RENDER_MASKMODE (1 << 2) -#define SF_RENDER_MASKCOLOR (1 << 3) - class CFrictionModifier: public CBaseEntity { public: @@ -95,8 +46,11 @@ public: float m_frictionFraction; }; +#define SF_AUTO_FIREONCE BIT(0) +#define SF_AUTO_NORESET BIT(1) + // This trigger will fire when the level spawns (or respawns if not fire once) -// It will check a global state before firing. It supports delay and killtargets +// It will check a global state before firing. It supports delay and killtargets class CAutoTrigger: public CBaseDelay { public: @@ -116,9 +70,11 @@ public: static TYPEDESCRIPTION IMPL(m_SaveData)[2]; int m_globalstate; - USE_TYPE triggerType; + USE_TYPE m_triggerType; }; +#define SF_RELAY_FIREONCE BIT(0) + class CTriggerRelay: public CBaseDelay { public: @@ -132,10 +88,15 @@ public: public: static TYPEDESCRIPTION IMPL(m_SaveData)[1]; - USE_TYPE triggerType; + USE_TYPE m_triggerType; }; -// The Multimanager Entity - when fired, will fire up to 16 targets +const int MAX_MM_TARGETS = 16; // maximum number of targets a single multi_manager entity may be assigned. + +#define SF_MULTIMAN_THREAD BIT(0) +#define SF_MULTIMAN_CLONE BIT(31) + +// This entity when fire, will fire up to 16 targets at specified times. // at specified times. // FLAG: THREAD (create clones when triggered) // FLAG: CLONE (this is a clone for a threaded execution) @@ -186,12 +147,17 @@ public: int m_cTargets; int m_index; float m_startTime; - int m_iTargetName[ MAX_MULTI_TARGETS ]; - float m_flTargetDelay[ MAX_MULTI_TARGETS ]; + int m_iTargetName[MAX_MM_TARGETS]; + float m_flTargetDelay[MAX_MM_TARGETS]; }; +// Flags to indicate masking off various render parameters that are normally copied to the targets +#define SF_RENDER_MASKFX BIT(0) +#define SF_RENDER_MASKAMT BIT(1) +#define SF_RENDER_MASKMODE BIT(2) +#define SF_RENDER_MASKCOLOR BIT(3) + // Render parameters trigger -// // This entity will copy its render parameters (renderfx, rendermode, rendercolor, renderamt) // to its targets when triggered. class CRenderFxManager: public CBaseEntity @@ -217,6 +183,11 @@ public: }; +#define SF_TRIGGER_ALLOWMONSTERS BIT(0) // monsters allowed to fire this trigger +#define SF_TRIGGER_NOCLIENTS BIT(1) // players not allowed to fire this trigger +#define SF_TRIGGER_PUSHABLES BIT(2) // only pushables can fire this trigger +#define SF_TRIGGER_NORESET BIT(6) // it is not allowed to be resetting on a new round + class CBaseTrigger: public CBaseToggle { public: @@ -235,8 +206,14 @@ public: void InitTrigger(); }; -// trigger_hurt - hurts anything that touches it. if the trigger has a targetname, firing it will toggle state -// int gfToggleState = 0; // used to determine when all radiation trigger hurts have called 'RadiationThink' +#define SF_TRIGGER_HURT_TARGETONCE BIT(0) // Only fire hurt target once +#define SF_TRIGGER_HURT_START_OFF BIT(1) // spawnflag that makes trigger_push spawn turned OFF +#define SF_TRIGGER_HURT_NO_CLIENTS BIT(3) // spawnflag that makes trigger_push spawn turned OFF +#define SF_TRIGGER_HURT_CLIENTONLYFIRE BIT(4) // trigger hurt will only fire its target if it is hurting a client +#define SF_TRIGGER_HURT_CLIENTONLYTOUCH BIT(5) // only clients may touch this trigger. + +// Hurts anything that touches it. +// If the trigger has a targetname, firing it will toggle state class CTriggerHurt: public CBaseTrigger { public: @@ -258,7 +235,7 @@ public: virtual void Touch(CBaseEntity *pOther); }; -// trigger_cdaudio - starts/stops cd audio tracks +// Starts/stops cd audio tracks class CTriggerCDAudio: public CBaseTrigger { public: @@ -283,8 +260,9 @@ public: void Play(edict_t *pEdict); }; -// QUAKED trigger_multiple (.5 .5 .5) ? notouch -// Variable sized repeatable trigger. Must be targeted at one or more entities. +#define SF_TRIGGER_MULTIPLE_NOTOUCH BIT(0) + +// Variable sized repeatable trigger. Must be targeted at one or more entities. // If "health" is set, the trigger must be killed to activate each time. // If "delay" is set, the trigger waits some time after activating before firing. // "wait" : Seconds between triggerings. (.2 default) @@ -303,12 +281,11 @@ public: virtual void Spawn(); }; -// QUAKED trigger_once (.5 .5 .5) ? notouch -// Variable sized trigger. Triggers once, then removes itself. You must set the key "target" to the name of another object in the level that has a matching -// "targetname". If "health" is set, the trigger must be killed to activate. +// Variable sized trigger. Triggers once, then removes itself. You must set the key "target" to the name of another object in the level that has a matching +// "targetname". If "health" is set, the trigger must be killed to activate. // If notouch is set, the trigger is only fired by other entities, not by touching. // if "killtarget" is set, any objects that have a matching "target" will be removed when the trigger is fired. -// if "angle" is set, the trigger will only fire when someone is facing the direction of the angle. Use "360" for an angle of 0. +// if "angle" is set, the trigger will only fire when someone is facing the direction of the angle. Use "360" for an angle of 0. // sounds // 1) secret // 2) beep beep @@ -324,10 +301,11 @@ public: #endif }; -// QUAKED trigger_counter (.5 .5 .5) ? nomessage +#define SF_TRIGGER_COUNTER_NOMESSAGE BIT(0) + // Acts as an intermediary for an action that takes multiple inputs. // If nomessage is not set, it will print "1 more.. " etc when triggered and -// "sequence complete" when finished. After the counter has been triggered "cTriggersLeft" +// "sequence complete" when finished. After the counter has been triggered "cTriggersLeft" // times (default 2), it will fire all of it's targets and remove itself. class CTriggerCounter: public CBaseTrigger { @@ -352,8 +330,10 @@ public: virtual void Think(); }; -// QUAKED trigger_changelevel (0.5 0.5 0.5) ? NO_INTERMISSION -// When the player touches this, he gets sent to the map listed in the "map" variable. Unless the NO_INTERMISSION flag is set, the view will go to the info_intermission spot and display stats. +#define SF_CHANGELEVEL_USEONLY BIT(1) + +// When the player touches this, he gets sent to the map listed in the "map" variable. +// Unless the NO_INTERMISSION flag is set, the view will go to the info_intermission spot and display stats. class CChangeLevel: public CBaseTrigger { public: @@ -377,8 +357,8 @@ public: public: static TYPEDESCRIPTION IMPL(m_SaveData)[4]; - char m_szMapName[cchMapNameMost]; // trigger_changelevel only: next map - char m_szLandmarkName[cchMapNameMost]; // trigger_changelevel only: landmark on next map + char m_szMapName[MAX_MAPNAME_LENGHT]; // next map + char m_szLandmarkName[MAX_MAPNAME_LENGHT]; // landmark on next map int m_changeTarget; float m_changeTargetDelay; }; @@ -391,6 +371,9 @@ public: virtual void KeyValue(KeyValueData *pkvd); }; +#define SF_TRIGGER_PUSH_ONCE BIT(0) +#define SF_TRIGGER_PUSH_START_OFF BIT(1) // spawnflag that makes trigger_push spawn turned OFF + class CTriggerPush: public CBaseTrigger { public: @@ -460,6 +443,8 @@ public: void EXPORT SaveTouch(CBaseEntity *pOther); }; +#define SF_ENDSECTION_USEONLY BIT(0) + class CTriggerEndSection: public CBaseTrigger { public: @@ -497,6 +482,10 @@ private: int m_iszNewTarget; }; +#define SF_CAMERA_PLAYER_POSITION BIT(0) +#define SF_CAMERA_PLAYER_TARGET BIT(1) +#define SF_CAMERA_PLAYER_TAKECONTROL BIT(2) + class CTriggerCamera: public CBaseDelay { public: @@ -513,8 +502,8 @@ public: static TYPEDESCRIPTION IMPL(m_SaveData)[13]; - EHANDLE m_hPlayer; - EHANDLE m_hTarget; + EntityHandle m_hPlayer; + EntityHandle m_hTarget; CBaseEntity *m_pentPath; int m_sPath; float m_flWait; @@ -549,5 +538,3 @@ public: void PlayCDTrack(edict_t *pClient, int iTrack); int BuildChangeList(LEVELLIST *pLevelList, int maxList); void NextLevel(); - -#endif // TRIGGERS_H diff --git a/regamedll/dlls/tutor.cpp b/regamedll/dlls/tutor.cpp index 493d611c..e17b18c4 100644 --- a/regamedll/dlls/tutor.cpp +++ b/regamedll/dlls/tutor.cpp @@ -8,25 +8,25 @@ bool s_tutorDisabledThisGame = false; float s_nextCvarCheckTime = 0.0f; -cvar_t cv_tutor_message_repeats = { "_tutor_message_repeats", "5", FCVAR_SERVER, 0.0f, NULL }; -cvar_t cv_tutor_debug_level = { "_tutor_debug_level", "0", FCVAR_SERVER, 0.0f, NULL }; -cvar_t cv_tutor_view_distance = { "_tutor_view_distance", "1000", FCVAR_SERVER, 0.0f, NULL }; -cvar_t cv_tutor_viewable_check_interval = { "_tutor_bomb_viewable_check_interval", "0.5", FCVAR_SERVER, 0.0f, NULL }; -cvar_t cv_tutor_look_distance = { "_tutor_look_distance", "200", FCVAR_SERVER, 0.0f, NULL }; -cvar_t cv_tutor_look_angle = { "_tutor_look_angle", "10", FCVAR_SERVER, 0.0f, NULL }; -cvar_t cv_tutor_examine_time = { "_tutor_examine_time", "0.5", FCVAR_SERVER, 0.0f, NULL }; -cvar_t cv_tutor_message_minimum_display_time = { "_tutor_message_minimum_display_time", "1", FCVAR_SERVER, 0.0f, NULL }; -cvar_t cv_tutor_message_character_display_time_coefficient = { "_tutor_message_character_display_time_coefficient", "0.07", FCVAR_SERVER, 0.0f, NULL }; -cvar_t cv_tutor_hint_interval_time = { "_tutor_hint_interval_time", "10.0", FCVAR_SERVER, 0.0f, NULL }; +cvar_t cv_tutor_message_repeats = { "_tutor_message_repeats", "5", FCVAR_SERVER, 0.0f, nullptr }; +cvar_t cv_tutor_debug_level = { "_tutor_debug_level", "0", FCVAR_SERVER, 0.0f, nullptr }; +cvar_t cv_tutor_view_distance = { "_tutor_view_distance", "1000", FCVAR_SERVER, 0.0f, nullptr }; +cvar_t cv_tutor_viewable_check_interval = { "_tutor_bomb_viewable_check_interval", "0.5", FCVAR_SERVER, 0.0f, nullptr }; +cvar_t cv_tutor_look_distance = { "_tutor_look_distance", "200", FCVAR_SERVER, 0.0f, nullptr }; +cvar_t cv_tutor_look_angle = { "_tutor_look_angle", "10", FCVAR_SERVER, 0.0f, nullptr }; +cvar_t cv_tutor_examine_time = { "_tutor_examine_time", "0.5", FCVAR_SERVER, 0.0f, nullptr }; +cvar_t cv_tutor_message_minimum_display_time = { "_tutor_message_minimum_display_time", "1", FCVAR_SERVER, 0.0f, nullptr }; +cvar_t cv_tutor_message_character_display_time_coefficient = { "_tutor_message_character_display_time_coefficient", "0.07", FCVAR_SERVER, 0.0f, nullptr }; +cvar_t cv_tutor_hint_interval_time = { "_tutor_hint_interval_time", "10.0", FCVAR_SERVER, 0.0f, nullptr }; #endif void InstallTutor(bool start) { - if (TheTutor != NULL) + if (TheTutor) { delete TheTutor; - TheTutor = NULL; + TheTutor = nullptr; } if (start) @@ -41,7 +41,7 @@ void InstallTutor(bool start) void Tutor_RegisterCVars() { #ifdef REGAMEDLL_FIXES - if (!g_bIsCzeroGame) + if (!AreRunningCZero()) return; #endif @@ -59,7 +59,7 @@ void Tutor_RegisterCVars() void MonitorTutorStatus() { - static cvar_t *tutor_enable = NULL; + static cvar_t *tutor_enable = nullptr; static bool tutor_enableCvarExists = true; bool shouldTutorBeOn = false; @@ -68,7 +68,7 @@ void MonitorTutorStatus() if (!tutor_enableCvarExists || s_nextCvarCheckTime > gpGlobals->time) return; - if (tutor_enable != NULL || (tutor_enable = CVAR_GET_POINTER("tutor_enable")) != NULL) + if (tutor_enable || (tutor_enable = CVAR_GET_POINTER("tutor_enable"))) { if (!s_tutorDisabledThisGame && tutor_enable->value > 0.0f) { @@ -78,46 +78,46 @@ void MonitorTutorStatus() else tutor_enableCvarExists = false; - for (int i = 1; i <= gpGlobals->maxClients; ++i) + for (int i = 1; i <= gpGlobals->maxClients; i++) { CBasePlayer *pPlayer = UTIL_PlayerByIndex(i); if (pPlayer && !pPlayer->IsBot()) - ++numHumans; + numHumans++; } if (shouldTutorBeOn) { if (numHumans <= 1) { - if (TheTutor == NULL) + if (!TheTutor) { - CBasePlayer *localPlayer = UTIL_GetLocalPlayer(); - - if (localPlayer != NULL) + CBasePlayer *pLocalPlayer = UTIL_GetLocalPlayer(); + if (pLocalPlayer) { - ClientPrint(localPlayer->pev, HUD_PRINTCENTER, "#CZero_Tutor_Turned_On"); + ClientPrint(pLocalPlayer->pev, HUD_PRINTCENTER, "#CZero_Tutor_Turned_On"); } TheTutor = new CCSTutor; } } else + { s_tutorDisabledThisGame = true; + } } else { - if (TheTutor != NULL) + if (TheTutor) { - CBasePlayer *localPlayer = UTIL_GetLocalPlayer(); - - if (localPlayer != NULL) + CBasePlayer *pLocalPlayer = UTIL_GetLocalPlayer(); + if (pLocalPlayer) { - ClientPrint(localPlayer->pev, HUD_PRINTCENTER, "#CZero_Tutor_Turned_Off"); + ClientPrint(pLocalPlayer->pev, HUD_PRINTCENTER, "#CZero_Tutor_Turned_Off"); } delete TheTutor; - TheTutor = NULL; + TheTutor = nullptr; } } diff --git a/regamedll/dlls/tutor.h b/regamedll/dlls/tutor.h index aa04aadd..e474555a 100644 --- a/regamedll/dlls/tutor.h +++ b/regamedll/dlls/tutor.h @@ -26,11 +26,7 @@ * */ -#ifndef TUTOR_H -#define TUTOR_H -#ifdef _WIN32 #pragma once -#endif extern cvar_t cv_tutor_message_repeats; extern cvar_t cv_tutor_debug_level; @@ -46,5 +42,3 @@ extern cvar_t cv_tutor_hint_interval_time; void InstallTutor(bool start); void Tutor_RegisterCVars(); void MonitorTutorStatus(); - -#endif // TUTOR_H diff --git a/regamedll/dlls/tutor_base_states.cpp b/regamedll/dlls/tutor_base_states.cpp index ca32d8ba..d5cd6c0e 100644 --- a/regamedll/dlls/tutor_base_states.cpp +++ b/regamedll/dlls/tutor_base_states.cpp @@ -2,7 +2,7 @@ CBaseTutorStateSystem::CBaseTutorStateSystem() { - ; + m_currentState = nullptr; } CBaseTutorStateSystem::~CBaseTutorStateSystem() @@ -10,19 +10,19 @@ CBaseTutorStateSystem::~CBaseTutorStateSystem() ; } -int CBaseTutorStateSystem::GetCurrentStateType() const +TutorStateType CBaseTutorStateSystem::GetCurrentStateType() const { if (m_currentState) { return m_currentState->GetType(); } - return 0; + return TUTORSTATE_UNDEFINED; } CBaseTutorState::CBaseTutorState() { - ; + m_type = TUTORSTATE_UNDEFINED; } CBaseTutorState::~CBaseTutorState() @@ -30,7 +30,7 @@ CBaseTutorState::~CBaseTutorState() ; } -int CBaseTutorState::GetType() const +TutorStateType CBaseTutorState::GetType() const { return m_type; } diff --git a/regamedll/dlls/tutor_base_states.h b/regamedll/dlls/tutor_base_states.h index ab56e6d0..c87a66d0 100644 --- a/regamedll/dlls/tutor_base_states.h +++ b/regamedll/dlls/tutor_base_states.h @@ -26,11 +26,32 @@ * */ -#ifndef TUTOR_BASE_STATES_H -#define TUTOR_BASE_STATES_H -#ifdef _WIN32 #pragma once -#endif + +enum TutorStateType +{ + TUTORSTATE_UNDEFINED = 0, + TUTORSTATE_LOOKING_FOR_HOSTAGE, + TUTORSTATE_ESCORTING_HOSTAGE, + //TUTORSTATE_LOOKING_FOR_LOST_HOSTAGE, + TUTORSTATE_FOLLOWING_HOSTAGE_ESCORT, + TUTORSTATE_MOVING_TO_BOMBSITE, + TUTORSTATE_LOOKING_FOR_BOMB_CARRIER, + TUTORSTATE_GUARDING_LOOSE_BOMB, + TUTORSTATE_DEFUSING_BOMB, + TUTORSTATE_GUARDING_HOSTAGE, + TUTORSTATE_MOVING_TO_INTERCEPT_ENEMY, + TUTORSTATE_LOOKING_FOR_HOSTAGE_ESCORT, + TUTORSTATE_ATTACKING_HOSTAGE_ESCORT, + TUTORSTATE_ESCORTING_BOMB_CARRIER, + TUTORSTATE_MOVING_TO_BOMB_SITE, + TUTORSTATE_PLANTING_BOMB, + TUTORSTATE_GUARDING_BOMB, + TUTORSTATE_LOOKING_FOR_LOOSE_BOMB, + TUTORSTATE_RUNNING_AWAY_FROM_TICKING_BOMB, + TUTORSTATE_BUYTIME, + TUTORSTATE_WAITING_FOR_START, +}; class CBaseTutorState { @@ -38,14 +59,14 @@ public: CBaseTutorState(); virtual ~CBaseTutorState(); - virtual int CheckForStateTransition(GameEventType event, CBaseEntity *entity, CBaseEntity *other) = 0; - virtual char *GetStateString() = 0; + virtual TutorStateType CheckForStateTransition(GameEventType event, CBaseEntity *entity, CBaseEntity *other) = 0; + virtual const char *GetStateString() = 0; public: - int GetType() const; + TutorStateType GetType() const; protected: - int m_type; + TutorStateType m_type; }; class CBaseTutorStateSystem @@ -55,14 +76,12 @@ public: virtual ~CBaseTutorStateSystem(); virtual bool UpdateState(GameEventType event, CBaseEntity *entity, CBaseEntity *other) = 0; - virtual char *GetCurrentStateString() = 0; - virtual CBaseTutorState *ConstructNewState(int stateType) = 0; + virtual const char *GetCurrentStateString() = 0; + virtual CBaseTutorState *ConstructNewState(TutorStateType stateType) = 0; public: - int GetCurrentStateType() const; + TutorStateType GetCurrentStateType() const; protected: CBaseTutorState *m_currentState; }; - -#endif // TUTOR_BASE_STATES_H diff --git a/regamedll/dlls/tutor_base_tutor.cpp b/regamedll/dlls/tutor_base_tutor.cpp index ad30345c..79ac04b6 100644 --- a/regamedll/dlls/tutor_base_tutor.cpp +++ b/regamedll/dlls/tutor_base_tutor.cpp @@ -1,6 +1,6 @@ #include "precompiled.h" -CBaseTutor *TheTutor = NULL; +CBaseTutor *TheTutor = nullptr; TutorMessageEvent::TutorMessageEvent(int mid, int duplicateID, float time, float lifetime, int priority) { @@ -10,9 +10,9 @@ TutorMessageEvent::TutorMessageEvent(int mid, int duplicateID, float time, float m_lifetime = lifetime; m_priority = priority; - m_paramList = NULL; + m_paramList = nullptr; m_numParameters = 0; - m_next = NULL; + m_next = nullptr; } TutorMessageEvent::~TutorMessageEvent() @@ -62,19 +62,19 @@ TutorMessageEvent *TutorMessageEvent::GetNext() void TutorMessageEvent::AddParameter(char *str) { - if (str == NULL) + if (str == nullptr) return; TutorMessageEventParam *param = new TutorMessageEventParam; - param->m_next = NULL; + param->m_next = nullptr; param->m_data = new char[Q_strlen(str) + 1]; if (param->m_data) { Q_strcpy(param->m_data, str); param->m_data[Q_strlen(str)] = '\0'; - ++m_numParameters; + m_numParameters++; if (m_paramList) { @@ -93,9 +93,10 @@ void TutorMessageEvent::AddParameter(char *str) char *TutorMessageEvent::GetNextParameter(char *buf, int buflen) { TutorMessageEventParam *param = m_paramList; - - if (param == NULL) - return NULL; + if (!param) + { + return nullptr; + } m_numParameters--; m_paramList = param->m_next; @@ -117,7 +118,7 @@ int TutorMessageEvent::GetNumParameters() CBaseTutor::CBaseTutor() { - m_eventList = NULL; + m_eventList = nullptr; m_deadAirStartTime = 0; m_roundStartTime = 0; } @@ -167,11 +168,11 @@ void CBaseTutor::DisplayMessageToPlayer(CBasePlayer *player, int id, const char numArgs = event->GetNumParameters(); definition = GetTutorMessageDefinition(event->GetID()); - MESSAGE_BEGIN(MSG_ONE, gmsgTutorText, NULL, player->pev); + MESSAGE_BEGIN(MSG_ONE, gmsgTutorText, nullptr, player->pev); WRITE_STRING(szMessage); WRITE_BYTE(numArgs); - for (int arg = 0; arg < numArgs; ++arg) + for (int arg = 0; arg < numArgs; arg++) { char *str = event->GetNextParameter(param, sizeof(param)); if (str) @@ -218,7 +219,7 @@ void CBaseTutor::DisplayMessageToPlayer(CBasePlayer *player, int id, const char NOXREF void CBaseTutor::DrawLineToEntity(CBasePlayer *player, int entindex, int id) { - MESSAGE_BEGIN(MSG_ONE, gmsgTutorLine, NULL, player->pev); + MESSAGE_BEGIN(MSG_ONE, gmsgTutorLine, nullptr, player->pev); WRITE_SHORT(entindex); WRITE_SHORT(id); MESSAGE_END(); @@ -226,27 +227,27 @@ NOXREF void CBaseTutor::DrawLineToEntity(CBasePlayer *player, int entindex, int void CBaseTutor::DisplayNewStateDescriptionToPlayer() { - CBasePlayer *localPlayer = UTIL_GetLocalPlayer(); - - if (!localPlayer) + CBasePlayer *pLocalPlayer = UTIL_GetLocalPlayer(); + if (!pLocalPlayer) + { return; + } - char *desc = m_stateSystem->GetCurrentStateString(); + auto desc = m_stateSystem->GetCurrentStateString(); if (!desc) { - MESSAGE_BEGIN(MSG_ONE, gmsgTutorState, NULL, localPlayer->pev); - WRITE_STRING(NULL); + MESSAGE_BEGIN(MSG_ONE, gmsgTutorState, nullptr, pLocalPlayer->pev); + WRITE_STRING(nullptr); MESSAGE_END(); } } void CBaseTutor::CloseCurrentWindow() { - CBasePlayer *localPlayer = (CBasePlayer *)UTIL_GetLocalPlayer(); - - if (localPlayer) + CBasePlayer *pLocalPlayer = UTIL_GetLocalPlayer(); + if (pLocalPlayer) { - MESSAGE_BEGIN(MSG_ONE, gmsgTutorClose, NULL, localPlayer->pev); + MESSAGE_BEGIN(MSG_ONE, gmsgTutorClose, nullptr, pLocalPlayer->pev); MESSAGE_END(); m_deadAirStartTime = gpGlobals->time; @@ -359,17 +360,7 @@ bool CBaseTutor::IsEntityInBombsite(CBaseEntity *bombsite, CBaseEntity *entity) if (!bombsite || !entity) return false; - if (entity->pev->origin.x <= bombsite->pev->absmax.x - && entity->pev->origin.y <= bombsite->pev->absmax.y - && entity->pev->origin.z <= bombsite->pev->absmax.z - && entity->pev->origin.x >= bombsite->pev->absmin.x - && entity->pev->origin.y >= bombsite->pev->absmin.y - && entity->pev->origin.z >= bombsite->pev->absmin.z) - { - return true; - } - - return false; + return bombsite->Intersects(entity); } bool CBaseTutor::DoMessagesHaveSameID(int id1, int id2) diff --git a/regamedll/dlls/tutor_base_tutor.h b/regamedll/dlls/tutor_base_tutor.h index f9d6f7b9..58321024 100644 --- a/regamedll/dlls/tutor_base_tutor.h +++ b/regamedll/dlls/tutor_base_tutor.h @@ -26,11 +26,7 @@ * */ -#ifndef TUTOR_BASE_TUTOR_H -#define TUTOR_BASE_TUTOR_H -#ifdef _WIN32 #pragma once -#endif class TutorMessageEvent { @@ -83,7 +79,7 @@ public: public: void StartFrame(float time); - void OnEvent(GameEventType event, CBaseEntity *entity = NULL, CBaseEntity *other = NULL); + void OnEvent(GameEventType event, CBaseEntity *entity = nullptr, CBaseEntity *other = nullptr); void ShotFired(Vector source, Vector target); void DisplayMessageToPlayer(CBasePlayer *player, int id, const char *szMessage, TutorMessageEvent *event); @@ -102,5 +98,3 @@ protected: }; extern CBaseTutor *TheTutor; - -#endif // TUTOR_BASE_TUTOR_H diff --git a/regamedll/dlls/tutor_cs_states.cpp b/regamedll/dlls/tutor_cs_states.cpp index 32364f08..4bb9cc73 100644 --- a/regamedll/dlls/tutor_cs_states.cpp +++ b/regamedll/dlls/tutor_cs_states.cpp @@ -5,28 +5,28 @@ */ #ifndef HOOK_GAMEDLL -char *const g_TutorStateStrings[20] = +const char *g_TutorStateStrings[] = { - "#Cstrike_TutorState_Undefined", - "#Cstrike_TutorState_Looking_For_Hostage", - "#Cstrike_TutorState_Escorting_Hostage", - "#Cstrike_TutorState_Following_Hostage_Escort", - "#Cstrike_TutorState_Moving_To_Bombsite", - "#Cstrike_TutorState_Looking_For_Bomb_Carrier", - "#Cstrike_TutorState_Guarding_Loose_Bomb", - "#Cstrike_TutorState_Defusing_Bomb", - "#Cstrike_TutorState_Guarding_Hostage", - "#Cstrike_TutorState_Moving_To_Intercept_Enemy", - "#Cstrike_TutorState_Looking_For_Hostage_Escort", - "#Cstrike_TutorState_Attacking_Hostage_Escort", - "#Cstrike_TutorState_Escorting_Bomb_Carrier", - "#Cstrike_TutorState_Moving_To_Bomb_Site", - "#Cstrike_TutorState_Planting_Bomb", - "#Cstrike_TutorState_Guarding_Bomb", - "#Cstrike_TutorState_Looking_For_Loose_Bomb", - "#Cstrike_TutorState_Running_Away_From_Ticking_Bomb", - "#Cstrike_TutorState_Buy_Time", - "#Cstrike_TutorState_Waiting_For_Start" + "#Cstrike_TutorState_Undefined", // TUTORSTATE_UNDEFINED + "#Cstrike_TutorState_Looking_For_Hostage", // TUTORSTATE_LOOKING_FOR_HOSTAGE + "#Cstrike_TutorState_Escorting_Hostage", // TUTORSTATE_ESCORTING_HOSTAGE + "#Cstrike_TutorState_Following_Hostage_Escort", // TUTORSTATE_FOLLOWING_HOSTAGE_ESCORT + "#Cstrike_TutorState_Moving_To_Bombsite", // TUTORSTATE_MOVING_TO_BOMBSITE, + "#Cstrike_TutorState_Looking_For_Bomb_Carrier", // TUTORSTATE_LOOKING_FOR_BOMB_CARRIER + "#Cstrike_TutorState_Guarding_Loose_Bomb", // TUTORSTATE_GUARDING_LOOSE_BOMB + "#Cstrike_TutorState_Defusing_Bomb", // TUTORSTATE_DEFUSING_BOMB + "#Cstrike_TutorState_Guarding_Hostage", // TUTORSTATE_GUARDING_HOSTAGE + "#Cstrike_TutorState_Moving_To_Intercept_Enemy", // TUTORSTATE_MOVING_TO_INTERCEPT_ENEMY + "#Cstrike_TutorState_Looking_For_Hostage_Escort", // TUTORSTATE_LOOKING_FOR_HOSTAGE_ESCORT + "#Cstrike_TutorState_Attacking_Hostage_Escort", // TUTORSTATE_ATTACKING_HOSTAGE_ESCORT + "#Cstrike_TutorState_Escorting_Bomb_Carrier", // TUTORSTATE_ESCORTING_BOMB_CARRIER + "#Cstrike_TutorState_Moving_To_Bomb_Site", // TUTORSTATE_MOVING_TO_BOMB_SITE + "#Cstrike_TutorState_Planting_Bomb", // TUTORSTATE_PLANTING_BOMB + "#Cstrike_TutorState_Guarding_Bomb", // TUTORSTATE_GUARDING_BOMB + "#Cstrike_TutorState_Looking_For_Loose_Bomb", // TUTORSTATE_LOOKING_FOR_LOOSE_BOMB + "#Cstrike_TutorState_Running_Away_From_Ticking_Bomb", // TUTORSTATE_RUNNING_AWAY_FROM_TICKING_BOMB + "#Cstrike_TutorState_Buy_Time", // TUTORSTATE_BUYTIME + "#Cstrike_TutorState_Waiting_For_Start" // TUTORSTATE_WAITING_FOR_START }; #endif @@ -47,15 +47,14 @@ CCSTutorStateSystem::~CCSTutorStateSystem() bool CCSTutorStateSystem::UpdateState(GameEventType event, CBaseEntity *entity, CBaseEntity *other) { - if (m_currentState == nullptr) + if (!m_currentState) { m_currentState = new CCSTutorUndefinedState; } if (m_currentState) { - TutorStateType nextStateType = static_cast(m_currentState->CheckForStateTransition(event, entity, other)); - + TutorStateType nextStateType = m_currentState->CheckForStateTransition(event, entity, other); if (nextStateType != TUTORSTATE_UNDEFINED) { delete m_currentState; @@ -67,31 +66,31 @@ bool CCSTutorStateSystem::UpdateState(GameEventType event, CBaseEntity *entity, return false; } -char *CCSTutorStateSystem::GetCurrentStateString() +const char *CCSTutorStateSystem::GetCurrentStateString() { if (m_currentState) { return m_currentState->GetStateString(); } - return NULL; + return nullptr; } -CBaseTutorState *CCSTutorStateSystem::ConstructNewState(int stateType) +CBaseTutorState *CCSTutorStateSystem::ConstructNewState(TutorStateType stateType) { switch (stateType) { - case TUTORSTATE_BUYTIME: return new CCSTutorBuyMenuState; + case TUTORSTATE_BUYTIME: return new CCSTutorBuyMenuState; case TUTORSTATE_WAITING_FOR_START: return new CCSTutorWaitingForStartState; - case TUTORSTATE_UNDEFINED: return new CCSTutorUndefinedState; + case TUTORSTATE_UNDEFINED: return new CCSTutorUndefinedState; } - return NULL; + return nullptr; } CCSTutorUndefinedState::CCSTutorUndefinedState() { - m_type = 0; + m_type = TUTORSTATE_UNDEFINED; } CCSTutorUndefinedState::~CCSTutorUndefinedState() @@ -99,41 +98,39 @@ CCSTutorUndefinedState::~CCSTutorUndefinedState() ; } -int CCSTutorUndefinedState::CheckForStateTransition(GameEventType event, CBaseEntity *entity, CBaseEntity *other) +TutorStateType CCSTutorUndefinedState::CheckForStateTransition(GameEventType event, CBaseEntity *entity, CBaseEntity *other) { if (event == EVENT_PLAYER_SPAWNED) { return HandlePlayerSpawned(entity, other); } - return 0; + return TUTORSTATE_UNDEFINED; } -int CCSTutorUndefinedState::HandlePlayerSpawned(CBaseEntity *entity, CBaseEntity *other) +TutorStateType CCSTutorUndefinedState::HandlePlayerSpawned(CBaseEntity *entity, CBaseEntity *other) { - CBasePlayer *localPlayer = UTIL_GetLocalPlayer(); - - if (localPlayer) + CBasePlayer *pLocalPlayer = UTIL_GetLocalPlayer(); + if (pLocalPlayer) { - CBasePlayer *player = static_cast(entity); - if (player && player->IsPlayer() && player == localPlayer) + CBasePlayer *pPlayer = static_cast(entity); + if (pPlayer && pPlayer->IsPlayer() && pPlayer == pLocalPlayer) { - // flags - return TUTOR_STATE_FLAG_1; + return TUTORSTATE_WAITING_FOR_START; } } - return 0; + return TUTORSTATE_UNDEFINED; } -char *CCSTutorUndefinedState::GetStateString() +const char *CCSTutorUndefinedState::GetStateString() { - return NULL; + return nullptr; } CCSTutorWaitingForStartState::CCSTutorWaitingForStartState() { - m_type = (TUTORMESSAGETYPE_ENEMY_DEATH | TUTORMESSAGETYPE_BUY); + m_type = TUTORSTATE_WAITING_FOR_START; } CCSTutorWaitingForStartState::~CCSTutorWaitingForStartState() @@ -141,7 +138,7 @@ CCSTutorWaitingForStartState::~CCSTutorWaitingForStartState() ; } -int CCSTutorWaitingForStartState::CheckForStateTransition(GameEventType event, CBaseEntity *entity, CBaseEntity *other) +TutorStateType CCSTutorWaitingForStartState::CheckForStateTransition(GameEventType event, CBaseEntity *entity, CBaseEntity *other) { switch (event) { @@ -151,39 +148,44 @@ int CCSTutorWaitingForStartState::CheckForStateTransition(GameEventType event, C return HandleBuyTimeStart(entity, other); } - return 0; + return TUTORSTATE_UNDEFINED; } -char *CCSTutorWaitingForStartState::GetStateString() +const char *CCSTutorWaitingForStartState::GetStateString() { +#ifdef REGAMEDLL_FIXES + if (m_type < TUTORSTATE_UNDEFINED || m_type > TUTORSTATE_WAITING_FOR_START) + { + return nullptr; + } +#endif + return g_TutorStateStrings[m_type]; } -int CCSTutorWaitingForStartState::HandlePlayerSpawned(CBaseEntity *entity, CBaseEntity *other) +TutorStateType CCSTutorWaitingForStartState::HandlePlayerSpawned(CBaseEntity *entity, CBaseEntity *other) { - CBasePlayer *localPlayer = UTIL_GetLocalPlayer(); - - if (localPlayer) + CBasePlayer *pLocalPlayer = UTIL_GetLocalPlayer(); + if (pLocalPlayer) { - CBasePlayer *player = static_cast(entity); - if (player && player->IsPlayer() && player == localPlayer) + CBasePlayer *pPlayer = static_cast(entity); + if (pPlayer && pPlayer->IsPlayer() && pPlayer == pLocalPlayer) { - // flags - return TUTOR_STATE_FLAG_1; + return TUTORSTATE_WAITING_FOR_START; } } - return 0; + return TUTORSTATE_UNDEFINED; } -int CCSTutorWaitingForStartState::HandleBuyTimeStart(CBaseEntity *entity, CBaseEntity *other) +TutorStateType CCSTutorWaitingForStartState::HandleBuyTimeStart(CBaseEntity *entity, CBaseEntity *other) { - return TUTOR_STATE_FLAG_2; + return TUTORSTATE_BUYTIME; } CCSTutorBuyMenuState::CCSTutorBuyMenuState() { - m_type = (TUTORMESSAGETYPE_DEFAULT | TUTORMESSAGETYPE_FRIEND_DEATH | TUTORMESSAGETYPE_BUY); + m_type = TUTORSTATE_BUYTIME; } CCSTutorBuyMenuState::~CCSTutorBuyMenuState() @@ -191,22 +193,29 @@ CCSTutorBuyMenuState::~CCSTutorBuyMenuState() ; } -int CCSTutorBuyMenuState::CheckForStateTransition(GameEventType event, CBaseEntity *entity, CBaseEntity *other) +TutorStateType CCSTutorBuyMenuState::CheckForStateTransition(GameEventType event, CBaseEntity *entity, CBaseEntity *other) { if (event == EVENT_ROUND_START) { return HandleRoundStart(entity, other); } - return 0; + return TUTORSTATE_UNDEFINED; } -char *CCSTutorBuyMenuState::GetStateString() +const char *CCSTutorBuyMenuState::GetStateString() { +#ifdef REGAMEDLL_FIXES + if (m_type < TUTORSTATE_UNDEFINED || m_type > TUTORSTATE_WAITING_FOR_START) + { + return nullptr; + } +#endif + return g_TutorStateStrings[m_type]; } -int CCSTutorBuyMenuState::HandleRoundStart(CBaseEntity *entity, CBaseEntity *other) +TutorStateType CCSTutorBuyMenuState::HandleRoundStart(CBaseEntity *entity, CBaseEntity *other) { - return TUTOR_STATE_FLAG_1; + return TUTORSTATE_WAITING_FOR_START; } diff --git a/regamedll/dlls/tutor_cs_states.h b/regamedll/dlls/tutor_cs_states.h index be03122e..679daaea 100644 --- a/regamedll/dlls/tutor_cs_states.h +++ b/regamedll/dlls/tutor_cs_states.h @@ -26,40 +26,7 @@ * */ -#ifndef TUTOR_CS_STATES_H -#define TUTOR_CS_STATES_H -#ifdef _WIN32 #pragma once -#endif - -// unknown flags -#define TUTOR_STATE_FLAG_1 0x00000014 -#define TUTOR_STATE_FLAG_2 0x00000013 - -enum TutorStateType -{ - TUTORSTATE_UNDEFINED = 0, - TUTORSTATE_LOOKING_FOR_HOSTAGE, - TUTORSTATE_ESCORTING_HOSTAGE, - TUTORSTATE_LOOKING_FOR_LOST_HOSTAGE, - TUTORSTATE_FOLLOWING_HOSTAGE_ESCORT, - TUTORSTATE_MOVING_TO_BOMBSITE, - TUTORSTATE_LOOKING_FOR_BOMB_CARRIER, - TUTORSTATE_GUARDING_LOOSE_BOMB, - TUTORSTATE_DEFUSING_BOMB, - TUTORSTATE_GUARDING_HOSTAGE, - TUTORSTATE_MOVING_TO_INTERCEPT_ENEMY, - TUTORSTATE_LOOKING_FOR_HOSTAGE_ESCORT, - TUTORSTATE_ATTACKING_HOSTAGE_ESCORT, - TUTORSTATE_ESCORTING_BOMB_CARRIER, - TUTORSTATE_MOVING_TO_BOMB_SITE, - TUTORSTATE_PLANTING_BOMB, - TUTORSTATE_GUARDING_BOMB, - TUTORSTATE_LOOKING_FOR_LOOSE_BOMB, - TUTORSTATE_RUNNING_AWAY_FROM_TICKING_BOMB, - TUTORSTATE_BUYTIME, - TUTORSTATE_WAITING_FOR_START, -}; class CCSTutorStateSystem: public CBaseTutorStateSystem { @@ -68,10 +35,10 @@ public: virtual ~CCSTutorStateSystem(); virtual bool UpdateState(GameEventType event, CBaseEntity *entity, CBaseEntity *other); - virtual char *GetCurrentStateString(); + virtual const char *GetCurrentStateString(); protected: - virtual CBaseTutorState *ConstructNewState(int stateType); + virtual CBaseTutorState *ConstructNewState(TutorStateType stateType); }; class CCSTutorUndefinedState: public CBaseTutorState @@ -80,11 +47,11 @@ public: CCSTutorUndefinedState(); virtual ~CCSTutorUndefinedState(); - virtual int CheckForStateTransition(GameEventType event, CBaseEntity *entity, CBaseEntity *other); - virtual char *GetStateString(); + virtual TutorStateType CheckForStateTransition(GameEventType event, CBaseEntity *entity, CBaseEntity *other); + virtual const char *GetStateString(); protected: - int HandlePlayerSpawned(CBaseEntity *entity, CBaseEntity *other); + TutorStateType HandlePlayerSpawned(CBaseEntity *entity, CBaseEntity *other); }; class CCSTutorWaitingForStartState: public CBaseTutorState @@ -93,12 +60,12 @@ public: CCSTutorWaitingForStartState(); virtual ~CCSTutorWaitingForStartState(); - virtual int CheckForStateTransition(GameEventType event, CBaseEntity *entity, CBaseEntity *other); - virtual char *GetStateString(); + virtual TutorStateType CheckForStateTransition(GameEventType event, CBaseEntity *entity, CBaseEntity *other); + virtual const char *GetStateString(); protected: - int HandlePlayerSpawned(CBaseEntity *entity, CBaseEntity *other); - int HandleBuyTimeStart(CBaseEntity *entity, CBaseEntity *other); + TutorStateType HandlePlayerSpawned(CBaseEntity *entity, CBaseEntity *other); + TutorStateType HandleBuyTimeStart(CBaseEntity *entity, CBaseEntity *other); }; class CCSTutorBuyMenuState: public CBaseTutorState @@ -107,11 +74,9 @@ public: CCSTutorBuyMenuState(); virtual ~CCSTutorBuyMenuState(); - virtual int CheckForStateTransition(GameEventType event, CBaseEntity *entity, CBaseEntity *other); - virtual char *GetStateString(); + virtual TutorStateType CheckForStateTransition(GameEventType event, CBaseEntity *entity, CBaseEntity *other); + virtual const char *GetStateString(); protected: - int HandleRoundStart(CBaseEntity *entity, CBaseEntity *other); + TutorStateType HandleRoundStart(CBaseEntity *entity, CBaseEntity *other); }; - -#endif // TUTOR_CS_STATES_H diff --git a/regamedll/dlls/tutor_cs_tutor.cpp b/regamedll/dlls/tutor_cs_tutor.cpp index 8e4b6263..a1d3b112 100644 --- a/regamedll/dlls/tutor_cs_tutor.cpp +++ b/regamedll/dlls/tutor_cs_tutor.cpp @@ -167,9 +167,9 @@ CCSTutor::CCSTutor() m_nextViewableCheckTime = 0; m_currentlyShownMessageID = TUTOR_NUM_MESSAGES; - m_currentMessageEvent = NULL; + m_currentMessageEvent = nullptr; m_messageTypeMask = TUTORMESSAGETYPE_ALL; - m_lastScenarioEvent = NULL; + m_lastScenarioEvent = nullptr; m_haveSpawned = false; m_lastHintShown = HINT_BEGIN; m_lastInGameHintShown = INGAME_HINT_BEGIN; @@ -184,19 +184,19 @@ CCSTutor::~CCSTutor() if (m_stateSystem) { delete m_stateSystem; - m_stateSystem = NULL; + m_stateSystem = nullptr; } if (m_currentMessageEvent) { DeleteEvent(m_currentMessageEvent); - m_currentMessageEvent = NULL; + m_currentMessageEvent = nullptr; } if (m_lastScenarioEvent) { DeleteEvent(m_lastScenarioEvent); - m_lastScenarioEvent = NULL; + m_lastScenarioEvent = nullptr; } ClearCurrentEvent(); @@ -209,8 +209,8 @@ void ParseMessageParameters(char *&messageData, TutorMessage *ret) while (true) { - messageData = MP_COM_Parse((char *)messageData); - token = MP_COM_GetToken(); + messageData = SharedParse((char *)messageData); + token = SharedGetToken(); if (!messageData || !Q_stricmp(token, "End")) { @@ -219,23 +219,23 @@ void ParseMessageParameters(char *&messageData, TutorMessage *ret) if (!Q_stricmp(token, "String")) { - messageData = MP_COM_Parse((char *)messageData); - ret->m_text = Q_strdup(MP_COM_GetToken()); + messageData = SharedParse((char *)messageData); + ret->m_text = Q_strdup(SharedGetToken()); } else if (!Q_stricmp(token, "Duration")) { - messageData = MP_COM_Parse((char *)messageData); - ret->m_duration = Q_atoi(MP_COM_GetToken()); + messageData = SharedParse((char *)messageData); + ret->m_duration = Q_atoi(SharedGetToken()); } else if (!Q_stricmp(token, "Priority")) { - messageData = MP_COM_Parse((char *)messageData); - ret->m_priority = Q_atoi(MP_COM_GetToken()); + messageData = SharedParse((char *)messageData); + ret->m_priority = Q_atoi(SharedGetToken()); } else if (!Q_stricmp(token, "KeepOld")) { - messageData = MP_COM_Parse((char *)messageData); - token = MP_COM_GetToken(); + messageData = SharedParse((char *)messageData); + token = SharedGetToken(); if (!Q_stricmp(token, "true")) { @@ -252,9 +252,9 @@ void ParseMessageParameters(char *&messageData, TutorMessage *ret) } else if (!Q_stricmp(token, "Class")) { - messageData = MP_COM_Parse((char *)messageData); + messageData = SharedParse((char *)messageData); - if (!Q_stricmp(MP_COM_GetToken(), "Examine")) + if (!Q_stricmp(SharedGetToken(), "Examine")) { ret->m_class = TUTORMESSAGECLASS_EXAMINE; } @@ -265,13 +265,13 @@ void ParseMessageParameters(char *&messageData, TutorMessage *ret) } else if (!Q_stricmp(token, "Decay")) { - messageData = MP_COM_Parse((char *)messageData); - ret->m_decay = Q_atoi(MP_COM_GetToken()); + messageData = SharedParse((char *)messageData); + ret->m_decay = Q_atoi(SharedGetToken()); } else if (!Q_stricmp(token, "Type")) { - messageData = MP_COM_Parse((char *)messageData); - token = MP_COM_GetToken(); + messageData = SharedParse((char *)messageData); + token = SharedGetToken(); if (!Q_stricmp(token, "FriendDeath")) { @@ -312,19 +312,19 @@ void ParseMessageParameters(char *&messageData, TutorMessage *ret) } else if (!Q_stricmp(token, "Lifetime")) { - messageData = MP_COM_Parse((char *)messageData); - ret->m_lifetime = Q_atoi(MP_COM_GetToken()); + messageData = SharedParse((char *)messageData); + ret->m_lifetime = Q_atoi(SharedGetToken()); } else if (!Q_stricmp(token, "DuplicateID")) { - messageData = MP_COM_Parse((char *)messageData); - ret->m_duplicateID = Q_atoi(MP_COM_GetToken()); + messageData = SharedParse((char *)messageData); + ret->m_duplicateID = Q_atoi(SharedGetToken()); } else if (!Q_stricmp(token, "Interrupt")) { - messageData = MP_COM_Parse((char *)messageData); + messageData = SharedParse((char *)messageData); - if (!Q_stricmp(MP_COM_GetToken(), "Now")) + if (!Q_stricmp(SharedGetToken(), "Now")) { ret->m_interruptFlag = TUTORMESSAGEINTERRUPTFLAG_NOW_DAMMIT; } @@ -335,40 +335,40 @@ void ParseMessageParameters(char *&messageData, TutorMessage *ret) } else if (!Q_stricmp(token, "MinDisplayTimeOverride")) { - messageData = MP_COM_Parse((char *)messageData); - ret->m_minDisplayTimeOverride = Q_atof(MP_COM_GetToken()); + messageData = SharedParse((char *)messageData); + ret->m_minDisplayTimeOverride = Q_atof(SharedGetToken()); } else if (!Q_stricmp(token, "MinRepeatInterval")) { - messageData = MP_COM_Parse((char *)messageData); - ret->m_minRepeatInterval = Q_atof(MP_COM_GetToken()); + messageData = SharedParse((char *)messageData); + ret->m_minRepeatInterval = Q_atof(SharedGetToken()); } } } TutorMessage *ConstructTutorMessage(char *&messageData, TutorMessage *defaults) { - TutorMessage *ret = new TutorMessage; + TutorMessage *msg = new TutorMessage; - ret->m_text = NULL; - ret->m_duplicateID = defaults->m_duplicateID; - ret->m_keepOld = defaults->m_keepOld; - ret->m_duration = defaults->m_duration; - ret->m_priority = defaults->m_priority; - ret->m_class = defaults->m_class; - ret->m_type = defaults->m_type; - ret->m_decay = defaults->m_decay; - ret->m_lifetime = defaults->m_lifetime; - ret->m_interruptFlag = defaults->m_interruptFlag; - ret->m_minDisplayTimeOverride = defaults->m_minDisplayTimeOverride; - ret->m_minRepeatInterval = defaults->m_minRepeatInterval; - ret->m_examineStartTime = -1.0f; - ret->m_timesShown = 0; - ret->m_lastCloseTime = 0; + msg->m_text = nullptr; + msg->m_duplicateID = defaults->m_duplicateID; + msg->m_keepOld = defaults->m_keepOld; + msg->m_duration = defaults->m_duration; + msg->m_priority = defaults->m_priority; + msg->m_class = defaults->m_class; + msg->m_type = defaults->m_type; + msg->m_decay = defaults->m_decay; + msg->m_lifetime = defaults->m_lifetime; + msg->m_interruptFlag = defaults->m_interruptFlag; + msg->m_minDisplayTimeOverride = defaults->m_minDisplayTimeOverride; + msg->m_minRepeatInterval = defaults->m_minRepeatInterval; + msg->m_examineStartTime = -1.0f; + msg->m_timesShown = 0; + msg->m_lastCloseTime = 0; - ParseMessageParameters(messageData, ret); + ParseMessageParameters(messageData, msg); - return ret; + return msg; } void ReadDefaultValues(char *&messageData, TutorMessage *defaults) @@ -388,7 +388,7 @@ void CCSTutor::ReadTutorMessageFile() if (!messageFile) { - if (g_bIsCzeroGame) + if (AreRunningCZero()) { CONSOLE_ECHO("Warning: Cannot access tutor message file tutordata.txt\n"); } @@ -410,19 +410,15 @@ void CCSTutor::ReadTutorMessageFile() while (true) { - messageData = MP_COM_Parse(messageData); - + messageData = SharedParse(messageData); if (!messageData) - { break; - } - - char *token = MP_COM_GetToken(); + char *token = SharedGetToken(); if (!Q_stricmp(token, "TutorMessage")) { - messageData = MP_COM_Parse(messageData); - token = MP_COM_GetToken(); + messageData = SharedParse(messageData); + token = SharedGetToken(); std::string identifier = token; TutorMessage *tm = ConstructTutorMessage(messageData, &defaultMessage); @@ -461,11 +457,11 @@ bool CCSTutor::HasCurrentWindowBeenActiveLongEnough(float time) bool CCSTutor::ShouldShowMessageEvent(TutorMessageEvent *event, float time) { - if (event == NULL) + if (!event) return false; TutorMessage *message = GetTutorMessageDefinition(event->GetID()); - if (message == NULL) + if (!message) return false; if (message->m_class == TUTORMESSAGECLASS_NORMAL) @@ -487,7 +483,7 @@ bool CCSTutor::ShouldShowMessageEvent(TutorMessageEvent *event, float time) return false; TutorMessage *current = GetTutorMessageDefinition(m_currentlyShownMessageID); - if (current == NULL || (DoMessagesHaveSameID(event->GetID(), m_currentlyShownMessageID) && current->m_keepOld != TUTORMESSAGEKEEPOLDTYPE_DONT_KEEP_OLD)) + if (!current || (DoMessagesHaveSameID(event->GetID(), m_currentlyShownMessageID) && current->m_keepOld != TUTORMESSAGEKEEPOLDTYPE_DONT_KEEP_OLD)) return false; if (message->m_priority > current->m_priority @@ -589,7 +585,7 @@ void CCSTutor::CheckForWindowClose(float time) return; TutorMessageEvent *event = GetTutorMessageUpdateEvent(); - if (event == NULL) + if (!event) { ClearCurrentEvent(); return; @@ -605,7 +601,7 @@ void CCSTutor::CheckForContentUpdate() return; TutorMessage *definition = GetTutorMessageDefinition(m_currentlyShownMessageID); - if (definition == NULL || definition->m_keepOld != TUTORMESSAGEKEEPOLDTYPE_UPDATE_CONTENT) + if (!definition || definition->m_keepOld != TUTORMESSAGEKEEPOLDTYPE_UPDATE_CONTENT) return; TutorMessageEvent *event = GetTutorMessageUpdateEvent(); @@ -641,21 +637,20 @@ void CCSTutor::ClearCurrentEvent(bool closeWindow, bool processDeathsForEvent) if (m_currentMessageEvent) { DeleteEvent(m_currentMessageEvent); - m_currentMessageEvent = NULL; + m_currentMessageEvent = nullptr; } } void CCSTutor::ProcessShownDeathsForEvent(TutorMessageEvent *event) { - if (event == NULL) + if (!event) return; - for (int i = 0; i < ARRAYSIZE(m_playerDeathInfo); ++i) + for (auto& info : m_playerDeathInfo) { - if (m_playerDeathInfo[i].m_event == event) - { - m_playerDeathInfo[i].m_hasBeenShown = true; - m_playerDeathInfo[i].m_event = NULL; + if (info.m_event == event) { + info.m_hasBeenShown = true; + info.m_event = nullptr; } } } @@ -663,9 +658,8 @@ void CCSTutor::ProcessShownDeathsForEvent(TutorMessageEvent *event) TutorMessageEvent *CCSTutor::GetTutorMessageUpdateEvent() { TutorMessage *definition = GetTutorMessageDefinition(m_currentlyShownMessageID); - - if (definition == NULL || definition->m_keepOld == TUTORMESSAGEKEEPOLDTYPE_DONT_KEEP_OLD) - return NULL; + if (!definition || definition->m_keepOld == TUTORMESSAGEKEEPOLDTYPE_DONT_KEEP_OLD) + return nullptr; for (TutorMessageEvent *event = m_eventList; event; event = event->GetNext()) { @@ -675,7 +669,7 @@ TutorMessageEvent *CCSTutor::GetTutorMessageUpdateEvent() } } - return NULL; + return nullptr; } bool CCSTutor::GetDuplicateMessagesFromEventList(TutorMessageEvent *&event1, TutorMessageEvent *&event2) @@ -712,8 +706,8 @@ void CCSTutor::CheckForInactiveEvents(float time) event = event->GetNext(); } - TutorMessageEvent *event1 = NULL; - TutorMessageEvent *event2 = NULL; + TutorMessageEvent *event1 = nullptr; + TutorMessageEvent *event2 = nullptr; if (GetDuplicateMessagesFromEventList(event1, event2)) { @@ -754,7 +748,7 @@ void CCSTutor::CancelEvent(TutorMessageID mid) if (m_lastScenarioEvent && m_lastScenarioEvent->GetID() == mid) { DeleteEvent(m_lastScenarioEvent); - m_lastScenarioEvent = NULL; + m_lastScenarioEvent = nullptr; } } @@ -767,24 +761,18 @@ NOXREF void CCSTutor::LookupHotKey(TutorMessageID mid, int paramNum, wchar_t *bu TutorMessageEvent *CCSTutor::CreateTutorMessageEvent(TutorMessageID mid, CBaseEntity *entity, CBaseEntity *other) { - CBasePlayer *localPlayer; - TutorMessage *message; - TutorMessageEvent *event; - char enemyList[2048]; char teammateList[2048]; - localPlayer = UTIL_GetLocalPlayer(); + CBasePlayer *pLocalPlayer = UTIL_GetLocalPlayer(); + if (!pLocalPlayer) + return nullptr; - if (localPlayer == NULL) - return NULL; + TutorMessage *message = GetTutorMessageDefinition(mid); + if (!message) + return nullptr; - message = GetTutorMessageDefinition(mid); - - if (message == NULL) - return NULL; - - event = new TutorMessageEvent + TutorMessageEvent *event = new TutorMessageEvent ( mid, message->m_duplicateID, @@ -793,116 +781,110 @@ TutorMessageEvent *CCSTutor::CreateTutorMessageEvent(TutorMessageID mid, CBaseEn message->m_priority ); - if (event) + switch (mid) { - switch (mid) + case YOU_KILLED_PLAYER_ONE_LEFT: + case YOU_KILLED_LAST_ENEMY: + case YOU_KILLED_PLAYER_HEADSHOT_ONE_LEFT: + case YOU_KILLED_LAST_ENEMY_HEADSHOT: + case ENEMY_KILLED_ONE_LEFT: + case LAST_ENEMY_KILLED: + { + switch (pLocalPlayer->m_iTeam) { - case YOU_KILLED_PLAYER_ONE_LEFT: - case YOU_KILLED_LAST_ENEMY: - case YOU_KILLED_PLAYER_HEADSHOT_ONE_LEFT: - case YOU_KILLED_LAST_ENEMY_HEADSHOT: - case ENEMY_KILLED_ONE_LEFT: - case LAST_ENEMY_KILLED: - { - switch (localPlayer->m_iTeam) - { - case CT: - ConstructRecentDeathsList(TERRORIST, enemyList, sizeof(enemyList), event); - event->AddParameter(enemyList); - break; - case TERRORIST: - ConstructRecentDeathsList(CT, teammateList, sizeof(teammateList), event); - event->AddParameter(teammateList); - break; - } - break; - } - case YOU_KILLED_PLAYER: - case YOU_KILLED_PLAYER_HEADSHOT: - case ENEMY_KILLED: - { - int numT; - int numCT; - - char numTStr[16]; - char numCTStr[16]; - - GetNumPlayersAliveOnTeams(numT, numCT); - - Q_snprintf(numTStr, sizeof(numTStr), "%i", numT); - Q_snprintf(numCTStr, sizeof(numCTStr), "%i", numCT); - - switch (localPlayer->m_iTeam) - { - case CT: - event->AddParameter(numCTStr); - ConstructRecentDeathsList(TERRORIST, enemyList, sizeof(enemyList), event); - event->AddParameter(enemyList); - break; - case TERRORIST: - event->AddParameter(numTStr); - ConstructRecentDeathsList(CT, teammateList, sizeof(teammateList), event); - event->AddParameter(teammateList); - break; - } - break; - } - case CAREER_TASK_DONE_MORE_LEFT: - { - char numLeftStr[16]; - int numtasks = 0; - - if (TheCareerTasks) - { - numtasks = TheCareerTasks->GetNumRemainingTasks(); - } - Q_sprintf(numLeftStr, "%d", numtasks); - event->AddParameter(numLeftStr); - break; - } - case YOU_KILLED_A_TEAMMATE: - case TEAMMATE_KILLED_ONE_LEFT: - case LAST_TEAMMATE_KILLED: - ConstructRecentDeathsList(localPlayer->m_iTeam, enemyList, sizeof(enemyList), event); + case CT: + ConstructRecentDeathsList(TERRORIST, enemyList, sizeof(enemyList), event); event->AddParameter(enemyList); break; - case TEAMMATE_KILLED: - { - int numT; - int numCT; - - char numTStr[16]; - char numCTStr[16]; - - GetNumPlayersAliveOnTeams(numT, numCT); - - if (localPlayer->IsAlive()) - { - switch (localPlayer->m_iTeam) - { - case CT: numCT--; break; - case TERRORIST: numT--; break; - } - } - - Q_snprintf(numTStr, sizeof(numTStr), "%i", numT); - Q_snprintf(numCTStr, sizeof(numCTStr), "%i", numCT); - - switch (localPlayer->m_iTeam) - { - case CT: - event->AddParameter(numCTStr); - break; - case TERRORIST: - event->AddParameter(numTStr); - break; - } - - ConstructRecentDeathsList(localPlayer->m_iTeam, teammateList, sizeof(teammateList), event); + case TERRORIST: + ConstructRecentDeathsList(CT, teammateList, sizeof(teammateList), event); event->AddParameter(teammateList); break; } + break; + } + case YOU_KILLED_PLAYER: + case YOU_KILLED_PLAYER_HEADSHOT: + case ENEMY_KILLED: + { + int numT, numCT; + char numTStr[16], numCTStr[16]; + + GetNumPlayersAliveOnTeams(numT, numCT); + + Q_snprintf(numTStr, sizeof(numTStr), "%i", numT); + Q_snprintf(numCTStr, sizeof(numCTStr), "%i", numCT); + + switch (pLocalPlayer->m_iTeam) + { + case CT: + event->AddParameter(numCTStr); + ConstructRecentDeathsList(TERRORIST, enemyList, sizeof(enemyList), event); + event->AddParameter(enemyList); + break; + case TERRORIST: + event->AddParameter(numTStr); + ConstructRecentDeathsList(CT, teammateList, sizeof(teammateList), event); + event->AddParameter(teammateList); + break; } + break; + } + case CAREER_TASK_DONE_MORE_LEFT: + { + char numLeftStr[16]; + int numtasks = 0; + + if (TheCareerTasks) + { + numtasks = TheCareerTasks->GetNumRemainingTasks(); + } + Q_sprintf(numLeftStr, "%d", numtasks); + event->AddParameter(numLeftStr); + break; + } + case YOU_KILLED_A_TEAMMATE: + case TEAMMATE_KILLED_ONE_LEFT: + case LAST_TEAMMATE_KILLED: + ConstructRecentDeathsList(pLocalPlayer->m_iTeam, enemyList, sizeof(enemyList), event); + event->AddParameter(enemyList); + break; + case TEAMMATE_KILLED: + { + int numT; + int numCT; + + char numTStr[16]; + char numCTStr[16]; + + GetNumPlayersAliveOnTeams(numT, numCT); + + if (pLocalPlayer->IsAlive()) + { + switch (pLocalPlayer->m_iTeam) + { + case CT: numCT--; break; + case TERRORIST: numT--; break; + } + } + + Q_snprintf(numTStr, sizeof(numTStr), "%i", numT); + Q_snprintf(numCTStr, sizeof(numCTStr), "%i", numCT); + + switch (pLocalPlayer->m_iTeam) + { + case CT: + event->AddParameter(numCTStr); + break; + case TERRORIST: + event->AddParameter(numTStr); + break; + } + + ConstructRecentDeathsList(pLocalPlayer->m_iTeam, teammateList, sizeof(teammateList), event); + event->AddParameter(teammateList); + break; + } } return event; @@ -928,7 +910,7 @@ void CCSTutor::CreateAndAddEventToList(TutorMessageID mid, CBaseEntity *entity, if (m_lastScenarioEvent) { DeleteEvent(m_lastScenarioEvent); - m_lastScenarioEvent = NULL; + m_lastScenarioEvent = nullptr; } m_lastScenarioEvent = CreateTutorMessageEvent(mid, entity, other); @@ -940,7 +922,7 @@ void CCSTutor::CreateAndAddEventToList(TutorMessageID mid, CBaseEntity *entity, void CCSTutor::DeleteEventFromEventList(TutorMessageEvent *event) { - if (event == NULL) + if (!event) return; TutorMessageEvent *temp = m_eventList; @@ -952,8 +934,7 @@ void CCSTutor::DeleteEventFromEventList(TutorMessageEvent *event) while (event != temp->GetNext()) { temp = temp->GetNext(); - - if (temp == NULL) + if (!temp) { return; } @@ -966,7 +947,9 @@ void CCSTutor::DeleteEventFromEventList(TutorMessageEvent *event) } } else + { m_eventList = m_eventList->GetNext(); + } } void CCSTutor::ClearEventList() @@ -982,10 +965,10 @@ void CCSTutor::ClearEventList() void CCSTutor::DeleteEvent(TutorMessageEvent *event) { - for (auto& playerDeathInfo : m_playerDeathInfo) + for (auto& info : m_playerDeathInfo) { - if (playerDeathInfo.m_event == event) { - playerDeathInfo.m_event = nullptr; + if (info.m_event == event) { + info.m_event = nullptr; } } @@ -1000,22 +983,20 @@ void CCSTutor::PurgeMessages() if (m_lastScenarioEvent) { DeleteEvent(m_lastScenarioEvent); - m_lastScenarioEvent = NULL; + m_lastScenarioEvent = nullptr; } } void CCSTutor::ComputeDisplayTimesForMessage() { TutorMessage *message = GetTutorMessageDefinition(m_currentlyShownMessageID); - float now = gpGlobals->time; - - if (message == NULL) + if (!message) { - m_currentlyShownMessageCloseTime = now; + m_currentlyShownMessageCloseTime = gpGlobals->time; return; } - m_currentlyShownMessageCloseTime = message->m_duration + now; + m_currentlyShownMessageCloseTime = message->m_duration + gpGlobals->time; m_currentlyShownMessageMinimumCloseTime = cv_tutor_message_minimum_display_time.value; int stringLength = GET_LOCALIZED_STRING_LENGTH(message->m_text); @@ -1031,7 +1012,7 @@ void CCSTutor::ComputeDisplayTimesForMessage() message->m_minDisplayTimeOverride = m_currentlyShownMessageMinimumCloseTime; } - m_currentlyShownMessageMinimumCloseTime = message->m_minDisplayTimeOverride + now; + m_currentlyShownMessageMinimumCloseTime = message->m_minDisplayTimeOverride + gpGlobals->time; if (m_currentlyShownMessageMinimumCloseTime > m_currentlyShownMessageCloseTime) { @@ -1060,7 +1041,7 @@ void CCSTutor::UpdateCurrentMessage(TutorMessageEvent *event) if (m_currentMessageEvent) { DeleteEvent(m_currentMessageEvent); - m_currentMessageEvent = NULL; + m_currentMessageEvent = nullptr; } m_currentlyShownMessageID = (TutorMessageID)event->GetID(); @@ -1069,15 +1050,15 @@ void CCSTutor::UpdateCurrentMessage(TutorMessageEvent *event) TutorMessage *definition = GetTutorMessageDefinition(event->GetID()); if (definition) { - CBasePlayer *localPlayer = UTIL_GetLocalPlayer(); - if (localPlayer) + CBasePlayer *pLocalPlayer = UTIL_GetLocalPlayer(); + if (pLocalPlayer) { m_currentlyShownMessageCloseTime = definition->m_duration + gpGlobals->time; if (definition->m_keepOld == TUTORMESSAGEKEEPOLDTYPE_UPDATE_CONTENT) { CloseCurrentWindow(); - DisplayMessageToPlayer(localPlayer, event->GetID(), definition->m_text, event); + DisplayMessageToPlayer(pLocalPlayer, event->GetID(), definition->m_text, event); } } } @@ -1086,7 +1067,6 @@ void CCSTutor::UpdateCurrentMessage(TutorMessageEvent *event) void CCSTutor::ShowTutorMessage(TutorMessageEvent *event) { TutorMessageID mid = static_cast(event->GetID()); - if (mid < 0 || mid >= TUTOR_NUM_MESSAGES) return; @@ -1103,11 +1083,10 @@ void CCSTutor::ShowTutorMessage(TutorMessageEvent *event) void CCSTutor::ConstructMessageAndDisplay() { - CBasePlayer *localPlayer = UTIL_GetLocalPlayer(); - if (localPlayer && !localPlayer->IsBot()) + CBasePlayer *pLocalPlayer = UTIL_GetLocalPlayer(); + if (pLocalPlayer && !pLocalPlayer->IsBot()) { TutorMessageID mid = static_cast(m_currentMessageEvent->GetID()); - if (mid < 0 || mid >= TUTOR_NUM_MESSAGES) return; @@ -1116,7 +1095,7 @@ void CCSTutor::ConstructMessageAndDisplay() { message->m_timesShown++; ComputeDisplayTimesForMessage(); - DisplayMessageToPlayer(localPlayer, mid, message->m_text, m_currentMessageEvent); + DisplayMessageToPlayer(pLocalPlayer, mid, message->m_text, m_currentMessageEvent); } } } @@ -1294,29 +1273,28 @@ void CCSTutor::CallEventHandler(GameEventType event, CBaseEntity *entity, CBaseE void CCSTutor::HandleWeaponFired(CBaseEntity *entity, CBaseEntity *other) { - CBasePlayer *localPlayer = UTIL_GetLocalPlayer(); - if (localPlayer && localPlayer->IsAlive()) + CBasePlayer *pLocalPlayer = UTIL_GetLocalPlayer(); + if (!pLocalPlayer || !pLocalPlayer->IsAlive()) + return; + + CBasePlayer *pPlayer = static_cast(entity); + if (pPlayer && pPlayer == pLocalPlayer) { - CBasePlayer *player = static_cast(entity); - if (player && player == localPlayer) - { - CheckForNeedToReload(); - } + CheckForNeedToReload(); } } void CCSTutor::HandleWeaponFiredOnEmpty(CBaseEntity *entity, CBaseEntity *other) { - CBasePlayer *localPlayer = UTIL_GetLocalPlayer(); - - if (localPlayer == NULL) + CBasePlayer *pLocalPlayer = UTIL_GetLocalPlayer(); + if (!pLocalPlayer) return; - CBasePlayer *player = static_cast(entity); - if (player && player->IsPlayer() && player == localPlayer) + CBasePlayer *pPlayer = static_cast(entity); + if (pPlayer && pPlayer->IsPlayer() && pPlayer == pLocalPlayer) { - CBasePlayerWeapon *currentWeapon = static_cast(player->m_pActiveItem); - if (currentWeapon && player->m_rgAmmo[currentWeapon->m_iPrimaryAmmoType] <= 0) + CBasePlayerWeapon *pCurrentWeapon = static_cast(pPlayer->m_pActiveItem); + if (pCurrentWeapon && pPlayer->m_rgAmmo[pCurrentWeapon->m_iPrimaryAmmoType] <= 0) { TutorMessage *message = GetTutorMessageDefinition(YOU_ARE_OUT_OF_AMMO); if (message) @@ -1331,8 +1309,8 @@ void CCSTutor::HandleWeaponFiredOnEmpty(CBaseEntity *entity, CBaseEntity *other) void CCSTutor::HandleWeaponReloaded(CBaseEntity *entity, CBaseEntity *other) { - CBasePlayer *player = static_cast(entity); - if (player && player->IsPlayer() && player == UTIL_GetLocalPlayer()) + CBasePlayer *pPlayer = static_cast(entity); + if (pPlayer && pPlayer->IsPlayer() && pPlayer == UTIL_GetLocalPlayer()) { CancelEvent(YOU_SHOULD_RELOAD); } @@ -1340,23 +1318,26 @@ void CCSTutor::HandleWeaponReloaded(CBaseEntity *entity, CBaseEntity *other) void CCSTutor::HandlePlayerDied(CBaseEntity *entity, CBaseEntity *other) { - CBasePlayer *localPlayer = UTIL_GetLocalPlayer(); - - if (localPlayer == NULL) + CBasePlayer *pLocalPlayer = UTIL_GetLocalPlayer(); + if (!pLocalPlayer) return; - CBasePlayer *victim = static_cast(entity); - CBasePlayer *attacker = static_cast(other); + CBasePlayer *pVictim = static_cast(entity); + CBasePlayer *pAttacker = static_cast(other); - if (victim && !victim->IsPlayer()) - victim = NULL; - - if (attacker && !attacker->IsPlayer()) - attacker = NULL; - - if (victim == localPlayer && !attacker) + if (pVictim && !pVictim->IsPlayer()) { - if (localPlayer->m_bKilledByBomb) + pVictim = nullptr; + } + + if (pAttacker && !pAttacker->IsPlayer()) + { + pAttacker = nullptr; + } + + if (pVictim == pLocalPlayer && !pAttacker) + { + if (pLocalPlayer->m_bKilledByBomb) { CreateAndAddEventToList(YOU_DIED, entity, other); } @@ -1366,10 +1347,10 @@ void CCSTutor::HandlePlayerDied(CBaseEntity *entity, CBaseEntity *other) } } - if (!victim || !attacker) + if (!pVictim || !pAttacker) return; - if (victim == attacker && victim == localPlayer) + if (pVictim == pAttacker && pVictim == pLocalPlayer) { CreateAndAddEventToList(YOU_DIED, entity, other); return; @@ -1378,148 +1359,25 @@ void CCSTutor::HandlePlayerDied(CBaseEntity *entity, CBaseEntity *other) int numT, numCT; GetNumPlayersAliveOnTeams(numT, numCT); - if (attacker == localPlayer) + if (pAttacker == pLocalPlayer) { - if (victim->m_iTeam == attacker->m_iTeam) + if (pVictim->m_iTeam == pAttacker->m_iTeam) { CreateAndAddEventToList(YOU_KILLED_A_TEAMMATE, entity, other); return; } - if (victim->m_bHeadshotKilled) + if (pVictim->m_bHeadshotKilled) { - switch (attacker->m_iTeam) + switch (pAttacker->m_iTeam) { - case CT: - { - switch (numT) - { - case 0: CreateAndAddEventToList(YOU_KILLED_LAST_ENEMY_HEADSHOT, entity, other); break; - case 1: CreateAndAddEventToList(YOU_KILLED_PLAYER_HEADSHOT_ONE_LEFT, entity, other); break; - default: CreateAndAddEventToList(YOU_KILLED_PLAYER_HEADSHOT, entity, other); break; - } - break; - } - case TERRORIST: - { - switch (numCT) - { - case 0: CreateAndAddEventToList(YOU_KILLED_LAST_ENEMY_HEADSHOT, entity, other); break; - case 1: CreateAndAddEventToList(YOU_KILLED_PLAYER_HEADSHOT_ONE_LEFT, entity, other); break; - default: CreateAndAddEventToList(YOU_KILLED_PLAYER_HEADSHOT, entity, other); break; - } - break; - } - } - } - else - { - switch (attacker->m_iTeam) - { - case CT: - { - switch (numT) - { - case 0: CreateAndAddEventToList(YOU_KILLED_LAST_ENEMY, entity, other); break; - case 1: CreateAndAddEventToList(YOU_KILLED_PLAYER_ONE_LEFT, entity, other); break; - default: CreateAndAddEventToList(YOU_KILLED_PLAYER, entity, other); break; - } - break; - } - case TERRORIST: - { - switch (numCT) - { - case 0: CreateAndAddEventToList(YOU_KILLED_LAST_ENEMY, entity, other); break; - case 1: CreateAndAddEventToList(YOU_KILLED_PLAYER_ONE_LEFT, entity, other); break; - default: CreateAndAddEventToList(YOU_KILLED_PLAYER, entity, other); break; - } - break; - } - } - } - } - else if (victim == localPlayer) - { - CreateAndAddEventToList(victim->m_bHeadshotKilled ? YOU_DIED_HEADSHOT : YOU_DIED, entity, other); - } - else if (victim->m_iTeam == localPlayer->m_iTeam) - { - switch (victim->m_iTeam) - { - case CT: - { - if (localPlayer->IsAlive()) - { - if (numCT == 1) - { - CreateAndAddEventToList(LAST_TEAMMATE_KILLED, entity, other); - } - else if (numCT == 2) - { - CreateAndAddEventToList(TEAMMATE_KILLED_ONE_LEFT, entity, other); - } - else - { - CreateAndAddEventToList(TEAMMATE_KILLED, entity, other); - } - } - else - { - if (numCT == 1) - { - CreateAndAddEventToList(TEAMMATE_KILLED_ONE_LEFT, entity, other); - } - else if (numCT > 1) - { - CreateAndAddEventToList(TEAMMATE_KILLED, entity, other); - } - } - break; - } - case TERRORIST: - { - if (localPlayer->IsAlive()) - { - if (numT == 1) - { - CreateAndAddEventToList(LAST_TEAMMATE_KILLED, entity, other); - } - else if (numT == 2) - { - CreateAndAddEventToList(TEAMMATE_KILLED_ONE_LEFT, entity, other); - } - else - { - CreateAndAddEventToList(TEAMMATE_KILLED, entity, other); - } - } - else - { - if (numT == 1) - { - CreateAndAddEventToList(TEAMMATE_KILLED_ONE_LEFT, entity, other); - } - else if (numT > 1) - { - CreateAndAddEventToList(TEAMMATE_KILLED, entity, other); - } - } - break; - } - } - } - else - { - switch (localPlayer->m_iTeam) - { case CT: { switch (numT) { - case 0: CreateAndAddEventToList(LAST_ENEMY_KILLED, entity, other); break; - case 1: CreateAndAddEventToList(ENEMY_KILLED_ONE_LEFT, entity, other); break; - default: CreateAndAddEventToList(ENEMY_KILLED, entity, other); break; + case 0: CreateAndAddEventToList(YOU_KILLED_LAST_ENEMY_HEADSHOT, entity, other); break; + case 1: CreateAndAddEventToList(YOU_KILLED_PLAYER_HEADSHOT_ONE_LEFT, entity, other); break; + default: CreateAndAddEventToList(YOU_KILLED_PLAYER_HEADSHOT, entity, other); break; } break; } @@ -1527,41 +1385,163 @@ void CCSTutor::HandlePlayerDied(CBaseEntity *entity, CBaseEntity *other) { switch (numCT) { - case 0: CreateAndAddEventToList(LAST_ENEMY_KILLED, entity, other); break; - case 1: CreateAndAddEventToList(ENEMY_KILLED_ONE_LEFT, entity, other); break; - default: CreateAndAddEventToList(ENEMY_KILLED, entity, other); break; + case 0: CreateAndAddEventToList(YOU_KILLED_LAST_ENEMY_HEADSHOT, entity, other); break; + case 1: CreateAndAddEventToList(YOU_KILLED_PLAYER_HEADSHOT_ONE_LEFT, entity, other); break; + default: CreateAndAddEventToList(YOU_KILLED_PLAYER_HEADSHOT, entity, other); break; } break; } + } + } + else + { + switch (pAttacker->m_iTeam) + { + case CT: + { + switch (numT) + { + case 0: CreateAndAddEventToList(YOU_KILLED_LAST_ENEMY, entity, other); break; + case 1: CreateAndAddEventToList(YOU_KILLED_PLAYER_ONE_LEFT, entity, other); break; + default: CreateAndAddEventToList(YOU_KILLED_PLAYER, entity, other); break; + } + break; + } + case TERRORIST: + { + switch (numCT) + { + case 0: CreateAndAddEventToList(YOU_KILLED_LAST_ENEMY, entity, other); break; + case 1: CreateAndAddEventToList(YOU_KILLED_PLAYER_ONE_LEFT, entity, other); break; + default: CreateAndAddEventToList(YOU_KILLED_PLAYER, entity, other); break; + } + break; + } + } + } + } + else if (pVictim == pLocalPlayer) + { + CreateAndAddEventToList(pVictim->m_bHeadshotKilled ? YOU_DIED_HEADSHOT : YOU_DIED, entity, other); + } + else if (pVictim->m_iTeam == pLocalPlayer->m_iTeam) + { + switch (pVictim->m_iTeam) + { + case CT: + { + if (pLocalPlayer->IsAlive()) + { + if (numCT == 1) + { + CreateAndAddEventToList(LAST_TEAMMATE_KILLED, entity, other); + } + else if (numCT == 2) + { + CreateAndAddEventToList(TEAMMATE_KILLED_ONE_LEFT, entity, other); + } + else + { + CreateAndAddEventToList(TEAMMATE_KILLED, entity, other); + } + } + else + { + if (numCT == 1) + { + CreateAndAddEventToList(TEAMMATE_KILLED_ONE_LEFT, entity, other); + } + else if (numCT > 1) + { + CreateAndAddEventToList(TEAMMATE_KILLED, entity, other); + } + } + break; + } + case TERRORIST: + { + if (pLocalPlayer->IsAlive()) + { + if (numT == 1) + { + CreateAndAddEventToList(LAST_TEAMMATE_KILLED, entity, other); + } + else if (numT == 2) + { + CreateAndAddEventToList(TEAMMATE_KILLED_ONE_LEFT, entity, other); + } + else + { + CreateAndAddEventToList(TEAMMATE_KILLED, entity, other); + } + } + else + { + if (numT == 1) + { + CreateAndAddEventToList(TEAMMATE_KILLED_ONE_LEFT, entity, other); + } + else if (numT > 1) + { + CreateAndAddEventToList(TEAMMATE_KILLED, entity, other); + } + } + break; + } + } + } + else + { + switch (pLocalPlayer->m_iTeam) + { + case CT: + { + switch (numT) + { + case 0: CreateAndAddEventToList(LAST_ENEMY_KILLED, entity, other); break; + case 1: CreateAndAddEventToList(ENEMY_KILLED_ONE_LEFT, entity, other); break; + default: CreateAndAddEventToList(ENEMY_KILLED, entity, other); break; + } + break; + } + case TERRORIST: + { + switch (numCT) + { + case 0: CreateAndAddEventToList(LAST_ENEMY_KILLED, entity, other); break; + case 1: CreateAndAddEventToList(ENEMY_KILLED_ONE_LEFT, entity, other); break; + default: CreateAndAddEventToList(ENEMY_KILLED, entity, other); break; + } + break; + } } } } void CCSTutor::HandlePlayerTookDamage(CBaseEntity *entity, CBaseEntity *other) { - CBasePlayer *localPlayer = UTIL_GetLocalPlayer(); - - if (localPlayer == NULL) + CBasePlayer *pLocalPlayer = UTIL_GetLocalPlayer(); + if (!pLocalPlayer) return; - CBasePlayer *victim = static_cast(entity); - CBasePlayer *attacker = static_cast(other); + CBasePlayer *pVictim = static_cast(entity); + CBasePlayer *pAttacker = static_cast(other); - if (victim && !victim->IsPlayer()) + if (pVictim && !pVictim->IsPlayer()) { - victim = NULL; + pVictim = nullptr; } - if (attacker && !attacker->IsPlayer()) + if (pAttacker && !pAttacker->IsPlayer()) { - attacker = NULL; + pAttacker = nullptr; } - if (victim && victim == localPlayer) + if (pVictim && pVictim == pLocalPlayer) { CreateAndAddEventToList(YOU_WERE_JUST_HURT); } - else if (attacker && victim && attacker == localPlayer && victim->m_iTeam == localPlayer->m_iTeam) + else if (pAttacker && pVictim && pAttacker == pLocalPlayer && pVictim->m_iTeam == pLocalPlayer->m_iTeam) { CreateAndAddEventToList(YOU_ATTACKED_TEAMMATE); } @@ -1569,13 +1549,12 @@ void CCSTutor::HandlePlayerTookDamage(CBaseEntity *entity, CBaseEntity *other) void CCSTutor::HandlePlayerBlindedByFlashbang(CBaseEntity *entity, CBaseEntity *other) { - CBasePlayer *localPlayer = UTIL_GetLocalPlayer(); - - if (localPlayer == NULL) + CBasePlayer *pLocalPlayer = UTIL_GetLocalPlayer(); + if (!pLocalPlayer) return; - CBasePlayer *player = static_cast(entity); - if (player && player->IsPlayer() && player == localPlayer) + CBasePlayer *pPlayer = static_cast(entity); + if (pPlayer && pPlayer->IsPlayer() && pPlayer == pLocalPlayer) { CreateAndAddEventToList(YOU_ARE_BLIND_FROM_FLASHBANG); } @@ -1583,27 +1562,25 @@ void CCSTutor::HandlePlayerBlindedByFlashbang(CBaseEntity *entity, CBaseEntity * void CCSTutor::HandlePlayerSpawned(CBaseEntity *entity, CBaseEntity *other) { - CBasePlayer *player = static_cast(entity); + CBasePlayer *pPlayer = static_cast(entity); + if (!pPlayer || !pPlayer->IsPlayer() || pPlayer != UTIL_GetLocalPlayer()) + return; - if (player->IsPlayer() && player == UTIL_GetLocalPlayer()) - { - m_haveSpawned = true; - m_lastInGameHintShown = INGAME_HINT_BEGIN; - CreateAndAddEventToList(YOU_SPAWNED, entity, other); - } + m_haveSpawned = true; + m_lastInGameHintShown = INGAME_HINT_BEGIN; + CreateAndAddEventToList(YOU_SPAWNED, entity, other); } NOXREF void CCSTutor::HandleClientCorpseSpawned(CBaseEntity *entity, CBaseEntity *other) { - CBasePlayer *player = static_cast(entity); - - if (player == NULL || !player->IsPlayer()) + CBasePlayer *pPlayer = static_cast(entity); + if (!pPlayer || !pPlayer->IsPlayer()) return; ClientCorpseStruct *corpse = new ClientCorpseStruct; - corpse->m_position = player->pev->origin; - corpse->m_team = player->m_iTeam; + corpse->m_position = pPlayer->pev->origin; + corpse->m_team = pPlayer->m_iTeam; m_clientCorpseList.push_back(corpse); } @@ -1641,18 +1618,17 @@ void CCSTutor::HandlePlayerLeftBuyZone(CBaseEntity *entity, CBaseEntity *other) { m_lastScenarioEvent->SetActivationTime(gpGlobals->time); AddToEventList(m_lastScenarioEvent); - m_lastScenarioEvent = NULL; + m_lastScenarioEvent = nullptr; } } void CCSTutor::HandleBombPlanted(CBaseEntity *entity, CBaseEntity *other) { - CBasePlayer *player = UTIL_GetLocalPlayer(); - - if (player == NULL) + CBasePlayer *pLocalPlayer = UTIL_GetLocalPlayer(); + if (!pLocalPlayer) return; - if (player->IsAlive() && player->m_iTeam == CT) + if (pLocalPlayer->IsAlive() && pLocalPlayer->m_iTeam == CT) { CreateAndAddEventToList(BOMB_PLANTED_CT, entity, other); } @@ -1664,36 +1640,33 @@ void CCSTutor::HandleBombPlanted(CBaseEntity *entity, CBaseEntity *other) void CCSTutor::HandleBombDefused(CBaseEntity *entity, CBaseEntity *other) { - CBasePlayer *localPlayer = UTIL_GetLocalPlayer(); - - if (localPlayer == NULL) + CBasePlayer *pLocalPlayer = UTIL_GetLocalPlayer(); + if (!pLocalPlayer) return; - CBasePlayer *defuser = static_cast(entity); - if (defuser && defuser->IsPlayer() && defuser == localPlayer) + CBasePlayer *pDefuser = static_cast(entity); + if (pDefuser && pDefuser->IsPlayer() && pDefuser == pLocalPlayer) { CreateAndAddEventToList(YOU_DEFUSED_BOMB); + return; } - else + + switch (pLocalPlayer->m_iTeam) { - switch (localPlayer->m_iTeam) - { - case CT: CreateAndAddEventToList(BOMB_DEFUSED_CT); break; - case TERRORIST: CreateAndAddEventToList(BOMB_DEFUSED_T); break; - default: CreateAndAddEventToList(ROUND_OVER); break; - } + case CT: CreateAndAddEventToList(BOMB_DEFUSED_CT); break; + case TERRORIST: CreateAndAddEventToList(BOMB_DEFUSED_T); break; + default: CreateAndAddEventToList(ROUND_OVER); break; } } void CCSTutor::HandleBombDefusing(CBaseEntity *entity, CBaseEntity *other) { - CBasePlayer *localPlayer = UTIL_GetLocalPlayer(); - - if (localPlayer == NULL) + CBasePlayer *pLocalPlayer = UTIL_GetLocalPlayer(); + if (!pLocalPlayer) return; - CBasePlayer *player = static_cast(entity); - if (player && player->IsPlayer() && player == localPlayer && !player->m_bHasDefuser) + CBasePlayer *pPlayer = static_cast(entity); + if (pPlayer && pPlayer->IsPlayer() && pPlayer == pLocalPlayer && !pPlayer->m_bHasDefuser) { CreateAndAddEventToList(DEFUSING_WITHOUT_KIT); } @@ -1701,37 +1674,36 @@ void CCSTutor::HandleBombDefusing(CBaseEntity *entity, CBaseEntity *other) void CCSTutor::HandleBombExploded(CBaseEntity *entity, CBaseEntity *other) { - CBasePlayer *localPlayer = UTIL_GetLocalPlayer(); - - if (localPlayer == NULL) + CBasePlayer *pLocalPlayer = UTIL_GetLocalPlayer(); + if (!pLocalPlayer) return; - switch (localPlayer->m_iTeam) + switch (pLocalPlayer->m_iTeam) { - case CT: CreateAndAddEventToList(BOMB_EXPLODED_CT); break; - case TERRORIST: CreateAndAddEventToList(BOMB_EXPLODED_T); break; + case CT: CreateAndAddEventToList(BOMB_EXPLODED_CT); break; + case TERRORIST: CreateAndAddEventToList(BOMB_EXPLODED_T); break; default: break; } } void CCSTutor::HandleRoundStart(CBaseEntity *entity, CBaseEntity *other) { - CBasePlayer *player = UTIL_GetLocalPlayer(); + CBasePlayer *pLocalPlayer = UTIL_GetLocalPlayer(); m_roundStartTime = gpGlobals->time; - if (player == NULL) + if (!pLocalPlayer) return; if (IsBombMap()) { - switch (player->m_iTeam) + switch (pLocalPlayer->m_iTeam) { case CT: CreateAndAddEventToList(ROUND_START_DE_CT); break; case TERRORIST: { - if (player->m_bHasC4) + if (pLocalPlayer->m_bHasC4) CreateAndAddEventToList(YOU_ARE_BOMB_CARRIER, entity, other); else CreateAndAddEventToList(ROUND_START_DE_T); @@ -1741,23 +1713,22 @@ void CCSTutor::HandleRoundStart(CBaseEntity *entity, CBaseEntity *other) } else if (IsHostageMap()) { - switch (player->m_iTeam) + switch (pLocalPlayer->m_iTeam) { - case CT: CreateAndAddEventToList(ROUND_START_CS_CT); break; - case TERRORIST: CreateAndAddEventToList(ROUND_START_CS_T); break; + case CT: CreateAndAddEventToList(ROUND_START_CS_CT); break; + case TERRORIST: CreateAndAddEventToList(ROUND_START_CS_T); break; } } } void CCSTutor::HandleBeingShotAt(CBaseEntity *entity, CBaseEntity *other) { - CBasePlayer *localPlayer = UTIL_GetLocalPlayer(); - - if (localPlayer == NULL) + CBasePlayer *pLocalPlayer = UTIL_GetLocalPlayer(); + if (!pLocalPlayer) return; - CBasePlayer *player = static_cast(entity); - if (player && player->IsPlayer() && player == localPlayer && localPlayer->IsAlive()) + CBasePlayer *pPlayer = static_cast(entity); + if (pPlayer && pPlayer->IsPlayer() && pPlayer == pLocalPlayer && pLocalPlayer->IsAlive()) { CreateAndAddEventToList(YOU_HAVE_BEEN_SHOT_AT, entity, other); } @@ -1765,26 +1736,24 @@ void CCSTutor::HandleBeingShotAt(CBaseEntity *entity, CBaseEntity *other) void CCSTutor::HandleHostageUsed(CBaseEntity *entity, CBaseEntity *other) { - CBasePlayer *localPlayer = UTIL_GetLocalPlayer(); - - if (localPlayer == NULL) + CBasePlayer *pLocalPlayer = UTIL_GetLocalPlayer(); + if (!pLocalPlayer) return; - CBasePlayer *activator = static_cast(entity); - if (activator && activator->IsPlayer()) + CBasePlayer *pActivator = static_cast(entity); + if (pActivator && pActivator->IsPlayer()) { bool unusedHostages = !CheckForAllHostagesFollowingSomeone(); - - if (activator == localPlayer) + if (pActivator == pLocalPlayer) { CreateAndAddEventToList(unusedHostages ? YOU_USED_HOSTAGE_MORE_LEFT : YOU_USED_HOSTAGE_NO_MORE_LEFT); } else if (!unusedHostages) { - switch (localPlayer->m_iTeam) + switch (pLocalPlayer->m_iTeam) { - case CT: CreateAndAddEventToList(ALL_HOSTAGES_FOLLOWING_CT); break; - case TERRORIST: CreateAndAddEventToList(ALL_HOSTAGES_FOLLOWING_T); break; + case CT: CreateAndAddEventToList(ALL_HOSTAGES_FOLLOWING_CT); break; + case TERRORIST: CreateAndAddEventToList(ALL_HOSTAGES_FOLLOWING_T); break; } } } @@ -1792,45 +1761,42 @@ void CCSTutor::HandleHostageUsed(CBaseEntity *entity, CBaseEntity *other) void CCSTutor::HandleHostageRescued(CBaseEntity *entity, CBaseEntity *other) { - CBasePlayer *localPlayer = UTIL_GetLocalPlayer(); - - if (localPlayer == NULL) + CBasePlayer *pLocalPlayer = UTIL_GetLocalPlayer(); + if (!pLocalPlayer) return; - CBasePlayer *rescuer = static_cast(entity); - if (rescuer && rescuer->IsPlayer()) + CBasePlayer *pRescuer = static_cast(entity); + if (pRescuer && pRescuer->IsPlayer()) { - switch (localPlayer->m_iTeam) + switch (pLocalPlayer->m_iTeam) { - case CT: CreateAndAddEventToList((localPlayer == rescuer) ? YOU_RESCUED_HOSTAGE : HOSTAGE_RESCUED_CT); break; - case TERRORIST: CreateAndAddEventToList(HOSTAGE_RESCUED_T); break; + case CT: CreateAndAddEventToList((pLocalPlayer == pRescuer) ? YOU_RESCUED_HOSTAGE : HOSTAGE_RESCUED_CT); break; + case TERRORIST: CreateAndAddEventToList(HOSTAGE_RESCUED_T); break; } } } void CCSTutor::HandleAllHostagesRescued(CBaseEntity *entity, CBaseEntity *other) { - CBasePlayer *localPlayer = UTIL_GetLocalPlayer(); - - if (localPlayer == NULL) + CBasePlayer *pLocalPlayer = UTIL_GetLocalPlayer(); + if (!pLocalPlayer) return; - switch (localPlayer->m_iTeam) + switch (pLocalPlayer->m_iTeam) { - case CT: CreateAndAddEventToList(ALL_HOSTAGES_RESCUED_CT); break; - case TERRORIST: CreateAndAddEventToList(ALL_HOSTAGES_RESCUED_T); break; + case CT: CreateAndAddEventToList(ALL_HOSTAGES_RESCUED_CT); break; + case TERRORIST: CreateAndAddEventToList(ALL_HOSTAGES_RESCUED_T); break; } } void CCSTutor::HandleHostageDamaged(CBaseEntity *entity, CBaseEntity *other) { - CBasePlayer *localPlayer = UTIL_GetLocalPlayer(); - - if (localPlayer == NULL) + CBasePlayer *pLocalPlayer = UTIL_GetLocalPlayer(); + if (!pLocalPlayer) return; - CBasePlayer *attacker = static_cast(other); - if (entity && attacker && attacker->IsPlayer() && localPlayer == attacker) + CBasePlayer *pAttacker = static_cast(other); + if (entity && pAttacker && pAttacker->IsPlayer() && pLocalPlayer == pAttacker) { CreateAndAddEventToList(YOU_DAMAGED_HOSTAGE); } @@ -1838,27 +1804,26 @@ void CCSTutor::HandleHostageDamaged(CBaseEntity *entity, CBaseEntity *other) void CCSTutor::HandleHostageKilled(CBaseEntity *entity, CBaseEntity *other) { - CBasePlayer *localPlayer = UTIL_GetLocalPlayer(); - - if (localPlayer == NULL) + CBasePlayer *pLocalPlayer = UTIL_GetLocalPlayer(); + if (!pLocalPlayer) return; CheckForAllHostagesDead(); - CBasePlayer *attacker = static_cast(other); - if (entity && attacker && attacker->IsPlayer()) + CBasePlayer *pAttacker = static_cast(other); + if (entity && pAttacker && pAttacker->IsPlayer()) { bool unusedHostages = CheckForAllHostagesFollowingSomeone(); - if (localPlayer == attacker) + if (pLocalPlayer == pAttacker) { CreateAndAddEventToList(YOU_KILLED_HOSTAGE); } if (unusedHostages) { - switch (localPlayer->m_iTeam) + switch (pLocalPlayer->m_iTeam) { - case CT: CreateAndAddEventToList(ALL_HOSTAGES_FOLLOWING_CT); break; + case CT: CreateAndAddEventToList(ALL_HOSTAGES_FOLLOWING_CT); break; case TERRORIST: CreateAndAddEventToList(ALL_HOSTAGES_FOLLOWING_T); break; } } @@ -1889,13 +1854,12 @@ void CCSTutor::HandleTWin(CBaseEntity *entity, CBaseEntity *other) void CCSTutor::HandleDeathCameraStart(CBaseEntity *entity, CBaseEntity *other) { - CBasePlayer *localPlayer = UTIL_GetLocalPlayer(); - - if (localPlayer == NULL) + CBasePlayer *pLocalPlayer = UTIL_GetLocalPlayer(); + if (!pLocalPlayer) return; - CBasePlayer *player = static_cast(entity); - if (player && player->IsPlayer() && player == localPlayer) + CBasePlayer *pPlayer = static_cast(entity); + if (pPlayer && pPlayer->IsPlayer() && pPlayer == pLocalPlayer) { m_messageTypeMask = (TUTORMESSAGETYPE_FRIEND_DEATH | TUTORMESSAGETYPE_ENEMY_DEATH | TUTORMESSAGETYPE_HINT | TUTORMESSAGETYPE_END_GAME); CreateAndAddEventToList(DEATH_CAMERA_START); @@ -2054,25 +2018,24 @@ void CCSTutor::HandleCareerTaskDone(CBaseEntity *entity, CBaseEntity *other) void CCSTutor::HandleShotFired(Vector source, Vector target) { - CBasePlayer *localPlayer = UTIL_GetLocalPlayer(); - - if (localPlayer == NULL) + CBasePlayer *pLocalPlayer = UTIL_GetLocalPlayer(); + if (!pLocalPlayer) return; - float d1, d, angle, FiringLineDistanceToPlayer; + float d1, d, angle, flFiringLineDistanceToPlayer; - d1 = (source - localPlayer->pev->origin).Length(); + d1 = (source - pLocalPlayer->pev->origin).Length(); if (d1 > 32.0f) { d = (target - source).Length(); angle = d1 / d; - FiringLineDistanceToPlayer = Q_sin(Q_acos(angle)) * d1; + flFiringLineDistanceToPlayer = Q_sin(Q_acos(angle)) * d1; - if (FiringLineDistanceToPlayer <= 3000.0f) + if (flFiringLineDistanceToPlayer <= 3000.0f) { - OnEvent(EVENT_BEING_SHOT_AT, localPlayer); + OnEvent(EVENT_BEING_SHOT_AT, pLocalPlayer); } } } @@ -2081,36 +2044,34 @@ void CCSTutor::GetNumPlayersAliveOnTeams(int &numT, int &numCT) { numT = numCT = 0; - for (int i = 1; i <= gpGlobals->maxClients; ++i) + for (int i = 1; i <= gpGlobals->maxClients; i++) { - CBasePlayer *player = UTIL_PlayerByIndex(i); - - if (!player || !player->IsAlive()) + CBasePlayer *pPlayer = UTIL_PlayerByIndex(i); + if (!pPlayer || !pPlayer->IsAlive()) continue; - switch (player->m_iTeam) + switch (pPlayer->m_iTeam) { - case CT: ++numCT; break; - case TERRORIST: ++numT; break; + case CT: numCT++; break; + case TERRORIST: numT++; break; } } } void CCSTutor::CheckForLooseWeaponViewable() { - CBasePlayer *localPlayer = UTIL_GetLocalPlayer(); - - if (localPlayer == NULL) + CBasePlayer *pLocalPlayer = UTIL_GetLocalPlayer(); + if (!pLocalPlayer) return; TutorMessage *message = GetTutorMessageDefinition(YOU_SEE_LOOSE_WEAPON); if (message && message->m_class == TUTORMESSAGECLASS_EXAMINE) return; - CBaseEntity *weapon = NULL; + CBaseEntity *weapon = nullptr; while ((weapon = UTIL_FindEntityByClassname(weapon, "weaponbox"))) { - if (IsEntityInViewOfPlayer(weapon, localPlayer)) + if (IsEntityInViewOfPlayer(weapon, pLocalPlayer)) { CreateAndAddEventToList(YOU_SEE_LOOSE_WEAPON); break; @@ -2120,19 +2081,18 @@ void CCSTutor::CheckForLooseWeaponViewable() void CCSTutor::CheckForLooseDefuserViewable() { - CBasePlayer *localPlayer = UTIL_GetLocalPlayer(); - - if (localPlayer == NULL || localPlayer->m_iTeam != CT) + CBasePlayer *pLocalPlayer = UTIL_GetLocalPlayer(); + if (!pLocalPlayer || pLocalPlayer->m_iTeam != CT) return; TutorMessage *message = GetTutorMessageDefinition(YOU_SEE_LOOSE_DEFUSER); if (message && message->m_class == TUTORMESSAGECLASS_EXAMINE) return; - CBaseEntity *defuser = NULL; - while ((defuser = UTIL_FindEntityByClassname(defuser, "item_thighpack"))) + CBaseEntity *pDefuser = nullptr; + while ((pDefuser = UTIL_FindEntityByClassname(pDefuser, "item_thighpack"))) { - if (IsEntityInViewOfPlayer(defuser, localPlayer)) + if (IsEntityInViewOfPlayer(pDefuser, pLocalPlayer)) { CreateAndAddEventToList(YOU_SEE_LOOSE_DEFUSER); break; @@ -2142,59 +2102,58 @@ void CCSTutor::CheckForLooseDefuserViewable() void CCSTutor::CheckForBombViewable() { - CBasePlayer *localPlayer = UTIL_GetLocalPlayer(); - - if (localPlayer == NULL) + CBasePlayer *pLocalPlayer = UTIL_GetLocalPlayer(); + if (!pLocalPlayer) return; - CBaseEntity *bomb = UTIL_FindEntityByClassname(NULL, "grenade"); - if (bomb && ((CGrenade *)bomb)->m_bIsC4 && IsEntityInViewOfPlayer(bomb, localPlayer)) + CGrenade *pBomb = (CGrenade *)UTIL_FindEntityByClassname(nullptr, "grenade"); + if (pBomb && pBomb->m_bIsC4 && IsEntityInViewOfPlayer(pBomb, pLocalPlayer)) { - switch (localPlayer->m_iTeam) + TutorMessageID mid = TUTOR_NUM_MESSAGES; + switch (pLocalPlayer->m_iTeam) { - case CT: + case CT: + { + mid = YOU_SEE_PLANTED_BOMB_CT; + break; + } + case TERRORIST: + { + mid = YOU_SEE_PLANTED_BOMB_T; + break; + } + } + + if (mid != TUTOR_NUM_MESSAGES) + { + TutorMessage *message = GetTutorMessageDefinition(mid); + if (!message || message->m_class != TUTORMESSAGECLASS_EXAMINE) { - TutorMessage *message = GetTutorMessageDefinition(YOU_SEE_PLANTED_BOMB_CT); - if (message == NULL || message->m_class != TUTORMESSAGECLASS_EXAMINE) - { - CreateAndAddEventToList(YOU_SEE_PLANTED_BOMB_CT); - } - break; - } - case TERRORIST: - { - TutorMessage *message = GetTutorMessageDefinition(YOU_SEE_PLANTED_BOMB_T); - if (message == NULL || message->m_class != TUTORMESSAGECLASS_EXAMINE) - { - CreateAndAddEventToList(YOU_SEE_PLANTED_BOMB_T); - } - break; + CreateAndAddEventToList(mid); } } } else { - CBasePlayer *bombCarrier = NULL; - for (int i = 1; i <= gpGlobals->maxClients; ++i) + CBasePlayer *pBombCarrier = nullptr; + for (int i = 1; i <= gpGlobals->maxClients; i++) { - CBasePlayer *player = UTIL_PlayerByIndex(i); - - if (player && player->m_bHasC4) + CBasePlayer *pPlayer = UTIL_PlayerByIndex(i); + if (pPlayer && pPlayer->m_bHasC4) { - bombCarrier = player; + pBombCarrier = pPlayer; break; } } - bomb = UTIL_FindEntityByClassname(NULL, "weapon_c4"); - - if (bomb && IsEntityInViewOfPlayer(bomb, localPlayer)) + CBaseEntity *pC4 = UTIL_FindEntityByClassname(nullptr, "weapon_c4"); + if (pC4 && IsEntityInViewOfPlayer(pC4, pLocalPlayer)) { - if (bombCarrier) + if (pBombCarrier) { - if (bombCarrier != localPlayer) + if (pBombCarrier != pLocalPlayer) { - switch (localPlayer->m_iTeam) + switch (pLocalPlayer->m_iTeam) { case CT: { @@ -2219,25 +2178,27 @@ void CCSTutor::CheckForBombViewable() } else { - switch (localPlayer->m_iTeam) + TutorMessageID mid = TUTOR_NUM_MESSAGES; + switch (pLocalPlayer->m_iTeam) { - case CT: + case CT: + { + mid = YOU_SEE_LOOSE_BOMB_CT; + break; + } + case TERRORIST: + { + mid = YOU_SEE_LOOSE_BOMB_T; + break; + } + } + + if (mid != TUTOR_NUM_MESSAGES) + { + TutorMessage *message = GetTutorMessageDefinition(mid); + if (!message || message->m_class != TUTORMESSAGECLASS_EXAMINE) { - TutorMessage *message = GetTutorMessageDefinition(YOU_SEE_LOOSE_BOMB_CT); - if (message == NULL || message->m_class != TUTORMESSAGECLASS_EXAMINE) - { - CreateAndAddEventToList(YOU_SEE_LOOSE_BOMB_CT); - } - break; - } - case TERRORIST: - { - TutorMessage *message = GetTutorMessageDefinition(YOU_SEE_LOOSE_BOMB_T); - if (message == NULL || message->m_class != TUTORMESSAGECLASS_EXAMINE) - { - CreateAndAddEventToList(YOU_SEE_LOOSE_BOMB_T); - } - break; + CreateAndAddEventToList(mid); } } } @@ -2247,103 +2208,85 @@ void CCSTutor::CheckForBombViewable() void CCSTutor::CheckForBombsiteViewable() { - CBasePlayer *localPlayer = UTIL_GetLocalPlayer(); - - if (localPlayer == NULL) + CBasePlayer *pLocalPlayer = UTIL_GetLocalPlayer(); + if (!pLocalPlayer) return; TutorMessageID mid = CheckForInBombZone(); - if (mid == TUTOR_NUM_MESSAGES) + if (mid != TUTOR_NUM_MESSAGES) { - switch (localPlayer->m_iTeam) + CreateAndAddEventToList(mid); + return; + } + + switch (pLocalPlayer->m_iTeam) + { + case CT: + { + mid = YOU_SEE_BOMBSITE_CT; + break; + } + case TERRORIST: + { + if (pLocalPlayer->m_bHasC4) { - case CT: - { - mid = YOU_SEE_BOMBSITE_CT; - break; - } - case TERRORIST: - { - if (localPlayer->m_bHasC4) - { - mid = YOU_SEE_BOMBSITE_T_BOMB; - } - else if (TheCSBots() == NULL || !TheCSBots()->IsBombPlanted()) - { - mid = YOU_SEE_BOMBSITE_T; - } - break; - } + mid = YOU_SEE_BOMBSITE_T_BOMB; } - - TutorMessage *definition = GetTutorMessageDefinition(mid); - if (definition == NULL || definition->m_class != TUTORMESSAGECLASS_EXAMINE) + else if (!TheCSBots() || !TheCSBots()->IsBombPlanted()) { - bool sawFirst = false; - CBaseEntity *bombTarget = NULL; + mid = YOU_SEE_BOMBSITE_T; + } + break; + } + } - while ((bombTarget = UTIL_FindEntityByClassname(bombTarget, "func_bomb_target"))) - { - if (IsBombPlantedInBombsite(bombTarget)) - { - sawFirst = true; - CreateAndAddEventToList(mid); - break; - } - } - - if (!sawFirst) - { - while ((bombTarget = UTIL_FindEntityByClassname(bombTarget, "info_bomb_target"))) - { - if (IsBombPlantedInBombsite(bombTarget)) - { - CreateAndAddEventToList(mid); - break; - } - } - } + TutorMessage *definition = GetTutorMessageDefinition(mid); + if (!definition || definition->m_class != TUTORMESSAGECLASS_EXAMINE) + { + if (IsBombPlantedInBombZone("func_bomb_target") + || IsBombPlantedInBombZone("info_bomb_target")) + { + CreateAndAddEventToList(mid); + return; } } - else - CreateAndAddEventToList(mid); } TutorMessageID CCSTutor::CheckForInBombZone() { - CBasePlayer *localPlayer = UTIL_GetLocalPlayer(); - TutorMessageID mid = TUTOR_NUM_MESSAGES; - - if (localPlayer && localPlayer->m_iTeam == CT) + CBasePlayer *pLocalPlayer = UTIL_GetLocalPlayer(); + if (pLocalPlayer && pLocalPlayer->m_iTeam == CT) { - CBaseEntity *bombTarget = NULL; - - while ((bombTarget = UTIL_FindEntityByClassname(bombTarget, "func_bomb_target"))) + if (IsBombPlantedInBombZone("func_bomb_target") + || IsBombPlantedInBombZone("info_bomb_target")) { - if (IsBombPlantedInBombsite(bombTarget)) - { - return YOU_SEE_PLANTED_BOMB_CT; - } - } - - while ((bombTarget = UTIL_FindEntityByClassname(bombTarget, "info_bomb_target"))) - { - if (IsBombPlantedInBombsite(bombTarget)) - { - return YOU_SEE_PLANTED_BOMB_CT; - } + return YOU_SEE_PLANTED_BOMB_CT; } } - return mid; + return TUTOR_NUM_MESSAGES; } bool CCSTutor::IsBombPlantedInBombsite(CBaseEntity *bombTarget) { - CGrenade *bomb = NULL; - while ((bomb = (CGrenade *)UTIL_FindEntityByClassname(bomb, "grenade"))) + CGrenade *pBomb = nullptr; + while ((pBomb = (CGrenade *)UTIL_FindEntityByClassname(pBomb, "grenade"))) { - if (bomb->m_bIsC4 && IsEntityInBombsite(bomb, bombTarget)) + if (pBomb->m_bIsC4 && IsEntityInBombsite(pBomb, bombTarget)) + { + return true; + } + } + + return false; +} + +bool CCSTutor::IsBombPlantedInBombZone(const char *pszBombZone) +{ + CBaseEntity *bombSite = nullptr; + while ((bombSite = UTIL_FindEntityByClassname(bombSite, pszBombZone))) + { + if (IsBombPlantedInBombsite(bombSite)) { return true; } @@ -2354,47 +2297,50 @@ bool CCSTutor::IsBombPlantedInBombsite(CBaseEntity *bombTarget) void CCSTutor::CheckForHostageViewable() { - CBasePlayer *localPlayer = UTIL_GetLocalPlayer(); - - if (localPlayer == NULL) + CBasePlayer *pLocalPlayer = UTIL_GetLocalPlayer(); + if (!pLocalPlayer) return; - CBaseEntity *hostageEntity = NULL; - while ((hostageEntity = UTIL_FindEntityByClassname(hostageEntity, "hostage_entity"))) + CBaseEntity *pHostageEntity = nullptr; + while ((pHostageEntity = UTIL_FindEntityByClassname(pHostageEntity, "hostage_entity"))) { - bool validHostage = false; - CHostage *hostage = static_cast(hostageEntity); + bool bValidHostage = false; + CHostage *pHostage = static_cast(pHostageEntity); - if (hostage->IsAlive()) + if (pHostage->IsAlive()) { - if (!hostage->IsFollowingSomeone()) - validHostage = true; + if (!pHostage->IsFollowingSomeone()) + { + bValidHostage = true; + } } - if (validHostage && IsEntityInViewOfPlayer(hostage, localPlayer)) + if (bValidHostage && IsEntityInViewOfPlayer(pHostage, pLocalPlayer)) { - switch (localPlayer->m_iTeam) + TutorMessageID mid = TUTOR_NUM_MESSAGES; + switch (pLocalPlayer->m_iTeam) { case CT: { - TutorMessage *message = GetTutorMessageDefinition(YOU_SEE_HOSTAGE_CT); - if (message && message->m_class == TUTORMESSAGECLASS_EXAMINE) - return; - - CreateAndAddEventToList(YOU_SEE_HOSTAGE_CT); + mid = YOU_SEE_HOSTAGE_CT; break; } case TERRORIST: { - TutorMessage *message = GetTutorMessageDefinition(YOU_SEE_HOSTAGE_T); - if (message && message->m_class == TUTORMESSAGECLASS_EXAMINE) - return; - - CreateAndAddEventToList(YOU_SEE_HOSTAGE_T); + mid = YOU_SEE_HOSTAGE_T; break; } } + if (mid != TUTOR_NUM_MESSAGES) + { + TutorMessage *message = GetTutorMessageDefinition(mid); + if (!message || message->m_class != TUTORMESSAGECLASS_EXAMINE) + { + CreateAndAddEventToList(mid); + } + } + break; } } @@ -2402,14 +2348,13 @@ void CCSTutor::CheckForHostageViewable() void CCSTutor::CheckForTimeRunningOut() { - CBasePlayer *localPlayer = UTIL_GetLocalPlayer(); - - if (localPlayer == NULL || CSGameRules()->IsFreezePeriod() || CSGameRules()->GetRoundRemainingTime() > 30.0f) + CBasePlayer *pLocalPlayer = UTIL_GetLocalPlayer(); + if (!pLocalPlayer || CSGameRules()->IsFreezePeriod() || CSGameRules()->GetRoundRemainingTime() > 30.0f) return; if (IsBombMap()) { - switch (localPlayer->m_iTeam) + switch (pLocalPlayer->m_iTeam) { case CT: CreateAndAddEventToList(TIME_RUNNING_OUT_DE_CT); @@ -2421,7 +2366,7 @@ void CCSTutor::CheckForTimeRunningOut() } else if (IsHostageMap()) { - switch (localPlayer->m_iTeam) + switch (pLocalPlayer->m_iTeam) { case CT: CreateAndAddEventToList(TIME_RUNNING_OUT_CS_CT); @@ -2436,11 +2381,11 @@ void CCSTutor::CheckForTimeRunningOut() void CCSTutor::CheckForAllHostagesDead() { bool foundLiveOne = false; - CHostage *hostage = NULL; + CHostage *pHostage = nullptr; - while ((hostage = (CHostage *)UTIL_FindEntityByClassname(hostage, "hostage_entity"))) + while ((pHostage = (CHostage *)UTIL_FindEntityByClassname(pHostage, "hostage_entity"))) { - if (hostage->IsAlive()) + if (pHostage->IsAlive()) { foundLiveOne = true; break; @@ -2456,13 +2401,13 @@ void CCSTutor::CheckForAllHostagesDead() bool CCSTutor::CheckForAllHostagesFollowingSomeone() { bool foundUnusedOne = false; - CHostage *hostage = NULL; + CHostage *pHostage = nullptr; - while ((hostage = (CHostage *)UTIL_FindEntityByClassname(hostage, "hostage_entity"))) + while ((pHostage = (CHostage *)UTIL_FindEntityByClassname(pHostage, "hostage_entity"))) { - if (hostage->IsAlive()) + if (pHostage->IsAlive()) { - if (!hostage->IsFollowingSomeone()) + if (!pHostage->IsFollowingSomeone()) { foundUnusedOne = true; break; @@ -2476,7 +2421,7 @@ bool CCSTutor::CheckForAllHostagesFollowingSomeone() TutorMessage *CCSTutor::GetTutorMessageDefinition(int messageID) { if (messageID < 0 || messageID >= TUTOR_NUM_MESSAGES) - return NULL; + return nullptr; TutorMessageMapIter iter = m_messageMap.find(TutorIdentifierList[messageID]); if (iter != m_messageMap.end()) @@ -2484,18 +2429,18 @@ TutorMessage *CCSTutor::GetTutorMessageDefinition(int messageID) return (*iter).second; } - return NULL; + return nullptr; } CBaseEntity *CCSTutor::GetEntityForMessageID(int messageID, CBaseEntity *last) { - CBaseEntity *ret = NULL; + CBaseEntity *pEntity = nullptr; switch (messageID) { case YOU_SEE_FRIEND: case YOU_SEE_ENEMY: - ret = UTIL_FindEntityByClassname(last, "player"); + pEntity = UTIL_FindEntityByClassname(last, "player"); break; case YOU_SEE_FRIEND_CORPSE: { @@ -2503,14 +2448,13 @@ CBaseEntity *CCSTutor::GetEntityForMessageID(int messageID, CBaseEntity *last) // this code fucked my brain, in that pointer Vector * is passed through the CBaseEntity * #if 1 - CBasePlayer *localPlayer = UTIL_GetLocalPlayer(); - - if (localPlayer) + CBasePlayer *pLocalPlayer = UTIL_GetLocalPlayer(); + if (pLocalPlayer) { if (m_clientCorpseList.empty()) - return NULL; + return nullptr; - ClientCorpseStruct *lastCorpse = NULL; + ClientCorpseStruct *lastCorpse = nullptr; ClientCorpseListIter iter; if (last) @@ -2524,20 +2468,20 @@ CBaseEntity *CCSTutor::GetEntityForMessageID(int messageID, CBaseEntity *last) if ((CBaseEntity *)lastCorpse == last) break; - ++iter; + iter++; } while (iter != m_clientCorpseList.end()) { ClientCorpseStruct *corpse = (*iter); - if (corpse->m_team == localPlayer->m_iTeam) + if (corpse->m_team == pLocalPlayer->m_iTeam) return (CBaseEntity *)&corpse->m_position; - ++iter; + iter++; } - return NULL; + return nullptr; } else return (CBaseEntity *)&m_clientCorpseList.front()->m_position; @@ -2549,26 +2493,26 @@ CBaseEntity *CCSTutor::GetEntityForMessageID(int messageID, CBaseEntity *last) case YOU_SEE_LOOSE_BOMB_CT: case YOU_SEE_BOMB_CARRIER_T: case YOU_SEE_BOMB_CARRIER_CT: - ret = UTIL_FindEntityByClassname(last, "weapon_c4"); + pEntity = UTIL_FindEntityByClassname(last, "weapon_c4"); break; case YOU_SEE_PLANTED_BOMB_T: case YOU_SEE_PLANTED_BOMB_CT: - ret = UTIL_FindEntityByClassname(last, "grenade"); + pEntity = UTIL_FindEntityByClassname(last, "grenade"); break; case YOU_SEE_LOOSE_WEAPON: - ret = UTIL_FindEntityByClassname(last, "weaponbox"); + pEntity = UTIL_FindEntityByClassname(last, "weaponbox"); break; case YOU_SEE_LOOSE_DEFUSER: - ret = UTIL_FindEntityByClassname(last, "item_thighpack"); + pEntity = UTIL_FindEntityByClassname(last, "item_thighpack"); break; case YOU_SEE_HOSTAGE_T: case YOU_SEE_HOSTAGE_CT: case YOU_SEE_HOSTAGE_CT_EXAMINE: - ret = UTIL_FindEntityByClassname(last, "hostage_entity"); + pEntity = UTIL_FindEntityByClassname(last, "hostage_entity"); break; } - return ret; + return pEntity; } void CCSTutor::CheckHintMessages(float time) @@ -2640,40 +2584,33 @@ void CCSTutor::CheckInGameHintMessages(float time) void CCSTutor::CheckForNeedToReload(bool isPassiveCheck) { - CBasePlayer *localPlayer; - CBasePlayerItem *currentItem; - CBasePlayerWeapon *currentWeapon; + CBasePlayer *pLocalPlayer = UTIL_GetLocalPlayer(); + if (!pLocalPlayer || !pLocalPlayer->IsPlayer()) + return; + + CBasePlayerWeapon *pCurrentWeapon = static_cast(pLocalPlayer->m_pActiveItem); + if (!pCurrentWeapon || !pCurrentWeapon->IsWeapon()) + return; + ItemInfo itemInfo; - - localPlayer = UTIL_GetLocalPlayer(); Q_memset(&itemInfo, 0, sizeof(itemInfo)); - - if (localPlayer == NULL || !localPlayer->IsPlayer()) - return; - - currentItem = localPlayer->m_pActiveItem; - - if (currentItem == NULL || !currentItem->IsWeapon()) - return; - - currentWeapon = static_cast(currentItem); - currentWeapon->GetItemInfo(&itemInfo); + pCurrentWeapon->GetItemInfo(&itemInfo); if (itemInfo.iSlot && itemInfo.iSlot != 1) return; - if (localPlayer->m_rgAmmo[currentWeapon->m_iPrimaryAmmoType]) + if (pLocalPlayer->m_rgAmmo[pCurrentWeapon->m_iPrimaryAmmoType]) { if (isPassiveCheck) { - if ((2 * currentWeapon->m_iClip) < currentItem->iMaxClip() && !currentWeapon->m_fInReload) + if ((2 * pCurrentWeapon->m_iClip) < pCurrentWeapon->iMaxClip() && !pCurrentWeapon->m_fInReload) { CreateAndAddEventToList(YOU_SHOULD_RELOAD); } } else { - if ((5 * currentWeapon->m_iClip) < currentItem->iMaxClip() && !currentWeapon->m_fInReload) + if ((5 * pCurrentWeapon->m_iClip) < pCurrentWeapon->iMaxClip() && !pCurrentWeapon->m_fInReload) { TutorMessage *message = GetTutorMessageDefinition(YOU_SHOULD_RELOAD); if (message) @@ -2693,7 +2630,7 @@ void CCSTutor::CheckForNeedToReload(bool isPassiveCheck) } } } - else if (!currentWeapon->m_iClip) + else if (!pCurrentWeapon->m_iClip) { if (!isPassiveCheck) { @@ -2710,26 +2647,24 @@ void CCSTutor::CheckForNeedToReload(bool isPassiveCheck) void CCSTutor::CheckExamineMessages(float time) { - CBasePlayer *localPlayer = UTIL_GetLocalPlayer(); - - if (localPlayer == NULL) + CBasePlayer *pLocalPlayer = UTIL_GetLocalPlayer(); + if (!pLocalPlayer) return; - for (int i = 0; i < TUTOR_NUM_MESSAGES; ++i) + for (int i = 0; i < TUTOR_NUM_MESSAGES; i++) { TutorMessage *message = GetTutorMessageDefinition(i); - - if (message == NULL || message->m_class != TUTORMESSAGECLASS_EXAMINE) + if (!message || message->m_class != TUTORMESSAGECLASS_EXAMINE) continue; - CBaseEntity *entity = NULL; + CBaseEntity *pEntity = nullptr; bool isPlayerLooking = false; - while ((entity = GetEntityForMessageID(i, entity))) + while ((pEntity = GetEntityForMessageID(i, pEntity))) { if (i == YOU_SEE_FRIEND_CORPSE || i == YOU_SEE_ENEMY_CORPSE) { - if (IsPlayerLookingAtPosition((Vector *)entity, localPlayer)) + if (IsPlayerLookingAtPosition((Vector *)pEntity, pLocalPlayer)) { isPlayerLooking = true; break; @@ -2737,13 +2672,13 @@ void CCSTutor::CheckExamineMessages(float time) } else if (i == YOU_SEE_HOSTAGE_CT_EXAMINE || i == YOU_SEE_FRIEND || i == YOU_SEE_ENEMY) { - if (IsPlayerLookingAtEntity(entity, localPlayer)) + if (IsPlayerLookingAtEntity(pEntity, pLocalPlayer)) { isPlayerLooking = true; break; } } - else if (IsPlayerLookingAtPosition(&entity->pev->origin, localPlayer)) + else if (IsPlayerLookingAtPosition(&pEntity->pev->origin, pLocalPlayer)) { isPlayerLooking = true; break; @@ -2761,47 +2696,53 @@ void CCSTutor::CheckExamineMessages(float time) bool validEntity = false; if (i == YOU_SEE_FRIEND) { - CBasePlayer *player = static_cast(entity); - - if (player->IsPlayer() && player->IsAlive() && player->m_iTeam == localPlayer->m_iTeam) + CBasePlayer *pPlayer = static_cast(pEntity); + if (pPlayer->IsPlayer() && pPlayer->IsAlive() && pPlayer->m_iTeam == pLocalPlayer->m_iTeam) + { validEntity = true; + } } else if (i == YOU_SEE_ENEMY) { - CBasePlayer *player = static_cast(entity); - - if (player->IsPlayer() && player->IsAlive() && player->m_iTeam == localPlayer->m_iTeam) + CBasePlayer *pPlayer = static_cast(pEntity); + if (pPlayer->IsPlayer() && pPlayer->IsAlive() && pPlayer->m_iTeam == pLocalPlayer->m_iTeam) { - if ((player->m_iTeam != CT || localPlayer->m_iTeam == TERRORIST) && (player->m_iTeam != TERRORIST || localPlayer->m_iTeam == CT)) + if ((pPlayer->m_iTeam != CT || pLocalPlayer->m_iTeam == TERRORIST) && (pPlayer->m_iTeam != TERRORIST || pLocalPlayer->m_iTeam == CT)) + { validEntity = true; + } } } else if (i == YOU_SEE_HOSTAGE_CT_EXAMINE) { - CHostage *hostage = static_cast(entity); - if (entity->IsAlive()) + CHostage *pHostage = static_cast(pEntity); + if (pEntity->IsAlive()) { - if (!hostage->IsFollowingSomeone()) + if (!pHostage->IsFollowingSomeone()) + { validEntity = true; + } } } if (validEntity) { - CreateAndAddEventToList((TutorMessageID)i, entity); + CreateAndAddEventToList((TutorMessageID)i, pEntity); } } else + { message->m_examineStartTime = -1.0f; + } } } bool CCSTutor::CanLocalPlayerBuyStuff() { - CBasePlayer *localPlayer = UTIL_GetLocalPlayer(); - if (localPlayer) + CBasePlayer *pLocalPlayer = UTIL_GetLocalPlayer(); + if (pLocalPlayer) { - return localPlayer->CanPlayerBuy(); + return pLocalPlayer->CanPlayerBuy(); } return false; @@ -2809,17 +2750,16 @@ bool CCSTutor::CanLocalPlayerBuyStuff() void CCSTutor::CheckBuyZoneMessages() { - CBasePlayer *localPlayer = UTIL_GetLocalPlayer(); - - if (localPlayer == NULL || m_currentlyShownMessageID == BUY_TIME_BEGIN) + CBasePlayer *pLocalPlayer = UTIL_GetLocalPlayer(); + if (!pLocalPlayer || m_currentlyShownMessageID == BUY_TIME_BEGIN) return; - CBasePlayerWeapon *primary = static_cast(localPlayer->m_rgpPlayerItems[PRIMARY_WEAPON_SLOT]); - CBasePlayerWeapon *secondary = static_cast(localPlayer->m_rgpPlayerItems[PISTOL_SLOT]); + CBasePlayerWeapon *pPrimaryWeapon = static_cast(pLocalPlayer->m_rgpPlayerItems[PRIMARY_WEAPON_SLOT]); + CBasePlayerWeapon *pSecondaryWeapon = static_cast(pLocalPlayer->m_rgpPlayerItems[PISTOL_SLOT]); - if (primary) + if (pPrimaryWeapon) { - if (localPlayer->NeedsPrimaryAmmo() && localPlayer->CanAffordPrimaryAmmo()) + if (pLocalPlayer->NeedsPrimaryAmmo() && pLocalPlayer->CanAffordPrimaryAmmo()) { TheTutor->OnEvent(EVENT_TUTOR_NEED_TO_BUY_PRIMARY_AMMO); return; @@ -2827,36 +2767,38 @@ void CCSTutor::CheckBuyZoneMessages() } else { - if (localPlayer->CanAffordPrimary()) + if (pLocalPlayer->CanAffordPrimary()) { TheTutor->OnEvent(EVENT_TUTOR_NEED_TO_BUY_PRIMARY_WEAPON); return; } } - if (secondary && localPlayer->NeedsSecondaryAmmo() && localPlayer->CanAffordSecondaryAmmo()) + if (pSecondaryWeapon && pLocalPlayer->NeedsSecondaryAmmo() && pLocalPlayer->CanAffordSecondaryAmmo()) { TheTutor->OnEvent(EVENT_TUTOR_NEED_TO_BUY_SECONDARY_AMMO); } - else if (localPlayer->NeedsArmor() && localPlayer->CanAffordArmor()) + else if (pLocalPlayer->NeedsArmor() && pLocalPlayer->CanAffordArmor()) { TheTutor->OnEvent(EVENT_TUTOR_NEED_TO_BUY_ARMOR); } - else if (localPlayer->NeedsDefuseKit() && localPlayer->CanAffordDefuseKit()) + else if (pLocalPlayer->NeedsDefuseKit() && pLocalPlayer->CanAffordDefuseKit()) { TheTutor->OnEvent(EVENT_TUTOR_NEED_TO_BUY_DEFUSE_KIT); } - else if (localPlayer->NeedsGrenade() && localPlayer->CanAffordGrenade()) + else if (pLocalPlayer->NeedsGrenade() && pLocalPlayer->CanAffordGrenade()) { TheTutor->OnEvent(EVENT_TUTOR_NEED_TO_BUY_GRENADE); } else + { TheTutor->OnEvent(EVENT_TUTOR_NOT_BUYING_ANYTHING); + } } bool CCSTutor::IsHostageMap() { - return UTIL_FindEntityByClassname(NULL, "hostage_entity") != NULL; + return UTIL_FindEntityByClassname(nullptr, "hostage_entity") != nullptr; } bool CCSTutor::IsBombMap() @@ -2880,7 +2822,7 @@ void CCSTutor::ConstructRecentDeathsList(TeamName team, char *buf, int buflen, T char scratch[32]; buf[0] = '\0'; - for (int i = 1; i <= gpGlobals->maxClients; ++i) + for (int i = 1; i <= gpGlobals->maxClients; i++) { CBasePlayer *pPlayer = UTIL_PlayerByIndex(i); diff --git a/regamedll/dlls/tutor_cs_tutor.h b/regamedll/dlls/tutor_cs_tutor.h index ee4f8b80..b9217bab 100644 --- a/regamedll/dlls/tutor_cs_tutor.h +++ b/regamedll/dlls/tutor_cs_tutor.h @@ -26,11 +26,7 @@ * */ -#ifndef TUTOR_CS_TUTOR_H -#define TUTOR_CS_TUTOR_H -#ifdef _WIN32 #pragma once -#endif #include @@ -42,18 +38,18 @@ enum TutorMessageClass enum TutorMessageType { - TUTORMESSAGETYPE_DEFAULT = (1 << 0), // icon info | color green - TUTORMESSAGETYPE_FRIEND_DEATH = (1 << 1), // icon skull | color red - TUTORMESSAGETYPE_ENEMY_DEATH = (1 << 2), // icon skull | color blue - TUTORMESSAGETYPE_SCENARIO = (1 << 3), // icon info | color yellow - TUTORMESSAGETYPE_BUY = (1 << 4), // icon info | color green - TUTORMESSAGETYPE_CAREER = (1 << 5), // icon info | color green - TUTORMESSAGETYPE_HINT = (1 << 6), // icon info | color green - TUTORMESSAGETYPE_INGAME_HINT = (1 << 7), // icon info | color green - TUTORMESSAGETYPE_END_GAME = (1 << 8), // icon info | color yellow + TUTORMESSAGETYPE_DEFAULT = BIT(0), // icon info | color green + TUTORMESSAGETYPE_FRIEND_DEATH = BIT(1), // icon skull | color red + TUTORMESSAGETYPE_ENEMY_DEATH = BIT(2), // icon skull | color blue + TUTORMESSAGETYPE_SCENARIO = BIT(3), // icon info | color yellow + TUTORMESSAGETYPE_BUY = BIT(4), // icon info | color green + TUTORMESSAGETYPE_CAREER = BIT(5), // icon info | color green + TUTORMESSAGETYPE_HINT = BIT(6), // icon info | color green + TUTORMESSAGETYPE_INGAME_HINT = BIT(7), // icon info | color green + TUTORMESSAGETYPE_END_GAME = BIT(8), // icon info | color yellow TUTORMESSAGETYPE_LAST, - TUTORMESSAGETYPE_ALL = (1 << 9) - 1 + TUTORMESSAGETYPE_ALL = (TUTORMESSAGETYPE_DEFAULT | TUTORMESSAGETYPE_FRIEND_DEATH | TUTORMESSAGETYPE_ENEMY_DEATH | TUTORMESSAGETYPE_SCENARIO | TUTORMESSAGETYPE_BUY | TUTORMESSAGETYPE_CAREER | TUTORMESSAGETYPE_HINT | TUTORMESSAGETYPE_INGAME_HINT | TUTORMESSAGETYPE_END_GAME) }; enum TutorMessageInterruptFlag @@ -385,6 +381,7 @@ public: bool CanLocalPlayerBuyStuff(); void CheckBuyZoneMessages(); bool IsBombPlantedInBombsite(CBaseEntity *bombTarget); + bool IsBombPlantedInBombZone(const char *pszBombZone); void ReadTutorMessageFile(); void ApplyPersistentDecay(); CBaseEntity *GetEntityForMessageID(int messageID, CBaseEntity *last = NULL); @@ -412,16 +409,15 @@ void ParseMessageParameters(char *&messageData, TutorMessage *ret); TutorMessage *ConstructTutorMessage(char *&messageData, TutorMessage *defaults); void ReadDefaultValues(char *&messageData, TutorMessage *defaults); -// custom operator -inline TutorMessageID operator++(TutorMessageID &e, int) +// custom operator++ +inline TutorMessageID operator++(TutorMessageID &iter, int) { - if (e == TUTOR_NUM_MESSAGES) + // bounds checking + if (iter == TUTOR_NUM_MESSAGES) { return YOU_FIRED_A_SHOT; } - const int i = static_cast(e); - return e = static_cast(i + 1); + iter = static_cast(static_cast(iter) + 1); + return iter; } - -#endif // TUTOR_CS_TUTOR_H diff --git a/regamedll/dlls/unisignals.h b/regamedll/dlls/unisignals.h index e05ecf95..aaa94159 100644 --- a/regamedll/dlls/unisignals.h +++ b/regamedll/dlls/unisignals.h @@ -26,11 +26,13 @@ * */ -#ifndef UNISIGNALS_H -#define UNISIGNALS_H -#ifdef _WIN32 #pragma once -#endif + +#define SIGNAL_BUY BIT(0) +#define SIGNAL_BOMB BIT(1) +#define SIGNAL_RESCUE BIT(2) +#define SIGNAL_ESCAPE BIT(3) +#define SIGNAL_VIPSAFETY BIT(4) class CUnifiedSignals { @@ -54,5 +56,3 @@ private: int m_flSignal; int m_flState; }; - -#endif // UNISIGNALS_H diff --git a/regamedll/dlls/util.cpp b/regamedll/dlls/util.cpp index ef0d0b9f..8d8ecdf6 100644 --- a/regamedll/dlls/util.cpp +++ b/regamedll/dlls/util.cpp @@ -239,7 +239,7 @@ NOXREF BOOL UTIL_GetNextBestWeapon(CBasePlayer *pPlayer, CBasePlayerItem *pCurre return g_pGameRules->GetNextBestWeapon(pPlayer,pCurrentWeapon); } -NOXREF float UTIL_AngleMod(float a) +float UTIL_AngleMod(float a) { if (a < 0.0f) a = a + 360.0f * (int(a / 360.0f) + 1); @@ -282,13 +282,12 @@ NOXREF void UTIL_MoveToOrigin(edict_t *pent, const Vector &vecGoal, float flDist int UTIL_EntitiesInBox(CBaseEntity **pList, int listMax, const Vector &mins, const Vector &maxs, int flagMask) { edict_t *pEdict = INDEXENT(1); - CBaseEntity *pEntity; int count = 0; if (!pEdict) return 0; - for (int i = 1; i < gpGlobals->maxEntities; ++i, ++pEdict) + for (int i = 1; i < gpGlobals->maxEntities; i++, pEdict++) { if (pEdict->free) continue; @@ -296,16 +295,11 @@ int UTIL_EntitiesInBox(CBaseEntity **pList, int listMax, const Vector &mins, con if (flagMask && !(pEdict->v.flags & flagMask)) continue; - if (mins.x > pEdict->v.absmax.x - || mins.y > pEdict->v.absmax.y - || mins.z > pEdict->v.absmax.z - || maxs.x < pEdict->v.absmin.x - || maxs.y < pEdict->v.absmin.y - || maxs.z < pEdict->v.absmin.z) + CBaseEntity *pEntity = CBaseEntity::Instance(pEdict); + if (!pEntity) continue; - pEntity = CBaseEntity::Instance(pEdict); - if (!pEntity) + if (!pEntity->Intersects(mins, maxs)) continue; pList[count++] = pEntity; @@ -331,7 +325,7 @@ NOXREF int UTIL_MonstersInSphere(CBaseEntity ** pList, int listMax, const Vector if (!pEdict) return count; - for (int i = 1; i < gpGlobals->maxEntities; ++i, ++pEdict) + for (int i = 1; i < gpGlobals->maxEntities; i++, pEdict++) { if (pEdict->free) continue; @@ -365,8 +359,7 @@ NOXREF int UTIL_MonstersInSphere(CBaseEntity ** pList, int listMax, const Vector if (!pEntity) continue; - pList[count] = pEntity; - count++; + pList[count++] = pEntity; if (count >= listMax) return count; @@ -378,10 +371,10 @@ NOXREF int UTIL_MonstersInSphere(CBaseEntity ** pList, int listMax, const Vector CBaseEntity *UTIL_FindEntityInSphere(CBaseEntity *pStartEntity, const Vector &vecCenter, float flRadius) { edict_t *pentEntity; - if (pStartEntity != NULL) + if (pStartEntity) pentEntity = pStartEntity->edict(); else - pentEntity = NULL; + pentEntity = nullptr; pentEntity = FIND_ENTITY_IN_SPHERE(pentEntity, vecCenter, flRadius); if (!FNullEnt(pentEntity)) @@ -389,16 +382,16 @@ CBaseEntity *UTIL_FindEntityInSphere(CBaseEntity *pStartEntity, const Vector &ve return CBaseEntity::Instance(pentEntity); } - return NULL; + return nullptr; } CBaseEntity *UTIL_FindEntityByString_Old(CBaseEntity *pStartEntity, const char *szKeyword, const char *szValue) { edict_t *pentEntity; - if (pStartEntity != NULL) + if (pStartEntity) pentEntity = pStartEntity->edict(); else - pentEntity = NULL; + pentEntity = nullptr; pentEntity = FIND_ENTITY_BY_STRING(pentEntity, szKeyword, szValue); if (!FNullEnt(pentEntity)) @@ -406,7 +399,7 @@ CBaseEntity *UTIL_FindEntityByString_Old(CBaseEntity *pStartEntity, const char * return CBaseEntity::Instance(pentEntity); } - return NULL; + return nullptr; } CBaseEntity *EXT_FUNC UTIL_FindEntityByString(CBaseEntity *pStartEntity, const char *szKeyword, const char *szValue) @@ -417,7 +410,7 @@ CBaseEntity *EXT_FUNC UTIL_FindEntityByString(CBaseEntity *pStartEntity, const c if (pStartEntity) pentEntity = pStartEntity->edict(); else - pentEntity = NULL; + pentEntity = nullptr; startEntityIndex = ENTINDEX(pentEntity); @@ -434,11 +427,11 @@ CBaseEntity *EXT_FUNC UTIL_FindEntityByString(CBaseEntity *pStartEntity, const c if (!item->pev) { - item->lastHash = NULL; - return NULL; + item->lastHash = nullptr; + return nullptr; } - while (item->pev != NULL) + while (item->pev) { if (!Q_strcmp(STRING(item->pev->classname), szValue)) break; @@ -449,11 +442,11 @@ CBaseEntity *EXT_FUNC UTIL_FindEntityByString(CBaseEntity *pStartEntity, const c if (!item->pev) { - item->lastHash = NULL; - return NULL; + item->lastHash = nullptr; + return nullptr; } - if (pStartEntity != NULL) + if (pStartEntity) { if (item->lastHash && item->lastHash->pevIndex <= startEntityIndex) item = item->lastHash; @@ -470,8 +463,8 @@ CBaseEntity *EXT_FUNC UTIL_FindEntityByString(CBaseEntity *pStartEntity, const c if (item->pevIndex == startEntityIndex) { - stringsHashTable[ hash ].lastHash = NULL; - return NULL; + stringsHashTable[ hash ].lastHash = nullptr; + return nullptr; } } } @@ -487,7 +480,7 @@ CBaseEntity *EXT_FUNC UTIL_FindEntityByString(CBaseEntity *pStartEntity, const c return CBaseEntity::Instance(pentEntity); } - return NULL; + return nullptr; } CBaseEntity *UTIL_FindEntityByClassname(CBaseEntity *pStartEntity, const char *szName) @@ -502,13 +495,13 @@ CBaseEntity *UTIL_FindEntityByTargetname(CBaseEntity *pStartEntity, const char * CBaseEntity *UTIL_FindEntityGeneric(const char *szWhatever, const Vector &vecSrc, float flRadius) { - CBaseEntity *pSearch = NULL; - CBaseEntity *pEntity = UTIL_FindEntityByTargetname(NULL, szWhatever); - if (pEntity != NULL) + CBaseEntity *pSearch = nullptr; + CBaseEntity *pEntity = UTIL_FindEntityByTargetname(nullptr, szWhatever); + if (pEntity) return pEntity; float flMaxDist2 = flRadius * flRadius; - while ((pSearch = UTIL_FindEntityByClassname(pSearch, szWhatever)) != NULL) + while ((pSearch = UTIL_FindEntityByClassname(pSearch, szWhatever))) { float flDist2 = (pSearch->pev->origin - vecSrc).Length(); flDist2 = flDist2 * flDist2; @@ -606,10 +599,10 @@ void UTIL_ScreenShake(const Vector ¢er, float amplitude, float frequency, fl float localAmplitude; ScreenShake shake; - shake.duration = FixedUnsigned16(duration, 1<<12); - shake.frequency = FixedUnsigned16(frequency, 1<<8); + shake.duration = FixedUnsigned16(duration, (1<<12)); + shake.frequency = FixedUnsigned16(frequency, (1<<8)); - for (i = 1; i <= gpGlobals->maxClients; ++i) + for (i = 1; i <= gpGlobals->maxClients; i++) { CBaseEntity *pPlayer = UTIL_PlayerByIndex(i); if (!pPlayer || !(pPlayer->pev->flags & FL_ONGROUND)) @@ -631,7 +624,7 @@ void UTIL_ScreenShake(const Vector ¢er, float amplitude, float frequency, fl { shake.amplitude = FixedUnsigned16(localAmplitude, 1<<12); - MESSAGE_BEGIN(MSG_ONE, gmsgShake, NULL, pPlayer->edict()); + MESSAGE_BEGIN(MSG_ONE, gmsgShake, nullptr, pPlayer->edict()); WRITE_SHORT(shake.amplitude); WRITE_SHORT(shake.duration); WRITE_SHORT(shake.frequency); @@ -661,7 +654,7 @@ void UTIL_ScreenFadeWrite(const ScreenFade &fade, CBaseEntity *pEntity) if (!pEntity || !pEntity->IsNetClient()) return; - MESSAGE_BEGIN(MSG_ONE, gmsgFade, NULL, pEntity->edict()); + MESSAGE_BEGIN(MSG_ONE, gmsgFade, nullptr, pEntity->edict()); WRITE_SHORT(fade.duration); WRITE_SHORT(fade.holdTime); WRITE_SHORT(fade.fadeFlags); @@ -677,7 +670,7 @@ void UTIL_ScreenFadeAll(const Vector &color, float fadeTime, float fadeHold, int int i; ScreenFade fade; UTIL_ScreenFadeBuild(fade, color, fadeTime, fadeHold, alpha, flags); - for (i = 1; i <= gpGlobals->maxClients; ++i) + for (i = 1; i <= gpGlobals->maxClients; i++) { CBaseEntity *pPlayer = UTIL_PlayerByIndex(i); UTIL_ScreenFadeWrite(fade, pPlayer); @@ -696,51 +689,54 @@ void UTIL_HudMessage(CBaseEntity *pEntity, const hudtextparms_t &textparms, cons if (!pEntity || !pEntity->IsNetClient()) return; - MESSAGE_BEGIN(MSG_ONE, SVC_TEMPENTITY, NULL, pEntity->edict()); - WRITE_BYTE(TE_TEXTMESSAGE); - WRITE_BYTE(textparms.channel & 0xFF); - WRITE_SHORT(FixedSigned16(textparms.x,1<<13)); - WRITE_SHORT(FixedSigned16(textparms.y,1<<13)); - WRITE_BYTE(textparms.effect); - WRITE_BYTE(textparms.r1); - WRITE_BYTE(textparms.g1); - WRITE_BYTE(textparms.b1); - WRITE_BYTE(textparms.a1); - WRITE_BYTE(textparms.r2); - WRITE_BYTE(textparms.g2); - WRITE_BYTE(textparms.b2); - WRITE_BYTE(textparms.a2); - WRITE_SHORT(FixedUnsigned16(textparms.fadeinTime,1<<8)); - WRITE_SHORT(FixedUnsigned16(textparms.fadeoutTime,1<<8)); - WRITE_SHORT(FixedUnsigned16(textparms.holdTime,1<<8)); + MESSAGE_BEGIN(MSG_ONE, SVC_TEMPENTITY, nullptr, pEntity->edict()); + WRITE_BYTE(TE_TEXTMESSAGE); + WRITE_BYTE(textparms.channel & 0xFF); + WRITE_SHORT(FixedSigned16(textparms.x, (1<<13))); + WRITE_SHORT(FixedSigned16(textparms.y, (1<<13))); + WRITE_BYTE(textparms.effect); + WRITE_BYTE(textparms.r1); + WRITE_BYTE(textparms.g1); + WRITE_BYTE(textparms.b1); + WRITE_BYTE(textparms.a1); + WRITE_BYTE(textparms.r2); + WRITE_BYTE(textparms.g2); + WRITE_BYTE(textparms.b2); + WRITE_BYTE(textparms.a2); + WRITE_SHORT(FixedUnsigned16(textparms.fadeinTime, (1<<8))); + WRITE_SHORT(FixedUnsigned16(textparms.fadeoutTime, (1<<8))); + WRITE_SHORT(FixedUnsigned16(textparms.holdTime, (1<<8))); - if (textparms.effect == 2) - WRITE_SHORT(FixedUnsigned16(textparms.fxTime,1<<8)); + if (textparms.effect == 2) + WRITE_SHORT(FixedUnsigned16(textparms.fxTime, (1<<8))); - if (!pMessage) - WRITE_STRING(" "); //TODO: oh yeah - else - { - if (Q_strlen(pMessage) >= 512) - { - char tmp[512]; - Q_strncpy(tmp, pMessage, 511); - tmp[511] = 0; - WRITE_STRING(tmp); - } + if (!pMessage) + WRITE_STRING(" "); else - WRITE_STRING(pMessage); - } + { + if (Q_strlen(pMessage) >= 512) + { + char tmp[512]; + Q_strlcpy(tmp, pMessage); + WRITE_STRING(tmp); + } + else + { + WRITE_STRING(pMessage); + } + } MESSAGE_END(); } void UTIL_HudMessageAll(const hudtextparms_t &textparms, const char *pMessage) { - for (int i = 1; i <= gpGlobals->maxClients; ++i) + for (int i = 1; i <= gpGlobals->maxClients; i++) { CBaseEntity *pPlayer = UTIL_PlayerByIndex(i); if (pPlayer) + { UTIL_HudMessage(pPlayer, textparms, pMessage); + } } } @@ -762,7 +758,7 @@ void UTIL_ClientPrintAll(int msg_dest, const char *msg_name, const char *param1, void ClientPrint(entvars_t *client, int msg_dest, const char *msg_name, const char *param1, const char *param2, const char *param3, const char *param4) { - MESSAGE_BEGIN(MSG_ONE, gmsgTextMsg, NULL, client); + MESSAGE_BEGIN(MSG_ONE, gmsgTextMsg, nullptr, client); WRITE_BYTE(msg_dest); WRITE_STRING(msg_name); if (param1) @@ -776,15 +772,88 @@ void ClientPrint(entvars_t *client, int msg_dest, const char *msg_name, const ch MESSAGE_END(); } -NOXREF void UTIL_SayText(const char *pText, CBaseEntity *pEntity) +void UTIL_Log(const char *fmt, ...) { - if (pEntity->IsNetClient()) - { - MESSAGE_BEGIN(MSG_ONE, gmsgSayText, NULL, pEntity->edict()); - WRITE_BYTE(pEntity->entindex()); - WRITE_STRING(pText); - MESSAGE_END(); - } + va_list ap; + static char string[1024]; + + va_start(ap, fmt); + Q_vsnprintf(string, sizeof(string), fmt, ap); + va_end(ap); + + if (Q_strlen(string) < sizeof(string) - 2) + Q_strcat(string, "\n"); + else + string[Q_strlen(string) - 1] = '\n'; + + FILE *fp = fopen("regamedll.log", "at"); + fprintf(fp, "%s", string); + fclose(fp); +} + +void UTIL_ServerPrint(const char *fmt, ...) +{ + // Check is null, test the demo started before than searches pointer to refs + if (&g_engfuncs == nullptr || g_engfuncs.pfnServerPrint == nullptr) + return; + + static char string[1024]; + va_list ap; + va_start(ap, fmt); + Q_vsnprintf(string, sizeof(string), fmt, ap); + va_end(ap); + + if (Q_strlen(string) < sizeof(string) - 2) + Q_strcat(string, "\n"); + else + string[Q_strlen(string) - 1] = '\n'; + + SERVER_PRINT(string); +} + +void UTIL_PrintConsole(edict_t *pEdict, const char *fmt, ...) +{ + CBaseEntity *pEntity = GET_PRIVATE(pEdict); + if (!pEntity || !pEntity->IsNetClient()) + return; + + static char string[1024]; + + va_list ap; + va_start(ap, fmt); + Q_vsnprintf(string, sizeof(string), fmt, ap); + va_end(ap); + + if (Q_strlen(string) < sizeof(string) - 2) + Q_strcat(string, "\n"); + else + string[Q_strlen(string) - 1] = '\n'; + + ClientPrint(pEntity->pev, HUD_PRINTCONSOLE, string); +} + +void UTIL_SayText(edict_t *pEdict, const char *fmt, ...) +{ + CBaseEntity *pEntity = GET_PRIVATE(pEdict); + if (!pEntity || !pEntity->IsNetClient()) + return; + + static char string[1024]; + + va_list ap; + va_start(ap, fmt); + Q_vsnprintf(string, sizeof(string), fmt, ap); + va_end(ap); + + if (Q_strlen(string) < sizeof(string) - 2) + Q_strcat(string, "\n"); + else + string[Q_strlen(string) - 1] = '\n'; + + MESSAGE_BEGIN(MSG_ONE, gmsgSayText, nullptr, pEntity->edict()); + WRITE_BYTE(pEntity->entindex()); + WRITE_STRING(string); + MESSAGE_END(); } void UTIL_SayTextAll(const char *pText, CBaseEntity *pEntity) @@ -833,19 +902,19 @@ void UTIL_ShowMessageArgs(const char *pString, CBaseEntity *pPlayer, CUtlVector< if (args) { - MESSAGE_BEGIN(MSG_ONE, gmsgHudTextArgs, NULL, pPlayer->pev); + MESSAGE_BEGIN(MSG_ONE, gmsgHudTextArgs, nullptr, pPlayer->pev); WRITE_STRING(pString); WRITE_BYTE(isHint); WRITE_BYTE(args->Count()); - for (int i = 0; i < args->Count(); ++i) + for (int i = 0; i < args->Count(); i++) WRITE_STRING((*args)[i]); MESSAGE_END(); } else { - MESSAGE_BEGIN(MSG_ONE, gmsgHudText, NULL, pPlayer->pev); + MESSAGE_BEGIN(MSG_ONE, gmsgHudText, nullptr, pPlayer->pev); WRITE_STRING(pString); WRITE_BYTE(isHint); MESSAGE_END(); @@ -857,7 +926,7 @@ void UTIL_ShowMessage(const char *pString, CBaseEntity *pEntity, bool isHint) if (!pEntity || !pEntity->IsNetClient()) return; - MESSAGE_BEGIN(MSG_ONE, gmsgHudText, NULL, pEntity->edict()); + MESSAGE_BEGIN(MSG_ONE, gmsgHudText, nullptr, pEntity->edict()); WRITE_STRING(pString); WRITE_BYTE(int(isHint)); MESSAGE_END(); @@ -865,7 +934,7 @@ void UTIL_ShowMessage(const char *pString, CBaseEntity *pEntity, bool isHint) void UTIL_ShowMessageAll(const char *pString, bool isHint) { - for (int i = 1; i <= gpGlobals->maxClients; ++i) + for (int i = 1; i <= gpGlobals->maxClients; i++) { CBaseEntity *pPlayer = UTIL_PlayerByIndex(i); if (pPlayer) @@ -924,10 +993,11 @@ float UTIL_VecToYaw(const Vector &vec) void UTIL_SetOrigin(entvars_t *pev, const Vector &vecOrigin) { - edict_t *ent = ENT(pev); - - if (ent != NULL) - SET_ORIGIN(ent, vecOrigin); + edict_t *pEdict = ENT(pev); + if (pEdict) + { + SET_ORIGIN(pEdict, vecOrigin); + } } NOXREF void UTIL_ParticleEffect(const Vector &vecOrigin, const Vector &vecDirection, ULONG ulColor, ULONG ulCount) @@ -951,7 +1021,12 @@ float UTIL_Approach(float target, float value, float speed) float_precision UTIL_ApproachAngle(float target, float value, float speed) { target = UTIL_AngleMod(target); + +#ifdef REGAMEDLL_FIXES + value = UTIL_AngleMod(value); +#else value = UTIL_AngleMod(target); +#endif float delta = target - value; if (speed < 0.0f) @@ -1012,21 +1087,22 @@ NOXREF Vector UTIL_GetAimVector(edict_t *pent, float flSpeed) return tmp; } -int UTIL_IsMasterTriggered(string_t sMaster, CBaseEntity *pActivator) +bool UTIL_IsMasterTriggered(string_t sMaster, CBaseEntity *pActivator) { if (sMaster) { - edict_t *pentTarget = FIND_ENTITY_BY_TARGETNAME(NULL, STRING(sMaster)); + edict_t *pentTarget = FIND_ENTITY_BY_TARGETNAME(nullptr, STRING(sMaster)); if (!FNullEnt(pentTarget)) { CBaseEntity *pMaster = CBaseEntity::Instance(pentTarget); if (pMaster && (pMaster->ObjectCaps() & FCAP_MASTER)) - return pMaster->IsTriggered(pActivator); + return pMaster->IsTriggered(pActivator) != FALSE; } + ALERT(at_console, "Master was null or not a master!\n"); } - return 1; + return true; } BOOL UTIL_ShouldShowBlood(int color) @@ -1250,18 +1326,18 @@ void UTIL_Ricochet(const Vector &position, float scale) MESSAGE_END(); } -BOOL UTIL_TeamsMatch(const char *pTeamName1, const char *pTeamName2) +bool UTIL_TeamsMatch(const char *pTeamName1, const char *pTeamName2) { if (!g_pGameRules->IsTeamplay()) - return TRUE; + return true; if (*pTeamName1 != '\0' && *pTeamName2 != '\0') { if (!Q_stricmp(pTeamName1, pTeamName2)) - return TRUE; + return true; } - return FALSE; + return false; } void UTIL_StringToVector(float *pVector, const char *pString) @@ -1294,6 +1370,43 @@ void UTIL_StringToVector(float *pVector, const char *pString) pVector[j] = 0; } +void UTIL_StringToVector(Vector &vecIn, const char *pString, char cSeparator) +{ + return UTIL_StringToVectorND(vecIn, 3, pString, cSeparator); +} + +void UTIL_StringToVectorND(Vector &vecIn, int nCount, const char *pString, char cSeparator) +{ + int i; + char *pstr; + char *pfront; + char tempString[128]; + + Q_strlcpy(tempString, pString); + + pstr = tempString; + pfront = tempString; + + for (i = 0; i < nCount; i++) + { + vecIn[i] = Q_atof(pfront); + + while (*pstr && *pstr != cSeparator) + pstr++; + + if (!*pstr) + break; + + pstr++; + pfront = pstr; + } + + if (++i < nCount) + { + Q_memset(&vecIn[i], 0, sizeof(float) * (nCount - i)); + } +} + void UTIL_StringToIntArray(int *pVector, int count, const char *pString) { char *pstr; @@ -1374,6 +1487,7 @@ float UTIL_WaterLevel(const Vector &position, float minz, float maxz) diff = maxz - minz; } + return midUp.z; } @@ -1433,6 +1547,19 @@ void UTIL_Remove(CBaseEntity *pEntity) if (!pEntity) return; +#if 0 + // TODO: Some safe checks. + if (pEntity == VARS(eoNullEntity)) + return; + + if (pEntity->IsPlayer()) + { + pEntity->pev->health = 1.0f; + pEntity->TakeDamage(VARS(eoNullEntity), VARS(eoNullEntity), 9999, DMG_ALWAYSGIB); + return; + } +#endif + pEntity->UpdateOnRemove(); pEntity->pev->flags |= FL_KILLME; pEntity->pev->targetname = 0; @@ -1456,7 +1583,7 @@ void UTIL_PrecacheOther(const char *szClassname) } CBaseEntity *pEntity = CBaseEntity::Instance(VARS(pent)); - if (pEntity != NULL) + if (pEntity) { pEntity->Precache(); } @@ -1476,7 +1603,7 @@ void UTIL_RestartOther(const char *szClassname) void UTIL_ResetEntities() { edict_t *pEdict = INDEXENT(1); - for (int i = 1; i < gpGlobals->maxEntities; ++i, ++pEdict) + for (int i = 1; i < gpGlobals->maxEntities; i++, pEdict++) { if (pEdict->free) continue; @@ -1532,20 +1659,9 @@ NOXREF float UTIL_DotPoints(const Vector &vecSrc, const Vector &vecCheck, const return DotProduct(vec2LOS, (vecDir.Make2D())); } -void UTIL_StripToken(const char *pKey, char *pDest) -{ - int i = 0; - while (pKey[i] && pKey[i] != '#') - { - pDest[i] = pKey[i]; - ++i; - } - pDest[i] = '\0'; -} - CSaveRestoreBuffer::CSaveRestoreBuffer() { - m_pdata = NULL; + m_pdata = nullptr; } CSaveRestoreBuffer::CSaveRestoreBuffer(SAVERESTOREDATA *pdata) @@ -1584,7 +1700,7 @@ int CSaveRestoreBuffer::EntityIndex(edict_t *pentLookup) if (!m_pdata || !pentLookup) return -1; - for (int i = 0; i < m_pdata->tableCount; ++i) + for (int i = 0; i < m_pdata->tableCount; i++) { ENTITYTABLE *pTable = &m_pdata->pTable[i]; if (pTable->pent == pentLookup) @@ -1597,16 +1713,16 @@ int CSaveRestoreBuffer::EntityIndex(edict_t *pentLookup) edict_t *CSaveRestoreBuffer::EntityFromIndex(int entityIndex) { if (!m_pdata || entityIndex < 0) - return NULL; + return nullptr; - for (int i = 0; i < m_pdata->tableCount; ++i) + for (int i = 0; i < m_pdata->tableCount; i++) { ENTITYTABLE *pTable = &m_pdata->pTable[i]; if (pTable->id == entityIndex) return pTable->pent; } - return NULL; + return nullptr; } int CSaveRestoreBuffer::EntityFlagsSet(int entityIndex, int flags) @@ -1668,7 +1784,7 @@ unsigned int CSaveRestoreBuffer::HashString(const char *pszToken) unsigned short CSaveRestoreBuffer::TokenHash(const char *pszToken) { unsigned short hash = (unsigned short)(HashString(pszToken) % (unsigned)m_pdata->tokenCount); - for (int i = 0; i < m_pdata->tokenCount; ++i) + for (int i = 0; i < m_pdata->tokenCount; i++) { int index = hash + i; if (index >= m_pdata->tokenCount) @@ -1710,7 +1826,7 @@ void CSave::WriteTime(const char *pname, const float *data, int count) int i; BufferHeader(pname, sizeof(float) * count); - for (i = 0; i < count; ++i) + for (i = 0; i < count; i++) { float tmp = data[0]; @@ -1732,11 +1848,11 @@ void CSave::WriteString(const char *pname, const int *stringId, int count) int i; int size = 0; - for (i = 0; i < count; ++i) + for (i = 0; i < count; i++) size += Q_strlen(STRING(stringId[i])) + 1; BufferHeader(pname, size); - for (i = 0; i < count; ++i) + for (i = 0; i < count; i++) { const char *pString = STRING(stringId[i]); BufferData(pString, Q_strlen(pString) + 1); @@ -1767,7 +1883,7 @@ NOXREF void CSave::WritePositionVector(const char *pname, const Vector &value) void CSave::WritePositionVector(const char *pname, const float *value, int count) { BufferHeader(pname, sizeof(float) * 3 * count); - for (int i = 0; i < count; ++i) + for (int i = 0; i < count; i++) { Vector tmp(value[0], value[1], value[2]); @@ -1791,7 +1907,7 @@ void CSave::WriteFunction(const char *pname, void **data, int count) void EntvarsKeyvalue(entvars_t *pev, KeyValueData *pkvd) { - for (int i = 0; i < ARRAYSIZE(gEntvarsDescription); ++i) + for (int i = 0; i < ARRAYSIZE(gEntvarsDescription); i++) { TYPEDESCRIPTION *pField = &gEntvarsDescription[i]; @@ -1841,7 +1957,7 @@ int CSave::WriteFields(const char *pname, void *pBaseData, TYPEDESCRIPTION *pFie int i; int emptyCount = 0; - for (i = 0; i < fieldCount; ++i) + for (i = 0; i < fieldCount; i++) { void *pOutputData = ((char *)pBaseData + pFields[i].fieldOffset); if (DataEmpty((const char *)pOutputData, pFields[i].fieldSize * gSizes[pFields[i].fieldType])) @@ -1852,7 +1968,7 @@ int CSave::WriteFields(const char *pname, void *pBaseData, TYPEDESCRIPTION *pFie int actualCount = fieldCount - emptyCount; WriteInt(pname, &actualCount, 1); - for (i = 0; i < fieldCount; ++i) + for (i = 0; i < fieldCount; i++) { TYPEDESCRIPTION *pTest = &pFields[i]; void *pOutputData = ((char *)pBaseData + pTest->fieldOffset); @@ -1950,7 +2066,7 @@ NOXREF void CSave::BufferString(char *pdata, int len) int CSave::DataEmpty(const char *pdata, int size) { - for (int i = 0; i < size; ++i) + for (int i = 0; i < size; i++) { if (pdata[i]) return 0; @@ -2003,7 +2119,7 @@ int CRestore::ReadField(void *pBaseData, TYPEDESCRIPTION *pFields, int fieldCoun if (m_pdata->fUseLandmark) position = m_pdata->vecLandmarkOffset; } - for (int i = 0; i < fieldCount; ++i) + for (int i = 0; i < fieldCount; i++) { int fieldNumber = (i + startField) % fieldCount; TYPEDESCRIPTION *pTest = &pFields[fieldNumber]; @@ -2066,7 +2182,7 @@ int CRestore::ReadField(void *pBaseData, TYPEDESCRIPTION *pFields, int fieldCoun if (pent) *((entvars_t **)pOutputData) = VARS(pent); else - *((entvars_t **)pOutputData) = NULL; + *((entvars_t **)pOutputData) = nullptr; break; } @@ -2078,7 +2194,7 @@ int CRestore::ReadField(void *pBaseData, TYPEDESCRIPTION *pFields, int fieldCoun if (pent) *((CBaseEntity **)pOutputData) = CBaseEntity::Instance(pent); else - *((CBaseEntity **)pOutputData) = NULL; + *((CBaseEntity **)pOutputData) = nullptr; break; } @@ -2098,7 +2214,7 @@ int CRestore::ReadField(void *pBaseData, TYPEDESCRIPTION *pFields, int fieldCoun if (pent) *((EHANDLE *)pOutputData) = CBaseEntity::Instance(pent); else - *((EHANDLE *)pOutputData) = NULL; + *((EHANDLE *)pOutputData) = nullptr; break; } @@ -2181,12 +2297,12 @@ int CRestore::ReadFields(const char *pname, void *pBaseData, TYPEDESCRIPTION *pF int fileCount = ReadInt(); int lastField = 0; - for (i = 0; i < fieldCount; ++i) + for (i = 0; i < fieldCount; i++) { if (!m_global || !(pFields[i].flags & FTYPEDESC_GLOBAL)) Q_memset(((char *)pBaseData + pFields[i].fieldOffset), 0, pFields[i].fieldSize * gSizes[pFields[i].fieldType]); } - for (i = 0; i < fileCount; ++i) + for (i = 0; i < fileCount; i++) { HEADER header; BufferReadHeader(&header); @@ -2194,6 +2310,7 @@ int CRestore::ReadFields(const char *pname, void *pBaseData, TYPEDESCRIPTION *pF lastField = ReadField(pBaseData, pFields, fieldCount, lastField, header.size, m_pdata->pTokens[header.token], header.pData); lastField++; } + return 1; } @@ -2237,7 +2354,7 @@ NOXREF char *CRestore::ReadNamedString(const char *pName) char *CRestore::BufferPointer() { if (!m_pdata) - return NULL; + return nullptr; return m_pdata->pCurrentData; } @@ -2263,7 +2380,7 @@ void CRestore::BufferReadBytes(char *pOutput, int size) void CRestore::BufferSkipBytes(int bytes) { - BufferReadBytes(NULL, bytes); + BufferReadBytes(nullptr, bytes); } NOXREF int CRestore::BufferSkipZString() @@ -2349,14 +2466,14 @@ NOXREF int GetPlayerTeam(int index) return 0; } -bool UTIL_IsGame(const char *gameName) +bool UTIL_IsGame(const char *pszGameName) { #ifndef CSTRIKE - if (gameName != NULL) + if (pszGameName) { - static char gameDir[256]; - GET_GAME_DIR(gameDir); - return (Q_stricmp(gameDir, gameName) == 0); + char szGameDir[256]; + GET_GAME_DIR(szGameDir); + return (Q_stricmp(szGameDir, pszGameName) == 0); } #endif @@ -2395,16 +2512,16 @@ int UTIL_ReadFlags(const char *c) bool UTIL_AreBotsAllowed() { #ifdef REGAMEDLL_ADD - if (g_engfuncs.pfnEngCheckParm == NULL) + if (g_engfuncs.pfnEngCheckParm == nullptr) return false; #endif - if (g_bIsCzeroGame) + if (AreRunningCZero()) { #ifdef REGAMEDLL_ADD // If they pass in -nobots, don't allow bots. This is for people who host servers, to // allow them to disallow bots to enforce CPU limits. - int nobots = ENG_CHECK_PARM("-nobots", NULL); + int nobots = ENG_CHECK_PARM("-nobots", nullptr); if (nobots) { return false; @@ -2422,7 +2539,7 @@ bool UTIL_AreBotsAllowed() } // allow the using of bots for CS 1.6 - int bots = ENG_CHECK_PARM("-bots", NULL); + int bots = ENG_CHECK_PARM("-bots", nullptr); if (bots) { return true; @@ -2434,14 +2551,14 @@ bool UTIL_AreBotsAllowed() bool UTIL_AreHostagesImprov() { - if (g_bIsCzeroGame) + if (AreRunningCZero()) { return true; } #ifdef REGAMEDLL_ADD // someday in CS 1.6 - int improv = ENG_CHECK_PARM("-host-improv", NULL); + int improv = ENG_CHECK_PARM("-host-improv", nullptr); if (improv) { return true; @@ -2451,6 +2568,42 @@ bool UTIL_AreHostagesImprov() return false; } +int UTIL_GetNumPlayers() +{ + int nNumPlayers = 0; + for (int i = 1; i <= gpGlobals->maxClients; i++) + { + CBasePlayer *pPlayer = UTIL_PlayerByIndex(i); + if (pPlayer) + { + nNumPlayers++; + } + } + + return nNumPlayers; +} + +bool UTIL_IsSpawnPointOccupied(CBaseEntity *pSpot) +{ + if (!pSpot) + return false; + + const int maxList = 8; + CBaseEntity *pList[maxList]; + + Vector mins(pSpot->pev->origin + VEC_SPOT_HULL_MIN - 8.0); + Vector maxs(pSpot->pev->origin + VEC_SPOT_HULL_MAX + 8.0); + + int nCount = UTIL_EntitiesInBox(pList, maxList, mins, maxs, FL_MONSTER | FL_CLIENT); + for (int i = 0; i < nCount; i++) + { + if (pList[i]->pev->solid != SOLID_NOT) + return false; + } + + return false; +} + void MAKE_STRING_CLASS(const char *str, entvars_t *pev) { if (!FStringNull(pev->classname)) @@ -2471,9 +2624,58 @@ void NORETURN Sys_Error(const char *error, ...) vsnprintf(text, sizeof(text), error, argptr); va_end(argptr); + FILE *fl = fopen("regamedll_error.txt", "w"); + fprintf(fl, "%s\n", text); + fclose(fl); + CONSOLE_ECHO("FATAL ERROR (shutting down): %s\n", text); + //TerminateProcess(GetCurrentProcess(), 1); int *null = 0; *null = 0; exit(-1); } + +int UTIL_CountPlayersInBrushVolume(bool bOnlyAlive, CBaseEntity *pBrushEntity, int &playersInCount, int &playersOutCount, CPlayerInVolumeAdapter *pAdapter) +{ + playersInCount = 0; + playersOutCount = 0; + + if (pBrushEntity) + { + for (int i = 1; i <= gpGlobals->maxClients; i++) + { + CBasePlayer *pPlayer = UTIL_PlayerByIndex(i); + + if (!pPlayer || !pPlayer->IsInWorld()) + continue; + + if (bOnlyAlive && !pPlayer->IsAlive()) + continue; + + TraceResult trace; + int hullNumber = (pPlayer->pev->flags & FL_DUCKING) ? head_hull : human_hull; + UTIL_TraceModel(pPlayer->pev->origin, pPlayer->pev->origin, hullNumber, pBrushEntity->edict(), &trace); + + bool fInVolume = trace.fStartSolid > 0.0f; + if (fInVolume) + { + playersInCount++; + } + else + { + playersOutCount++; + } + + if (pAdapter) { + pAdapter->PlayerDetected(fInVolume, pPlayer); + } + } + } + else + { + playersOutCount = UTIL_GetNumPlayers(); + } + + return playersInCount + playersOutCount; +} diff --git a/regamedll/dlls/util.h b/regamedll/dlls/util.h index 2cfdeced..0869db8c 100644 --- a/regamedll/dlls/util.h +++ b/regamedll/dlls/util.h @@ -26,47 +26,30 @@ * */ -#ifndef UTIL_H -#define UTIL_H -#ifdef _WIN32 #pragma once -#endif #include "shake.h" #include "activity.h" #include "enginecallback.h" #include "utlvector.h" -#define eoNullEntity 0 // Testing the three types of "entity" for nullity -#define iStringNull 0 // Testing strings for nullity - -#define cchMapNameMost 32 - -#define CBSENTENCENAME_MAX 16 -#define CVOXFILESENTENCEMAX 1536 // max number of sentences in game. NOTE: this must match CVOXFILESENTENCEMAX in engine\sound.h - -#define GROUP_OP_AND 0 -#define GROUP_OP_NAND 1 - -extern globalvars_t *gpGlobals; - -#define STRING(offset) ((const char *)(gpGlobals->pStringBase + (unsigned int)(offset))) -#define MAKE_STRING(str) ((uint64)(str) - (uint64)(STRING(0))) +#define GROUP_OP_AND 0 +#define GROUP_OP_NAND 1 // Dot products for view cone checking - -#define VIEW_FIELD_FULL -1.0 // +-180 degrees -#define VIEW_FIELD_WIDE -0.7 // +-135 degrees 0.1 // +-85 degrees, used for full FOV checks -#define VIEW_FIELD_NARROW 0.7 // +-45 degrees, more narrow check used to set up ranged attacks +#define VIEW_FIELD_FULL -1.0 // +-180 degrees +#define VIEW_FIELD_WIDE -0.7 // +-135 degrees 0.1 // +-85 degrees, used for full FOV checks +#define VIEW_FIELD_NARROW 0.7 // +-45 degrees, more narrow check used to set up ranged attacks #define VIEW_FIELD_ULTRA_NARROW 0.9 // +-25 degrees, more narrow check used to set up ranged attacks -#define SND_SPAWNING (1<<8) // duplicated in protocol.h we're spawing, used in some cases for ambients -#define SND_STOP (1<<5) // duplicated in protocol.h stop sound -#define SND_CHANGE_VOL (1<<6) // duplicated in protocol.h change sound vol -#define SND_CHANGE_PITCH (1<<7) // duplicated in protocol.h change sound pitch +#define SND_STOP BIT(5) // duplicated in protocol.h stop sound +#define SND_CHANGE_VOL BIT(6) // duplicated in protocol.h change sound vol +#define SND_CHANGE_PITCH BIT(7) // duplicated in protocol.h change sound pitch +#define SND_SPAWNING BIT(8) // duplicated in protocol.h we're spawing, used in some cases for ambients // All monsters need this data -#define DONT_BLEED -1 +#define DONT_BLEED -1 +#define BLOOD_COLOR_DARKRED (byte)223 #define BLOOD_COLOR_RED (byte)247 #define BLOOD_COLOR_YELLOW (byte)195 #define BLOOD_COLOR_GREEN BLOOD_COLOR_YELLOW @@ -80,9 +63,11 @@ extern globalvars_t *gpGlobals; #define LANGUAGE_FRENCH 2 #define LANGUAGE_BRITISH 3 +#define SVC_NOP 1 +#define SVC_SOUND 6 #define SVC_TEMPENTITY 23 #define SVC_INTERMISSION 30 -#define SVC_CDTRACK 32 +#define SVC_CDTRACK 32 #define SVC_WEAPONANIM 35 #define SVC_ROOMTYPE 37 #define SVC_DIRECTOR 51 @@ -95,10 +80,16 @@ extern globalvars_t *gpGlobals; #define VEC_VIEW Vector(0, 0, 17) +#define VEC_SPOT_HULL_MIN Vector(-16, -16, 0) +#define VEC_SPOT_HULL_MAX Vector(16, 16, 72) + #define VEC_DUCK_HULL_MIN Vector(-16, -16, -18) #define VEC_DUCK_HULL_MAX Vector(16, 16, 32) #define VEC_DUCK_VIEW Vector(0, 0, 12) +#define PRECACHE_SOUND_ARRAY(a) \ + { for (int i = 0; i < ARRAYSIZE(a); ++i) PRECACHE_SOUND((char *)a[i]); } + #define PLAYBACK_EVENT(flags, who, index)\ PLAYBACK_EVENT_FULL(flags, who, index, 0, (float *)&g_vecZero, (float *)&g_vecZero, 0.0, 0.0, 0, 0, 0, 0) @@ -112,6 +103,9 @@ extern globalvars_t *gpGlobals; GetClassPtr((DLLClassName *)pev);\ } +const EOFFSET eoNullEntity = (EOFFSET)0; // Testing the three types of "entity" for nullity +const string_t iStringNull = (string_t)0; // Testing strings for nullity + class UTIL_GroupTrace { public: @@ -134,7 +128,7 @@ inline EOFFSET OFFSET(const entvars_t *pev) { return OFFSET(ENT(pev)); } inline entvars_t *VARS(edict_t *pent) { if (!pent) - return NULL; + return nullptr; return &pent->v; } @@ -154,15 +148,17 @@ inline edict_t *INDEXENT(int iEdictNum) { return (*g_engfuncs.pfnPEntityOfEntInd #endif // INDEXENT inline void MESSAGE_BEGIN(int msg_dest, int msg_type, const float *pOrigin, entvars_t *ent) { MESSAGE_BEGIN(msg_dest, msg_type, pOrigin, ENT(ent)); } -inline BOOL FNullEnt(EOFFSET eoffset) { return (eoffset == 0); } -inline BOOL FNullEnt(entvars_t *pev) { return (pev == NULL || FNullEnt(OFFSET(pev))); } -inline BOOL FNullEnt(const edict_t *pent) { return (pent == NULL || FNullEnt(OFFSET(pent))); } -inline BOOL FStringNull(int iString) { return (iString == iStringNull); } -inline BOOL FStrEq(const char *sz1, const char *sz2) { return (Q_strcmp(sz1, sz2) == 0); } -inline BOOL FClassnameIs(entvars_t *pev, const char *szClassname) { return FStrEq(STRING(pev->classname), szClassname); } -inline BOOL FClassnameIs(edict_t *pent, const char *szClassname) { return FStrEq(STRING(VARS(pent)->classname), szClassname); } +inline bool FNullEnt(EOFFSET eoffset) { return (eoffset == 0); } +inline bool FNullEnt(entvars_t *pev) { return (pev == nullptr || FNullEnt(OFFSET(pev))); } +inline bool FNullEnt(const edict_t *pent) { return (pent == nullptr || pent->free || FNullEnt(OFFSET(pent))); } +inline bool FStringNull(string_t iString) { return (iString == iStringNull); } +inline bool FStrEq(const char *sz1, const char *sz2) { return (Q_strcmp(sz1, sz2) == 0); } +inline bool FClassnameIs(entvars_t *pev, const char *szClassname) { return FStrEq(STRING(pev->classname), szClassname); } +inline bool FClassnameIs(edict_t *pent, const char *szClassname) { return FStrEq(STRING(VARS(pent)->classname), szClassname); } inline void UTIL_MakeVectorsPrivate(Vector vecAngles, float *p_vForward, float *p_vRight, float *p_vUp) { g_engfuncs.pfnAngleVectors(vecAngles, p_vForward, p_vRight, p_vUp); } +#include "ehandle.h" + extern void EMIT_SOUND_DYN(edict_t *entity, int channel, const char *sample, float volume, float attenuation, int flags, int pitch); // NOTE: use EMIT_SOUND_DYN to set the pitch of a sound. Pitch of 100 @@ -180,6 +176,16 @@ inline void STOP_SOUND(edict_t *entity, int channel, const char *sample) EMIT_SOUND_DYN(entity, channel, sample, 0, 0, SND_STOP, PITCH_NORM); } +inline void EMIT_SOUND_MSG(edict_t *entity, int msg_type, int channel, const char *sample, float volume, float attenuation, int flags, int pitch = PITCH_NORM, Vector vecOrigin = g_vecZero, edict_t *player = nullptr) +{ + BUILD_SOUND_MSG(entity, channel, sample, (volume * 255.0f), attenuation, flags, pitch, msg_type, SVC_NOP, vecOrigin, player); +} + +inline void STOP_SOUND_MSG(edict_t *entity, int msg_type, int channel, const char *sample, edict_t *player) +{ + BUILD_SOUND_MSG(entity, channel, sample, 0, 0, SND_STOP, PITCH_NORM, msg_type, SVC_NOP, g_vecZero, player); +} + class CBaseEntity; class CBasePlayer; class CBasePlayerItem; @@ -222,9 +228,12 @@ void UTIL_ScreenFadeAll(const Vector &color, float fadeTime, float fadeHold, int void UTIL_ScreenFade(CBaseEntity *pEntity, const Vector &color, float fadeTime, float fadeHold = 0.0f, int alpha = 0, int flags = 0); void UTIL_HudMessage(CBaseEntity *pEntity, const hudtextparms_t &textparms, const char *pMessage); void UTIL_HudMessageAll(const hudtextparms_t &textparms, const char *pMessage); -void UTIL_ClientPrintAll(int msg_dest, const char *msg_name, const char *param1 = NULL, const char *param2 = NULL, const char *param3 = NULL, const char *param4 = NULL); -void ClientPrint(entvars_t *client, int msg_dest, const char *msg_name, const char *param1 = NULL, const char *param2 = NULL, const char *param3 = NULL, const char *param4 = NULL); -void UTIL_SayText(const char *pText, CBaseEntity *pEntity); +void UTIL_ClientPrintAll(int msg_dest, const char *msg_name, const char *param1 = nullptr, const char *param2 = nullptr, const char *param3 = nullptr, const char *param4 = nullptr); +void ClientPrint(entvars_t *client, int msg_dest, const char *msg_name, const char *param1 = nullptr, const char *param2 = nullptr, const char *param3 = nullptr, const char *param4 = nullptr); +void UTIL_Log(const char *fmt, ...); +void UTIL_ServerPrint(const char *fmt, ...); +void UTIL_PrintConsole(edict_t *pEdict, const char *fmt, ...); +void UTIL_SayText(CBaseEntity *pEntity, const char *fmt, ...); void UTIL_SayTextAll(const char *pText, CBaseEntity *pEntity); char *UTIL_dtos1(int d); char *UTIL_dtos2(int d); @@ -248,7 +257,7 @@ float_precision UTIL_AngleDistance(float next, float cur); float UTIL_SplineFraction(float value, float scale); char *UTIL_VarArgs(char *format, ...); Vector UTIL_GetAimVector(edict_t *pent, float flSpeed); -int UTIL_IsMasterTriggered(string_t sMaster, CBaseEntity *pActivator); +bool UTIL_IsMasterTriggered(string_t sMaster, CBaseEntity *pActivator); BOOL UTIL_ShouldShowBlood(int color); int UTIL_PointContents(const Vector &vec); void UTIL_BloodStream(const Vector &origin, const Vector &direction, int color, int amount); @@ -260,8 +269,10 @@ void UTIL_PlayerDecalTrace(TraceResult *pTrace, int playernum, int decalNumber, void UTIL_GunshotDecalTrace(TraceResult *pTrace, int decalNumber, bool ClientOnly, entvars_t *pShooter); void UTIL_Sparks(const Vector &position); void UTIL_Ricochet(const Vector &position, float scale); -BOOL UTIL_TeamsMatch(const char *pTeamName1, const char *pTeamName2); +bool UTIL_TeamsMatch(const char *pTeamName1, const char *pTeamName2); void UTIL_StringToVector(float *pVector, const char *pString); +void UTIL_StringToVector(Vector &vecIn, const char *pString, char cSeparator); +void UTIL_StringToVectorND(Vector &vecIn, int nCount, const char *pString, char cSeparator); void UTIL_StringToIntArray(int *pVector, int count, const char *pString); Vector UTIL_ClampVectorToBox(const Vector &input, const Vector &clampSize); float UTIL_WaterLevel(const Vector &position, float minz, float maxz); @@ -275,19 +286,73 @@ void UTIL_ResetEntities(); void UTIL_RemoveOther(const char *szClassname, int nCount = 0); void UTIL_LogPrintf(const char *fmt, ...); float UTIL_DotPoints(const Vector &vecSrc, const Vector &vecCheck, const Vector &vecDir); -void UTIL_StripToken(const char *pKey, char *pDest); void EntvarsKeyvalue(entvars_t *pev, KeyValueData *pkvd); char UTIL_TextureHit(TraceResult *ptr, Vector vecSrc, Vector vecEnd); int GetPlayerTeam(int index); -bool UTIL_IsGame(const char *gameName); +bool UTIL_IsGame(const char *pszGameName); float_precision UTIL_GetPlayerGaitYaw(int playerIndex); int UTIL_ReadFlags(const char *c); bool UTIL_AreBotsAllowed(); bool UTIL_AreHostagesImprov(); +int UTIL_GetNumPlayers(); +bool UTIL_IsSpawnPointOccupied(CBaseEntity *pSpot); void MAKE_STRING_CLASS(const char *str, entvars_t *pev); void NORETURN Sys_Error(const char *error, ...); +// Inlines +template +inline T *UTIL_FindEntityByClassname(T *pStartEntity, const char *szName) +{ + return (T *)UTIL_FindEntityByString(pStartEntity, "classname", szName); +} + +template +inline T *UTIL_FindEntityByTargetname(T *pStartEntity, const char *szName) +{ + return (T *)UTIL_FindEntityByString(pStartEntity, "targetname", szName); +} + +template +void UTIL_StripToken(const char *pKey, char (&pDest)[nSize]) +{ + int i = 0; + while (i < nSize && pKey[i] && pKey[i] != '#') + { + pDest[i] = pKey[i]; + i++; + } + + pDest[i] = '\0'; +} + +class CPlayerInVolumeAdapter +{ +public: + virtual ~CPlayerInVolumeAdapter() {}; + virtual void PlayerDetected(const bool fInVolume, CBasePlayer *pPlayer) = 0; +}; + +int UTIL_CountPlayersInBrushVolume(bool bOnlyAlive, CBaseEntity *pBrushEntity, int &playersInCount, int &playersOutCount, CPlayerInVolumeAdapter *pAdapter); + +inline float_precision UTIL_FixupAngle(float_precision v) +{ + float_precision angle = v; + + while (angle < 0) + angle += 360; + + while (angle > 360) + angle -= 360; + + return angle; +} + +inline void UTIL_FixupAngles(Vector &v) +{ + v.x = UTIL_FixupAngle(v.x); + v.y = UTIL_FixupAngle(v.y); + v.z = UTIL_FixupAngle(v.z); +} + extern int g_groupmask; extern int g_groupop; - -#endif // UTIL_H diff --git a/regamedll/dlls/vector.h b/regamedll/dlls/vector.h index b20b7bb4..7fb93a47 100644 --- a/regamedll/dlls/vector.h +++ b/regamedll/dlls/vector.h @@ -26,70 +26,57 @@ * */ -#ifndef VECTOR_H -#define VECTOR_H -#ifdef _WIN32 #pragma once -#endif +// Used for many pathfinding and many other operations that are treated as planar rather than 3D. class Vector2D { public: - vec_t x, y; + // Construction/destruction Vector2D() : x(), y() {} Vector2D(float X, float Y) : x(X), y(Y) {} - Vector2D(const Vector2D &v) { *(int*)&x = *(int*)&v.x; *(int*)&y = *(int*)&v.y; } - Vector2D operator+(const Vector2D &v) const - { - return Vector2D(x + v.x, y + v.y); - } - Vector2D operator-(const Vector2D &v) const - { - return Vector2D(x - v.x, y - v.y); - } + Vector2D(const Vector2D &v) { *(int *)&x = *(int *)&v.x; *(int *)&y = *(int *)&v.y; } + + // Operators + inline decltype(auto) operator-() const { return Vector2D(-x, -y); } + inline bool operator==(const Vector2D &v) const { return x == v.x && y == v.y; } + inline bool operator!=(const Vector2D &v) const { return !(*this == v); } + + inline decltype(auto) operator+(const Vector2D &v) const { return Vector2D(x + v.x, y + v.y); } + inline decltype(auto) operator-(const Vector2D &v) const { return Vector2D(x - v.x, y - v.y); } + inline decltype(auto) operator*(const Vector2D &v) const { return Vector2D(x * v.x, y * v.y); } + inline decltype(auto) operator/(const Vector2D &v) const { return Vector2D(x / v.x, y / v.y); } + + inline decltype(auto) operator+=(const Vector2D &v) { return (*this = *this + v); } + inline decltype(auto) operator-=(const Vector2D &v) { return (*this = *this - v); } + inline decltype(auto) operator*=(const Vector2D &v) { return (*this = *this * v); } + inline decltype(auto) operator/=(const Vector2D &v) { return (*this = *this / v); } + + inline decltype(auto) operator+(float fl) const { return Vector2D(x + fl, y + fl); } + inline decltype(auto) operator-(float fl) const { return Vector2D(x - fl, y - fl); } + + // TODO: FIX ME!! #ifdef PLAY_GAMEDLL - Vector2D operator*(float_precision fl) const - { - return Vector2D(vec_t(x * fl), vec_t(y * fl)); - } - Vector2D operator/(float_precision fl) const - { - return Vector2D(vec_t(x / fl), vec_t(y / fl)); - } - Vector2D operator/=(float_precision fl) const - { - return Vector2D(vec_t(x / fl), vec_t(y / fl)); - } + inline decltype(auto) operator*(float fl) const { return Vector2D(vec_t(x * fl), vec_t(y * fl)); } + inline decltype(auto) operator/(float fl) const { return Vector2D(vec_t(x / fl), vec_t(y / fl)); } #else - Vector2D operator*(float fl) const - { - return Vector2D(x * fl, y * fl); - } - Vector2D operator/(float fl) const - { - return Vector2D(x / fl, y / fl); - } - Vector2D operator/=(float fl) const - { - return Vector2D(x / fl, y / fl); - } -#endif // PLAY_GAMEDLL - float_precision Length() const - { - return Q_sqrt(float_precision(x * x + y * y)); - } - float LengthSquared() const - { - return (x * x + y * y); - } - operator float*() - { - return &x; - } - operator const float*() const - { - return &x; - } + inline decltype(auto) operator*(float fl) const { return Vector2D(x * fl, y * fl); } + inline decltype(auto) operator/(float fl) const { return Vector2D(x / fl, y / fl); } +#endif + + inline decltype(auto) operator+=(float fl) { return (*this = *this + fl); } + inline decltype(auto) operator-=(float fl) { return (*this = *this - fl); } + inline decltype(auto) operator*=(float fl) { return (*this = *this * fl); } + inline decltype(auto) operator/=(float fl) { return (*this = *this / fl); } + + // Methods + inline void CopyToArray(float *rgfl) const { *(int *)&rgfl[0] = *(int *)&x; *(int *)&rgfl[1] = *(int *)&y; } + inline float_precision Length() const { return Q_sqrt(float_precision(x * x + y * y)); } // Get the vector's magnitude + inline float LengthSquared() const { return (x * x + y * y); } // Get the vector's magnitude squared + + operator float*() { return &x; } // Vectors will now automatically convert to float * when needed + operator const float*() const { return &x; } // Vectors will now automatically convert to float * when needed + Vector2D Normalize() const { float_precision flLen = Length(); @@ -104,14 +91,8 @@ public: return Vector2D(x * flLen, y * flLen); #endif // PLAY_GAMEDLL } - bool IsLengthLessThan(float length) const - { - return (LengthSquared() < length * length); - } - bool IsLengthGreaterThan(float length) const - { - return (LengthSquared() > length * length); - } + inline bool IsLengthLessThan (float length) const { return (LengthSquared() < length * length); } + inline bool IsLengthGreaterThan(float length) const { return (LengthSquared() > length * length); } float_precision NormalizeInPlace() { float_precision flLen = Length(); @@ -132,6 +113,9 @@ public: return (x > -tolerance && x < tolerance && y > -tolerance && y < tolerance); } + + // Members + vec_t x, y; }; inline float_precision DotProduct(const Vector2D &a, const Vector2D &b) @@ -144,67 +128,57 @@ inline Vector2D operator*(float fl, const Vector2D &v) return v * fl; } +// 3D Vector +// Same data-layout as engine's vec3_t, which is a vec_t[3] class Vector { public: - vec_t x, y, z; + // Construction/destruction Vector() : x(), y(), z() {} Vector(float X, float Y, float Z) : x(X), y(Y), z(Z) {} - Vector(const Vector &v) { *(int*)&x = *(int*)&v.x; *(int*)&y = *(int*)&v.y; *(int*)&z = *(int*)&v.z; } - Vector(const float rgfl[3]) { *(int*)&x = *(int*)&rgfl[0]; *(int*)&y = *(int*)&rgfl[1]; *(int*)&z = *(int*)&rgfl[2]; } - Vector operator-() const - { - return Vector(-x, -y, -z); - } - int operator==(const Vector &v) const - { - return x == v.x && y == v.y && z == v.z; - } - int operator!=(const Vector &v) const - { - return !(*this == v); - } - Vector operator+(const Vector &v) const - { - return Vector(x + v.x, y + v.y, z + v.z); - } - Vector operator-(const Vector &v) const - { - return Vector(x - v.x, y - v.y, z - v.z); - } + Vector(const Vector &v) { *(int *)&x = *(int *)&v.x; *(int *)&y = *(int *)&v.y; *(int *)&z = *(int *)&v.z; } + Vector(const float rgfl[3]) { *(int *)&x = *(int *)&rgfl[0]; *(int *)&y = *(int *)&rgfl[1]; *(int *)&z = *(int *)&rgfl[2]; } + + // Operators + inline decltype(auto) operator-() const { return Vector(-x, -y, -z); } + inline bool operator==(const Vector &v) const { return x == v.x && y == v.y && z == v.z; } + inline bool operator!=(const Vector &v) const { return !(*this == v); } + + inline decltype(auto) operator+(const Vector &v) const { return Vector(x + v.x, y + v.y, z + v.z); } + inline decltype(auto) operator-(const Vector &v) const { return Vector(x - v.x, y - v.y, z - v.z); } + inline decltype(auto) operator*(const Vector &v) const { return Vector(x * v.x, y * v.y, z * v.z); } + inline decltype(auto) operator/(const Vector &v) const { return Vector(x / v.x, y / v.y, z / v.z); } + + inline decltype(auto) operator+=(const Vector &v) { return (*this = *this + v); } + inline decltype(auto) operator-=(const Vector &v) { return (*this = *this - v); } + inline decltype(auto) operator*=(const Vector &v) { return (*this = *this * v); } + inline decltype(auto) operator/=(const Vector &v) { return (*this = *this / v); } + + inline decltype(auto) operator+(float fl) const { return Vector(x + fl, y + fl, z + fl); } + inline decltype(auto) operator-(float fl) const { return Vector(x - fl, y - fl, z - fl); } + + // TODO: FIX ME!! #ifdef PLAY_GAMEDLL - Vector operator*(float_precision fl) const - { - return Vector(vec_t(x * fl), vec_t(y * fl), vec_t(z * fl)); - } - Vector operator/(float_precision fl) const - { - return Vector(vec_t(x / fl), vec_t(y / fl), vec_t(z / fl)); - } - Vector operator/=(float_precision fl) const - { - return Vector(vec_t(x / fl), vec_t(y / fl), vec_t(z / fl)); - } + inline decltype(auto) operator*(float fl) const { return Vector(vec_t(x * fl), vec_t(y * fl), vec_t(z * fl)); } + inline decltype(auto) operator/(float fl) const { return Vector(vec_t(x / fl), vec_t(y / fl), vec_t(z / fl)); } #else - Vector operator*(float fl) const - { - return Vector(x * fl, y * fl, z * fl); - } - Vector operator/(float fl) const - { - return Vector(x / fl, y / fl, z / fl); - } - Vector operator/=(float fl) const - { - return Vector(x / fl, y / fl, z / fl); - } -#endif // PLAY_GAMEDLL + inline decltype(auto) operator*(float fl) const { return Vector(x * fl, y * fl, z * fl); } + inline decltype(auto) operator/(float fl) const { return Vector(x / fl, y / fl, z / fl); } +#endif + + inline decltype(auto) operator+=(float fl) { return (*this = *this + fl); } + inline decltype(auto) operator-=(float fl) { return (*this = *this - fl); } + inline decltype(auto) operator*=(float fl) { return (*this = *this * fl); } + inline decltype(auto) operator/=(float fl) { return (*this = *this / fl); } + void CopyToArray(float *rgfl) const { - *(int*)&rgfl[0] = *(int*)&x; - *(int*)&rgfl[1] = *(int*)&y; - *(int*)&rgfl[2] = *(int*)&z; + *(int *)&rgfl[0] = *(int *)&x; + *(int *)&rgfl[1] = *(int *)&y; + *(int *)&rgfl[2] = *(int *)&z; } + + // Get the vector's magnitude float_precision Length() const { float_precision x1 = float_precision(x); @@ -213,18 +187,13 @@ public: return Q_sqrt(x1 * x1 + y1 * y1 + z1 * z1); } - float_precision LengthSquared() const - { - return (x * x + y * y + z * z); - } - operator float*() - { - return &x; - } - operator const float*() const - { - return &x; - } + + // Get the vector's magnitude squared + float_precision LengthSquared() const { return (x * x + y * y + z * z); } + + operator float*() { return &x; } // Vectors will now automatically convert to float * when needed + operator const float*() const { return &x; } // Vectors will now automatically convert to float * when needed + #ifndef PLAY_GAMEDLL Vector Normalize() const { @@ -263,22 +232,16 @@ public: Vector2D Make2D() const { Vector2D Vec2; - *(int*)&Vec2.x = *(int*)&x; - *(int*)&Vec2.y = *(int*)&y; + *(int *)&Vec2.x = *(int *)&x; + *(int *)&Vec2.y = *(int *)&y; return Vec2; } - float_precision Length2D() const - { - return Q_sqrt(float_precision(x * x + y * y)); - } - bool IsLengthLessThan(float length) const - { - return (LengthSquared() < length * length); - } - bool IsLengthGreaterThan(float length) const - { - return (LengthSquared() > length * length); - } + + float_precision Length2D() const { return Q_sqrt(float_precision(x * x + y * y)); } + + inline bool IsLengthLessThan (float length) const { return (LengthSquared() < length * length); } + inline bool IsLengthGreaterThan(float length) const { return (LengthSquared() > length * length); } + #ifdef PLAY_GAMEDLL template float_precision NormalizeInPlace() @@ -325,6 +288,9 @@ public: y > -tolerance && y < tolerance && z > -tolerance && z < tolerance); } + + // Members + vec_t x, y, z; }; inline Vector operator*(float fl, const Vector &v) @@ -447,5 +413,3 @@ inline Vector NormalizeMulScalar(Vector vec, float scalar) return Vector(vec_t(floatX * scalar), vec_t(floatY * scalar), 0); } #endif // PLAY_GAMEDLL - -#endif // VECTOR_H diff --git a/regamedll/dlls/vehicle.cpp b/regamedll/dlls/vehicle.cpp index e0d6496f..e2649ebe 100644 --- a/regamedll/dlls/vehicle.cpp +++ b/regamedll/dlls/vehicle.cpp @@ -23,24 +23,6 @@ TYPEDESCRIPTION CFuncVehicle::m_SaveData[] = #endif -float_precision Fix2(float angle) -{ - while (angle < 0) - angle += 360; - - while (angle > 360) - angle -= 360; - - return angle; -} - -void FixupAngles2(Vector &v) -{ - v.x = Fix2(v.x); - v.y = Fix2(v.y); - v.z = Fix2(v.z); -} - IMPLEMENT_SAVERESTORE(CFuncVehicle, CBaseEntity) LINK_ENTITY_TO_CLASS(func_vehicle, CFuncVehicle, CCSFuncVehicle) @@ -97,7 +79,9 @@ void CFuncVehicle::KeyValue(KeyValueData *pkvd) pkvd->fHandled = TRUE; } else + { CBaseEntity::KeyValue(pkvd); + } } void CFuncVehicle::NextThink(float thinkTime, BOOL alwaysThink) @@ -596,8 +580,8 @@ void CFuncVehicle::Next() vTargetAngle.y += m_iTurnAngle; } - FixupAngles2(vTargetAngle); - FixupAngles2(vAngle); + UTIL_FixupAngles(vTargetAngle); + UTIL_FixupAngles(vAngle); vx = UTIL_AngleDistance(vTargetAngle.x, vAngle.x); vy = UTIL_AngleDistance(vTargetAngle.y, vAngle.y); @@ -667,7 +651,7 @@ void CFuncVehicle::DeadEnd() CPathTrack *pTrack = m_ppath; ALERT(at_aiconsole, "TRAIN(%s): Dead end ", STRING(pev->targetname)); - if (pTrack != NULL) + if (pTrack) { CPathTrack *pNext; @@ -676,33 +660,31 @@ void CFuncVehicle::DeadEnd() do { pNext = pTrack->ValidPath(pTrack->GetPrevious(), TRUE); - - if (pNext != NULL) + if (pNext) { pTrack = pNext; } } - while (pNext != NULL); + while (pNext); } else { do { pNext = pTrack->ValidPath(pTrack->GetNext(), TRUE); - - if (pNext != NULL) + if (pNext) { pTrack = pNext; } } - while (pNext != NULL); + while (pNext); } } pev->velocity = g_vecZero; pev->avelocity = g_vecZero; - if (pTrack != NULL) + if (pTrack) { ALERT(at_aiconsole, "at %s\n", STRING(pTrack->pev->targetname)); @@ -742,7 +724,7 @@ BOOL CFuncVehicle::OnControls(entvars_t *pevTest) void CFuncVehicle::Find() { - m_ppath = CPathTrack::Instance(FIND_ENTITY_BY_TARGETNAME(NULL, STRING(pev->target))); + m_ppath = CPathTrack::Instance(FIND_ENTITY_BY_TARGETNAME(nullptr, STRING(pev->target))); if (!m_ppath) return; @@ -752,7 +734,7 @@ void CFuncVehicle::Find() if (!FClassnameIs(pevTarget, "path_track")) { ALERT(at_error, "func_track_train must be on a path of path_track\n"); - m_ppath = NULL; + m_ppath = nullptr; return; } @@ -781,12 +763,12 @@ void CFuncVehicle::Find() void CFuncVehicle::NearestPath() { - CBaseEntity *pTrack = NULL; - CBaseEntity *pNearest = NULL; + CBaseEntity *pTrack = nullptr; + CBaseEntity *pNearest = nullptr; float_precision dist; float closest = 1024; - while ((pTrack = UTIL_FindEntityInSphere(pTrack, pev->origin, 1024)) != NULL) + while ((pTrack = UTIL_FindEntityInSphere(pTrack, pev->origin, 1024))) { if (!(pTrack->pev->flags & (FL_CLIENT | FL_MONSTER)) && FClassnameIs(pTrack->pev, "path_track")) { @@ -808,9 +790,9 @@ void CFuncVehicle::NearestPath() } ALERT(at_aiconsole, "TRAIN: %s, Nearest track is %s\n", STRING(pev->targetname), STRING(pNearest->pev->targetname)); - pTrack = ((CPathTrack *)pNearest)->GetNext(); - if (pTrack != NULL) + pTrack = ((CPathTrack *)pNearest)->GetNext(); + if (pTrack) { if ((pev->origin - pTrack->pev->origin).Length() < (pev->origin - pNearest->pev->origin).Length()) { @@ -839,7 +821,7 @@ CFuncVehicle *CFuncVehicle::Instance(edict_t *pent) return (CFuncVehicle *)GET_PRIVATE(pent); } - return NULL; + return nullptr; } int CFuncVehicle::Classify() @@ -908,7 +890,7 @@ void CFuncVehicle::Restart() m_flTurnStartTime = -1; m_flUpdateSound = -1; m_dir = 1; - m_pDriver = NULL; + m_pDriver = nullptr; if (FStringNull(pev->target)) { @@ -947,7 +929,7 @@ LINK_ENTITY_TO_CLASS(func_vehiclecontrols, CFuncVehicleControls, CCSFuncVehicleC void CFuncVehicleControls::Find() { - edict_t *pTarget = NULL; + edict_t *pTarget = nullptr; do { diff --git a/regamedll/dlls/vehicle.h b/regamedll/dlls/vehicle.h index 87e40227..9b494c60 100644 --- a/regamedll/dlls/vehicle.h +++ b/regamedll/dlls/vehicle.h @@ -26,30 +26,26 @@ * */ -#ifndef VEHICLE_H -#define VEHICLE_H -#ifdef _WIN32 #pragma once -#endif -#define VEHICLE_SPEED0_ACCELERATION 0.005000000000000000 -#define VEHICLE_SPEED1_ACCELERATION 0.002142857142857143 -#define VEHICLE_SPEED2_ACCELERATION 0.003333333333333334 -#define VEHICLE_SPEED3_ACCELERATION 0.004166666666666667 -#define VEHICLE_SPEED4_ACCELERATION 0.004000000000000000 -#define VEHICLE_SPEED5_ACCELERATION 0.003800000000000000 -#define VEHICLE_SPEED6_ACCELERATION 0.004500000000000000 -#define VEHICLE_SPEED7_ACCELERATION 0.004250000000000000 -#define VEHICLE_SPEED8_ACCELERATION 0.002666666666666667 -#define VEHICLE_SPEED9_ACCELERATION 0.002285714285714286 -#define VEHICLE_SPEED10_ACCELERATION 0.001875000000000000 -#define VEHICLE_SPEED11_ACCELERATION 0.001444444444444444 -#define VEHICLE_SPEED12_ACCELERATION 0.001200000000000000 -#define VEHICLE_SPEED13_ACCELERATION 0.000916666666666666 +#define VEHICLE_SPEED0_ACCELERATION 0.005000000000000000 +#define VEHICLE_SPEED1_ACCELERATION 0.002142857142857143 +#define VEHICLE_SPEED2_ACCELERATION 0.003333333333333334 +#define VEHICLE_SPEED3_ACCELERATION 0.004166666666666667 +#define VEHICLE_SPEED4_ACCELERATION 0.004000000000000000 +#define VEHICLE_SPEED5_ACCELERATION 0.003800000000000000 +#define VEHICLE_SPEED6_ACCELERATION 0.004500000000000000 +#define VEHICLE_SPEED7_ACCELERATION 0.004250000000000000 +#define VEHICLE_SPEED8_ACCELERATION 0.002666666666666667 +#define VEHICLE_SPEED9_ACCELERATION 0.002285714285714286 +#define VEHICLE_SPEED10_ACCELERATION 0.001875000000000000 +#define VEHICLE_SPEED11_ACCELERATION 0.001444444444444444 +#define VEHICLE_SPEED12_ACCELERATION 0.001200000000000000 +#define VEHICLE_SPEED13_ACCELERATION 0.000916666666666666 -#define VEHICLE_STARTPITCH 60 -#define VEHICLE_MAXPITCH 200 -#define VEHICLE_MAXSPEED 1500 +#define VEHICLE_STARTPITCH 60 +#define VEHICLE_MAXPITCH 200 +#define VEHICLE_MAXSPEED 1500 class CFuncVehicleControls: public CBaseEntity { @@ -60,8 +56,3 @@ public: public: void EXPORT Find(); }; - -float_precision Fix2(float angle); -void FixupAngles2(Vector &v); - -#endif // VEHICLE_H diff --git a/regamedll/dlls/weapons.cpp b/regamedll/dlls/weapons.cpp index 85fd9177..3630b74a 100644 --- a/regamedll/dlls/weapons.cpp +++ b/regamedll/dlls/weapons.cpp @@ -88,11 +88,6 @@ int MaxAmmoCarry(WeaponIdType weaponId) return IMPL_CLASS(CBasePlayerItem, ItemInfoArray)[ weaponId ].iMaxAmmo1; } -int MaxAmmoCarry(int iszName) -{ - return MaxAmmoCarry(STRING(iszName)); -} - // ClearMultiDamage - resets the global multi damage accumulator void ClearMultiDamage() { @@ -156,7 +151,7 @@ void DecalGunshot(TraceResult *pTrace, int iBulletType, bool ClientOnly, entvars // EjectBrass - tosses a brass shell from passed origin at passed velocity void EjectBrass(const Vector &vecOrigin, const Vector &vecLeft, const Vector &vecVelocity, float rotation, int model, int soundtype, int entityIndex) { - bool useNewBehavior = g_bIsCzeroGame; + bool useNewBehavior = AreRunningCZero(); MESSAGE_BEGIN(MSG_PVS, gmsgBrass, vecOrigin); if (!useNewBehavior) @@ -1348,10 +1343,10 @@ void CBasePlayerWeapon::ReloadSound() distance = (origin - pPlayer->pev->origin).Length(); - if (distance <= DISTANCE_RELOAD_SOUND) + if (distance <= MAX_DIST_RELOAD_SOUND) { MESSAGE_BEGIN(MSG_ONE, gmsgReloadSound, NULL, pPlayer->pev); - WRITE_BYTE(int((1.0f - (distance / DISTANCE_RELOAD_SOUND)) * 255.0f)); + WRITE_BYTE(int((1.0f - (distance / MAX_DIST_RELOAD_SOUND)) * 255.0f)); if (!Q_strcmp(STRING(pev->classname), "weapon_m3") || !Q_strcmp(STRING(pev->classname), "weapon_xm1014")) WRITE_BYTE(0); else @@ -1991,7 +1986,7 @@ BOOL CWeaponBox::PackWeapon(CBasePlayerItem *pWeapon) return TRUE; } -int CWeaponBox::PackAmmo(int iszName, int iCount) +BOOL CWeaponBox::PackAmmo(string_t iszName, int iCount) { if (!iszName) { @@ -2268,38 +2263,36 @@ struct ArmouryItemStruct int giveAmount; int maxRounds; } armouryItemInfo[] = { - { "weapon_mp5navy", "9mm", 60, MAX_AMMO_9MM }, // ARMOURY_MP5NAVY - { "weapon_tmp", "9mm", 60, MAX_AMMO_9MM }, // ARMOURY_TMP - { "weapon_p90", "57mm", 50, MAX_AMMO_57MM }, // ARMOURY_P90 - { "weapon_mac10", "45acp", 60, MAX_AMMO_45ACP }, // ARMOURY_MAC10 - { "weapon_ak47", "762Nato", 60, MAX_AMMO_762NATO }, // ARMOURY_AK47 - { "weapon_sg552", "556Nato", 60, MAX_AMMO_556NATO }, // ARMOURY_SG552 - { "weapon_m4a1", "556Nato", 60, MAX_AMMO_556NATO }, // ARMOURY_M4A1 - { "weapon_aug", "556Nato", 60, MAX_AMMO_556NATO }, // ARMOURY_AUG - { "weapon_scout", "762Nato", 30, MAX_AMMO_762NATO }, // ARMOURY_SCOUT - { "weapon_g3sg1", "762Nato", 30, MAX_AMMO_762NATO }, // ARMOURY_G3SG1 - { "weapon_awp", "338Magnum", 20, MAX_AMMO_338MAGNUM }, // ARMOURY_AWP - { "weapon_m3", "buckshot", 24, MAX_AMMO_BUCKSHOT }, // ARMOURY_M3 - { "weapon_xm1014", "buckshot", 24, MAX_AMMO_BUCKSHOT }, // ARMOURY_XM1014 - { "weapon_m249", "556NatoBox", 60, MAX_AMMO_556NATOBOX }, // ARMOURY_M249 - - { NULL, NULL, 0, 0 }, // ARMOURY_FLASHBANG - { NULL, NULL, 0, 0 }, // ARMOURY_HEGRENADE - { NULL, NULL, 0, 0 }, // ARMOURY_KEVLAR - { NULL, NULL, 0, 0 }, // ARMOURY_ASSAULT - { NULL, NULL, 0, 0 }, // ARMOURY_SMOKEGRENADE - { NULL, NULL, 0, 0 }, // ARMOURY_SHIELD - - { "weapon_famas", "556Nato", 90, MAX_AMMO_556NATO }, // ARMOURY_FAMAS - { "weapon_sg550", "556Nato", 90, MAX_AMMO_556NATO }, // ARMOURY_SG550 - { "weapon_galil", "556Nato", 90, MAX_AMMO_556NATO }, // ARMOURY_GALIL - { "weapon_ump45", "45acp", 100, MAX_AMMO_45ACP }, // ARMOURY_UMP45 - { "weapon_glock18", "9mm", 120, MAX_AMMO_9MM }, // ARMOURY_GLOCK18 - { "weapon_usp", "45acp", 100, MAX_AMMO_45ACP }, // ARMOURY_USP - { "weapon_elite", "9mm", 120, MAX_AMMO_9MM }, // ARMOURY_ELITE - { "weapon_fiveseven", "57mm", 100, MAX_AMMO_57MM }, // ARMOURY_FIVESEVEN - { "weapon_p228", "357SIG", 52, MAX_AMMO_357SIG }, // ARMOURY_P228 - { "weapon_deagle", "50AE", 35, MAX_AMMO_50AE }, // ARMOURY_DEAGLE + { "weapon_mp5navy", "9mm", 60, MAX_AMMO_9MM }, // ARMOURY_MP5NAVY + { "weapon_tmp", "9mm", 60, MAX_AMMO_9MM }, // ARMOURY_TMP + { "weapon_p90", "57mm", 50, MAX_AMMO_57MM }, // ARMOURY_P90 + { "weapon_mac10", "45acp", 60, MAX_AMMO_45ACP }, // ARMOURY_MAC10 + { "weapon_ak47", "762Nato", 60, MAX_AMMO_762NATO }, // ARMOURY_AK47 + { "weapon_sg552", "556Nato", 60, MAX_AMMO_556NATO }, // ARMOURY_SG552 + { "weapon_m4a1", "556Nato", 60, MAX_AMMO_556NATO }, // ARMOURY_M4A1 + { "weapon_aug", "556Nato", 60, MAX_AMMO_556NATO }, // ARMOURY_AUG + { "weapon_scout", "762Nato", 30, MAX_AMMO_762NATO }, // ARMOURY_SCOUT + { "weapon_g3sg1", "762Nato", 30, MAX_AMMO_762NATO }, // ARMOURY_G3SG1 + { "weapon_awp", "338Magnum", 20, MAX_AMMO_338MAGNUM }, // ARMOURY_AWP + { "weapon_m3", "buckshot", 24, MAX_AMMO_BUCKSHOT }, // ARMOURY_M3 + { "weapon_xm1014", "buckshot", 24, MAX_AMMO_BUCKSHOT }, // ARMOURY_XM1014 + { "weapon_m249", "556NatoBox", 60, MAX_AMMO_556NATOBOX }, // ARMOURY_M249 + { nullptr, nullptr, 0, 0 }, // ARMOURY_FLASHBANG + { nullptr, nullptr, 0, 0 }, // ARMOURY_HEGRENADE + { nullptr, nullptr, 0, 0 }, // ARMOURY_KEVLAR + { nullptr, nullptr, 0, 0 }, // ARMOURY_ASSAULT + { nullptr, nullptr, 0, 0 }, // ARMOURY_SMOKEGRENADE + { nullptr, nullptr, 0, 0 }, // ARMOURY_SHIELD + { "weapon_famas", "556Nato", 90, MAX_AMMO_556NATO }, // ARMOURY_FAMAS + { "weapon_sg550", "556Nato", 90, MAX_AMMO_556NATO }, // ARMOURY_SG550 + { "weapon_galil", "556Nato", 90, MAX_AMMO_556NATO }, // ARMOURY_GALIL + { "weapon_ump45", "45acp", 100, MAX_AMMO_45ACP }, // ARMOURY_UMP45 + { "weapon_glock18", "9mm", 120, MAX_AMMO_9MM }, // ARMOURY_GLOCK18 + { "weapon_usp", "45acp", 100, MAX_AMMO_45ACP }, // ARMOURY_USP + { "weapon_elite", "9mm", 120, MAX_AMMO_9MM }, // ARMOURY_ELITE + { "weapon_fiveseven", "57mm", 100, MAX_AMMO_57MM }, // ARMOURY_FIVESEVEN + { "weapon_p228", "357SIG", 52, MAX_AMMO_357SIG }, // ARMOURY_P228 + { "weapon_deagle", "50AE", 35, MAX_AMMO_50AE }, // ARMOURY_DEAGLE }; void CArmoury::ArmouryTouch(CBaseEntity *pOther) @@ -2433,7 +2426,9 @@ void CArmoury::KeyValue(KeyValueData *pkvd) pkvd->fHandled = TRUE; } else + { CBaseEntity::KeyValue(pkvd); + } } #ifdef REGAMEDLL_ADD diff --git a/regamedll/dlls/weapons.h b/regamedll/dlls/weapons.h index 441fced4..257ddcd7 100644 --- a/regamedll/dlls/weapons.h +++ b/regamedll/dlls/weapons.h @@ -26,55 +26,49 @@ * */ -#ifndef WEAPONS_H -#define WEAPONS_H -#ifdef _WIN32 #pragma once -#endif class CBasePlayer; -#define MAX_WEAPONS 32 -#define MAX_NORMAL_BATTERY 100.0f -#define DISTANCE_RELOAD_SOUND 512.0f +const float MAX_NORMAL_BATTERY = 100.0f; +const float MAX_DIST_RELOAD_SOUND = 512.0f; -#define ITEM_FLAG_SELECTONEMPTY 1 -#define ITEM_FLAG_NOAUTORELOAD 2 -#define ITEM_FLAG_NOAUTOSWITCHEMPTY 4 -#define ITEM_FLAG_LIMITINWORLD 8 -#define ITEM_FLAG_EXHAUSTIBLE 16 // A player can totally exhaust their ammo supply and lose this weapon +#define MAX_WEAPONS 32 -#define WEAPON_IS_ONTARGET 0x40 +#define ITEM_FLAG_SELECTONEMPTY 1 +#define ITEM_FLAG_NOAUTORELOAD 2 +#define ITEM_FLAG_NOAUTOSWITCHEMPTY 4 +#define ITEM_FLAG_LIMITINWORLD 8 +#define ITEM_FLAG_EXHAUSTIBLE 16 // A player can totally exhaust their ammo supply and lose this weapon + +#define WEAPON_IS_ONTARGET 0x40 // the maximum amount of ammo each weapon's clip can hold -#define WEAPON_NOCLIP -1 +#define WEAPON_NOCLIP -1 -#define LOUD_GUN_VOLUME 1000 -#define NORMAL_GUN_VOLUME 600 -#define QUIET_GUN_VOLUME 200 +#define LOUD_GUN_VOLUME 1000 +#define NORMAL_GUN_VOLUME 600 +#define QUIET_GUN_VOLUME 200 -#define BRIGHT_GUN_FLASH 512 -#define NORMAL_GUN_FLASH 256 -#define DIM_GUN_FLASH 128 +#define BRIGHT_GUN_FLASH 512 +#define NORMAL_GUN_FLASH 256 +#define DIM_GUN_FLASH 128 -#define BIG_EXPLOSION_VOLUME 2048 -#define NORMAL_EXPLOSION_VOLUME 1024 -#define SMALL_EXPLOSION_VOLUME 512 +#define BIG_EXPLOSION_VOLUME 2048 +#define NORMAL_EXPLOSION_VOLUME 1024 +#define SMALL_EXPLOSION_VOLUME 512 -#define WEAPON_ACTIVITY_VOLUME 64 +#define WEAPON_ACTIVITY_VOLUME 64 // spawn flags -#define SF_DETONATE 0x0001 // Grenades flagged with this will be triggered when the owner calls detonateSatchelCharges - -#include "weapontype.h" -#include "wpn_shared.h" +#define SF_DETONATE BIT(0) // Grenades flagged with this will be triggered when the owner calls detonateSatchelCharges // custom enum enum ArmorType { - ARMOR_NONE, // no armor - ARMOR_KEVLAR, // body vest only - ARMOR_VESTHELM, // vest and helmet + ARMOR_NONE, // No armor + ARMOR_KEVLAR, // Body vest only + ARMOR_VESTHELM, // Vest and helmet }; enum ArmouryItemPack @@ -108,7 +102,7 @@ enum ArmouryItemPack ARMOURY_ELITE, ARMOURY_FIVESEVEN, ARMOURY_P228, - ARMOURY_DEAGLE + ARMOURY_DEAGLE, }; struct ItemInfo @@ -139,6 +133,9 @@ struct MULTIDAMAGE int type; }; +#include "weapontype.h" +#include "items.h" + class CArmoury: public CBaseEntity { public: @@ -180,7 +177,7 @@ public: enum SATCHELCODE { SATCHEL_DETONATE, - SATCHEL_RELEASE + SATCHEL_RELEASE, }; public: static CGrenade *ShootTimed(entvars_t *pevOwner, Vector vecStart, Vector vecVelocity, float time); @@ -222,7 +219,7 @@ public: bool m_bStartDefuse; bool m_bIsC4; - EHANDLE m_pBombDefuser; + EntityHandle m_pBombDefuser; float m_flDefuseCountDown; float m_flC4Blow; float m_flNextFreqInterval; @@ -253,18 +250,18 @@ public: virtual int Restore(CRestore &restore); virtual void SetObjectCollisionBox(); virtual CBaseEntity *Respawn(); - virtual int AddToPlayer(CBasePlayer *pPlayer); - virtual int AddDuplicate(CBasePlayerItem *pItem) { return FALSE; } - virtual int GetItemInfo(ItemInfo *p) { return 0; } + virtual int AddToPlayer(CBasePlayer *pPlayer); // return TRUE if the item you want the item added to the player inventory + virtual int AddDuplicate(CBasePlayerItem *pItem) { return FALSE; } // return TRUE if you want your duplicate removed from world + virtual int GetItemInfo(ItemInfo *p) { return 0; } // returns 0 if struct not filled out virtual BOOL CanDeploy() { return TRUE; } - virtual BOOL CanDrop() { return TRUE; } + virtual BOOL CanDrop() { return TRUE; } // returns is deploy was successful virtual BOOL Deploy() { return TRUE; } virtual BOOL IsWeapon() { return FALSE; } - virtual BOOL CanHolster() { return TRUE; } + virtual BOOL CanHolster() { return TRUE; } // can this weapon be put away right now? virtual void Holster(int skiplocal = 0); virtual void UpdateItemInfo() {} - virtual void ItemPreFrame() {} - virtual void ItemPostFrame() {} + virtual void ItemPreFrame() {} // called each frame by the player PreThink + virtual void ItemPostFrame() {} // called each frame by the player PostThink virtual void Drop(); virtual void Kill(); virtual void AttachToPlayer(CBasePlayer *pPlayer); @@ -273,7 +270,7 @@ public: virtual int UpdateClientData(CBasePlayer *pPlayer) { return 0; } virtual CBasePlayerItem *GetWeaponPtr() { return NULL; } virtual float GetMaxSpeed() { return 260.0f; } - virtual int iItemSlot() { return 0; } + virtual int iItemSlot() { return 0; } // return 0 to MAX_ITEMS_SLOTS, used in hud public: void EXPORT DestroyItem(); @@ -303,14 +300,17 @@ public: CBasePlayer *m_pPlayer; CBasePlayerItem *m_pNext; - int m_iId; + int m_iId; // WEAPON_??? }; +// inventory items that class CBasePlayerWeapon: public CBasePlayerItem { public: virtual int Save(CSave &save); virtual int Restore(CRestore &restore); + + // generic weapon versions of CBasePlayerItem calls virtual int AddToPlayer(CBasePlayer *pPlayer); virtual int AddDuplicate(CBasePlayerItem *pItem); virtual BOOL CanDeploy(); @@ -366,16 +366,16 @@ public: int m_iPlayEmptySound; int m_fFireOnEmpty; - float m_flNextPrimaryAttack; // soonest time ItemPostFrame will call PrimaryAttack - float m_flNextSecondaryAttack; // soonest time ItemPostFrame will call SecondaryAttack - float m_flTimeWeaponIdle; // soonest time ItemPostFrame will call WeaponIdle - int m_iPrimaryAmmoType; // "primary" ammo index into players m_rgAmmo[] - int m_iSecondaryAmmoType; // "secondary" ammo index into players m_rgAmmo[] + float m_flNextPrimaryAttack; // soonest time ItemPostFrame will call PrimaryAttack + float m_flNextSecondaryAttack; // soonest time ItemPostFrame will call SecondaryAttack + float m_flTimeWeaponIdle; // soonest time ItemPostFrame will call WeaponIdle + int m_iPrimaryAmmoType; // "primary" ammo index into players m_rgAmmo[] + int m_iSecondaryAmmoType; // "secondary" ammo index into players m_rgAmmo[] int m_iClip; // number of shots left in the primary weapon clip, -1 it not used int m_iClientClip; // the last version of m_iClip sent to hud dll - int m_iClientWeaponState; // the last version of the weapon state sent to hud dll (is current weapon, is on target) + int m_iClientWeaponState; // the last version of the weapon state sent to hud dll (is current weapon, is on target) int m_fInReload; // Are we in the middle of a reload; - int m_fInSpecialReload; // Are we in the middle of a reload for the shotguns + int m_fInSpecialReload; // Are we in the middle of a reload for the shotguns int m_iDefaultAmmo; // how much ammo you get when you pick up this weapon as placed by a level designer. int m_iShellId; float m_fMaxSpeed; @@ -387,8 +387,8 @@ public: int m_iShotsFired; Vector m_vVecAiming; string_t model_name; - float m_flGlock18Shoot; // time to shoot the remaining bullets of the glock18 burst fire - int m_iGlock18ShotsFired; // used to keep track of the shots fired during the Glock18 burst fire mode. + float m_flGlock18Shoot; // time to shoot the remaining bullets of the glock18 burst fire + int m_iGlock18ShotsFired; // used to keep track of the shots fired during the Glock18 burst fire mode. float m_flFamasShoot; int m_iFamasShotsFired; float m_fBurstSpread; @@ -435,18 +435,58 @@ public: BOOL HasWeapon(CBasePlayerItem *pCheckItem); BOOL PackWeapon(CBasePlayerItem *pWeapon); - BOOL PackAmmo(int iszName, int iCount); + BOOL PackAmmo(string_t iszName, int iCount); public: static TYPEDESCRIPTION IMPL(m_SaveData)[4]; - CBasePlayerItem *m_rgpPlayerItems[ MAX_ITEM_TYPES ]; - int m_rgiszAmmo[ MAX_AMMO_SLOTS ]; - int m_rgAmmo[ MAX_AMMO_SLOTS ]; + CBasePlayerItem *m_rgpPlayerItems[MAX_ITEM_TYPES]; + string_t m_rgiszAmmo[MAX_AMMO_SLOTS]; + int m_rgAmmo[MAX_AMMO_SLOTS]; int m_cAmmoTypes; bool m_bIsBomb; }; + +const float USP_MAX_SPEED = 250.0f; +const float USP_DAMAGE = 34.0f; +const float USP_DAMAGE_SIL = 30.0f; +const float USP_RANGE_MODIFER = 0.79f; +const float USP_RELOAD_TIME = 2.7f; + +enum usp_e +{ + USP_IDLE, + USP_SHOOT1, + USP_SHOOT2, + USP_SHOOT3, + USP_SHOOT_EMPTY, + USP_RELOAD, + USP_DRAW, + USP_ATTACH_SILENCER, + USP_UNSIL_IDLE, + USP_UNSIL_SHOOT1, + USP_UNSIL_SHOOT2, + USP_UNSIL_SHOOT3, + USP_UNSIL_SHOOT_EMPTY, + USP_UNSIL_RELOAD, + USP_UNSIL_DRAW, + USP_DETACH_SILENCER, +}; + +enum usp_shield_e +{ + USP_SHIELD_IDLE, + USP_SHIELD_SHOOT1, + USP_SHIELD_SHOOT2, + USP_SHIELD_SHOOT_EMPTY, + USP_SHIELD_RELOAD, + USP_SHIELD_DRAW, + USP_SHIELD_UP_IDLE, + USP_SHIELD_UP, + USP_SHIELD_DOWN, +}; + class CUSP: public CBasePlayerWeapon { public: @@ -481,6 +521,22 @@ private: unsigned short m_usFireUSP; }; + +const float MP5N_MAX_SPEED = 250.0f; +const float MP5N_DAMAGE = 26.0f; +const float MP5N_RANGE_MODIFER = 0.84f; +const float MP5N_RELOAD_TIME = 2.63f; + +enum mp5n_e +{ + MP5N_IDLE1, + MP5N_RELOAD, + MP5N_DRAW, + MP5N_SHOOT1, + MP5N_SHOOT2, + MP5N_SHOOT3, +}; + class CMP5N: public CBasePlayerWeapon { public: @@ -512,6 +568,23 @@ private: unsigned short m_usFireMP5N; }; + +const float SG552_MAX_SPEED = 235.0f; +const float SG552_MAX_SPEED_ZOOM = 200.0f; +const float SG552_DAMAGE = 33.0f; +const float SG552_RANGE_MODIFER = 0.955f; +const float SG552_RELOAD_TIME = 3.0f; + +enum sg552_e +{ + SG552_IDLE1, + SG552_RELOAD, + SG552_DRAW, + SG552_SHOOT1, + SG552_SHOOT2, + SG552_SHOOT3, +}; + class CSG552: public CBasePlayerWeapon { public: @@ -544,6 +617,22 @@ private: unsigned short m_usFireSG552; }; + +const float AK47_MAX_SPEED = 221.0f; +const float AK47_DAMAGE = 36.0f; +const float AK47_RANGE_MODIFER = 0.98f; +const float AK47_RELOAD_TIME = 2.45f; + +enum ak47_e +{ + AK47_IDLE1, + AK47_RELOAD, + AK47_DRAW, + AK47_SHOOT1, + AK47_SHOOT2, + AK47_SHOOT3, +}; + class CAK47: public CBasePlayerWeapon { public: @@ -576,6 +665,22 @@ private: unsigned short m_usFireAK47; }; + +const float AUG_MAX_SPEED = 240.0f; +const float AUG_DAMAGE = 32.0f; +const float AUG_RANGE_MODIFER = 0.96f; +const float AUG_RELOAD_TIME = 3.3f; + +enum aug_e +{ + AUG_IDLE1, + AUG_RELOAD, + AUG_DRAW, + AUG_SHOOT1, + AUG_SHOOT2, + AUG_SHOOT3, +}; + class CAUG: public CBasePlayerWeapon { public: @@ -608,6 +713,23 @@ private: unsigned short m_usFireAug; }; + +const float AWP_MAX_SPEED = 210.0f; +const float AWP_MAX_SPEED_ZOOM = 150.0f; +const float AWP_DAMAGE = 115.0f; +const float AWP_RANGE_MODIFER = 0.99f; +const float AWP_RELOAD_TIME = 2.5f; + +enum awp_e +{ + AWP_IDLE, + AWP_SHOOT, + AWP_SHOOT2, + AWP_SHOOT3, + AWP_RELOAD, + AWP_DRAW, +}; + class CAWP: public CBasePlayerWeapon { public: @@ -639,10 +761,23 @@ private: unsigned short m_usFireAWP; }; + // for usermsg BombDrop #define BOMB_FLAG_DROPPED 0 // if the bomb was dropped due to voluntary dropping or death/disconnect #define BOMB_FLAG_PLANTED 1 // if the bomb has been planted will also trigger the round timer to hide will also show where the dropped bomb on the Terrorist team's radar. +const float C4_MAX_AMMO = 1.0f; +const float C4_MAX_SPEED = 250.0f; +const float C4_ARMING_ON_TIME = 3.0f; + +enum c4_e +{ + C4_IDLE1, + C4_DRAW, + C4_DROP, + C4_ARM, +}; + class CC4: public CBasePlayerWeapon { public: @@ -675,6 +810,22 @@ private: bool m_bHasShield; }; + +const float DEAGLE_MAX_SPEED = 250.0f; +const float DEAGLE_DAMAGE = 54.0f; +const float DEAGLE_RANGE_MODIFER = 0.81f; +const float DEAGLE_RELOAD_TIME = 2.2f; + +enum deagle_e +{ + DEAGLE_IDLE1, + DEAGLE_SHOOT1, + DEAGLE_SHOOT2, + DEAGLE_SHOOT_EMPTY, + DEAGLE_RELOAD, + DEAGLE_DRAW, +}; + class CDEAGLE: public CBasePlayerWeapon { public: @@ -707,6 +858,18 @@ private: unsigned short m_usFireDeagle; }; + +const float FLASHBANG_MAX_SPEED = 250.0f; +const float FLASHBANG_MAX_SPEED_SHIELD = 180.0f; + +enum flashbang_e +{ + FLASHBANG_IDLE, + FLASHBANG_PULLPIN, + FLASHBANG_THROW, + FLASHBANG_DRAW, +}; + class CFlashbang: public CBasePlayerWeapon { public: @@ -746,6 +909,22 @@ public: void ResetPlayerShieldAnim(); }; + +const float G3SG1_MAX_SPEED = 210.0f; +const float G3SG1_MAX_SPEED_ZOOM = 150.0f; +const float G3SG1_DAMAGE = 80.0f; +const float G3SG1_RANGE_MODIFER = 0.98f; +const float G3SG1_RELOAD_TIME = 3.5f; + +enum g3sg1_e +{ + G3SG1_IDLE, + G3SG1_SHOOT, + G3SG1_SHOOT2, + G3SG1_RELOAD, + G3SG1_DRAW, +}; + class CG3SG1: public CBasePlayerWeapon { public: @@ -777,6 +956,42 @@ private: unsigned short m_usFireG3SG1; }; + +const float GLOCK18_MAX_SPEED = 250.0f; +const float GLOCK18_DAMAGE = 25.0f; +const float GLOCK18_RANGE_MODIFER = 0.75f; +const float GLOCK18_RELOAD_TIME = 2.2f; + +enum glock18_e +{ + GLOCK18_IDLE1, + GLOCK18_IDLE2, + GLOCK18_IDLE3, + GLOCK18_SHOOT, + GLOCK18_SHOOT2, + GLOCK18_SHOOT3, + GLOCK18_SHOOT_EMPTY, + GLOCK18_RELOAD, + GLOCK18_DRAW, + GLOCK18_HOLSTER, + GLOCK18_ADD_SILENCER, + GLOCK18_DRAW2, + GLOCK18_RELOAD2, +}; + +enum glock18_shield_e +{ + GLOCK18_SHIELD_IDLE1, + GLOCK18_SHIELD_SHOOT, + GLOCK18_SHIELD_SHOOT2, + GLOCK18_SHIELD_SHOOT_EMPTY, + GLOCK18_SHIELD_RELOAD, + GLOCK18_SHIELD_DRAW, + GLOCK18_SHIELD_IDLE, + GLOCK18_SHIELD_UP, + GLOCK18_SHIELD_DOWN, +}; + class CGLOCK18: public CBasePlayerWeapon { public: @@ -808,6 +1023,18 @@ public: bool m_bBurstFire; }; + +const float HEGRENADE_MAX_SPEED = 250.0f; +const float HEGRENADE_MAX_SPEED_SHIELD = 180.0f; + +enum hegrenade_e +{ + HEGRENADE_IDLE, + HEGRENADE_PULLPIN, + HEGRENADE_THROW, + HEGRENADE_DRAW, +}; + class CHEGrenade: public CBasePlayerWeapon { public: @@ -841,6 +1068,35 @@ public: unsigned short m_usCreateExplosion; }; + +const float KNIFE_BODYHIT_VOLUME = 128.0f; +const float KNIFE_WALLHIT_VOLUME = 512.0f; +const float KNIFE_MAX_SPEED = 250.0f; +const float KNIFE_MAX_SPEED_SHIELD = 180.0f; + +enum knife_e +{ + KNIFE_IDLE, + KNIFE_ATTACK1HIT, + KNIFE_ATTACK2HIT, + KNIFE_DRAW, + KNIFE_STABHIT, + KNIFE_STABMISS, + KNIFE_MIDATTACK1HIT, + KNIFE_MIDATTACK2HIT, +}; + +enum knife_shield_e +{ + KNIFE_SHIELD_IDLE, + KNIFE_SHIELD_SLASH, + KNIFE_SHIELD_ATTACKHIT, + KNIFE_SHIELD_DRAW, + KNIFE_SHIELD_UPIDLE, + KNIFE_SHIELD_UP, + KNIFE_SHIELD_DOWN, +}; + class CKnife: public CBasePlayerWeapon { public: @@ -882,6 +1138,21 @@ public: unsigned short m_usKnife; }; + +const float M249_MAX_SPEED = 220.0f; +const float M249_DAMAGE = 32.0f; +const float M249_RANGE_MODIFER = 0.97f; +const float M249_RELOAD_TIME = 4.7f; + +enum m249_e +{ + M249_IDLE1, + M249_SHOOT1, + M249_SHOOT2, + M249_RELOAD, + M249_DRAW, +}; + class CM249: public CBasePlayerWeapon { public: @@ -913,6 +1184,22 @@ private: unsigned short m_usFireM249; }; + +const float M3_MAX_SPEED = 230.0f; +const Vector M3_CONE_VECTOR = Vector(0.0675, 0.0675, 0.0); // special shotgun spreads + +enum m3_e +{ + M3_IDLE, + M3_FIRE1, + M3_FIRE2, + M3_RELOAD, + M3_PUMP, + M3_START_RELOAD, + M3_DRAW, + M3_HOLSTER, +}; + class CM3: public CBasePlayerWeapon { public: @@ -942,6 +1229,32 @@ private: unsigned short m_usFireM3; }; + +const float M4A1_MAX_SPEED = 230.0f; +const float M4A1_DAMAGE = 32.0f; +const float M4A1_DAMAGE_SIL = 33.0f; +const float M4A1_RANGE_MODIFER = 0.97f; +const float M4A1_RANGE_MODIFER_SIL = 0.95f; +const float M4A1_RELOAD_TIME = 3.05f; + +enum m4a1_e +{ + M4A1_IDLE, + M4A1_SHOOT1, + M4A1_SHOOT2, + M4A1_SHOOT3, + M4A1_RELOAD, + M4A1_DRAW, + M4A1_ATTACH_SILENCER, + M4A1_UNSIL_IDLE, + M4A1_UNSIL_SHOOT1, + M4A1_UNSIL_SHOOT2, + M4A1_UNSIL_SHOOT3, + M4A1_UNSIL_RELOAD, + M4A1_UNSIL_DRAW, + M4A1_DETACH_SILENCER, +}; + class CM4A1: public CBasePlayerWeapon { public: @@ -974,6 +1287,22 @@ private: unsigned short m_usFireM4A1; }; + +const float MAC10_MAX_SPEED = 250.0f; +const float MAC10_DAMAGE = 29.0f; +const float MAC10_RANGE_MODIFER = 0.82f; +const float MAC10_RELOAD_TIME = 3.15f; + +enum mac10_e +{ + MAC10_IDLE1, + MAC10_RELOAD, + MAC10_DRAW, + MAC10_SHOOT1, + MAC10_SHOOT2, + MAC10_SHOOT3, +}; + class CMAC10: public CBasePlayerWeapon { public: @@ -1005,6 +1334,36 @@ private: unsigned short m_usFireMAC10; }; + +const float P228_MAX_SPEED = 250.0f; +const float P228_DAMAGE = 32.0f; +const float P228_RANGE_MODIFER = 0.8f; +const float P228_RELOAD_TIME = 2.7f; + +enum p228_e +{ + P228_IDLE, + P228_SHOOT1, + P228_SHOOT2, + P228_SHOOT3, + P228_SHOOT_EMPTY, + P228_RELOAD, + P228_DRAW, +}; + +enum p228_shield_e +{ + P228_SHIELD_IDLE, + P228_SHIELD_SHOOT1, + P228_SHIELD_SHOOT2, + P228_SHIELD_SHOOT_EMPTY, + P228_SHIELD_RELOAD, + P228_SHIELD_DRAW, + P228_SHIELD_IDLE_UP, + P228_SHIELD_UP, + P228_SHIELD_DOWN, +}; + class CP228: public CBasePlayerWeapon { public: @@ -1040,6 +1399,22 @@ private: unsigned short m_usFireP228; }; + +const float P90_MAX_SPEED = 245.0f; +const float P90_DAMAGE = 21.0f; +const float P90_RANGE_MODIFER = 0.885f; +const float P90_RELOAD_TIME = 3.4f; + +enum p90_e +{ + P90_IDLE1, + P90_RELOAD, + P90_DRAW, + P90_SHOOT1, + P90_SHOOT2, + P90_SHOOT3, +}; + class CP90: public CBasePlayerWeapon { public: @@ -1071,6 +1446,22 @@ private: unsigned short m_usFireP90; }; + +const float SCOUT_MAX_SPEED = 260.0f; +const float SCOUT_MAX_SPEED_ZOOM = 220.0f; +const float SCOUT_DAMAGE = 75.0f; +const float SCOUT_RANGE_MODIFER = 0.98f; +const float SCOUT_RELOAD_TIME = 2.0f; + +enum scout_e +{ + SCOUT_IDLE, + SCOUT_SHOOT, + SCOUT_SHOOT2, + SCOUT_RELOAD, + SCOUT_DRAW, +}; + class CSCOUT: public CBasePlayerWeapon { public: @@ -1101,6 +1492,18 @@ private: unsigned short m_usFireScout; }; + +const float SMOKEGRENADE_MAX_SPEED = 250.0f; +const float SMOKEGRENADE_MAX_SPEED_SHIELD = 180.0f; + +enum smokegrenade_e +{ + SMOKEGRENADE_IDLE, + SMOKEGRENADE_PINPULL, + SMOKEGRENADE_THROW, + SMOKEGRENADE_DRAW, +}; + class CSmokeGrenade: public CBasePlayerWeapon { public: @@ -1134,6 +1537,22 @@ public: unsigned short m_usCreateSmoke; }; + +const float TMP_MAX_SPEED = 250.0f; +const float TMP_DAMAGE = 20.0f; +const float TMP_RANGE_MODIFER = 0.85f; +const float TMP_RELOAD_TIME = 2.12f; + +enum tmp_e +{ + TMP_IDLE1, + TMP_RELOAD, + TMP_DRAW, + TMP_SHOOT1, + TMP_SHOOT2, + TMP_SHOOT3, +}; + class CTMP: public CBasePlayerWeapon { public: @@ -1166,6 +1585,21 @@ private: unsigned short m_usFireTMP; }; + +const float XM1014_MAX_SPEED = 240.0f; +const Vector XM1014_CONE_VECTOR = Vector(0.0725, 0.0725, 0.0); // special shotgun spreads + +enum xm1014_e +{ + XM1014_IDLE, + XM1014_FIRE1, + XM1014_FIRE2, + XM1014_RELOAD, + XM1014_PUMP, + XM1014_START_RELOAD, + XM1014_DRAW, +}; + class CXM1014: public CBasePlayerWeapon { public: @@ -1195,6 +1629,32 @@ private: unsigned short m_usFireXM1014; }; + +const float ELITE_MAX_SPEED = 250.0f; +const float ELITE_RELOAD_TIME = 4.5f; +const float ELITE_DAMAGE = 36.0f; +const float ELITE_RANGE_MODIFER = 0.75f; + +enum elite_e +{ + ELITE_IDLE, + ELITE_IDLE_LEFTEMPTY, + ELITE_SHOOTLEFT1, + ELITE_SHOOTLEFT2, + ELITE_SHOOTLEFT3, + ELITE_SHOOTLEFT4, + ELITE_SHOOTLEFT5, + ELITE_SHOOTLEFTLAST, + ELITE_SHOOTRIGHT1, + ELITE_SHOOTRIGHT2, + ELITE_SHOOTRIGHT3, + ELITE_SHOOTRIGHT4, + ELITE_SHOOTRIGHT5, + ELITE_SHOOTRIGHTLAST, + ELITE_RELOAD, + ELITE_DRAW, +}; + class CELITE: public CBasePlayerWeapon { public: @@ -1227,6 +1687,22 @@ private: unsigned short m_usFireELITE_RIGHT; }; + +const float FIVESEVEN_MAX_SPEED = 250.0f; +const float FIVESEVEN_DAMAGE = 20.0f; +const float FIVESEVEN_RANGE_MODIFER = 0.885f; +const float FIVESEVEN_RELOAD_TIME = 2.7f; + +enum fiveseven_e +{ + FIVESEVEN_IDLE, + FIVESEVEN_SHOOT1, + FIVESEVEN_SHOOT2, + FIVESEVEN_SHOOT_EMPTY, + FIVESEVEN_RELOAD, + FIVESEVEN_DRAW, +}; + class CFiveSeven: public CBasePlayerWeapon { public: @@ -1262,6 +1738,22 @@ private: unsigned short m_usFireFiveSeven; }; + +const float UMP45_MAX_SPEED = 250.0f; +const float UMP45_DAMAGE = 30.0f; +const float UMP45_RANGE_MODIFER = 0.82f; +const float UMP45_RELOAD_TIME = 3.5f; + +enum ump45_e +{ + UMP45_IDLE1, + UMP45_RELOAD, + UMP45_DRAW, + UMP45_SHOOT1, + UMP45_SHOOT2, + UMP45_SHOOT3, +}; + class CUMP45: public CBasePlayerWeapon { public: @@ -1293,6 +1785,22 @@ private: unsigned short m_usFireUMP45; }; + +const float SG550_MAX_SPEED = 210.0f; +const float SG550_MAX_SPEED_ZOOM = 150.0f; +const float SG550_DAMAGE = 70.0f; +const float SG550_RANGE_MODIFER = 0.98f; +const float SG550_RELOAD_TIME = 3.35f; + +enum sg550_e +{ + SG550_IDLE, + SG550_SHOOT, + SG550_SHOOT2, + SG550_RELOAD, + SG550_DRAW, +}; + class CSG550: public CBasePlayerWeapon { public: @@ -1323,6 +1831,22 @@ private: unsigned short m_usFireSG550; }; + +const float GALIL_MAX_SPEED = 240.0f; +const float GALIL_DAMAGE = 30.0f; +const float GALIL_RANGE_MODIFER = 0.98f; +const float GALIL_RELOAD_TIME = 2.45f; + +enum galil_e +{ + GALIL_IDLE1, + GALIL_RELOAD, + GALIL_DRAW, + GALIL_SHOOT1, + GALIL_SHOOT2, + GALIL_SHOOT3, +}; + class CGalil: public CBasePlayerWeapon { public: @@ -1356,6 +1880,23 @@ private: unsigned short m_usFireGalil; }; + +const float FAMAS_MAX_SPEED = 240.0f; +const float FAMAS_RELOAD_TIME = 3.3f; +const float FAMAS_DAMAGE = 30.0f; +const float FAMAS_DAMAGE_BURST = 34.0f; +const float FAMAS_RANGE_MODIFER = 0.96f; + +enum famas_e +{ + FAMAS_IDLE1, + FAMAS_RELOAD, + FAMAS_DRAW, + FAMAS_SHOOT1, + FAMAS_SHOOT2, + FAMAS_SHOOT3, +}; + class CFamas: public CBasePlayerWeapon { public: @@ -1410,7 +1951,6 @@ extern MULTIDAMAGE gMultiDamage; void FindHullIntersection(const Vector &vecSrc, TraceResult &tr, float *mins, float *maxs, edict_t *pEntity); void AnnounceFlashInterval(float interval, float offset = 0); -int MaxAmmoCarry(int iszName); int MaxAmmoCarry(const char *szName); int MaxAmmoCarry(WeaponIdType ammoType); @@ -1427,5 +1967,3 @@ void UTIL_PrecacheOtherWeapon(const char *szClassname); void UTIL_PrecacheOtherWeapon2(const char *szClassname); void W_Precache(); BOOL CanAttack(float attack_time, float curtime, BOOL isPredicted); - -#endif // WEAPONS_H diff --git a/regamedll/dlls/weapontype.cpp b/regamedll/dlls/weapontype.cpp index bbe0e245..4200f0e0 100644 --- a/regamedll/dlls/weapontype.cpp +++ b/regamedll/dlls/weapontype.cpp @@ -9,311 +9,313 @@ WeaponStruct g_weaponStruct[ MAX_WEAPONS ] = { { 0, 0, 0, 0, 0 }, - { WEAPON_P228, P228_PRICE, TERRORIST|CT, AUTOBUYCLASS_SECONDARY, AMMO_357SIG_PRICE }, - { WEAPON_SCOUT, SCOUT_PRICE, TERRORIST|CT, AUTOBUYCLASS_PRIMARY, AMMO_762MM_PRICE }, - { WEAPON_XM1014, XM1014_PRICE, TERRORIST|CT, AUTOBUYCLASS_PRIMARY, AMMO_BUCKSHOT_PRICE }, - { WEAPON_MAC10, MAC10_PRICE, CT, AUTOBUYCLASS_PRIMARY, AMMO_45ACP_PRICE }, - { WEAPON_AUG, AUG_PRICE, TERRORIST, AUTOBUYCLASS_PRIMARY, AMMO_556MM_PRICE }, - { WEAPON_ELITE, ELITE_PRICE, CT, AUTOBUYCLASS_SECONDARY, AMMO_9MM_PRICE }, - { WEAPON_FIVESEVEN, FIVESEVEN_PRICE, TERRORIST|CT, AUTOBUYCLASS_SECONDARY, AMMO_57MM_PRICE }, - { WEAPON_UMP45, UMP45_PRICE, TERRORIST, AUTOBUYCLASS_PRIMARY, AMMO_45ACP_PRICE }, - { WEAPON_SG550, SG550_PRICE, TERRORIST, AUTOBUYCLASS_PRIMARY, AMMO_556MM_PRICE }, - { WEAPON_USP, USP_PRICE, TERRORIST|CT, AUTOBUYCLASS_SECONDARY, AMMO_45ACP_PRICE }, - { WEAPON_GLOCK18, GLOCK18_PRICE, TERRORIST|CT, AUTOBUYCLASS_SECONDARY, AMMO_9MM_PRICE }, - { WEAPON_MP5N, MP5NAVY_PRICE, TERRORIST|CT, AUTOBUYCLASS_PRIMARY, AMMO_9MM_PRICE }, - { WEAPON_AWP, AWP_PRICE, TERRORIST|CT, AUTOBUYCLASS_PRIMARY, AMMO_338MAG_PRICE }, - { WEAPON_M249, M249_PRICE, TERRORIST|CT, AUTOBUYCLASS_PRIMARY, AMMO_556MM_PRICE }, - { WEAPON_M3, M3_PRICE, TERRORIST|CT, AUTOBUYCLASS_PRIMARY, AMMO_BUCKSHOT_PRICE }, - { WEAPON_M4A1, M4A1_PRICE, TERRORIST, AUTOBUYCLASS_PRIMARY, AMMO_556MM_PRICE }, - { WEAPON_TMP, TMP_PRICE, TERRORIST, AUTOBUYCLASS_PRIMARY, AMMO_9MM_PRICE }, - { WEAPON_G3SG1, G3SG1_PRICE, CT, AUTOBUYCLASS_PRIMARY, AMMO_762MM_PRICE }, - { WEAPON_DEAGLE, DEAGLE_PRICE, TERRORIST|CT, AUTOBUYCLASS_SECONDARY, AMMO_50AE_PRICE }, - { WEAPON_SG552, SG552_PRICE, CT, AUTOBUYCLASS_PRIMARY, AMMO_556MM_PRICE }, - { WEAPON_AK47, AK47_PRICE, CT, AUTOBUYCLASS_PRIMARY, AMMO_762MM_PRICE }, - { WEAPON_P90, P90_PRICE, TERRORIST|CT, AUTOBUYCLASS_PRIMARY, AMMO_57MM_PRICE }, - { WEAPON_FAMAS, FAMAS_PRICE, TERRORIST, AUTOBUYCLASS_PRIMARY, AMMO_556MM_PRICE }, - { WEAPON_GALIL, GALIL_PRICE, CT, AUTOBUYCLASS_PRIMARY, AMMO_556MM_PRICE }, - // TODO: this have bug, the cost of galil $2000, but not $2250 + { WEAPON_P228, P228_PRICE, TERRORIST|CT, AUTOBUYCLASS_SECONDARY, AMMO_357SIG_PRICE }, + { WEAPON_SCOUT, SCOUT_PRICE, TERRORIST|CT, AUTOBUYCLASS_PRIMARY, AMMO_762MM_PRICE }, + { WEAPON_XM1014, XM1014_PRICE, TERRORIST|CT, AUTOBUYCLASS_PRIMARY, AMMO_BUCKSHOT_PRICE }, + { WEAPON_MAC10, MAC10_PRICE, CT, AUTOBUYCLASS_PRIMARY, AMMO_45ACP_PRICE }, + { WEAPON_AUG, AUG_PRICE, TERRORIST, AUTOBUYCLASS_PRIMARY, AMMO_556MM_PRICE }, + { WEAPON_ELITE, ELITE_PRICE, CT, AUTOBUYCLASS_SECONDARY, AMMO_9MM_PRICE }, + { WEAPON_FIVESEVEN, FIVESEVEN_PRICE, TERRORIST|CT, AUTOBUYCLASS_SECONDARY, AMMO_57MM_PRICE }, + { WEAPON_UMP45, UMP45_PRICE, TERRORIST, AUTOBUYCLASS_PRIMARY, AMMO_45ACP_PRICE }, + { WEAPON_SG550, SG550_PRICE, TERRORIST, AUTOBUYCLASS_PRIMARY, AMMO_556MM_PRICE }, + { WEAPON_USP, USP_PRICE, TERRORIST|CT, AUTOBUYCLASS_SECONDARY, AMMO_45ACP_PRICE }, + { WEAPON_GLOCK18, GLOCK18_PRICE, TERRORIST|CT, AUTOBUYCLASS_SECONDARY, AMMO_9MM_PRICE }, + { WEAPON_MP5N, MP5NAVY_PRICE, TERRORIST|CT, AUTOBUYCLASS_PRIMARY, AMMO_9MM_PRICE }, + { WEAPON_AWP, AWP_PRICE, TERRORIST|CT, AUTOBUYCLASS_PRIMARY, AMMO_338MAG_PRICE }, + { WEAPON_M249, M249_PRICE, TERRORIST|CT, AUTOBUYCLASS_PRIMARY, AMMO_556MM_PRICE }, + { WEAPON_M3, M3_PRICE, TERRORIST|CT, AUTOBUYCLASS_PRIMARY, AMMO_BUCKSHOT_PRICE }, + { WEAPON_M4A1, M4A1_PRICE, TERRORIST, AUTOBUYCLASS_PRIMARY, AMMO_556MM_PRICE }, + { WEAPON_TMP, TMP_PRICE, TERRORIST, AUTOBUYCLASS_PRIMARY, AMMO_9MM_PRICE }, + { WEAPON_G3SG1, G3SG1_PRICE, CT, AUTOBUYCLASS_PRIMARY, AMMO_762MM_PRICE }, + { WEAPON_DEAGLE, DEAGLE_PRICE, TERRORIST|CT, AUTOBUYCLASS_SECONDARY, AMMO_50AE_PRICE }, + { WEAPON_SG552, SG552_PRICE, CT, AUTOBUYCLASS_PRIMARY, AMMO_556MM_PRICE }, + { WEAPON_AK47, AK47_PRICE, CT, AUTOBUYCLASS_PRIMARY, AMMO_762MM_PRICE }, + { WEAPON_P90, P90_PRICE, TERRORIST|CT, AUTOBUYCLASS_PRIMARY, AMMO_57MM_PRICE }, + { WEAPON_FAMAS, FAMAS_PRICE, TERRORIST, AUTOBUYCLASS_PRIMARY, AMMO_556MM_PRICE }, + { WEAPON_GALIL, GALIL_PRICE, CT, AUTOBUYCLASS_PRIMARY, AMMO_556MM_PRICE }, + // FIX: there is a bug, the cost of galil $2000 instead $2250 - { WEAPON_SHIELDGUN, SHIELDGUN_PRICE, TERRORIST, AUTOBUYCLASS_PRIMARY, 0 }, + { WEAPON_SHIELDGUN, SHIELDGUN_PRICE, TERRORIST, AUTOBUYCLASS_PRIMARY, 0 }, { 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0 }, - { 0, 0, 0, 0, 0 } + { 0, 0, 0, 0, 0 }, }; AutoBuyInfoStruct g_autoBuyInfo[] = { - { AUTOBUYCLASS_PRIMARY|AUTOBUYCLASS_RIFLE, "galil", "weapon_galil" }, - { AUTOBUYCLASS_PRIMARY|AUTOBUYCLASS_RIFLE, "ak47", "weapon_ak47" }, - { AUTOBUYCLASS_PRIMARY|AUTOBUYCLASS_SNIPERRIFLE, "scout", "weapon_scout" }, - { AUTOBUYCLASS_PRIMARY|AUTOBUYCLASS_RIFLE, "sg552", "weapon_sg552" }, - { AUTOBUYCLASS_PRIMARY|AUTOBUYCLASS_SNIPERRIFLE, "awp", "weapon_awp" }, - { AUTOBUYCLASS_PRIMARY|AUTOBUYCLASS_SNIPERRIFLE, "g3sg1", "weapon_g3sg1" }, - { AUTOBUYCLASS_PRIMARY|AUTOBUYCLASS_RIFLE, "famas", "weapon_famas" }, - { AUTOBUYCLASS_PRIMARY|AUTOBUYCLASS_RIFLE, "m4a1", "weapon_m4a1" }, - { AUTOBUYCLASS_PRIMARY|AUTOBUYCLASS_RIFLE, "aug", "weapon_aug" }, - { AUTOBUYCLASS_PRIMARY|AUTOBUYCLASS_SNIPERRIFLE, "sg550", "weapon_sg550" }, - { AUTOBUYCLASS_SECONDARY|AUTOBUYCLASS_PISTOL, "glock", "weapon_glock18" }, - { AUTOBUYCLASS_SECONDARY|AUTOBUYCLASS_PISTOL, "usp", "weapon_usp" }, - { AUTOBUYCLASS_SECONDARY|AUTOBUYCLASS_PISTOL, "p228", "weapon_p228" }, - { AUTOBUYCLASS_SECONDARY|AUTOBUYCLASS_PISTOL, "deagle", "weapon_deagle" }, - { AUTOBUYCLASS_SECONDARY|AUTOBUYCLASS_PISTOL, "elites", "weapon_elite" }, - { AUTOBUYCLASS_SECONDARY|AUTOBUYCLASS_PISTOL, "fn57", "weapon_fiveseven" }, - { AUTOBUYCLASS_PRIMARY|AUTOBUYCLASS_SHOTGUN, "m3", "weapon_m3" }, - { AUTOBUYCLASS_PRIMARY|AUTOBUYCLASS_SHOTGUN, "xm1014", "weapon_xm1014" }, - { AUTOBUYCLASS_PRIMARY|AUTOBUYCLASS_SMG, "mac10", "weapon_mac10" }, - { AUTOBUYCLASS_PRIMARY|AUTOBUYCLASS_SMG, "tmp", "weapon_tmp" }, - { AUTOBUYCLASS_PRIMARY|AUTOBUYCLASS_SMG, "mp5", "weapon_mp5navy" }, - { AUTOBUYCLASS_PRIMARY|AUTOBUYCLASS_SMG, "ump45", "weapon_ump45" }, - { AUTOBUYCLASS_PRIMARY|AUTOBUYCLASS_SMG, "p90", "weapon_p90" }, - { AUTOBUYCLASS_PRIMARY|AUTOBUYCLASS_MACHINEGUN, "m249", "weapon_m249" }, - { AUTOBUYCLASS_PRIMARY|AUTOBUYCLASS_AMMO, "primammo", "primammo" }, - { AUTOBUYCLASS_SECONDARY|AUTOBUYCLASS_AMMO, "secammo", "secammo" }, - { AUTOBUYCLASS_ARMOR, "vest", "item_kevlar" }, - { AUTOBUYCLASS_ARMOR, "vesthelm", "item_assaultsuit" }, - { AUTOBUYCLASS_GRENADE, "flash", "weapon_flashbang" }, - { AUTOBUYCLASS_GRENADE, "hegren", "weapon_hegrenade" }, - { AUTOBUYCLASS_GRENADE, "sgren", "weapon_smokegrenade"}, - { AUTOBUYCLASS_NIGHTVISION, "nvgs", "nvgs" }, - { AUTOBUYCLASS_DEFUSER, "defuser", "defuser" }, - { AUTOBUYCLASS_PRIMARY|AUTOBUYCLASS_SHIELD, "shield", "shield" }, - { AUTOBUYCLASS_NONE, NULL, NULL } + { AUTOBUYCLASS_PRIMARY|AUTOBUYCLASS_RIFLE, "galil", "weapon_galil" }, + { AUTOBUYCLASS_PRIMARY|AUTOBUYCLASS_RIFLE, "ak47", "weapon_ak47" }, + { AUTOBUYCLASS_PRIMARY|AUTOBUYCLASS_SNIPERRIFLE,"scout", "weapon_scout" }, + { AUTOBUYCLASS_PRIMARY|AUTOBUYCLASS_RIFLE, "sg552", "weapon_sg552" }, + { AUTOBUYCLASS_PRIMARY|AUTOBUYCLASS_SNIPERRIFLE,"awp", "weapon_awp" }, + { AUTOBUYCLASS_PRIMARY|AUTOBUYCLASS_SNIPERRIFLE,"g3sg1", "weapon_g3sg1" }, + { AUTOBUYCLASS_PRIMARY|AUTOBUYCLASS_RIFLE, "famas", "weapon_famas" }, + { AUTOBUYCLASS_PRIMARY|AUTOBUYCLASS_RIFLE, "m4a1", "weapon_m4a1" }, + { AUTOBUYCLASS_PRIMARY|AUTOBUYCLASS_RIFLE, "aug", "weapon_aug" }, + { AUTOBUYCLASS_PRIMARY|AUTOBUYCLASS_SNIPERRIFLE,"sg550", "weapon_sg550" }, + { AUTOBUYCLASS_SECONDARY|AUTOBUYCLASS_PISTOL, "glock", "weapon_glock18" }, + { AUTOBUYCLASS_SECONDARY|AUTOBUYCLASS_PISTOL, "usp", "weapon_usp" }, + { AUTOBUYCLASS_SECONDARY|AUTOBUYCLASS_PISTOL, "p228", "weapon_p228" }, + { AUTOBUYCLASS_SECONDARY|AUTOBUYCLASS_PISTOL, "deagle", "weapon_deagle" }, + { AUTOBUYCLASS_SECONDARY|AUTOBUYCLASS_PISTOL, "elites", "weapon_elite" }, + { AUTOBUYCLASS_SECONDARY|AUTOBUYCLASS_PISTOL, "fn57", "weapon_fiveseven" }, + { AUTOBUYCLASS_PRIMARY|AUTOBUYCLASS_SHOTGUN, "m3", "weapon_m3" }, + { AUTOBUYCLASS_PRIMARY|AUTOBUYCLASS_SHOTGUN, "xm1014", "weapon_xm1014" }, + { AUTOBUYCLASS_PRIMARY|AUTOBUYCLASS_SMG, "mac10", "weapon_mac10" }, + { AUTOBUYCLASS_PRIMARY|AUTOBUYCLASS_SMG, "tmp", "weapon_tmp" }, + { AUTOBUYCLASS_PRIMARY|AUTOBUYCLASS_SMG, "mp5", "weapon_mp5navy" }, + { AUTOBUYCLASS_PRIMARY|AUTOBUYCLASS_SMG, "ump45", "weapon_ump45" }, + { AUTOBUYCLASS_PRIMARY|AUTOBUYCLASS_SMG, "p90", "weapon_p90" }, + { AUTOBUYCLASS_PRIMARY|AUTOBUYCLASS_MACHINEGUN, "m249", "weapon_m249" }, + { AUTOBUYCLASS_PRIMARY|AUTOBUYCLASS_AMMO, "primammo", "primammo" }, + { AUTOBUYCLASS_SECONDARY|AUTOBUYCLASS_AMMO, "secammo", "secammo" }, + { AUTOBUYCLASS_ARMOR, "vest", "item_kevlar" }, + { AUTOBUYCLASS_ARMOR, "vesthelm", "item_assaultsuit" }, + { AUTOBUYCLASS_GRENADE, "flash", "weapon_flashbang" }, + { AUTOBUYCLASS_GRENADE, "hegren", "weapon_hegrenade" }, + { AUTOBUYCLASS_GRENADE, "sgren", "weapon_smokegrenade" }, + { AUTOBUYCLASS_NIGHTVISION, "nvgs", "nvgs" }, + { AUTOBUYCLASS_DEFUSER, "defuser", "defuser" }, + { AUTOBUYCLASS_PRIMARY|AUTOBUYCLASS_SHIELD, "shield", "shield" }, + { AUTOBUYCLASS_NONE, nullptr, nullptr }, }; WeaponAliasInfo weaponAliasInfo[] = { - { "p228", WEAPON_P228 }, - { "???", WEAPON_GLOCK }, - { "scout", WEAPON_SCOUT }, - { "hegren", WEAPON_HEGRENADE }, - { "xm1014", WEAPON_XM1014 }, - { "c4", WEAPON_C4 }, - { "mac10", WEAPON_MAC10 }, - { "aug", WEAPON_AUG }, - { "sgren", WEAPON_SMOKEGRENADE }, - { "elites", WEAPON_ELITE }, - { "fn57", WEAPON_FIVESEVEN }, - { "ump45", WEAPON_UMP45 }, - { "sg550", WEAPON_SG550 }, - { "galil", WEAPON_GALIL }, - { "famas", WEAPON_FAMAS }, - { "usp", WEAPON_USP }, - { "glock", WEAPON_GLOCK18 }, - { "awp", WEAPON_AWP }, - { "mp5", WEAPON_MP5N }, - { "m249", WEAPON_M249 }, - { "m3", WEAPON_M3 }, - { "m4a1", WEAPON_M4A1 }, - { "tmp", WEAPON_TMP }, - { "g3sg1", WEAPON_G3SG1 }, - { "flash", WEAPON_FLASHBANG }, - { "deagle", WEAPON_DEAGLE }, - { "sg552", WEAPON_SG552 }, - { "ak47", WEAPON_AK47 }, - { "knife", WEAPON_KNIFE }, - { "p90", WEAPON_P90 }, - { "shield", WEAPON_SHIELDGUN }, - { "none", WEAPON_NONE }, - { "grenade", WEAPON_HEGRENADE }, - { "hegrenade", WEAPON_HEGRENADE }, - { "glock18", WEAPON_GLOCK18 }, - { "elite", WEAPON_ELITE }, - { "fiveseven", WEAPON_FIVESEVEN }, - { "mp5navy", WEAPON_MP5N }, - { NULL, WEAPON_NONE } + { "p228", WEAPON_P228 }, + { "???", WEAPON_GLOCK }, + { "scout", WEAPON_SCOUT }, + { "hegren", WEAPON_HEGRENADE }, + { "xm1014", WEAPON_XM1014 }, + { "c4", WEAPON_C4 }, + { "mac10", WEAPON_MAC10 }, + { "aug", WEAPON_AUG }, + { "sgren", WEAPON_SMOKEGRENADE }, + { "elites", WEAPON_ELITE }, + { "fn57", WEAPON_FIVESEVEN }, + { "ump45", WEAPON_UMP45 }, + { "sg550", WEAPON_SG550 }, + { "galil", WEAPON_GALIL }, + { "famas", WEAPON_FAMAS }, + { "usp", WEAPON_USP }, + { "glock", WEAPON_GLOCK18 }, + { "awp", WEAPON_AWP }, + { "mp5", WEAPON_MP5N }, + { "m249", WEAPON_M249 }, + { "m3", WEAPON_M3 }, + { "m4a1", WEAPON_M4A1 }, + { "tmp", WEAPON_TMP }, + { "g3sg1", WEAPON_G3SG1 }, + { "flash", WEAPON_FLASHBANG }, + { "deagle", WEAPON_DEAGLE }, + { "sg552", WEAPON_SG552 }, + { "ak47", WEAPON_AK47 }, + { "knife", WEAPON_KNIFE }, + { "p90", WEAPON_P90 }, + { "shield", WEAPON_SHIELDGUN }, + { "none", WEAPON_NONE }, + { "grenade", WEAPON_HEGRENADE }, + { "hegrenade", WEAPON_HEGRENADE }, + { "glock18", WEAPON_GLOCK18 }, + { "elite", WEAPON_ELITE }, + { "fiveseven", WEAPON_FIVESEVEN }, + { "mp5navy", WEAPON_MP5N }, + { nullptr, WEAPON_NONE }, }; WeaponBuyAliasInfo weaponBuyAliasInfo[] = { - { "galil", WEAPON_GALIL, "#Galil" }, - { "defender", WEAPON_GALIL, "#Galil" }, - { "ak47", WEAPON_AK47, "#AK47" }, - { "cv47", WEAPON_AK47, "#AK47" }, - { "scout", WEAPON_SCOUT, NULL }, - { "sg552", WEAPON_SG552, "#SG552" }, - { "krieg552", WEAPON_SG552, "#SG552" }, - { "awp", WEAPON_AWP, NULL }, - { "magnum", WEAPON_AWP, NULL }, - { "g3sg1", WEAPON_G3SG1, "#G3SG1" }, - { "d3au1", WEAPON_G3SG1, "#G3SG1" }, - { "famas", WEAPON_FAMAS, "#Famas" }, - { "clarion", WEAPON_FAMAS, "#Famas" }, - { "m4a1", WEAPON_M4A1, "#M4A1" }, - { "aug", WEAPON_AUG, "#Aug" }, - { "bullpup", WEAPON_AUG, "#Aug" }, - { "sg550", WEAPON_SG550, "#SG550" }, - { "krieg550", WEAPON_SG550, "#SG550" }, - { "glock", WEAPON_GLOCK18, NULL }, - { "9x19mm", WEAPON_GLOCK18, NULL }, - { "usp", WEAPON_USP, NULL }, - { "km45", WEAPON_USP, NULL }, - { "p228", WEAPON_P228, NULL }, - { "228compact", WEAPON_P228, NULL }, - { "deagle", WEAPON_DEAGLE, NULL }, - { "nighthaw", WEAPON_DEAGLE, NULL }, - { "elites", WEAPON_ELITE, "#Beretta96G" }, - { "fn57", WEAPON_FIVESEVEN, "#FiveSeven" }, - { "fiveseven", WEAPON_FIVESEVEN, "#FiveSeven" }, - { "m3", WEAPON_M3, NULL }, - { "12gauge", WEAPON_M3, NULL }, - { "xm1014", WEAPON_XM1014, NULL }, - { "autoshotgun", WEAPON_XM1014, NULL }, - { "mac10", WEAPON_MAC10, "#Mac10" }, - { "tmp", WEAPON_TMP, "#tmp" }, - { "mp", WEAPON_TMP, "#tmp" }, - { "mp5", WEAPON_MP5N, NULL }, - { "smg", WEAPON_MP5N, NULL }, - { "ump45", WEAPON_UMP45, NULL }, - { "p90", WEAPON_P90, NULL }, - { "c90", WEAPON_P90, NULL }, - { "m249", WEAPON_M249, NULL }, - { NULL, WEAPON_NONE, NULL } + { "galil", WEAPON_GALIL, "#Galil" }, + { "defender", WEAPON_GALIL, "#Galil" }, + { "ak47", WEAPON_AK47, "#AK47" }, + { "cv47", WEAPON_AK47, "#AK47" }, + { "scout", WEAPON_SCOUT, nullptr }, + { "sg552", WEAPON_SG552, "#SG552" }, + { "krieg552", WEAPON_SG552, "#SG552" }, + { "awp", WEAPON_AWP, nullptr }, + { "magnum", WEAPON_AWP, nullptr }, + { "g3sg1", WEAPON_G3SG1, "#G3SG1" }, + { "d3au1", WEAPON_G3SG1, "#G3SG1" }, + { "famas", WEAPON_FAMAS, "#Famas" }, + { "clarion", WEAPON_FAMAS, "#Famas" }, + { "m4a1", WEAPON_M4A1, "#M4A1" }, + { "aug", WEAPON_AUG, "#Aug" }, + { "bullpup", WEAPON_AUG, "#Aug" }, + { "sg550", WEAPON_SG550, "#SG550" }, + { "krieg550", WEAPON_SG550, "#SG550" }, + { "glock", WEAPON_GLOCK18, nullptr }, + { "9x19mm", WEAPON_GLOCK18, nullptr }, + { "usp", WEAPON_USP, nullptr }, + { "km45", WEAPON_USP, nullptr }, + { "p228", WEAPON_P228, nullptr }, + { "228compact", WEAPON_P228, nullptr }, + { "deagle", WEAPON_DEAGLE, nullptr }, + { "nighthaw", WEAPON_DEAGLE, nullptr }, + { "elites", WEAPON_ELITE, "#Beretta96G" }, + { "fn57", WEAPON_FIVESEVEN, "#FiveSeven" }, + { "fiveseven", WEAPON_FIVESEVEN, "#FiveSeven" }, + { "m3", WEAPON_M3, nullptr }, + { "12gauge", WEAPON_M3, nullptr }, + { "xm1014", WEAPON_XM1014, nullptr }, + { "autoshotgun",WEAPON_XM1014, nullptr }, + { "mac10", WEAPON_MAC10, "#Mac10" }, + { "tmp", WEAPON_TMP, "#tmp" }, + { "mp", WEAPON_TMP, "#tmp" }, + { "mp5", WEAPON_MP5N, nullptr }, + { "smg", WEAPON_MP5N, nullptr }, + { "ump45", WEAPON_UMP45, nullptr }, + { "p90", WEAPON_P90, nullptr }, + { "c90", WEAPON_P90, nullptr }, + { "m249", WEAPON_M249, nullptr }, + { nullptr, WEAPON_NONE, nullptr }, }; WeaponClassAliasInfo weaponClassAliasInfo[] = { - { "p228", WEAPONCLASS_PISTOL }, - { "???", WEAPONCLASS_PISTOL }, - { "scout", WEAPONCLASS_SNIPERRIFLE }, - { "hegren", WEAPONCLASS_GRENADE }, - { "xm1014", WEAPONCLASS_SHOTGUN }, - { "c4", WEAPONCLASS_GRENADE }, - { "mac10", WEAPONCLASS_SUBMACHINEGUN }, - { "aug", WEAPONCLASS_RIFLE }, - { "sgren", WEAPONCLASS_GRENADE }, - { "elites", WEAPONCLASS_PISTOL }, - { "fn57", WEAPONCLASS_PISTOL }, - { "ump45", WEAPONCLASS_SUBMACHINEGUN }, - { "sg550", WEAPONCLASS_SNIPERRIFLE }, - { "galil", WEAPONCLASS_RIFLE }, - { "famas", WEAPONCLASS_RIFLE }, - { "usp", WEAPONCLASS_PISTOL }, - { "glock", WEAPONCLASS_PISTOL }, - { "awp", WEAPONCLASS_SNIPERRIFLE }, - { "mp5", WEAPONCLASS_SUBMACHINEGUN }, - { "m249", WEAPONCLASS_MACHINEGUN }, - { "m3", WEAPONCLASS_SHOTGUN }, - { "m4a1", WEAPONCLASS_RIFLE }, - { "tmp", WEAPONCLASS_SUBMACHINEGUN }, - { "g3sg1", WEAPONCLASS_SNIPERRIFLE }, - { "flash", WEAPONCLASS_GRENADE }, - { "deagle", WEAPONCLASS_PISTOL }, - { "sg552", WEAPONCLASS_RIFLE }, - { "ak47", WEAPONCLASS_RIFLE }, - { "knife", WEAPONCLASS_KNIFE }, - { "p90", WEAPONCLASS_SUBMACHINEGUN }, - { "shield", WEAPONCLASS_PISTOL }, - { "grenade", WEAPONCLASS_GRENADE }, - { "hegrenade", WEAPONCLASS_GRENADE }, - { "glock18", WEAPONCLASS_PISTOL }, - { "elite", WEAPONCLASS_PISTOL }, - { "fiveseven", WEAPONCLASS_PISTOL }, - { "mp5navy", WEAPONCLASS_SUBMACHINEGUN }, - { "grenade", WEAPONCLASS_GRENADE }, - { "pistol", WEAPONCLASS_PISTOL }, - { "SMG", WEAPONCLASS_SUBMACHINEGUN }, - { "machinegun", WEAPONCLASS_MACHINEGUN }, - { "shotgun", WEAPONCLASS_SHOTGUN }, - { "rifle", WEAPONCLASS_RIFLE }, - { "sniper", WEAPONCLASS_SNIPERRIFLE }, - { "none", WEAPONCLASS_NONE }, - { NULL, WEAPONCLASS_NONE } + { "p228", WEAPONCLASS_PISTOL }, + { "???", WEAPONCLASS_PISTOL }, + { "scout", WEAPONCLASS_SNIPERRIFLE }, + { "hegren", WEAPONCLASS_GRENADE }, + { "xm1014", WEAPONCLASS_SHOTGUN }, + { "c4", WEAPONCLASS_GRENADE }, + { "mac10", WEAPONCLASS_SUBMACHINEGUN }, + { "aug", WEAPONCLASS_RIFLE }, + { "sgren", WEAPONCLASS_GRENADE }, + { "elites", WEAPONCLASS_PISTOL }, + { "fn57", WEAPONCLASS_PISTOL }, + { "ump45", WEAPONCLASS_SUBMACHINEGUN }, + { "sg550", WEAPONCLASS_SNIPERRIFLE }, + { "galil", WEAPONCLASS_RIFLE }, + { "famas", WEAPONCLASS_RIFLE }, + { "usp", WEAPONCLASS_PISTOL }, + { "glock", WEAPONCLASS_PISTOL }, + { "awp", WEAPONCLASS_SNIPERRIFLE }, + { "mp5", WEAPONCLASS_SUBMACHINEGUN }, + { "m249", WEAPONCLASS_MACHINEGUN }, + { "m3", WEAPONCLASS_SHOTGUN }, + { "m4a1", WEAPONCLASS_RIFLE }, + { "tmp", WEAPONCLASS_SUBMACHINEGUN }, + { "g3sg1", WEAPONCLASS_SNIPERRIFLE }, + { "flash", WEAPONCLASS_GRENADE }, + { "deagle", WEAPONCLASS_PISTOL }, + { "sg552", WEAPONCLASS_RIFLE }, + { "ak47", WEAPONCLASS_RIFLE }, + { "knife", WEAPONCLASS_KNIFE }, + { "p90", WEAPONCLASS_SUBMACHINEGUN }, + { "shield", WEAPONCLASS_PISTOL }, + { "grenade", WEAPONCLASS_GRENADE }, + { "hegrenade", WEAPONCLASS_GRENADE }, + { "glock18", WEAPONCLASS_PISTOL }, + { "elite", WEAPONCLASS_PISTOL }, + { "fiveseven", WEAPONCLASS_PISTOL }, + { "mp5navy", WEAPONCLASS_SUBMACHINEGUN }, + { "grenade", WEAPONCLASS_GRENADE }, + { "pistol", WEAPONCLASS_PISTOL }, + { "SMG", WEAPONCLASS_SUBMACHINEGUN }, + { "machinegun", WEAPONCLASS_MACHINEGUN }, + { "shotgun", WEAPONCLASS_SHOTGUN }, + { "rifle", WEAPONCLASS_RIFLE }, + { "sniper", WEAPONCLASS_SNIPERRIFLE }, + { "none", WEAPONCLASS_NONE }, + { nullptr, WEAPONCLASS_NONE }, }; WeaponInfoStruct weaponInfo[31]; WeaponInfoStruct weaponInfo_default[] = { - { WEAPON_P228, P228_PRICE, AMMO_357SIG_PRICE, AMMO_357SIG_BUY, P228_MAX_CLIP, MAX_AMMO_357SIG, AMMO_357SIG, "weapon_p228", "ammo_357sig" }, + { WEAPON_P228, P228_PRICE, AMMO_357SIG_PRICE, AMMO_357SIG_BUY, P228_MAX_CLIP, MAX_AMMO_357SIG, AMMO_357SIG, "weapon_p228", "ammo_357sig" }, + +// fix collision with glock18 #ifdef REGAMEDLL_FIXES - // fix collision with glock18 - { WEAPON_GLOCK, GLOCK18_PRICE, AMMO_9MM_PRICE, AMMO_9MM_BUY, GLOCK18_MAX_CLIP, MAX_AMMO_9MM, AMMO_9MM, "weapon_glock", "ammo_9mm" }, + { WEAPON_GLOCK, GLOCK18_PRICE, AMMO_9MM_PRICE, AMMO_9MM_BUY, GLOCK18_MAX_CLIP, MAX_AMMO_9MM, AMMO_9MM, "weapon_glock", "ammo_9mm" }, #else - { WEAPON_GLOCK, GLOCK18_PRICE, AMMO_9MM_PRICE, AMMO_9MM_BUY, GLOCK18_MAX_CLIP, MAX_AMMO_9MM, AMMO_9MM, "weapon_glock18", "ammo_9mm" }, -#endif - { WEAPON_GLOCK18, GLOCK18_PRICE, AMMO_9MM_PRICE, AMMO_9MM_BUY, GLOCK18_MAX_CLIP, MAX_AMMO_9MM, AMMO_9MM, "weapon_glock18", "ammo_9mm" }, - { WEAPON_SCOUT, SCOUT_PRICE, AMMO_762MM_PRICE, AMMO_762NATO_BUY, SCOUT_MAX_CLIP, MAX_AMMO_762NATO, AMMO_762NATO, "weapon_scout", "ammo_762nato" }, - { WEAPON_XM1014, XM1014_PRICE, AMMO_BUCKSHOT_PRICE, AMMO_BUCKSHOT_BUY, XM1014_MAX_CLIP, MAX_AMMO_BUCKSHOT, AMMO_BUCKSHOT, "weapon_xm1014", "ammo_buckshot" }, - { WEAPON_MAC10, MAC10_PRICE, AMMO_45ACP_PRICE, AMMO_45ACP_BUY, MAC10_MAX_CLIP, MAX_AMMO_45ACP, AMMO_45ACP, "weapon_mac10", "ammo_45acp" }, - { WEAPON_AUG, AUG_PRICE, AMMO_556MM_PRICE, AMMO_556NATO_BUY, AUG_MAX_CLIP, MAX_AMMO_556NATO, AMMO_556NATO, "weapon_aug", "ammo_556nato" }, - { WEAPON_ELITE, ELITE_PRICE, AMMO_9MM_PRICE, AMMO_9MM_BUY, ELITE_MAX_CLIP, MAX_AMMO_9MM, AMMO_9MM, "weapon_elite", "ammo_9mm" }, - { WEAPON_FIVESEVEN, FIVESEVEN_PRICE, AMMO_57MM_PRICE, AMMO_57MM_BUY, FIVESEVEN_MAX_CLIP, MAX_AMMO_57MM, AMMO_57MM, "weapon_fiveseven", "ammo_57mm" }, - { WEAPON_UMP45, UMP45_PRICE, AMMO_45ACP_PRICE, AMMO_45ACP_BUY, UMP45_MAX_CLIP, MAX_AMMO_45ACP, AMMO_45ACP, "weapon_ump45", "ammo_45acp" }, - { WEAPON_SG550, SG550_PRICE, AMMO_556MM_PRICE, AMMO_556NATO_BUY, SG550_MAX_CLIP, MAX_AMMO_556NATO, AMMO_556NATO, "weapon_sg550", "ammo_556nato" }, - { WEAPON_GALIL, GALIL_PRICE, AMMO_556MM_PRICE, AMMO_556NATO_BUY, GALIL_MAX_CLIP, MAX_AMMO_556NATO, AMMO_556NATO, "weapon_galil", "ammo_556nato" }, - { WEAPON_FAMAS, FAMAS_PRICE, AMMO_556MM_PRICE, AMMO_556NATO_BUY, FAMAS_MAX_CLIP, MAX_AMMO_556NATO, AMMO_556NATO, "weapon_famas", "ammo_556nato" }, - { WEAPON_USP, USP_PRICE, AMMO_45ACP_PRICE, AMMO_45ACP_BUY, USP_MAX_CLIP, MAX_AMMO_45ACP, AMMO_45ACP, "weapon_usp", "ammo_45acp" }, - { WEAPON_AWP, AWP_PRICE, AMMO_338MAG_PRICE, AMMO_338MAG_BUY, AWP_MAX_CLIP, MAX_AMMO_338MAGNUM, AMMO_338MAGNUM, "weapon_awp", "ammo_338magnum" }, - { WEAPON_MP5N, MP5NAVY_PRICE, AMMO_9MM_PRICE, AMMO_9MM_BUY, MP5N_MAX_CLIP, MAX_AMMO_9MM, AMMO_9MM, "weapon_mp5navy", "ammo_9mm" }, - { WEAPON_M249, M249_PRICE, AMMO_556MM_PRICE, AMMO_556NATOBOX_BUY, M249_MAX_CLIP, MAX_AMMO_556NATOBOX, AMMO_556NATOBOX, "weapon_m249", "ammo_556natobox" }, - { WEAPON_M3, M3_PRICE, AMMO_BUCKSHOT_PRICE, AMMO_BUCKSHOT_BUY, M3_MAX_CLIP, MAX_AMMO_BUCKSHOT, AMMO_BUCKSHOT, "weapon_m3", "ammo_buckshot" }, - { WEAPON_M4A1, M4A1_PRICE, AMMO_556MM_PRICE, AMMO_556NATO_BUY, M4A1_MAX_CLIP, MAX_AMMO_556NATO, AMMO_556NATO, "weapon_m4a1", "ammo_556nato" }, - { WEAPON_TMP, TMP_PRICE, AMMO_9MM_PRICE, AMMO_9MM_BUY, TMP_MAX_CLIP, MAX_AMMO_9MM, AMMO_9MM, "weapon_tmp", "ammo_9mm" }, - { WEAPON_G3SG1, G3SG1_PRICE, AMMO_762MM_PRICE, AMMO_762NATO_BUY, G3SG1_MAX_CLIP, MAX_AMMO_762NATO, AMMO_762NATO, "weapon_g3sg1", "ammo_762nato" }, - { WEAPON_DEAGLE, DEAGLE_PRICE, AMMO_50AE_PRICE, AMMO_50AE_BUY, DEAGLE_MAX_CLIP, MAX_AMMO_50AE, AMMO_50AE, "weapon_deagle", "ammo_50ae" }, - { WEAPON_SG552, SG552_PRICE, AMMO_556MM_PRICE, AMMO_556NATO_BUY, SG552_MAX_CLIP, MAX_AMMO_556NATO, AMMO_556NATO, "weapon_sg552", "ammo_556nato" }, - { WEAPON_AK47, AK47_PRICE, AMMO_762MM_PRICE, AMMO_762NATO_BUY, AK47_MAX_CLIP, MAX_AMMO_762NATO, AMMO_762NATO, "weapon_ak47", "ammo_762nato" }, - { WEAPON_P90, P90_PRICE, AMMO_57MM_PRICE, AMMO_57MM_BUY, P90_MAX_CLIP, MAX_AMMO_57MM, AMMO_57MM, "weapon_p90", "ammo_57mm" }, - -#ifdef REGAMEDLL_ADD - { WEAPON_C4, 0, 0, 0, 0, 0, AMMO_C4, "weapon_c4", nullptr }, - { WEAPON_KNIFE, 0, 0, 0, 0, 0, AMMO_NONE, "weapon_knife", nullptr }, - { WEAPON_HEGRENADE, (WeaponCostType)HEGRENADE_PRICE, 0, 0, 0, MAX_AMMO_HEGRENADE, AMMO_HEGRENADE, "weapon_hegrenade", nullptr }, - { WEAPON_SMOKEGRENADE, (WeaponCostType)SMOKEGRENADE_PRICE, 0, 0, 0, MAX_AMMO_SMOKEGRENADE, AMMO_SMOKEGRENADE, "weapon_smokegrenade", nullptr }, - { WEAPON_FLASHBANG, (WeaponCostType)FLASHBANG_PRICE, 0, 0, 0, MAX_AMMO_FLASHBANG, AMMO_FLASHBANG, "weapon_flashbang", nullptr }, + { WEAPON_GLOCK, GLOCK18_PRICE, AMMO_9MM_PRICE, AMMO_9MM_BUY, GLOCK18_MAX_CLIP, MAX_AMMO_9MM, AMMO_9MM, "weapon_glock18", "ammo_9mm" }, #endif - { WEAPON_SHIELDGUN, SHIELDGUN_PRICE, 0, 0, 0, 0, AMMO_NONE, "weapon_shield", nullptr }, -#ifndef REGAMEDLL_ADD - { 0, 0, 0, 0, 0, 0, AMMO_NONE, nullptr, nullptr } + { WEAPON_GLOCK18, GLOCK18_PRICE, AMMO_9MM_PRICE, AMMO_9MM_BUY, GLOCK18_MAX_CLIP, MAX_AMMO_9MM, AMMO_9MM, "weapon_glock18", "ammo_9mm" }, + { WEAPON_SCOUT, SCOUT_PRICE, AMMO_762MM_PRICE, AMMO_762NATO_BUY, SCOUT_MAX_CLIP, MAX_AMMO_762NATO, AMMO_762NATO, "weapon_scout", "ammo_762nato" }, + { WEAPON_XM1014, XM1014_PRICE, AMMO_BUCKSHOT_PRICE, AMMO_BUCKSHOT_BUY, XM1014_MAX_CLIP, MAX_AMMO_BUCKSHOT, AMMO_BUCKSHOT, "weapon_xm1014", "ammo_buckshot" }, + { WEAPON_MAC10, MAC10_PRICE, AMMO_45ACP_PRICE, AMMO_45ACP_BUY, MAC10_MAX_CLIP, MAX_AMMO_45ACP, AMMO_45ACP, "weapon_mac10", "ammo_45acp" }, + { WEAPON_AUG, AUG_PRICE, AMMO_556MM_PRICE, AMMO_556NATO_BUY, AUG_MAX_CLIP, MAX_AMMO_556NATO, AMMO_556NATO, "weapon_aug", "ammo_556nato" }, + { WEAPON_ELITE, ELITE_PRICE, AMMO_9MM_PRICE, AMMO_9MM_BUY, ELITE_MAX_CLIP, MAX_AMMO_9MM, AMMO_9MM, "weapon_elite", "ammo_9mm" }, + { WEAPON_FIVESEVEN, FIVESEVEN_PRICE, AMMO_57MM_PRICE, AMMO_57MM_BUY, FIVESEVEN_MAX_CLIP, MAX_AMMO_57MM, AMMO_57MM, "weapon_fiveseven", "ammo_57mm" }, + { WEAPON_UMP45, UMP45_PRICE, AMMO_45ACP_PRICE, AMMO_45ACP_BUY, UMP45_MAX_CLIP, MAX_AMMO_45ACP, AMMO_45ACP, "weapon_ump45", "ammo_45acp" }, + { WEAPON_SG550, SG550_PRICE, AMMO_556MM_PRICE, AMMO_556NATO_BUY, SG550_MAX_CLIP, MAX_AMMO_556NATO, AMMO_556NATO, "weapon_sg550", "ammo_556nato" }, + { WEAPON_GALIL, GALIL_PRICE, AMMO_556MM_PRICE, AMMO_556NATO_BUY, GALIL_MAX_CLIP, MAX_AMMO_556NATO, AMMO_556NATO, "weapon_galil", "ammo_556nato" }, + { WEAPON_FAMAS, FAMAS_PRICE, AMMO_556MM_PRICE, AMMO_556NATO_BUY, FAMAS_MAX_CLIP, MAX_AMMO_556NATO, AMMO_556NATO, "weapon_famas", "ammo_556nato" }, + { WEAPON_USP, USP_PRICE, AMMO_45ACP_PRICE, AMMO_45ACP_BUY, USP_MAX_CLIP, MAX_AMMO_45ACP, AMMO_45ACP, "weapon_usp", "ammo_45acp" }, + { WEAPON_AWP, AWP_PRICE, AMMO_338MAG_PRICE, AMMO_338MAG_BUY, AWP_MAX_CLIP, MAX_AMMO_338MAGNUM, AMMO_338MAGNUM, "weapon_awp", "ammo_338magnum" }, + { WEAPON_MP5N, MP5NAVY_PRICE, AMMO_9MM_PRICE, AMMO_9MM_BUY, MP5N_MAX_CLIP, MAX_AMMO_9MM, AMMO_9MM, "weapon_mp5navy", "ammo_9mm" }, + { WEAPON_M249, M249_PRICE, AMMO_556MM_PRICE, AMMO_556NATOBOX_BUY, M249_MAX_CLIP, MAX_AMMO_556NATOBOX, AMMO_556NATOBOX, "weapon_m249", "ammo_556natobox" }, + { WEAPON_M3, M3_PRICE, AMMO_BUCKSHOT_PRICE, AMMO_BUCKSHOT_BUY, M3_MAX_CLIP, MAX_AMMO_BUCKSHOT, AMMO_BUCKSHOT, "weapon_m3", "ammo_buckshot" }, + { WEAPON_M4A1, M4A1_PRICE, AMMO_556MM_PRICE, AMMO_556NATO_BUY, M4A1_MAX_CLIP, MAX_AMMO_556NATO, AMMO_556NATO, "weapon_m4a1", "ammo_556nato" }, + { WEAPON_TMP, TMP_PRICE, AMMO_9MM_PRICE, AMMO_9MM_BUY, TMP_MAX_CLIP, MAX_AMMO_9MM, AMMO_9MM, "weapon_tmp", "ammo_9mm" }, + { WEAPON_G3SG1, G3SG1_PRICE, AMMO_762MM_PRICE, AMMO_762NATO_BUY, G3SG1_MAX_CLIP, MAX_AMMO_762NATO, AMMO_762NATO, "weapon_g3sg1", "ammo_762nato" }, + { WEAPON_DEAGLE, DEAGLE_PRICE, AMMO_50AE_PRICE, AMMO_50AE_BUY, DEAGLE_MAX_CLIP, MAX_AMMO_50AE, AMMO_50AE, "weapon_deagle", "ammo_50ae" }, + { WEAPON_SG552, SG552_PRICE, AMMO_556MM_PRICE, AMMO_556NATO_BUY, SG552_MAX_CLIP, MAX_AMMO_556NATO, AMMO_556NATO, "weapon_sg552", "ammo_556nato" }, + { WEAPON_AK47, AK47_PRICE, AMMO_762MM_PRICE, AMMO_762NATO_BUY, AK47_MAX_CLIP, MAX_AMMO_762NATO, AMMO_762NATO, "weapon_ak47", "ammo_762nato" }, + { WEAPON_P90, P90_PRICE, AMMO_57MM_PRICE, AMMO_57MM_BUY, P90_MAX_CLIP, MAX_AMMO_57MM, AMMO_57MM, "weapon_p90", "ammo_57mm" }, + +#ifdef REGAMEDLL_FIXES + { WEAPON_C4, 0, 0, 0, 0, 0, AMMO_C4, "weapon_c4", nullptr }, + { WEAPON_KNIFE, 0, 0, 0, 0, 0, AMMO_NONE, "weapon_knife", nullptr }, + { WEAPON_HEGRENADE, (WeaponCostType)HEGRENADE_PRICE, 0, 0, 0, MAX_AMMO_HEGRENADE, AMMO_HEGRENADE, "weapon_hegrenade", nullptr }, + { WEAPON_SMOKEGRENADE, (WeaponCostType)SMOKEGRENADE_PRICE, 0, 0, 0, MAX_AMMO_SMOKEGRENADE, AMMO_SMOKEGRENADE, "weapon_smokegrenade", nullptr }, + { WEAPON_FLASHBANG, (WeaponCostType)FLASHBANG_PRICE, 0, 0, 0, MAX_AMMO_FLASHBANG, AMMO_FLASHBANG, "weapon_flashbang", nullptr }, +#endif + + { WEAPON_SHIELDGUN, SHIELDGUN_PRICE, 0, 0, 0, 0, AMMO_NONE, "weapon_shield", nullptr }, +#ifndef REGAMEDLL_FIXES + { 0, 0, 0, 0, 0, 0, AMMO_NONE, nullptr, nullptr }, #endif }; #endif // HOOK_GAMEDLL WeaponSlotInfo weaponSlotInfo[] = { - { WEAPON_C4, C4_SLOT, "weapon_c4" }, - { WEAPON_KNIFE, KNIFE_SLOT, "weapon_knife" }, - { WEAPON_P228, PISTOL_SLOT, "weapon_p228" }, - { WEAPON_GLOCK, PISTOL_SLOT, "weapon_glock" }, - { WEAPON_ELITE, PISTOL_SLOT, "weapon_elite" }, - { WEAPON_FIVESEVEN, PISTOL_SLOT, "weapon_fiveseven" }, - { WEAPON_USP, PISTOL_SLOT, "weapon_usp" }, - { WEAPON_GLOCK18, PISTOL_SLOT, "weapon_glock18" }, - { WEAPON_DEAGLE, PISTOL_SLOT, "weapon_deagle" }, - { WEAPON_HEGRENADE, GRENADE_SLOT, "weapon_hegrenade" }, - { WEAPON_SMOKEGRENADE, GRENADE_SLOT, "weapon_smokegrenade" }, - { WEAPON_FLASHBANG, GRENADE_SLOT, "weapon_flashbang" }, - { WEAPON_SCOUT, PRIMARY_WEAPON_SLOT, "weapon_scout" }, - { WEAPON_XM1014, PRIMARY_WEAPON_SLOT, "weapon_xm1014" }, - { WEAPON_MAC10, PRIMARY_WEAPON_SLOT, "weapon_mac10" }, - { WEAPON_AUG, PRIMARY_WEAPON_SLOT, "weapon_aug" }, - { WEAPON_UMP45, PRIMARY_WEAPON_SLOT, "weapon_ump45" }, - { WEAPON_SG550, PRIMARY_WEAPON_SLOT, "weapon_sg550" }, - { WEAPON_GALIL, PRIMARY_WEAPON_SLOT, "weapon_galil" }, - { WEAPON_FAMAS, PRIMARY_WEAPON_SLOT, "weapon_famas" }, - { WEAPON_AWP, PRIMARY_WEAPON_SLOT, "weapon_awp" }, - { WEAPON_MP5N, PRIMARY_WEAPON_SLOT, "weapon_mp5navy" }, - { WEAPON_M249, PRIMARY_WEAPON_SLOT, "weapon_m249" }, - { WEAPON_M3, PRIMARY_WEAPON_SLOT, "weapon_m3" }, - { WEAPON_M4A1, PRIMARY_WEAPON_SLOT, "weapon_m4a1" }, - { WEAPON_TMP, PRIMARY_WEAPON_SLOT, "weapon_tmp" }, - { WEAPON_G3SG1, PRIMARY_WEAPON_SLOT, "weapon_g3sg1" }, - { WEAPON_SG552, PRIMARY_WEAPON_SLOT, "weapon_sg552" }, - { WEAPON_AK47, PRIMARY_WEAPON_SLOT, "weapon_ak47" }, - { WEAPON_P90, PRIMARY_WEAPON_SLOT, "weapon_p90" }, - { WEAPON_SHIELDGUN, NONE_SLOT, "weapon_shield" } + { WEAPON_C4, C4_SLOT, "weapon_c4" }, + { WEAPON_KNIFE, KNIFE_SLOT, "weapon_knife" }, + { WEAPON_P228, PISTOL_SLOT, "weapon_p228" }, + { WEAPON_GLOCK, PISTOL_SLOT, "weapon_glock" }, + { WEAPON_ELITE, PISTOL_SLOT, "weapon_elite" }, + { WEAPON_FIVESEVEN, PISTOL_SLOT, "weapon_fiveseven" }, + { WEAPON_USP, PISTOL_SLOT, "weapon_usp" }, + { WEAPON_GLOCK18, PISTOL_SLOT, "weapon_glock18" }, + { WEAPON_DEAGLE, PISTOL_SLOT, "weapon_deagle" }, + { WEAPON_HEGRENADE, GRENADE_SLOT, "weapon_hegrenade" }, + { WEAPON_SMOKEGRENADE, GRENADE_SLOT, "weapon_smokegrenade" }, + { WEAPON_FLASHBANG, GRENADE_SLOT, "weapon_flashbang" }, + { WEAPON_SCOUT, PRIMARY_WEAPON_SLOT, "weapon_scout" }, + { WEAPON_XM1014, PRIMARY_WEAPON_SLOT, "weapon_xm1014" }, + { WEAPON_MAC10, PRIMARY_WEAPON_SLOT, "weapon_mac10" }, + { WEAPON_AUG, PRIMARY_WEAPON_SLOT, "weapon_aug" }, + { WEAPON_UMP45, PRIMARY_WEAPON_SLOT, "weapon_ump45" }, + { WEAPON_SG550, PRIMARY_WEAPON_SLOT, "weapon_sg550" }, + { WEAPON_GALIL, PRIMARY_WEAPON_SLOT, "weapon_galil" }, + { WEAPON_FAMAS, PRIMARY_WEAPON_SLOT, "weapon_famas" }, + { WEAPON_AWP, PRIMARY_WEAPON_SLOT, "weapon_awp" }, + { WEAPON_MP5N, PRIMARY_WEAPON_SLOT, "weapon_mp5navy" }, + { WEAPON_M249, PRIMARY_WEAPON_SLOT, "weapon_m249" }, + { WEAPON_M3, PRIMARY_WEAPON_SLOT, "weapon_m3" }, + { WEAPON_M4A1, PRIMARY_WEAPON_SLOT, "weapon_m4a1" }, + { WEAPON_TMP, PRIMARY_WEAPON_SLOT, "weapon_tmp" }, + { WEAPON_G3SG1, PRIMARY_WEAPON_SLOT, "weapon_g3sg1" }, + { WEAPON_SG552, PRIMARY_WEAPON_SLOT, "weapon_sg552" }, + { WEAPON_AK47, PRIMARY_WEAPON_SLOT, "weapon_ak47" }, + { WEAPON_P90, PRIMARY_WEAPON_SLOT, "weapon_p90" }, + { WEAPON_SHIELDGUN, NONE_SLOT, "weapon_shield" }, }; // Given an alias, return the associated weapon ID WeaponIdType AliasToWeaponID(const char *alias) { - if (alias != NULL) + if (alias) { - for (int i = 0; weaponAliasInfo[i].alias != NULL; ++i) + for (int i = 0; weaponAliasInfo[i].alias; ++i) { if (!Q_stricmp(weaponAliasInfo[i].alias, alias)) return weaponAliasInfo[i].id; @@ -327,7 +329,7 @@ const char *BuyAliasToWeaponID(const char *alias, WeaponIdType &id) { if (alias) { - for (int i = 0; weaponBuyAliasInfo[i].alias != NULL; ++i) + for (int i = 0; weaponBuyAliasInfo[i].alias; ++i) { if (!Q_stricmp(weaponBuyAliasInfo[i].alias, alias)) { @@ -338,26 +340,26 @@ const char *BuyAliasToWeaponID(const char *alias, WeaponIdType &id) } id = WEAPON_NONE; - return NULL; + return nullptr; } // Given a weapon ID, return its alias const char *WeaponIDToAlias(int id) { - for (int i = 0; weaponAliasInfo[i].alias != NULL; ++i) + for (int i = 0; weaponAliasInfo[i].alias; ++i) { if (weaponAliasInfo[i].id == id) return weaponAliasInfo[i].alias; } - return NULL; + return nullptr; } WeaponClassType AliasToWeaponClass(const char *alias) { - if (alias != NULL) + if (alias) { - for (int i = 0; weaponClassAliasInfo[i].alias != NULL; ++i) + for (int i = 0; weaponClassAliasInfo[i].alias; ++i) { if (!Q_stricmp(weaponClassAliasInfo[i].alias, alias)) return weaponClassAliasInfo[i].id; @@ -452,7 +454,7 @@ void WeaponInfoReset() #endif } -WeaponSlotInfo* GetWeaponSlot(WeaponIdType weaponID) +WeaponSlotInfo *GetWeaponSlot(WeaponIdType weaponID) { for (auto& infoSlot : weaponSlotInfo) { if (infoSlot.id == weaponID) { @@ -463,7 +465,7 @@ WeaponSlotInfo* GetWeaponSlot(WeaponIdType weaponID) return nullptr; } -WeaponSlotInfo* GetWeaponSlot(const char* weaponName) +WeaponSlotInfo *GetWeaponSlot(const char *weaponName) { for (auto& infoSlot : weaponSlotInfo) { if (!Q_stricmp(infoSlot.weaponName, weaponName)) { diff --git a/regamedll/dlls/weapontype.h b/regamedll/dlls/weapontype.h index 872bc021..bb226979 100644 --- a/regamedll/dlls/weapontype.h +++ b/regamedll/dlls/weapontype.h @@ -26,11 +26,7 @@ * */ -#ifndef WEAPONTYPE_H -#define WEAPONTYPE_H -#ifdef _WIN32 #pragma once -#endif enum WeaponIdType { @@ -70,188 +66,188 @@ enum WeaponIdType enum AutoBuyClassType { - AUTOBUYCLASS_NONE = 0, - AUTOBUYCLASS_PRIMARY = (1 << 0), - AUTOBUYCLASS_SECONDARY = (1 << 1), - AUTOBUYCLASS_AMMO = (1 << 2), - AUTOBUYCLASS_ARMOR = (1 << 3), - AUTOBUYCLASS_DEFUSER = (1 << 4), - AUTOBUYCLASS_PISTOL = (1 << 5), - AUTOBUYCLASS_SMG = (1 << 6), - AUTOBUYCLASS_RIFLE = (1 << 7), - AUTOBUYCLASS_SNIPERRIFLE = (1 << 8), - AUTOBUYCLASS_SHOTGUN = (1 << 9), - AUTOBUYCLASS_MACHINEGUN = (1 << 10), - AUTOBUYCLASS_GRENADE = (1 << 11), - AUTOBUYCLASS_NIGHTVISION = (1 << 12), - AUTOBUYCLASS_SHIELD = (1 << 13), + AUTOBUYCLASS_NONE = 0, + AUTOBUYCLASS_PRIMARY = BIT(0), + AUTOBUYCLASS_SECONDARY = BIT(1), + AUTOBUYCLASS_AMMO = BIT(2), + AUTOBUYCLASS_ARMOR = BIT(3), + AUTOBUYCLASS_DEFUSER = BIT(4), + AUTOBUYCLASS_PISTOL = BIT(5), + AUTOBUYCLASS_SMG = BIT(6), + AUTOBUYCLASS_RIFLE = BIT(7), + AUTOBUYCLASS_SNIPERRIFLE = BIT(8), + AUTOBUYCLASS_SHOTGUN = BIT(9), + AUTOBUYCLASS_MACHINEGUN = BIT(10), + AUTOBUYCLASS_GRENADE = BIT(11), + AUTOBUYCLASS_NIGHTVISION = BIT(12), + AUTOBUYCLASS_SHIELD = BIT(13), }; enum AmmoCostType { - AMMO_338MAG_PRICE = 125, - AMMO_357SIG_PRICE = 50, - AMMO_45ACP_PRICE = 25, - AMMO_50AE_PRICE = 40, - AMMO_556MM_PRICE = 60, - AMMO_57MM_PRICE = 50, - AMMO_762MM_PRICE = 80, - AMMO_9MM_PRICE = 20, - AMMO_BUCKSHOT_PRICE = 65, + AMMO_338MAG_PRICE = 125, + AMMO_357SIG_PRICE = 50, + AMMO_45ACP_PRICE = 25, + AMMO_50AE_PRICE = 40, + AMMO_556MM_PRICE = 60, + AMMO_57MM_PRICE = 50, + AMMO_762MM_PRICE = 80, + AMMO_9MM_PRICE = 20, + AMMO_BUCKSHOT_PRICE = 65, }; enum WeaponCostType { - AK47_PRICE = 2500, - AWP_PRICE = 4750, - DEAGLE_PRICE = 650, - G3SG1_PRICE = 5000, - SG550_PRICE = 4200, - GLOCK18_PRICE = 400, - M249_PRICE = 5750, - M3_PRICE = 1700, - M4A1_PRICE = 3100, - AUG_PRICE = 3500, - MP5NAVY_PRICE = 1500, - P228_PRICE = 600, - P90_PRICE = 2350, - UMP45_PRICE = 1700, - MAC10_PRICE = 1400, - SCOUT_PRICE = 2750, - SG552_PRICE = 3500, - TMP_PRICE = 1250, - USP_PRICE = 500, - ELITE_PRICE = 800, - FIVESEVEN_PRICE = 750, - XM1014_PRICE = 3000, - GALIL_PRICE = 2000, - FAMAS_PRICE = 2250, - SHIELDGUN_PRICE = 2200, + AK47_PRICE = 2500, + AWP_PRICE = 4750, + DEAGLE_PRICE = 650, + G3SG1_PRICE = 5000, + SG550_PRICE = 4200, + GLOCK18_PRICE = 400, + M249_PRICE = 5750, + M3_PRICE = 1700, + M4A1_PRICE = 3100, + AUG_PRICE = 3500, + MP5NAVY_PRICE = 1500, + P228_PRICE = 600, + P90_PRICE = 2350, + UMP45_PRICE = 1700, + MAC10_PRICE = 1400, + SCOUT_PRICE = 2750, + SG552_PRICE = 3500, + TMP_PRICE = 1250, + USP_PRICE = 500, + ELITE_PRICE = 800, + FIVESEVEN_PRICE = 750, + XM1014_PRICE = 3000, + GALIL_PRICE = 2000, + FAMAS_PRICE = 2250, + SHIELDGUN_PRICE = 2200, }; enum WeaponState { - WPNSTATE_USP_SILENCED = (1 << 0), - WPNSTATE_GLOCK18_BURST_MODE = (1 << 1), - WPNSTATE_M4A1_SILENCED = (1 << 2), - WPNSTATE_ELITE_LEFT = (1 << 3), - WPNSTATE_FAMAS_BURST_MODE = (1 << 4), - WPNSTATE_SHIELD_DRAWN = (1 << 5), + WPNSTATE_USP_SILENCED = BIT(0), + WPNSTATE_GLOCK18_BURST_MODE = BIT(1), + WPNSTATE_M4A1_SILENCED = BIT(2), + WPNSTATE_ELITE_LEFT = BIT(3), + WPNSTATE_FAMAS_BURST_MODE = BIT(4), + WPNSTATE_SHIELD_DRAWN = BIT(5), }; // custom enum // the default amount of ammo that comes with each gun when it spawns enum ClipGiveDefault { - P228_DEFAULT_GIVE = 13, - GLOCK18_DEFAULT_GIVE = 20, - SCOUT_DEFAULT_GIVE = 10, - HEGRENADE_DEFAULT_GIVE = 1, - XM1014_DEFAULT_GIVE = 7, - C4_DEFAULT_GIVE = 1, - MAC10_DEFAULT_GIVE = 30, - AUG_DEFAULT_GIVE = 30, - SMOKEGRENADE_DEFAULT_GIVE = 1, - ELITE_DEFAULT_GIVE = 30, - FIVESEVEN_DEFAULT_GIVE = 20, - UMP45_DEFAULT_GIVE = 25, - SG550_DEFAULT_GIVE = 30, - GALIL_DEFAULT_GIVE = 35, - FAMAS_DEFAULT_GIVE = 25, - USP_DEFAULT_GIVE = 12, - AWP_DEFAULT_GIVE = 10, - MP5NAVY_DEFAULT_GIVE = 30, - M249_DEFAULT_GIVE = 100, - M3_DEFAULT_GIVE = 8, - M4A1_DEFAULT_GIVE = 30, - TMP_DEFAULT_GIVE = 30, - G3SG1_DEFAULT_GIVE = 20, - FLASHBANG_DEFAULT_GIVE = 1, - DEAGLE_DEFAULT_GIVE = 7, - SG552_DEFAULT_GIVE = 30, - AK47_DEFAULT_GIVE = 30, - /*KNIFE_DEFAULT_GIVE = 1,*/ - P90_DEFAULT_GIVE = 50, + P228_DEFAULT_GIVE = 13, + GLOCK18_DEFAULT_GIVE = 20, + SCOUT_DEFAULT_GIVE = 10, + HEGRENADE_DEFAULT_GIVE = 1, + XM1014_DEFAULT_GIVE = 7, + C4_DEFAULT_GIVE = 1, + MAC10_DEFAULT_GIVE = 30, + AUG_DEFAULT_GIVE = 30, + SMOKEGRENADE_DEFAULT_GIVE = 1, + ELITE_DEFAULT_GIVE = 30, + FIVESEVEN_DEFAULT_GIVE = 20, + UMP45_DEFAULT_GIVE = 25, + SG550_DEFAULT_GIVE = 30, + GALIL_DEFAULT_GIVE = 35, + FAMAS_DEFAULT_GIVE = 25, + USP_DEFAULT_GIVE = 12, + AWP_DEFAULT_GIVE = 10, + MP5NAVY_DEFAULT_GIVE = 30, + M249_DEFAULT_GIVE = 100, + M3_DEFAULT_GIVE = 8, + M4A1_DEFAULT_GIVE = 30, + TMP_DEFAULT_GIVE = 30, + G3SG1_DEFAULT_GIVE = 20, + FLASHBANG_DEFAULT_GIVE = 1, + DEAGLE_DEFAULT_GIVE = 7, + SG552_DEFAULT_GIVE = 30, + AK47_DEFAULT_GIVE = 30, + //KNIFE_DEFAULT_GIVE = 1, + P90_DEFAULT_GIVE = 50, }; enum ClipSizeType { - P228_MAX_CLIP = 13, - GLOCK18_MAX_CLIP = 20, - SCOUT_MAX_CLIP = 10, - XM1014_MAX_CLIP = 7, - MAC10_MAX_CLIP = 30, - AUG_MAX_CLIP = 30, - ELITE_MAX_CLIP = 30, - FIVESEVEN_MAX_CLIP = 20, - UMP45_MAX_CLIP = 25, - SG550_MAX_CLIP = 30, - GALIL_MAX_CLIP = 35, - FAMAS_MAX_CLIP = 25, - USP_MAX_CLIP = 12, - AWP_MAX_CLIP = 10, - MP5N_MAX_CLIP = 30, - M249_MAX_CLIP = 100, - M3_MAX_CLIP = 8, - M4A1_MAX_CLIP = 30, - TMP_MAX_CLIP = 30, - G3SG1_MAX_CLIP = 20, - DEAGLE_MAX_CLIP = 7, - SG552_MAX_CLIP = 30, - AK47_MAX_CLIP = 30, - P90_MAX_CLIP = 50, + P228_MAX_CLIP = 13, + GLOCK18_MAX_CLIP = 20, + SCOUT_MAX_CLIP = 10, + XM1014_MAX_CLIP = 7, + MAC10_MAX_CLIP = 30, + AUG_MAX_CLIP = 30, + ELITE_MAX_CLIP = 30, + FIVESEVEN_MAX_CLIP = 20, + UMP45_MAX_CLIP = 25, + SG550_MAX_CLIP = 30, + GALIL_MAX_CLIP = 35, + FAMAS_MAX_CLIP = 25, + USP_MAX_CLIP = 12, + AWP_MAX_CLIP = 10, + MP5N_MAX_CLIP = 30, + M249_MAX_CLIP = 100, + M3_MAX_CLIP = 8, + M4A1_MAX_CLIP = 30, + TMP_MAX_CLIP = 30, + G3SG1_MAX_CLIP = 20, + DEAGLE_MAX_CLIP = 7, + SG552_MAX_CLIP = 30, + AK47_MAX_CLIP = 30, + P90_MAX_CLIP = 50, }; enum WeightWeapon { - P228_WEIGHT = 5, - GLOCK18_WEIGHT = 5, - SCOUT_WEIGHT = 30, - HEGRENADE_WEIGHT = 2, - XM1014_WEIGHT = 20, - C4_WEIGHT = 3, - MAC10_WEIGHT = 25, - AUG_WEIGHT = 25, - SMOKEGRENADE_WEIGHT = 1, - ELITE_WEIGHT = 5, - FIVESEVEN_WEIGHT = 5, - UMP45_WEIGHT = 25, - SG550_WEIGHT = 20, - GALIL_WEIGHT = 25, - FAMAS_WEIGHT = 75, - USP_WEIGHT = 5, - AWP_WEIGHT = 30, - MP5NAVY_WEIGHT = 25, - M249_WEIGHT = 25, - M3_WEIGHT = 20, - M4A1_WEIGHT = 25, - TMP_WEIGHT = 25, - G3SG1_WEIGHT = 20, - FLASHBANG_WEIGHT = 1, - DEAGLE_WEIGHT = 7, - SG552_WEIGHT = 25, - AK47_WEIGHT = 25, - P90_WEIGHT = 26, - KNIFE_WEIGHT = 0, + P228_WEIGHT = 5, + GLOCK18_WEIGHT = 5, + SCOUT_WEIGHT = 30, + HEGRENADE_WEIGHT = 2, + XM1014_WEIGHT = 20, + C4_WEIGHT = 3, + MAC10_WEIGHT = 25, + AUG_WEIGHT = 25, + SMOKEGRENADE_WEIGHT = 1, + ELITE_WEIGHT = 5, + FIVESEVEN_WEIGHT = 5, + UMP45_WEIGHT = 25, + SG550_WEIGHT = 20, + GALIL_WEIGHT = 25, + FAMAS_WEIGHT = 75, + USP_WEIGHT = 5, + AWP_WEIGHT = 30, + MP5NAVY_WEIGHT = 25, + M249_WEIGHT = 25, + M3_WEIGHT = 20, + M4A1_WEIGHT = 25, + TMP_WEIGHT = 25, + G3SG1_WEIGHT = 20, + FLASHBANG_WEIGHT = 1, + DEAGLE_WEIGHT = 7, + SG552_WEIGHT = 25, + AK47_WEIGHT = 25, + P90_WEIGHT = 26, + KNIFE_WEIGHT = 0, }; enum MaxAmmoType { - MAX_AMMO_BUCKSHOT = 32, - MAX_AMMO_9MM = 120, - MAX_AMMO_556NATO = 90, - MAX_AMMO_556NATOBOX = 200, - MAX_AMMO_762NATO = 90, - MAX_AMMO_45ACP = 100, - MAX_AMMO_50AE = 35, - MAX_AMMO_338MAGNUM = 30, - MAX_AMMO_57MM = 100, - MAX_AMMO_357SIG = 52, + MAX_AMMO_BUCKSHOT = 32, + MAX_AMMO_9MM = 120, + MAX_AMMO_556NATO = 90, + MAX_AMMO_556NATOBOX = 200, + MAX_AMMO_762NATO = 90, + MAX_AMMO_45ACP = 100, + MAX_AMMO_50AE = 35, + MAX_AMMO_338MAGNUM = 30, + MAX_AMMO_57MM = 100, + MAX_AMMO_357SIG = 52, // custom - MAX_AMMO_SMOKEGRENADE = 1, - MAX_AMMO_HEGRENADE = 1, - MAX_AMMO_FLASHBANG = 2, + MAX_AMMO_SMOKEGRENADE = 1, + MAX_AMMO_HEGRENADE = 1, + MAX_AMMO_FLASHBANG = 2, }; enum AmmoType @@ -291,28 +287,28 @@ enum WeaponClassType enum AmmoBuyAmount { - AMMO_338MAG_BUY = 10, - AMMO_357SIG_BUY = 13, - AMMO_45ACP_BUY = 12, - AMMO_50AE_BUY = 7, - AMMO_556NATO_BUY = 30, - AMMO_556NATOBOX_BUY = 30, - AMMO_57MM_BUY = 50, - AMMO_762NATO_BUY = 30, - AMMO_9MM_BUY = 30, - AMMO_BUCKSHOT_BUY = 8, + AMMO_338MAG_BUY = 10, + AMMO_357SIG_BUY = 13, + AMMO_45ACP_BUY = 12, + AMMO_50AE_BUY = 7, + AMMO_556NATO_BUY = 30, + AMMO_556NATOBOX_BUY = 30, + AMMO_57MM_BUY = 50, + AMMO_762NATO_BUY = 30, + AMMO_9MM_BUY = 30, + AMMO_BUCKSHOT_BUY = 8, }; enum ItemCostType { - ASSAULTSUIT_PRICE = 1000, - FLASHBANG_PRICE = 200, - HEGRENADE_PRICE = 300, - SMOKEGRENADE_PRICE = 300, - KEVLAR_PRICE = 650, - HELMET_PRICE = 350, - NVG_PRICE = 1250, - DEFUSEKIT_PRICE = 200, + ASSAULTSUIT_PRICE = 1000, + FLASHBANG_PRICE = 200, + HEGRENADE_PRICE = 300, + SMOKEGRENADE_PRICE = 300, + KEVLAR_PRICE = 650, + HELMET_PRICE = 350, + NVG_PRICE = 1250, + DEFUSEKIT_PRICE = 200, }; enum shieldgun_e @@ -345,7 +341,7 @@ enum InventorySlotType GRENADE_SLOT, C4_SLOT, }; - + enum Bullet { BULLET_NONE, @@ -377,7 +373,7 @@ struct WeaponStruct struct AutoBuyInfoStruct { - AutoBuyClassType m_class; + int m_class; char *m_command; char *m_classname; }; @@ -437,10 +433,8 @@ bool IsSecondaryWeapon(int id); bool CanBuyWeaponByMaptype(int playerTeam, WeaponIdType weaponID, bool useAssasinationRestrictions); void WeaponInfoReset(); -WeaponInfoStruct* GetWeaponInfo(int weaponID); -WeaponInfoStruct* GetWeaponInfo(const char* weaponName); +WeaponInfoStruct *GetWeaponInfo(int weaponID); +WeaponInfoStruct *GetWeaponInfo(const char *weaponName); -WeaponSlotInfo* GetWeaponSlot(WeaponIdType weaponID); -WeaponSlotInfo* GetWeaponSlot(const char* weaponName); - -#endif // WEAPONTYPE_H +WeaponSlotInfo *GetWeaponSlot(WeaponIdType weaponID); +WeaponSlotInfo *GetWeaponSlot(const char *weaponName); diff --git a/regamedll/dlls/world.cpp b/regamedll/dlls/world.cpp index 3ff8cd23..2812c5d8 100644 --- a/regamedll/dlls/world.cpp +++ b/regamedll/dlls/world.cpp @@ -11,48 +11,48 @@ float g_flWeaponCheat; DLL_DECALLIST gDecals[] = { - { "{shot1", 0 }, // DECAL_GUNSHOT1 - { "{shot2", 0 }, // DECAL_GUNSHOT2 - { "{shot3", 0 }, // DECAL_GUNSHOT3 - { "{shot4", 0 }, // DECAL_GUNSHOT4 - { "{shot5", 0 }, // DECAL_GUNSHOT5 - { "{lambda01", 0 }, // DECAL_LAMBDA1 - { "{lambda02", 0 }, // DECAL_LAMBDA2 - { "{lambda03", 0 }, // DECAL_LAMBDA3 - { "{lambda04", 0 }, // DECAL_LAMBDA4 - { "{lambda05", 0 }, // DECAL_LAMBDA5 - { "{lambda06", 0 }, // DECAL_LAMBDA6 - { "{scorch1", 0 }, // DECAL_SCORCH1 - { "{scorch2", 0 }, // DECAL_SCORCH2 - { "{blood1", 0 }, // DECAL_BLOOD1 - { "{blood2", 0 }, // DECAL_BLOOD2 - { "{blood3", 0 }, // DECAL_BLOOD3 - { "{blood4", 0 }, // DECAL_BLOOD4 - { "{blood5", 0 }, // DECAL_BLOOD5 - { "{blood6", 0 }, // DECAL_BLOOD6 - { "{yblood1", 0 }, // DECAL_YBLOOD1 - { "{yblood2", 0 }, // DECAL_YBLOOD2 - { "{yblood3", 0 }, // DECAL_YBLOOD3 - { "{yblood4", 0 }, // DECAL_YBLOOD4 - { "{yblood5", 0 }, // DECAL_YBLOOD5 - { "{yblood6", 0 }, // DECAL_YBLOOD6 - { "{break1", 0 }, // DECAL_GLASSBREAK1 - { "{break2", 0 }, // DECAL_GLASSBREAK2 - { "{break3", 0 }, // DECAL_GLASSBREAK3 - { "{bigshot1", 0 }, // DECAL_BIGSHOT1 - { "{bigshot2", 0 }, // DECAL_BIGSHOT2 - { "{bigshot3", 0 }, // DECAL_BIGSHOT3 - { "{bigshot4", 0 }, // DECAL_BIGSHOT4 - { "{bigshot5", 0 }, // DECAL_BIGSHOT5 - { "{spit1", 0 }, // DECAL_SPIT1 - { "{spit2", 0 }, // DECAL_SPIT2 - { "{bproof1", 0 }, // DECAL_BPROOF1 - { "{gargstomp", 0 }, // DECAL_GARGSTOMP1, // Gargantua stomp crack - { "{smscorch1", 0 }, // DECAL_SMALLSCORCH1, // Small scorch mark - { "{smscorch2", 0 }, // DECAL_SMALLSCORCH2, // Small scorch mark - { "{smscorch3", 0 }, // DECAL_SMALLSCORCH3, // Small scorch mark - { "{mommablob", 0 }, // DECAL_MOMMABIRTH // BM Birth spray - { "{mommablob", 0 }, // DECAL_MOMMASPLAT // BM Mortar spray?? need decal*/ + DEFINE_DECAL("{shot1"), // DECAL_GUNSHOT1 + DEFINE_DECAL("{shot2"), // DECAL_GUNSHOT2 + DEFINE_DECAL("{shot3"), // DECAL_GUNSHOT3 + DEFINE_DECAL("{shot4"), // DECAL_GUNSHOT4 + DEFINE_DECAL("{shot5"), // DECAL_GUNSHOT5 + DEFINE_DECAL("{lambda01"), // DECAL_LAMBDA1 + DEFINE_DECAL("{lambda02"), // DECAL_LAMBDA2 + DEFINE_DECAL("{lambda03"), // DECAL_LAMBDA3 + DEFINE_DECAL("{lambda04"), // DECAL_LAMBDA4 + DEFINE_DECAL("{lambda05"), // DECAL_LAMBDA5 + DEFINE_DECAL("{lambda06"), // DECAL_LAMBDA6 + DEFINE_DECAL("{scorch1"), // DECAL_SCORCH1 + DEFINE_DECAL("{scorch2"), // DECAL_SCORCH2 + DEFINE_DECAL("{blood1"), // DECAL_BLOOD1 + DEFINE_DECAL("{blood2"), // DECAL_BLOOD2 + DEFINE_DECAL("{blood3"), // DECAL_BLOOD3 + DEFINE_DECAL("{blood4"), // DECAL_BLOOD4 + DEFINE_DECAL("{blood5"), // DECAL_BLOOD5 + DEFINE_DECAL("{blood6"), // DECAL_BLOOD6 + DEFINE_DECAL("{yblood1"), // DECAL_YBLOOD1 + DEFINE_DECAL("{yblood2"), // DECAL_YBLOOD2 + DEFINE_DECAL("{yblood3"), // DECAL_YBLOOD3 + DEFINE_DECAL("{yblood4"), // DECAL_YBLOOD4 + DEFINE_DECAL("{yblood5"), // DECAL_YBLOOD5 + DEFINE_DECAL("{yblood6"), // DECAL_YBLOOD6 + DEFINE_DECAL("{break1"), // DECAL_GLASSBREAK1 + DEFINE_DECAL("{break2"), // DECAL_GLASSBREAK2 + DEFINE_DECAL("{break3"), // DECAL_GLASSBREAK3 + DEFINE_DECAL("{bigshot1"), // DECAL_BIGSHOT1 + DEFINE_DECAL("{bigshot2"), // DECAL_BIGSHOT2 + DEFINE_DECAL("{bigshot3"), // DECAL_BIGSHOT3 + DEFINE_DECAL("{bigshot4"), // DECAL_BIGSHOT4 + DEFINE_DECAL("{bigshot5"), // DECAL_BIGSHOT5 + DEFINE_DECAL("{spit1"), // DECAL_SPIT1 + DEFINE_DECAL("{spit2"), // DECAL_SPIT2 + DEFINE_DECAL("{bproof1"), // DECAL_BPROOF1 + DEFINE_DECAL("{gargstomp"), // DECAL_GARGSTOMP1, // Gargantua stomp crack + DEFINE_DECAL("{smscorch1"), // DECAL_SMALLSCORCH1, // Small scorch mark + DEFINE_DECAL("{smscorch2"), // DECAL_SMALLSCORCH2, // Small scorch mark + DEFINE_DECAL("{smscorch3"), // DECAL_SMALLSCORCH3, // Small scorch mark + DEFINE_DECAL("{mommablob"), // DECAL_MOMMABIRTH // BM Birth spray + DEFINE_DECAL("{mommablob"), // DECAL_MOMMASPLAT // BM Mortar spray?? need decal*/ }; TYPEDESCRIPTION CGlobalState::m_SaveData[] = @@ -71,6 +71,8 @@ TYPEDESCRIPTION gGlobalEntitySaveData[] = char g_szMapBriefingText[512]; +#define SF_DECAL_NOTINDEATHMATCH BIT(11) + class CDecal: public CBaseEntity { public: @@ -165,7 +167,9 @@ void CDecal::KeyValue(KeyValueData *pkvd) ALERT(at_console, "Can't find decal %s\n", pkvd->szValue); } else + { CBaseEntity::KeyValue(pkvd); + } } // Body queue class here.... It's really just CBaseEntity @@ -179,7 +183,7 @@ LINK_ENTITY_TO_CLASS(bodyque, CCorpse, CCSCorpse) static void InitBodyQue() { - g_pBodyQueueHead = NULL; + g_pBodyQueueHead = nullptr; } // make a body que entry for the given ent so the ent can be respawned elsewhere @@ -228,19 +232,19 @@ CGlobalState::CGlobalState() void CGlobalState::Reset() { - m_pList = NULL; + m_pList = nullptr; m_listCount = 0; } globalentity_t *CGlobalState::Find(string_t globalname) { if (!globalname) - return NULL; + return nullptr; globalentity_t *pTest = m_pList; const char *pEntityName = STRING(globalname); - while (pTest != NULL) + while (pTest) { if (!Q_strcmp(pEntityName, pTest->name)) break; @@ -260,7 +264,7 @@ void CGlobalState::DumpGlobals() ALERT(at_console, "-- Globals --\n"); pTest = m_pList; - while (pTest != NULL) + while (pTest) { ALERT(at_console, "%s: %s (%s)\n", pTest->name, pTest->levelName, estates[ pTest->state ]); pTest = pTest->pNext; @@ -271,8 +275,8 @@ void CGlobalState::EntityAdd(string_t globalname, string_t mapName, GLOBALESTATE { assert(!Find(globalname)); - globalentity_t *pNewEntity = (globalentity_t *)Q_calloc(sizeof(globalentity_t), 1); - assert(pNewEntity != NULL); + globalentity_t *pNewEntity = (globalentity_t *)calloc(sizeof(globalentity_t), 1); + assert(pNewEntity != nullptr); pNewEntity->pNext = m_pList; m_pList = pNewEntity; @@ -286,8 +290,7 @@ void CGlobalState::EntityAdd(string_t globalname, string_t mapName, GLOBALESTATE void CGlobalState::EntitySetState(string_t globalname, GLOBALESTATE state) { globalentity_t *pEnt = Find(globalname); - - if (pEnt != NULL) + if (pEnt) { pEnt->state = state; } @@ -303,8 +306,7 @@ const globalentity_t *CGlobalState::EntityFromTable(string_t globalname) GLOBALESTATE CGlobalState::EntityGetState(string_t globalname) { globalentity_t *pEnt = Find(globalname); - - if (pEnt != NULL) + if (pEnt) { return pEnt->state; } @@ -323,7 +325,7 @@ int CGlobalState::Save(CSave &save) } pEntity = m_pList; - for (i = 0; i < m_listCount && pEntity != NULL; ++i) + for (i = 0; i < m_listCount && pEntity; i++) { if (!save.WriteFields("GENT", pEntity, gGlobalEntitySaveData, ARRAYSIZE(gGlobalEntitySaveData))) { @@ -370,8 +372,7 @@ int CGlobalState::Restore(CRestore &restore) void CGlobalState::EntityUpdate(string_t globalname, string_t mapname) { globalentity_t *pEnt = Find(globalname); - - if (pEnt != NULL) + if (pEnt) { Q_strcpy(pEnt->levelName, STRING(mapname)); } @@ -380,12 +381,11 @@ void CGlobalState::EntityUpdate(string_t globalname, string_t mapname) void CGlobalState::ClearStates() { globalentity_t *pFree = m_pList; - - while (pFree != NULL) + while (pFree) { globalentity_t *pNext = pFree->pNext; - Q_free(pFree); + free(pFree); pFree = pNext; } @@ -485,9 +485,9 @@ void CWorld::Spawn() void CWorld::Precache() { - g_pLastSpawn = NULL; - g_pLastCTSpawn = NULL; - g_pLastTerroristSpawn = NULL; + g_pLastSpawn = nullptr; + g_pLastCTSpawn = nullptr; + g_pLastTerroristSpawn = nullptr; CVAR_SET_STRING("sv_gravity", "800"); CVAR_SET_STRING("sv_maxspeed", "900"); @@ -510,9 +510,9 @@ void CWorld::Precache() // LATER - do we want a sound ent in deathmatch? (sjb) //pSoundEnt = CBaseEntity::Create("soundent", g_vecZero, g_vecZero, edict()); - pSoundEnt = GetClassPtr((CSoundEnt *)NULL); + pSoundEnt = GetClassPtr((CSoundEnt *)nullptr); - if (pSoundEnt == NULL) + if (pSoundEnt == nullptr) { ALERT(at_console, "**COULD NOT CREATE SOUNDENT**\n"); } @@ -621,35 +621,9 @@ void CWorld::Precache() // 63 testing LIGHT_STYLE(63, "a"); - for (int i = 0; i < ARRAYSIZE(gDecals); ++i) + for (int i = 0; i < ARRAYSIZE(gDecals); i++) gDecals[i].index = DECAL_INDEX(gDecals[i].name); -#ifndef REGAMEDLL_FIXES - // init the WorldGraph. - WorldGraph.InitGraph(); - - // make sure the .NOD file is newer than the .BSP file. - if (!WorldGraph.CheckNODFile((char *)STRING(gpGlobals->mapname))) - { - // NOD file is not present, or is older than the BSP file. - WorldGraph.AllocNodes(); - } - else - { - // Load the node graph for this level - if (!WorldGraph.FLoadGraph((char *)STRING(gpGlobals->mapname))) - { - // couldn't load, so alloc and prepare to build a graph. - ALERT(at_console, "*Error opening .NOD file\n"); - WorldGraph.AllocNodes(); - } - else - { - ALERT(at_console, "\n*Graph Loaded!\n"); - } - } -#endif - if (pev->speed > 0) CVAR_SET_FLOAT("sv_zmax", pev->speed); else @@ -659,9 +633,8 @@ void CWorld::Precache() { ALERT(at_aiconsole, "Chapter title: %s\n", STRING(pev->netname)); - CBaseEntity *pEntity = CBaseEntity::Create("env_message", g_vecZero, g_vecZero, NULL); - - if (pEntity != NULL) + CBaseEntity *pEntity = CBaseEntity::Create("env_message", g_vecZero, g_vecZero, nullptr); + if (pEntity) { pEntity->SetThink(&CBaseEntity::SUB_CallUseToggle); pEntity->pev->message = pev->netname; @@ -755,5 +728,7 @@ void CWorld::KeyValue(KeyValueData *pkvd) pkvd->fHandled = TRUE; } else + { CBaseEntity::KeyValue(pkvd); + } } diff --git a/regamedll/dlls/world.h b/regamedll/dlls/world.h index 4d6eda30..4292661c 100644 --- a/regamedll/dlls/world.h +++ b/regamedll/dlls/world.h @@ -26,13 +26,19 @@ * */ -#ifndef WORLD_H -#define WORLD_H -#ifdef _WIN32 #pragma once -#endif -#define SF_DECAL_NOTINDEATHMATCH 2048 +#define SF_WORLD_DARK BIT(0) // Fade from black at startup +#define SF_WORLD_TITLE BIT(1) // Display game title at startup +#define SF_WORLD_FORCETEAM BIT(2) // Force teams + +// This spawns first when each level begins. +class CWorld: public CBaseEntity { +public: + virtual void Spawn(); + virtual void Precache(); + virtual void KeyValue(KeyValueData *pkvd); +}; void CopyToBodyQue(entvars_t *pev); void ClearBodyQue(); @@ -43,5 +49,3 @@ void ResetGlobalState(); extern CGlobalState gGlobalState; extern float g_flWeaponCheat; extern char g_szMapBriefingText[512]; - -#endif // WORLD_H diff --git a/regamedll/dlls/wpn_shared.h b/regamedll/dlls/wpn_shared.h deleted file mode 100644 index b8de084e..00000000 --- a/regamedll/dlls/wpn_shared.h +++ /dev/null @@ -1,598 +0,0 @@ -#pragma once - -//AK47 -#define AK47_MAX_SPEED 221 -#define AK47_DAMAGE 36 -#define AK47_RANGE_MODIFER 0.98 -#define AK47_RELOAD_TIME 2.45 - -enum ak47_e -{ - AK47_IDLE1, - AK47_RELOAD, - AK47_DRAW, - AK47_SHOOT1, - AK47_SHOOT2, - AK47_SHOOT3 -}; - - - -//AUG -#define AUG_MAX_SPEED 240 -#define AUG_DAMAGE 32 -#define AUG_RANGE_MODIFER 0.96 -#define AUG_RELOAD_TIME 3.3 - -enum aug_e -{ - AUG_IDLE1, - AUG_RELOAD, - AUG_DRAW, - AUG_SHOOT1, - AUG_SHOOT2, - AUG_SHOOT3 -}; - - - -//AWP -#define AWP_MAX_SPEED 210 -#define AWP_MAX_SPEED_ZOOM 150 -#define AWP_DAMAGE 115 -#define AWP_RANGE_MODIFER 0.99 -#define AWP_RELOAD_TIME 2.5 - -enum awp_e -{ - AWP_IDLE, - AWP_SHOOT, - AWP_SHOOT2, - AWP_SHOOT3, - AWP_RELOAD, - AWP_DRAW, -}; - - - -//C4 -#define C4_MAX_AMMO 1 -#define C4_MAX_SPEED 250.0 -#define C4_ARMING_ON_TIME 3.0 - -enum c4_e -{ - C4_IDLE1, - C4_DRAW, - C4_DROP, - C4_ARM -}; - - - -//Deagle -#define DEAGLE_MAX_SPEED 250 -#define DEAGLE_DAMAGE 54 -#define DEAGLE_RANGE_MODIFER 0.81 -#define DEAGLE_RELOAD_TIME 2.2 - -enum deagle_e -{ - DEAGLE_IDLE1, - DEAGLE_SHOOT1, - DEAGLE_SHOOT2, - DEAGLE_SHOOT_EMPTY, - DEAGLE_RELOAD, - DEAGLE_DRAW -}; - - - -//Elites -#define ELITE_MAX_SPEED 250 -#define ELITE_RELOAD_TIME 4.5 -#define ELITE_DAMAGE 36 -#define ELITE_RANGE_MODIFER 0.75 - -enum elite_e -{ - ELITE_IDLE, - ELITE_IDLE_LEFTEMPTY, - ELITE_SHOOTLEFT1, - ELITE_SHOOTLEFT2, - ELITE_SHOOTLEFT3, - ELITE_SHOOTLEFT4, - ELITE_SHOOTLEFT5, - ELITE_SHOOTLEFTLAST, - ELITE_SHOOTRIGHT1, - ELITE_SHOOTRIGHT2, - ELITE_SHOOTRIGHT3, - ELITE_SHOOTRIGHT4, - ELITE_SHOOTRIGHT5, - ELITE_SHOOTRIGHTLAST, - ELITE_RELOAD, - ELITE_DRAW -}; - - - -//Famas -#define FAMAS_MAX_SPEED 240 -#define FAMAS_RELOAD_TIME 3.3 -#define FAMAS_DAMAGE 30 -#define FAMAS_DAMAGE_BURST 34 -#define FAMAS_RANGE_MODIFER 0.96 - -enum famas_e -{ - FAMAS_IDLE1, - FAMAS_RELOAD, - FAMAS_DRAW, - FAMAS_SHOOT1, - FAMAS_SHOOT2, - FAMAS_SHOOT3 -}; - - - -//Fiveseven -#define FIVESEVEN_MAX_SPEED 250 -#define FIVESEVEN_DAMAGE 20 -#define FIVESEVEN_RANGE_MODIFER 0.885 -#define FIVESEVEN_RELOAD_TIME 2.7 - -enum fiveseven_e -{ - FIVESEVEN_IDLE, - FIVESEVEN_SHOOT1, - FIVESEVEN_SHOOT2, - FIVESEVEN_SHOOT_EMPTY, - FIVESEVEN_RELOAD, - FIVESEVEN_DRAW -}; - - - -//Flashbang -#define FLASHBANG_MAX_SPEED 250 -#define FLASHBANG_MAX_SPEED_SHIELD 180 - -enum flashbang_e -{ - FLASHBANG_IDLE, - FLASHBANG_PULLPIN, - FLASHBANG_THROW, - FLASHBANG_DRAW -}; - - - -//g3sg1 -#define G3SG1_MAX_SPEED 210 -#define G3SG1_MAX_SPEED_ZOOM 150 -#define G3SG1_DAMAGE 80 -#define G3SG1_RANGE_MODIFER 0.98 -#define G3SG1_RELOAD_TIME 3.5 - -enum g3sg1_e -{ - G3SG1_IDLE, - G3SG1_SHOOT, - G3SG1_SHOOT2, - G3SG1_RELOAD, - G3SG1_DRAW -}; - - - -//galil -#define GALIL_MAX_SPEED 240 -#define GALIL_DAMAGE 30 -#define GALIL_RANGE_MODIFER 0.98 -#define GALIL_RELOAD_TIME 2.45 - -enum galil_e -{ - GALIL_IDLE1, - GALIL_RELOAD, - GALIL_DRAW, - GALIL_SHOOT1, - GALIL_SHOOT2, - GALIL_SHOOT3 -}; - - - -//glock18 -#define GLOCK18_MAX_SPEED 250 -#define GLOCK18_DAMAGE 25 -#define GLOCK18_RANGE_MODIFER 0.75 -#define GLOCK18_RELOAD_TIME 2.2 - -enum glock18_e -{ - GLOCK18_IDLE1, - GLOCK18_IDLE2, - GLOCK18_IDLE3, - GLOCK18_SHOOT, - GLOCK18_SHOOT2, - GLOCK18_SHOOT3, - GLOCK18_SHOOT_EMPTY, - GLOCK18_RELOAD, - GLOCK18_DRAW, - GLOCK18_HOLSTER, - GLOCK18_ADD_SILENCER, - GLOCK18_DRAW2, - GLOCK18_RELOAD2 -}; - -enum glock18_shield_e -{ - GLOCK18_SHIELD_IDLE1, - GLOCK18_SHIELD_SHOOT, - GLOCK18_SHIELD_SHOOT2, - GLOCK18_SHIELD_SHOOT_EMPTY, - GLOCK18_SHIELD_RELOAD, - GLOCK18_SHIELD_DRAW, - GLOCK18_SHIELD_IDLE, - GLOCK18_SHIELD_UP, - GLOCK18_SHIELD_DOWN -}; - - - -//hegrenade -#define HEGRENADE_MAX_SPEED 250 -#define HEGRENADE_MAX_SPEED_SHIELD 180 - -enum hegrenade_e -{ - HEGRENADE_IDLE, - HEGRENADE_PULLPIN, - HEGRENADE_THROW, - HEGRENADE_DRAW -}; - - - -//knife -#define KNIFE_BODYHIT_VOLUME 128 -#define KNIFE_WALLHIT_VOLUME 512 -#define KNIFE_MAX_SPEED 250 -#define KNIFE_MAX_SPEED_SHIELD 180 - -enum knife_e -{ - KNIFE_IDLE, - KNIFE_ATTACK1HIT, - KNIFE_ATTACK2HIT, - KNIFE_DRAW, - KNIFE_STABHIT, - KNIFE_STABMISS, - KNIFE_MIDATTACK1HIT, - KNIFE_MIDATTACK2HIT -}; - -enum knife_shield_e -{ - KNIFE_SHIELD_IDLE, - KNIFE_SHIELD_SLASH, - KNIFE_SHIELD_ATTACKHIT, - KNIFE_SHIELD_DRAW, - KNIFE_SHIELD_UPIDLE, - KNIFE_SHIELD_UP, - KNIFE_SHIELD_DOWN -}; - - - -//m3 -#define M3_MAX_SPEED 230 -#define M3_CONE_VECTOR Vector(0.0675, 0.0675, 0.0) // special shotgun spreads - -enum m3_e -{ - M3_IDLE, - M3_FIRE1, - M3_FIRE2, - M3_RELOAD, - M3_PUMP, - M3_START_RELOAD, - M3_DRAW, - M3_HOLSTER -}; - - - -//m4a1 -#define M4A1_MAX_SPEED 230 -#define M4A1_DAMAGE 32 -#define M4A1_DAMAGE_SIL 33 -#define M4A1_RANGE_MODIFER 0.97 -#define M4A1_RANGE_MODIFER_SIL 0.95 -#define M4A1_RELOAD_TIME 3.05 - -enum m4a1_e -{ - M4A1_IDLE, - M4A1_SHOOT1, - M4A1_SHOOT2, - M4A1_SHOOT3, - M4A1_RELOAD, - M4A1_DRAW, - M4A1_ATTACH_SILENCER, - M4A1_UNSIL_IDLE, - M4A1_UNSIL_SHOOT1, - M4A1_UNSIL_SHOOT2, - M4A1_UNSIL_SHOOT3, - M4A1_UNSIL_RELOAD, - M4A1_UNSIL_DRAW, - M4A1_DETACH_SILENCER -}; - - - -//m249 -#define M249_MAX_SPEED 220 -#define M249_DAMAGE 32 -#define M249_RANGE_MODIFER 0.97 -#define M249_RELOAD_TIME 4.7 - -enum m249_e -{ - M249_IDLE1, - M249_SHOOT1, - M249_SHOOT2, - M249_RELOAD, - M249_DRAW -}; - - - -//mac10 -#define MAC10_MAX_SPEED 250 -#define MAC10_DAMAGE 29 -#define MAC10_RANGE_MODIFER 0.82 -#define MAC10_RELOAD_TIME 3.15 - -enum mac10_e -{ - MAC10_IDLE1, - MAC10_RELOAD, - MAC10_DRAW, - MAC10_SHOOT1, - MAC10_SHOOT2, - MAC10_SHOOT3 -}; - - - -//mp5navy -#define MP5N_MAX_SPEED 250 -#define MP5N_DAMAGE 26 -#define MP5N_RANGE_MODIFER 0.84 -#define MP5N_RELOAD_TIME 2.63 - -enum mp5n_e -{ - MP5N_IDLE1, - MP5N_RELOAD, - MP5N_DRAW, - MP5N_SHOOT1, - MP5N_SHOOT2, - MP5N_SHOOT3 -}; - - - -//p90 -#define P90_MAX_SPEED 245 -#define P90_DAMAGE 21 -#define P90_RANGE_MODIFER 0.885 -#define P90_RELOAD_TIME 3.4 - -enum p90_e -{ - P90_IDLE1, - P90_RELOAD, - P90_DRAW, - P90_SHOOT1, - P90_SHOOT2, - P90_SHOOT3 -}; - - - -//p228 -#define P228_MAX_SPEED 250 -#define P228_DAMAGE 32 -#define P228_RANGE_MODIFER 0.8 -#define P228_RELOAD_TIME 2.7 - -enum p228_e -{ - P228_IDLE, - P228_SHOOT1, - P228_SHOOT2, - P228_SHOOT3, - P228_SHOOT_EMPTY, - P228_RELOAD, - P228_DRAW -}; - -enum p228_shield_e -{ - P228_SHIELD_IDLE, - P228_SHIELD_SHOOT1, - P228_SHIELD_SHOOT2, - P228_SHIELD_SHOOT_EMPTY, - P228_SHIELD_RELOAD, - P228_SHIELD_DRAW, - P228_SHIELD_IDLE_UP, - P228_SHIELD_UP, - P228_SHIELD_DOWN -}; - - - -//scout -#define SCOUT_MAX_SPEED 260 -#define SCOUT_MAX_SPEED_ZOOM 220 -#define SCOUT_DAMAGE 75 -#define SCOUT_RANGE_MODIFER 0.98 -#define SCOUT_RELOAD_TIME 2 - -enum scout_e -{ - SCOUT_IDLE, - SCOUT_SHOOT, - SCOUT_SHOOT2, - SCOUT_RELOAD, - SCOUT_DRAW -}; - - - -//sg550 -#define SG550_MAX_SPEED 210 -#define SG550_MAX_SPEED_ZOOM 150 -#define SG550_DAMAGE 70 -#define SG550_RANGE_MODIFER 0.98 -#define SG550_RELOAD_TIME 3.35 - -enum sg550_e -{ - SG550_IDLE, - SG550_SHOOT, - SG550_SHOOT2, - SG550_RELOAD, - SG550_DRAW -}; - - - -//sg552 -#define SG552_MAX_SPEED 235 -#define SG552_MAX_SPEED_ZOOM 200 -#define SG552_DAMAGE 33 -#define SG552_RANGE_MODIFER 0.955 -#define SG552_RELOAD_TIME 3 - -enum sg552_e -{ - SG552_IDLE1, - SG552_RELOAD, - SG552_DRAW, - SG552_SHOOT1, - SG552_SHOOT2, - SG552_SHOOT3 -}; - - - -//smokegrenade -#define SMOKEGRENADE_MAX_SPEED 250 -#define SMOKEGRENADE_MAX_SPEED_SHIELD 180 - -enum smokegrenade_e -{ - SMOKEGRENADE_IDLE, - SMOKEGRENADE_PINPULL, - SMOKEGRENADE_THROW, - SMOKEGRENADE_DRAW -}; - - - -//tmp -#define TMP_MAX_SPEED 250 -#define TMP_DAMAGE 20 -#define TMP_RANGE_MODIFER 0.85 -#define TMP_RELOAD_TIME 2.12 - -enum tmp_e -{ - TMP_IDLE1, - TMP_RELOAD, - TMP_DRAW, - TMP_SHOOT1, - TMP_SHOOT2, - TMP_SHOOT3 -}; - - - -//ump45 -#define UMP45_MAX_SPEED 250 -#define UMP45_DAMAGE 30 -#define UMP45_RANGE_MODIFER 0.82 -#define UMP45_RELOAD_TIME 3.5 - -enum ump45_e -{ - UMP45_IDLE1, - UMP45_RELOAD, - UMP45_DRAW, - UMP45_SHOOT1, - UMP45_SHOOT2, - UMP45_SHOOT3 -}; - - - -//tmp -#define USP_MAX_SPEED 250 -#define USP_DAMAGE 34 -#define USP_DAMAGE_SIL 30 -#define USP_RANGE_MODIFER 0.79 -#define USP_RELOAD_TIME 2.7 - -enum usp_e -{ - USP_IDLE, - USP_SHOOT1, - USP_SHOOT2, - USP_SHOOT3, - USP_SHOOT_EMPTY, - USP_RELOAD, - USP_DRAW, - USP_ATTACH_SILENCER, - USP_UNSIL_IDLE, - USP_UNSIL_SHOOT1, - USP_UNSIL_SHOOT2, - USP_UNSIL_SHOOT3, - USP_UNSIL_SHOOT_EMPTY, - USP_UNSIL_RELOAD, - USP_UNSIL_DRAW, - USP_DETACH_SILENCER -}; - -enum usp_shield_e -{ - USP_SHIELD_IDLE, - USP_SHIELD_SHOOT1, - USP_SHIELD_SHOOT2, - USP_SHIELD_SHOOT_EMPTY, - USP_SHIELD_RELOAD, - USP_SHIELD_DRAW, - USP_SHIELD_UP_IDLE, - USP_SHIELD_UP, - USP_SHIELD_DOWN -}; - - - -//xm1014 -#define XM1014_MAX_SPEED 240 -#define XM1014_CONE_VECTOR Vector(0.0725, 0.0725, 0.0) // special shotgun spreads - -enum xm1014_e -{ - XM1014_IDLE, - XM1014_FIRE1, - XM1014_FIRE2, - XM1014_RELOAD, - XM1014_PUMP, - XM1014_START_RELOAD, - XM1014_DRAW -}; diff --git a/regamedll/dlls/wpn_shared/wpn_ak47.cpp b/regamedll/dlls/wpn_shared/wpn_ak47.cpp index 73f065e6..93d6128c 100644 --- a/regamedll/dlls/wpn_shared/wpn_ak47.cpp +++ b/regamedll/dlls/wpn_shared/wpn_ak47.cpp @@ -36,7 +36,7 @@ int CAK47::GetItemInfo(ItemInfo *p) p->pszName = STRING(pev->classname); p->pszAmmo1 = "762Nato"; p->iMaxAmmo1 = MAX_AMMO_762NATO; - p->pszAmmo2 = NULL; + p->pszAmmo2 = nullptr; p->iMaxAmmo2 = -1; p->iMaxClip = AK47_MAX_CLIP; p->iSlot = 0; @@ -84,7 +84,7 @@ void CAK47::AK47Fire(float flSpread, float flCycleTime, BOOL fUseAutoAim) int flag; m_bDelayFire = true; - ++m_iShotsFired; + m_iShotsFired++; m_flAccuracy = ((m_iShotsFired * m_iShotsFired * m_iShotsFired) / 200) + 0.35f; @@ -99,7 +99,7 @@ void CAK47::AK47Fire(float flSpread, float flCycleTime, BOOL fUseAutoAim) m_flNextPrimaryAttack = GetNextAttackDelay(0.2); } - if (TheBots != NULL) + if (TheBots) { TheBots->OnEvent(EVENT_WEAPON_FIRED_ON_EMPTY, m_pPlayer); } @@ -107,7 +107,7 @@ void CAK47::AK47Fire(float flSpread, float flCycleTime, BOOL fUseAutoAim) return; } - --m_iClip; + m_iClip--; m_pPlayer->pev->effects |= EF_MUZZLEFLASH; m_pPlayer->SetAnimation(PLAYER_ATTACK1); @@ -135,7 +135,7 @@ void CAK47::AK47Fire(float flSpread, float flCycleTime, BOOL fUseAutoAim) if (!m_iClip && m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0) { - m_pPlayer->SetSuitUpdate("!HEV_AMO0", FALSE, 0); + m_pPlayer->SetSuitUpdate("!HEV_AMO0", SUIT_SENTENCE, SUIT_REPEAT_OK); } m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 1.9f; diff --git a/regamedll/dlls/wpn_shared/wpn_aug.cpp b/regamedll/dlls/wpn_shared/wpn_aug.cpp index 55b11146..d2d7f33b 100644 --- a/regamedll/dlls/wpn_shared/wpn_aug.cpp +++ b/regamedll/dlls/wpn_shared/wpn_aug.cpp @@ -37,7 +37,7 @@ int CAUG::GetItemInfo(ItemInfo *p) p->pszName = STRING(pev->classname); p->pszAmmo1 = "556Nato"; p->iMaxAmmo1 = MAX_AMMO_556NATO; - p->pszAmmo2 = NULL; + p->pszAmmo2 = nullptr; p->iMaxAmmo2 = -1; p->iMaxClip = AUG_MAX_CLIP; p->iSlot = 0; @@ -94,7 +94,7 @@ void CAUG::AUGFire(float flSpread, float flCycleTime, BOOL fUseAutoAim) int flag; m_bDelayFire = true; - ++m_iShotsFired; + m_iShotsFired++; m_flAccuracy = ((m_iShotsFired * m_iShotsFired * m_iShotsFired) / 215) + 0.3f; @@ -109,7 +109,7 @@ void CAUG::AUGFire(float flSpread, float flCycleTime, BOOL fUseAutoAim) m_flNextPrimaryAttack = GetNextAttackDelay(0.2); } - if (TheBots != NULL) + if (TheBots) { TheBots->OnEvent(EVENT_WEAPON_FIRED_ON_EMPTY, m_pPlayer); } @@ -117,7 +117,7 @@ void CAUG::AUGFire(float flSpread, float flCycleTime, BOOL fUseAutoAim) return; } - --m_iClip; + m_iClip--; m_pPlayer->pev->effects |= EF_MUZZLEFLASH; m_pPlayer->SetAnimation(PLAYER_ATTACK1); @@ -145,7 +145,7 @@ void CAUG::AUGFire(float flSpread, float flCycleTime, BOOL fUseAutoAim) if (!m_iClip && m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0) { - m_pPlayer->SetSuitUpdate("!HEV_AMO0", FALSE, 0); + m_pPlayer->SetSuitUpdate("!HEV_AMO0", SUIT_SENTENCE, SUIT_REPEAT_OK); } m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 1.9f; diff --git a/regamedll/dlls/wpn_shared/wpn_awp.cpp b/regamedll/dlls/wpn_shared/wpn_awp.cpp index d62e2b37..8e40336b 100644 --- a/regamedll/dlls/wpn_shared/wpn_awp.cpp +++ b/regamedll/dlls/wpn_shared/wpn_awp.cpp @@ -37,7 +37,7 @@ int CAWP::GetItemInfo(ItemInfo *p) p->pszName = STRING(pev->classname); p->pszAmmo1 = "338Magnum"; p->iMaxAmmo1 = MAX_AMMO_338MAGNUM; - p->pszAmmo2 = NULL; + p->pszAmmo2 = nullptr; p->iMaxAmmo2 = -1; p->iMaxClip = AWP_MAX_CLIP; p->iSlot = 0; @@ -72,7 +72,7 @@ void CAWP::SecondaryAttack() default: m_pPlayer->m_iFOV = m_pPlayer->pev->fov = 90; break; } - if (TheBots != NULL) + if (TheBots) { TheBots->OnEvent(EVENT_WEAPON_ZOOMED, m_pPlayer); } @@ -135,7 +135,7 @@ void CAWP::AWPFire(float flSpread, float flCycleTime, BOOL fUseAutoAim) m_flNextPrimaryAttack = GetNextAttackDelay(0.2); } - if (TheBots != NULL) + if (TheBots) { TheBots->OnEvent(EVENT_WEAPON_FIRED_ON_EMPTY, m_pPlayer); } @@ -143,7 +143,7 @@ void CAWP::AWPFire(float flSpread, float flCycleTime, BOOL fUseAutoAim) return; } - --m_iClip; + m_iClip--; m_pPlayer->pev->effects |= EF_MUZZLEFLASH; m_pPlayer->SetAnimation(PLAYER_ATTACK1); @@ -171,7 +171,7 @@ void CAWP::AWPFire(float flSpread, float flCycleTime, BOOL fUseAutoAim) if (!m_iClip && m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0) { - m_pPlayer->SetSuitUpdate("!HEV_AMO0", FALSE, 0); + m_pPlayer->SetSuitUpdate("!HEV_AMO0", SUIT_SENTENCE, SUIT_REPEAT_OK); } m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 2.0f; diff --git a/regamedll/dlls/wpn_shared/wpn_c4.cpp b/regamedll/dlls/wpn_shared/wpn_c4.cpp index 87da872d..b615c7ae 100644 --- a/regamedll/dlls/wpn_shared/wpn_c4.cpp +++ b/regamedll/dlls/wpn_shared/wpn_c4.cpp @@ -41,7 +41,7 @@ int CC4::GetItemInfo(ItemInfo *p) p->pszName = STRING(pev->classname); p->pszAmmo1 = "C4"; p->iMaxAmmo1 = C4_MAX_AMMO; - p->pszAmmo2 = NULL; + p->pszAmmo2 = nullptr; p->iMaxAmmo2 = -1; p->iMaxClip = WEAPON_NOCLIP; p->iSlot = 4; @@ -137,8 +137,8 @@ void CC4::PrimaryAttack() { if (bPlaceBomb) { - CBaseEntity *pEntity = NULL; - CBasePlayer *pTempPlayer = NULL; + CBaseEntity *pEntity = nullptr; + CBasePlayer *pTempPlayer = nullptr; if (m_fArmedTime <= gpGlobals->time) { @@ -316,7 +316,7 @@ void CC4::Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, f if (pPlayer) { edict_t *m_pentOldCurBombTarget = pPlayer->m_pentCurBombTarget; - pPlayer->m_pentCurBombTarget = NULL; + pPlayer->m_pentCurBombTarget = nullptr; if (pev->speed != 0 && CSGameRules()) { @@ -327,13 +327,13 @@ void CC4::Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, f CGrenade::ShootSatchelCharge(pPlayer->pev, pev->origin, Vector(0, 0, 0)); - CGrenade *pC4 = NULL; - while ((pC4 = (CGrenade *)UTIL_FindEntityByClassname(pC4, "grenade"))) + CGrenade *pBomb = nullptr; + while ((pBomb = (CGrenade *)UTIL_FindEntityByClassname(pBomb, "grenade"))) { - if (pC4->m_bIsC4 && pC4->m_flNextFreq == gpGlobals->time) + if (pBomb->m_bIsC4 && pBomb->m_flNextFreq == gpGlobals->time) { - pC4->pev->target = pev->target; - pC4->pev->noise1 = pev->noise1; + pBomb->pev->target = pev->target; + pBomb->pev->noise1 = pev->noise1; break; } } diff --git a/regamedll/dlls/wpn_shared/wpn_deagle.cpp b/regamedll/dlls/wpn_shared/wpn_deagle.cpp index 3783f835..f0fafef9 100644 --- a/regamedll/dlls/wpn_shared/wpn_deagle.cpp +++ b/regamedll/dlls/wpn_shared/wpn_deagle.cpp @@ -38,7 +38,7 @@ int CDEAGLE::GetItemInfo(ItemInfo *p) p->pszName = STRING(pev->classname); p->pszAmmo1 = "50AE"; p->iMaxAmmo1 = MAX_AMMO_50AE; - p->pszAmmo2 = NULL; + p->pszAmmo2 = nullptr; p->iMaxAmmo2 = -1; p->iMaxClip = DEAGLE_MAX_CLIP; p->iSlot = 1; @@ -124,7 +124,7 @@ void CDEAGLE::DEAGLEFire(float flSpread, float flCycleTime, BOOL fUseSemi) m_flNextPrimaryAttack = GetNextAttackDelay(0.2); } - if (TheBots != NULL) + if (TheBots) { TheBots->OnEvent(EVENT_WEAPON_FIRED_ON_EMPTY, m_pPlayer); } @@ -132,7 +132,7 @@ void CDEAGLE::DEAGLEFire(float flSpread, float flCycleTime, BOOL fUseSemi) return; } - --m_iClip; + m_iClip--; m_pPlayer->pev->effects |= EF_MUZZLEFLASH; SetPlayerShieldAnim(); @@ -160,7 +160,7 @@ void CDEAGLE::DEAGLEFire(float flSpread, float flCycleTime, BOOL fUseSemi) if (!m_iClip && m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0) { - m_pPlayer->SetSuitUpdate("!HEV_AMO0", FALSE, FALSE); + m_pPlayer->SetSuitUpdate("!HEV_AMO0", SUIT_SENTENCE, SUIT_REPEAT_OK); } m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 1.8f; diff --git a/regamedll/dlls/wpn_shared/wpn_elite.cpp b/regamedll/dlls/wpn_shared/wpn_elite.cpp index a5bc4ffc..67745f5d 100644 --- a/regamedll/dlls/wpn_shared/wpn_elite.cpp +++ b/regamedll/dlls/wpn_shared/wpn_elite.cpp @@ -39,7 +39,7 @@ int CELITE::GetItemInfo(ItemInfo *p) p->pszName = STRING(pev->classname); p->pszAmmo1 = "9mm"; p->iMaxAmmo1 = MAX_AMMO_9MM; - p->pszAmmo2 = NULL; + p->pszAmmo2 = nullptr; p->iMaxAmmo2 = -1; p->iMaxClip = ELITE_MAX_CLIP; p->iSlot = 1; @@ -128,7 +128,7 @@ void CELITE::ELITEFire(float flSpread, float flCycleTime, BOOL fUseSemi) m_flNextPrimaryAttack = GetNextAttackDelay(0.2); } - if (TheBots != NULL) + if (TheBots) { TheBots->OnEvent(EVENT_WEAPON_FIRED_ON_EMPTY, m_pPlayer); } @@ -138,7 +138,7 @@ void CELITE::ELITEFire(float flSpread, float flCycleTime, BOOL fUseSemi) m_flNextPrimaryAttack = m_flNextSecondaryAttack = GetNextAttackDelay(flCycleTime); - --m_iClip; + m_iClip--; m_pPlayer->m_iWeaponVolume = BIG_EXPLOSION_VOLUME; m_pPlayer->m_iWeaponFlash = DIM_GUN_FLASH; @@ -180,7 +180,7 @@ void CELITE::ELITEFire(float flSpread, float flCycleTime, BOOL fUseSemi) if (!m_iClip && m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0) { - m_pPlayer->SetSuitUpdate("!HEV_AMO0", FALSE, 0); + m_pPlayer->SetSuitUpdate("!HEV_AMO0", SUIT_SENTENCE, SUIT_REPEAT_OK); } m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 2.0f; diff --git a/regamedll/dlls/wpn_shared/wpn_famas.cpp b/regamedll/dlls/wpn_shared/wpn_famas.cpp index 9f63ff31..03e2bb81 100644 --- a/regamedll/dlls/wpn_shared/wpn_famas.cpp +++ b/regamedll/dlls/wpn_shared/wpn_famas.cpp @@ -39,7 +39,7 @@ int CFamas::GetItemInfo(ItemInfo *p) p->pszName = STRING(pev->classname); p->pszAmmo1 = "556Nato"; p->iMaxAmmo1 = MAX_AMMO_556NATO; - p->pszAmmo2 = NULL; + p->pszAmmo2 = nullptr; p->iMaxAmmo2 = -1; p->iMaxClip = FAMAS_MAX_CLIP; p->iSlot = 0; @@ -120,7 +120,7 @@ void CFamas::FamasFire(float flSpread, float flCycleTime, BOOL fUseAutoAim, BOOL } m_bDelayFire = true; - ++m_iShotsFired; + m_iShotsFired++; m_flAccuracy = (m_iShotsFired * m_iShotsFired * m_iShotsFired / 215) + 0.3f; @@ -135,7 +135,7 @@ void CFamas::FamasFire(float flSpread, float flCycleTime, BOOL fUseAutoAim, BOOL m_flNextPrimaryAttack = GetNextAttackDelay(0.2); } - if (TheBots != NULL) + if (TheBots) { TheBots->OnEvent(EVENT_WEAPON_FIRED_ON_EMPTY, m_pPlayer); } @@ -143,7 +143,7 @@ void CFamas::FamasFire(float flSpread, float flCycleTime, BOOL fUseAutoAim, BOOL return; } - --m_iClip; + m_iClip--; m_pPlayer->pev->effects |= EF_MUZZLEFLASH; m_pPlayer->SetAnimation(PLAYER_ATTACK1); @@ -171,7 +171,7 @@ void CFamas::FamasFire(float flSpread, float flCycleTime, BOOL fUseAutoAim, BOOL if (!m_iClip && m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0) { - m_pPlayer->SetSuitUpdate("!HEV_AMO0", FALSE, 0); + m_pPlayer->SetSuitUpdate("!HEV_AMO0", SUIT_SENTENCE, SUIT_REPEAT_OK); } m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 1.1f; @@ -195,7 +195,7 @@ void CFamas::FamasFire(float flSpread, float flCycleTime, BOOL fUseAutoAim, BOOL if (bFireBurst) { - ++m_iFamasShotsFired; + m_iFamasShotsFired++; m_fBurstSpread = flSpread; m_flFamasShoot = gpGlobals->time + 0.05f; } diff --git a/regamedll/dlls/wpn_shared/wpn_fiveseven.cpp b/regamedll/dlls/wpn_shared/wpn_fiveseven.cpp index 6792d0a9..acb9f3a2 100644 --- a/regamedll/dlls/wpn_shared/wpn_fiveseven.cpp +++ b/regamedll/dlls/wpn_shared/wpn_fiveseven.cpp @@ -37,7 +37,7 @@ int CFiveSeven::GetItemInfo(ItemInfo *p) p->pszName = STRING(pev->classname); p->pszAmmo1 = "57mm"; p->iMaxAmmo1 = MAX_AMMO_57MM; - p->pszAmmo2 = NULL; + p->pszAmmo2 = nullptr; p->iMaxAmmo2 = -1; p->iMaxClip = FIVESEVEN_MAX_CLIP; p->iSlot = 1; @@ -123,7 +123,7 @@ void CFiveSeven::FiveSevenFire(float flSpread, float flCycleTime, BOOL fUseSemi) m_flNextPrimaryAttack = GetNextAttackDelay(0.2); } - if (TheBots != NULL) + if (TheBots) { TheBots->OnEvent(EVENT_WEAPON_FIRED_ON_EMPTY, m_pPlayer); } @@ -131,7 +131,7 @@ void CFiveSeven::FiveSevenFire(float flSpread, float flCycleTime, BOOL fUseSemi) return; } - --m_iClip; + m_iClip--; m_pPlayer->pev->effects |= EF_MUZZLEFLASH; SetPlayerShieldAnim(); @@ -159,7 +159,7 @@ void CFiveSeven::FiveSevenFire(float flSpread, float flCycleTime, BOOL fUseSemi) if (!m_iClip && m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0) { - m_pPlayer->SetSuitUpdate("!HEV_AMO0", FALSE, FALSE); + m_pPlayer->SetSuitUpdate("!HEV_AMO0", SUIT_SENTENCE, SUIT_REPEAT_OK); } m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 2.0f; diff --git a/regamedll/dlls/wpn_shared/wpn_flashbang.cpp b/regamedll/dlls/wpn_shared/wpn_flashbang.cpp index 489ba465..97e58bc5 100644 --- a/regamedll/dlls/wpn_shared/wpn_flashbang.cpp +++ b/regamedll/dlls/wpn_shared/wpn_flashbang.cpp @@ -40,7 +40,7 @@ int CFlashbang::GetItemInfo(ItemInfo *p) p->iMaxAmmo1 = info ? info->maxRounds : MAX_AMMO_FLASHBANG; p->iMaxClip = info ? info->gunClipSize : WEAPON_NOCLIP; - p->pszAmmo2 = NULL; + p->pszAmmo2 = nullptr; p->iMaxAmmo2 = -1; p->iSlot = 3; p->iPosition = 2; diff --git a/regamedll/dlls/wpn_shared/wpn_g3sg1.cpp b/regamedll/dlls/wpn_shared/wpn_g3sg1.cpp index 45eb908d..f1656e00 100644 --- a/regamedll/dlls/wpn_shared/wpn_g3sg1.cpp +++ b/regamedll/dlls/wpn_shared/wpn_g3sg1.cpp @@ -140,7 +140,7 @@ void CG3SG1::G3SG1Fire(float flSpread, float flCycleTime, BOOL fUseAutoAim) return; } - --m_iClip; + m_iClip--; m_pPlayer->pev->effects |= EF_MUZZLEFLASH; m_pPlayer->SetAnimation(PLAYER_ATTACK1); @@ -167,7 +167,7 @@ void CG3SG1::G3SG1Fire(float flSpread, float flCycleTime, BOOL fUseAutoAim) if (!m_iClip && m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0) { - m_pPlayer->SetSuitUpdate("!HEV_AMO0", FALSE, 0); + m_pPlayer->SetSuitUpdate("!HEV_AMO0", SUIT_SENTENCE, SUIT_REPEAT_OK); } m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 1.8f; diff --git a/regamedll/dlls/wpn_shared/wpn_galil.cpp b/regamedll/dlls/wpn_shared/wpn_galil.cpp index 65501870..7b4d400b 100644 --- a/regamedll/dlls/wpn_shared/wpn_galil.cpp +++ b/regamedll/dlls/wpn_shared/wpn_galil.cpp @@ -34,7 +34,7 @@ int CGalil::GetItemInfo(ItemInfo *p) p->pszName = STRING(pev->classname); p->pszAmmo1 = "556Nato"; p->iMaxAmmo1 = MAX_AMMO_556NATO; - p->pszAmmo2 = NULL; + p->pszAmmo2 = nullptr; p->iMaxAmmo2 = -1; p->iMaxClip = GALIL_MAX_CLIP; p->iSlot = 0; @@ -89,7 +89,7 @@ void CGalil::GalilFire(float flSpread, float flCycleTime, BOOL fUseAutoAim) int flag; m_bDelayFire = true; - ++m_iShotsFired; + m_iShotsFired++; m_flAccuracy = ((m_iShotsFired * m_iShotsFired * m_iShotsFired) / 200) + 0.35f; @@ -104,7 +104,7 @@ void CGalil::GalilFire(float flSpread, float flCycleTime, BOOL fUseAutoAim) m_flNextPrimaryAttack = GetNextAttackDelay(0.2); } - if (TheBots != NULL) + if (TheBots) { TheBots->OnEvent(EVENT_WEAPON_FIRED_ON_EMPTY, m_pPlayer); } @@ -112,7 +112,7 @@ void CGalil::GalilFire(float flSpread, float flCycleTime, BOOL fUseAutoAim) return; } - --m_iClip; + m_iClip--; m_pPlayer->pev->effects |= EF_MUZZLEFLASH; m_pPlayer->SetAnimation(PLAYER_ATTACK1); @@ -140,7 +140,7 @@ void CGalil::GalilFire(float flSpread, float flCycleTime, BOOL fUseAutoAim) if (!m_iClip && m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0) { - m_pPlayer->SetSuitUpdate("!HEV_AMO0", FALSE, 0); + m_pPlayer->SetSuitUpdate("!HEV_AMO0", SUIT_SENTENCE, SUIT_REPEAT_OK); } m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 1.28f; diff --git a/regamedll/dlls/wpn_shared/wpn_glock18.cpp b/regamedll/dlls/wpn_shared/wpn_glock18.cpp index d3fec4da..63851774 100644 --- a/regamedll/dlls/wpn_shared/wpn_glock18.cpp +++ b/regamedll/dlls/wpn_shared/wpn_glock18.cpp @@ -45,7 +45,7 @@ int CGLOCK18::GetItemInfo(ItemInfo *p) p->pszName = STRING(pev->classname); p->pszAmmo1 = "9mm"; p->iMaxAmmo1 = MAX_AMMO_9MM; - p->pszAmmo2 = NULL; + p->pszAmmo2 = nullptr; p->iMaxAmmo2 = -1; p->iMaxClip = GLOCK18_MAX_CLIP; p->iSlot = 1; @@ -189,7 +189,7 @@ void CGLOCK18::GLOCK18Fire(float flSpread, float flCycleTime, BOOL bFireBurst) m_flNextPrimaryAttack = GetNextAttackDelay(0.2); } - if (TheBots != NULL) + if (TheBots) { TheBots->OnEvent(EVENT_WEAPON_FIRED_ON_EMPTY, m_pPlayer); } @@ -197,7 +197,7 @@ void CGLOCK18::GLOCK18Fire(float flSpread, float flCycleTime, BOOL bFireBurst) return; } - --m_iClip; + m_iClip--; m_pPlayer->pev->effects |= EF_MUZZLEFLASH; // player "shoot" animation @@ -228,7 +228,7 @@ void CGLOCK18::GLOCK18Fire(float flSpread, float flCycleTime, BOOL bFireBurst) if (!m_iClip && m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0) { // HEV suit - indicate out of ammo condition - m_pPlayer->SetSuitUpdate("!HEV_AMO0", FALSE, FALSE); + m_pPlayer->SetSuitUpdate("!HEV_AMO0", SUIT_SENTENCE, SUIT_REPEAT_OK); } m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 2.5f; @@ -236,7 +236,7 @@ void CGLOCK18::GLOCK18Fire(float flSpread, float flCycleTime, BOOL bFireBurst) if (bFireBurst) { // Fire off the next two rounds - ++m_iGlock18ShotsFired; + m_iGlock18ShotsFired++; m_flGlock18Shoot = gpGlobals->time + 0.1f; } diff --git a/regamedll/dlls/wpn_shared/wpn_hegrenade.cpp b/regamedll/dlls/wpn_shared/wpn_hegrenade.cpp index 52014d8c..ffac7a1b 100644 --- a/regamedll/dlls/wpn_shared/wpn_hegrenade.cpp +++ b/regamedll/dlls/wpn_shared/wpn_hegrenade.cpp @@ -43,7 +43,7 @@ int CHEGrenade::GetItemInfo(ItemInfo *p) p->iMaxAmmo1 = info ? info->maxRounds : MAX_AMMO_HEGRENADE; p->iMaxClip = info ? info->gunClipSize : WEAPON_NOCLIP; - p->pszAmmo2 = NULL; + p->pszAmmo2 = nullptr; p->iMaxAmmo2 = -1; p->iSlot = 3; p->iPosition = 1; diff --git a/regamedll/dlls/wpn_shared/wpn_knife.cpp b/regamedll/dlls/wpn_shared/wpn_knife.cpp index 4c49bec9..211428b1 100644 --- a/regamedll/dlls/wpn_shared/wpn_knife.cpp +++ b/regamedll/dlls/wpn_shared/wpn_knife.cpp @@ -37,9 +37,9 @@ void CKnife::Precache() int CKnife::GetItemInfo(ItemInfo *p) { p->pszName = STRING(pev->classname); - p->pszAmmo1 = NULL; + p->pszAmmo1 = nullptr; p->iMaxAmmo1 = -1; - p->pszAmmo2 = NULL; + p->pszAmmo2 = nullptr; p->iMaxAmmo2 = -1; p->iMaxClip = WEAPON_NOCLIP; p->iSlot = 2; @@ -114,11 +114,11 @@ void FindHullIntersection(const Vector &vecSrc, TraceResult &tr, float *mins, fl return; } - for (i = 0; i < 2; ++i) + for (i = 0; i < 2; i++) { - for (j = 0; j < 2; ++j) + for (j = 0; j < 2; j++) { - for (k = 0; k < 2; ++k) + for (k = 0; k < 2; k++) { vecEnd.x = vecHullEnd.x + minmaxs[i][0]; vecEnd.y = vecHullEnd.y + minmaxs[j][1]; @@ -361,7 +361,7 @@ int CKnife::Swing(int fFirst) ApplyMultiDamage(m_pPlayer->pev, m_pPlayer->pev); #ifndef REGAMEDLL_FIXES - if (pEntity != NULL) // -V595 + if (pEntity) // -V595 #endif { if (pEntity->Classify() != CLASS_NONE && pEntity->Classify() != CLASS_MACHINE) @@ -494,7 +494,7 @@ int CKnife::Stab(int fFirst) float flDamage = 65.0f; - if (pEntity != NULL && pEntity->IsPlayer()) + if (pEntity && pEntity->IsPlayer()) { Vector2D vec2LOS; float flDot; @@ -521,7 +521,7 @@ int CKnife::Stab(int fFirst) ApplyMultiDamage(m_pPlayer->pev, m_pPlayer->pev); #ifndef REGAMEDLL_FIXES - if (pEntity != NULL) // -V595 + if (pEntity) // -V595 #endif { if (pEntity->Classify() != CLASS_NONE && pEntity->Classify() != CLASS_MACHINE) diff --git a/regamedll/dlls/wpn_shared/wpn_m249.cpp b/regamedll/dlls/wpn_shared/wpn_m249.cpp index d6cb0882..890aac29 100644 --- a/regamedll/dlls/wpn_shared/wpn_m249.cpp +++ b/regamedll/dlls/wpn_shared/wpn_m249.cpp @@ -38,7 +38,7 @@ int CM249::GetItemInfo(ItemInfo *p) p->pszName = STRING(pev->classname); p->pszAmmo1 = "556NatoBox"; p->iMaxAmmo1 = MAX_AMMO_556NATOBOX; - p->pszAmmo2 = NULL; + p->pszAmmo2 = nullptr; p->iMaxAmmo2 = -1; p->iMaxClip = M249_MAX_CLIP; p->iSlot = 0; @@ -81,7 +81,7 @@ void CM249::M249Fire(float flSpread, float flCycleTime, BOOL fUseAutoAim) int flag; m_bDelayFire = true; - ++m_iShotsFired; + m_iShotsFired++; m_flAccuracy = ((m_iShotsFired * m_iShotsFired * m_iShotsFired) / 175) + 0.4f; @@ -96,7 +96,7 @@ void CM249::M249Fire(float flSpread, float flCycleTime, BOOL fUseAutoAim) m_flNextPrimaryAttack = GetNextAttackDelay(0.2); } - if (TheBots != NULL) + if (TheBots) { TheBots->OnEvent(EVENT_WEAPON_FIRED_ON_EMPTY, m_pPlayer); } @@ -104,7 +104,7 @@ void CM249::M249Fire(float flSpread, float flCycleTime, BOOL fUseAutoAim) return; } - --m_iClip; + m_iClip--; m_pPlayer->pev->effects |= EF_MUZZLEFLASH; m_pPlayer->SetAnimation(PLAYER_ATTACK1); @@ -132,7 +132,7 @@ void CM249::M249Fire(float flSpread, float flCycleTime, BOOL fUseAutoAim) if (!m_iClip && m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0) { - m_pPlayer->SetSuitUpdate("!HEV_AMO0", FALSE, 0); + m_pPlayer->SetSuitUpdate("!HEV_AMO0", SUIT_SENTENCE, SUIT_REPEAT_OK); } m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 1.6f; diff --git a/regamedll/dlls/wpn_shared/wpn_m3.cpp b/regamedll/dlls/wpn_shared/wpn_m3.cpp index 1471e742..fa1f7e2b 100644 --- a/regamedll/dlls/wpn_shared/wpn_m3.cpp +++ b/regamedll/dlls/wpn_shared/wpn_m3.cpp @@ -35,7 +35,7 @@ int CM3::GetItemInfo(ItemInfo *p) p->pszName = STRING(pev->classname); p->pszAmmo1 = "buckshot"; p->iMaxAmmo1 = MAX_AMMO_BUCKSHOT; - p->pszAmmo2 = NULL; + p->pszAmmo2 = nullptr; p->iMaxAmmo2 = -1; p->iMaxClip = M3_MAX_CLIP; p->iSlot = 0; @@ -74,7 +74,7 @@ void CM3::PrimaryAttack() PlayEmptySound(); } - if (TheBots != NULL) + if (TheBots) { TheBots->OnEvent(EVENT_WEAPON_FIRED_ON_EMPTY, m_pPlayer); } @@ -83,9 +83,9 @@ void CM3::PrimaryAttack() return; } + m_iClip--; m_pPlayer->m_iWeaponVolume = LOUD_GUN_VOLUME; m_pPlayer->m_iWeaponFlash = BRIGHT_GUN_FLASH; - --m_iClip; m_pPlayer->pev->effects |= EF_MUZZLEFLASH; // player "shoot" animation @@ -109,11 +109,13 @@ void CM3::PrimaryAttack() if (!m_iClip && m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0) { // HEV suit - indicate out of ammo condition - m_pPlayer->SetSuitUpdate("!HEV_AMO0", FALSE, 0); + m_pPlayer->SetSuitUpdate("!HEV_AMO0", SUIT_SENTENCE, SUIT_REPEAT_OK); } +#ifndef REGAMEDLL_FIXES if (m_iClip != 0) m_flPumpTime = UTIL_WeaponTimeBase() + 0.5f; +#endif m_flNextPrimaryAttack = GetNextAttackDelay(0.875); m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 0.875f; @@ -165,14 +167,14 @@ void CM3::Reload() } else { - ++m_iClip; + m_iClip++; #ifdef REGAMEDLL_ADD if (refill_bpammo_weapons.value < 3.0f) #endif { - --m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]; - --m_pPlayer->ammo_buckshot; + m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]--; + m_pPlayer->ammo_buckshot--; } m_fInSpecialReload = 1; @@ -184,10 +186,12 @@ void CM3::WeaponIdle() ResetEmptySound(); m_pPlayer->GetAutoaimVector(AUTOAIM_5DEGREES); +#ifndef REGAMEDLL_FIXES if (m_flPumpTime && m_flPumpTime < UTIL_WeaponTimeBase()) { m_flPumpTime = 0; } +#endif if (m_flTimeWeaponIdle < UTIL_WeaponTimeBase()) { diff --git a/regamedll/dlls/wpn_shared/wpn_m4a1.cpp b/regamedll/dlls/wpn_shared/wpn_m4a1.cpp index 864ef2fb..39769c5e 100644 --- a/regamedll/dlls/wpn_shared/wpn_m4a1.cpp +++ b/regamedll/dlls/wpn_shared/wpn_m4a1.cpp @@ -41,7 +41,7 @@ int CM4A1::GetItemInfo(ItemInfo *p) p->pszName = STRING(pev->classname); p->pszAmmo1 = "556Nato"; p->iMaxAmmo1 = MAX_AMMO_556NATO; - p->pszAmmo2 = NULL; + p->pszAmmo2 = nullptr; p->iMaxAmmo2 = -1; p->iMaxClip = M4A1_MAX_CLIP; p->iSlot = 0; @@ -126,7 +126,7 @@ void CM4A1::M4A1Fire(float flSpread, float flCycleTime, BOOL fUseAutoAim) int flag; m_bDelayFire = true; - ++m_iShotsFired; + m_iShotsFired++; m_flAccuracy = ((m_iShotsFired * m_iShotsFired * m_iShotsFired) / 220) + 0.3f; @@ -141,7 +141,7 @@ void CM4A1::M4A1Fire(float flSpread, float flCycleTime, BOOL fUseAutoAim) m_flNextPrimaryAttack = GetNextAttackDelay(0.2); } - if (TheBots != NULL) + if (TheBots) { TheBots->OnEvent(EVENT_WEAPON_FIRED_ON_EMPTY, m_pPlayer); } @@ -149,7 +149,7 @@ void CM4A1::M4A1Fire(float flSpread, float flCycleTime, BOOL fUseAutoAim) return; } - --m_iClip; + m_iClip--; m_pPlayer->SetAnimation(PLAYER_ATTACK1); UTIL_MakeVectors(m_pPlayer->pev->v_angle + m_pPlayer->pev->punchangle); @@ -180,7 +180,7 @@ void CM4A1::M4A1Fire(float flSpread, float flCycleTime, BOOL fUseAutoAim) #endif #ifndef REGAMEDLL_FIXES - --m_pPlayer->ammo_556nato; + m_pPlayer->ammo_556nato--; #endif PLAYBACK_EVENT_FULL(flag, m_pPlayer->edict(), m_usFireM4A1, 0, (float *)&g_vecZero, (float *)&g_vecZero, vecDir.x, vecDir.y, @@ -190,7 +190,7 @@ void CM4A1::M4A1Fire(float flSpread, float flCycleTime, BOOL fUseAutoAim) if (!m_iClip && m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0) { - m_pPlayer->SetSuitUpdate("!HEV_AMO0", FALSE, 0); + m_pPlayer->SetSuitUpdate("!HEV_AMO0", SUIT_SENTENCE, SUIT_REPEAT_OK); } m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 1.5f; diff --git a/regamedll/dlls/wpn_shared/wpn_mac10.cpp b/regamedll/dlls/wpn_shared/wpn_mac10.cpp index fcffae62..5208de20 100644 --- a/regamedll/dlls/wpn_shared/wpn_mac10.cpp +++ b/regamedll/dlls/wpn_shared/wpn_mac10.cpp @@ -35,7 +35,7 @@ int CMAC10::GetItemInfo(ItemInfo *p) p->pszName = STRING(pev->classname); p->pszAmmo1 = "45acp"; p->iMaxAmmo1 = MAX_AMMO_45ACP; - p->pszAmmo2 = NULL; + p->pszAmmo2 = nullptr; p->iMaxAmmo2 = -1; p->iMaxClip = MAC10_MAX_CLIP; p->iSlot = 0; @@ -74,7 +74,7 @@ void CMAC10::MAC10Fire(float flSpread, float flCycleTime, BOOL fUseAutoAim) int flag; m_bDelayFire = true; - ++m_iShotsFired; + m_iShotsFired++; m_flAccuracy = ((m_iShotsFired * m_iShotsFired * m_iShotsFired) / 200) + 0.6f; @@ -89,7 +89,7 @@ void CMAC10::MAC10Fire(float flSpread, float flCycleTime, BOOL fUseAutoAim) m_flNextPrimaryAttack = GetNextAttackDelay(0.2); } - if (TheBots != NULL) + if (TheBots) { TheBots->OnEvent(EVENT_WEAPON_FIRED_ON_EMPTY, m_pPlayer); } @@ -97,7 +97,7 @@ void CMAC10::MAC10Fire(float flSpread, float flCycleTime, BOOL fUseAutoAim) return; } - --m_iClip; + m_iClip--; m_pPlayer->pev->effects |= EF_MUZZLEFLASH; m_pPlayer->SetAnimation(PLAYER_ATTACK1); @@ -125,7 +125,7 @@ void CMAC10::MAC10Fire(float flSpread, float flCycleTime, BOOL fUseAutoAim) if (!m_iClip && m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0) { - m_pPlayer->SetSuitUpdate("!HEV_AMO0", FALSE, 0); + m_pPlayer->SetSuitUpdate("!HEV_AMO0", SUIT_SENTENCE, SUIT_REPEAT_OK); } m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 2.0f; diff --git a/regamedll/dlls/wpn_shared/wpn_mp5navy.cpp b/regamedll/dlls/wpn_shared/wpn_mp5navy.cpp index 8bd52293..be339e5f 100644 --- a/regamedll/dlls/wpn_shared/wpn_mp5navy.cpp +++ b/regamedll/dlls/wpn_shared/wpn_mp5navy.cpp @@ -36,7 +36,7 @@ int CMP5N::GetItemInfo(ItemInfo *p) p->pszName = STRING(pev->classname); p->pszAmmo1 = "9mm"; p->iMaxAmmo1 = MAX_AMMO_9MM; - p->pszAmmo2 = NULL; + p->pszAmmo2 = nullptr; p->iMaxAmmo2 = -1; p->iMaxClip = MP5N_MAX_CLIP; p->iSlot = 0; @@ -75,7 +75,7 @@ void CMP5N::MP5NFire(float flSpread, float flCycleTime, BOOL fUseAutoAim) int flag; m_bDelayFire = true; - ++m_iShotsFired; + m_iShotsFired++; m_flAccuracy = ((m_iShotsFired * m_iShotsFired) / 220.1) + 0.45f; @@ -90,7 +90,7 @@ void CMP5N::MP5NFire(float flSpread, float flCycleTime, BOOL fUseAutoAim) m_flNextPrimaryAttack = GetNextAttackDelay(0.2); } - if (TheBots != NULL) + if (TheBots) { TheBots->OnEvent(EVENT_WEAPON_FIRED_ON_EMPTY, m_pPlayer); } @@ -98,7 +98,7 @@ void CMP5N::MP5NFire(float flSpread, float flCycleTime, BOOL fUseAutoAim) return; } - --m_iClip; + m_iClip--; m_pPlayer->pev->effects |= EF_MUZZLEFLASH; m_pPlayer->SetAnimation(PLAYER_ATTACK1); @@ -126,7 +126,7 @@ void CMP5N::MP5NFire(float flSpread, float flCycleTime, BOOL fUseAutoAim) if (!m_iClip && m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0) { - m_pPlayer->SetSuitUpdate("!HEV_AMO0", FALSE, 0); + m_pPlayer->SetSuitUpdate("!HEV_AMO0", SUIT_SENTENCE, SUIT_REPEAT_OK); } m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 2.0f; diff --git a/regamedll/dlls/wpn_shared/wpn_p228.cpp b/regamedll/dlls/wpn_shared/wpn_p228.cpp index 954e9aeb..a313a259 100644 --- a/regamedll/dlls/wpn_shared/wpn_p228.cpp +++ b/regamedll/dlls/wpn_shared/wpn_p228.cpp @@ -37,7 +37,7 @@ int CP228::GetItemInfo(ItemInfo *p) p->pszName = STRING(pev->classname); p->pszAmmo1 = "357SIG"; p->iMaxAmmo1 = MAX_AMMO_357SIG; - p->pszAmmo2 = NULL; + p->pszAmmo2 = nullptr; p->iMaxAmmo2 = -1; p->iMaxClip = P228_MAX_CLIP; p->iSlot = 1; @@ -123,7 +123,7 @@ void CP228::P228Fire(float flSpread, float flCycleTime, BOOL fUseSemi) m_flNextPrimaryAttack = GetNextAttackDelay(0.2); } - if (TheBots != NULL) + if (TheBots) { TheBots->OnEvent(EVENT_WEAPON_FIRED_ON_EMPTY, m_pPlayer); } @@ -131,7 +131,7 @@ void CP228::P228Fire(float flSpread, float flCycleTime, BOOL fUseSemi) return; } - --m_iClip; + m_iClip--; m_pPlayer->pev->effects |= EF_MUZZLEFLASH; SetPlayerShieldAnim(); @@ -159,7 +159,7 @@ void CP228::P228Fire(float flSpread, float flCycleTime, BOOL fUseSemi) if (!m_iClip && m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0) { - m_pPlayer->SetSuitUpdate("!HEV_AMO0", FALSE, FALSE); + m_pPlayer->SetSuitUpdate("!HEV_AMO0", SUIT_SENTENCE, SUIT_REPEAT_OK); } m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 2.0f; diff --git a/regamedll/dlls/wpn_shared/wpn_p90.cpp b/regamedll/dlls/wpn_shared/wpn_p90.cpp index 67404e74..405c54b3 100644 --- a/regamedll/dlls/wpn_shared/wpn_p90.cpp +++ b/regamedll/dlls/wpn_shared/wpn_p90.cpp @@ -37,7 +37,7 @@ int CP90::GetItemInfo(ItemInfo *p) p->pszName = STRING(pev->classname); p->pszAmmo1 = "57mm"; p->iMaxAmmo1 = MAX_AMMO_57MM; - p->pszAmmo2 = NULL; + p->pszAmmo2 = nullptr; p->iMaxAmmo2 = -1; p->iMaxClip = P90_MAX_CLIP; p->iSlot = 0; @@ -82,7 +82,7 @@ void CP90::P90Fire(float flSpread, float flCycleTime, BOOL fUseAutoAim) int flag; m_bDelayFire = true; - ++m_iShotsFired; + m_iShotsFired++; m_flAccuracy = (m_iShotsFired * m_iShotsFired / 175) + 0.45f; @@ -97,7 +97,7 @@ void CP90::P90Fire(float flSpread, float flCycleTime, BOOL fUseAutoAim) m_flNextPrimaryAttack = GetNextAttackDelay(0.2); } - if (TheBots != NULL) + if (TheBots) { TheBots->OnEvent(EVENT_WEAPON_FIRED_ON_EMPTY, m_pPlayer); } @@ -105,7 +105,7 @@ void CP90::P90Fire(float flSpread, float flCycleTime, BOOL fUseAutoAim) return; } - --m_iClip; + m_iClip--; m_pPlayer->pev->effects |= EF_MUZZLEFLASH; m_pPlayer->SetAnimation(PLAYER_ATTACK1); @@ -132,7 +132,7 @@ void CP90::P90Fire(float flSpread, float flCycleTime, BOOL fUseAutoAim) if (!m_iClip && m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0) { - m_pPlayer->SetSuitUpdate("!HEV_AMO0", FALSE, 0); + m_pPlayer->SetSuitUpdate("!HEV_AMO0", SUIT_SENTENCE, SUIT_REPEAT_OK); } m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 2.0f; diff --git a/regamedll/dlls/wpn_shared/wpn_scout.cpp b/regamedll/dlls/wpn_shared/wpn_scout.cpp index ec550739..4969cea5 100644 --- a/regamedll/dlls/wpn_shared/wpn_scout.cpp +++ b/regamedll/dlls/wpn_shared/wpn_scout.cpp @@ -34,7 +34,7 @@ int CSCOUT::GetItemInfo(ItemInfo *p) p->pszName = STRING(pev->classname); p->pszAmmo1 = "762Nato"; p->iMaxAmmo1 = MAX_AMMO_762NATO; - p->pszAmmo2 = NULL; + p->pszAmmo2 = nullptr; p->iMaxAmmo2 = -1; p->iMaxClip = SCOUT_MAX_CLIP; p->iSlot = 0; @@ -73,7 +73,7 @@ void CSCOUT::SecondaryAttack() m_pPlayer->m_iFOV = m_pPlayer->pev->fov = 90; break; } - if (TheBots != NULL) + if (TheBots) { TheBots->OnEvent(EVENT_WEAPON_ZOOMED, m_pPlayer); } @@ -129,7 +129,7 @@ void CSCOUT::SCOUTFire(float flSpread, float flCycleTime, BOOL fUseAutoAim) m_flNextPrimaryAttack = GetNextAttackDelay(0.2); } - if (TheBots != NULL) + if (TheBots) { TheBots->OnEvent(EVENT_WEAPON_FIRED_ON_EMPTY, m_pPlayer); } @@ -137,7 +137,7 @@ void CSCOUT::SCOUTFire(float flSpread, float flCycleTime, BOOL fUseAutoAim) return; } - --m_iClip; + m_iClip--; m_pPlayer->SetAnimation(PLAYER_ATTACK1); UTIL_MakeVectors(m_pPlayer->pev->v_angle + m_pPlayer->pev->punchangle); @@ -164,7 +164,7 @@ void CSCOUT::SCOUTFire(float flSpread, float flCycleTime, BOOL fUseAutoAim) if (!m_iClip && m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0) { - m_pPlayer->SetSuitUpdate("!HEV_AMO0", FALSE, 0); + m_pPlayer->SetSuitUpdate("!HEV_AMO0", SUIT_SENTENCE, SUIT_REPEAT_OK); } m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 1.8f; diff --git a/regamedll/dlls/wpn_shared/wpn_sg550.cpp b/regamedll/dlls/wpn_shared/wpn_sg550.cpp index 35de62f0..583ec81d 100644 --- a/regamedll/dlls/wpn_shared/wpn_sg550.cpp +++ b/regamedll/dlls/wpn_shared/wpn_sg550.cpp @@ -12,6 +12,10 @@ void CSG550::Spawn() m_iDefaultAmmo = SG550_DEFAULT_GIVE; m_flLastFire = 0; +#ifdef REGAMEDLL_FIXES + m_flAccuracy = 0.2f; +#endif + FallInit(); } @@ -35,7 +39,7 @@ int CSG550::GetItemInfo(ItemInfo *p) p->pszName = STRING(pev->classname); p->pszAmmo1 = "556Nato"; p->iMaxAmmo1 = MAX_AMMO_556NATO; - p->pszAmmo2 = NULL; + p->pszAmmo2 = nullptr; p->iMaxAmmo2 = -1; p->iMaxClip = SG550_MAX_CLIP; p->iSlot = 0; @@ -49,6 +53,10 @@ int CSG550::GetItemInfo(ItemInfo *p) BOOL CSG550::Deploy() { +#ifdef REGAMEDLL_FIXES + m_flAccuracy = 0.2f; +#endif + return DefaultDeploy("models/v_sg550.mdl", "models/p_sg550.mdl", SG550_DRAW, "rifle", UseDecrement() != FALSE); } @@ -68,7 +76,7 @@ void CSG550::SecondaryAttack() m_pPlayer->ResetMaxSpeed(); - if (TheBots != NULL) + if (TheBots) { TheBots->OnEvent(EVENT_WEAPON_ZOOMED, m_pPlayer); } @@ -127,7 +135,7 @@ void CSG550::SG550Fire(float flSpread, float flCycleTime, BOOL fUseAutoAim) m_flNextPrimaryAttack = GetNextAttackDelay(0.2); } - if (TheBots != NULL) + if (TheBots) { TheBots->OnEvent(EVENT_WEAPON_FIRED_ON_EMPTY, m_pPlayer); } @@ -135,7 +143,7 @@ void CSG550::SG550Fire(float flSpread, float flCycleTime, BOOL fUseAutoAim) return; } - --m_iClip; + m_iClip--; m_pPlayer->pev->effects |= EF_MUZZLEFLASH; m_pPlayer->SetAnimation(PLAYER_ATTACK1); @@ -162,7 +170,7 @@ void CSG550::SG550Fire(float flSpread, float flCycleTime, BOOL fUseAutoAim) if (!m_iClip && m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0) { - m_pPlayer->SetSuitUpdate("!HEV_AMO0", FALSE, 0); + m_pPlayer->SetSuitUpdate("!HEV_AMO0", SUIT_SENTENCE, SUIT_REPEAT_OK); } m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 1.8f; diff --git a/regamedll/dlls/wpn_shared/wpn_sg552.cpp b/regamedll/dlls/wpn_shared/wpn_sg552.cpp index 299d7913..4124e556 100644 --- a/regamedll/dlls/wpn_shared/wpn_sg552.cpp +++ b/regamedll/dlls/wpn_shared/wpn_sg552.cpp @@ -36,7 +36,7 @@ int CSG552::GetItemInfo(ItemInfo *p) p->pszName = STRING(pev->classname); p->pszAmmo1 = "556Nato"; p->iMaxAmmo1 = MAX_AMMO_556NATO; - p->pszAmmo2 = NULL; + p->pszAmmo2 = nullptr; p->iMaxAmmo2 = -1; p->iMaxClip = SG552_MAX_CLIP; p->iSlot = 0; @@ -108,7 +108,7 @@ void CSG552::SG552Fire(float flSpread, float flCycleTime, BOOL fUseAutoAim) m_flNextPrimaryAttack = GetNextAttackDelay(0.2); } - if (TheBots != NULL) + if (TheBots) { TheBots->OnEvent(EVENT_WEAPON_FIRED_ON_EMPTY, m_pPlayer); } @@ -144,7 +144,7 @@ void CSG552::SG552Fire(float flSpread, float flCycleTime, BOOL fUseAutoAim) if (!m_iClip && m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0) { - m_pPlayer->SetSuitUpdate("!HEV_AMO0", FALSE, 0); + m_pPlayer->SetSuitUpdate("!HEV_AMO0", SUIT_SENTENCE, SUIT_REPEAT_OK); } m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 2.0f; diff --git a/regamedll/dlls/wpn_shared/wpn_smokegrenade.cpp b/regamedll/dlls/wpn_shared/wpn_smokegrenade.cpp index 273d559c..b4780aed 100644 --- a/regamedll/dlls/wpn_shared/wpn_smokegrenade.cpp +++ b/regamedll/dlls/wpn_shared/wpn_smokegrenade.cpp @@ -41,7 +41,7 @@ int CSmokeGrenade::GetItemInfo(ItemInfo *p) p->iMaxAmmo1 = info ? info->maxRounds : MAX_AMMO_SMOKEGRENADE; p->iMaxClip = info ? info->gunClipSize : WEAPON_NOCLIP; - p->pszAmmo2 = NULL; + p->pszAmmo2 = nullptr; p->iMaxAmmo2 = -1; p->iSlot = 3; p->iPosition = 3; diff --git a/regamedll/dlls/wpn_shared/wpn_tmp.cpp b/regamedll/dlls/wpn_shared/wpn_tmp.cpp index 9ee39faf..706e1e6f 100644 --- a/regamedll/dlls/wpn_shared/wpn_tmp.cpp +++ b/regamedll/dlls/wpn_shared/wpn_tmp.cpp @@ -34,7 +34,7 @@ int CTMP::GetItemInfo(ItemInfo *p) p->pszName = STRING(pev->classname); p->pszAmmo1 = "9mm"; p->iMaxAmmo1 = MAX_AMMO_9MM; - p->pszAmmo2 = NULL; + p->pszAmmo2 = nullptr; p->iMaxAmmo2 = -1; p->iMaxClip = TMP_MAX_CLIP; p->iSlot = 0; @@ -74,7 +74,7 @@ void CTMP::TMPFire(float flSpread, float flCycleTime, BOOL fUseAutoAim) int flag; m_bDelayFire = true; - ++m_iShotsFired; + m_iShotsFired++; m_flAccuracy = ((m_iShotsFired * m_iShotsFired * m_iShotsFired) / 200) + 0.55f; @@ -89,7 +89,7 @@ void CTMP::TMPFire(float flSpread, float flCycleTime, BOOL fUseAutoAim) m_flNextPrimaryAttack = GetNextAttackDelay(0.2); } - if (TheBots != NULL) + if (TheBots) { TheBots->OnEvent(EVENT_WEAPON_FIRED_ON_EMPTY, m_pPlayer); } @@ -97,7 +97,7 @@ void CTMP::TMPFire(float flSpread, float flCycleTime, BOOL fUseAutoAim) return; } - --m_iClip; + m_iClip--; m_pPlayer->SetAnimation(PLAYER_ATTACK1); UTIL_MakeVectors(m_pPlayer->pev->v_angle + m_pPlayer->pev->punchangle); @@ -123,7 +123,7 @@ void CTMP::TMPFire(float flSpread, float flCycleTime, BOOL fUseAutoAim) if (!m_iClip && m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0) { - m_pPlayer->SetSuitUpdate("!HEV_AMO0", FALSE, 0); + m_pPlayer->SetSuitUpdate("!HEV_AMO0", SUIT_SENTENCE, SUIT_REPEAT_OK); } m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 2.0f; diff --git a/regamedll/dlls/wpn_shared/wpn_ump45.cpp b/regamedll/dlls/wpn_shared/wpn_ump45.cpp index ef14cfa7..b4c06d7b 100644 --- a/regamedll/dlls/wpn_shared/wpn_ump45.cpp +++ b/regamedll/dlls/wpn_shared/wpn_ump45.cpp @@ -39,7 +39,7 @@ int CUMP45::GetItemInfo(ItemInfo *p) p->pszAmmo1 = "45ACP"; #endif p->iMaxAmmo1 = MAX_AMMO_45ACP; - p->pszAmmo2 = NULL; + p->pszAmmo2 = nullptr; p->iMaxAmmo2 = -1; p->iMaxClip = UMP45_MAX_CLIP; p->iSlot = 0; @@ -78,7 +78,7 @@ void CUMP45::UMP45Fire(float flSpread, float flCycleTime, BOOL fUseAutoAim) int flag; m_bDelayFire = true; - ++m_iShotsFired; + m_iShotsFired++; m_flAccuracy = ((m_iShotsFired * m_iShotsFired) / 210) + 0.5f; @@ -93,7 +93,7 @@ void CUMP45::UMP45Fire(float flSpread, float flCycleTime, BOOL fUseAutoAim) m_flNextPrimaryAttack = GetNextAttackDelay(0.2); } - if (TheBots != NULL) + if (TheBots) { TheBots->OnEvent(EVENT_WEAPON_FIRED_ON_EMPTY, m_pPlayer); } @@ -101,7 +101,7 @@ void CUMP45::UMP45Fire(float flSpread, float flCycleTime, BOOL fUseAutoAim) return; } - --m_iClip; + m_iClip--; m_pPlayer->pev->effects |= EF_MUZZLEFLASH; m_pPlayer->SetAnimation(PLAYER_ATTACK1); @@ -129,7 +129,7 @@ void CUMP45::UMP45Fire(float flSpread, float flCycleTime, BOOL fUseAutoAim) if (!m_iClip && m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0) { - m_pPlayer->SetSuitUpdate("!HEV_AMO0", FALSE, 0); + m_pPlayer->SetSuitUpdate("!HEV_AMO0", SUIT_SENTENCE, SUIT_REPEAT_OK); } m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 2.0f; diff --git a/regamedll/dlls/wpn_shared/wpn_usp.cpp b/regamedll/dlls/wpn_shared/wpn_usp.cpp index c1b85b25..e2aa215b 100644 --- a/regamedll/dlls/wpn_shared/wpn_usp.cpp +++ b/regamedll/dlls/wpn_shared/wpn_usp.cpp @@ -45,7 +45,7 @@ int CUSP::GetItemInfo(ItemInfo *p) p->pszAmmo1 = "45ACP"; #endif // REGAMEDLL_FIXES p->iMaxAmmo1 = MAX_AMMO_45ACP; - p->pszAmmo2 = NULL; + p->pszAmmo2 = nullptr; p->iMaxAmmo2 = -1; p->iMaxClip = USP_MAX_CLIP; p->iSlot = 1; @@ -182,7 +182,7 @@ void CUSP::USPFire(float flSpread, float flCycleTime, BOOL fUseSemi) m_flNextPrimaryAttack = GetNextAttackDelay(0.2); } - if (TheBots != NULL) + if (TheBots) { TheBots->OnEvent(EVENT_WEAPON_FIRED_ON_EMPTY, m_pPlayer); } @@ -192,7 +192,7 @@ void CUSP::USPFire(float flSpread, float flCycleTime, BOOL fUseSemi) m_flNextPrimaryAttack = m_flNextSecondaryAttack = GetNextAttackDelay(flCycleTime); - --m_iClip; + m_iClip--; SetPlayerShieldAnim(); m_pPlayer->SetAnimation(PLAYER_ATTACK1); @@ -224,7 +224,7 @@ void CUSP::USPFire(float flSpread, float flCycleTime, BOOL fUseSemi) if (!m_iClip && m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0) { - m_pPlayer->SetSuitUpdate("!HEV_AMO0", FALSE, FALSE); + m_pPlayer->SetSuitUpdate("!HEV_AMO0", SUIT_SENTENCE, SUIT_REPEAT_OK); } m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 2.0f; diff --git a/regamedll/dlls/wpn_shared/wpn_xm1014.cpp b/regamedll/dlls/wpn_shared/wpn_xm1014.cpp index 9e44940b..5e52ff81 100644 --- a/regamedll/dlls/wpn_shared/wpn_xm1014.cpp +++ b/regamedll/dlls/wpn_shared/wpn_xm1014.cpp @@ -109,11 +109,13 @@ void CXM1014::PrimaryAttack() if (!m_iClip && m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0) { // HEV suit - indicate out of ammo condition - m_pPlayer->SetSuitUpdate("!HEV_AMO0", FALSE, 0); + m_pPlayer->SetSuitUpdate("!HEV_AMO0", SUIT_SENTENCE, SUIT_REPEAT_OK); } +#ifndef REGAMEDLL_FIXES if (m_iClip != 0) m_flPumpTime = UTIL_WeaponTimeBase() + 0.125f; +#endif m_flNextPrimaryAttack = GetNextAttackDelay(0.25); m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 0.25f; @@ -169,14 +171,14 @@ void CXM1014::Reload() } else { - ++m_iClip; + m_iClip++; #ifdef REGAMEDLL_ADD if (refill_bpammo_weapons.value < 3.0f) #endif { - --m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]; - --m_pPlayer->ammo_buckshot; + m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]--; + m_pPlayer->ammo_buckshot--; } m_fInSpecialReload = 1; @@ -188,10 +190,12 @@ void CXM1014::WeaponIdle() ResetEmptySound(); m_pPlayer->GetAutoaimVector(AUTOAIM_5DEGREES); +#ifndef REGAMEDLL_FIXES if (m_flPumpTime && m_flPumpTime < UTIL_WeaponTimeBase()) { m_flPumpTime = 0; } +#endif if (m_flTimeWeaponIdle < UTIL_WeaponTimeBase()) { diff --git a/regamedll/engine/eiface.h b/regamedll/engine/eiface.h index 704fe38a..f504eba6 100644 --- a/regamedll/engine/eiface.h +++ b/regamedll/engine/eiface.h @@ -12,8 +12,7 @@ * without written permission from Valve LLC. * ****/ -#ifndef EIFACE_H -#define EIFACE_H +#pragma once #include "archtypes.h" // DAL @@ -38,9 +37,9 @@ /* #ifdef _WIN32 -#define DLLEXPORT __stdcall +#define DLLEXPORT __stdcall EXT_FUNC #else -#define DLLEXPORT __attribute__ ((visibility("default"))) +#define DLLEXPORT __attribute__ ((visibility("default"))) EXT_FUNC #endif */ @@ -79,9 +78,9 @@ struct TraceResult int fInOpen; int fInWater; float flFraction; // time completed, 1.0 = didn't hit anything - Vector vecEndPos; // final position + vec3_t vecEndPos; // final position float flPlaneDist; - Vector vecPlaneNormal; // surface normal at impact + vec3_t vecPlaneNormal; // surface normal at impact edict_t *pHit; // entity the surface is on int iHitgroup; // 0 == generic, non zero is specific body part }; @@ -95,7 +94,7 @@ typedef struct int fEnabled; int fPlayLooping; float cdvolume; - //byte remap[100]; + //BYTE remap[100]; int fCDRom; int fPlayTrack; } CDStatus; @@ -106,13 +105,13 @@ typedef struct // Engine hands this to DLLs for functionality callbacks typedef struct enginefuncs_s { - int (*pfnPrecacheModel) (char* s); - int (*pfnPrecacheSound) (char* s); + int (*pfnPrecacheModel) (const char* s); + int (*pfnPrecacheSound) (const char* s); void (*pfnSetModel) (edict_t *e, const char *m); int (*pfnModelIndex) (const char *m); int (*pfnModelFrames) (int modelIndex); void (*pfnSetSize) (edict_t *e, const float *rgflMin, const float *rgflMax); - void (*pfnChangeLevel) (char* s1, char* s2); + void (*pfnChangeLevel) (const char* s1, const char* s2); void (*pfnGetSpawnParms) (edict_t *ent); void (*pfnSaveSpawnParms) (edict_t *ent); float (*pfnVecToYaw) (const float *rgflVector); @@ -145,11 +144,11 @@ typedef struct enginefuncs_s const char *(*pfnTraceTexture) (edict_t *pTextureEntity, const float *v1, const float *v2 ); void (*pfnTraceSphere) (const float *v1, const float *v2, int fNoMonsters, float radius, edict_t *pentToSkip, TraceResult *ptr); void (*pfnGetAimVector) (edict_t* ent, float speed, float *rgflReturn); - void (*pfnServerCommand) (char* str); + void (*pfnServerCommand) (const char* str); void (*pfnServerExecute) (void); - void (*pfnClientCommand) (edict_t* pEdict, char* szFmt, ...); + void (*pfnClientCommand) (edict_t* pEdict, const char* szFmt, ...); void (*pfnParticleEffect) (const float *org, const float *dir, float color, float count); - void (*pfnLightStyle) (int style, char* val); + void (*pfnLightStyle) (int style, const char* val); int (*pfnDecalIndex) (const char *name); int (*pfnPointContents) (const float *rgflVector); void (*pfnMessageBegin) (int msg_dest, int msg_type, const float *pOrigin, edict_t *ed); @@ -201,7 +200,7 @@ typedef struct enginefuncs_s void (*pfnSetView) (const edict_t *pClient, const edict_t *pViewent ); float (*pfnTime) ( void ); void (*pfnCrosshairAngle) (const edict_t *pClient, float pitch, float yaw); - byte * (*pfnLoadFileForMe) (char *filename, int *pLength); + byte * (*pfnLoadFileForMe) (const char *filename, int *pLength); void (*pfnFreeFile) (void *buffer); void (*pfnEndSection) (const char *pszSectionName); // trigger_endsection int (*pfnCompareFileTime) (char *filename1, char *filename2, int *iCompare); @@ -213,12 +212,12 @@ typedef struct enginefuncs_s void (*pfnRunPlayerMove) (edict_t *fakeclient, const float *viewangles, float forwardmove, float sidemove, float upmove, unsigned short buttons, byte impulse, byte msec ); int (*pfnNumberOfEntities) (void); char* (*pfnGetInfoKeyBuffer) (edict_t *e); // passing in NULL gets the serverinfo - char* (*pfnInfoKeyValue) (char *infobuffer, char *key); - void (*pfnSetKeyValue) (char *infobuffer, char *key, char *value); - void (*pfnSetClientKeyValue) (int clientIndex, char *infobuffer, char *key, char *value); - int (*pfnIsMapValid) (char *filename); + char* (*pfnInfoKeyValue) (char *infobuffer, const char *key); + void (*pfnSetKeyValue) (char *infobuffer, const char *key, const char *value); + void (*pfnSetClientKeyValue) (int clientIndex, char *infobuffer, const char *key, const char *value); + int (*pfnIsMapValid) (const char *filename); void (*pfnStaticDecal) ( const float *origin, int decalIndex, int entityIndex, int modelIndex ); - int (*pfnPrecacheGeneric) (char* s); + int (*pfnPrecacheGeneric) (const char* s); int (*pfnGetPlayerUserId) (edict_t *e ); // returns the server assigned userid for this player. useful for logging frags, etc. returns -1 if the edict couldn't be found in the list of clients void (*pfnBuildSoundMsg) (edict_t *entity, int channel, const char *sample, /*int*/float volume, float attenuation, int fFlags, int pitch, int msg_dest, int msg_type, const float *pOrigin, edict_t *ed); int (*pfnIsDedicatedServer) (void);// is this a dedicated server? @@ -240,7 +239,7 @@ typedef struct enginefuncs_s void (*pfnDeltaSetField) ( struct delta_s *pFields, const char *fieldname ); void (*pfnDeltaUnsetField) ( struct delta_s *pFields, const char *fieldname ); - void (*pfnDeltaAddEncoder) ( char *name, void (*conditionalencode)( struct delta_s *pFields, const unsigned char *from, const unsigned char *to ) ); + void (*pfnDeltaAddEncoder) ( const char *name, void (*conditionalencode)( struct delta_s *pFields, const unsigned char *from, const unsigned char *to ) ); int (*pfnGetCurrentPlayer) ( void ); int (*pfnCanSkipPlayer) ( const edict_t *player ); int (*pfnDeltaFindField) ( struct delta_s *pFields, const char *fieldname ); @@ -250,7 +249,7 @@ typedef struct enginefuncs_s void (*pfnSetGroupMask) ( int mask, int op ); int (*pfnCreateInstancedBaseline) ( int classname, struct entity_state_s *baseline ); - void (*pfnCvar_DirectSet) ( struct cvar_s *var, char *value ); + void (*pfnCvar_DirectSet) ( struct cvar_s *var, const char *value ); // Forces the client and server to be running with the same version of the specified file // ( e.g., a player model ). @@ -259,7 +258,7 @@ typedef struct enginefuncs_s void (*pfnGetPlayerStats) ( const edict_t *pClient, int *ping, int *packet_loss ); - void (*pfnAddServerCommand) ( char *cmd_name, void (*function) (void) ); + void (*pfnAddServerCommand) ( const char *cmd_name, void (*function) (void) ); // For voice communications, set which clients hear eachother. // NOTE: these functions take player entity indices (starting at 1). @@ -275,7 +274,7 @@ typedef struct enginefuncs_s sentenceEntry_s* (*pfnSequencePickSentence) ( const char* groupName, int pickMethod, int *picked ); // LH: Give access to filesize via filesystem - int (*pfnGetFileSize) ( char *filename ); + int (*pfnGetFileSize) ( const char *filename ); unsigned int (*pfnGetApproxWavePlayLen) (const char *filepath); // MDC: Added for CZ career-mode @@ -321,7 +320,7 @@ typedef struct char mapName[ 32 ]; char landmarkName[ 32 ]; edict_t *pentLandmark; - Vector vecLandmarkOrigin; + vec3_t vecLandmarkOrigin; } LEVELLIST; #define MAX_LEVEL_CONNECTIONS 16 // These are encoded in the lower 16bits of ENTITYTABLE->flags @@ -365,7 +364,7 @@ struct saverestore_s // smooth transition int fUseLandmark; char szLandmarkName[20];// landmark we'll spawn near in next level - Vector vecLandmarkOffset;// for landmark transitions + vec3_t vecLandmarkOffset;// for landmark transitions float time; char szCurrentMapName[32]; // To check global entities @@ -395,6 +394,7 @@ typedef enum _fieldtypes FIELD_TIME, // a floating point time (these are fixed up automatically too!) FIELD_MODELNAME, // Engine string that is a model name (needs precache) FIELD_SOUNDNAME, // Engine string that is a sound name (needs precache) + FIELD_TYPECOUNT, // MUST BE LAST } FIELDTYPE; @@ -484,7 +484,7 @@ typedef struct void (*pfnSetupVisibility)( struct edict_s *pViewEntity, struct edict_s *pClient, unsigned char **pvs, unsigned char **pas ); void (*pfnUpdateClientData) ( const struct edict_s *ent, int sendweapons, struct clientdata_s *cd ); int (*pfnAddToFullPack)( struct entity_state_s *state, int e, edict_t *ent, edict_t *host, int hostflags, int player, unsigned char *pSet ); - void (*pfnCreateBaseline) ( int player, int eindex, struct entity_state_s *baseline, struct edict_s *entity, int playermodelindex, Vector player_mins, Vector player_maxs ); + void (*pfnCreateBaseline) ( int player, int eindex, struct entity_state_s *baseline, struct edict_s *entity, int playermodelindex, vec3_t player_mins, vec3_t player_maxs ); void (*pfnRegisterEncoders) ( void ); int (*pfnGetWeaponData) ( struct edict_s *player, struct weapon_data_s *info ); @@ -493,7 +493,7 @@ typedef struct // Return 1 if the packet is valid. Set response_buffer_size if you want to send a response packet. Incoming, it holds the max // size of the response_buffer, so you must zero it out if you choose not to respond. - int (*pfnConnectionlessPacket ) ( const struct netadr_s *net_from, const char *args, char *response_buffer, int *response_buffer_size ); + int (*pfnConnectionlessPacket ) ( const struct netadr_s *net_from_, const char *args, char *response_buffer, int *response_buffer_size ); // Enumerates player hulls. Returns 0 if the hull number doesn't exist, 1 otherwise int (*pfnGetHullBounds) ( int hullnumber, float *mins, float *maxs ); @@ -534,5 +534,3 @@ extern NEW_DLL_FUNCTIONS gNewDLLFunctions; typedef int(*APIFUNCTION)(DLL_FUNCTIONS *pFunctionTable, int interfaceVersion); typedef int(*APIFUNCTION2)(DLL_FUNCTIONS *pFunctionTable, int *interfaceVersion); - -#endif /* EIFACE_H */ diff --git a/regamedll/engine/maintypes.h b/regamedll/engine/maintypes.h index caf0418f..2430eaee 100644 --- a/regamedll/engine/maintypes.h +++ b/regamedll/engine/maintypes.h @@ -47,8 +47,7 @@ #define BIT(n) (1<<(n)) - -typedef unsigned int string_t; // from engine's pr_comp.h; +typedef unsigned int string_t; typedef int EOFFSET; typedef int BOOL; diff --git a/regamedll/engine/osconfig.h b/regamedll/engine/osconfig.h index bf1585e1..f9bc5835 100644 --- a/regamedll/engine/osconfig.h +++ b/regamedll/engine/osconfig.h @@ -80,9 +80,6 @@ #include #include #include - - // Deail with stupid macro in kernel.h - #undef __FUNCTION__ #endif // _WIN32 #include @@ -93,19 +90,32 @@ #include #include + #ifdef _WIN32 // WINDOWS + // Define __func__ on VS less than 2015 + #if _MSC_VER < 1900 + #define __func__ __FUNCTION__ + #endif + #define _CRT_SECURE_NO_WARNINGS #define WIN32_LEAN_AND_MEAN #ifndef CDECL #define CDECL __cdecl #endif + #define FASTCALL __fastcall #define STDCALL __stdcall #define HIDDEN + #define FORCEINLINE __forceinline #define NOINLINE __declspec(noinline) #define ALIGN16 __declspec(align(16)) #define NORETURN __declspec(noreturn) #define FORCE_STACK_ALIGN + #define FUNC_TARGET(x) + + #define __builtin_bswap16 _byteswap_ushort + #define __builtin_bswap32 _byteswap_ulong + #define __builtin_bswap64 _byteswap_uint64 //inline bool SOCKET_FIONBIO(SOCKET s, int m) { return (ioctlsocket(s, FIONBIO, (u_long*)&m) == 0); } //inline int SOCKET_MSGLEN(SOCKET s, u_long& r) { return ioctlsocket(s, FIONREAD, (u_long*)&r); } @@ -125,11 +135,6 @@ VirtualFree(ptr, 0, MEM_RELEASE); } #else // _WIN32 - #ifdef __FUNCTION__ - #undef __FUNCTION__ - #endif - #define __FUNCTION__ __func__ - #ifndef PAGESIZE #define PAGESIZE 4096 #endif @@ -145,14 +150,26 @@ typedef unsigned short WORD; typedef unsigned int UNINT32; + #define FASTCALL #define CDECL __attribute__ ((cdecl)) #define STDCALL __attribute__ ((stdcall)) #define HIDDEN __attribute__((visibility("hidden"))) + #define FORCEINLINE inline #define NOINLINE __attribute__((noinline)) #define ALIGN16 __attribute__((aligned(16))) #define NORETURN __attribute__((noreturn)) #define FORCE_STACK_ALIGN __attribute__((force_align_arg_pointer)) +#if defined __INTEL_COMPILER + #define FUNC_TARGET(x) + + #define __builtin_bswap16 _bswap16 + #define __builtin_bswap32 _bswap + #define __builtin_bswap64 _bswap64 +#else + #define FUNC_TARGET(x) __attribute__((target(x))) +#endif // __INTEL_COMPILER + //inline bool SOCKET_FIONBIO(SOCKET s, int m) { return (ioctl(s, FIONBIO, (int*)&m) == 0); } //inline int SOCKET_MSGLEN(SOCKET s, u_long& r) { return ioctl(s, FIONREAD, (int*)&r); } typedef int SOCKET; @@ -165,6 +182,10 @@ #define SOCKET_AGAIN() (errno == EAGAIN) #define SOCKET_ERROR -1 + inline int ioctlsocket(int fd, int cmd, unsigned int *argp) { return ioctl(fd, cmd, argp); } + inline int closesocket(int fd) { return close(fd); } + inline int WSAGetLastError() { return errno; } + inline void* sys_allocmem(unsigned int size) { return mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); } @@ -192,4 +213,8 @@ #define EXT_FUNC FORCE_STACK_ALIGN +// Used to obtain the string name of a variable. +#define nameof_variable(name) template_nameof_variable(name, #name) +template const char* template_nameof_variable(const T& /*validate_type*/, const char* name) { return name; } + #endif // _OSCONFIG_H diff --git a/regamedll/engine/progdefs.h b/regamedll/engine/progdefs.h index 0b71a7a8..5e241726 100644 --- a/regamedll/engine/progdefs.h +++ b/regamedll/engine/progdefs.h @@ -96,8 +96,8 @@ typedef struct entvars_s int modelindex; string_t model; - int viewmodel; // player's viewmodel - int weaponmodel; // what other players see + string_t viewmodel; // player's viewmodel + string_t weaponmodel; // what other players see Vector absmin; // BB max translated to world coord Vector absmax; // BB max translated to world coord diff --git a/regamedll/engine/unicode_strtools.cpp b/regamedll/engine/unicode_strtools.cpp index 294b6cc6..1647da44 100644 --- a/regamedll/engine/unicode_strtools.cpp +++ b/regamedll/engine/unicode_strtools.cpp @@ -412,7 +412,7 @@ NOXREF char *Q_UnicodeAdvance(char *pUTF8, int nChars) // behavior when used in names, web pages, chat windows, etc. // // characters in this set are removed from the beginning and/or end of strings -// by Q_AggressiveStripPrecedingAndTrailingWhitespaceW() +// by Q_AggressiveStripPrecedingAndTrailingWhitespaceW() //----------------------------------------------------------------------------- bool Q_IsMeanSpaceW(uchar32 wch) { @@ -541,7 +541,7 @@ qboolean Q_StripUnprintableAndSpace(char *pch) int cch = Q_strlen(pch); int cubDest = (cch + 1) * sizeof(uchar16); - uchar16 *pwch_alloced = (uchar16 *)Q_alloca(cubDest); + uchar16 *pwch_alloced = (uchar16 *)alloca(cubDest); bStrippedAny = false; bStrippedWhitespace = false; diff --git a/regamedll/extra/Toolkit/GameDefinitionFile/regamedll-cs.fgd b/regamedll/extra/Toolkit/GameDefinitionFile/regamedll-cs.fgd index 5b9a7149..fbeeacfd 100644 --- a/regamedll/extra/Toolkit/GameDefinitionFile/regamedll-cs.fgd +++ b/regamedll/extra/Toolkit/GameDefinitionFile/regamedll-cs.fgd @@ -659,9 +659,8 @@ spawnflags(flags) = [ 1 : "Starts Open" : 0 - 4 : "Don't link" : 0 8 : "Passable" : 0 - 32: "Toggle" : 0 + 32: "Toggle" : 0 // Normally a named door, or a door with "use only" selected, won't open when touched. 256: "Use Only" : 0 @@ -733,7 +732,6 @@ _minlight(string) : "Minimum light level" ] - @BaseClass base(Targetname, Angles) size(-16 -16 -16, 16 16 16) = gibshooterbase [ // how many pieces to create @@ -1377,6 +1375,7 @@ [ 1: "Remove On fire" : 0 2: "Reset On fire" : 1 + 4: "Fire if over limit" : 1 ] frags(integer) : "Initial Value" : 0 health(integer) : "Limit Value" : 10 @@ -1730,7 +1729,13 @@ 1: "On" 2: "Toggle" ] - teamindex(integer) : "Team Index (-1 = no team)" : -1 + teamindex(choices) : "Team" : -1 = + [ + -1: "No Team" + 1: "Terrorist" + 2: "Counter-terrorist" + 3: "Specator" + ] ] @PointClass base(Targetname, Master, Targetx) iconsprite("sprites/CS/game_team_set.spr") = game_team_set : "Sets team of team_master" @@ -1773,11 +1778,15 @@ @SolidClass base(Targetname) iconsprite("sprites/CS/game_zone_player.spr") = game_zone_player : "Player Zone brush" [ - master(string) : "Master" + spawnflags(Flags) = + [ + 1 : "Ignore Dead Players" : 0 + ] intarget(target_destination) : "Target for IN players" outtarget(target_destination) : "Target for OUT players" incount(target_destination) : "Counter for IN players" outcount(target_destination) : "Counter for OUT players" + // master(string) : "Master" ] @PointClass base(gibshooterbase) iconsprite("sprites/CS/gibshooter.spr") = gibshooter : "Gib Shooter" [] @@ -1927,8 +1936,16 @@ ] // items -@PointClass size(-16 -16 0, 16 16 36) base(Weapon, Targetx, RenderFields) = item_battery : "HEV battery" [] -@PointClass size(-16 -16 0, 16 16 36) base(Weapon, Targetx, RenderFields) = item_healthkit : "Small Health Kit" [] +@PointClass size(-16 -16 0, 16 16 36) base(Weapon, Targetx, RenderFields) = item_battery : "HEV battery" +[ + armorvalue(string) : "Kevlar Points" : "15.0" +] + +@PointClass size(-16 -16 0, 16 16 36) base(Weapon, Targetx, RenderFields) = item_healthkit : "Small Health Kit" +[ + health(string) : "Health Points" : "15.0" +] + @PointClass size(-16 -16 0, 16 16 36) base(Weapon, Targetx, RenderFields) = item_longjump : "Longjump Module" [] @PointClass size(-16 -16 0, 16 16 36) base(Weapon, Targetx, RenderFields) = item_nvgs : "NightVision" [] @@ -2313,6 +2330,7 @@ @SolidClass base(Global, RenderFields, ZHLT, TexLightType) = func_healthcharger: "Wall health recharger" [ // dmdelay may not work in CS + health(integer) : "Healthcharger Capacity" : 50 dmdelay(integer) : "Deathmatch recharge delay" : 0 _minlight(string) : "Minimum light level" : "0" ] @@ -2361,6 +2379,7 @@ spawnflags(flags) = [ 1: "Start ON" : 0 + 2: "Rope swing" : 0 8: "Passable" : 0 16: "Auto-return" : 0 64: "X Axis" : 0 @@ -2419,7 +2438,8 @@ @SolidClass base(Global, RenderFields, ZHLT, TexLightType) = func_recharge: "Battery recharger" [ - dmdelay(integer) : "Deathmatch recharge delay" : 0 + armorvalue(integer) : "Suitcharger Capacity" : 30 + dmdelay(integer) : "Deathmatch recharge delay" : 0 _minlight(string) : "Minimum light level" : "0" ] @@ -2452,9 +2472,7 @@ 1 : "Not solid" : 0 2 : "Reverse Dir" : 0 32: "Toggle" : 0 - 64: "X Axis" : 0 - 128: "Y Axis" : 0 - 256:"Touch Activates": 0 + 256: "Touch Activates": 0 ] _minlight(string) : "Minimum light level" : "0" ] @@ -2481,8 +2499,8 @@ [ 1 : "Start ON" : 0 2 : "Reverse Direction" : 0 - 4 : "X Axis" : 0 - 8 : "Y Axis" : 0 + 4 : "Z Axis" : 0 + 8 : "X Axis" : 0 16: "Acc/Dcc" : 0 32: "Fan Pain" : 0 64: "Not Solid" : 0 diff --git a/regamedll/extra/cssdk/common/IGameServerData.h b/regamedll/extra/cssdk/common/IGameServerData.h deleted file mode 100644 index d431f004..00000000 --- a/regamedll/extra/cssdk/common/IGameServerData.h +++ /dev/null @@ -1,15 +0,0 @@ -#pragma once - -#include "maintypes.h" -#include "interface.h" - -class IGameServerData : public IBaseInterface { -public: - virtual ~IGameServerData() { }; - - virtual void WriteDataRequest(const void *buffer, int bufferSize) = 0; - - virtual int ReadDataResponse(void *data, int len) = 0; -}; - -#define GAMESERVERDATA_INTERFACE_VERSION "GameServerData001" diff --git a/regamedll/extra/cssdk/common/Sequence.h b/regamedll/extra/cssdk/common/Sequence.h deleted file mode 100644 index 8df553df..00000000 --- a/regamedll/extra/cssdk/common/Sequence.h +++ /dev/null @@ -1,201 +0,0 @@ -//--------------------------------------------------------------------------- -// -// S c r i p t e d S e q u e n c e s -// -//--------------------------------------------------------------------------- -#ifndef _INCLUDE_SEQUENCE_H_ -#define _INCLUDE_SEQUENCE_H_ - - -#ifndef _DEF_BYTE_ -typedef unsigned char byte; -#endif - -//--------------------------------------------------------------------------- -// client_textmessage_t -//--------------------------------------------------------------------------- -typedef struct client_textmessage_s -{ - int effect; - byte r1, g1, b1, a1; // 2 colors for effects - byte r2, g2, b2, a2; - float x; - float y; - float fadein; - float fadeout; - float holdtime; - float fxtime; - const char *pName; - const char *pMessage; -} client_textmessage_t; - - -//-------------------------------------------------------------------------- -// sequenceDefaultBits_e -// -// Enumerated list of possible modifiers for a command. This enumeration -// is used in a bitarray controlling what modifiers are specified for a command. -//--------------------------------------------------------------------------- -enum sequenceModifierBits -{ - SEQUENCE_MODIFIER_EFFECT_BIT = (1 << 1), - SEQUENCE_MODIFIER_POSITION_BIT = (1 << 2), - SEQUENCE_MODIFIER_COLOR_BIT = (1 << 3), - SEQUENCE_MODIFIER_COLOR2_BIT = (1 << 4), - SEQUENCE_MODIFIER_FADEIN_BIT = (1 << 5), - SEQUENCE_MODIFIER_FADEOUT_BIT = (1 << 6), - SEQUENCE_MODIFIER_HOLDTIME_BIT = (1 << 7), - SEQUENCE_MODIFIER_FXTIME_BIT = (1 << 8), - SEQUENCE_MODIFIER_SPEAKER_BIT = (1 << 9), - SEQUENCE_MODIFIER_LISTENER_BIT = (1 << 10), - SEQUENCE_MODIFIER_TEXTCHANNEL_BIT = (1 << 11), -}; -typedef enum sequenceModifierBits sequenceModifierBits_e ; - - -//--------------------------------------------------------------------------- -// sequenceCommandEnum_e -// -// Enumerated sequence command types. -//--------------------------------------------------------------------------- -enum sequenceCommandEnum_ -{ - SEQUENCE_COMMAND_ERROR = -1, - SEQUENCE_COMMAND_PAUSE = 0, - SEQUENCE_COMMAND_FIRETARGETS, - SEQUENCE_COMMAND_KILLTARGETS, - SEQUENCE_COMMAND_TEXT, - SEQUENCE_COMMAND_SOUND, - SEQUENCE_COMMAND_GOSUB, - SEQUENCE_COMMAND_SENTENCE, - SEQUENCE_COMMAND_REPEAT, - SEQUENCE_COMMAND_SETDEFAULTS, - SEQUENCE_COMMAND_MODIFIER, - SEQUENCE_COMMAND_POSTMODIFIER, - SEQUENCE_COMMAND_NOOP, - - SEQUENCE_MODIFIER_EFFECT, - SEQUENCE_MODIFIER_POSITION, - SEQUENCE_MODIFIER_COLOR, - SEQUENCE_MODIFIER_COLOR2, - SEQUENCE_MODIFIER_FADEIN, - SEQUENCE_MODIFIER_FADEOUT, - SEQUENCE_MODIFIER_HOLDTIME, - SEQUENCE_MODIFIER_FXTIME, - SEQUENCE_MODIFIER_SPEAKER, - SEQUENCE_MODIFIER_LISTENER, - SEQUENCE_MODIFIER_TEXTCHANNEL, -}; -typedef enum sequenceCommandEnum_ sequenceCommandEnum_e; - - -//--------------------------------------------------------------------------- -// sequenceCommandType_e -// -// Typeerated sequence command types. -//--------------------------------------------------------------------------- -enum sequenceCommandType_ -{ - SEQUENCE_TYPE_COMMAND, - SEQUENCE_TYPE_MODIFIER, -}; -typedef enum sequenceCommandType_ sequenceCommandType_e; - - -//--------------------------------------------------------------------------- -// sequenceCommandMapping_s -// -// A mapping of a command enumerated-value to its name. -//--------------------------------------------------------------------------- -typedef struct sequenceCommandMapping_ sequenceCommandMapping_s; -struct sequenceCommandMapping_ -{ - sequenceCommandEnum_e commandEnum; - const char* commandName; - sequenceCommandType_e commandType; -}; - - -//--------------------------------------------------------------------------- -// sequenceCommandLine_s -// -// Structure representing a single command (usually 1 line) from a -// .SEQ file entry. -//--------------------------------------------------------------------------- -typedef struct sequenceCommandLine_ sequenceCommandLine_s; -struct sequenceCommandLine_ -{ - int commandType; // Specifies the type of command - client_textmessage_t clientMessage; // Text HUD message struct - char* speakerName; // Targetname of speaking entity - char* listenerName; // Targetname of entity being spoken to - char* soundFileName; // Name of sound file to play - char* sentenceName; // Name of sentences.txt to play - char* fireTargetNames; // List of targetnames to fire - char* killTargetNames; // List of targetnames to remove - float delay; // Seconds 'till next command - int repeatCount; // If nonzero, reset execution pointer to top of block (N times, -1 = infinite) - int textChannel; // Display channel on which text message is sent - int modifierBitField; // Bit field to specify what clientmessage fields are valid - sequenceCommandLine_s* nextCommandLine; // Next command (linked list) -}; - - -//--------------------------------------------------------------------------- -// sequenceEntry_s -// -// Structure representing a single command (usually 1 line) from a -// .SEQ file entry. -//--------------------------------------------------------------------------- -typedef struct sequenceEntry_ sequenceEntry_s; -struct sequenceEntry_ -{ - char* fileName; // Name of sequence file without .SEQ extension - char* entryName; // Name of entry label in file - sequenceCommandLine_s* firstCommand; // Linked list of commands in entry - sequenceEntry_s* nextEntry; // Next loaded entry - qboolean isGlobal; // Is entry retained over level transitions? -}; - - - -//--------------------------------------------------------------------------- -// sentenceEntry_s -// Structure representing a single sentence of a group from a .SEQ -// file entry. Sentences are identical to entries in sentences.txt, but -// can be unique per level and are loaded/unloaded with the level. -//--------------------------------------------------------------------------- -typedef struct sentenceEntry_ sentenceEntry_s; -struct sentenceEntry_ -{ - char* data; // sentence data (ie "We have hostiles" ) - sentenceEntry_s* nextEntry; // Next loaded entry - qboolean isGlobal; // Is entry retained over level transitions? - unsigned int index; // this entry's position in the file. -}; - -//-------------------------------------------------------------------------- -// sentenceGroupEntry_s -// Structure representing a group of sentences found in a .SEQ file. -// A sentence group is defined by all sentences with the same name, ignoring -// the number at the end of the sentence name. Groups enable a sentence -// to be picked at random across a group. -//-------------------------------------------------------------------------- -typedef struct sentenceGroupEntry_ sentenceGroupEntry_s; -struct sentenceGroupEntry_ -{ - char* groupName; // name of the group (ie CT_ALERT ) - unsigned int numSentences; // number of sentences in group - sentenceEntry_s* firstSentence; // head of linked list of sentences in group - sentenceGroupEntry_s* nextEntry; // next loaded group -}; - -//--------------------------------------------------------------------------- -// Function declarations -//--------------------------------------------------------------------------- -sequenceEntry_s* SequenceGet( const char* fileName, const char* entryName ); -void Sequence_ParseFile( const char* fileName, qboolean isGlobal ); -void Sequence_OnLevelLoad( const char* mapName ); -sentenceEntry_s* SequencePickSentence( const char *groupName, int pickMethod, int *picked ); - -#endif // _INCLUDE_SEQUENCE_H_ diff --git a/regamedll/extra/cssdk/common/SteamCommon.h b/regamedll/extra/cssdk/common/SteamCommon.h deleted file mode 100644 index 364889c9..00000000 --- a/regamedll/extra/cssdk/common/SteamCommon.h +++ /dev/null @@ -1,703 +0,0 @@ - -//========= Copyright Valve Corporation, All rights reserved. ============// -/* -** The copyright to the contents herein is the property of Valve Corporation. -** The contents may be used and/or copied only with the written permission of -** Valve, or in accordance with the terms and conditions stipulated in -** the agreement/contract under which the contents have been supplied. -** -******************************************************************************* -** -** Contents: -** -** Common types used in the Steam DLL interface. -** -** This file is distributed to Steam application developers. -** -** -** -*******************************************************************************/ - -#ifndef INCLUDED_STEAM_COMMON_STEAMCOMMON_H -#define INCLUDED_STEAM_COMMON_STEAMCOMMON_H - -#if defined(_MSC_VER) && (_MSC_VER > 1000) -#pragma once -#endif - - -#ifdef __cplusplus -extern "C" -{ -#endif - -/* Applications should not define STEAM_EXPORTS. */ - -#if defined ( _WIN32 ) - -#ifdef STEAM_EXPORTS -#define STEAM_API __declspec(dllexport) -#else -#define STEAM_API __declspec(dllimport) -#endif - -#define STEAM_CALL __cdecl - -#else - -#define STEAM_API /* */ -#define STEAM_CALL /* */ - -#endif - -typedef void (STEAM_CALL *KeyValueIteratorCallback_t )(const char *Key, const char *Val, void *pvParam); - - -/****************************************************************************** -** -** Exported macros and constants -** -******************************************************************************/ - -/* DEPRECATED -- these are ignored now, all API access is granted on SteamStartup */ -#define STEAM_USING_FILESYSTEM (0x00000001) -#define STEAM_USING_LOGGING (0x00000002) -#define STEAM_USING_USERID (0x00000004) -#define STEAM_USING_ACCOUNT (0x00000008) -#define STEAM_USING_ALL (0x0000000f) -/* END DEPRECATED */ - -#define STEAM_MAX_PATH (255) -#define STEAM_QUESTION_MAXLEN (255) -#define STEAM_SALT_SIZE (8) -#define STEAM_PROGRESS_PERCENT_SCALE (0x00001000) - -/* These are maximum significant string lengths, excluding nul-terminator. */ -#define STEAM_CARD_NUMBER_SIZE (17) -#define STEAM_CARD_HOLDERNAME_SIZE (100) -#define STEAM_CARD_EXPYEAR_SIZE (4) -#define STEAM_CARD_EXPMONTH_SIZE (2) -#define STEAM_CARD_CVV2_SIZE (5) -#define STEAM_BILLING_ADDRESS1_SIZE (128) -#define STEAM_BILLING_ADDRESS2_SIZE (128) -#define STEAM_BILLING_CITY_SIZE (50) -#define STEAM_BILLING_ZIP_SIZE (16) -#define STEAM_BILLING_STATE_SIZE (32) -#define STEAM_BILLING_COUNTRY_SIZE (32) -#define STEAM_BILLING_PHONE_SIZE (20) -#define STEAM_BILLING_EMAIL_ADDRESS_SIZE (100) -#define STEAM_TYPE_OF_PROOF_OF_PURCHASE_SIZE (20) -#define STEAM_PROOF_OF_PURCHASE_TOKEN_SIZE (200) -#define STEAM_EXTERNAL_ACCOUNTNAME_SIZE (100) -#define STEAM_EXTERNAL_ACCOUNTPASSWORD_SIZE (80) -#define STEAM_BILLING_CONFIRMATION_CODE_SIZE (22) -#define STEAM_BILLING_CARD_APPROVAL_CODE_SIZE (100) -#define STEAM_BILLING_TRANS_DATE_SIZE (9) // mm/dd/yy -#define STEAM_BILLING_TRANS_TIME_SIZE (9) // hh:mm:ss - -/****************************************************************************** -** -** Scalar type and enumerated type definitions. -** -******************************************************************************/ - - -typedef unsigned int SteamHandle_t; - -typedef void * SteamUserIDTicketValidationHandle_t; - -typedef unsigned int SteamCallHandle_t; - -#if defined(_MSC_VER) -typedef unsigned __int64 SteamUnsigned64_t; -#else -typedef unsigned long long SteamUnsigned64_t; -#endif - -typedef enum -{ - eSteamSeekMethodSet = 0, - eSteamSeekMethodCur = 1, - eSteamSeekMethodEnd = 2 -} ESteamSeekMethod; - -typedef enum -{ - eSteamBufferMethodFBF = 0, - eSteamBufferMethodNBF = 1 -} ESteamBufferMethod; - -typedef enum -{ - eSteamErrorNone = 0, - eSteamErrorUnknown = 1, - eSteamErrorLibraryNotInitialized = 2, - eSteamErrorLibraryAlreadyInitialized = 3, - eSteamErrorConfig = 4, - eSteamErrorContentServerConnect = 5, - eSteamErrorBadHandle = 6, - eSteamErrorHandlesExhausted = 7, - eSteamErrorBadArg = 8, - eSteamErrorNotFound = 9, - eSteamErrorRead = 10, - eSteamErrorEOF = 11, - eSteamErrorSeek = 12, - eSteamErrorCannotWriteNonUserConfigFile = 13, - eSteamErrorCacheOpen = 14, - eSteamErrorCacheRead = 15, - eSteamErrorCacheCorrupted = 16, - eSteamErrorCacheWrite = 17, - eSteamErrorCacheSession = 18, - eSteamErrorCacheInternal = 19, - eSteamErrorCacheBadApp = 20, - eSteamErrorCacheVersion = 21, - eSteamErrorCacheBadFingerPrint = 22, - - eSteamErrorNotFinishedProcessing = 23, - eSteamErrorNothingToDo = 24, - eSteamErrorCorruptEncryptedUserIDTicket = 25, - eSteamErrorSocketLibraryNotInitialized = 26, - eSteamErrorFailedToConnectToUserIDTicketValidationServer = 27, - eSteamErrorBadProtocolVersion = 28, - eSteamErrorReplayedUserIDTicketFromClient = 29, - eSteamErrorReceiveResultBufferTooSmall = 30, - eSteamErrorSendFailed = 31, - eSteamErrorReceiveFailed = 32, - eSteamErrorReplayedReplyFromUserIDTicketValidationServer = 33, - eSteamErrorBadSignatureFromUserIDTicketValidationServer = 34, - eSteamErrorValidationStalledSoAborted = 35, - eSteamErrorInvalidUserIDTicket = 36, - eSteamErrorClientLoginRateTooHigh = 37, - eSteamErrorClientWasNeverValidated = 38, - eSteamErrorInternalSendBufferTooSmall = 39, - eSteamErrorInternalReceiveBufferTooSmall = 40, - eSteamErrorUserTicketExpired = 41, - eSteamErrorCDKeyAlreadyInUseOnAnotherClient = 42, - - eSteamErrorNotLoggedIn = 101, - eSteamErrorAlreadyExists = 102, - eSteamErrorAlreadySubscribed = 103, - eSteamErrorNotSubscribed = 104, - eSteamErrorAccessDenied = 105, - eSteamErrorFailedToCreateCacheFile = 106, - eSteamErrorCallStalledSoAborted = 107, - eSteamErrorEngineNotRunning = 108, - eSteamErrorEngineConnectionLost = 109, - eSteamErrorLoginFailed = 110, - eSteamErrorAccountPending = 111, - eSteamErrorCacheWasMissingRetry = 112, - eSteamErrorLocalTimeIncorrect = 113, - eSteamErrorCacheNeedsDecryption = 114, - eSteamErrorAccountDisabled = 115, - eSteamErrorCacheNeedsRepair = 116, - eSteamErrorRebootRequired = 117, - - eSteamErrorNetwork = 200, - eSteamErrorOffline = 201 - - -} ESteamError; - - -typedef enum -{ - eNoDetailedErrorAvailable, - eStandardCerrno, - eWin32LastError, - eWinSockLastError, - eDetailedPlatformErrorCount -} EDetailedPlatformErrorType; - -typedef enum /* Filter elements returned by SteamFind{First,Next} */ -{ - eSteamFindLocalOnly, /* limit search to local filesystem */ - eSteamFindRemoteOnly, /* limit search to remote repository */ - eSteamFindAll /* do not limit search (duplicates allowed) */ -} ESteamFindFilter; - - -/****************************************************************************** -** -** Exported structure and complex type definitions. -** -******************************************************************************/ - - -typedef struct -{ - ESteamError eSteamError; - EDetailedPlatformErrorType eDetailedErrorType; - int nDetailedErrorCode; - char szDesc[STEAM_MAX_PATH]; -} TSteamError; - - - -typedef struct -{ - int bIsDir; /* If non-zero, element is a directory; if zero, element is a file */ - unsigned int uSizeOrCount; /* If element is a file, this contains size of file in bytes */ - int bIsLocal; /* If non-zero, reported item is a standalone element on local filesystem */ - char cszName[STEAM_MAX_PATH]; /* Base element name (no path) */ - long lLastAccessTime; /* Seconds since 1/1/1970 (like time_t) when element was last accessed */ - long lLastModificationTime; /* Seconds since 1/1/1970 (like time_t) when element was last modified */ - long lCreationTime; /* Seconds since 1/1/1970 (like time_t) when element was created */ -} TSteamElemInfo; - - -typedef struct -{ - unsigned int uNumSubscriptions; - unsigned int uMaxNameChars; - unsigned int uMaxApps; - -} TSteamSubscriptionStats; - - -typedef struct -{ - unsigned int uNumApps; - unsigned int uMaxNameChars; - unsigned int uMaxInstallDirNameChars; - unsigned int uMaxVersionLabelChars; - unsigned int uMaxLaunchOptions; - unsigned int uMaxLaunchOptionDescChars; - unsigned int uMaxLaunchOptionCmdLineChars; - unsigned int uMaxNumIcons; - unsigned int uMaxIconSize; - unsigned int uMaxDependencies; - -} TSteamAppStats; - -typedef struct -{ - char *szLabel; - unsigned int uMaxLabelChars; - unsigned int uVersionId; - int bIsNotAvailable; -} TSteamAppVersion; - -typedef struct -{ - char *szDesc; - unsigned int uMaxDescChars; - char *szCmdLine; - unsigned int uMaxCmdLineChars; - unsigned int uIndex; - unsigned int uIconIndex; - int bNoDesktopShortcut; - int bNoStartMenuShortcut; - int bIsLongRunningUnattended; - -} TSteamAppLaunchOption; - - -typedef struct -{ - char *szName; - unsigned int uMaxNameChars; - char *szLatestVersionLabel; - unsigned int uMaxLatestVersionLabelChars; - char *szCurrentVersionLabel; - unsigned int uMaxCurrentVersionLabelChars; - char *szInstallDirName; - unsigned int uMaxInstallDirNameChars; - unsigned int uId; - unsigned int uLatestVersionId; - unsigned int uCurrentVersionId; - unsigned int uMinCacheFileSizeMB; - unsigned int uMaxCacheFileSizeMB; - unsigned int uNumLaunchOptions; - unsigned int uNumIcons; - unsigned int uNumVersions; - unsigned int uNumDependencies; - -} TSteamApp; - -typedef enum -{ - eNoCost = 0, - eBillOnceOnly = 1, - eBillMonthly = 2, - eProofOfPrepurchaseOnly = 3, - eGuestPass = 4, - eHardwarePromo = 5, - eNumBillingTypes, -} EBillingType; - -typedef struct -{ - char *szName; - unsigned int uMaxNameChars; - unsigned int *puAppIds; - unsigned int uMaxAppIds; - unsigned int uId; - unsigned int uNumApps; - EBillingType eBillingType; - unsigned int uCostInCents; - unsigned int uNumDiscounts; - int bIsPreorder; - int bRequiresShippingAddress; - unsigned int uDomesticShippingCostInCents; - unsigned int uInternationalShippingCostInCents; - bool bIsCyberCafeSubscription; - unsigned int uGameCode; - char szGameCodeDesc[STEAM_MAX_PATH]; - bool bIsDisabled; - bool bRequiresCD; - unsigned int uTerritoryCode; - bool bIsSteam3Subscription; - -} TSteamSubscription; - -typedef struct -{ - char szName[STEAM_MAX_PATH]; - unsigned int uDiscountInCents; - unsigned int uNumQualifiers; - -} TSteamSubscriptionDiscount; - -typedef struct -{ - char szName[STEAM_MAX_PATH]; - unsigned int uRequiredSubscription; - int bIsDisqualifier; - -} TSteamDiscountQualifier; - -typedef struct TSteamProgress -{ - int bValid; /* non-zero if call provides progress info */ - unsigned int uPercentDone; /* 0 to 100 * STEAM_PROGRESS_PERCENT_SCALE if bValid */ - char szProgress[STEAM_MAX_PATH]; /* additional progress info */ -} TSteamProgress; - -typedef enum -{ - eSteamNotifyTicketsWillExpire, - eSteamNotifyAccountInfoChanged, - eSteamNotifyContentDescriptionChanged, - eSteamNotifyPleaseShutdown, - eSteamNotifyNewContentServer, - eSteamNotifySubscriptionStatusChanged, - eSteamNotifyContentServerConnectionLost, - eSteamNotifyCacheLoadingCompleted, - eSteamNotifyCacheNeedsDecryption, - eSteamNotifyCacheNeedsRepair -} ESteamNotificationCallbackEvent; - - -typedef void(*SteamNotificationCallback_t)(ESteamNotificationCallbackEvent eEvent, unsigned int nData); - - -typedef char SteamPersonalQuestion_t[ STEAM_QUESTION_MAXLEN + 1 ]; - -typedef struct -{ - unsigned char uchSalt[STEAM_SALT_SIZE]; -} SteamSalt_t; - -typedef enum -{ - eVisa = 1, - eMaster = 2, - eAmericanExpress = 3, - eDiscover = 4, - eDinnersClub = 5, - eJCB = 6 -} ESteamPaymentCardType; - -typedef struct -{ - ESteamPaymentCardType eCardType; - char szCardNumber[ STEAM_CARD_NUMBER_SIZE +1 ]; - char szCardHolderName[ STEAM_CARD_HOLDERNAME_SIZE + 1]; - char szCardExpYear[ STEAM_CARD_EXPYEAR_SIZE + 1 ]; - char szCardExpMonth[ STEAM_CARD_EXPMONTH_SIZE+ 1 ]; - char szCardCVV2[ STEAM_CARD_CVV2_SIZE + 1 ]; - char szBillingAddress1[ STEAM_BILLING_ADDRESS1_SIZE + 1 ]; - char szBillingAddress2[ STEAM_BILLING_ADDRESS2_SIZE + 1 ]; - char szBillingCity[ STEAM_BILLING_CITY_SIZE + 1 ]; - char szBillingZip[ STEAM_BILLING_ZIP_SIZE + 1 ]; - char szBillingState[ STEAM_BILLING_STATE_SIZE + 1 ]; - char szBillingCountry[ STEAM_BILLING_COUNTRY_SIZE + 1 ]; - char szBillingPhone[ STEAM_BILLING_PHONE_SIZE + 1 ]; - char szBillingEmailAddress[ STEAM_BILLING_EMAIL_ADDRESS_SIZE + 1 ]; - unsigned int uExpectedCostInCents; - unsigned int uExpectedTaxInCents; - /* If the TSteamSubscription says that shipping info is required, */ - /* then the following fields must be filled out. */ - /* If szShippingName is empty, then assumes so are the rest. */ - char szShippingName[ STEAM_CARD_HOLDERNAME_SIZE + 1]; - char szShippingAddress1[ STEAM_BILLING_ADDRESS1_SIZE + 1 ]; - char szShippingAddress2[ STEAM_BILLING_ADDRESS2_SIZE + 1 ]; - char szShippingCity[ STEAM_BILLING_CITY_SIZE + 1 ]; - char szShippingZip[ STEAM_BILLING_ZIP_SIZE + 1 ]; - char szShippingState[ STEAM_BILLING_STATE_SIZE + 1 ]; - char szShippingCountry[ STEAM_BILLING_COUNTRY_SIZE + 1 ]; - char szShippingPhone[ STEAM_BILLING_PHONE_SIZE + 1 ]; - unsigned int uExpectedShippingCostInCents; - -} TSteamPaymentCardInfo; - -typedef struct -{ - char szTypeOfProofOfPurchase[ STEAM_TYPE_OF_PROOF_OF_PURCHASE_SIZE + 1 ]; - - /* A ProofOfPurchase token is not necessarily a nul-terminated string; it may be binary data - (perhaps encrypted). Hence we need a length and an array of bytes. */ - unsigned int uLengthOfBinaryProofOfPurchaseToken; - char cBinaryProofOfPurchaseToken[ STEAM_PROOF_OF_PURCHASE_TOKEN_SIZE + 1 ]; -} TSteamPrepurchaseInfo; - -typedef struct -{ - char szAccountName[ STEAM_EXTERNAL_ACCOUNTNAME_SIZE + 1 ]; - char szPassword[ STEAM_EXTERNAL_ACCOUNTPASSWORD_SIZE + 1 ]; -} TSteamExternalBillingInfo; - -typedef enum -{ - ePaymentCardInfo = 1, - ePrepurchasedInfo = 2, - eAccountBillingInfo = 3, - eExternalBillingInfo = 4, /* indirect billing via ISP etc (not supported yet) */ - ePaymentCardReceipt = 5, - ePrepurchaseReceipt = 6, - eEmptyReceipt = 7 -} ESteamSubscriptionBillingInfoType; - -typedef struct -{ - ESteamSubscriptionBillingInfoType eBillingInfoType; - union { - TSteamPaymentCardInfo PaymentCardInfo; - TSteamPrepurchaseInfo PrepurchaseInfo; - TSteamExternalBillingInfo ExternalBillingInfo; - char bUseAccountBillingInfo; - }; - -} TSteamSubscriptionBillingInfo; - -typedef enum -{ - /* Subscribed */ - eSteamSubscriptionOK = 0, /* Subscribed */ - eSteamSubscriptionPending = 1, /* Awaiting transaction completion */ - eSteamSubscriptionPreorder = 2, /* Is currently a pre-order */ - eSteamSubscriptionPrepurchaseTransferred = 3, /* hop to this account */ - /* Unusbscribed */ - eSteamSubscriptionPrepurchaseInvalid = 4, /* Invalid cd-key */ - eSteamSubscriptionPrepurchaseRejected = 5, /* hopped out / banned / etc */ - eSteamSubscriptionPrepurchaseRevoked = 6, /* hop away from this account */ - eSteamSubscriptionPaymentCardDeclined = 7, /* CC txn declined */ - eSteamSubscriptionCancelledByUser = 8, /* Cancelled by client */ - eSteamSubscriptionCancelledByVendor = 9, /* Cancelled by us */ - eSteamSubscriptionPaymentCardUseLimit = 10, /* Card used too many times, potential fraud */ - eSteamSubscriptionPaymentCardAlert = 11, /* Got a "pick up card" or the like from bank */ - eSteamSubscriptionFailed = 12, /* Other Error in subscription data or transaction failed/lost */ - eSteamSubscriptionPaymentCardAVSFailure = 13, /* Card failed Address Verification check */ - eSteamSubscriptionPaymentCardInsufficientFunds = 14, /* Card failed due to insufficient funds */ - eSteamSubscriptionRestrictedCountry = 15 /* The subscription is not available in the user's country */ - -} ESteamSubscriptionStatus; - -typedef struct -{ - ESteamPaymentCardType eCardType; - char szCardLastFourDigits[ 4 + 1 ]; - char szCardHolderName[ STEAM_CARD_HOLDERNAME_SIZE + 1]; - char szBillingAddress1[ STEAM_BILLING_ADDRESS1_SIZE + 1 ]; - char szBillingAddress2[ STEAM_BILLING_ADDRESS2_SIZE + 1 ]; - char szBillingCity[ STEAM_BILLING_CITY_SIZE + 1 ]; - char szBillingZip[ STEAM_BILLING_ZIP_SIZE + 1 ]; - char szBillingState[ STEAM_BILLING_STATE_SIZE + 1 ]; - char szBillingCountry[ STEAM_BILLING_COUNTRY_SIZE + 1 ]; - - // The following are only available after the subscription leaves "pending" status - char szCardApprovalCode[ STEAM_BILLING_CARD_APPROVAL_CODE_SIZE + 1]; - char szTransDate[ STEAM_BILLING_TRANS_DATE_SIZE + 1]; /* mm/dd/yy */ - char szTransTime[ STEAM_BILLING_TRANS_TIME_SIZE + 1]; /* hh:mm:ss */ - unsigned int uPriceWithoutTax; - unsigned int uTaxAmount; - unsigned int uShippingCost; - -} TSteamPaymentCardReceiptInfo; - -typedef struct -{ - char szTypeOfProofOfPurchase[ STEAM_TYPE_OF_PROOF_OF_PURCHASE_SIZE + 1 ]; -} TSteamPrepurchaseReceiptInfo; - -typedef struct -{ - ESteamSubscriptionStatus eStatus; - ESteamSubscriptionStatus ePreviousStatus; - ESteamSubscriptionBillingInfoType eReceiptInfoType; - char szConfirmationCode[ STEAM_BILLING_CONFIRMATION_CODE_SIZE + 1]; - union { - TSteamPaymentCardReceiptInfo PaymentCardReceiptInfo; - TSteamPrepurchaseReceiptInfo PrepurchaseReceiptInfo; - }; - -} TSteamSubscriptionReceipt; - -typedef enum -{ - ePhysicalBytesReceivedThisSession = 1, - eAppReadyToLaunchStatus = 2, - eAppPreloadStatus = 3, - eAppEntireDepot = 4, - eCacheBytesPresent = 5 -} ESteamAppUpdateStatsQueryType; - -typedef struct -{ - SteamUnsigned64_t uBytesTotal; - SteamUnsigned64_t uBytesPresent; -} TSteamUpdateStats; - -typedef enum -{ - eSteamUserAdministrator = 0x00000001, /* May subscribe, unsubscribe, etc */ - eSteamUserDeveloper = 0x00000002, /* Steam or App developer */ - eSteamUserCyberCafe = 0x00000004 /* CyberCafe, school, etc -- UI should ask for password */ - /* before allowing logout, unsubscribe, etc */ -} ESteamUserTypeFlags; - -typedef enum -{ - eSteamAccountStatusDefault = 0x00000000, - eSteamAccountStatusEmailVerified = 0x00000001, - /* Note: Mask value 0x2 is reserved for future use. (Some, but not all, public accounts already have this set.) */ - eSteamAccountDisabled = 0x00000004 -} ESteamAccountStatusBitFields ; - - -typedef enum -{ - eSteamBootstrapperError = -1, - eSteamBootstrapperDontCheckForUpdate = 0, - eSteamBootstrapperCheckForUpdateAndRerun = 7 - -} ESteamBootStrapperClientAppResult; - -typedef enum -{ - eSteamOnline = 0, - eSteamOffline = 1, - eSteamNoAuthMode = 2, - eSteamBillingOffline = 3 -} eSteamOfflineStatus; - -typedef struct -{ - int eOfflineNow; - int eOfflineNextSession; -} TSteamOfflineStatus; - -typedef struct -{ - unsigned int uAppId; - int bIsSystemDefined; - char szMountPath[STEAM_MAX_PATH]; -} TSteamAppDependencyInfo; - -typedef enum -{ - eSteamOpenFileRegular = 0x0, - eSteamOpenFileIgnoreLocal = 0x1, - eSteamOpenFileChecksumReads = 0x2 -} ESteamOpenFileFlags; - -typedef enum -{ - eSteamValveCDKeyValidationServer = 0, - eSteamHalfLifeMasterServer = 1, - eSteamFriendsServer = 2, - eSteamCSERServer = 3, - eSteamHalfLife2MasterServer = 4, - eSteamRDKFMasterServer = 5, - eMaxServerTypes = 6 -} ESteamServerType; - -/****************************************************************************** -** -** More exported constants -** -******************************************************************************/ - - -#ifdef __cplusplus - -const SteamHandle_t STEAM_INVALID_HANDLE = 0; -const SteamCallHandle_t STEAM_INVALID_CALL_HANDLE = 0; -const SteamUserIDTicketValidationHandle_t STEAM_INACTIVE_USERIDTICKET_VALIDATION_HANDLE = 0; -const unsigned int STEAM_USE_LATEST_VERSION = 0xFFFFFFFF; - -#else - -#define STEAM_INVALID_HANDLE ((SteamHandle_t)(0)) -#define STEAM_INVALID_CALL_HANDLE ((SteamCallHandle_t)(0)) -#define STEAM_INACTIVE_USERIDTICKET_VALIDATION_HANDLE ((SteamUserIDTicketValidationHandle_t)(0)) -#define STEAM_USE_LATEST_VERSION (0xFFFFFFFFu); - -#endif - - -/****************************************************************************** -** Each Steam instance (licensed Steam Service Provider) has a unique SteamInstanceID_t. -** -** Each Steam instance as its own DB of users. -** Each user in the DB has a unique SteamLocalUserID_t (a serial number, with possible -** rare gaps in the sequence). -** -******************************************************************************/ - -typedef unsigned short SteamInstanceID_t; // MUST be 16 bits - - -#if defined ( _WIN32 ) -typedef unsigned __int64 SteamLocalUserID_t; // MUST be 64 bits -#else -typedef unsigned long long SteamLocalUserID_t; // MUST be 64 bits -#endif - -/****************************************************************************** -** -** Applications need to be able to authenticate Steam users from ANY instance. -** So a SteamIDTicket contains SteamGlobalUserID, which is a unique combination of -** instance and user id. -** -** SteamLocalUserID is an unsigned 64-bit integer. -** For platforms without 64-bit int support, we provide access via a union that splits it into -** high and low unsigned 32-bit ints. Such platforms will only need to compare LocalUserIDs -** for equivalence anyway - not perform arithmetic with them. -** -********************************************************************************/ -typedef struct -{ - unsigned int Low32bits; - unsigned int High32bits; -} TSteamSplitLocalUserID; - -typedef struct -{ - SteamInstanceID_t m_SteamInstanceID; - - union - { - SteamLocalUserID_t As64bits; - TSteamSplitLocalUserID Split; - } m_SteamLocalUserID; - -} TSteamGlobalUserID; - - -#ifdef __cplusplus -} -#endif - - -#endif diff --git a/regamedll/extra/cssdk/common/beamdef.h b/regamedll/extra/cssdk/common/beamdef.h deleted file mode 100644 index fd77a76f..00000000 --- a/regamedll/extra/cssdk/common/beamdef.h +++ /dev/null @@ -1,62 +0,0 @@ -/*** -* -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ -#if !defined ( BEAMDEFH ) -#define BEAMDEFH -#ifdef _WIN32 -#pragma once -#endif - -#define FBEAM_STARTENTITY 0x00000001 -#define FBEAM_ENDENTITY 0x00000002 -#define FBEAM_FADEIN 0x00000004 -#define FBEAM_FADEOUT 0x00000008 -#define FBEAM_SINENOISE 0x00000010 -#define FBEAM_SOLID 0x00000020 -#define FBEAM_SHADEIN 0x00000040 -#define FBEAM_SHADEOUT 0x00000080 -#define FBEAM_STARTVISIBLE 0x10000000 // Has this client actually seen this beam's start entity yet? -#define FBEAM_ENDVISIBLE 0x20000000 // Has this client actually seen this beam's end entity yet? -#define FBEAM_ISACTIVE 0x40000000 -#define FBEAM_FOREVER 0x80000000 - -typedef struct beam_s BEAM; -struct beam_s -{ - BEAM *next; - int type; - int flags; - vec3_t source; - vec3_t target; - vec3_t delta; - float t; // 0 .. 1 over lifetime of beam - float freq; - float die; - float width; - float amplitude; - float r, g, b; - float brightness; - float speed; - float frameRate; - float frame; - int segments; - int startEntity; - int endEntity; - int modelIndex; - int frameCount; - struct model_s *pFollowModel; - struct particle_s *particles; -}; - -#endif diff --git a/regamedll/extra/cssdk/common/cl_entity.h b/regamedll/extra/cssdk/common/cl_entity.h deleted file mode 100644 index a7cd4720..00000000 --- a/regamedll/extra/cssdk/common/cl_entity.h +++ /dev/null @@ -1,115 +0,0 @@ -/*** -* -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ -// cl_entity.h -#if !defined( CL_ENTITYH ) -#define CL_ENTITYH -#ifdef _WIN32 -#pragma once -#endif - -typedef struct efrag_s -{ - struct mleaf_s *leaf; - struct efrag_s *leafnext; - struct cl_entity_s *entity; - struct efrag_s *entnext; -} efrag_t; - -typedef struct -{ - byte mouthopen; // 0 = mouth closed, 255 = mouth agape - byte sndcount; // counter for running average - int sndavg; // running average -} mouth_t; - -typedef struct -{ - float prevanimtime; - float sequencetime; - byte prevseqblending[2]; - vec3_t prevorigin; - vec3_t prevangles; - - int prevsequence; - float prevframe; - - byte prevcontroller[4]; - byte prevblending[2]; -} latchedvars_t; - -typedef struct -{ - // Time stamp for this movement - float animtime; - - vec3_t origin; - vec3_t angles; -} position_history_t; - -typedef struct cl_entity_s cl_entity_t; - -#define HISTORY_MAX 64 // Must be power of 2 -#define HISTORY_MASK ( HISTORY_MAX - 1 ) - - -#if !defined( ENTITY_STATEH ) -#include "entity_state.h" -#endif - -#if !defined( PROGS_H ) -#include "progs.h" -#endif - -struct cl_entity_s -{ - int index; // Index into cl_entities ( should match actual slot, but not necessarily ) - - qboolean player; // True if this entity is a "player" - - entity_state_t baseline; // The original state from which to delta during an uncompressed message - entity_state_t prevstate; // The state information from the penultimate message received from the server - entity_state_t curstate; // The state information from the last message received from server - - int current_position; // Last received history update index - position_history_t ph[ HISTORY_MAX ]; // History of position and angle updates for this player - - mouth_t mouth; // For synchronizing mouth movements. - - latchedvars_t latched; // Variables used by studio model rendering routines - - // Information based on interplocation, extrapolation, prediction, or just copied from last msg received. - // - float lastmove; - - // Actual render position and angles - vec3_t origin; - vec3_t angles; - - // Attachment points - vec3_t attachment[4]; - - // Other entity local information - int trivial_accept; - - struct model_s *model; // cl.model_precache[ curstate.modelindes ]; all visible entities have a model - struct efrag_s *efrag; // linked list of efrags - struct mnode_s *topnode; // for bmodels, first world node that splits bmodel, or NULL if not split - - float syncbase; // for client-side animations -- used by obsolete alias animation system, remove? - int visframe; // last frame this entity was found in an active leaf - colorVec cvFloorColor; -}; - -#endif // !CL_ENTITYH diff --git a/regamedll/extra/cssdk/common/com_model.h b/regamedll/extra/cssdk/common/com_model.h deleted file mode 100644 index d6e3d427..00000000 --- a/regamedll/extra/cssdk/common/com_model.h +++ /dev/null @@ -1,340 +0,0 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ -// -// Purpose: -// -// $NoKeywords: $ -//============================================================================= - -// com_model.h -#pragma once - -#define STUDIO_RENDER 1 -#define STUDIO_EVENTS 2 - -//#define MAX_MODEL_NAME 64 -//#define MAX_MAP_HULLS 4 -//#define MIPLEVELS 4 -//#define NUM_AMBIENTS 4 // automatic ambient sounds -//#define MAXLIGHTMAPS 4 -#define PLANE_ANYZ 5 - -#define ALIAS_Z_CLIP_PLANE 5 - -// flags in finalvert_t.flags -#define ALIAS_LEFT_CLIP 0x0001 -#define ALIAS_TOP_CLIP 0x0002 -#define ALIAS_RIGHT_CLIP 0x0004 -#define ALIAS_BOTTOM_CLIP 0x0008 -#define ALIAS_Z_CLIP 0x0010 -#define ALIAS_ONSEAM 0x0020 -#define ALIAS_XY_CLIP_MASK 0x000F - -#define ZISCALE ((float)0x8000) - -#define CACHE_SIZE 32 // used to align key data structures - -//typedef enum -//{ -// mod_brush, -// mod_sprite, -// mod_alias, -// mod_studio -//} modtype_t; - -// must match definition in modelgen.h -//#ifndef SYNCTYPE_T -//#define SYNCTYPE_T -// -//typedef enum -//{ -// ST_SYNC=0, -// ST_RAND -//} synctype_t; -// -//#endif - -//typedef struct -//{ -// float mins[3], maxs[3]; -// float origin[3]; -// int headnode[MAX_MAP_HULLS]; -// int visleafs; // not including the solid leaf 0 -// int firstface, numfaces; -//} dmodel_t; - -// plane_t structure -//typedef struct mplane_s -//{ -// vec3_t normal; // surface normal -// float dist; // closest appoach to origin -// byte type; // for texture axis selection and fast side tests -// byte signbits; // signx + signy<<1 + signz<<1 -// byte pad[2]; -//} mplane_t; - -//typedef struct -//{ -// vec3_t position; -//} mvertex_t; - -//typedef struct -//{ -// unsigned short v[2]; -// unsigned int cachededgeoffset; -//} medge_t; - -//typedef struct texture_s -//{ -// char name[16]; -// unsigned width, height; -// int anim_total; // total tenths in sequence ( 0 = no) -// int anim_min, anim_max; // time for this frame min <=time< max -// struct texture_s *anim_next; // in the animation sequence -// struct texture_s *alternate_anims; // bmodels in frame 1 use these -// unsigned offsets[MIPLEVELS]; // four mip maps stored -// unsigned paloffset; -//} texture_t; - -//typedef struct -//{ -// float vecs[2][4]; // [s/t] unit vectors in world space. -// // [i][3] is the s/t offset relative to the origin. -// // s or t = dot(3Dpoint,vecs[i])+vecs[i][3] -// float mipadjust; // ?? mipmap limits for very small surfaces -// texture_t *texture; -// int flags; // sky or slime, no lightmap or 256 subdivision -//} mtexinfo_t; - -//typedef struct mnode_s -//{ -// // common with leaf -// int contents; // 0, to differentiate from leafs -// int visframe; // node needs to be traversed if current -// -// short minmaxs[6]; // for bounding box culling -// -// struct mnode_s *parent; -// -// // node specific -// mplane_t *plane; -// struct mnode_s *children[2]; -// -// unsigned short firstsurface; -// unsigned short numsurfaces; -//} mnode_t; - -//typedef struct msurface_s msurface_t; -//typedef struct decal_s decal_t; - -// JAY: Compress this as much as possible -//struct decal_s -//{ -// decal_t *pnext; // linked list for each surface -// msurface_t *psurface; // Surface id for persistence / unlinking -// short dx; // Offsets into surface texture (in texture coordinates, so we don't need floats) -// short dy; -// short texture; // Decal texture -// byte scale; // Pixel scale -// byte flags; // Decal flags -// -// short entityIndex; // Entity this is attached to -//}; - -//typedef struct mleaf_s -//{ -// // common with node -// int contents; // wil be a negative contents number -// int visframe; // node needs to be traversed if current -// -// short minmaxs[6]; // for bounding box culling -// -// struct mnode_s *parent; -// -// // leaf specific -// byte *compressed_vis; -// struct efrag_s *efrags; -// -// msurface_t **firstmarksurface; -// int nummarksurfaces; -// int key; // BSP sequence number for leaf's contents -// byte ambient_sound_level[NUM_AMBIENTS]; -//} mleaf_t; - -//struct msurface_s -//{ -// int visframe; // should be drawn when node is crossed -// -// int dlightframe; // last frame the surface was checked by an animated light -// int dlightbits; // dynamically generated. Indicates if the surface illumination -// // is modified by an animated light. -// -// mplane_t *plane; // pointer to shared plane -// int flags; // see SURF_ #defines -// -// int firstedge; // look up in model->surfedges[], negative numbers -// int numedges; // are backwards edges -// -// // surface generation data -// struct surfcache_s *cachespots[MIPLEVELS]; -// -// short texturemins[2]; // smallest s/t position on the surface. -// short extents[2]; // ?? s/t texture size, 1..256 for all non-sky surfaces -// -// mtexinfo_t *texinfo; -// -// // lighting info -// byte styles[MAXLIGHTMAPS]; // index into d_lightstylevalue[] for animated lights -// // no one surface can be effected by more than 4 -// // animated lights. -// color24 *samples; -// -// decal_t *pdecals; -//}; - -//typedef struct -//{ -// int planenum; -// short children[2]; // negative numbers are contents -//} dclipnode_t; - -//typedef struct hull_s -//{ -// dclipnode_t *clipnodes; -// mplane_t *planes; -// int firstclipnode; -// int lastclipnode; -// vec3_t clip_mins; -// vec3_t clip_maxs; -//} hull_t; - -typedef struct cache_user_s -{ - void *data; -} cache_user_t; - -//typedef struct model_s -//{ -// char name[ MAX_MODEL_NAME ]; -// qboolean needload; // bmodels and sprites don't cache normally -// -// modtype_t type; -// int numframes; -// synctype_t synctype; -// -// int flags; -// -// // -// // volume occupied by the model -// // -// vec3_t mins, maxs; -// float radius; -// -// // -// // brush model -// // -// int firstmodelsurface, nummodelsurfaces; -// -// int numsubmodels; -// dmodel_t *submodels; -// -// int numplanes; -// mplane_t *planes; -// -// int numleafs; // number of visible leafs, not counting 0 -// struct mleaf_s *leafs; -// -// int numvertexes; -// mvertex_t *vertexes; -// -// int numedges; -// medge_t *edges; -// -// int numnodes; -// mnode_t *nodes; -// -// int numtexinfo; -// mtexinfo_t *texinfo; -// -// int numsurfaces; -// msurface_t *surfaces; -// -// int numsurfedges; -// int *surfedges; -// -// int numclipnodes; -// dclipnode_t *clipnodes; -// -// int nummarksurfaces; -// msurface_t **marksurfaces; -// -// hull_t hulls[MAX_MAP_HULLS]; -// -// int numtextures; -// texture_t **textures; -// -// byte *visdata; -// -// color24 *lightdata; -// -// char *entities; -// -// // -// // additional model data -// // -// cache_user_t cache; // only access through Mod_Extradata -// -//} model_t; - -//typedef vec_t vec4_t[4]; - -typedef struct alight_s -{ - int ambientlight; // clip at 128 - int shadelight; // clip at 192 - ambientlight - vec3_t color; - float *plightvec; -} alight_t; - -typedef struct auxvert_s -{ - float fv[3]; // viewspace x, y -} auxvert_t; - -#include "custom.h" - -//#define MAX_SCOREBOARDNAME 32 - -// Defined in client.h differently -//typedef struct player_info_s -//{ -// // User id on server -// int userid; -// -// // User info string -// char userinfo[ MAX_INFO_STRING ]; -// -// // Name -// char name[ MAX_SCOREBOARDNAME ]; -// -// // Spectator or not, unused -// int spectator; -// -// int ping; -// int packet_loss; -// -// // skin information -// char model[MAX_QPATH]; -// int topcolor; -// int bottomcolor; -// -// // last frame rendered -// int renderframe; -// -// // Gait frame estimation -// int gaitsequence; -// float gaitframe; -// float gaityaw; -// vec3_t prevgaitorigin; -// -// customization_t customdata; -//} player_info_t; diff --git a/regamedll/extra/cssdk/common/con_nprint.h b/regamedll/extra/cssdk/common/con_nprint.h deleted file mode 100644 index b2a18889..00000000 --- a/regamedll/extra/cssdk/common/con_nprint.h +++ /dev/null @@ -1,38 +0,0 @@ -/*** -* -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ -#if !defined( CON_NPRINTH ) -#define CON_NPRINTH -#ifdef _WIN32 -#pragma once -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct con_nprint_s -{ - int index; // Row # - float time_to_live; // # of seconds before it dissappears - float color[ 3 ]; // RGB colors ( 0.0 -> 1.0 scale ) -} con_nprint_t; - -void Con_NPrintf( int idx, const char *fmt, ... ); -void Con_NXPrintf( struct con_nprint_s *info, const char *fmt, ... ); -#ifdef __cplusplus -} -#endif - -#endif diff --git a/regamedll/extra/cssdk/common/const.h b/regamedll/extra/cssdk/common/const.h deleted file mode 100644 index aa081dc4..00000000 --- a/regamedll/extra/cssdk/common/const.h +++ /dev/null @@ -1,806 +0,0 @@ -/*** -* -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ - -#ifndef CONST_H -#define CONST_H -#ifdef _WIN32 -#pragma once -#endif - -// Max # of clients allowed in a server. -#define MAX_CLIENTS 32 - -// How many bits to use to encode an edict. -#define MAX_EDICT_BITS 11 // # of bits needed to represent max edicts -// Max # of edicts in a level (2048) -#define MAX_EDICTS (1<flags -#define FL_FLY (1<<0) // Changes the SV_Movestep() behavior to not need to be on ground -#define FL_SWIM (1<<1) // Changes the SV_Movestep() behavior to not need to be on ground (but stay in water) -#define FL_CONVEYOR (1<<2) -#define FL_CLIENT (1<<3) -#define FL_INWATER (1<<4) -#define FL_MONSTER (1<<5) -#define FL_GODMODE (1<<6) -#define FL_NOTARGET (1<<7) -#define FL_SKIPLOCALHOST (1<<8) // Don't send entity to local host, it's predicting this entity itself -#define FL_ONGROUND (1<<9) // At rest / on the ground -#define FL_PARTIALGROUND (1<<10) // not all corners are valid -#define FL_WATERJUMP (1<<11) // player jumping out of water -#define FL_FROZEN (1<<12) // Player is frozen for 3rd person camera -#define FL_FAKECLIENT (1<<13) // JAC: fake client, simulated server side; don't send network messages to them -#define FL_DUCKING (1<<14) // Player flag -- Player is fully crouched -#define FL_FLOAT (1<<15) // Apply floating force to this entity when in water -#define FL_GRAPHED (1<<16) // worldgraph has this ent listed as something that blocks a connection - -// UNDONE: Do we need these? -#define FL_IMMUNE_WATER (1<<17) -#define FL_IMMUNE_SLIME (1<<18) -#define FL_IMMUNE_LAVA (1<<19) - -#define FL_PROXY (1<<20) // This is a spectator proxy -#define FL_ALWAYSTHINK (1<<21) // Brush model flag -- call think every frame regardless of nextthink - ltime (for constantly changing velocity/path) -#define FL_BASEVELOCITY (1<<22) // Base velocity has been applied this frame (used to convert base velocity into momentum) -#define FL_MONSTERCLIP (1<<23) // Only collide in with monsters who have FL_MONSTERCLIP set -#define FL_ONTRAIN (1<<24) // Player is _controlling_ a train, so movement commands should be ignored on client during prediction. -#define FL_WORLDBRUSH (1<<25) // Not moveable/removeable brush entity (really part of the world, but represented as an entity for transparency or something) -#define FL_SPECTATOR (1<<26) // This client is a spectator, don't run touch functions, etc. -#define FL_CUSTOMENTITY (1<<29) // This is a custom entity -#define FL_KILLME (1<<30) // This entity is marked for death -- This allows the engine to kill ents at the appropriate time -#define FL_DORMANT (1<<31) // Entity is dormant, no updates to client - -// SV_EmitSound2 flags -#define SND_EMIT2_NOPAS (1<<0) // never to do check PAS -#define SND_EMIT2_INVOKER (1<<1) // do not send to the client invoker - -// Engine edict->spawnflags -#define SF_NOTINDEATHMATCH 0x0800 // Do not spawn when deathmatch and loading entities from a file - - -// Goes into globalvars_t.trace_flags -#define FTRACE_SIMPLEBOX (1<<0) // Traceline with a simple box - - -// walkmove modes -#define WALKMOVE_NORMAL 0 // normal walkmove -#define WALKMOVE_WORLDONLY 1 // doesn't hit ANY entities, no matter what the solid type -#define WALKMOVE_CHECKONLY 2 // move, but don't touch triggers - -// edict->movetype values -#define MOVETYPE_NONE 0 // never moves -//#define MOVETYPE_ANGLENOCLIP 1 -//#define MOVETYPE_ANGLECLIP 2 -#define MOVETYPE_WALK 3 // Player only - moving on the ground -#define MOVETYPE_STEP 4 // gravity, special edge handling -- monsters use this -#define MOVETYPE_FLY 5 // No gravity, but still collides with stuff -#define MOVETYPE_TOSS 6 // gravity/collisions -#define MOVETYPE_PUSH 7 // no clip to world, push and crush -#define MOVETYPE_NOCLIP 8 // No gravity, no collisions, still do velocity/avelocity -#define MOVETYPE_FLYMISSILE 9 // extra size to monsters -#define MOVETYPE_BOUNCE 10 // Just like Toss, but reflect velocity when contacting surfaces -#define MOVETYPE_BOUNCEMISSILE 11 // bounce w/o gravity -#define MOVETYPE_FOLLOW 12 // track movement of aiment -#define MOVETYPE_PUSHSTEP 13 // BSP model that needs physics/world collisions (uses nearest hull for world collision) - -// edict->solid values -// NOTE: Some movetypes will cause collisions independent of SOLID_NOT/SOLID_TRIGGER when the entity moves -// SOLID only effects OTHER entities colliding with this one when they move - UGH! -#define SOLID_NOT 0 // no interaction with other objects -#define SOLID_TRIGGER 1 // touch on edge, but not blocking -#define SOLID_BBOX 2 // touch on edge, block -#define SOLID_SLIDEBOX 3 // touch on edge, but not an onground -#define SOLID_BSP 4 // bsp clip, touch on edge, block - -// edict->deadflag values -#define DEAD_NO 0 // alive -#define DEAD_DYING 1 // playing death animation or still falling off of a ledge waiting to hit ground -#define DEAD_DEAD 2 // dead. lying still. -#define DEAD_RESPAWNABLE 3 -#define DEAD_DISCARDBODY 4 - -#define DAMAGE_NO 0 -#define DAMAGE_YES 1 -#define DAMAGE_AIM 2 - -// entity effects -#define EF_BRIGHTFIELD 1 // swirling cloud of particles -#define EF_MUZZLEFLASH 2 // single frame ELIGHT on entity attachment 0 -#define EF_BRIGHTLIGHT 4 // DLIGHT centered at entity origin -#define EF_DIMLIGHT 8 // player flashlight -#define EF_INVLIGHT 16 // get lighting from ceiling -#define EF_NOINTERP 32 // don't interpolate the next frame -#define EF_LIGHT 64 // rocket flare glow sprite -#define EF_NODRAW 128 // don't draw entity -#define EF_NIGHTVISION 256 // player nightvision -#define EF_SNIPERLASER 512 // sniper laser effect -#define EF_FIBERCAMERA 1024// fiber camera - - -// entity flags -#define EFLAG_SLERP 1 // do studio interpolation of this entity - -// -// temp entity events -// -#define TE_BEAMPOINTS 0 // beam effect between two points -// coord coord coord (start position) -// coord coord coord (end position) -// short (sprite index) -// byte (starting frame) -// byte (frame rate in 0.1's) -// byte (life in 0.1's) -// byte (line width in 0.1's) -// byte (noise amplitude in 0.01's) -// byte,byte,byte (color) -// byte (brightness) -// byte (scroll speed in 0.1's) - -#define TE_BEAMENTPOINT 1 // beam effect between point and entity -// short (start entity) -// coord coord coord (end position) -// short (sprite index) -// byte (starting frame) -// byte (frame rate in 0.1's) -// byte (life in 0.1's) -// byte (line width in 0.1's) -// byte (noise amplitude in 0.01's) -// byte,byte,byte (color) -// byte (brightness) -// byte (scroll speed in 0.1's) - -#define TE_GUNSHOT 2 // particle effect plus ricochet sound -// coord coord coord (position) - -#define TE_EXPLOSION 3 // additive sprite, 2 dynamic lights, flickering particles, explosion sound, move vertically 8 pps -// coord coord coord (position) -// short (sprite index) -// byte (scale in 0.1's) -// byte (framerate) -// byte (flags) -// -// The Explosion effect has some flags to control performance/aesthetic features: -#define TE_EXPLFLAG_NONE 0 // all flags clear makes default Half-Life explosion -#define TE_EXPLFLAG_NOADDITIVE 1 // sprite will be drawn opaque (ensure that the sprite you send is a non-additive sprite) -#define TE_EXPLFLAG_NODLIGHTS 2 // do not render dynamic lights -#define TE_EXPLFLAG_NOSOUND 4 // do not play client explosion sound -#define TE_EXPLFLAG_NOPARTICLES 8 // do not draw particles - - -#define TE_TAREXPLOSION 4 // Quake1 "tarbaby" explosion with sound -// coord coord coord (position) - -#define TE_SMOKE 5 // alphablend sprite, move vertically 30 pps -// coord coord coord (position) -// short (sprite index) -// byte (scale in 0.1's) -// byte (framerate) - -#define TE_TRACER 6 // tracer effect from point to point -// coord, coord, coord (start) -// coord, coord, coord (end) - -#define TE_LIGHTNING 7 // TE_BEAMPOINTS with simplified parameters -// coord, coord, coord (start) -// coord, coord, coord (end) -// byte (life in 0.1's) -// byte (width in 0.1's) -// byte (amplitude in 0.01's) -// short (sprite model index) - -#define TE_BEAMENTS 8 -// short (start entity) -// short (end entity) -// short (sprite index) -// byte (starting frame) -// byte (frame rate in 0.1's) -// byte (life in 0.1's) -// byte (line width in 0.1's) -// byte (noise amplitude in 0.01's) -// byte,byte,byte (color) -// byte (brightness) -// byte (scroll speed in 0.1's) - -#define TE_SPARKS 9 // 8 random tracers with gravity, ricochet sprite -// coord coord coord (position) - -#define TE_LAVASPLASH 10 // Quake1 lava splash -// coord coord coord (position) - -#define TE_TELEPORT 11 // Quake1 teleport splash -// coord coord coord (position) - -#define TE_EXPLOSION2 12 // Quake1 colormaped (base palette) particle explosion with sound -// coord coord coord (position) -// byte (starting color) -// byte (num colors) - -#define TE_BSPDECAL 13 // Decal from the .BSP file -// coord, coord, coord (x,y,z), decal position (center of texture in world) -// short (texture index of precached decal texture name) -// short (entity index) -// [optional - only included if previous short is non-zero (not the world)] short (index of model of above entity) - -#define TE_IMPLOSION 14 // tracers moving toward a point -// coord, coord, coord (position) -// byte (radius) -// byte (count) -// byte (life in 0.1's) - -#define TE_SPRITETRAIL 15 // line of moving glow sprites with gravity, fadeout, and collisions -// coord, coord, coord (start) -// coord, coord, coord (end) -// short (sprite index) -// byte (count) -// byte (life in 0.1's) -// byte (scale in 0.1's) -// byte (velocity along vector in 10's) -// byte (randomness of velocity in 10's) - -#define TE_BEAM 16 // obsolete - -#define TE_SPRITE 17 // additive sprite, plays 1 cycle -// coord, coord, coord (position) -// short (sprite index) -// byte (scale in 0.1's) -// byte (brightness) - -#define TE_BEAMSPRITE 18 // A beam with a sprite at the end -// coord, coord, coord (start position) -// coord, coord, coord (end position) -// short (beam sprite index) -// short (end sprite index) - -#define TE_BEAMTORUS 19 // screen aligned beam ring, expands to max radius over lifetime -// coord coord coord (center position) -// coord coord coord (axis and radius) -// short (sprite index) -// byte (starting frame) -// byte (frame rate in 0.1's) -// byte (life in 0.1's) -// byte (line width in 0.1's) -// byte (noise amplitude in 0.01's) -// byte,byte,byte (color) -// byte (brightness) -// byte (scroll speed in 0.1's) - -#define TE_BEAMDISK 20 // disk that expands to max radius over lifetime -// coord coord coord (center position) -// coord coord coord (axis and radius) -// short (sprite index) -// byte (starting frame) -// byte (frame rate in 0.1's) -// byte (life in 0.1's) -// byte (line width in 0.1's) -// byte (noise amplitude in 0.01's) -// byte,byte,byte (color) -// byte (brightness) -// byte (scroll speed in 0.1's) - -#define TE_BEAMCYLINDER 21 // cylinder that expands to max radius over lifetime -// coord coord coord (center position) -// coord coord coord (axis and radius) -// short (sprite index) -// byte (starting frame) -// byte (frame rate in 0.1's) -// byte (life in 0.1's) -// byte (line width in 0.1's) -// byte (noise amplitude in 0.01's) -// byte,byte,byte (color) -// byte (brightness) -// byte (scroll speed in 0.1's) - -#define TE_BEAMFOLLOW 22 // create a line of decaying beam segments until entity stops moving -// short (entity:attachment to follow) -// short (sprite index) -// byte (life in 0.1's) -// byte (line width in 0.1's) -// byte,byte,byte (color) -// byte (brightness) - -#define TE_GLOWSPRITE 23 -// coord, coord, coord (pos) short (model index) byte (scale / 10) - -#define TE_BEAMRING 24 // connect a beam ring to two entities -// short (start entity) -// short (end entity) -// short (sprite index) -// byte (starting frame) -// byte (frame rate in 0.1's) -// byte (life in 0.1's) -// byte (line width in 0.1's) -// byte (noise amplitude in 0.01's) -// byte,byte,byte (color) -// byte (brightness) -// byte (scroll speed in 0.1's) - -#define TE_STREAK_SPLASH 25 // oriented shower of tracers -// coord coord coord (start position) -// coord coord coord (direction vector) -// byte (color) -// short (count) -// short (base speed) -// short (ramdon velocity) - -#define TE_BEAMHOSE 26 // obsolete - -#define TE_DLIGHT 27 // dynamic light, effect world, minor entity effect -// coord, coord, coord (pos) -// byte (radius in 10's) -// byte byte byte (color) -// byte (brightness) -// byte (life in 10's) -// byte (decay rate in 10's) - -#define TE_ELIGHT 28 // point entity light, no world effect -// short (entity:attachment to follow) -// coord coord coord (initial position) -// coord (radius) -// byte byte byte (color) -// byte (life in 0.1's) -// coord (decay rate) - -#define TE_TEXTMESSAGE 29 -// short 1.2.13 x (-1 = center) -// short 1.2.13 y (-1 = center) -// byte Effect 0 = fade in/fade out - // 1 is flickery credits - // 2 is write out (training room) - -// 4 bytes r,g,b,a color1 (text color) -// 4 bytes r,g,b,a color2 (effect color) -// ushort 8.8 fadein time -// ushort 8.8 fadeout time -// ushort 8.8 hold time -// optional ushort 8.8 fxtime (time the highlight lags behing the leading text in effect 2) -// string text message (512 chars max sz string) -#define TE_LINE 30 -// coord, coord, coord startpos -// coord, coord, coord endpos -// short life in 0.1 s -// 3 bytes r, g, b - -#define TE_BOX 31 -// coord, coord, coord boxmins -// coord, coord, coord boxmaxs -// short life in 0.1 s -// 3 bytes r, g, b - -#define TE_KILLBEAM 99 // kill all beams attached to entity -// short (entity) - -#define TE_LARGEFUNNEL 100 -// coord coord coord (funnel position) -// short (sprite index) -// short (flags) - -#define TE_BLOODSTREAM 101 // particle spray -// coord coord coord (start position) -// coord coord coord (spray vector) -// byte (color) -// byte (speed) - -#define TE_SHOWLINE 102 // line of particles every 5 units, dies in 30 seconds -// coord coord coord (start position) -// coord coord coord (end position) - -#define TE_BLOOD 103 // particle spray -// coord coord coord (start position) -// coord coord coord (spray vector) -// byte (color) -// byte (speed) - -#define TE_DECAL 104 // Decal applied to a brush entity (not the world) -// coord, coord, coord (x,y,z), decal position (center of texture in world) -// byte (texture index of precached decal texture name) -// short (entity index) - -#define TE_FIZZ 105 // create alpha sprites inside of entity, float upwards -// short (entity) -// short (sprite index) -// byte (density) - -#define TE_MODEL 106 // create a moving model that bounces and makes a sound when it hits -// coord, coord, coord (position) -// coord, coord, coord (velocity) -// angle (initial yaw) -// short (model index) -// byte (bounce sound type) -// byte (life in 0.1's) - -#define TE_EXPLODEMODEL 107 // spherical shower of models, picks from set -// coord, coord, coord (origin) -// coord (velocity) -// short (model index) -// short (count) -// byte (life in 0.1's) - -#define TE_BREAKMODEL 108 // box of models or sprites -// coord, coord, coord (position) -// coord, coord, coord (size) -// coord, coord, coord (velocity) -// byte (random velocity in 10's) -// short (sprite or model index) -// byte (count) -// byte (life in 0.1 secs) -// byte (flags) - -#define TE_GUNSHOTDECAL 109 // decal and ricochet sound -// coord, coord, coord (position) -// short (entity index???) -// byte (decal???) - -#define TE_SPRITE_SPRAY 110 // spay of alpha sprites -// coord, coord, coord (position) -// coord, coord, coord (velocity) -// short (sprite index) -// byte (count) -// byte (speed) -// byte (noise) - -#define TE_ARMOR_RICOCHET 111 // quick spark sprite, client ricochet sound. -// coord, coord, coord (position) -// byte (scale in 0.1's) - -#define TE_PLAYERDECAL 112 // ??? -// byte (playerindex) -// coord, coord, coord (position) -// short (entity???) -// byte (decal number???) -// [optional] short (model index???) - -#define TE_BUBBLES 113 // create alpha sprites inside of box, float upwards -// coord, coord, coord (min start position) -// coord, coord, coord (max start position) -// coord (float height) -// short (model index) -// byte (count) -// coord (speed) - -#define TE_BUBBLETRAIL 114 // create alpha sprites along a line, float upwards -// coord, coord, coord (min start position) -// coord, coord, coord (max start position) -// coord (float height) -// short (model index) -// byte (count) -// coord (speed) - -#define TE_BLOODSPRITE 115 // spray of opaque sprite1's that fall, single sprite2 for 1..2 secs (this is a high-priority tent) -// coord, coord, coord (position) -// short (sprite1 index) -// short (sprite2 index) -// byte (color) -// byte (scale) - -#define TE_WORLDDECAL 116 // Decal applied to the world brush -// coord, coord, coord (x,y,z), decal position (center of texture in world) -// byte (texture index of precached decal texture name) - -#define TE_WORLDDECALHIGH 117 // Decal (with texture index > 256) applied to world brush -// coord, coord, coord (x,y,z), decal position (center of texture in world) -// byte (texture index of precached decal texture name - 256) - -#define TE_DECALHIGH 118 // Same as TE_DECAL, but the texture index was greater than 256 -// coord, coord, coord (x,y,z), decal position (center of texture in world) -// byte (texture index of precached decal texture name - 256) -// short (entity index) - -#define TE_PROJECTILE 119 // Makes a projectile (like a nail) (this is a high-priority tent) -// coord, coord, coord (position) -// coord, coord, coord (velocity) -// short (modelindex) -// byte (life) -// byte (owner) projectile won't collide with owner (if owner == 0, projectile will hit any client). - -#define TE_SPRAY 120 // Throws a shower of sprites or models -// coord, coord, coord (position) -// coord, coord, coord (direction) -// short (modelindex) -// byte (count) -// byte (speed) -// byte (noise) -// byte (rendermode) - -#define TE_PLAYERSPRITES 121 // sprites emit from a player's bounding box (ONLY use for players!) -// byte (playernum) -// short (sprite modelindex) -// byte (count) -// byte (variance) (0 = no variance in size) (10 = 10% variance in size) - -#define TE_PARTICLEBURST 122 // very similar to lavasplash. -// coord (origin) -// short (radius) -// byte (particle color) -// byte (duration * 10) (will be randomized a bit) - -#define TE_FIREFIELD 123 // makes a field of fire. -// coord (origin) -// short (radius) (fire is made in a square around origin. -radius, -radius to radius, radius) -// short (modelindex) -// byte (count) -// byte (flags) -// byte (duration (in seconds) * 10) (will be randomized a bit) -// -// to keep network traffic low, this message has associated flags that fit into a byte: -#define TEFIRE_FLAG_ALLFLOAT 1 // all sprites will drift upwards as they animate -#define TEFIRE_FLAG_SOMEFLOAT 2 // some of the sprites will drift upwards. (50% chance) -#define TEFIRE_FLAG_LOOP 4 // if set, sprite plays at 15 fps, otherwise plays at whatever rate stretches the animation over the sprite's duration. -#define TEFIRE_FLAG_ALPHA 8 // if set, sprite is rendered alpha blended at 50% else, opaque -#define TEFIRE_FLAG_PLANAR 16 // if set, all fire sprites have same initial Z instead of randomly filling a cube. -#define TEFIRE_FLAG_ADDITIVE 32 // if set, sprite is rendered non-opaque with additive - -#define TE_PLAYERATTACHMENT 124 // attaches a TENT to a player (this is a high-priority tent) -// byte (entity index of player) -// coord (vertical offset) ( attachment origin.z = player origin.z + vertical offset ) -// short (model index) -// short (life * 10 ); - -#define TE_KILLPLAYERATTACHMENTS 125 // will expire all TENTS attached to a player. -// byte (entity index of player) - -#define TE_MULTIGUNSHOT 126 // much more compact shotgun message -// This message is used to make a client approximate a 'spray' of gunfire. -// Any weapon that fires more than one bullet per frame and fires in a bit of a spread is -// a good candidate for MULTIGUNSHOT use. (shotguns) -// -// NOTE: This effect makes the client do traces for each bullet, these client traces ignore -// entities that have studio models.Traces are 4096 long. -// -// coord (origin) -// coord (origin) -// coord (origin) -// coord (direction) -// coord (direction) -// coord (direction) -// coord (x noise * 100) -// coord (y noise * 100) -// byte (count) -// byte (bullethole decal texture index) - -#define TE_USERTRACER 127 // larger message than the standard tracer, but allows some customization. -// coord (origin) -// coord (origin) -// coord (origin) -// coord (velocity) -// coord (velocity) -// coord (velocity) -// byte ( life * 10 ) -// byte ( color ) this is an index into an array of color vectors in the engine. (0 - ) -// byte ( length * 10 ) - - - -#define MSG_BROADCAST 0 // unreliable to all -#define MSG_ONE 1 // reliable to one (msg_entity) -#define MSG_ALL 2 // reliable to all -#define MSG_INIT 3 // write to the init string -#define MSG_PVS 4 // Ents in PVS of org -#define MSG_PAS 5 // Ents in PAS of org -#define MSG_PVS_R 6 // Reliable to PVS -#define MSG_PAS_R 7 // Reliable to PAS -#define MSG_ONE_UNRELIABLE 8 // Send to one client, but don't put in reliable stream, put in unreliable datagram ( could be dropped ) -#define MSG_SPEC 9 // Sends to all spectator proxies - -// contents of a spot in the world -#define CONTENTS_EMPTY -1 -#define CONTENTS_SOLID -2 -#define CONTENTS_WATER -3 -#define CONTENTS_SLIME -4 -#define CONTENTS_LAVA -5 -#define CONTENTS_SKY -6 -/* These additional contents constants are defined in bspfile.h -#define CONTENTS_ORIGIN -7 // removed at csg time -#define CONTENTS_CLIP -8 // changed to contents_solid -#define CONTENTS_CURRENT_0 -9 -#define CONTENTS_CURRENT_90 -10 -#define CONTENTS_CURRENT_180 -11 -#define CONTENTS_CURRENT_270 -12 -#define CONTENTS_CURRENT_UP -13 -#define CONTENTS_CURRENT_DOWN -14 - -#define CONTENTS_TRANSLUCENT -15 -*/ -#define CONTENTS_LADDER -16 - -#define CONTENT_FLYFIELD -17 -#define CONTENT_GRAVITY_FLYFIELD -18 -#define CONTENT_FOG -19 - -#define CONTENT_EMPTY -1 -#define CONTENT_SOLID -2 -#define CONTENT_WATER -3 -#define CONTENT_SLIME -4 -#define CONTENT_LAVA -5 -#define CONTENT_SKY -6 - -// channels -#define CHAN_AUTO 0 -#define CHAN_WEAPON 1 -#define CHAN_VOICE 2 -#define CHAN_ITEM 3 -#define CHAN_BODY 4 -#define CHAN_STREAM 5 // allocate stream channel from the static or dynamic area -#define CHAN_STATIC 6 // allocate channel from the static area -#define CHAN_NETWORKVOICE_BASE 7 // voice data coming across the network -#define CHAN_NETWORKVOICE_END 500 // network voice data reserves slots (CHAN_NETWORKVOICE_BASE through CHAN_NETWORKVOICE_END). -#define CHAN_BOT 501 // channel used for bot chatter. - -// attenuation values -#define ATTN_NONE 0 -#define ATTN_NORM (float)0.8 -#define ATTN_IDLE (float)2 -#define ATTN_STATIC (float)1.25 - -// pitch values -#define PITCH_NORM 100 // non-pitch shifted -#define PITCH_LOW 95 // other values are possible - 0-255, where 255 is very high -#define PITCH_HIGH 120 - -// volume values -#define VOL_NORM 1.0 - -// plats -#define PLAT_LOW_TRIGGER 1 - -// Trains -#define SF_TRAIN_WAIT_RETRIGGER 1 -#define SF_TRAIN_START_ON 4 // Train is initially moving -#define SF_TRAIN_PASSABLE 8 // Train is not solid -- used to make water trains - -// buttons -#ifndef IN_BUTTONS_H -#include "in_buttons.h" -#endif - -// Break Model Defines - -#define BREAK_TYPEMASK 0x4F -#define BREAK_GLASS 0x01 -#define BREAK_METAL 0x02 -#define BREAK_FLESH 0x04 -#define BREAK_WOOD 0x08 - -#define BREAK_SMOKE 0x10 -#define BREAK_TRANS 0x20 -#define BREAK_CONCRETE 0x40 -#define BREAK_2 0x80 - -// Colliding temp entity sounds - -#define BOUNCE_GLASS BREAK_GLASS -#define BOUNCE_METAL BREAK_METAL -#define BOUNCE_FLESH BREAK_FLESH -#define BOUNCE_WOOD BREAK_WOOD -#define BOUNCE_SHRAP 0x10 -#define BOUNCE_SHELL 0x20 -#define BOUNCE_CONCRETE BREAK_CONCRETE -#define BOUNCE_SHOTSHELL 0x80 - -// Temp entity bounce sound types -#define TE_BOUNCE_NULL 0 -#define TE_BOUNCE_SHELL 1 -#define TE_BOUNCE_SHOTSHELL 2 - -// Rendering constants -enum -{ - kRenderNormal, // src - kRenderTransColor, // c*a+dest*(1-a) - kRenderTransTexture, // src*a+dest*(1-a) - kRenderGlow, // src*a+dest -- No Z buffer checks - kRenderTransAlpha, // src*srca+dest*(1-srca) - kRenderTransAdd, // src*a+dest -}; - -enum -{ - kRenderFxNone = 0, - kRenderFxPulseSlow, - kRenderFxPulseFast, - kRenderFxPulseSlowWide, - kRenderFxPulseFastWide, - kRenderFxFadeSlow, - kRenderFxFadeFast, - kRenderFxSolidSlow, - kRenderFxSolidFast, - kRenderFxStrobeSlow, - kRenderFxStrobeFast, - kRenderFxStrobeFaster, - kRenderFxFlickerSlow, - kRenderFxFlickerFast, - kRenderFxNoDissipation, - kRenderFxDistort, // Distort/scale/translate flicker - kRenderFxHologram, // kRenderFxDistort + distance fade - kRenderFxDeadPlayer, // kRenderAmt is the player index - kRenderFxExplode, // Scale up really big! - kRenderFxGlowShell, // Glowing Shell - kRenderFxClampMinScale, // Keep this sprite from getting very small (SPRITES only!) - kRenderFxLightMultiplier, //CTM !!!CZERO added to tell the studiorender that the value in iuser2 is a lightmultiplier -}; - - -typedef unsigned int func_t; -typedef unsigned int string_t; - -typedef unsigned char byte; -typedef unsigned short word; -#define _DEF_BYTE_ - -#undef true -#undef false - -#ifndef __cplusplus -typedef enum {false, true} qboolean; -#else -typedef int qboolean; -#endif - -typedef struct -{ - byte r, g, b; -} color24; - -typedef struct -{ - unsigned r, g, b, a; -} colorVec; - -#ifdef _WIN32 -#pragma pack(push,2) -#endif - -typedef struct -{ - unsigned short r, g, b, a; -} PackedColorVec; - -#ifdef _WIN32 -#pragma pack(pop) -#endif -typedef struct link_s -{ - struct link_s *prev, *next; -} link_t; - -typedef struct edict_s edict_t; - -typedef struct -{ - vec3_t normal; - float dist; -} plane_t; - -typedef struct -{ - qboolean allsolid; // if true, plane is not valid - qboolean startsolid; // if true, the initial point was in a solid area - qboolean inopen, inwater; - float fraction; // time completed, 1.0 = didn't hit anything - vec3_t endpos; // final position - plane_t plane; // surface normal at impact - edict_t * ent; // entity the surface is on - int hitgroup; // 0 == generic, non zero is specific body part -} trace_t; - -#endif // CONST_H diff --git a/regamedll/extra/cssdk/common/crc.h b/regamedll/extra/cssdk/common/crc.h deleted file mode 100644 index 44bcf35b..00000000 --- a/regamedll/extra/cssdk/common/crc.h +++ /dev/null @@ -1,55 +0,0 @@ -/*** -* -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ -/* crc.h */ -#pragma once - -#include "quakedef.h" - -// MD5 Hash -typedef struct -{ - unsigned int buf[4]; - unsigned int bits[2]; - unsigned char in[64]; -} MD5Context_t; - -typedef unsigned int CRC32_t; - - -#ifdef __cplusplus -extern "C" -{ -#endif - -void CRC32_Init(CRC32_t *pulCRC); -CRC32_t CRC32_Final(CRC32_t pulCRC); -void CRC32_ProcessByte(CRC32_t *pulCRC, unsigned char ch); -void CRC32_ProcessBuffer(CRC32_t *pulCRC, void *pBuffer, int nBuffer); -BOOL CRC_File(CRC32_t *crcvalue, char *pszFileName); - -#ifdef __cplusplus -} -#endif - -byte COM_BlockSequenceCRCByte(byte *base, int length, int sequence); -int CRC_MapFile(CRC32_t *crcvalue, char *pszFileName); - -void MD5Init(MD5Context_t *ctx); -void MD5Update(MD5Context_t *ctx, const unsigned char *buf, unsigned int len); -void MD5Final(unsigned char digest[16], MD5Context_t *ctx); -void MD5Transform(unsigned int buf[4], const unsigned int in[16]); - -BOOL MD5_Hash_File(unsigned char digest[16], char *pszFileName, BOOL bUsefopen, BOOL bSeed, unsigned int seed[4]); -char *MD5_Print(unsigned char hash[16]); diff --git a/regamedll/extra/cssdk/common/cvardef.h b/regamedll/extra/cssdk/common/cvardef.h deleted file mode 100644 index cc3a2226..00000000 --- a/regamedll/extra/cssdk/common/cvardef.h +++ /dev/null @@ -1,39 +0,0 @@ -/*** -* -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ - -#ifndef CVARDEF_H -#define CVARDEF_H - -#define FCVAR_ARCHIVE (1<<0) // set to cause it to be saved to vars.rc -#define FCVAR_USERINFO (1<<1) // changes the client's info string -#define FCVAR_SERVER (1<<2) // notifies players when changed -#define FCVAR_EXTDLL (1<<3) // defined by external DLL -#define FCVAR_CLIENTDLL (1<<4) // defined by the client dll -#define FCVAR_PROTECTED (1<<5) // It's a server cvar, but we don't send the data since it's a password, etc. Sends 1 if it's not bland/zero, 0 otherwise as value -#define FCVAR_SPONLY (1<<6) // This cvar cannot be changed by clients connected to a multiplayer server. -#define FCVAR_PRINTABLEONLY (1<<7) // This cvar's string cannot contain unprintable characters ( e.g., used for player name etc ). -#define FCVAR_UNLOGGED (1<<8) // If this is a FCVAR_SERVER, don't log changes to the log file / console if we are creating a log -#define FCVAR_NOEXTRAWHITEPACE (1<<9) // strip trailing/leading white space from this cvar - -typedef struct cvar_s -{ - const char *name; - char *string; - int flags; - float value; - struct cvar_s *next; -} cvar_t; - -#endif // CVARDEF_H diff --git a/regamedll/extra/cssdk/common/demo_api.h b/regamedll/extra/cssdk/common/demo_api.h deleted file mode 100644 index 8284a815..00000000 --- a/regamedll/extra/cssdk/common/demo_api.h +++ /dev/null @@ -1,31 +0,0 @@ -/*** -* -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ -#if !defined ( DEMO_APIH ) -#define DEMO_APIH -#ifdef _WIN32 -#pragma once -#endif - -typedef struct demo_api_s -{ - int ( *IsRecording ) ( void ); - int ( *IsPlayingback ) ( void ); - int ( *IsTimeDemo ) ( void ); - void ( *WriteBuffer ) ( int size, unsigned char *buffer ); -} demo_api_t; - -extern demo_api_t demoapi; - -#endif diff --git a/regamedll/extra/cssdk/common/director_cmds.h b/regamedll/extra/cssdk/common/director_cmds.h deleted file mode 100644 index 4c8fdd57..00000000 --- a/regamedll/extra/cssdk/common/director_cmds.h +++ /dev/null @@ -1,38 +0,0 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ -// -// Purpose: -// -// $NoKeywords: $ -//============================================================================= - -// director_cmds.h -// sub commands for svc_director - -#define DRC_ACTIVE 0 // tells client that he's an spectator and will get director command -#define DRC_STATUS 1 // send status infos about proxy -#define DRC_CAMERA 2 // set the actual director camera position -#define DRC_EVENT 3 // informs the dircetor about ann important game event - - -#define DRC_FLAG_PRIO_MASK 0x0F // priorities between 0 and 15 (15 most important) -#define DRC_FLAG_SIDE (1<<4) -#define DRC_FLAG_DRAMATIC (1<<5) - - - -// commands of the director API function CallDirectorProc(...) - -#define DRCAPI_NOP 0 // no operation -#define DRCAPI_ACTIVE 1 // de/acivates director mode in engine -#define DRCAPI_STATUS 2 // request proxy information -#define DRCAPI_SETCAM 3 // set camera n to given position and angle -#define DRCAPI_GETCAM 4 // request camera n position and angle -#define DRCAPI_DIRPLAY 5 // set director time and play with normal speed -#define DRCAPI_DIRFREEZE 6 // freeze directo at this time -#define DRCAPI_SETVIEWMODE 7 // overview or 4 cameras -#define DRCAPI_SETOVERVIEWPARAMS 8 // sets parameter for overview mode -#define DRCAPI_SETFOCUS 9 // set the camera which has the input focus -#define DRCAPI_GETTARGETS 10 // queries engine for player list -#define DRCAPI_SETVIEWPOINTS 11 // gives engine all waypoints - - diff --git a/regamedll/extra/cssdk/common/dlight.h b/regamedll/extra/cssdk/common/dlight.h deleted file mode 100644 index f869c983..00000000 --- a/regamedll/extra/cssdk/common/dlight.h +++ /dev/null @@ -1,33 +0,0 @@ -/*** -* -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ -#if !defined ( DLIGHTH ) -#define DLIGHTH -#ifdef _WIN32 -#pragma once -#endif - -typedef struct dlight_s -{ - vec3_t origin; - float radius; - color24 color; - float die; // stop lighting after this time - float decay; // drop this each second - float minlight; // don't add when contributing less - int key; - qboolean dark; // subtracts light instead of adding -} dlight_t; - -#endif diff --git a/regamedll/extra/cssdk/common/dll_state.h b/regamedll/extra/cssdk/common/dll_state.h deleted file mode 100644 index ad16296b..00000000 --- a/regamedll/extra/cssdk/common/dll_state.h +++ /dev/null @@ -1,23 +0,0 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ -// -// Purpose: -// -// $NoKeywords: $ -//============================================================================= - -//DLL State Flags - -#define DLL_INACTIVE 0 // no dll -#define DLL_ACTIVE 1 // dll is running -#define DLL_PAUSED 2 // dll is paused -#define DLL_CLOSE 3 // closing down dll -#define DLL_TRANS 4 // Level Transition - -// DLL Pause reasons - -#define DLL_NORMAL 0 // User hit Esc or something. -#define DLL_QUIT 4 // Quit now -#define DLL_RESTART 5 // Switch to launcher for linux, does a quit but returns 1 - -// DLL Substate info ( not relevant ) -#define ENG_NORMAL (1<<0) diff --git a/regamedll/extra/cssdk/common/entity_state.h b/regamedll/extra/cssdk/common/entity_state.h deleted file mode 100644 index b3d364dc..00000000 --- a/regamedll/extra/cssdk/common/entity_state.h +++ /dev/null @@ -1,197 +0,0 @@ -/*** -* -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ - -#ifndef ENTITY_STATE_H -#define ENTITY_STATE_H -#ifdef _WIN32 -#pragma once -#endif - -#include "const.h" - - -// For entityType below -#define ENTITY_NORMAL (1<<0) -#define ENTITY_BEAM (1<<1) - -// Entity state is used for the baseline and for delta compression of a packet of -// entities that is sent to a client. -typedef struct entity_state_s entity_state_t; - -struct entity_state_s -{ -// Fields which are filled in by routines outside of delta compression - int entityType; - // Index into cl_entities array for this entity. - int number; - float msg_time; - - // Message number last time the player/entity state was updated. - int messagenum; - - // Fields which can be transitted and reconstructed over the network stream - vec3_t origin; - vec3_t angles; - - int modelindex; - int sequence; - float frame; - int colormap; - short skin; - short solid; - int effects; - float scale; - - byte eflags; - - // Render information - int rendermode; - int renderamt; - color24 rendercolor; - int renderfx; - - int movetype; - float animtime; - float framerate; - int body; - byte controller[4]; - byte blending[4]; - vec3_t velocity; - - // Send bbox down to client for use during prediction. - vec3_t mins; - vec3_t maxs; - - int aiment; - // If owned by a player, the index of that player ( for projectiles ). - int owner; - - // Friction, for prediction. - float friction; - // Gravity multiplier - float gravity; - -// PLAYER SPECIFIC - int team; - int playerclass; - int health; - qboolean spectator; - int weaponmodel; - int gaitsequence; - // If standing on conveyor, e.g. - vec3_t basevelocity; - // Use the crouched hull, or the regular player hull. - int usehull; - // Latched buttons last time state updated. - int oldbuttons; - // -1 = in air, else pmove entity number - int onground; - int iStepLeft; - // How fast we are falling - float flFallVelocity; - - float fov; - int weaponanim; - - // Parametric movement overrides - vec3_t startpos; - vec3_t endpos; - float impacttime; - float starttime; - - // For mods - int iuser1; - int iuser2; - int iuser3; - int iuser4; - float fuser1; - float fuser2; - float fuser3; - float fuser4; - vec3_t vuser1; - vec3_t vuser2; - vec3_t vuser3; - vec3_t vuser4; -}; - -#include "pm_info.h" - -typedef struct clientdata_s -{ - vec3_t origin; - vec3_t velocity; - - int viewmodel; - vec3_t punchangle; - int flags; - int waterlevel; - int watertype; - vec3_t view_ofs; - float health; - - int bInDuck; - - int weapons; // remove? - - int flTimeStepSound; - int flDuckTime; - int flSwimTime; - int waterjumptime; - - float maxspeed; - - float fov; - int weaponanim; - - int m_iId; - int ammo_shells; - int ammo_nails; - int ammo_cells; - int ammo_rockets; - float m_flNextAttack; - - int tfstate; - - int pushmsec; - - int deadflag; - - char physinfo[ MAX_PHYSINFO_STRING ]; - - // For mods - int iuser1; - int iuser2; - int iuser3; - int iuser4; - float fuser1; - float fuser2; - float fuser3; - float fuser4; - vec3_t vuser1; - vec3_t vuser2; - vec3_t vuser3; - vec3_t vuser4; -} clientdata_t; - -#include "weaponinfo.h" - -typedef struct local_state_s -{ - entity_state_t playerstate; - clientdata_t client; - weapon_data_t weapondata[ 64 ]; -} local_state_t; - -#endif // ENTITY_STATE_H diff --git a/regamedll/extra/cssdk/common/entity_types.h b/regamedll/extra/cssdk/common/entity_types.h deleted file mode 100644 index ff783df1..00000000 --- a/regamedll/extra/cssdk/common/entity_types.h +++ /dev/null @@ -1,26 +0,0 @@ -/*** -* -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ -// entity_types.h -#if !defined( ENTITY_TYPESH ) -#define ENTITY_TYPESH - -#define ET_NORMAL 0 -#define ET_PLAYER 1 -#define ET_TEMPENTITY 2 -#define ET_BEAM 3 -// BMODEL or SPRITE that was split across BSP nodes -#define ET_FRAGMENTED 4 - -#endif // !ENTITY_TYPESH diff --git a/regamedll/extra/cssdk/common/enums.h b/regamedll/extra/cssdk/common/enums.h deleted file mode 100644 index 14e2ce3a..00000000 --- a/regamedll/extra/cssdk/common/enums.h +++ /dev/null @@ -1,27 +0,0 @@ -/*** - * - * Copyright (c) 2009, Valve LLC. All rights reserved. - * - * This product contains software technology licensed from Id - * Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. - * All Rights Reserved. - * - * Use, distribution, and modification of this source code and/or resulting - * object code is restricted to non-commercial enhancements to products from - * Valve LLC. All other use, distribution, or modification is prohibited - * without written permission from Valve LLC. - * - ****/ - -#ifndef ENUMS_H -#define ENUMS_H - -typedef enum netsrc_s -{ - NS_CLIENT, - NS_SERVER, - NS_MULTICAST // xxxMO -} netsrc_t; - -#endif - diff --git a/regamedll/extra/cssdk/common/event_api.h b/regamedll/extra/cssdk/common/event_api.h deleted file mode 100644 index 722dfe22..00000000 --- a/regamedll/extra/cssdk/common/event_api.h +++ /dev/null @@ -1,51 +0,0 @@ -/*** -* -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ -#if !defined ( EVENT_APIH ) -#define EVENT_APIH -#ifdef _WIN32 -#pragma once -#endif - -#define EVENT_API_VERSION 1 - -typedef struct event_api_s -{ - int version; - void ( *EV_PlaySound ) ( int ent, float *origin, int channel, const char *sample, float volume, float attenuation, int fFlags, int pitch ); - void ( *EV_StopSound ) ( int ent, int channel, const char *sample ); - int ( *EV_FindModelIndex )( const char *pmodel ); - int ( *EV_IsLocal ) ( int playernum ); - int ( *EV_LocalPlayerDucking ) ( void ); - void ( *EV_LocalPlayerViewheight ) ( float * ); - void ( *EV_LocalPlayerBounds ) ( int hull, float *mins, float *maxs ); - int ( *EV_IndexFromTrace) ( struct pmtrace_s *pTrace ); - struct physent_s *( *EV_GetPhysent ) ( int idx ); - void ( *EV_SetUpPlayerPrediction ) ( int dopred, int bIncludeLocalClient ); - void ( *EV_PushPMStates ) ( void ); - void ( *EV_PopPMStates ) ( void ); - void ( *EV_SetSolidPlayers ) (int playernum); - void ( *EV_SetTraceHull ) ( int hull ); - void ( *EV_PlayerTrace ) ( float *start, float *end, int traceFlags, int ignore_pe, struct pmtrace_s *tr ); - void ( *EV_WeaponAnimation ) ( int sequence, int body ); - unsigned short ( *EV_PrecacheEvent ) ( int type, const char* psz ); - void ( *EV_PlaybackEvent ) ( int flags, const struct edict_s *pInvoker, unsigned short eventindex, float delay, float *origin, float *angles, float fparam1, float fparam2, int iparam1, int iparam2, int bparam1, int bparam2 ); - const char *( *EV_TraceTexture ) ( int ground, float *vstart, float *vend ); - void ( *EV_StopAllSounds ) ( int entnum, int entchannel ); - void ( *EV_KillEvents ) ( int entnum, const char *eventname ); -} event_api_t; - -extern event_api_t eventapi; - -#endif diff --git a/regamedll/extra/cssdk/common/event_args.h b/regamedll/extra/cssdk/common/event_args.h deleted file mode 100644 index 99dd49af..00000000 --- a/regamedll/extra/cssdk/common/event_args.h +++ /dev/null @@ -1,50 +0,0 @@ -/*** -* -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ -#if !defined( EVENT_ARGSH ) -#define EVENT_ARGSH -#ifdef _WIN32 -#pragma once -#endif - -// Event was invoked with stated origin -#define FEVENT_ORIGIN ( 1<<0 ) - -// Event was invoked with stated angles -#define FEVENT_ANGLES ( 1<<1 ) - -typedef struct event_args_s -{ - int flags; - - // Transmitted - int entindex; - - float origin[3]; - float angles[3]; - float velocity[3]; - - int ducking; - - float fparam1; - float fparam2; - - int iparam1; - int iparam2; - - int bparam1; - int bparam2; -} event_args_t; - -#endif diff --git a/regamedll/extra/cssdk/common/event_flags.h b/regamedll/extra/cssdk/common/event_flags.h deleted file mode 100644 index 43f804f7..00000000 --- a/regamedll/extra/cssdk/common/event_flags.h +++ /dev/null @@ -1,47 +0,0 @@ -/*** -* -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ -#if !defined( EVENT_FLAGSH ) -#define EVENT_FLAGSH -#ifdef _WIN32 -#pragma once -#endif - -// Skip local host for event send. -#define FEV_NOTHOST (1<<0) - -// Send the event reliably. You must specify the origin and angles and use -// PLAYBACK_EVENT_FULL for this to work correctly on the server for anything -// that depends on the event origin/angles. I.e., the origin/angles are not -// taken from the invoking edict for reliable events. -#define FEV_RELIABLE (1<<1) - -// Don't restrict to PAS/PVS, send this event to _everybody_ on the server ( useful for stopping CHAN_STATIC -// sounds started by client event when client is not in PVS anymore ( hwguy in TFC e.g. ). -#define FEV_GLOBAL (1<<2) - -// If this client already has one of these events in its queue, just update the event instead of sending it as a duplicate -// -#define FEV_UPDATE (1<<3) - -// Only send to entity specified as the invoker -#define FEV_HOSTONLY (1<<4) - -// Only send if the event was created on the server. -#define FEV_SERVER (1<<5) - -// Only issue event client side ( from shared code ) -#define FEV_CLIENT (1<<6) - -#endif diff --git a/regamedll/extra/cssdk/common/hltv.h b/regamedll/extra/cssdk/common/hltv.h deleted file mode 100644 index a6ded4e8..00000000 --- a/regamedll/extra/cssdk/common/hltv.h +++ /dev/null @@ -1,61 +0,0 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ -// -// Purpose: -// -// $NoKeywords: $ -//============================================================================= - -// hltv.h -// all shared consts between server, clients and proxy - -#ifndef HLTV_H -#define HLTV_H - -#define TYPE_CLIENT 0 // client is a normal HL client (default) -#define TYPE_PROXY 1 // client is another proxy -#define TYPE_COMMENTATOR 3 // client is a commentator -#define TYPE_DEMO 4 // client is a demo file - -// sub commands of svc_hltv: -#define HLTV_ACTIVE 0 // tells client that he's an spectator and will get director commands -#define HLTV_STATUS 1 // send status infos about proxy -#define HLTV_LISTEN 2 // tell client to listen to a multicast stream - -// director command types: -#define DRC_CMD_NONE 0 // NULL director command -#define DRC_CMD_START 1 // start director mode -#define DRC_CMD_EVENT 2 // informs about director command -#define DRC_CMD_MODE 3 // switches camera modes -#define DRC_CMD_CAMERA 4 // set fixed camera -#define DRC_CMD_TIMESCALE 5 // sets time scale -#define DRC_CMD_MESSAGE 6 // send HUD centerprint -#define DRC_CMD_SOUND 7 // plays a particular sound -#define DRC_CMD_STATUS 8 // HLTV broadcast status -#define DRC_CMD_BANNER 9 // set GUI banner -#define DRC_CMD_STUFFTEXT 10 // like the normal svc_stufftext but as director command -#define DRC_CMD_CHASE 11 // chase a certain player -#define DRC_CMD_INEYE 12 // view player through own eyes -#define DRC_CMD_MAP 13 // show overview map -#define DRC_CMD_CAMPATH 14 // define camera waypoint -#define DRC_CMD_WAYPOINTS 15 // start moving camera, inetranl message - -#define DRC_CMD_LAST 15 - - -// DRC_CMD_EVENT event flags -#define DRC_FLAG_PRIO_MASK 0x0F // priorities between 0 and 15 (15 most important) -#define DRC_FLAG_SIDE (1<<4) // -#define DRC_FLAG_DRAMATIC (1<<5) // is a dramatic scene -#define DRC_FLAG_SLOWMOTION (1<<6) // would look good in SloMo -#define DRC_FLAG_FACEPLAYER (1<<7) // player is doning something (reload/defuse bomb etc) -#define DRC_FLAG_INTRO (1<<8) // is a introduction scene -#define DRC_FLAG_FINAL (1<<9) // is a final scene -#define DRC_FLAG_NO_RANDOM (1<<10) // don't randomize event data - - -// DRC_CMD_WAYPOINT flags -#define DRC_FLAG_STARTPATH 1 // end with speed 0.0 -#define DRC_FLAG_SLOWSTART 2 // start with speed 0.0 -#define DRC_FLAG_SLOWEND 4 // end with speed 0.0 - -#endif // HLTV_H diff --git a/regamedll/extra/cssdk/common/in_buttons.h b/regamedll/extra/cssdk/common/in_buttons.h deleted file mode 100644 index 4196a2d6..00000000 --- a/regamedll/extra/cssdk/common/in_buttons.h +++ /dev/null @@ -1,38 +0,0 @@ -/*** -* -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ -#ifndef IN_BUTTONS_H -#define IN_BUTTONS_H -#ifdef _WIN32 -#pragma once -#endif - -#define IN_ATTACK (1 << 0) -#define IN_JUMP (1 << 1) -#define IN_DUCK (1 << 2) -#define IN_FORWARD (1 << 3) -#define IN_BACK (1 << 4) -#define IN_USE (1 << 5) -#define IN_CANCEL (1 << 6) -#define IN_LEFT (1 << 7) -#define IN_RIGHT (1 << 8) -#define IN_MOVELEFT (1 << 9) -#define IN_MOVERIGHT (1 << 10) -#define IN_ATTACK2 (1 << 11) -#define IN_RUN (1 << 12) -#define IN_RELOAD (1 << 13) -#define IN_ALT1 (1 << 14) -#define IN_SCORE (1 << 15) // Used by client.dll for when scoreboard is held down - -#endif // IN_BUTTONS_H diff --git a/regamedll/extra/cssdk/common/ivoicetweak.h b/regamedll/extra/cssdk/common/ivoicetweak.h deleted file mode 100644 index da568c5a..00000000 --- a/regamedll/extra/cssdk/common/ivoicetweak.h +++ /dev/null @@ -1,38 +0,0 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ -// -// Purpose: -// -// $NoKeywords: $ -//============================================================================= - -#ifndef IVOICETWEAK_H -#define IVOICETWEAK_H -#ifdef _WIN32 -#pragma once -#endif - -// These provide access to the voice controls. -typedef enum -{ - MicrophoneVolume=0, // values 0-1. - OtherSpeakerScale, // values 0-1. Scales how loud other players are. - MicBoost, // 20 db gain to voice input -} VoiceTweakControl; - - -typedef struct IVoiceTweak_s -{ - // These turn voice tweak mode on and off. While in voice tweak mode, the user's voice is echoed back - // without sending to the server. - int (*StartVoiceTweakMode)(); // Returns 0 on error. - void (*EndVoiceTweakMode)(); - - // Get/set control values. - void (*SetControlFloat)(VoiceTweakControl iControl, float value); - float (*GetControlFloat)(VoiceTweakControl iControl); - - int (*GetSpeakingVolume)(); -} IVoiceTweak; - - -#endif // IVOICETWEAK_H diff --git a/regamedll/extra/cssdk/common/kbutton.h b/regamedll/extra/cssdk/common/kbutton.h deleted file mode 100644 index a890ce50..00000000 --- a/regamedll/extra/cssdk/common/kbutton.h +++ /dev/null @@ -1,44 +0,0 @@ -/* -* -* This program is free software; you can redistribute it and/or modify it -* under the terms of the GNU General Public License as published by the -* Free Software Foundation; either version 2 of the License, or (at -* your option) any later version. -* -* This program 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 -* General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* -*/ - -#ifndef KBUTTON_H -#define KBUTTON_H -#ifdef _WIN32 -#pragma once -#endif - - -/* <31b2a> ../common/kbutton.h:7 */ -typedef struct kbutton_s -{ - int down[2]; - int state; -} kbutton_t; - - -#endif // KBUTTON_H diff --git a/regamedll/extra/cssdk/common/mathlib.h b/regamedll/extra/cssdk/common/mathlib.h deleted file mode 100644 index d1dbdc9e..00000000 --- a/regamedll/extra/cssdk/common/mathlib.h +++ /dev/null @@ -1,127 +0,0 @@ -/* -* -* This program is free software; you can redistribute it and/or modify it -* under the terms of the GNU General Public License as published by the -* Free Software Foundation; either version 2 of the License, or (at -* your option) any later version. -* -* This program 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 -* General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* -*/ - -#pragma once - -#ifdef PLAY_GAMEDLL - -// probably gamedll compiled with flag /fpmath:fasted, -// so we need to use type double, otherwise will be the test failed - -typedef double float_precision; - -#else - -typedef float float_precision; - -#endif // PLAY_GAMEDLL - -typedef float vec_t; -typedef vec_t vec3_t[3]; -typedef vec_t vec4_t[4]; -typedef int fixed16_t; - -typedef union DLONG_u -{ - int i[2]; - double d; - float f; -} DLONG; - -#define M_PI 3.14159265358979323846 - -#ifdef __cplusplus -#ifdef min -#undef min -#endif - -#ifdef max -#undef max -#endif - -#ifdef clamp -#undef clamp -#endif - -template -const T& min(const T& a, const T& b) { return (a < b) ? a : b; } - -template -const T& max(const T& a, const T& b) { return (a > b) ? a : b; } - -template -const T& clamp(const T& a, const T& min, const T& max) { return (a > max) ? max : (a < min) ? min : a; } - -#else // __cplusplus - -#ifndef max -#define max(a,b) (((a) > (b)) ? (a) : (b)) -#endif - -#ifndef min -#define min(a,b) (((a) < (b)) ? (a) : (b)) -#endif - -#define clamp(val, min, max) (((val) > (max)) ? (max) : (((val) < (min)) ? (min) : (val))) -#endif // __cplusplus - -// bitwise operators templates -template::type> -inline T operator~ (T a) { return (T)~(type)a; } -template::type> -inline T operator| (T a, T b) { return (T)((type)a | (type)b); } -template::type> -inline T operator& (T a, T b) { return (T)((type)a & (type)b); } -template::type> -inline T operator^ (T a, T b) { return (T)((type)a ^ (type)b); } -template::type> -inline T& operator|= (T& a, T b) { return (T&)((type&)a |= (type)b); } -template::type> -inline T& operator&= (T& a, T b) { return (T&)((type&)a &= (type)b); } -template::type> -inline T& operator^= (T& a, T b) { return (T&)((type&)a ^= (type)b); } - -inline double M_sqrt(int value) { - return sqrt(value); -} - -inline float M_sqrt(float value) { - return _mm_cvtss_f32(_mm_sqrt_ss(_mm_load_ss(&value))); -} - -inline double M_sqrt(double value) { - double ret; - auto v = _mm_load_sd(&value); - _mm_store_sd(&ret, _mm_sqrt_sd(v, v)); - return ret; -} - -#define VectorSubtract(a,b,c) {(c)[0]=(a)[0]-(b)[0];(c)[1]=(a)[1]-(b)[1];(c)[2]=(a)[2]-(b)[2];} -#define VectorAdd(a,b,c) {(c)[0]=(a)[0]+(b)[0];(c)[1]=(a)[1]+(b)[1];(c)[2]=(a)[2]+(b)[2];} -#define VectorCopy(a,b) {(b)[0]=(a)[0];(b)[1]=(a)[1];(b)[2]=(a)[2];} -#define VectorClear(a) {(a)[0]=0.0;(a)[1]=0.0;(a)[2]=0.0;} diff --git a/regamedll/extra/cssdk/common/net_api.h b/regamedll/extra/cssdk/common/net_api.h deleted file mode 100644 index 9551d189..00000000 --- a/regamedll/extra/cssdk/common/net_api.h +++ /dev/null @@ -1,99 +0,0 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ -// -// Purpose: -// -// $NoKeywords: $ -//============================================================================= - -#if !defined( NET_APIH ) -#define NET_APIH -#ifdef _WIN32 -#pragma once -#endif - -#if !defined ( NETADRH ) -#include "netadr.h" -#endif - -#define NETAPI_REQUEST_SERVERLIST ( 0 ) // Doesn't need a remote address -#define NETAPI_REQUEST_PING ( 1 ) -#define NETAPI_REQUEST_RULES ( 2 ) -#define NETAPI_REQUEST_PLAYERS ( 3 ) -#define NETAPI_REQUEST_DETAILS ( 4 ) - -// Set this flag for things like broadcast requests, etc. where the engine should not -// kill the request hook after receiving the first response -#define FNETAPI_MULTIPLE_RESPONSE ( 1<<0 ) - -typedef void ( *net_api_response_func_t ) ( struct net_response_s *response ); - -#define NET_SUCCESS ( 0 ) -#define NET_ERROR_TIMEOUT ( 1<<0 ) -#define NET_ERROR_PROTO_UNSUPPORTED ( 1<<1 ) -#define NET_ERROR_UNDEFINED ( 1<<2 ) - -typedef struct net_adrlist_s -{ - struct net_adrlist_s *next; - netadr_t remote_address; -} net_adrlist_t; - -typedef struct net_response_s -{ - // NET_SUCCESS or an error code - int error; - - // Context ID - int context; - // Type - int type; - - // Server that is responding to the request - netadr_t remote_address; - - // Response RTT ping time - double ping; - // Key/Value pair string ( separated by backlash \ characters ) - // WARNING: You must copy this buffer in the callback function, because it is freed - // by the engine right after the call!!!! - // ALSO: For NETAPI_REQUEST_SERVERLIST requests, this will be a pointer to a linked list of net_adrlist_t's - void *response; -} net_response_t; - -typedef struct net_status_s -{ - // Connected to remote server? 1 == yes, 0 otherwise - int connected; - // Client's IP address - netadr_t local_address; - // Address of remote server - netadr_t remote_address; - // Packet Loss ( as a percentage ) - int packet_loss; - // Latency, in seconds ( multiply by 1000.0 to get milliseconds ) - double latency; - // Connection time, in seconds - double connection_time; - // Rate setting ( for incoming data ) - double rate; -} net_status_t; - -typedef struct net_api_s -{ - // APIs - void ( *InitNetworking )( void ); - void ( *Status ) ( struct net_status_s *status ); - void ( *SendRequest) ( int context, int request, int flags, double timeout, struct netadr_s *remote_address, net_api_response_func_t response ); - void ( *CancelRequest ) ( int context ); - void ( *CancelAllRequests ) ( void ); - char *( *AdrToString ) ( struct netadr_s *a ); - int ( *CompareAdr ) ( struct netadr_s *a, struct netadr_s *b ); - int ( *StringToAdr ) ( char *s, struct netadr_s *a ); - const char *( *ValueForKey ) ( const char *s, const char *key ); - void ( *RemoveKey ) ( char *s, const char *key ); - void ( *SetValueForKey ) (char *s, const char *key, const char *value, int maxsize ); -} net_api_t; - -extern net_api_t netapi; - -#endif // NET_APIH diff --git a/regamedll/extra/cssdk/common/netadr.h b/regamedll/extra/cssdk/common/netadr.h deleted file mode 100644 index 304073cf..00000000 --- a/regamedll/extra/cssdk/common/netadr.h +++ /dev/null @@ -1,40 +0,0 @@ -/*** -* -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ -// netadr.h -#ifndef NETADR_H -#define NETADR_H -#ifdef _WIN32 -#pragma once -#endif - -typedef enum -{ - NA_UNUSED, - NA_LOOPBACK, - NA_BROADCAST, - NA_IP, - NA_IPX, - NA_BROADCAST_IPX, -} netadrtype_t; - -typedef struct netadr_s -{ - netadrtype_t type; - unsigned char ip[4]; - unsigned char ipx[10]; - unsigned short port; -} netadr_t; - -#endif // NETADR_H diff --git a/regamedll/extra/cssdk/common/nowin.h b/regamedll/extra/cssdk/common/nowin.h deleted file mode 100644 index 0b1f5776..00000000 --- a/regamedll/extra/cssdk/common/nowin.h +++ /dev/null @@ -1,16 +0,0 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ -// -// Purpose: -// -// $NoKeywords: $ -//============================================================================= - -#ifndef INC_NOWIN_H -#define INC_NOWIN_H -#ifndef _WIN32 - -#include -#include - -#endif //!_WIN32 -#endif //INC_NOWIN_H diff --git a/regamedll/extra/cssdk/common/parsemsg.cpp b/regamedll/extra/cssdk/common/parsemsg.cpp deleted file mode 100644 index 6742db21..00000000 --- a/regamedll/extra/cssdk/common/parsemsg.cpp +++ /dev/null @@ -1,259 +0,0 @@ -/*** -* -* Copyright (c) 1999, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ -// -// parsemsg.cpp -// -//-------------------------------------------------------------------------------------------------------------- -#include "parsemsg.h" -#include - -typedef unsigned char byte; -#define true 1 - -static byte *gpBuf; -static int giSize; -static int giRead; -static int giBadRead; - -int READ_OK( void ) -{ - return !giBadRead; -} - -void BEGIN_READ( void *buf, int size ) -{ - giRead = 0; - giBadRead = 0; - giSize = size; - gpBuf = (byte*)buf; -} - - -int READ_CHAR( void ) -{ - int c; - - if (giRead + 1 > giSize) - { - giBadRead = true; - return -1; - } - - c = (signed char)gpBuf[giRead]; - giRead++; - - return c; -} - -int READ_BYTE( void ) -{ - int c; - - if (giRead+1 > giSize) - { - giBadRead = true; - return -1; - } - - c = (unsigned char)gpBuf[giRead]; - giRead++; - - return c; -} - -int READ_SHORT( void ) -{ - int c; - - if (giRead+2 > giSize) - { - giBadRead = true; - return -1; - } - - c = (short)( gpBuf[giRead] + ( gpBuf[giRead+1] << 8 ) ); - - giRead += 2; - - return c; -} - -int READ_WORD( void ) -{ - return READ_SHORT(); -} - - -int READ_LONG( void ) -{ - int c; - - if (giRead+4 > giSize) - { - giBadRead = true; - return -1; - } - - c = gpBuf[giRead] + (gpBuf[giRead + 1] << 8) + (gpBuf[giRead + 2] << 16) + (gpBuf[giRead + 3] << 24); - - giRead += 4; - - return c; -} - -float READ_FLOAT( void ) -{ - union - { - byte b[4]; - float f; - int l; - } dat; - - dat.b[0] = gpBuf[giRead]; - dat.b[1] = gpBuf[giRead+1]; - dat.b[2] = gpBuf[giRead+2]; - dat.b[3] = gpBuf[giRead+3]; - giRead += 4; - -// dat.l = LittleLong (dat.l); - - return dat.f; -} - -char* READ_STRING( void ) -{ - static char string[2048]; - int l,c; - - string[0] = 0; - - l = 0; - do - { - if ( giRead+1 > giSize ) - break; // no more characters - - c = READ_CHAR(); - if (c == -1 || c == 0) - break; - string[l] = c; - l++; - } while (l < sizeof(string)-1); - - string[l] = 0; - - return string; -} - -float READ_COORD( void ) -{ - return (float)(READ_SHORT() * (1.0/8)); -} - -float READ_ANGLE( void ) -{ - return (float)(READ_CHAR() * (360.0/256)); -} - -float READ_HIRESANGLE( void ) -{ - return (float)(READ_SHORT() * (360.0/65536)); -} - -//-------------------------------------------------------------------------------------------------------------- -BufferWriter::BufferWriter() -{ - Init( NULL, 0 ); -} - -//-------------------------------------------------------------------------------------------------------------- -BufferWriter::BufferWriter( unsigned char *buffer, int bufferLen ) -{ - Init( buffer, bufferLen ); -} - -//-------------------------------------------------------------------------------------------------------------- -void BufferWriter::Init( unsigned char *buffer, int bufferLen ) -{ - m_overflow = false; - m_buffer = buffer; - m_remaining = bufferLen; - m_overallLength = bufferLen; -} - -//-------------------------------------------------------------------------------------------------------------- -void BufferWriter::WriteByte( unsigned char data ) -{ - if (!m_buffer || !m_remaining) - { - m_overflow = true; - return; - } - - *m_buffer = data; - ++m_buffer; - --m_remaining; -} - -//-------------------------------------------------------------------------------------------------------------- -void BufferWriter::WriteLong( int data ) -{ - if (!m_buffer || m_remaining < 4) - { - m_overflow = true; - return; - } - - m_buffer[0] = data&0xff; - m_buffer[1] = (data>>8)&0xff; - m_buffer[2] = (data>>16)&0xff; - m_buffer[3] = data>>24; - m_buffer += 4; - m_remaining -= 4; -} - -//-------------------------------------------------------------------------------------------------------------- -void BufferWriter::WriteString( const char *str ) -{ - if (!m_buffer || !m_remaining) - { - m_overflow = true; - return; - } - - if (!str) - str = ""; - - int len = strlen(str)+1; - if ( len > m_remaining ) - { - m_overflow = true; - str = ""; - len = 1; - } - - strcpy((char *)m_buffer, str); - m_remaining -= len; - m_buffer += len; -} - -//-------------------------------------------------------------------------------------------------------------- -int BufferWriter::GetSpaceUsed() -{ - return m_overallLength - m_remaining; -} - -//-------------------------------------------------------------------------------------------------------------- diff --git a/regamedll/extra/cssdk/common/parsemsg.h b/regamedll/extra/cssdk/common/parsemsg.h deleted file mode 100644 index be7affce..00000000 --- a/regamedll/extra/cssdk/common/parsemsg.h +++ /dev/null @@ -1,66 +0,0 @@ -/*** -* -* Copyright (c) 1999, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ -// -// parsemsg.h -// MDC - copying from cstrike\cl_dll so career-mode stuff can catch messages -// in this dll. (and C++ifying it) -// - -#ifndef PARSEMSG_H -#define PARSEMSG_H - -#define ASSERT( x ) -//-------------------------------------------------------------------------------------------------------------- -void BEGIN_READ( void *buf, int size ); -int READ_CHAR( void ); -int READ_BYTE( void ); -int READ_SHORT( void ); -int READ_WORD( void ); -int READ_LONG( void ); -float READ_FLOAT( void ); -char* READ_STRING( void ); -float READ_COORD( void ); -float READ_ANGLE( void ); -float READ_HIRESANGLE( void ); -int READ_OK( void ); - -//-------------------------------------------------------------------------------------------------------------- -class BufferWriter -{ -public: - BufferWriter(); - BufferWriter( unsigned char *buffer, int bufferLen ); - void Init( unsigned char *buffer, int bufferLen ); - - void WriteByte( unsigned char data ); - void WriteLong( int data ); - void WriteString( const char *str ); - - bool HasOverflowed(); - int GetSpaceUsed(); - -protected: - unsigned char *m_buffer; - int m_remaining; - bool m_overflow; - int m_overallLength; -}; - -//-------------------------------------------------------------------------------------------------------------- - -#endif // PARSEMSG_H - - - diff --git a/regamedll/extra/cssdk/common/particledef.h b/regamedll/extra/cssdk/common/particledef.h deleted file mode 100644 index 7e4043af..00000000 --- a/regamedll/extra/cssdk/common/particledef.h +++ /dev/null @@ -1,57 +0,0 @@ -/*** -* -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ -#if !defined( PARTICLEDEFH ) -#define PARTICLEDEFH -#ifdef _WIN32 -#pragma once -#endif - -typedef enum { - pt_static, - pt_grav, - pt_slowgrav, - pt_fire, - pt_explode, - pt_explode2, - pt_blob, - pt_blob2, - pt_vox_slowgrav, - pt_vox_grav, - pt_clientcustom // Must have callback function specified -} ptype_t; - -// !!! if this is changed, it must be changed in d_ifacea.h too !!! -typedef struct particle_s -{ -// driver-usable fields - vec3_t org; - short color; - short packedColor; -// drivers never touch the following fields - struct particle_s *next; - vec3_t vel; - float ramp; - float die; - ptype_t type; - void (*deathfunc)( struct particle_s *particle ); - - // for pt_clientcusttom, we'll call this function each frame - void (*callback)( struct particle_s *particle, float frametime ); - - // For deathfunc, etc. - unsigned char context; -} particle_t; - -#endif diff --git a/regamedll/extra/cssdk/common/pmtrace.h b/regamedll/extra/cssdk/common/pmtrace.h deleted file mode 100644 index 1784e9c4..00000000 --- a/regamedll/extra/cssdk/common/pmtrace.h +++ /dev/null @@ -1,43 +0,0 @@ -/*** -* -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ -#if !defined( PMTRACEH ) -#define PMTRACEH -#ifdef _WIN32 -#pragma once -#endif - -typedef struct -{ - vec3_t normal; - float dist; -} pmplane_t; - -typedef struct pmtrace_s pmtrace_t; - -struct pmtrace_s -{ - qboolean allsolid; // if true, plane is not valid - qboolean startsolid; // if true, the initial point was in a solid area - qboolean inopen, inwater; // End point is in empty space or in water - float fraction; // time completed, 1.0 = didn't hit anything - vec3_t endpos; // final position - pmplane_t plane; // surface normal at impact - int ent; // entity at impact - vec3_t deltavelocity; // Change in player's velocity caused by impact. - // Only run on server. - int hitgroup; -}; - -#endif diff --git a/regamedll/extra/cssdk/common/port.h b/regamedll/extra/cssdk/common/port.h deleted file mode 100644 index a0838a7f..00000000 --- a/regamedll/extra/cssdk/common/port.h +++ /dev/null @@ -1,119 +0,0 @@ -// port.h: portability helper -// -////////////////////////////////////////////////////////////////////// - -#pragma once - -#include "archtypes.h" // DAL - -#ifdef _WIN32 - - // Insert your headers here - #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers - #define WIN32_EXTRA_LEAN - - #include "winsani_in.h" - #include - #include "winsani_out.h" - - #include - #include - #include - -#else // _WIN32 - - #include - #include - #include // exit() - #include // strncpy() - #include // tolower() - #include - #include - #include - #include - - typedef unsigned char BYTE; - - typedef int32 LONG; - //typedef uint32 ULONG; - - #ifndef ARCHTYPES_H - typedef uint32 ULONG; - #endif - - typedef void *HANDLE; - - #ifndef HMODULE - typedef void *HMODULE; - #endif - - typedef char * LPSTR; - - #define __cdecl - - - #ifdef __linux__ - typedef struct POINT_s - { - int x; - int y; - } POINT; - typedef void *HINSTANCE; - typedef void *HWND; - typedef void *HDC; - typedef void *HGLRC; - - typedef struct RECT_s - { - int left; - int right; - int top; - int bottom; - } RECT; - #endif - - - #ifdef __cplusplus - - //#undef FALSE - //#undef TRUE - - #ifdef OSX - //#else - //const bool FALSE = false; - //const bool TRUE = true; - #endif - #endif - - #ifndef NULL - #ifdef __cplusplus - #define NULL 0 - #else - #define NULL ((void *)0) - #endif - #endif - - #ifdef __cplusplus - inline int ioctlsocket( int d, int cmd, uint32 *argp ) { return ioctl( d, cmd, argp ); } - inline int closesocket( int fd ) { return close( fd ); } - inline char * GetCurrentDirectory( size_t size, char * buf ) { return getcwd( buf, size ); } - inline int WSAGetLastError() { return errno; } - - inline void DebugBreak( void ) { exit( 1 ); } - #endif - - extern char g_szEXEName[ 4096 ]; - - #define _snprintf snprintf - - #if defined(OSX) - #define SO_ARCH_SUFFIX ".dylib" - #else - #if defined ( __x86_64__ ) - #define SO_ARCH_SUFFIX "_amd64.so" - #else - #define SO_ARCH_SUFFIX ".so" - #endif - #endif -#endif - diff --git a/regamedll/extra/cssdk/common/qfont.h b/regamedll/extra/cssdk/common/qfont.h deleted file mode 100644 index 2fc81295..00000000 --- a/regamedll/extra/cssdk/common/qfont.h +++ /dev/null @@ -1,41 +0,0 @@ -/*** -* -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ -#if !defined( QFONTH ) -#define QFONTH -#ifdef _WIN32 -#pragma once -#endif - -// Font stuff - -#define NUM_GLYPHS 256 -// does not exist: // #include "basetypes.h" - -typedef struct -{ - short startoffset; - short charwidth; -} charinfo; - -typedef struct qfont_s -{ - int width, height; - int rowcount; - int rowheight; - charinfo fontinfo[ NUM_GLYPHS ]; - unsigned char data[4]; -} qfont_t; - -#endif // qfont.h diff --git a/regamedll/extra/cssdk/common/qlimits.h b/regamedll/extra/cssdk/common/qlimits.h deleted file mode 100644 index 3fad4036..00000000 --- a/regamedll/extra/cssdk/common/qlimits.h +++ /dev/null @@ -1,39 +0,0 @@ -//========= Copyright (c) 1996-2002, Valve LLC, All rights reserved. ========== -// -// Purpose: -// -// $NoKeywords: $ -//============================================================================= - -#ifndef QLIMITS_H -#define QLIMITS_H - -#if defined( _WIN32 ) -#pragma once -#endif - -// DATA STRUCTURE INFO - -#define MAX_NUM_ARGVS 50 - -// SYSTEM INFO -#define MAX_QPATH 64 // max length of a game pathname -#define MAX_OSPATH 260 // max length of a filesystem pathname - -#define ON_EPSILON 0.1 // point on plane side epsilon - -#define MAX_LIGHTSTYLE_INDEX_BITS 6 -#define MAX_LIGHTSTYLES (1< ../common/quakedef.h:29 */ -typedef int BOOL; /* size: 4 */ - -// user message -#define MAX_USER_MSG_DATA 192 - -/* <627f> ../common/quakedef.h:137 */ -//moved to com_model.h -//typedef struct cache_user_s -//{ -// void *data; -//} cache_user_t; - -/* <4313b> ../common/quakedef.h:162 */ -typedef int (*pfnUserMsgHook)(const char *, int, void *); diff --git a/regamedll/extra/cssdk/common/r_efx.h b/regamedll/extra/cssdk/common/r_efx.h deleted file mode 100644 index 4f7b806a..00000000 --- a/regamedll/extra/cssdk/common/r_efx.h +++ /dev/null @@ -1,197 +0,0 @@ -/*** -* -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ -#if !defined ( R_EFXH ) -#define R_EFXH -#ifdef _WIN32 -#pragma once -#endif - -// particle_t -#if !defined( PARTICLEDEFH ) -#include "particledef.h" -#endif - -// BEAM -#if !defined( BEAMDEFH ) -#include "beamdef.h" -#endif - -// dlight_t -#if !defined ( DLIGHTH ) -#include "dlight.h" -#endif - -// cl_entity_t -#if !defined( CL_ENTITYH ) -#include "cl_entity.h" -#endif - -/* -// FOR REFERENCE, These are the built-in tracer colors. Note, color 4 is the one -// that uses the tracerred/tracergreen/tracerblue and traceralpha cvar settings -color24 gTracerColors[] = -{ - { 255, 255, 255 }, // White - { 255, 0, 0 }, // Red - { 0, 255, 0 }, // Green - { 0, 0, 255 }, // Blue - { 0, 0, 0 }, // Tracer default, filled in from cvars, etc. - { 255, 167, 17 }, // Yellow-orange sparks - { 255, 130, 90 }, // Yellowish streaks (garg) - { 55, 60, 144 }, // Blue egon streak - { 255, 130, 90 }, // More Yellowish streaks (garg) - { 255, 140, 90 }, // More Yellowish streaks (garg) - { 200, 130, 90 }, // More red streaks (garg) - { 255, 120, 70 }, // Darker red streaks (garg) -}; -*/ - -// Temporary entity array -#define TENTPRIORITY_LOW 0 -#define TENTPRIORITY_HIGH 1 - -// TEMPENTITY flags -#define FTENT_NONE 0x00000000 -#define FTENT_SINEWAVE 0x00000001 -#define FTENT_GRAVITY 0x00000002 -#define FTENT_ROTATE 0x00000004 -#define FTENT_SLOWGRAVITY 0x00000008 -#define FTENT_SMOKETRAIL 0x00000010 -#define FTENT_COLLIDEWORLD 0x00000020 -#define FTENT_FLICKER 0x00000040 -#define FTENT_FADEOUT 0x00000080 -#define FTENT_SPRANIMATE 0x00000100 -#define FTENT_HITSOUND 0x00000200 -#define FTENT_SPIRAL 0x00000400 -#define FTENT_SPRCYCLE 0x00000800 -#define FTENT_COLLIDEALL 0x00001000 // will collide with world and slideboxes -#define FTENT_PERSIST 0x00002000 // tent is not removed when unable to draw -#define FTENT_COLLIDEKILL 0x00004000 // tent is removed upon collision with anything -#define FTENT_PLYRATTACHMENT 0x00008000 // tent is attached to a player (owner) -#define FTENT_SPRANIMATELOOP 0x00010000 // animating sprite doesn't die when last frame is displayed -#define FTENT_SPARKSHOWER 0x00020000 -#define FTENT_NOMODEL 0x00040000 // Doesn't have a model, never try to draw ( it just triggers other things ) -#define FTENT_CLIENTCUSTOM 0x00080000 // Must specify callback. Callback function is responsible for killing tempent and updating fields ( unless other flags specify how to do things ) - -typedef struct tempent_s -{ - int flags; - float die; - float frameMax; - float x; - float y; - float z; - float fadeSpeed; - float bounceFactor; - int hitSound; - void ( *hitcallback ) ( struct tempent_s *ent, struct pmtrace_s *ptr ); - void ( *callback ) ( struct tempent_s *ent, float frametime, float currenttime ); - struct tempent_s *next; - int priority; - short clientIndex; // if attached, this is the index of the client to stick to - // if COLLIDEALL, this is the index of the client to ignore - // TENTS with FTENT_PLYRATTACHMENT MUST set the clientindex! - - vec3_t tentOffset; // if attached, client origin + tentOffset = tent origin. - cl_entity_t entity; - - // baseline.origin - velocity - // baseline.renderamt - starting fadeout intensity - // baseline.angles - angle velocity -} TEMPENTITY; - -typedef struct efx_api_s efx_api_t; - -struct efx_api_s -{ - particle_t *( *R_AllocParticle ) ( void ( *callback ) ( struct particle_s *particle, float frametime ) ); - void ( *R_BlobExplosion ) ( float * org ); - void ( *R_Blood ) ( float * org, float * dir, int pcolor, int speed ); - void ( *R_BloodSprite ) ( float * org, int colorindex, int modelIndex, int modelIndex2, float size ); - void ( *R_BloodStream ) ( float * org, float * dir, int pcolor, int speed ); - void ( *R_BreakModel ) ( float *pos, float *size, float *dir, float random, float life, int count, int modelIndex, char flags ); - void ( *R_Bubbles ) ( float * mins, float * maxs, float height, int modelIndex, int count, float speed ); - void ( *R_BubbleTrail ) ( float * start, float * end, float height, int modelIndex, int count, float speed ); - void ( *R_BulletImpactParticles ) ( float * pos ); - void ( *R_EntityParticles ) ( struct cl_entity_s *ent ); - void ( *R_Explosion ) ( float *pos, int model, float scale, float framerate, int flags ); - void ( *R_FizzEffect ) ( struct cl_entity_s *pent, int modelIndex, int density ); - void ( *R_FireField ) ( float * org, int radius, int modelIndex, int count, int flags, float life ); - void ( *R_FlickerParticles ) ( float * org ); - void ( *R_FunnelSprite ) ( float *org, int modelIndex, int reverse ); - void ( *R_Implosion ) ( float * end, float radius, int count, float life ); - void ( *R_LargeFunnel ) ( float * org, int reverse ); - void ( *R_LavaSplash ) ( float * org ); - void ( *R_MultiGunshot ) ( float * org, float * dir, float * noise, int count, int decalCount, int *decalIndices ); - void ( *R_MuzzleFlash ) ( float *pos1, int type ); - void ( *R_ParticleBox ) ( float *mins, float *maxs, unsigned char r, unsigned char g, unsigned char b, float life ); - void ( *R_ParticleBurst ) ( float * pos, int size, int color, float life ); - void ( *R_ParticleExplosion ) ( float * org ); - void ( *R_ParticleExplosion2 ) ( float * org, int colorStart, int colorLength ); - void ( *R_ParticleLine ) ( float * start, float *end, unsigned char r, unsigned char g, unsigned char b, float life ); - void ( *R_PlayerSprites ) ( int client, int modelIndex, int count, int size ); - void ( *R_Projectile ) ( float * origin, float * velocity, int modelIndex, int life, int owner, void (*hitcallback)( struct tempent_s *ent, struct pmtrace_s *ptr ) ); - void ( *R_RicochetSound ) ( float * pos ); - void ( *R_RicochetSprite ) ( float *pos, struct model_s *pmodel, float duration, float scale ); - void ( *R_RocketFlare ) ( float *pos ); - void ( *R_RocketTrail ) ( float * start, float * end, int type ); - void ( *R_RunParticleEffect ) ( float * org, float * dir, int color, int count ); - void ( *R_ShowLine ) ( float * start, float * end ); - void ( *R_SparkEffect ) ( float *pos, int count, int velocityMin, int velocityMax ); - void ( *R_SparkShower ) ( float *pos ); - void ( *R_SparkStreaks ) ( float * pos, int count, int velocityMin, int velocityMax ); - void ( *R_Spray ) ( float * pos, float * dir, int modelIndex, int count, int speed, int spread, int rendermode ); - void ( *R_Sprite_Explode ) ( TEMPENTITY *pTemp, float scale, int flags ); - void ( *R_Sprite_Smoke ) ( TEMPENTITY *pTemp, float scale ); - void ( *R_Sprite_Spray ) ( float * pos, float * dir, int modelIndex, int count, int speed, int iRand ); - void ( *R_Sprite_Trail ) ( int type, float * start, float * end, int modelIndex, int count, float life, float size, float amplitude, int renderamt, float speed ); - void ( *R_Sprite_WallPuff ) ( TEMPENTITY *pTemp, float scale ); - void ( *R_StreakSplash ) ( float * pos, float * dir, int color, int count, float speed, int velocityMin, int velocityMax ); - void ( *R_TracerEffect ) ( float * start, float * end ); - void ( *R_UserTracerParticle ) ( float * org, float * vel, float life, int colorIndex, float length, unsigned char deathcontext, void ( *deathfunc)( struct particle_s *particle ) ); - particle_t *( *R_TracerParticles ) ( float * org, float * vel, float life ); - void ( *R_TeleportSplash ) ( float * org ); - void ( *R_TempSphereModel ) ( float *pos, float speed, float life, int count, int modelIndex ); - TEMPENTITY *( *R_TempModel ) ( float *pos, float *dir, float *angles, float life, int modelIndex, int soundtype ); - TEMPENTITY *( *R_DefaultSprite ) ( float *pos, int spriteIndex, float framerate ); - TEMPENTITY *( *R_TempSprite ) ( float *pos, float *dir, float scale, int modelIndex, int rendermode, int renderfx, float a, float life, int flags ); - int ( *Draw_DecalIndex ) ( int id ); - int ( *Draw_DecalIndexFromName ) ( char *name ); - void ( *R_DecalShoot ) ( int textureIndex, int entity, int modelIndex, float * position, int flags ); - void ( *R_AttachTentToPlayer ) ( int client, int modelIndex, float zoffset, float life ); - void ( *R_KillAttachedTents ) ( int client ); - BEAM *( *R_BeamCirclePoints ) ( int type, float * start, float * end, int modelIndex, float life, float width, float amplitude, float brightness, float speed, int startFrame, float framerate, float r, float g, float b ); - BEAM *( *R_BeamEntPoint ) ( int startEnt, float * end, int modelIndex, float life, float width, float amplitude, float brightness, float speed, int startFrame, float framerate, float r, float g, float b ); - BEAM *( *R_BeamEnts ) ( int startEnt, int endEnt, int modelIndex, float life, float width, float amplitude, float brightness, float speed, int startFrame, float framerate, float r, float g, float b ); - BEAM *( *R_BeamFollow ) ( int startEnt, int modelIndex, float life, float width, float r, float g, float b, float brightness ); - void ( *R_BeamKill ) ( int deadEntity ); - BEAM *( *R_BeamLightning ) ( float * start, float * end, int modelIndex, float life, float width, float amplitude, float brightness, float speed ); - BEAM *( *R_BeamPoints ) ( float * start, float * end, int modelIndex, float life, float width, float amplitude, float brightness, float speed, int startFrame, float framerate, float r, float g, float b ); - BEAM *( *R_BeamRing ) ( int startEnt, int endEnt, int modelIndex, float life, float width, float amplitude, float brightness, float speed, int startFrame, float framerate, float r, float g, float b ); - dlight_t *( *CL_AllocDlight ) ( int key ); - dlight_t *( *CL_AllocElight ) ( int key ); - TEMPENTITY *( *CL_TempEntAlloc ) ( float * org, struct model_s *model ); - TEMPENTITY *( *CL_TempEntAllocNoModel ) ( float * org ); - TEMPENTITY *( *CL_TempEntAllocHigh ) ( float * org, struct model_s *model ); - TEMPENTITY *( *CL_TentEntAllocCustom ) ( float *origin, struct model_s *model, int high, void ( *callback ) ( struct tempent_s *ent, float frametime, float currenttime ) ); - void ( *R_GetPackedColor ) ( short *packed, short color ); - short ( *R_LookupColor ) ( unsigned char r, unsigned char g, unsigned char b ); - void ( *R_DecalRemoveAll ) ( int textureIndex ); //textureIndex points to the decal index in the array, not the actual texture index. - void ( *R_FireCustomDecal ) ( int textureIndex, int entity, int modelIndex, float * position, int flags, float scale ); -}; - -extern efx_api_t efx; - -#endif diff --git a/regamedll/extra/cssdk/common/r_studioint.h b/regamedll/extra/cssdk/common/r_studioint.h deleted file mode 100644 index 2ddf012a..00000000 --- a/regamedll/extra/cssdk/common/r_studioint.h +++ /dev/null @@ -1,151 +0,0 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ -// -// Purpose: -// -// $NoKeywords: $ -//============================================================================= - -#if !defined( R_STUDIOINT_H ) -#define R_STUDIOINT_H -#if defined( _WIN32 ) -#pragma once -#endif - -#define STUDIO_INTERFACE_VERSION 1 - -typedef struct engine_studio_api_s -{ - // Allocate number*size bytes and zero it - void *( *Mem_Calloc ) ( int number, size_t size ); - // Check to see if pointer is in the cache - void *( *Cache_Check ) ( struct cache_user_s *c ); - // Load file into cache ( can be swapped out on demand ) - void ( *LoadCacheFile ) ( char *path, struct cache_user_s *cu ); - // Retrieve model pointer for the named model - struct model_s *( *Mod_ForName ) ( const char *name, int crash_if_missing ); - // Retrieve pointer to studio model data block from a model - void *( *Mod_Extradata ) ( struct model_s *mod ); - // Retrieve indexed model from client side model precache list - struct model_s *( *GetModelByIndex ) ( int index ); - // Get entity that is set for rendering - struct cl_entity_s * ( *GetCurrentEntity ) ( void ); - // Get referenced player_info_t - struct player_info_s *( *PlayerInfo ) ( int index ); - // Get most recently received player state data from network system - struct entity_state_s *( *GetPlayerState ) ( int index ); - // Get viewentity - struct cl_entity_s * ( *GetViewEntity ) ( void ); - // Get current frame count, and last two timestampes on client - void ( *GetTimes ) ( int *framecount, double *current, double *old ); - // Get a pointer to a cvar by name - struct cvar_s *( *GetCvar ) ( const char *name ); - // Get current render origin and view vectors ( up, right and vpn ) - void ( *GetViewInfo ) ( float *origin, float *upv, float *rightv, float *vpnv ); - // Get sprite model used for applying chrome effect - struct model_s *( *GetChromeSprite ) ( void ); - // Get model counters so we can incement instrumentation - void ( *GetModelCounters ) ( int **s, int **a ); - // Get software scaling coefficients - void ( *GetAliasScale ) ( float *x, float *y ); - - // Get bone, light, alias, and rotation matrices - float ****( *StudioGetBoneTransform ) ( void ); - float ****( *StudioGetLightTransform )( void ); - float ***( *StudioGetAliasTransform ) ( void ); - float ***( *StudioGetRotationMatrix ) ( void ); - - // Set up body part, and get submodel pointers - void ( *StudioSetupModel ) ( int bodypart, void **ppbodypart, void **ppsubmodel ); - // Check if entity's bbox is in the view frustum - int ( *StudioCheckBBox ) ( void ); - // Apply lighting effects to model - void ( *StudioDynamicLight ) ( struct cl_entity_s *ent, struct alight_s *plight ); - void ( *StudioEntityLight ) ( struct alight_s *plight ); - void ( *StudioSetupLighting ) ( struct alight_s *plighting ); - - // Draw mesh vertices - void ( *StudioDrawPoints ) ( void ); - - // Draw hulls around bones - void ( *StudioDrawHulls ) ( void ); - // Draw bbox around studio models - void ( *StudioDrawAbsBBox ) ( void ); - // Draws bones - void ( *StudioDrawBones ) ( void ); - // Loads in appropriate texture for model - void ( *StudioSetupSkin ) ( void *ptexturehdr, int index ); - // Sets up for remapped colors - void ( *StudioSetRemapColors ) ( int top, int bottom ); - // Set's player model and returns model pointer - struct model_s *( *SetupPlayerModel ) ( int index ); - // Fires any events embedded in animation - void ( *StudioClientEvents ) ( void ); - // Retrieve/set forced render effects flags - int ( *GetForceFaceFlags ) ( void ); - void ( *SetForceFaceFlags ) ( int flags ); - // Tell engine the value of the studio model header - void ( *StudioSetHeader ) ( void *header ); - // Tell engine which model_t * is being renderered - void ( *SetRenderModel ) ( struct model_s *model ); - - // Final state setup and restore for rendering - void ( *SetupRenderer ) ( int rendermode ); - void ( *RestoreRenderer ) ( void ); - - // Set render origin for applying chrome effect - void ( *SetChromeOrigin ) ( void ); - - // True if using D3D/OpenGL - int ( *IsHardware ) ( void ); - - // Only called by hardware interface - void ( *GL_StudioDrawShadow ) ( void ); - void ( *GL_SetRenderMode ) ( int mode ); - - void ( *StudioSetRenderamt ) (int iRenderamt); //!!!CZERO added for rendering glass on viewmodels - void ( *StudioSetCullState ) ( int iCull ); - void ( *StudioRenderShadow ) ( int iSprite, float *p1, float *p2, float *p3, float *p4 ); -} engine_studio_api_t; - -typedef struct server_studio_api_s -{ - // Allocate number*size bytes and zero it - void *( *Mem_Calloc ) ( int number, size_t size ); - // Check to see if pointer is in the cache - void *( *Cache_Check ) ( struct cache_user_s *c ); - // Load file into cache ( can be swapped out on demand ) - void ( *LoadCacheFile ) ( char *path, struct cache_user_s *cu ); - // Retrieve pointer to studio model data block from a model - void *( *Mod_Extradata ) ( struct model_s *mod ); -} server_studio_api_t; - - -// client blending -typedef struct r_studio_interface_s -{ - int version; - int ( *StudioDrawModel ) ( int flags ); - int ( *StudioDrawPlayer ) ( int flags, struct entity_state_s *pplayer ); -} r_studio_interface_t; - -extern r_studio_interface_t *pStudioAPI; - -// server blending -#define SV_BLENDING_INTERFACE_VERSION 1 - -typedef struct sv_blending_interface_s -{ - int version; - - void ( *SV_StudioSetupBones )( struct model_s *pModel, - float frame, - int sequence, - const vec3_t angles, - const vec3_t origin, - const byte *pcontroller, - const byte *pblending, - int iBone, - const edict_t *pEdict ); -} sv_blending_interface_t; - -#endif // R_STUDIOINT_H diff --git a/regamedll/extra/cssdk/common/ref_params.h b/regamedll/extra/cssdk/common/ref_params.h deleted file mode 100644 index 90eb03f3..00000000 --- a/regamedll/extra/cssdk/common/ref_params.h +++ /dev/null @@ -1,75 +0,0 @@ -/*** -* -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ -#if !defined( REF_PARAMSH ) -#define REF_PARAMSH - -typedef struct ref_params_s -{ - // Output - float vieworg[3]; - float viewangles[3]; - - float forward[3]; - float right[3]; - float up[3]; - - // Client frametime; - float frametime; - // Client time - float time; - - // Misc - int intermission; - int paused; - int spectator; - int onground; - int waterlevel; - - float simvel[3]; - float simorg[3]; - - float viewheight[3]; - float idealpitch; - - float cl_viewangles[3]; - - int health; - float crosshairangle[3]; - float viewsize; - - float punchangle[3]; - int maxclients; - int viewentity; - int playernum; - int max_entities; - int demoplayback; - int hardware; - - int smoothing; - - // Last issued usercmd - struct usercmd_s *cmd; - - // Movevars - struct movevars_s *movevars; - - int viewport[4]; // the viewport coordinates x ,y , width, height - - int nextView; // the renderer calls ClientDLL_CalcRefdef() and Renderview - // so long in cycles until this value is 0 (multiple views) - int onlyClientDraw; // if !=0 nothing is drawn by the engine except clientDraw functions -} ref_params_t; - -#endif // !REF_PARAMSH diff --git a/regamedll/extra/cssdk/common/screenfade.h b/regamedll/extra/cssdk/common/screenfade.h deleted file mode 100644 index 62c0d25a..00000000 --- a/regamedll/extra/cssdk/common/screenfade.h +++ /dev/null @@ -1,24 +0,0 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ -// -// Purpose: -// -// $NoKeywords: $ -//============================================================================= - -#if !defined( SCREENFADEH ) -#define SCREENFADEH -#ifdef _WIN32 -#pragma once -#endif - -typedef struct screenfade_s -{ - float fadeSpeed; // How fast to fade (tics / second) (+ fade in, - fade out) - float fadeEnd; // When the fading hits maximum - float fadeTotalEnd; // Total End Time of the fade (used for FFADE_OUT) - float fadeReset; // When to reset to not fading (for fadeout and hold) - byte fader, fadeg, fadeb, fadealpha; // Fade color - int fadeFlags; // Fading flags -} screenfade_t; - -#endif // !SCREENFADEH diff --git a/regamedll/extra/cssdk/common/studio_event.h b/regamedll/extra/cssdk/common/studio_event.h deleted file mode 100644 index c79c2100..00000000 --- a/regamedll/extra/cssdk/common/studio_event.h +++ /dev/null @@ -1,29 +0,0 @@ -/*** -* -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ -#if !defined( STUDIO_EVENTH ) -#define STUDIO_EVENTH -#ifdef _WIN32 -#pragma once -#endif - -typedef struct mstudioevent_s -{ - int frame; - int event; - int type; - char options[64]; -} mstudioevent_t; - -#endif // STUDIO_EVENTH diff --git a/regamedll/extra/cssdk/common/triangleapi.h b/regamedll/extra/cssdk/common/triangleapi.h deleted file mode 100644 index 069a4d65..00000000 --- a/regamedll/extra/cssdk/common/triangleapi.h +++ /dev/null @@ -1,64 +0,0 @@ -/*** -* -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ -#if !defined( TRIANGLEAPIH ) -#define TRIANGLEAPIH -#ifdef _WIN32 -#pragma once -#endif - -typedef enum -{ - TRI_FRONT = 0, - TRI_NONE = 1, -} TRICULLSTYLE; - -#define TRI_API_VERSION 1 - -#define TRI_TRIANGLES 0 -#define TRI_TRIANGLE_FAN 1 -#define TRI_QUADS 2 -#define TRI_POLYGON 3 -#define TRI_LINES 4 -#define TRI_TRIANGLE_STRIP 5 -#define TRI_QUAD_STRIP 6 - -typedef struct triangleapi_s -{ - int version; - - void ( *RenderMode )( int mode ); - void ( *Begin )( int primitiveCode ); - void ( *End ) ( void ); - - void ( *Color4f ) ( float r, float g, float b, float a ); - void ( *Color4ub ) ( unsigned char r, unsigned char g, unsigned char b, unsigned char a ); - void ( *TexCoord2f ) ( float u, float v ); - void ( *Vertex3fv ) ( float *worldPnt ); - void ( *Vertex3f ) ( float x, float y, float z ); - void ( *Brightness ) ( float brightness ); - void ( *CullFace ) ( TRICULLSTYLE style ); - int ( *SpriteTexture ) ( struct model_s *pSpriteModel, int frame ); - int ( *WorldToScreen ) ( float *world, float *screen ); // Returns 1 if it's z clipped - void ( *Fog ) ( float flFogColor[3], float flStart, float flEnd, int bOn ); // Works just like GL_FOG, flFogColor is r/g/b. - void ( *ScreenToWorld ) ( float *screen, float *world ); - void ( *GetMatrix ) ( const int pname, float *matrix ); - int ( *BoxInPVS ) ( float *mins, float *maxs ); - void ( *LightAtPoint ) ( float *pos, float *value ); - void ( *Color4fRendermode ) ( float r, float g, float b, float a, int rendermode ); - void ( *FogParams ) ( float flDensity, int iFogSkybox ); // Used with Fog()...sets fog density and whether the fog should be applied to the skybox - -} triangleapi_t; - -#endif // !TRIANGLEAPIH diff --git a/regamedll/extra/cssdk/common/usercmd.h b/regamedll/extra/cssdk/common/usercmd.h deleted file mode 100644 index 7cdcfe2d..00000000 --- a/regamedll/extra/cssdk/common/usercmd.h +++ /dev/null @@ -1,41 +0,0 @@ -/*** -* -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ -#ifndef USERCMD_H -#define USERCMD_H -#ifdef _WIN32 -#pragma once -#endif - -typedef struct usercmd_s -{ - short lerp_msec; // Interpolation time on client - byte msec; // Duration in ms of command - vec3_t viewangles; // Command view angles. - -// intended velocities - float forwardmove; // Forward velocity. - float sidemove; // Sideways velocity. - float upmove; // Upward velocity. - byte lightlevel; // Light level at spot where we are standing. - unsigned short buttons; // Attack buttons - byte impulse; // Impulse command issued. - byte weaponselect; // Current weapon id - -// Experimental player impact stuff. - int impact_index; - vec3_t impact_position; -} usercmd_t; - -#endif // USERCMD_H diff --git a/regamedll/extra/cssdk/common/vmodes.h b/regamedll/extra/cssdk/common/vmodes.h deleted file mode 100644 index 5d4384f5..00000000 --- a/regamedll/extra/cssdk/common/vmodes.h +++ /dev/null @@ -1,35 +0,0 @@ -/* -* -* This program is free software; you can redistribute it and/or modify it -* under the terms of the GNU General Public License as published by the -* Free Software Foundation; either version 2 of the License, or (at -* your option) any later version. -* -* This program 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 -* General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* -*/ -#pragma once - - -/* <430ee> ../common/vmodes.h:40 */ -typedef struct rect_s -{ - int left, right, top, bottom; -} wrect_t; diff --git a/regamedll/extra/cssdk/common/weaponinfo.h b/regamedll/extra/cssdk/common/weaponinfo.h deleted file mode 100644 index 251a0964..00000000 --- a/regamedll/extra/cssdk/common/weaponinfo.h +++ /dev/null @@ -1,53 +0,0 @@ -/*** -* -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ - -#ifndef WEAPONINFO_H -#define WEAPONINFO_H -#ifdef _WIN32 -#pragma once -#endif - -// Info about weapons player might have in his/her possession -typedef struct weapon_data_s -{ - int m_iId; - int m_iClip; - - float m_flNextPrimaryAttack; - float m_flNextSecondaryAttack; - float m_flTimeWeaponIdle; - - int m_fInReload; - int m_fInSpecialReload; - float m_flNextReload; - float m_flPumpTime; - float m_fReloadTime; - - float m_fAimedDamage; - float m_fNextAimBonus; - int m_fInZoom; - int m_iWeaponState; - - int iuser1; - int iuser2; - int iuser3; - int iuser4; - float fuser1; - float fuser2; - float fuser3; - float fuser4; -} weapon_data_t; - -#endif // WEAPONINFO_H diff --git a/regamedll/extra/cssdk/common/winsani_in.h b/regamedll/extra/cssdk/common/winsani_in.h deleted file mode 100644 index d8c85271..00000000 --- a/regamedll/extra/cssdk/common/winsani_in.h +++ /dev/null @@ -1,7 +0,0 @@ -#if _MSC_VER >= 1500 // MSVC++ 9.0 (Visual Studio 2008) -#pragma push_macro("ARRAYSIZE") -#ifdef ARRAYSIZE -#undef ARRAYSIZE -#endif -#define HSPRITE WINDOWS_HSPRITE -#endif diff --git a/regamedll/extra/cssdk/common/winsani_out.h b/regamedll/extra/cssdk/common/winsani_out.h deleted file mode 100644 index 27269500..00000000 --- a/regamedll/extra/cssdk/common/winsani_out.h +++ /dev/null @@ -1,4 +0,0 @@ -#if _MSC_VER >= 1500 // MSVC++ 9.0 (Visual Studio 2008) -#undef HSPRITE -#pragma pop_macro("ARRAYSIZE") -#endif diff --git a/regamedll/extra/cssdk/dlls/activity.h b/regamedll/extra/cssdk/dlls/activity.h deleted file mode 100644 index a34b76a6..00000000 --- a/regamedll/extra/cssdk/dlls/activity.h +++ /dev/null @@ -1,145 +0,0 @@ -/* -* -* This program is free software; you can redistribute it and/or modify it -* under the terms of the GNU General Public License as published by the -* Free Software Foundation; either version 2 of the License, or (at -* your option) any later version. -* -* This program 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 -* General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* -*/ -#pragma once - -typedef enum Activity_s -{ - ACT_INVALID = -1, - - ACT_RESET = 0, // Set m_Activity to this invalid value to force a reset to m_IdealActivity - ACT_IDLE, - ACT_GUARD, - ACT_WALK, - ACT_RUN, - ACT_FLY, - ACT_SWIM, - ACT_HOP, - ACT_LEAP, - ACT_FALL, - ACT_LAND, - ACT_STRAFE_LEFT, - ACT_STRAFE_RIGHT, - ACT_ROLL_LEFT, - ACT_ROLL_RIGHT, - ACT_TURN_LEFT, - ACT_TURN_RIGHT, - ACT_CROUCH, - ACT_CROUCHIDLE, - ACT_STAND, - ACT_USE, - ACT_SIGNAL1, - ACT_SIGNAL2, - ACT_SIGNAL3, - ACT_TWITCH, - ACT_COWER, - ACT_SMALL_FLINCH, - ACT_BIG_FLINCH, - ACT_RANGE_ATTACK1, - ACT_RANGE_ATTACK2, - ACT_MELEE_ATTACK1, - ACT_MELEE_ATTACK2, - ACT_RELOAD, - ACT_ARM, - ACT_DISARM, - ACT_EAT, - ACT_DIESIMPLE, - ACT_DIEBACKWARD, - ACT_DIEFORWARD, - ACT_DIEVIOLENT, - ACT_BARNACLE_HIT, - ACT_BARNACLE_PULL, - ACT_BARNACLE_CHOMP, - ACT_BARNACLE_CHEW, - ACT_SLEEP, - ACT_INSPECT_FLOOR, - ACT_INSPECT_WALL, - ACT_IDLE_ANGRY, - ACT_WALK_HURT, - ACT_RUN_HURT, - ACT_HOVER, - ACT_GLIDE, - ACT_FLY_LEFT, - ACT_FLY_RIGHT, - ACT_DETECT_SCENT, - ACT_SNIFF, - ACT_BITE, - ACT_THREAT_DISPLAY, - ACT_FEAR_DISPLAY, - ACT_EXCITED, - ACT_SPECIAL_ATTACK1, - ACT_SPECIAL_ATTACK2, - ACT_COMBAT_IDLE, - ACT_WALK_SCARED, - ACT_RUN_SCARED, - ACT_VICTORY_DANCE, - ACT_DIE_HEADSHOT, - ACT_DIE_CHESTSHOT, - ACT_DIE_GUTSHOT, - ACT_DIE_BACKSHOT, - ACT_FLINCH_HEAD, - ACT_FLINCH_CHEST, - ACT_FLINCH_STOMACH, - ACT_FLINCH_LEFTARM, - ACT_FLINCH_RIGHTARM, - ACT_FLINCH_LEFTLEG, - ACT_FLINCH_RIGHTLEG, - ACT_FLINCH, - ACT_LARGE_FLINCH, - ACT_HOLDBOMB, - ACT_IDLE_FIDGET, - ACT_IDLE_SCARED, - ACT_IDLE_SCARED_FIDGET, - ACT_FOLLOW_IDLE, - ACT_FOLLOW_IDLE_FIDGET, - ACT_FOLLOW_IDLE_SCARED, - ACT_FOLLOW_IDLE_SCARED_FIDGET, - ACT_CROUCH_IDLE, - ACT_CROUCH_IDLE_FIDGET, - ACT_CROUCH_IDLE_SCARED, - ACT_CROUCH_IDLE_SCARED_FIDGET, - ACT_CROUCH_WALK, - ACT_CROUCH_WALK_SCARED, - ACT_CROUCH_DIE, - ACT_WALK_BACK, - ACT_IDLE_SNEAKY, - ACT_IDLE_SNEAKY_FIDGET, - ACT_WALK_SNEAKY, - ACT_WAVE, - ACT_YES, - ACT_NO, - -} Activity; - -typedef struct -{ - int type; - char *name; - -} activity_map_t; - -extern activity_map_t activity_map[]; diff --git a/regamedll/extra/cssdk/dlls/activitymap.h b/regamedll/extra/cssdk/dlls/activitymap.h deleted file mode 100644 index cf5ddfc7..00000000 --- a/regamedll/extra/cssdk/dlls/activitymap.h +++ /dev/null @@ -1,111 +0,0 @@ -/* -* -* This program is free software; you can redistribute it and/or modify it -* under the terms of the GNU General Public License as published by the -* Free Software Foundation; either version 2 of the License, or (at -* your option) any later version. -* -* This program 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 -* General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* -*/ - -#define _A(a)\ - { a, #a } - -activity_map_t activity_map[] = -{ - _A(ACT_IDLE), - _A(ACT_GUARD), - _A(ACT_WALK), - _A(ACT_RUN), - _A(ACT_FLY), - _A(ACT_SWIM), - _A(ACT_HOP), - _A(ACT_LEAP), - _A(ACT_FALL), - _A(ACT_LAND), - _A(ACT_STRAFE_LEFT), - _A(ACT_STRAFE_RIGHT), - _A(ACT_ROLL_LEFT), - _A(ACT_ROLL_RIGHT), - _A(ACT_TURN_LEFT), - _A(ACT_TURN_RIGHT), - _A(ACT_CROUCH), - _A(ACT_CROUCHIDLE), - _A(ACT_STAND), - _A(ACT_USE), - _A(ACT_SIGNAL1), - _A(ACT_SIGNAL2), - _A(ACT_SIGNAL3), - _A(ACT_TWITCH), - _A(ACT_COWER), - _A(ACT_SMALL_FLINCH), - _A(ACT_BIG_FLINCH), - _A(ACT_RANGE_ATTACK1), - _A(ACT_RANGE_ATTACK2), - _A(ACT_MELEE_ATTACK1), - _A(ACT_MELEE_ATTACK2), - _A(ACT_RELOAD), - _A(ACT_ARM), - _A(ACT_DISARM), - _A(ACT_EAT), - _A(ACT_DIESIMPLE), - _A(ACT_DIEBACKWARD), - _A(ACT_DIEFORWARD), - _A(ACT_DIEVIOLENT), - _A(ACT_BARNACLE_HIT), - _A(ACT_BARNACLE_PULL), - _A(ACT_BARNACLE_CHOMP), - _A(ACT_BARNACLE_CHEW), - _A(ACT_SLEEP), - _A(ACT_INSPECT_FLOOR), - _A(ACT_INSPECT_WALL), - _A(ACT_IDLE_ANGRY), - _A(ACT_WALK_HURT), - _A(ACT_RUN_HURT), - _A(ACT_HOVER), - _A(ACT_GLIDE), - _A(ACT_FLY_LEFT), - _A(ACT_FLY_RIGHT), - _A(ACT_DETECT_SCENT), - _A(ACT_SNIFF), - _A(ACT_BITE), - _A(ACT_THREAT_DISPLAY), - _A(ACT_FEAR_DISPLAY), - _A(ACT_EXCITED), - _A(ACT_SPECIAL_ATTACK1), - _A(ACT_SPECIAL_ATTACK2), - _A(ACT_COMBAT_IDLE), - _A(ACT_WALK_SCARED), - _A(ACT_RUN_SCARED), - _A(ACT_VICTORY_DANCE), - _A(ACT_DIE_HEADSHOT), - _A(ACT_DIE_CHESTSHOT), - _A(ACT_DIE_GUTSHOT), - _A(ACT_DIE_BACKSHOT), - _A(ACT_FLINCH_HEAD), - _A(ACT_FLINCH_CHEST), - _A(ACT_FLINCH_STOMACH), - _A(ACT_FLINCH_LEFTARM), - _A(ACT_FLINCH_RIGHTARM), - _A(ACT_FLINCH_LEFTLEG), - _A(ACT_FLINCH_RIGHTLEG), - 0, NULL -}; diff --git a/regamedll/extra/cssdk/dlls/airtank.h b/regamedll/extra/cssdk/dlls/airtank.h deleted file mode 100644 index 3f435a86..00000000 --- a/regamedll/extra/cssdk/dlls/airtank.h +++ /dev/null @@ -1,42 +0,0 @@ -/* -* -* This program is free software; you can redistribute it and/or modify it -* under the terms of the GNU General Public License as published by the -* Free Software Foundation; either version 2 of the License, or (at -* your option) any later version. -* -* This program 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 -* General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* -*/ -#pragma once - -class CAirtank: public CGrenade { -public: - virtual void Spawn() = 0; - virtual void Precache() = 0; - virtual int Save(CSave &save) = 0; - virtual int Restore(CRestore &restore) = 0; - virtual void Killed(entvars_t *pevAttacker, int iGib) = 0; - virtual int BloodColor() = 0; - - int GetState() const { return m_state; } -private: - int m_state; -}; diff --git a/regamedll/extra/cssdk/dlls/ammo.h b/regamedll/extra/cssdk/dlls/ammo.h deleted file mode 100644 index 4b22b9e3..00000000 --- a/regamedll/extra/cssdk/dlls/ammo.h +++ /dev/null @@ -1,98 +0,0 @@ -/* -* -* This program is free software; you can redistribute it and/or modify it -* under the terms of the GNU General Public License as published by the -* Free Software Foundation; either version 2 of the License, or (at -* your option) any later version. -* -* This program 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 -* General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* -*/ -#pragma once - -class C9MMAmmo: public CBasePlayerAmmo { -public: - virtual void Spawn() = 0; - virtual void Precache() = 0; - virtual BOOL AddAmmo(CBaseEntity *pOther) = 0; -}; - -class CBuckShotAmmo: public CBasePlayerAmmo { -public: - virtual void Spawn() = 0; - virtual void Precache() = 0; - virtual BOOL AddAmmo(CBaseEntity *pOther) = 0; -}; - -class C556NatoAmmo: public CBasePlayerAmmo { -public: - virtual void Spawn() = 0; - virtual void Precache() = 0; - virtual BOOL AddAmmo(CBaseEntity *pOther) = 0; -}; - -class C556NatoBoxAmmo: public CBasePlayerAmmo { -public: - virtual void Spawn() = 0; - virtual void Precache() = 0; - virtual BOOL AddAmmo(CBaseEntity *pOther) = 0; -}; - -class C762NatoAmmo: public CBasePlayerAmmo { -public: - virtual void Spawn() = 0; - virtual void Precache() = 0; - virtual BOOL AddAmmo(CBaseEntity *pOther) = 0; -}; - -class C45ACPAmmo: public CBasePlayerAmmo { -public: - virtual void Spawn() = 0; - virtual void Precache() = 0; - virtual BOOL AddAmmo(CBaseEntity *pOther) = 0; -}; - -class C50AEAmmo: public CBasePlayerAmmo { -public: - virtual void Spawn() = 0; - virtual void Precache() = 0; - virtual BOOL AddAmmo(CBaseEntity *pOther) = 0; -}; - -class C338MagnumAmmo: public CBasePlayerAmmo { -public: - virtual void Spawn() = 0; - virtual void Precache() = 0; - virtual BOOL AddAmmo(CBaseEntity *pOther) = 0; -}; - -class C57MMAmmo: public CBasePlayerAmmo { -public: - virtual void Spawn() = 0; - virtual void Precache() = 0; - virtual BOOL AddAmmo(CBaseEntity *pOther) = 0; -}; - -class C357SIGAmmo: public CBasePlayerAmmo { -public: - virtual void Spawn() = 0; - virtual void Precache() = 0; - virtual BOOL AddAmmo(CBaseEntity *pOther) = 0; -}; diff --git a/regamedll/extra/cssdk/dlls/basemonster.h b/regamedll/extra/cssdk/dlls/basemonster.h deleted file mode 100644 index 05cb5e3c..00000000 --- a/regamedll/extra/cssdk/dlls/basemonster.h +++ /dev/null @@ -1,105 +0,0 @@ -/* -* -* This program is free software; you can redistribute it and/or modify it -* under the terms of the GNU General Public License as published by the -* Free Software Foundation; either version 2 of the License, or (at -* your option) any later version. -* -* This program 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 -* General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* -*/ -#pragma once - -#include "activity.h" - -class EHANDLE; - -enum MONSTERSTATE -{ - MONSTERSTATE_NONE = 0, - MONSTERSTATE_IDLE, - MONSTERSTATE_COMBAT, - MONSTERSTATE_ALERT, - MONSTERSTATE_HUNT, - MONSTERSTATE_PRONE, - MONSTERSTATE_SCRIPT, - MONSTERSTATE_PLAYDEAD, - MONSTERSTATE_DEAD -}; - -class CBaseToggle; -class CBaseMonster: public CBaseToggle { -public: - virtual void KeyValue(KeyValueData *pkvd) = 0; - virtual void TraceAttack(entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType) = 0; - virtual BOOL TakeDamage(entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType) = 0; - virtual BOOL TakeHealth(float flHealth, int bitsDamageType) = 0; - virtual void Killed(entvars_t *pevAttacker, int iGib) = 0; - virtual int BloodColor() = 0; - virtual BOOL IsAlive() = 0; - virtual float ChangeYaw(int speed) = 0; - virtual BOOL HasHumanGibs() = 0; - virtual BOOL HasAlienGibs() = 0; - virtual void FadeMonster() = 0; - virtual void GibMonster() = 0; - virtual Activity GetDeathActivity() = 0; - virtual void BecomeDead() = 0; - virtual BOOL ShouldFadeOnDeath() = 0; - virtual int IRelationship(CBaseEntity *pTarget) = 0; - virtual void PainSound() = 0; - virtual void ResetMaxSpeed() = 0; - virtual void ReportAIState() = 0; - virtual void MonsterInitDead() = 0; - virtual void Look(int iDistance) = 0; - virtual CBaseEntity *BestVisibleEnemy() = 0; - virtual BOOL FInViewCone(CBaseEntity *pEntity) = 0; - virtual BOOL FInViewCone(const Vector *pOrigin) = 0; -public: - void SetConditions(int iConditions) { m_afConditions |= iConditions; } - void ClearConditions(int iConditions) { m_afConditions &= ~iConditions; } - BOOL HasConditions(int iConditions) { return (m_afConditions & iConditions) ? TRUE : FALSE; } - BOOL HasAllConditions(int iConditions) { return ((m_afConditions & iConditions) == iConditions) ? TRUE : FALSE; } - - void Remember(int iMemory) { m_afMemory |= iMemory; } - void Forget(int iMemory) { m_afMemory &= ~iMemory; } - BOOL HasMemory(int iMemory) { return (m_afMemory & iMemory) ? TRUE : FALSE; } - BOOL HasAllMemories(int iMemory) { return ((m_afMemory & iMemory) == iMemory) ? TRUE : FALSE; } - - void StopAnimation() { pev->framerate = 0.0f; } -public: - Activity m_Activity; // what the monster is doing (animation) - Activity m_IdealActivity; // monster should switch to this activity - int m_LastHitGroup; // the last body region that took damage - int m_bitsDamageType; // what types of damage has monster (player) taken - byte m_rgbTimeBasedDamage[8]; - - MONSTERSTATE m_MonsterState; // monster's current state - MONSTERSTATE m_IdealMonsterState; // monster should change to this state - int m_afConditions; - int m_afMemory; - - float m_flNextAttack; // cannot attack again until this time - EHANDLE m_hEnemy; // the entity that the monster is fighting. - EHANDLE m_hTargetEnt; // the entity that the monster is trying to reach - float m_flFieldOfView; // width of monster's field of view ( dot product ) - int m_bloodColor; // color of blood particless - Vector m_HackedGunPos; // HACK until we can query end of gun - Vector m_vecEnemyLKP; // last known position of enemy. (enemy's origin) -}; diff --git a/regamedll/extra/cssdk/dlls/bmodels.h b/regamedll/extra/cssdk/dlls/bmodels.h deleted file mode 100644 index e3fa20f9..00000000 --- a/regamedll/extra/cssdk/dlls/bmodels.h +++ /dev/null @@ -1,150 +0,0 @@ -/* -* -* This program is free software; you can redistribute it and/or modify it -* under the terms of the GNU General Public License as published by the -* Free Software Foundation; either version 2 of the License, or (at -* your option) any later version. -* -* This program 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 -* General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* -*/ -#pragma once - -// func_rotating -#define SF_BRUSH_ROTATE_Y_AXIS 0 -#define SF_BRUSH_ROTATE_INSTANT 1 -#define SF_BRUSH_ROTATE_BACKWARDS 2 -#define SF_BRUSH_ROTATE_Z_AXIS 4 -#define SF_BRUSH_ROTATE_X_AXIS 8 - -#define SF_BRUSH_ACCDCC 16 // brush should accelerate and decelerate when toggled -#define SF_BRUSH_HURT 32 // rotating brush that inflicts pain based on rotation speed - -#define SF_ROTATING_NOT_SOLID 64 // some special rotating objects are not solid. - -#define SF_BRUSH_ROTATE_SMALLRADIUS 128 -#define SF_BRUSH_ROTATE_MEDIUMRADIUS 256 -#define SF_BRUSH_ROTATE_LARGERADIUS 512 - -#define FANPITCHMIN 30 -#define FANPITCHMAX 100 - -// func_pendulum -#define SF_PENDULUM_SWING 2 // spawnflag that makes a pendulum a rope swing. -#define SF_PENDULUM_AUTO_RETURN 16 -#define SF_PENDULUM_PASSABLE 32 - -// func_wall_toggle -#define SF_WALL_START_OFF 0x0001 -#define SF_WALL_NOTSOLID 0x0008 - -// func_conveyor -#define SF_CONVEYOR_VISUAL 0x0001 -#define SF_CONVEYOR_NOTSOLID 0x0002 - -// This is just a solid wall if not inhibited -class CFuncWall: public CBaseEntity { -public: - virtual void Spawn() = 0; - - // Bmodels don't go across transitions - virtual int ObjectCaps() = 0; - virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) = 0; -}; - -class CFuncWallToggle: public CFuncWall { -public: - virtual void Spawn() = 0; - virtual void Restart() = 0; - virtual int ObjectCaps() = 0; - virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) = 0; -}; - -class CFuncConveyor: public CFuncWall { -public: - virtual void Spawn() = 0; - virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) = 0; -}; - -// A simple entity that looks solid but lets you walk through it. -class CFuncIllusionary: public CBaseToggle { -public: - virtual void Spawn() = 0; - virtual void KeyValue(KeyValueData *pkvd) = 0; - virtual int ObjectCaps() = 0; -}; - -// Monster only clip brush -// -// This brush will be solid for any entity who has the FL_MONSTERCLIP flag set -// in pev->flags -// -// otherwise it will be invisible and not solid. This can be used to keep -// specific monsters out of certain areas -class CFuncMonsterClip: public CFuncWall { -public: - virtual void Spawn() = 0; - - // Clear out func_wall's use function - virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) = 0; -}; - -class CFuncRotating: public CBaseEntity { -public: - // basic functions - virtual void Spawn() = 0; - virtual void Precache() = 0; - virtual void Restart() = 0; - virtual void KeyValue(KeyValueData *pkvd) = 0; - virtual int Save(CSave &save) = 0; - virtual int Restore(CRestore &restore) = 0; - virtual int ObjectCaps() = 0; - virtual void Blocked(CBaseEntity *pOther) = 0; -public: - - float m_flFanFriction; - float m_flAttenuation; - float m_flVolume; - float m_pitch; - int m_sounds; - - Vector m_angles; -}; - -class CPendulum: public CBaseEntity { -public: - virtual void Spawn() = 0; - virtual void KeyValue(KeyValueData *pkvd) = 0; - virtual int Save(CSave &save) = 0; - virtual int Restore(CRestore &restore) = 0; - virtual int ObjectCaps() = 0; - virtual void Touch(CBaseEntity *pOther) = 0; - virtual void Blocked(CBaseEntity *pOther) = 0; -public: - float m_accel; // Acceleration - float m_distance; - float m_time; - float m_damp; - float m_maxSpeed; - float m_dampSpeed; - - Vector m_center; - Vector m_start; -}; diff --git a/regamedll/extra/cssdk/dlls/bot/cs_bot.h b/regamedll/extra/cssdk/dlls/bot/cs_bot.h deleted file mode 100644 index f9f30aa9..00000000 --- a/regamedll/extra/cssdk/dlls/bot/cs_bot.h +++ /dev/null @@ -1,641 +0,0 @@ -/* -* -* This program is free software; you can redistribute it and/or modify it -* under the terms of the GNU General Public License as published by the -* Free Software Foundation; either version 2 of the License, or (at -* your option) any later version. -* -* This program 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 -* General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* -*/ -#pragma once - -#include "bot/cs_gamestate.h" -#include "bot/cs_bot_manager.h" -#include "bot/cs_bot_chatter.h" - -#define PRIMARY_WEAPON_BUY_COUNT 13 -#define SECONDARY_WEAPON_BUY_COUNT 3 - -#define FLAG_PROGRESS_DRAW 0x0 // draw status bar progress -#define FLAG_PROGRESS_START 0x1 // init status bar progress -#define FLAG_PROGRESS_HIDE 0x2 // hide status bar progress - -#define HI_X 0x01 -#define LO_X 0x02 -#define HI_Y 0x04 -#define LO_Y 0x08 -#define HI_Z 0x10 -#define LO_Z 0x20 - -extern int _navAreaCount; -extern int _currentIndex; - -extern struct BuyInfo primaryWeaponBuyInfoCT[PRIMARY_WEAPON_BUY_COUNT]; -extern struct BuyInfo secondaryWeaponBuyInfoCT[SECONDARY_WEAPON_BUY_COUNT]; - -extern struct BuyInfo primaryWeaponBuyInfoT[PRIMARY_WEAPON_BUY_COUNT]; -extern struct BuyInfo secondaryWeaponBuyInfoT[SECONDARY_WEAPON_BUY_COUNT]; - -class CCSBot; -class BotChatterInterface; - -class BotState { -public: - virtual void OnEnter(CCSBot *me) {} - virtual void OnUpdate(CCSBot *me) {} - virtual void OnExit(CCSBot *me) {} - virtual const char *GetName() const = 0; -}; - -class IdleState: public BotState { -public: - virtual void OnEnter(CCSBot *me) {} - virtual void OnUpdate(CCSBot *me) {} - virtual const char *GetName() const { return "Idle"; } -}; - -class HuntState: public BotState { -public: - virtual void OnEnter(CCSBot *me) {} - virtual void OnUpdate(CCSBot *me) {} - virtual void OnExit(CCSBot *me) {} - virtual const char *GetName() const { return "Hunt"; } -public: - CNavArea *m_huntArea; -}; - -class AttackState: public BotState { -public: - virtual void OnEnter(CCSBot *me) {} - virtual void OnUpdate(CCSBot *me) {} - virtual void OnExit(CCSBot *me) {} - virtual const char *GetName() const { return "Attack"; } -public: - enum DodgeStateType - { - STEADY_ON, - SLIDE_LEFT, - SLIDE_RIGHT, - JUMP, - NUM_ATTACK_STATES - } m_dodgeState; - - float m_nextDodgeStateTimestamp; - CountdownTimer m_repathTimer; - float m_scopeTimestamp; - bool m_haveSeenEnemy; - bool m_isEnemyHidden; - float m_reacquireTimestamp; - float m_shieldToggleTimestamp; - bool m_shieldForceOpen; - float m_pinnedDownTimestamp; - bool m_crouchAndHold; - bool m_didAmbushCheck; - bool m_dodge; - bool m_firstDodge; - bool m_isCoward; - CountdownTimer m_retreatTimer; -}; - -class InvestigateNoiseState: public BotState { -public: - virtual void OnEnter(CCSBot *me) {} - virtual void OnUpdate(CCSBot *me) {} - virtual void OnExit(CCSBot *me) {} - virtual const char *GetName() const { return "InvestigateNoise"; } -private: - void AttendCurrentNoise(CCSBot *me); - Vector m_checkNoisePosition; -}; - -class BuyState: public BotState { -public: - virtual void OnEnter(CCSBot *me) {} - virtual void OnUpdate(CCSBot *me) {} - virtual void OnExit(CCSBot *me) {} - virtual const char *GetName() const { return "Buy"; } -public: - bool m_isInitialDelay; - int m_prefRetries; - int m_prefIndex; - int m_retries; - bool m_doneBuying; - bool m_buyDefuseKit; - bool m_buyGrenade; - bool m_buyShield; - bool m_buyPistol; -}; - -class MoveToState: public BotState { -public: - virtual void OnEnter(CCSBot *me) {} - virtual void OnUpdate(CCSBot *me) {} - virtual void OnExit(CCSBot *me) {} - virtual const char *GetName() const { return "MoveTo"; } - - void SetGoalPosition(const Vector &pos) { m_goalPosition = pos; } - void SetRouteType(RouteType route) { m_routeType = route; } - -private: - Vector m_goalPosition; - RouteType m_routeType; - bool m_radioedPlan; - bool m_askedForCover; -}; - -class FetchBombState: public BotState { -public: - virtual void OnEnter(CCSBot *me) {} - virtual void OnUpdate(CCSBot *me) {} - virtual const char *GetName() const { return "FetchBomb"; } -}; - -class PlantBombState: public BotState { -public: - virtual void OnEnter(CCSBot *me) {} - virtual void OnUpdate(CCSBot *me) {} - virtual void OnExit(CCSBot *me) {} - virtual const char *GetName() const { return "PlantBomb"; } -}; - -class DefuseBombState: public BotState { -public: - virtual void OnEnter(CCSBot *me) {} - virtual void OnUpdate(CCSBot *me) {} - virtual void OnExit(CCSBot *me) {} - virtual const char *GetName() const { return "DefuseBomb"; } -}; - -class HideState: public BotState { -public: - virtual void OnEnter(CCSBot *me) {} - virtual void OnUpdate(CCSBot *me) {} - virtual void OnExit(CCSBot *me) {} - virtual const char *GetName() const { return "Hide"; } - -public: - void SetHidingSpot(const Vector &pos) { m_hidingSpot = pos; } - const Vector &GetHidingSpot() const { return m_hidingSpot; } - - void SetSearchArea(CNavArea *area) { m_searchFromArea = area; } - void SetSearchRange(float range) { m_range = range; } - - void SetDuration(float time) { m_duration = time; } - void SetHoldPosition(bool hold) { m_isHoldingPosition = hold; } - - bool IsAtSpot() const { return m_isAtSpot; } - -public: - CNavArea *m_searchFromArea; - float m_range; - - Vector m_hidingSpot; - bool m_isAtSpot; - float m_duration; - bool m_isHoldingPosition; - float m_holdPositionTime; - bool m_heardEnemy; - - float m_firstHeardEnemyTime; - int m_retry; - Vector m_leaderAnchorPos; -}; - -class EscapeFromBombState: public BotState { -public: - virtual void OnEnter(CCSBot *me) {} - virtual void OnUpdate(CCSBot *me) {} - virtual void OnExit(CCSBot *me) {} - virtual const char *GetName() const { return "EscapeFromBomb"; } -}; - -class FollowState: public BotState -{ -public: - virtual void OnEnter(CCSBot *me) {} - virtual void OnUpdate(CCSBot *me) {} - virtual void OnExit(CCSBot *me) {} - virtual const char *GetName() const { return "Follow"; } - - void SetLeader(CBaseEntity *leader) { m_leader = leader; } - -public: - EHANDLE m_leader; - Vector m_lastLeaderPos; - bool m_isStopped; - float m_stoppedTimestamp; - - enum LeaderMotionStateType - { - INVALID, - STOPPED, - WALKING, - RUNNING - - } m_leaderMotionState; - - IntervalTimer m_leaderMotionStateTime; - - bool m_isSneaking; - float m_lastSawLeaderTime; - CountdownTimer m_repathInterval; - - IntervalTimer m_walkTime; - bool m_isAtWalkSpeed; - - float m_waitTime; - CountdownTimer m_idleTimer; -}; - -class UseEntityState: public BotState { -public: - virtual void OnEnter(CCSBot *me) {} - virtual void OnUpdate(CCSBot *me) {} - virtual void OnExit(CCSBot *me) {} - virtual const char *GetName() const { return "UseEntity"; } - - void SetEntity(CBaseEntity *entity) { m_entity = entity; } - -private: - EHANDLE m_entity; -}; - -// The Counter-strike Bot -class CCSBot: public CBot { -public: - virtual BOOL TakeDamage(entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType) = 0; // invoked when injured by something (EXTEND) - returns the amount of damage inflicted - virtual void Killed(entvars_t *pevAttacker, int iGib) = 0; // invoked when killed (EXTEND) - virtual void RoundRespawn() = 0; - virtual void Blind(float duration, float holdTime, float fadeTime, int alpha = 255) = 0; // player blinded by a flashbang - virtual void OnTouchingWeapon(CWeaponBox *box) = 0; // invoked when in contact with a CWeaponBox - - virtual bool Initialize(const BotProfile *profile) = 0; // (EXTEND) prepare bot for action - virtual void SpawnBot() = 0; // (EXTEND) spawn the bot into the game - - virtual void Upkeep() = 0; // lightweight maintenance, invoked frequently - virtual void Update() = 0; // heavyweight algorithms, invoked less often - - virtual void Walk() = 0; - virtual bool Jump(bool mustJump = false) = 0; // returns true if jump was started - - virtual void OnEvent(GameEventType event, CBaseEntity *entity = NULL, CBaseEntity *other = NULL) = 0; // invoked when event occurs in the game (some events have NULL entity) - - #define CHECK_FOV true - virtual bool IsVisible(const Vector *pos, bool testFOV = false) const = 0; // return true if we can see the point - virtual bool IsVisible(CBasePlayer *player, bool testFOV = false, unsigned char *visParts = NULL) const = 0; // return true if we can see any part of the player - - virtual bool IsEnemyPartVisible(VisiblePartType part) const = 0; // if enemy is visible, return the part we see for our current enemy - -public: - const Vector &GetEyePosition() const - { - m_eyePos = pev->origin + pev->view_ofs; - return m_eyePos; - } -public: - friend class CCSBotManager; - - // TODO: Get rid of these - friend class AttackState; - friend class BuyState; - - char m_name[64]; // copied from STRING(pev->netname) for debugging - - // behavior properties - float m_combatRange; // desired distance between us and them during gunplay - mutable bool m_isRogue; // if true, the bot is a "rogue" and listens to no-one - mutable CountdownTimer m_rogueTimer; - - enum MoraleType - { - TERRIBLE = -3, - BAD = -2, - NEGATIVE = -1, - NEUTRAL = 0, - POSITIVE = 1, - GOOD = 2, - EXCELLENT = 3, - }; - - MoraleType m_morale; // our current morale, based on our win/loss history - bool m_diedLastRound; // true if we died last round - float m_safeTime; // duration at the beginning of the round where we feel "safe" - bool m_wasSafe; // true if we were in the safe time last update - NavRelativeDirType m_blindMoveDir; // which way to move when we're blind - bool m_blindFire; // if true, fire weapon while blinded - - // TODO: implement through CountdownTimer - float m_surpriseDelay; // when we were surprised - float m_surpriseTimestamp; - - bool m_isFollowing; // true if we are following someone - EHANDLE m_leader; // the ID of who we are following - float m_followTimestamp; // when we started following - float m_allowAutoFollowTime; // time when we can auto follow - - CountdownTimer m_hurryTimer; // if valid, bot is in a hurry - - // instances of each possible behavior state, to avoid dynamic memory allocation during runtime - IdleState m_idleState; - HuntState m_huntState; - AttackState m_attackState; - InvestigateNoiseState m_investigateNoiseState; - BuyState m_buyState; - MoveToState m_moveToState; - FetchBombState m_fetchBombState; - PlantBombState m_plantBombState; - DefuseBombState m_defuseBombState; - HideState m_hideState; - EscapeFromBombState m_escapeFromBombState; - FollowState m_followState; - UseEntityState m_useEntityState; - - // TODO: Allow multiple simultaneous state machines (look around, etc) - BotState *m_state; // current behavior state - float m_stateTimestamp; // time state was entered - bool m_isAttacking; // if true, special Attack state is overriding the state machine - - // high-level tasks - enum TaskType - { - SEEK_AND_DESTROY, - PLANT_BOMB, - FIND_TICKING_BOMB, - DEFUSE_BOMB, - GUARD_TICKING_BOMB, - GUARD_BOMB_DEFUSER, - GUARD_LOOSE_BOMB, - GUARD_BOMB_ZONE, - ESCAPE_FROM_BOMB, - HOLD_POSITION, - FOLLOW, - VIP_ESCAPE, - GUARD_VIP_ESCAPE_ZONE, - COLLECT_HOSTAGES, - RESCUE_HOSTAGES, - GUARD_HOSTAGES, - GUARD_HOSTAGE_RESCUE_ZONE, - MOVE_TO_LAST_KNOWN_ENEMY_POSITION, - MOVE_TO_SNIPER_SPOT, - SNIPING, - - NUM_TASKS - }; - TaskType m_task; // our current task - EHANDLE m_taskEntity; // an entity used for our task - - // navigation - Vector m_goalPosition; - EHANDLE m_goalEntity; - - CNavArea *m_currentArea; // the nav area we are standing on - CNavArea *m_lastKnownArea; // the last area we were in - EHANDLE m_avoid; // higher priority player we need to make way for - float m_avoidTimestamp; - bool m_isJumpCrouching; - bool m_isJumpCrouched; - float m_jumpCrouchTimestamp; - - // path navigation data - enum { _MAX_PATH_LENGTH = 256 }; - struct ConnectInfo - { - CNavArea *area; // the area along the path - NavTraverseType how; // how to enter this area from the previous one - Vector pos; // our movement goal position at this point in the path - const CNavLadder *ladder; // if "how" refers to a ladder, this is it - } - m_path[_MAX_PATH_LENGTH]; - int m_pathLength; - int m_pathIndex; - float m_areaEnteredTimestamp; - - CountdownTimer m_repathTimer; // must have elapsed before bot can pathfind again - - mutable CountdownTimer m_avoidFriendTimer; // used to throttle how often we check for friends in our path - mutable bool m_isFriendInTheWay; // true if a friend is blocking our path - CountdownTimer m_politeTimer; // we'll wait for friend to move until this runs out - bool m_isWaitingBehindFriend; // true if we are waiting for a friend to move - - enum LadderNavState - { - APPROACH_ASCENDING_LADDER, // prepare to scale a ladder - APPROACH_DESCENDING_LADDER, // prepare to go down ladder - FACE_ASCENDING_LADDER, - FACE_DESCENDING_LADDER, - MOUNT_ASCENDING_LADDER, // move toward ladder until "on" it - MOUNT_DESCENDING_LADDER, // move toward ladder until "on" it - ASCEND_LADDER, // go up the ladder - DESCEND_LADDER, // go down the ladder - DISMOUNT_ASCENDING_LADDER, // get off of the ladder - DISMOUNT_DESCENDING_LADDER, // get off of the ladder - MOVE_TO_DESTINATION, // dismount ladder and move to destination area - } - m_pathLadderState; - bool m_pathLadderFaceIn; // if true, face towards ladder, otherwise face away - const CNavLadder *m_pathLadder; // the ladder we need to use to reach the next area - NavRelativeDirType m_pathLadderDismountDir; // which way to dismount - float m_pathLadderDismountTimestamp; // time when dismount started - float m_pathLadderEnd; // if ascending, z of top, if descending z of bottom - float m_pathLadderTimestamp; // time when we started using ladder - for timeout check - - CountdownTimer m_mustRunTimer; // if nonzero, bot cannot walk - - // game scenario mechanisms - CSGameState m_gameState; - - // hostages mechanism - byte m_hostageEscortCount; - float m_hostageEscortCountTimestamp; - bool m_isWaitingForHostage; - CountdownTimer m_inhibitWaitingForHostageTimer; - CountdownTimer m_waitForHostageTimer; - - // listening mechanism - Vector m_noisePosition; // position we last heard non-friendly noise - float m_noiseTimestamp; // when we heard it (can get zeroed) - CNavArea *m_noiseArea; // the nav area containing the noise - float m_noiseCheckTimestamp; - PriorityType m_noisePriority; // priority of currently heard noise - bool m_isNoiseTravelRangeChecked; - - // "looking around" mechanism - float m_lookAroundStateTimestamp; // time of next state change - float m_lookAheadAngle; // our desired forward look angle - float m_forwardAngle; // our current forward facing direction - float m_inhibitLookAroundTimestamp; // time when we can look around again - - enum LookAtSpotState - { - NOT_LOOKING_AT_SPOT, // not currently looking at a point in space - LOOK_TOWARDS_SPOT, // in the process of aiming at m_lookAtSpot - LOOK_AT_SPOT, // looking at m_lookAtSpot - NUM_LOOK_AT_SPOT_STATES - } - m_lookAtSpotState; - Vector m_lookAtSpot; // the spot we're currently looking at - PriorityType m_lookAtSpotPriority; - float m_lookAtSpotDuration; // how long we need to look at the spot - float m_lookAtSpotTimestamp; // when we actually began looking at the spot - float m_lookAtSpotAngleTolerance; // how exactly we must look at the spot - bool m_lookAtSpotClearIfClose; // if true, the look at spot is cleared if it gets close to us - const char *m_lookAtDesc; // for debugging - float m_peripheralTimestamp; - - enum { MAX_APPROACH_POINTS = 16 }; - Vector m_approachPoint[MAX_APPROACH_POINTS]; - unsigned char m_approachPointCount; - Vector m_approachPointViewPosition; // the position used when computing current approachPoint set - bool m_isWaitingToTossGrenade; // lining up throw - CountdownTimer m_tossGrenadeTimer; // timeout timer for grenade tossing - - SpotEncounter *m_spotEncounter; // the spots we will encounter as we move thru our current area - float m_spotCheckTimestamp; // when to check next encounter spot - - // TODO: Add timestamp for each possible client to hiding spots - enum { MAX_CHECKED_SPOTS = 64 }; - struct HidingSpotCheckInfo - { - HidingSpot *spot; - float timestamp; - } - m_checkedHidingSpot[MAX_CHECKED_SPOTS]; - int m_checkedHidingSpotCount; - - // view angle mechanism - float m_lookPitch; // our desired look pitch angle - float m_lookPitchVel; - float m_lookYaw; // our desired look yaw angle - float m_lookYawVel; - - // aim angle mechanism - mutable Vector m_eyePos; - Vector m_aimOffset; // current error added to victim's position to get actual aim spot - Vector m_aimOffsetGoal; // desired aim offset - float m_aimOffsetTimestamp; // time of next offset adjustment - float m_aimSpreadTimestamp; // time used to determine max spread as it begins to tighten up - Vector m_aimSpot; // the spot we are currently aiming to fire at - - // attack state data - // behavior modifiers - enum DispositionType - { - ENGAGE_AND_INVESTIGATE, // engage enemies on sight and investigate enemy noises - OPPORTUNITY_FIRE, // engage enemies on sight, but only look towards enemy noises, dont investigate - SELF_DEFENSE, // only engage if fired on, or very close to enemy - IGNORE_ENEMIES, // ignore all enemies - useful for ducking around corners, running away, etc - - NUM_DISPOSITIONS - }; - DispositionType m_disposition; // how we will react to enemies - CountdownTimer m_ignoreEnemiesTimer; // how long will we ignore enemies - mutable EHANDLE m_enemy; // our current enemy - bool m_isEnemyVisible; // result of last visibility test on enemy - unsigned char m_visibleEnemyParts; // which parts of the visible enemy do we see - Vector m_lastEnemyPosition; // last place we saw the enemy - float m_lastSawEnemyTimestamp; - float m_firstSawEnemyTimestamp; - float m_currentEnemyAcquireTimestamp; - float m_enemyDeathTimestamp; // if m_enemy is dead, this is when he died - bool m_isLastEnemyDead; // true if we killed or saw our last enemy die - int m_nearbyEnemyCount; // max number of enemies we've seen recently - unsigned int m_enemyPlace; // the location where we saw most of our enemies - - struct WatchInfo - { - float timestamp; - bool isEnemy; - } - m_watchInfo[MAX_CLIENTS]; - mutable EHANDLE m_bomber; // points to bomber if we can see him - - int m_nearbyFriendCount; // number of nearby teammates - mutable EHANDLE m_closestVisibleFriend; // the closest friend we can see - mutable EHANDLE m_closestVisibleHumanFriend; // the closest human friend we can see - - CBasePlayer *m_attacker; // last enemy that hurt us (may not be same as m_enemy) - float m_attackedTimestamp; // when we were hurt by the m_attacker - - int m_lastVictimID; // the entindex of the last victim we killed, or zero - bool m_isAimingAtEnemy; // if true, we are trying to aim at our enemy - bool m_isRapidFiring; // if true, RunUpkeep() will toggle our primary attack as fast as it can - IntervalTimer m_equipTimer; // how long have we had our current weapon equipped - float m_fireWeaponTimestamp; - - // reaction time system - enum { MAX_ENEMY_QUEUE = 20 }; - struct ReactionState - { - // NOTE: player position & orientation is not currently stored separately - EHANDLE player; - bool isReloading; - bool isProtectedByShield; - } - m_enemyQueue[MAX_ENEMY_QUEUE]; // round-robin queue for simulating reaction times - - byte m_enemyQueueIndex; - byte m_enemyQueueCount; - byte m_enemyQueueAttendIndex; // index of the timeframe we are "conscious" of - - // stuck detection - bool m_isStuck; - float m_stuckTimestamp; // time when we got stuck - Vector m_stuckSpot; // the location where we became stuck - NavRelativeDirType m_wiggleDirection; - float m_wiggleTimestamp; - float m_stuckJumpTimestamp; // time for next jump when stuck - - enum { MAX_VEL_SAMPLES = 5 }; - float m_avgVel[MAX_VEL_SAMPLES]; - int m_avgVelIndex; - int m_avgVelCount; - Vector m_lastOrigin; - - // chatter mechanism - GameEventType m_lastRadioCommand; // last radio command we recieved - - float m_lastRadioRecievedTimestamp; // time we recieved a radio message - float m_lastRadioSentTimestamp; // time when we send a radio message - EHANDLE m_radioSubject; // who issued the radio message - Vector m_radioPosition; // position referred to in radio message - float m_voiceFeedbackStartTimestamp; - float m_voiceFeedbackEndTimestamp; // new-style "voice" chatter gets voice feedback - BotChatterInterface m_chatter; - - // learn map mechanism - const CNavNode *m_navNodeList; - CNavNode *m_currentNode; - NavDirType m_generationDir; - NavAreaList::iterator m_analyzeIter; - - enum ProcessType - { - PROCESS_NORMAL, - PROCESS_LEARN, - PROCESS_ANALYZE_ALPHA, - PROCESS_ANALYZE_BETA, - PROCESS_SAVE, - } - m_processMode; - CountdownTimer m_mumbleTimer; - CountdownTimer m_booTimer; - CountdownTimer m_relocateTimer; -}; diff --git a/regamedll/extra/cssdk/dlls/bot/cs_bot_chatter.h b/regamedll/extra/cssdk/dlls/bot/cs_bot_chatter.h deleted file mode 100644 index 2e62a332..00000000 --- a/regamedll/extra/cssdk/dlls/bot/cs_bot_chatter.h +++ /dev/null @@ -1,339 +0,0 @@ -/* -* -* This program is free software; you can redistribute it and/or modify it -* under the terms of the GNU General Public License as published by the -* Free Software Foundation; either version 2 of the License, or (at -* your option) any later version. -* -* This program 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 -* General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* -*/ -#pragma once - -#define UNDEFINED_COUNT 0xFFFF -#define MAX_PLACES_PER_MAP 64 -#define UNDEFINED_SUBJECT (-1) -#define COUNT_MANY 4 // equal to or greater than this is "many" - -class CCSBot; -class BotChatterInterface; - -typedef unsigned int PlaceCriteria; -typedef unsigned int CountCriteria; - -// A meme is a unit information that bots use to -// transmit information to each other via the radio -class BotMeme { -public: - virtual void Interpret(CCSBot *sender, CCSBot *receiver) const = 0; // cause the given bot to act on this meme -}; - -class BotAllHostagesGoneMeme: public BotMeme { -public: - virtual void Interpret(CCSBot *sender, CCSBot *receiver) const; // cause the given bot to act on this meme -}; - -class BotHostageBeingTakenMeme: public BotMeme { -public: - virtual void Interpret(CCSBot *sender, CCSBot *receiver) const; // cause the given bot to act on this meme -}; - -class BotHelpMeme: public BotMeme { -public: - virtual void Interpret(CCSBot *sender, CCSBot *receiver) const; // cause the given bot to act on this meme - -public: - Place m_place; -}; - -class BotBombsiteStatusMeme: public BotMeme { -public: - virtual void Interpret(CCSBot *sender, CCSBot *receiver) const; // cause the given bot to act on this meme - -public: - enum StatusType { CLEAR, PLANTED }; - int m_zoneIndex; // the bombsite - StatusType m_status; // whether it is cleared or the bomb is there (planted) -}; - -class BotBombStatusMeme: public BotMeme { -public: - virtual void Interpret(CCSBot *sender, CCSBot *receiver) const; // cause the given bot to act on this meme - -public: - CSGameState::BombState m_state; - Vector m_pos; -}; - -class BotFollowMeme: public BotMeme { -public: - virtual void Interpret(CCSBot *sender, CCSBot *receiver) const; // cause the given bot to act on this meme -}; - -class BotDefendHereMeme: public BotMeme { -public: - virtual void Interpret(CCSBot *sender, CCSBot *receiver) const; // cause the given bot to act on this meme - -public: - Vector m_pos; -}; - -class BotWhereBombMeme: public BotMeme { -public: - virtual void Interpret(CCSBot *sender, CCSBot *receiver) const; // cause the given bot to act on this meme -}; - -class BotRequestReportMeme: public BotMeme { -public: - virtual void Interpret(CCSBot *sender, CCSBot *receiver) const; // cause the given bot to act on this meme -}; - -enum BotStatementType -{ - REPORT_VISIBLE_ENEMIES, - REPORT_ENEMY_ACTION, - REPORT_MY_CURRENT_TASK, - REPORT_MY_INTENTION, - REPORT_CRITICAL_EVENT, - REPORT_REQUEST_HELP, - REPORT_REQUEST_INFORMATION, - REPORT_ROUND_END, - REPORT_MY_PLAN, - REPORT_INFORMATION, - REPORT_EMOTE, - REPORT_ACKNOWLEDGE, // affirmative or negative - REPORT_ENEMIES_REMAINING, - REPORT_FRIENDLY_FIRE, - REPORT_KILLED_FRIEND, - //REPORT_ENEMY_LOST - - NUM_BOT_STATEMENT_TYPES, -}; - -// BotSpeakables are the smallest unit of bot chatter. -// They represent a specific wav file of a phrase, and the criteria for which it is useful -class BotSpeakable { -public: - char *m_phrase; - float m_duration; - PlaceCriteria m_place; - CountCriteria m_count; -}; - -typedef std::vector BotSpeakableVector; -typedef std::vector BotVoiceBankVector; - -// The BotPhrase class is a collection of Speakables associated with a name, ID, and criteria -class BotPhrase { -public: - const char *GetName() const { return m_name; } - Place GetID() const { return m_id; } - GameEventType GetRadioEquivalent() const { return m_radioEvent; } - bool IsImportant() const { return m_isImportant; } // return true if this phrase is part of an important statement - bool IsPlace() const { return m_isPlace; } - -public: - friend class BotPhraseManager; - char *m_name; - Place m_id; - bool m_isPlace; // true if this is a Place phrase - GameEventType m_radioEvent; - bool m_isImportant; // mission-critical statement - - mutable BotVoiceBankVector m_voiceBank; // array of voice banks (arrays of speakables) - std::vector m_count; // number of speakables - mutable std::vector< int > m_index; // index of next speakable to return - int m_numVoiceBanks; // number of voice banks that have been initialized - - mutable PlaceCriteria m_placeCriteria; - mutable CountCriteria m_countCriteria; -}; - -typedef std::list BotPhraseList; - -// The BotPhraseManager is a singleton that provides an interface to all BotPhrase collections -class BotPhraseManager { -public: - const BotPhraseList *GetPlaceList() const { return &m_placeList; } - - // return time last statement of given type was emitted by a teammate for the given place - float GetPlaceStatementInterval(Place place) const; - - // set time of last statement of given type was emitted by a teammate for the given place - void ResetPlaceStatementInterval(Place place) const; - -public: - int FindPlaceIndex(Place where) const; - - // master list of all phrase collections - BotPhraseList m_list; - - // master list of all Place phrases - BotPhraseList m_placeList; - - struct PlaceTimeInfo - { - Place placeID; - IntervalTimer timer; - }; - - mutable PlaceTimeInfo m_placeStatementHistory[MAX_PLACES_PER_MAP]; - mutable int m_placeCount; -}; - -inline int BotPhraseManager::FindPlaceIndex(Place where) const -{ - for (int i = 0; i < m_placeCount; ++i) - { - if (m_placeStatementHistory[i].placeID == where) - return i; - } - - if (m_placeCount < MAX_PLACES_PER_MAP) - { - m_placeStatementHistory[++m_placeCount].placeID = where; - m_placeStatementHistory[++m_placeCount].timer.Invalidate(); - return m_placeCount - 1; - } - - return -1; -} - -inline float BotPhraseManager::GetPlaceStatementInterval(Place place) const -{ - int index = FindPlaceIndex(place); - - if (index < 0) - return 999999.9f; - - if (index >= m_placeCount) - return 999999.9f; - - return m_placeStatementHistory[index].timer.GetElapsedTime(); -} - -inline void BotPhraseManager::ResetPlaceStatementInterval(Place place) const -{ - int index = FindPlaceIndex(place); - - if (index < 0) - return; - - if (index >= m_placeCount) - return; - - m_placeStatementHistory[index].timer.Reset(); -} - -// Statements are meaningful collections of phrases -class BotStatement { -public: - BotChatterInterface *GetChatter() const { return m_chatter; } - BotStatementType GetType() const { return m_type; } // return the type of statement this is - bool HasSubject() const { return (m_subject != UNDEFINED_SUBJECT); } - void SetSubject(int playerID) { m_subject = playerID; } // who this statement is about - int GetSubject() const { return m_subject; } // who this statement is about - void SetPlace(Place where) { m_place = where; } // explicitly set place - - void SetStartTime(float timestamp) { m_startTime = timestamp; } // define the earliest time this statement can be spoken - float GetStartTime() const { return m_startTime; } - bool IsSpeaking() const { return m_isSpeaking; } // return true if this statement is currently being spoken - float GetTimestamp() const { return m_timestamp; } // get time statement was created (but not necessarily started talking) - -public: - friend class BotChatterInterface; - - BotChatterInterface *m_chatter; // the chatter system this statement is part of - BotStatement *m_next, *m_prev; // linked list hooks - BotStatementType m_type; // what kind of statement this is - int m_subject; // who this subject is about - Place m_place; // explicit place - note some phrases have implicit places as well - BotMeme *m_meme; // a statement can only have a single meme for now - - float m_timestamp; // time when message was created - float m_startTime; // the earliest time this statement can be spoken - float m_expireTime; // time when this statement is no longer valid - float m_speakTimestamp; // time when message began being spoken - bool m_isSpeaking; // true if this statement is current being spoken - - float m_nextTime; // time for next phrase to begin - - enum { MAX_BOT_PHRASES = 4 }; - enum ContextType - { - CURRENT_ENEMY_COUNT, - REMAINING_ENEMY_COUNT, - SHORT_DELAY, - LONG_DELAY, - ACCUMULATE_ENEMIES_DELAY, - }; - struct - { - bool isPhrase; - union - { - const BotPhrase *phrase; - ContextType context; - }; - - } - m_statement[MAX_BOT_PHRASES]; - - enum { MAX_BOT_CONDITIONS = 4 }; - enum ConditionType - { - IS_IN_COMBAT, - RADIO_SILENCE, - ENEMIES_REMAINING, - NUM_CONDITIONS, - }; - - ConditionType m_condition[MAX_BOT_CONDITIONS]; // conditions that must be true for the statement to be said - int m_conditionCount; - - int m_index; // m_index refers to the phrase currently being spoken, or -1 if we havent started yet - int m_count; -}; - -// This class defines the interface to the bot radio chatter system -class BotChatterInterface { -public: - CCSBot *GetOwner() const { return m_me; } - int GetPitch() const { return m_pitch; } - bool SeesAtLeastOneEnemy() const { return m_seeAtLeastOneEnemy; } - -public: - BotStatement *m_statementList; // list of all active/pending messages for this bot - CCSBot *m_me; // the bot this chatter is for - bool m_seeAtLeastOneEnemy; - float m_timeWhenSawFirstEnemy; - bool m_reportedEnemies; - bool m_requestedBombLocation; // true if we already asked where the bomb has been planted - int m_pitch; - IntervalTimer m_needBackupInterval; - IntervalTimer m_spottedBomberInterval; - IntervalTimer m_scaredInterval; - IntervalTimer m_planInterval; - CountdownTimer m_spottedLooseBombTimer; - CountdownTimer m_heardNoiseTimer; - CountdownTimer m_escortingHostageTimer; -}; - -extern BotPhraseManager *TheBotPhrases; diff --git a/regamedll/extra/cssdk/dlls/bot/cs_bot_manager.h b/regamedll/extra/cssdk/dlls/bot/cs_bot_manager.h deleted file mode 100644 index 38f3d602..00000000 --- a/regamedll/extra/cssdk/dlls/bot/cs_bot_manager.h +++ /dev/null @@ -1,145 +0,0 @@ -/* -* -* This program is free software; you can redistribute it and/or modify it -* under the terms of the GNU General Public License as published by the -* Free Software Foundation; either version 2 of the License, or (at -* your option) any later version. -* -* This program 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 -* General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* -*/ -#pragma once - -extern CBotManager *TheBots; - -// The manager for Counter-Strike specific bots -class CCSBotManager: public CBotManager { -public: - virtual void ClientDisconnect(CBasePlayer *pPlayer) = 0; - virtual BOOL ClientCommand(CBasePlayer *pPlayer, const char *pcmd) = 0; - - virtual void ServerActivate() = 0; - virtual void ServerDeactivate() = 0; - - virtual void ServerCommand(const char *pcmd) = 0; - virtual void AddServerCommand(const char *cmd) = 0; - virtual void AddServerCommands() = 0; - - virtual void RestartRound() = 0; // (EXTEND) invoked when a new round begins - virtual void StartFrame() = 0; // (EXTEND) called each frame - - virtual void OnEvent(GameEventType event, CBaseEntity *entity = NULL, CBaseEntity *other = NULL) = 0; - virtual unsigned int GetPlayerPriority(CBasePlayer *player) const = 0; // return priority of player (0 = max pri) - virtual bool IsImportantPlayer(CBasePlayer *player) const = 0; // return true if player is important to scenario (VIP, bomb carrier, etc) - -public: - // the supported game scenarios - enum GameScenarioType - { - SCENARIO_DEATHMATCH, - SCENARIO_DEFUSE_BOMB, - SCENARIO_RESCUE_HOSTAGES, - SCENARIO_ESCORT_VIP - }; - GameScenarioType GetScenario() const { return m_gameScenario; } - - // "zones" - // depending on the game mode, these are bomb zones, rescue zones, etc. - enum { MAX_ZONES = 4 }; // max # of zones in a map - enum { MAX_ZONE_NAV_AREAS = 16 }; // max # of nav areas in a zone - struct Zone - { - CBaseEntity *m_entity; // the map entity - CNavArea *m_area[MAX_ZONE_NAV_AREAS]; // nav areas that overlap this zone - int m_areaCount; - Vector m_center; - bool m_isLegacy; // if true, use pev->origin and 256 unit radius as zone - int m_index; - Extent m_extent; - }; - - const Zone *GetZone(int i) const { return &m_zone[i]; } - int GetZoneCount() const { return m_zoneCount; } - - // pick a zone at random and return it - const Zone *GetRandomZone() const - { - if (!m_zoneCount) - return NULL; - - return &m_zone[RANDOM_LONG(0, m_zoneCount - 1)]; - } - - bool IsBombPlanted() const { return m_isBombPlanted; } // returns true if bomb has been planted - float GetBombPlantTimestamp() const { return m_bombPlantTimestamp; } // return time bomb was planted - bool IsTimeToPlantBomb() const { return (gpGlobals->time >= m_earliestBombPlantTimestamp); } // return true if it's ok to try to plant bomb - CBasePlayer *GetBombDefuser() const { return m_bombDefuser; } // return the player currently defusing the bomb, or NULL - CBaseEntity *GetLooseBomb() { return m_looseBomb; } // return the bomb if it is loose on the ground - CNavArea *GetLooseBombArea() const { return m_looseBombArea; } // return area that bomb is in/near - - float GetLastSeenEnemyTimestamp() const { return m_lastSeenEnemyTimestamp; } // return the last time anyone has seen an enemy - void SetLastSeenEnemyTimestamp() { m_lastSeenEnemyTimestamp = gpGlobals->time; } - - float GetRoundStartTime() const { return m_roundStartTimestamp; } - float GetElapsedRoundTime() const { return gpGlobals->time - m_roundStartTimestamp; } // return the elapsed time since the current round began - - bool IsDefenseRushing() const { return m_isDefenseRushing; } // returns true if defense team has "decided" to rush this round - bool IsRoundOver() const { return m_isRoundOver; } // return true if the round has ended - - unsigned int GetNavPlace() const { return m_navPlace; } - void SetNavPlace(unsigned int place) { m_navPlace = place; } - -public: - GameScenarioType m_gameScenario; // what kind of game are we playing - - Zone m_zone[MAX_ZONES]; - int m_zoneCount; - - bool m_isBombPlanted; // true if bomb has been planted - float m_bombPlantTimestamp; // time bomb was planted - float m_earliestBombPlantTimestamp; // don't allow planting until after this time has elapsed - CBasePlayer *m_bombDefuser; // the player currently defusing a bomb - EHANDLE m_looseBomb; // will be non-NULL if bomb is loose on the ground - CNavArea *m_looseBombArea; // area that bomb is is/near - - bool m_isRoundOver; // true if the round has ended - float m_radioMsgTimestamp[24][2]; - - float m_lastSeenEnemyTimestamp; - float m_roundStartTimestamp; // the time when the current round began - - bool m_isDefenseRushing; // whether defensive team is rushing this round or not - - unsigned int m_navPlace; - CountdownTimer m_respawnTimer; - bool m_isRespawnStarted; - bool m_canRespawn; - bool m_bServerActive; -}; - -inline int OtherTeam(int team) -{ - return (team == TERRORIST) ? CT : TERRORIST; -} - -inline CCSBotManager *TheCSBots() -{ - return reinterpret_cast(TheBots); -} diff --git a/regamedll/extra/cssdk/dlls/bot/cs_gamestate.h b/regamedll/extra/cssdk/dlls/bot/cs_gamestate.h deleted file mode 100644 index 769575ff..00000000 --- a/regamedll/extra/cssdk/dlls/bot/cs_gamestate.h +++ /dev/null @@ -1,90 +0,0 @@ -/* -* -* This program is free software; you can redistribute it and/or modify it -* under the terms of the GNU General Public License as published by the -* Free Software Foundation; either version 2 of the License, or (at -* your option) any later version. -* -* This program 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 -* General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* -*/ -#pragma once - -class CCSBot; - -// This class represents the game state as known by a particular bot -class CSGameState { -public: - // bomb defuse scenario - enum BombState - { - MOVING, // being carried by a Terrorist - LOOSE, // loose on the ground somewhere - PLANTED, // planted and ticking - DEFUSED, // the bomb has been defused - EXPLODED, // the bomb has exploded - }; - - bool IsBombMoving() const { return (m_bombState == MOVING); } - bool IsBombLoose() const { return (m_bombState == LOOSE); } - bool IsBombPlanted() const { return (m_bombState == PLANTED); } - bool IsBombDefused() const { return (m_bombState == DEFUSED); } - bool IsBombExploded() const { return (m_bombState == EXPLODED); } - -public: - CCSBot *m_owner; // who owns this gamestate - bool m_isRoundOver; // true if round is over, but no yet reset - - // bomb defuse scenario - BombState GetBombState() { return m_bombState; } - BombState m_bombState; // what we think the bomb is doing - - IntervalTimer m_lastSawBomber; - Vector m_bomberPos; - - IntervalTimer m_lastSawLooseBomb; - Vector m_looseBombPos; - - bool m_isBombsiteClear[4]; // corresponds to zone indices in CCSBotManager - int m_bombsiteSearchOrder[4]; // randomized order of bombsites to search - int m_bombsiteCount; - int m_bombsiteSearchIndex; // the next step in the search - - int m_plantedBombsite; // zone index of the bombsite where the planted bomb is - - bool m_isPlantedBombPosKnown; // if true, we know the exact location of the bomb - Vector m_plantedBombPos; - - // hostage rescue scenario - struct HostageInfo - { - CHostage *hostage; - Vector knownPos; - bool isValid; - bool isAlive; - bool isFree; // not being escorted by a CT - } - m_hostage[MAX_HOSTAGES]; - int m_hostageCount; // number of hostages left in map - CountdownTimer m_validateInterval; - - bool m_allHostagesRescued; // if true, so every hostages been is rescued - bool m_haveSomeHostagesBeenTaken; // true if a hostage has been moved by a CT (and we've seen it) -}; diff --git a/regamedll/extra/cssdk/dlls/buttons.h b/regamedll/extra/cssdk/dlls/buttons.h deleted file mode 100644 index 84161f18..00000000 --- a/regamedll/extra/cssdk/dlls/buttons.h +++ /dev/null @@ -1,109 +0,0 @@ -/* -* -* This program is free software; you can redistribute it and/or modify it -* under the terms of the GNU General Public License as published by the -* Free Software Foundation; either version 2 of the License, or (at -* your option) any later version. -* -* This program 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 -* General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* -*/ -#pragma once - -#define SF_BUTTON_DONTMOVE 1 -#define SF_ROTBUTTON_NOTSOLID 1 -#define SF_BUTTON_TOGGLE 32 // button stays pushed until reactivated -#define SF_BUTTON_SPARK_IF_OFF 64 // button sparks in OFF state -#define SF_BUTTON_TOUCH_ONLY 256 // button only fires as a result of USE key. - -#define SF_GLOBAL_SET 1 // Set global state to initial state on spawn - -#define SF_MULTI_INIT 1 - -// Make this button behave like a door (HACKHACK) -// This will disable use and make the button solid -// rotating buttons were made SOLID_NOT by default since their were some -// collision problems with them... -#define SF_MOMENTARY_DOOR 0x0001 - -#define SF_SPARK_TOOGLE 32 -#define SF_SPARK_IF_OFF 64 - -#define SF_BTARGET_USE 0x0001 -#define SF_BTARGET_ON 0x0002 - -class CEnvGlobal: public CPointEntity { -public: - virtual void Spawn() = 0; - virtual void KeyValue(KeyValueData *pkvd) = 0; - virtual int Save(CSave &save) = 0; - virtual int Restore(CRestore &restore) = 0; - virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) = 0; -public: - string_t m_globalstate; - int m_triggermode; - int m_initialstate; -}; - -class CRotButton: public CBaseButton { -public: - virtual void Spawn() = 0; - virtual void Restart() = 0; - virtual int Save(CSave &save) = 0; - virtual int Restore(CRestore &restore) = 0; -public: - Vector m_vecSpawn; -}; - -class CMomentaryRotButton: public CBaseToggle { -public: - virtual void Spawn() = 0; - virtual void KeyValue(KeyValueData *pkvd) = 0; - virtual int Save(CSave &save) = 0; - virtual int Restore(CRestore &restore) = 0; - virtual int ObjectCaps() = 0; - virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) = 0; -public: - int m_lastUsed; - int m_direction; - float m_returnSpeed; - Vector m_start; - Vector m_end; - int m_sounds; -}; - -class CEnvSpark: public CBaseEntity { -public: - virtual void Spawn() = 0; - virtual void Precache() = 0; - virtual void KeyValue(KeyValueData *pkvd) = 0; - virtual int Save(CSave &save) = 0; - virtual int Restore(CRestore &restore) = 0; -public: - float m_flDelay; -}; - -class CButtonTarget: public CBaseEntity { -public: - virtual void Spawn() = 0; - virtual int ObjectCaps() = 0; - virtual BOOL TakeDamage(entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType) = 0; - virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) = 0; -}; diff --git a/regamedll/extra/cssdk/dlls/cbase.h b/regamedll/extra/cssdk/dlls/cbase.h deleted file mode 100644 index 33e57329..00000000 --- a/regamedll/extra/cssdk/dlls/cbase.h +++ /dev/null @@ -1,383 +0,0 @@ -/* -* -* This program is free software; you can redistribute it and/or modify it -* under the terms of the GNU General Public License as published by the -* Free Software Foundation; either version 2 of the License, or (at -* your option) any later version. -* -* This program 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 -* General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* -*/ -#pragma once - -#include "util.h" -#include "monsterevent.h" - -class CSave; -class CRestore; -class CBasePlayer; -class CBaseEntity; -class CBaseMonster; -class CBasePlayerItem; -class CSquadMonster; -class CCSEntity; - -class CBaseEntity { -public: - // Constructor. Set engine to use C/C++ callback functions - // pointers to engine data - entvars_t *pev; // Don't need to save/restore this pointer, the engine resets it - - // path corners - CBaseEntity *m_pGoalEnt; // path corner we are heading towards - CBaseEntity *m_pLink; // used for temporary link-list operations. - - // initialization functions - virtual void Spawn() = 0; - virtual void Precache() = 0; - virtual void Restart() = 0; - virtual void KeyValue(KeyValueData *pkvd) = 0; - virtual int Save(CSave &save) = 0; - virtual int Restore(CRestore &restore) = 0; - virtual int ObjectCaps() = 0; - virtual void Activate() = 0; - - // Setup the object->object collision box (pev->mins / pev->maxs is the object->world collision box) - virtual void SetObjectCollisionBox() = 0; - - // Classify - returns the type of group (i.e, "houndeye", or "human military" so that monsters with different classnames - // still realize that they are teammates. (overridden for monsters that form groups) - virtual int Classify() = 0; - virtual void DeathNotice(entvars_t *pevChild) = 0; - - virtual void TraceAttack(entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType) = 0; - virtual BOOL TakeDamage(entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType) = 0; - virtual BOOL TakeHealth(float flHealth, int bitsDamageType) = 0; - virtual void Killed(entvars_t *pevAttacker, int iGib) = 0; - virtual int BloodColor() = 0; - virtual void TraceBleed(float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType) = 0; - virtual BOOL IsTriggered(CBaseEntity *pActivator) = 0; - virtual CBaseMonster *MyMonsterPointer() = 0; - virtual CSquadMonster *MySquadMonsterPointer() = 0; - virtual int GetToggleState() = 0; - virtual void AddPoints(int score, BOOL bAllowNegativeScore) = 0; - virtual void AddPointsToTeam(int score, BOOL bAllowNegativeScore) = 0; - virtual BOOL AddPlayerItem(CBasePlayerItem *pItem) = 0; - virtual BOOL RemovePlayerItem(CBasePlayerItem *pItem) = 0; - virtual int GiveAmmo(int iAmount, const char *szName, int iMax = -1) = 0; - virtual float GetDelay() = 0; - virtual int IsMoving() = 0; - virtual void OverrideReset() = 0; - virtual int DamageDecal(int bitsDamageType) = 0; - - // This is ONLY used by the node graph to test movement through a door - virtual void SetToggleState(int state) = 0; - virtual void StartSneaking() = 0; - virtual void UpdateOnRemove() = 0; - virtual BOOL OnControls(entvars_t *onpev) = 0; - virtual BOOL IsSneaking() = 0; - virtual BOOL IsAlive() = 0; - virtual BOOL IsBSPModel() = 0; - virtual BOOL ReflectGauss() = 0; - virtual BOOL HasTarget(string_t targetname) = 0; - virtual BOOL IsInWorld() = 0; - virtual BOOL IsPlayer() = 0; - virtual BOOL IsNetClient() = 0; - virtual const char *TeamID() = 0; - - virtual CBaseEntity *GetNextTarget() = 0; - - // fundamental callbacks - void (CBaseEntity::*m_pfnThink)(); - void (CBaseEntity::*m_pfnTouch)(CBaseEntity *pOther); - void (CBaseEntity::*m_pfnUse)(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); - void (CBaseEntity::*m_pfnBlocked)(CBaseEntity *pOther); - - virtual void Think() = 0; - virtual void Touch(CBaseEntity *pOther) = 0; - virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType = USE_OFF, float value = 0.0f) = 0; - virtual void Blocked(CBaseEntity *pOther) = 0; - - virtual CBaseEntity *Respawn() = 0; - virtual void UpdateOwner() = 0; - virtual BOOL FBecomeProne() = 0; - - virtual Vector Center() = 0; // center point of entity - virtual Vector EyePosition() = 0; // position of eyes - virtual Vector EarPosition() = 0; // position of ears - virtual Vector BodyTarget(const Vector &posSrc) = 0; // position to shoot at - - virtual int Illumination() = 0; - virtual BOOL FVisible(CBaseEntity *pEntity) = 0; - virtual BOOL FVisible(const Vector &vecOrigin) = 0; -public: - static CBaseEntity *Instance(edict_t *pent) { return (CBaseEntity *)GET_PRIVATE(pent ? pent : ENT(0)); } - static CBaseEntity *Instance(entvars_t *pev) { return Instance(ENT(pev)); } - static CBaseEntity *Instance(int offset) { return Instance(ENT(offset)); } - - edict_t *edict() { return ENT(pev); } - EOFFSET eoffset() { return OFFSET(pev); } - int entindex() { return ENTINDEX(edict()); } - int IsDormant() { return (pev->flags & FL_DORMANT) == FL_DORMANT; } - -public: - CCSEntity *m_pEntity; // NOTE: it was replaced on member "int *current_ammo" because it is useless. - - // We use this variables to store each ammo count. - float currentammo; - int maxammo_buckshot; - int ammo_buckshot; - int maxammo_9mm; - int ammo_9mm; - int maxammo_556nato; - int ammo_556nato; - int maxammo_556natobox; - int ammo_556natobox; - int maxammo_762nato; - int ammo_762nato; - int maxammo_45acp; - int ammo_45acp; - int maxammo_50ae; - int ammo_50ae; - int maxammo_338mag; - int ammo_338mag; - int maxammo_57mm; - int ammo_57mm; - int maxammo_357sig; - int ammo_357sig; - - // Special stuff for grenades and knife. - float m_flStartThrow; - float m_flReleaseThrow; - int m_iSwing; - - // client has left the game - bool has_disconnected; -}; - -class CPointEntity: public CBaseEntity { -public: - virtual void Spawn() = 0; - virtual int ObjectCaps() = 0; -}; - - -// generic Delay entity -class CBaseDelay: public CBaseEntity { -public: - virtual void KeyValue(KeyValueData *pkvd) = 0; - virtual int Save(CSave &save) = 0; - virtual int Restore(CRestore &restore) = 0; -public: - float m_flDelay; - int m_iszKillTarget; -}; - -class CBaseAnimating: public CBaseDelay { -public: - virtual int Save(CSave &save) = 0; - virtual int Restore(CRestore &restore) = 0; - virtual void HandleAnimEvent(MonsterEvent_t *pEvent) = 0; -public: - // animation needs - float m_flFrameRate; // computed FPS for current sequence - float m_flGroundSpeed; // computed linear movement rate for current sequence - float m_flLastEventCheck; // last time the event list was checked - BOOL m_fSequenceFinished; // flag set when StudioAdvanceFrame moves across a frame boundry - BOOL m_fSequenceLoops; // true if the sequence loops -}; - -// EHANDLE. Safe way to point to CBaseEntities who may die between frames -class EHANDLE { -public: - edict_t *Get(); - edict_t *Set(edict_t *pent); - - operator int(); - operator CBaseEntity*(); - operator CBasePlayer*(); - - CBaseEntity *operator=(CBaseEntity *pEntity); - CBaseEntity *operator->(); - -private: - edict_t *m_pent; - int m_serialnumber; -}; - -// generic Toggle entity. -class CBaseToggle: public CBaseAnimating { -public: - virtual void KeyValue(KeyValueData *pkvd) = 0; - virtual int Save(CSave &save) = 0; - virtual int Restore(CRestore &restore) = 0; - virtual int GetToggleState() = 0; - virtual float GetDelay() = 0; -public: - TOGGLE_STATE m_toggle_state; - float m_flActivateFinished; // like attack_finished, but for doors - float m_flMoveDistance; // how far a door should slide or rotate - float m_flWait; - float m_flLip; - float m_flTWidth; // for plats - float m_flTLength; // for plats - - Vector m_vecPosition1; - Vector m_vecPosition2; - Vector m_vecAngle1; - Vector m_vecAngle2; - - int m_cTriggersLeft; // trigger_counter only, # of activations remaining - float m_flHeight; - EHANDLE m_hActivator; - void (CBaseToggle::*m_pfnCallWhenMoveDone)(); - Vector m_vecFinalDest; - Vector m_vecFinalAngle; - - int m_bitsDamageInflict; // DMG_ damage type that the door or tigger does - - string_t m_sMaster; // If this button has a master switch, this is the targetname. - // A master switch must be of the multisource type. If all - // of the switches in the multisource have been triggered, then - // the button will be allowed to operate. Otherwise, it will be - // deactivated. -}; - -#include "basemonster.h" -#include "weapons.h" -#include "player.h" - -// Generic Button -class CBaseButton: public CBaseToggle { -public: - virtual void Spawn() = 0; - virtual void Precache() = 0; - virtual void Restart() = 0; - virtual void KeyValue(KeyValueData *pkvd) = 0; - virtual BOOL TakeDamage(entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType) = 0; - virtual int Save(CSave &save) = 0; - virtual int Restore(CRestore &restore) = 0; - virtual int ObjectCaps() = 0; // Buttons that don't take damage can be IMPULSE used -public: - BOOL m_fStayPushed; // button stays pushed in until touched again? - BOOL m_fRotating; // a rotating button? default is a sliding button. - - string_t m_strChangeTarget; // if this field is not null, this is an index into the engine string array. - // when this button is touched, it's target entity's TARGET field will be set - // to the button's ChangeTarget. This allows you to make a func_train switch paths, etc. - - locksound_t m_ls; // door lock sounds - - byte m_bLockedSound; // ordinals from entity selection - byte m_bLockedSentence; - byte m_bUnlockedSound; - byte m_bUnlockedSentence; - int m_sounds; -}; - -// MultiSouce - -#define MAX_MULTI_TARGETS 16 // maximum number of targets a single multi_manager entity may be assigned. -#define MS_MAX_TARGETS 32 - -class CMultiSource: public CPointEntity { -public: - virtual void Spawn() = 0; - virtual void Restart() = 0; - virtual void KeyValue(KeyValueData *pkvd) = 0; - virtual int Save(CSave &save) = 0; - virtual int Restore(CRestore &restore) = 0; - virtual int ObjectCaps() = 0; - virtual BOOL IsTriggered(CBaseEntity *pActivator) = 0; - virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) = 0; -public: - EHANDLE m_rgEntities[MS_MAX_TARGETS]; - int m_rgTriggered[MS_MAX_TARGETS]; - - int m_iTotal; - string_t m_globalstate; -}; - -#define SF_WORLD_DARK 0x0001 // Fade from black at startup -#define SF_WORLD_TITLE 0x0002 // Display game title at startup -#define SF_WORLD_FORCETEAM 0x0004 // Force teams - -// This spawns first when each level begins. -class CWorld: public CBaseEntity { -public: - virtual void Spawn() = 0; - virtual void Precache() = 0; - virtual void KeyValue(KeyValueData *pkvd) = 0; -}; - -// Inlines -inline edict_t *EHANDLE::Get() -{ - if (!m_pent || m_pent->serialnumber != m_serialnumber) - return NULL; - - return m_pent; -} - -inline edict_t *EHANDLE::Set(edict_t *pent) -{ - m_pent = pent; - if (pent) - m_serialnumber = pent->serialnumber; - - return pent; -} - -inline EHANDLE::operator int() -{ - return Get() != NULL; -} - -inline EHANDLE::operator CBaseEntity *() -{ - return (CBaseEntity *)GET_PRIVATE(Get()); -} - -inline EHANDLE::operator CBasePlayer *() -{ - return static_cast(GET_PRIVATE(Get())); -} - -inline CBaseEntity *EHANDLE::operator=(CBaseEntity *pEntity) -{ - if (pEntity != NULL) - { - m_pent = ENT(pEntity->pev); - if (m_pent) - m_serialnumber = m_pent->serialnumber; - } - else - { - m_pent = NULL; - m_serialnumber = 0; - } - - return pEntity; -} - -inline CBaseEntity *EHANDLE::operator->() -{ - return (CBaseEntity *)GET_PRIVATE(Get()); -} diff --git a/regamedll/extra/cssdk/dlls/cdll_dll.h b/regamedll/extra/cssdk/dlls/cdll_dll.h deleted file mode 100644 index cb0a2253..00000000 --- a/regamedll/extra/cssdk/dlls/cdll_dll.h +++ /dev/null @@ -1,127 +0,0 @@ -/* -* -* This program is free software; you can redistribute it and/or modify it -* under the terms of the GNU General Public License as published by the -* Free Software Foundation; either version 2 of the License, or (at -* your option) any later version. -* -* This program 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 -* General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* -*/ -#pragma once - -#define MAX_WEAPON_SLOTS 5 // hud item selection slots -#define MAX_ITEM_TYPES 6 // hud item selection slots - -#define MAX_ITEMS 4 // hard coded item types - -#define DEFAULT_FOV 90 // the default field of view - -#define HIDEHUD_WEAPONS (1<<0) -#define HIDEHUD_FLASHLIGHT (1<<1) -#define HIDEHUD_ALL (1<<2) -#define HIDEHUD_HEALTH (1<<3) -#define HIDEHUD_TIMER (1<<4) -#define HIDEHUD_MONEY (1<<5) -#define HIDEHUD_CROSSHAIR (1<<6) -#define HIDEHUD_OBSERVER_CROSSHAIR (1<<7) - -#define STATUSICON_HIDE 0 -#define STATUSICON_SHOW 1 -#define STATUSICON_FLASH 2 - -#define HUD_PRINTNOTIFY 1 -#define HUD_PRINTCONSOLE 2 -#define HUD_PRINTTALK 3 -#define HUD_PRINTCENTER 4 -#define HUD_PRINTRADIO 5 - -#define STATUS_NIGHTVISION_ON 1 -#define STATUS_NIGHTVISION_OFF 0 - -#define ITEM_STATUS_NIGHTVISION (1<<0) -#define ITEM_STATUS_DEFUSER (1<<1) - -#define SCORE_STATUS_DEAD (1<<0) -#define SCORE_STATUS_BOMB (1<<1) -#define SCORE_STATUS_VIP (1<<2) - -#define SIGNAL_BUY (1<<0) -#define SIGNAL_BOMB (1<<1) -#define SIGNAL_RESCUE (1<<2) -#define SIGNAL_ESCAPE (1<<3) -#define SIGNAL_VIPSAFETY (1<<4) - -// player data iuser3 -#define PLAYER_CAN_SHOOT (1<<0) -#define PLAYER_FREEZE_TIME_OVER (1<<1) -#define PLAYER_IN_BOMB_ZONE (1<<2) -#define PLAYER_HOLDING_SHIELD (1<<3) - -#define MENU_KEY_1 (1<<0) -#define MENU_KEY_2 (1<<1) -#define MENU_KEY_3 (1<<2) -#define MENU_KEY_4 (1<<3) -#define MENU_KEY_5 (1<<4) -#define MENU_KEY_6 (1<<5) -#define MENU_KEY_7 (1<<6) -#define MENU_KEY_8 (1<<7) -#define MENU_KEY_9 (1<<8) -#define MENU_KEY_0 (1<<9) - -#define MAX_AMMO_SLOTS 32 // not really slots - -#define HUD_PRINTNOTIFY 1 -#define HUD_PRINTCONSOLE 2 -#define HUD_PRINTTALK 3 -#define HUD_PRINTCENTER 4 - -#define WEAPON_SUIT 31 -#define WEAPON_ALLWEAPONS (~(1 << WEAPON_SUIT)) - -// custom enum -enum VGUIMenu -{ - VGUI_Menu_Team = 2, - VGUI_Menu_MapBriefing = 4, - - VGUI_Menu_Class_T = 26, - VGUI_Menu_Class_CT, - VGUI_Menu_Buy, - VGUI_Menu_Buy_Pistol, - VGUI_Menu_Buy_ShotGun, - VGUI_Menu_Buy_Rifle, - VGUI_Menu_Buy_SubMachineGun, - VGUI_Menu_Buy_MachineGun, - VGUI_Menu_Buy_Item, -}; - -// custom enum -enum VGUIMenuSlot -{ - VGUI_MenuSlot_Buy_Pistol = 1, - VGUI_MenuSlot_Buy_ShotGun, - VGUI_MenuSlot_Buy_SubMachineGun, - VGUI_MenuSlot_Buy_Rifle, - VGUI_MenuSlot_Buy_MachineGun, - VGUI_MenuSlot_Buy_PrimAmmo, - VGUI_MenuSlot_Buy_SecAmmo, - VGUI_MenuSlot_Buy_Item, -}; diff --git a/regamedll/extra/cssdk/dlls/client.h b/regamedll/extra/cssdk/dlls/client.h deleted file mode 100644 index f7f8a55f..00000000 --- a/regamedll/extra/cssdk/dlls/client.h +++ /dev/null @@ -1,97 +0,0 @@ -/* -* -* This program is free software; you can redistribute it and/or modify it -* under the terms of the GNU General Public License as published by the -* Free Software Foundation; either version 2 of the License, or (at -* your option) any later version. -* -* This program 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 -* General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* -*/ -#pragma once - -// custom enum -enum ChooseTeamMenuSlot -{ - MENU_SLOT_TEAM_UNDEFINED = -1, - - MENU_SLOT_TEAM_TERRORIST = 1, - MENU_SLOT_TEAM_CT, - MENU_SLOT_TEAM_VIP, - - MENU_SLOT_TEAM_RANDOM = 5, - MENU_SLOT_TEAM_SPECT -}; - -// custom enum -enum BuyItemMenuSlot -{ - MENU_SLOT_ITEM_VEST = 1, - MENU_SLOT_ITEM_VESTHELM, - MENU_SLOT_ITEM_FLASHGREN, - MENU_SLOT_ITEM_HEGREN, - MENU_SLOT_ITEM_SMOKEGREN, - MENU_SLOT_ITEM_NVG, - MENU_SLOT_ITEM_DEFUSEKIT, - MENU_SLOT_ITEM_SHIELD, -}; - -#define CS_NUM_SKIN 4 -#define CZ_NUM_SKIN 5 - -#define FIELD_ORIGIN0 0 -#define FIELD_ORIGIN1 1 -#define FIELD_ORIGIN2 2 - -#define FIELD_ANGLES0 3 -#define FIELD_ANGLES1 4 -#define FIELD_ANGLES2 5 - -#define CUSTOMFIELD_ORIGIN0 0 -#define CUSTOMFIELD_ORIGIN1 1 -#define CUSTOMFIELD_ORIGIN2 2 - -#define CUSTOMFIELD_ANGLES0 3 -#define CUSTOMFIELD_ANGLES1 4 -#define CUSTOMFIELD_ANGLES2 5 - -#define CUSTOMFIELD_SKIN 6 -#define CUSTOMFIELD_SEQUENCE 7 -#define CUSTOMFIELD_ANIMTIME 8 - -typedef struct -{ - float m_fTimeEnteredPVS; - -} ENTITYPVSSTATUS; - -struct PLAYERPVSSTATUS -{ - ENTITYPVSSTATUS m_Status[1380]; - int headnode; - int num_leafs; - short int leafnums[ MAX_ENT_LEAFS ]; -}; - -struct entity_field_alias_t -{ - char name[32]; - int field; -}; diff --git a/regamedll/extra/cssdk/dlls/csbot_dll.h b/regamedll/extra/cssdk/dlls/csbot_dll.h deleted file mode 100644 index 4620d053..00000000 --- a/regamedll/extra/cssdk/dlls/csbot_dll.h +++ /dev/null @@ -1,50 +0,0 @@ -/* -* -* This program is free software; you can redistribute it and/or modify it -* under the terms of the GNU General Public License as published by the -* Free Software Foundation; either version 2 of the License, or (at -* your option) any later version. -* -* This program 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 -* General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* -*/ -#pragma once - -#include "../game_shared/GameEvent.h" -#include "../game_shared/bot/bot_util.h" -#include "../game_shared/bot/simple_state_machine.h" -#include "../game_shared/steam_util.h" -#include "../game_shared/counter.h" -#include "../game_shared/bot/bot_manager.h" -#include "../game_shared/bot/bot_constants.h" -#include "../game_shared/bot/bot.h" -#include "../game_shared/shared_util.h" -#include "../game_shared/bot/bot_profile.h" - -#include "../game_shared/bot/improv.h" -#include "../game_shared/bot/nav.h" -#include "../game_shared/bot/nav_node.h" -#include "../game_shared/bot/nav_area.h" -#include "../game_shared/bot/nav_path.h" - -#include "../dlls/hostage/hostage.h" -#include "../dlls/hostage/hostage_localnav.h" - -#include "../dlls/bot/cs_bot.h" diff --git a/regamedll/extra/cssdk/dlls/decals.h b/regamedll/extra/cssdk/dlls/decals.h deleted file mode 100644 index 6f374327..00000000 --- a/regamedll/extra/cssdk/dlls/decals.h +++ /dev/null @@ -1,83 +0,0 @@ -/* -* -* This program is free software; you can redistribute it and/or modify it -* under the terms of the GNU General Public License as published by the -* Free Software Foundation; either version 2 of the License, or (at -* your option) any later version. -* -* This program 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 -* General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* -*/ -#pragma once - -enum decal_e -{ - DECAL_GUNSHOT1 = 0, - DECAL_GUNSHOT2, - DECAL_GUNSHOT3, - DECAL_GUNSHOT4, - DECAL_GUNSHOT5, - DECAL_LAMBDA1, - DECAL_LAMBDA2, - DECAL_LAMBDA3, - DECAL_LAMBDA4, - DECAL_LAMBDA5, - DECAL_LAMBDA6, - DECAL_SCORCH1, - DECAL_SCORCH2, - DECAL_BLOOD1, - DECAL_BLOOD2, - DECAL_BLOOD3, - DECAL_BLOOD4, - DECAL_BLOOD5, - DECAL_BLOOD6, - DECAL_YBLOOD1, - DECAL_YBLOOD2, - DECAL_YBLOOD3, - DECAL_YBLOOD4, - DECAL_YBLOOD5, - DECAL_YBLOOD6, - DECAL_GLASSBREAK1, - DECAL_GLASSBREAK2, - DECAL_GLASSBREAK3, - DECAL_BIGSHOT1, - DECAL_BIGSHOT2, - DECAL_BIGSHOT3, - DECAL_BIGSHOT4, - DECAL_BIGSHOT5, - DECAL_SPIT1, - DECAL_SPIT2, - DECAL_BPROOF1, // Bulletproof glass decal - DECAL_GARGSTOMP1, // Gargantua stomp crack - DECAL_SMALLSCORCH1, // Small scorch mark - DECAL_SMALLSCORCH2, // Small scorch mark - DECAL_SMALLSCORCH3, // Small scorch mark - DECAL_MOMMABIRTH, // Big momma birth splatter - DECAL_MOMMASPLAT, -}; - -typedef struct -{ - char *name; - int index; - -} DLL_DECALLIST; - -extern DLL_DECALLIST gDecals[42]; diff --git a/regamedll/extra/cssdk/dlls/doors.h b/regamedll/extra/cssdk/dlls/doors.h deleted file mode 100644 index 43ef05db..00000000 --- a/regamedll/extra/cssdk/dlls/doors.h +++ /dev/null @@ -1,93 +0,0 @@ -/* -* -* This program is free software; you can redistribute it and/or modify it -* under the terms of the GNU General Public License as published by the -* Free Software Foundation; either version 2 of the License, or (at -* your option) any later version. -* -* This program 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 -* General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* -*/ -#pragma once - -#define DOOR_SENTENCEWAIT 6 -#define DOOR_SOUNDWAIT 3 -#define BUTTON_SOUNDWAIT 0.5 - -#define SF_DOOR_ROTATE_Y 0 -#define SF_DOOR_START_OPEN 1 -#define SF_DOOR_ROTATE_BACKWARDS 2 -#define SF_DOOR_PASSABLE 8 -#define SF_DOOR_ONEWAY 16 -#define SF_DOOR_NO_AUTO_RETURN 32 -#define SF_DOOR_ROTATE_Z 64 -#define SF_DOOR_ROTATE_X 128 -#define SF_DOOR_USE_ONLY 256 // door must be opened by player's use button. -#define SF_DOOR_NOMONSTERS 512 // Monster can't open -#define SF_DOOR_TOUCH_ONLY_CLIENTS 1024 // Only clients can touch -#define SF_DOOR_SILENT 0x80000000 - -class CBaseDoor: public CBaseToggle { -public: - virtual void Spawn() = 0; - virtual void Precache() = 0; - virtual void Restart() = 0; - virtual void KeyValue(KeyValueData *pkvd) = 0; - virtual int Save(CSave &save) = 0; - virtual int Restore(CRestore &restore) = 0; - virtual int ObjectCaps() = 0; - virtual void SetToggleState(int state) = 0; - virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) = 0; - virtual void Blocked(CBaseEntity *pOther) = 0; -public: - byte m_bHealthValue; // some doors are medi-kit doors, they give players health - - byte m_bMoveSnd; // sound a door makes while moving - byte m_bStopSnd; // sound a door makes when it stops - - locksound_t m_ls; // door lock sounds - - byte m_bLockedSound; // ordinals from entity selection - byte m_bLockedSentence; - byte m_bUnlockedSound; - byte m_bUnlockedSentence; - - float m_lastBlockedTimestamp; -}; - -class CRotDoor: public CBaseDoor { -public: - virtual void Spawn() = 0; - virtual void Restart() = 0; - virtual void SetToggleState(int state) = 0; -}; - -class CMomentaryDoor: public CBaseToggle { -public: - virtual void Spawn() = 0; - virtual void Precache() = 0; - virtual void KeyValue(KeyValueData *pkvd) = 0; - virtual int Save(CSave &save) = 0; - virtual int Restore(CRestore &restore) = 0; - virtual int ObjectCaps() = 0; - virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) = 0; -public: - byte m_bMoveSnd; // sound a door makes while moving -}; diff --git a/regamedll/extra/cssdk/dlls/effects.h b/regamedll/extra/cssdk/dlls/effects.h deleted file mode 100644 index 5df1335e..00000000 --- a/regamedll/extra/cssdk/dlls/effects.h +++ /dev/null @@ -1,407 +0,0 @@ -/* -* -* This program is free software; you can redistribute it and/or modify it -* under the terms of the GNU General Public License as published by the -* Free Software Foundation; either version 2 of the License, or (at -* your option) any later version. -* -* This program 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 -* General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* -*/ -#pragma once - -#define SF_BEAM_STARTON 0x0001 -#define SF_BEAM_TOGGLE 0x0002 -#define SF_BEAM_RANDOM 0x0004 -#define SF_BEAM_RING 0x0008 -#define SF_BEAM_SPARKSTART 0x0010 -#define SF_BEAM_SPARKEND 0x0020 -#define SF_BEAM_DECALS 0x0040 -#define SF_BEAM_SHADEIN 0x0080 -#define SF_BEAM_SHADEOUT 0x0100 -#define SF_BEAM_TEMPORARY 0x8000 - -#define SF_GIBSHOOTER_REPEATABLE 1 -#define SF_FUNNEL_REVERSE 1 - -#define SF_BUBBLES_STARTOFF 0x0001 - -#define SF_BLOOD_RANDOM 0x0001 -#define SF_BLOOD_STREAM 0x0002 -#define SF_BLOOD_PLAYER 0x0004 -#define SF_BLOOD_DECAL 0x0008 - -#define SF_SHAKE_EVERYONE 0x0001 -#define SF_SHAKE_DISRUPT 0x0002 -#define SF_SHAKE_INAIR 0x0004 - -#define SF_FADE_IN 0x0001 -#define SF_FADE_MODULATE 0x0002 -#define SF_FADE_ONLYONE 0x0004 - -#define SF_SPRITE_STARTON 0x0001 -#define SF_SPRITE_ONCE 0x0002 -#define SF_SPRITE_TEMPORARY 0x8000 - -#define SF_MESSAGE_ONCE 0x0001 // Fade in, not out -#define SF_MESSAGE_ALL 0x0002 // Send to all clients - -class CSprite: public CPointEntity { -public: - virtual void Spawn() = 0; - virtual void Precache() = 0; - virtual void Restart() = 0; - virtual int Save(CSave &save) = 0; - virtual int Restore(CRestore &restore) = 0; - virtual int ObjectCaps() = 0; - virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) = 0; - -public: - void SetAttachment(edict_t *pEntity, int attachment) - { - if (pEntity != NULL) - { - pev->skin = ENTINDEX(pEntity); - pev->body = attachment; - pev->aiment = pEntity; - pev->movetype = MOVETYPE_FOLLOW; - } - } - - float Frames() const { return m_maxFrame; } - void SetTransparency(int rendermode, int r, int g, int b, int a, int fx) - { - pev->rendermode = rendermode; - pev->rendercolor.x = r; - pev->rendercolor.y = g; - pev->rendercolor.z = b; - pev->renderamt = a; - pev->renderfx = fx; - } - - void SetTexture(int spriteIndex) { pev->modelindex = spriteIndex; } - void SetScale(float scale) { pev->scale = scale; } - void SetColor(int r, int g, int b) { pev->rendercolor.x = r; pev->rendercolor.y = g; pev->rendercolor.z = b; } - void SetBrightness(int brightness) { pev->renderamt = brightness; } - void AnimateAndDie(float framerate) - { - SetThink(&CSprite::AnimateUntilDead); - pev->framerate = framerate; - pev->dmgtime = gpGlobals->time + (m_maxFrame / framerate); - pev->nextthink = gpGlobals->time; - } -private: - float m_lastTime; - float m_maxFrame; -}; - -class CBeam: public CBaseEntity { -public: - virtual void Spawn() = 0; - virtual void Precache() = 0; - virtual int ObjectCaps() = 0; - virtual Vector Center() = 0; -public: - void SetType(int type) { pev->rendermode = (pev->rendermode & 0xF0) | (type & 0x0F); } - void SetFlags(int flags) { pev->rendermode = (pev->rendermode & 0x0F) | (flags & 0xF0); } - void SetStartPos(const Vector &pos) { pev->origin = pos; } - void SetEndPos(const Vector &pos) { pev->angles = pos; } - - void SetStartEntity(int entityIndex); - void SetEndEntity(int entityIndex); - - void SetStartAttachment(int attachment) { pev->sequence = (pev->sequence & 0x0FFF) | ((attachment & 0xF) << 12); } - void SetEndAttachment(int attachment) { pev->skin = (pev->skin & 0x0FFF) | ((attachment & 0xF) << 12); } - void SetTexture(int spriteIndex) { pev->modelindex = spriteIndex; } - void SetWidth(int width) { pev->scale = width; } - void SetNoise(int amplitude) { pev->body = amplitude; } - void SetColor(int r, int g, int b) { pev->rendercolor.x = r; pev->rendercolor.y = g; pev->rendercolor.z = b; } - void SetBrightness(int brightness) { pev->renderamt = brightness; } - void SetFrame(float frame) { pev->frame = frame; } - void SetScrollRate(int speed) { pev->animtime = speed; } - int GetType() const { return pev->rendermode & 0x0F; } - int GetFlags() const { return pev->rendermode & 0xF0; } - int GetStartEntity() const { return pev->sequence & 0xFFF; } - int GetEndEntity() const { return pev->skin & 0xFFF; } - - const Vector &GetStartPos(); - const Vector &GetEndPos(); - - int GetTexture() const { return pev->modelindex; } - int GetWidth() const { return pev->scale; } - int GetNoise() const { return pev->body; } - int GetBrightness() const { return pev->renderamt; } - int GetFrame() const { return pev->frame; } - int GetScrollRate() const { return pev->animtime; } - - void LiveForTime(float time) - { - SetThink(&CBeam::SUB_Remove); - pev->nextthink = gpGlobals->time + time; - } - void BeamDamageInstant(TraceResult *ptr, float damage) - { - pev->dmg = damage; - pev->dmgtime = gpGlobals->time - 1; - BeamDamage(ptr); - } -}; - -class CLaser: public CBeam { -public: - virtual void Spawn() = 0; - virtual void Precache() = 0; - virtual void KeyValue(KeyValueData *pkvd) = 0; - virtual int Save(CSave &save) = 0; - virtual int Restore(CRestore &restore) = 0; - virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) = 0; -public: - CSprite *m_pSprite; - int m_iszSpriteName; - Vector m_firePosition; -}; - -class CBubbling: public CBaseEntity { -public: - virtual void Spawn() = 0; - virtual void Precache() = 0; - virtual void KeyValue(KeyValueData *pkvd) = 0; - virtual int Save(CSave &save) = 0; - virtual int Restore(CRestore &restore) = 0; - virtual int ObjectCaps() = 0; - virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) = 0; -public: - int m_density; - int m_frequency; - int m_bubbleModel; - int m_state; -}; - -class CLightning: public CBeam { -public: - virtual void Spawn() = 0; - virtual void Precache() = 0; - virtual void KeyValue(KeyValueData *pkvd) = 0; - virtual int Save(CSave &save) = 0; - virtual int Restore(CRestore &restore) = 0; - virtual void Activate() = 0; -public: - inline BOOL ServerSide() const - { - if (!m_life && !(pev->spawnflags & SF_BEAM_RING)) - return TRUE; - - return FALSE; - } -public: - int m_active; - int m_iszStartEntity; - int m_iszEndEntity; - float m_life; - int m_boltWidth; - int m_noiseAmplitude; - int m_brightness; - int m_speed; - float m_restrike; - int m_spriteTexture; - int m_iszSpriteName; - int m_frameStart; - float m_radius; -}; - -class CGlow: public CPointEntity { -public: - virtual void Spawn() = 0; - virtual int Save(CSave &save) = 0; - virtual int Restore(CRestore &restore) = 0; - virtual void Think() = 0; -public: - float m_lastTime; - float m_maxFrame; -}; - -class CBombGlow: public CSprite { -public: - virtual void Spawn() = 0; - virtual void Think() = 0; -public: - float m_lastTime; - float m_tmBeepPeriod; - bool m_bSetModel; -}; - -class CGibShooter: public CBaseDelay { -public: - virtual void Spawn() = 0; - virtual void Precache() = 0; - virtual void KeyValue(KeyValueData *pkvd) = 0; - virtual int Save(CSave &save) = 0; - virtual int Restore(CRestore &restore) = 0; - virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) = 0; - virtual CGib *CreateGib() = 0; -public: - int m_iGibs; - int m_iGibCapacity; - int m_iGibMaterial; - int m_iGibModelIndex; - - float m_flGibVelocity; - float m_flVariance; - float m_flGibLife; -}; - -class CEnvShooter: public CGibShooter { -public: - virtual void Precache() = 0; - virtual void KeyValue(KeyValueData *pkvd) = 0; - virtual CGib *CreateGib() = 0; -}; - -#define MAX_BEAM 24 - -class CTestEffect: public CBaseDelay { -public: - virtual void Spawn() = 0; - virtual void Precache() = 0; - virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) = 0; -public: - int m_iLoop; - int m_iBeam; - - CBeam *m_pBeam[MAX_BEAM]; - - float m_flBeamTime[MAX_BEAM]; - float m_flStartTime; -}; - -class CBlood: public CPointEntity { -public: - virtual void Spawn() = 0; - virtual void KeyValue(KeyValueData *pkvd) = 0; - virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) = 0; - -public: - int Color() const { return pev->impulse; } - float BloodAmount() const { return pev->dmg; } - - void SetColor(int color) { pev->impulse = color; } - void SetBloodAmount(float amount) { pev->dmg = amount; } -}; - -class CShake: public CPointEntity { -public: - virtual void Spawn() = 0; - virtual void KeyValue(KeyValueData *pkvd) = 0; - virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) = 0; -public: - float Amplitude() const { return pev->scale; } - float Frequency() const { return pev->dmg_save; } - float Duration() const { return pev->dmg_take; } - float Radius() const { return pev->dmg; } - - void SetAmplitude(float amplitude) { pev->scale = amplitude; } - void SetFrequency(float frequency) { pev->dmg_save = frequency; } - void SetDuration(float duration) { pev->dmg_take = duration; } - void SetRadius(float radius) { pev->dmg = radius; } -}; - -class CFade: public CPointEntity { -public: - virtual void Spawn() = 0; - virtual void KeyValue(KeyValueData *pkvd) = 0; - virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) = 0; -public: - float Duration() const { return pev->dmg_take; } - float HoldTime() const { return pev->dmg_save; } - - void SetDuration(float duration) { pev->dmg_take = duration; } - void SetHoldTime(float hold) { pev->dmg_save = hold; } -}; - -class CMessage: public CPointEntity { -public: - virtual void Spawn() = 0; - virtual void Precache() = 0; - virtual void KeyValue(KeyValueData *pkvd) = 0; - virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) = 0; -}; - -class CEnvFunnel: public CBaseDelay { -public: - virtual void Spawn() = 0; - virtual void Precache() = 0; - virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) = 0; -public: - int m_iSprite; -}; - -class CEnvBeverage: public CBaseDelay { -public: - virtual void Spawn() = 0; - virtual void Precache() = 0; - virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) = 0; -}; - -class CItemSoda: public CBaseEntity { -public: - virtual void Spawn() = 0; - virtual void Precache() = 0; -}; - -// Inlines -inline void CBeam::SetStartEntity(int entityIndex) -{ - pev->sequence = (entityIndex & 0x0FFF) | ((pev->sequence & 0xF000) << 12); - pev->owner = INDEXENT(entityIndex); -} - -inline void CBeam::SetEndEntity(int entityIndex) -{ - pev->skin = (entityIndex & 0x0FFF) | ((pev->skin & 0xF000) << 12); - pev->aiment = INDEXENT(entityIndex); -} - -inline const Vector &CBeam::GetStartPos() -{ - if (GetType() == BEAM_ENTS) - { - edict_t *pent = INDEXENT(GetStartEntity()); - return pent->v.origin; - } - - return pev->origin; -} - -inline const Vector &CBeam::GetEndPos() -{ - int type = GetType(); - if (type == BEAM_POINTS || type == BEAM_HOSE) - { - return pev->angles; - } - - edict_t *pent = INDEXENT(GetEndEntity()); - if (pent != NULL) - { - return pent->v.origin; - } - - return pev->angles; -} diff --git a/regamedll/extra/cssdk/dlls/enginecallback.h b/regamedll/extra/cssdk/dlls/enginecallback.h deleted file mode 100644 index dbe3e718..00000000 --- a/regamedll/extra/cssdk/dlls/enginecallback.h +++ /dev/null @@ -1,178 +0,0 @@ -/* -* -* This program is free software; you can redistribute it and/or modify it -* under the terms of the GNU General Public License as published by the -* Free Software Foundation; either version 2 of the License, or (at -* your option) any later version. -* -* This program 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 -* General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* -*/ -#pragma once - -#include "event_flags.h" - -// Must be provided by user of this code -extern enginefuncs_t g_engfuncs; - -// The actual engine callbacks -#define GETPLAYERUSERID (*g_engfuncs.pfnGetPlayerUserId) -#define PRECACHE_MODEL (*g_engfuncs.pfnPrecacheModel) -#define PRECACHE_SOUND (*g_engfuncs.pfnPrecacheSound) -#define PRECACHE_GENERIC (*g_engfuncs.pfnPrecacheGeneric) -#define SET_MODEL (*g_engfuncs.pfnSetModel) -#define MODEL_INDEX (*g_engfuncs.pfnModelIndex) -#define MODEL_FRAMES (*g_engfuncs.pfnModelFrames) -#define SET_SIZE (*g_engfuncs.pfnSetSize) -#define CHANGE_LEVEL (*g_engfuncs.pfnChangeLevel) -#define GET_SPAWN_PARMS (*g_engfuncs.pfnGetSpawnParms) -#define SAVE_SPAWN_PARMS (*g_engfuncs.pfnSaveSpawnParms) -#define VEC_TO_YAW (*g_engfuncs.pfnVecToYaw) -#define VEC_TO_ANGLES (*g_engfuncs.pfnVecToAngles) -#define MOVE_TO_ORIGIN (*g_engfuncs.pfnMoveToOrigin) -#define oldCHANGE_YAW (*g_engfuncs.pfnChangeYaw) -#define CHANGE_PITCH (*g_engfuncs.pfnChangePitch) -#define MAKE_VECTORS (*g_engfuncs.pfnMakeVectors) -#define CREATE_ENTITY (*g_engfuncs.pfnCreateEntity) -#define REMOVE_ENTITY (*g_engfuncs.pfnRemoveEntity) -#define CREATE_NAMED_ENTITY (*g_engfuncs.pfnCreateNamedEntity) -#define MAKE_STATIC (*g_engfuncs.pfnMakeStatic) -#define ENT_IS_ON_FLOOR (*g_engfuncs.pfnEntIsOnFloor) -#define DROP_TO_FLOOR (*g_engfuncs.pfnDropToFloor) -#define WALK_MOVE (*g_engfuncs.pfnWalkMove) -#define SET_ORIGIN (*g_engfuncs.pfnSetOrigin) -#define EMIT_SOUND_DYN2 (*g_engfuncs.pfnEmitSound) -#define BUILD_SOUND_MSG (*g_engfuncs.pfnBuildSoundMsg) -#define TRACE_LINE (*g_engfuncs.pfnTraceLine) -#define TRACE_TOSS (*g_engfuncs.pfnTraceToss) -#define TRACE_MONSTER_HULL (*g_engfuncs.pfnTraceMonsterHull) -#define TRACE_HULL (*g_engfuncs.pfnTraceHull) -#define TRACE_MODEL (*g_engfuncs.pfnTraceModel) -#define GET_AIM_VECTOR (*g_engfuncs.pfnGetAimVector) -#define SERVER_COMMAND (*g_engfuncs.pfnServerCommand) -#define SERVER_EXECUTE (*g_engfuncs.pfnServerExecute) -#define CLIENT_COMMAND (*g_engfuncs.pfnClientCommand) -#define PARTICLE_EFFECT (*g_engfuncs.pfnParticleEffect) -#define LIGHT_STYLE (*g_engfuncs.pfnLightStyle) -#define DECAL_INDEX (*g_engfuncs.pfnDecalIndex) -#define POINT_CONTENTS (*g_engfuncs.pfnPointContents) -#define CRC32_INIT (*g_engfuncs.pfnCRC32_Init) -#define CRC32_PROCESS_BUFFER (*g_engfuncs.pfnCRC32_ProcessBuffer) -#define CRC32_PROCESS_BYTE (*g_engfuncs.pfnCRC32_ProcessByte) -#define CRC32_FINAL (*g_engfuncs.pfnCRC32_Final) -#define RANDOM_LONG (*g_engfuncs.pfnRandomLong) -#define RANDOM_FLOAT (*g_engfuncs.pfnRandomFloat) -#define ADD_SERVER_COMMAND (*g_engfuncs.pfnAddServerCommand) -#define SET_CLIENT_LISTENING (*g_engfuncs.pfnVoice_SetClientListening) -#define GETPLAYERAUTHID (*g_engfuncs.pfnGetPlayerAuthId) -#define GET_FILE_SIZE (*g_engfuncs.pfnGetFileSize) -#define GET_APPROX_WAVE_PLAY_LEN (*g_engfuncs.pfnGetApproxWavePlayLen) -#define IS_CAREER_MATCH (*g_engfuncs.pfnIsCareerMatch) -#define GET_LOCALIZED_STRING_LENGTH (*g_engfuncs.pfnGetLocalizedStringLength) -#define REGISTER_TUTOR_MESSAGE_SHOWN (*g_engfuncs.pfnRegisterTutorMessageShown) -#define GET_TIMES_TUTOR_MESSAGE_SHOWN (*g_engfuncs.pfnGetTimesTutorMessageShown) -#define ENG_CHECK_PARM (*g_engfuncs.pfnEngCheckParm) - -inline void MESSAGE_BEGIN(int msg_dest, int msg_type, const float *pOrigin = NULL, edict_t *ed = NULL) { (*g_engfuncs.pfnMessageBegin)(msg_dest, msg_type, pOrigin, ed); } - -inline void *GET_PRIVATE(edict_t *pent) -{ - if (pent) - return pent->pvPrivateData; - return NULL; -} - -#define MESSAGE_END (*g_engfuncs.pfnMessageEnd) -#define WRITE_BYTE (*g_engfuncs.pfnWriteByte) -#define WRITE_CHAR (*g_engfuncs.pfnWriteChar) -#define WRITE_SHORT (*g_engfuncs.pfnWriteShort) -#define WRITE_LONG (*g_engfuncs.pfnWriteLong) -#define WRITE_ANGLE (*g_engfuncs.pfnWriteAngle) -#define WRITE_COORD (*g_engfuncs.pfnWriteCoord) -#define WRITE_STRING (*g_engfuncs.pfnWriteString) -#define WRITE_ENTITY (*g_engfuncs.pfnWriteEntity) -#define CVAR_REGISTER (*g_engfuncs.pfnCVarRegister) -#define CVAR_GET_FLOAT (*g_engfuncs.pfnCVarGetFloat) -#define CVAR_GET_STRING (*g_engfuncs.pfnCVarGetString) -#define CVAR_SET_FLOAT (*g_engfuncs.pfnCVarSetFloat) -#define CVAR_SET_STRING (*g_engfuncs.pfnCVarSetString) -#define CVAR_GET_POINTER (*g_engfuncs.pfnCVarGetPointer) -#define ALERT (*g_engfuncs.pfnAlertMessage) -#define ENGINE_FPRINTF (*g_engfuncs.pfnEngineFprintf) -#define ALLOC_PRIVATE (*g_engfuncs.pfnPvAllocEntPrivateData) -#define FREE_PRIVATE (*g_engfuncs.pfnFreeEntPrivateData) -//#define STRING (*g_engfuncs.pfnSzFromIndex) -#define ALLOC_STRING (*g_engfuncs.pfnAllocString) -#define FIND_ENTITY_BY_STRING (*g_engfuncs.pfnFindEntityByString) -#define GETENTITYILLUM (*g_engfuncs.pfnGetEntityIllum) -#define FIND_ENTITY_IN_SPHERE (*g_engfuncs.pfnFindEntityInSphere) -#define FIND_CLIENT_IN_PVS (*g_engfuncs.pfnFindClientInPVS) -#define FIND_ENTITY_IN_PVS (*g_engfuncs.pfnEntitiesInPVS) -#define EMIT_AMBIENT_SOUND (*g_engfuncs.pfnEmitAmbientSound) -#define GET_MODEL_PTR (*g_engfuncs.pfnGetModelPtr) -#define REG_USER_MSG (*g_engfuncs.pfnRegUserMsg) -#define GET_BONE_POSITION (*g_engfuncs.pfnGetBonePosition) -#define FUNCTION_FROM_NAME (*g_engfuncs.pfnFunctionFromName) -#define NAME_FOR_FUNCTION (*g_engfuncs.pfnNameForFunction) -#define TRACE_TEXTURE (*g_engfuncs.pfnTraceTexture) -#define CLIENT_PRINTF (*g_engfuncs.pfnClientPrintf) -#define SERVER_PRINT (*g_engfuncs.pfnServerPrint) -#define CMD_ARGS (*g_engfuncs.pfnCmd_Args) -#define CMD_ARGC (*g_engfuncs.pfnCmd_Argc) -#define CMD_ARGV (*g_engfuncs.pfnCmd_Argv) -#define GET_ATTACHMENT (*g_engfuncs.pfnGetAttachment) -#define SET_VIEW (*g_engfuncs.pfnSetView) -#define SET_CROSSHAIRANGLE (*g_engfuncs.pfnCrosshairAngle) -#define LOAD_FILE_FOR_ME (*g_engfuncs.pfnLoadFileForMe) -#define FREE_FILE (*g_engfuncs.pfnFreeFile) -#define END_SECTION (*g_engfuncs.pfnEndSection) -#define COMPARE_FILE_TIME (*g_engfuncs.pfnCompareFileTime) -#define GET_GAME_DIR (*g_engfuncs.pfnGetGameDir) -#define SET_CLIENT_MAXSPEED (*g_engfuncs.pfnSetClientMaxspeed) -#define CREATE_FAKE_CLIENT (*g_engfuncs.pfnCreateFakeClient) -#define PLAYER_RUN_MOVE (*g_engfuncs.pfnRunPlayerMove) -#define NUMBER_OF_ENTITIES (*g_engfuncs.pfnNumberOfEntities) -#define GET_INFO_BUFFER (*g_engfuncs.pfnGetInfoKeyBuffer) -#define GET_KEY_VALUE (*g_engfuncs.pfnInfoKeyValue) -#define SET_KEY_VALUE (*g_engfuncs.pfnSetKeyValue) -#define SET_CLIENT_KEY_VALUE (*g_engfuncs.pfnSetClientKeyValue) -#define IS_MAP_VALID (*g_engfuncs.pfnIsMapValid) -#define STATIC_DECAL (*g_engfuncs.pfnStaticDecal) -#define IS_DEDICATED_SERVER (*g_engfuncs.pfnIsDedicatedServer) -#define PRECACHE_EVENT (*g_engfuncs.pfnPrecacheEvent) -#define PLAYBACK_EVENT_FULL (*g_engfuncs.pfnPlaybackEvent) -#define ENGINE_SET_PVS (*g_engfuncs.pfnSetFatPVS) -#define ENGINE_SET_PAS (*g_engfuncs.pfnSetFatPAS) -#define ENGINE_CHECK_VISIBILITY (*g_engfuncs.pfnCheckVisibility) -#define DELTA_SET (*g_engfuncs.pfnDeltaSetField) -#define DELTA_UNSET (*g_engfuncs.pfnDeltaUnsetField) -#define DELTA_ADDENCODER (*g_engfuncs.pfnDeltaAddEncoder) -#define ENGINE_CURRENT_PLAYER (*g_engfuncs.pfnGetCurrentPlayer) -#define ENGINE_CANSKIP (*g_engfuncs.pfnCanSkipPlayer) -#define DELTA_FINDFIELD (*g_engfuncs.pfnDeltaFindField) -#define DELTA_SETBYINDEX (*g_engfuncs.pfnDeltaSetFieldByIndex) -#define DELTA_UNSETBYINDEX (*g_engfuncs.pfnDeltaUnsetFieldByIndex) -#define REMOVE_KEY_VALUE (*g_engfuncs.pfnInfo_RemoveKey) -#define SET_PHYSICS_KEY_VALUE (*g_engfuncs.pfnSetPhysicsKeyValue) -#define ENGINE_GETPHYSINFO (*g_engfuncs.pfnGetPhysicsInfoString) -#define ENGINE_SETGROUPMASK (*g_engfuncs.pfnSetGroupMask) -#define ENGINE_INSTANCE_BASELINE (*g_engfuncs.pfnCreateInstancedBaseline) -#define ENGINE_FORCE_UNMODIFIED (*g_engfuncs.pfnForceUnmodified) -#define PLAYER_CNX_STATS (*g_engfuncs.pfnGetPlayerStats) diff --git a/regamedll/extra/cssdk/dlls/explode.h b/regamedll/extra/cssdk/dlls/explode.h deleted file mode 100644 index 1a2f7a09..00000000 --- a/regamedll/extra/cssdk/dlls/explode.h +++ /dev/null @@ -1,55 +0,0 @@ -/* -* -* This program is free software; you can redistribute it and/or modify it -* under the terms of the GNU General Public License as published by the -* Free Software Foundation; either version 2 of the License, or (at -* your option) any later version. -* -* This program 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 -* General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* -*/ -#pragma once - -#define SF_ENVEXPLOSION_NODAMAGE (1<<0) // when set, ENV_EXPLOSION will not actually inflict damage -#define SF_ENVEXPLOSION_REPEATABLE (1<<1) // can this entity be refired? -#define SF_ENVEXPLOSION_NOFIREBALL (1<<2) // don't draw the fireball -#define SF_ENVEXPLOSION_NOSMOKE (1<<3) // don't draw the smoke -#define SF_ENVEXPLOSION_NODECAL (1<<4) // don't make a scorch mark -#define SF_ENVEXPLOSION_NOSPARKS (1<<5) // don't make a scorch mark - -class CShower: public CBaseEntity { -public: - virtual void Spawn() = 0; - virtual int ObjectCaps() = 0; - virtual void Think() = 0; - virtual void Touch(CBaseEntity *pOther) = 0; -}; - -class CEnvExplosion: public CBaseMonster { -public: - virtual void Spawn() = 0; - virtual void KeyValue(KeyValueData *pkvd) = 0; - virtual int Save(CSave &save) = 0; - virtual int Restore(CRestore &restore) = 0; - virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) = 0; -public: - int m_iMagnitude; - int m_spriteScale; -}; diff --git a/regamedll/extra/cssdk/dlls/extdef.h b/regamedll/extra/cssdk/dlls/extdef.h deleted file mode 100644 index 383a668e..00000000 --- a/regamedll/extra/cssdk/dlls/extdef.h +++ /dev/null @@ -1,113 +0,0 @@ -/* -* -* This program is free software; you can redistribute it and/or modify it -* under the terms of the GNU General Public License as published by the -* Free Software Foundation; either version 2 of the License, or (at -* your option) any later version. -* -* This program 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 -* General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* -*/ -#pragma once - -#include "regamedll_const.h" - -#undef DLLEXPORT -#ifdef _WIN32 - // Attributes to specify an "exported" function, visible from outside the - // DLL. - #define DLLEXPORT __declspec(dllexport) - // WINAPI should be provided in the windows compiler headers. - // It's usually defined to something like "__stdcall". - - #define NOINLINE __declspec(noinline) -#else - #define DLLEXPORT __attribute__((visibility("default"))) - #define WINAPI /* */ - #define NOINLINE __attribute__((noinline)) -#endif // _WIN32 - -// Manual branch optimization for GCC 3.0.0 and newer -#if !defined(__GNUC__) || __GNUC__ < 3 - #define likely(x) (x) - #define unlikely(x) (x) -#else - #define likely(x) __builtin_expect(!!(x), 1) - #define unlikely(x) __builtin_expect(!!(x), 0) -#endif - -// Simplified macro for declaring/defining exported DLL functions. They -// need to be 'extern "C"' so that the C++ compiler enforces parameter -// type-matching, rather than considering routines with mis-matched -// arguments/types to be overloaded functions... -// -// AFAIK, this is os-independent, but it's included here in osdep.h where -// DLLEXPORT is defined, for convenience. -#define C_DLLEXPORT extern "C" DLLEXPORT - -enum hash_types_e { CLASSNAME }; - -// Things that toggle (buttons/triggers/doors) need this -enum TOGGLE_STATE { TS_AT_TOP, TS_AT_BOTTOM, TS_GOING_UP, TS_GOING_DOWN }; - -typedef struct hash_item_s -{ - entvars_t *pev; - struct hash_item_s *next; - struct hash_item_s *lastHash; - int pevIndex; - -} hash_item_t; - -typedef struct locksounds -{ - string_t sLockedSound; - string_t sLockedSentence; - string_t sUnlockedSound; - string_t sUnlockedSentence; - int iLockedSentence; - int iUnlockedSentence; - float flwaitSound; - float flwaitSentence; - byte bEOFLocked; - byte bEOFUnlocked; - -} locksound_t; - -typedef struct hudtextparms_s -{ - float x; - float y; - int effect; - byte r1,g1,b1,a1; - byte r2,g2,b2,a2; - float fadeinTime; - float fadeoutTime; - float holdTime; - float fxTime; - int channel; - -} hudtextparms_t; - -enum USE_TYPE { USE_OFF, USE_ON, USE_SET, USE_TOGGLE }; -enum TRAIN_CODE { TRAIN_SAFE, TRAIN_BLOCKING, TRAIN_FOLLOWING }; -enum IGNORE_MONSTERS { ignore_monsters = 1, dont_ignore_monsters = 0, missile = 2 }; -enum IGNORE_GLASS { ignore_glass = 1, dont_ignore_glass = 0 }; -enum { point_hull = 0, human_hull = 1, large_hull = 2, head_hull = 3 }; diff --git a/regamedll/extra/cssdk/dlls/func_break.h b/regamedll/extra/cssdk/dlls/func_break.h deleted file mode 100644 index 51099d52..00000000 --- a/regamedll/extra/cssdk/dlls/func_break.h +++ /dev/null @@ -1,120 +0,0 @@ -/* -* -* This program is free software; you can redistribute it and/or modify it -* under the terms of the GNU General Public License as published by the -* Free Software Foundation; either version 2 of the License, or (at -* your option) any later version. -* -* This program 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 -* General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* -*/ -#pragma once - -// this many shards spawned when breakable objects break; -#define NUM_SHARDS 6 - -// func breakable -#define SF_BREAK_TRIGGER_ONLY 1 // may only be broken by trigger -#define SF_BREAK_TOUCH 2 // can be 'crashed through' by running player (plate glass) -#define SF_BREAK_PRESSURE 4 // can be broken by a player standing on it -#define SF_BREAK_CROWBAR 256 // instant break if hit with crowbar - -// func_pushable (it's also func_breakable, so don't collide with those flags) -#define SF_PUSH_BREAKABLE 128 - -typedef enum -{ - expRandom = 0, - expDirected, - -} Explosions; - -typedef enum -{ - matGlass = 0, - matWood, - matMetal, - matFlesh, - matCinderBlock, - matCeilingTile, - matComputer, - matUnbreakableGlass, - matRocks, - matNone, - matLastMaterial, - -} Materials; - -class CBreakable: public CBaseDelay { -public: - // basic functions - virtual void Spawn() = 0; - virtual void Precache() = 0; - virtual void Restart() = 0; - virtual void KeyValue(KeyValueData *pkvd) = 0; - virtual int Save(CSave &save) = 0; - virtual int Restore(CRestore &restore) = 0; - virtual int ObjectCaps() = 0; - - // To spark when hit - virtual void TraceAttack(entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType) = 0; - - // breakables use an overridden takedamage - virtual BOOL TakeDamage(entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType) = 0; - - virtual int DamageDecal(int bitsDamageType) = 0; - virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) = 0; - -public: - BOOL Explodable() const { return ExplosionMagnitude() > 0; } - int ExplosionMagnitude() const { return pev->impulse; } - void ExplosionSetMagnitude(int magnitude) { pev->impulse = magnitude; } - -public: - Materials m_Material; - Explosions m_Explosion; - int m_idShard; - float m_angle; - int m_iszGibModel; - int m_iszSpawnObject; - float m_flHealth; -}; - -class CPushable: public CBreakable { -public: - virtual void Spawn() = 0; - virtual void Precache() = 0; - virtual void Restart() = 0; - virtual void KeyValue(KeyValueData *pkvd) = 0; - virtual int Save(CSave &save) = 0; - virtual int Restore(CRestore &restore) = 0; - virtual int ObjectCaps() = 0; - virtual BOOL TakeDamage(entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType) = 0; - virtual void Touch(CBaseEntity *pOther) = 0; - virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) = 0; - -public: - float MaxSpeed() const { return m_maxSpeed; } - -public: - int m_lastSound; - float m_maxSpeed; - float m_soundTime; -}; \ No newline at end of file diff --git a/regamedll/extra/cssdk/dlls/func_tank.h b/regamedll/extra/cssdk/dlls/func_tank.h deleted file mode 100644 index 6ae26faa..00000000 --- a/regamedll/extra/cssdk/dlls/func_tank.h +++ /dev/null @@ -1,159 +0,0 @@ -/* -* -* This program is free software; you can redistribute it and/or modify it -* under the terms of the GNU General Public License as published by the -* Free Software Foundation; either version 2 of the License, or (at -* your option) any later version. -* -* This program 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 -* General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* -*/ -#pragma once - -#define SF_TANK_ACTIVE 0x0001 -#define SF_TANK_PLAYER 0x0002 -#define SF_TANK_HUMANS 0x0004 -#define SF_TANK_ALIENS 0x0008 -#define SF_TANK_LINEOFSIGHT 0x0010 -#define SF_TANK_CANCONTROL 0x0020 -#define SF_TANK_SOUNDON 0x8000 - -enum TANKBULLET -{ - TANK_BULLET_NONE = 0, // Custom damage - TANK_BULLET_9MM, // env_laser (duration is 0.5 rate of fire) - TANK_BULLET_MP5, // rockets - TANK_BULLET_12MM, // explosion? -}; - -class CFuncTank: public CBaseEntity { -public: - virtual void Spawn() = 0; - virtual void Precache() = 0; - virtual void KeyValue(KeyValueData *pkvd) = 0; - virtual int Save(CSave &save) = 0; - virtual int Restore(CRestore &restore) = 0; - - // Bmodels don't go across transitions - virtual int ObjectCaps() = 0; - virtual BOOL OnControls(entvars_t *pevTest) = 0; - virtual void Think() = 0; - virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) = 0; - virtual void Fire(const Vector &barrelEnd, const Vector &forward, entvars_t *pevAttacker) = 0; - virtual Vector UpdateTargetPosition(CBaseEntity *pTarget) = 0; -public: - BOOL IsActive() const { return (pev->spawnflags & SF_TANK_ACTIVE) == SF_TANK_ACTIVE; } - void TankActivate() - { - pev->spawnflags |= SF_TANK_ACTIVE; - pev->nextthink = pev->ltime + 0.1f; - m_fireLast = 0.0f; - } - void TankDeactivate() - { - pev->spawnflags &= ~SF_TANK_ACTIVE; - m_fireLast = 0.0f; - StopRotSound(); - } - - BOOL CanFire() const { return (gpGlobals->time - m_lastSightTime) < m_persist; } - Vector BarrelPosition() - { - Vector forward, right, up; - UTIL_MakeVectorsPrivate(pev->angles, forward, right, up); - return pev->origin + (forward * m_barrelPos.x) + (right * m_barrelPos.y) + (up * m_barrelPos.z); - } -protected: - CBasePlayer *m_pController; - float m_flNextAttack; - Vector m_vecControllerUsePos; - - float m_yawCenter; // "Center" yaw - float m_yawRate; // Max turn rate to track targets - float m_yawRange; // Range of turning motion (one-sided: 30 is +/- 30 degress from center) - // Zero is full rotation - - float m_yawTolerance; // Tolerance angle - - float m_pitchCenter; // "Center" pitch - float m_pitchRate; // Max turn rate on pitch - float m_pitchRange; // Range of pitch motion as above - float m_pitchTolerance; // Tolerance angle - - float m_fireLast; // Last time I fired - float m_fireRate; // How many rounds/second - float m_lastSightTime; // Last time I saw target - float m_persist; // Persistence of firing (how long do I shoot when I can't see) - float m_minRange; // Minimum range to aim/track - float m_maxRange; // Max range to aim/track - - Vector m_barrelPos; // Length of the freakin barrel - float m_spriteScale; // Scale of any sprites we shoot - int m_iszSpriteSmoke; - int m_iszSpriteFlash; - TANKBULLET m_bulletType; // Bullet type - int m_iBulletDamage; // 0 means use Bullet type's default damage - - Vector m_sightOrigin; // Last sight of target - int m_spread; // firing spread - int m_iszMaster; // Master entity (game_team_master or multisource) -}; - -class CFuncTankGun: public CFuncTank { -public: - virtual void Fire(const Vector &barrelEnd, const Vector &forward, entvars_t *pevAttacker) = 0; -}; - -class CFuncTankLaser: public CFuncTank { -public: - virtual void KeyValue(KeyValueData *pkvd) = 0; - virtual int Save(CSave &save) = 0; - virtual int Restore(CRestore &restore) = 0; - virtual void Activate() = 0; - virtual void Think() = 0; - virtual void Fire(const Vector &barrelEnd, const Vector &forward, entvars_t *pevAttacker) = 0; -private: - CLaser *m_pLaser; - float m_laserTime; -}; - -class CFuncTankRocket: public CFuncTank { -public: - virtual void Precache() = 0; - virtual void Fire(const Vector &barrelEnd, const Vector &forward, entvars_t *pevAttacker) = 0; -}; - -class CFuncTankMortar: public CFuncTank { -public: - virtual void KeyValue(KeyValueData *pkvd) = 0; - virtual void Fire(const Vector &barrelEnd, const Vector &forward, entvars_t *pevAttacker) = 0; -}; - -class CFuncTankControls: public CBaseEntity { -public: - virtual void Spawn() = 0; - virtual int Save(CSave &save) = 0; - virtual int Restore(CRestore &restore) = 0; - virtual int ObjectCaps() = 0; - virtual void Think() = 0; - virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) = 0; -public: - CFuncTank *m_pTank; -}; diff --git a/regamedll/extra/cssdk/dlls/gamerules.h b/regamedll/extra/cssdk/dlls/gamerules.h deleted file mode 100644 index 56e1fea1..00000000 --- a/regamedll/extra/cssdk/dlls/gamerules.h +++ /dev/null @@ -1,688 +0,0 @@ -/* -* -* This program is free software; you can redistribute it and/or modify it -* under the terms of the GNU General Public License as published by the -* Free Software Foundation; either version 2 of the License, or (at -* your option) any later version. -* -* This program 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 -* General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* -*/ -#pragma once - -#include "voice_gamemgr.h" - -#define MAX_RULE_BUFFER 1024 -#define MAX_VOTE_MAPS 100 -#define MAX_VIP_QUEUES 5 - -#define MAX_BOMB_RADIUS 2048 - -#define ITEM_RESPAWN_TIME 30 -#define WEAPON_RESPAWN_TIME 20 -#define AMMO_RESPAWN_TIME 20 - -// longest the intermission can last, in seconds -#define MAX_INTERMISSION_TIME 120 - -// when we are within this close to running out of entities, items -// marked with the ITEM_FLAG_LIMITINWORLD will delay their respawn -#define ENTITY_INTOLERANCE 100 - -#define MAX_MOTD_CHUNK 60 -#define MAX_MOTD_LENGTH 1536 // (MAX_MOTD_CHUNK * 4) - -// custom enum -#define WINNER_NONE 0 -#define WINNER_DRAW 1 - -enum -{ - WINSTATUS_CTS = 1, - WINSTATUS_TERRORISTS, - WINSTATUS_DRAW, -}; - -// custom enum -// used for EndRoundMessage() logged messages -enum ScenarioEventEndRound -{ - ROUND_NONE, - ROUND_TARGET_BOMB, - ROUND_VIP_ESCAPED, - ROUND_VIP_ASSASSINATED, - ROUND_TERRORISTS_ESCAPED, - ROUND_CTS_PREVENT_ESCAPE, - ROUND_ESCAPING_TERRORISTS_NEUTRALIZED, - ROUND_BOMB_DEFUSED, - ROUND_CTS_WIN, - ROUND_TERRORISTS_WIN, - ROUND_END_DRAW, - ROUND_ALL_HOSTAGES_RESCUED, - ROUND_TARGET_SAVED, - ROUND_HOSTAGE_NOT_RESCUED, - ROUND_TERRORISTS_NOT_ESCAPED, - ROUND_VIP_NOT_ESCAPED, - ROUND_GAME_COMMENCE, - ROUND_GAME_RESTART, - ROUND_GAME_OVER -}; - -enum RewardRules -{ - RR_CTS_WIN, - RR_TERRORISTS_WIN, - RR_TARGET_BOMB, - RR_VIP_ESCAPED, - RR_VIP_ASSASSINATED, - RR_TERRORISTS_ESCAPED, - RR_CTS_PREVENT_ESCAPE, - RR_ESCAPING_TERRORISTS_NEUTRALIZED, - RR_BOMB_DEFUSED, - RR_BOMB_PLANTED, - RR_BOMB_EXPLODED, - RR_ALL_HOSTAGES_RESCUED, - RR_TARGET_BOMB_SAVED, - RR_HOSTAGE_NOT_RESCUED, - RR_VIP_NOT_ESCAPED, - RR_LOSER_BONUS_DEFAULT, - RR_LOSER_BONUS_MIN, - RR_LOSER_BONUS_MAX, - RR_LOSER_BONUS_ADD, - RR_RESCUED_HOSTAGE, - RR_TOOK_HOSTAGE_ACC, - RR_TOOK_HOSTAGE, - RR_END -}; - -// custom enum -enum RewardAccount -{ - REWARD_TARGET_BOMB = 3500, - REWARD_VIP_ESCAPED = 3500, - REWARD_VIP_ASSASSINATED = 3250, - REWARD_TERRORISTS_ESCAPED = 3150, - REWARD_CTS_PREVENT_ESCAPE = 3500, - REWARD_ESCAPING_TERRORISTS_NEUTRALIZED = 3250, - REWARD_BOMB_DEFUSED = 3250, - REWARD_BOMB_PLANTED = 800, - REWARD_BOMB_EXPLODED = 3250, - REWARD_CTS_WIN = 3000, - REWARD_TERRORISTS_WIN = 3000, - REWARD_ALL_HOSTAGES_RESCUED = 2500, - - // the end round was by the expiration time - REWARD_TARGET_BOMB_SAVED = 3250, - REWARD_HOSTAGE_NOT_RESCUED = 3250, - REWARD_VIP_NOT_ESCAPED = 3250, - - // loser bonus - REWARD_LOSER_BONUS_DEFAULT = 1400, - REWARD_LOSER_BONUS_MIN = 1500, - REWARD_LOSER_BONUS_MAX = 3000, - REWARD_LOSER_BONUS_ADD = 500, - - REWARD_RESCUED_HOSTAGE = 750, - REWARD_KILLED_ENEMY = 300, - REWARD_KILLED_VIP = 2500, - REWARD_VIP_HAVE_SELF_RESCUED = 2500, - - REWARD_TAKEN_HOSTAGE = 1000, - REWARD_TOOK_HOSTAGE_ACC = 100, - REWARD_TOOK_HOSTAGE = 150, -}; - -// custom enum -enum PaybackForBadThing -{ - PAYBACK_FOR_KILLED_TEAMMATES = -3300, -}; - -// custom enum -enum InfoMapBuyParam -{ - BUYING_EVERYONE = 0, - BUYING_ONLY_CTS, - BUYING_ONLY_TERRORISTS, - BUYING_NO_ONE, -}; - -// weapon respawning return codes -enum -{ - GR_NONE = 0, - - GR_WEAPON_RESPAWN_YES, - GR_WEAPON_RESPAWN_NO, - - GR_AMMO_RESPAWN_YES, - GR_AMMO_RESPAWN_NO, - - GR_ITEM_RESPAWN_YES, - GR_ITEM_RESPAWN_NO, - - GR_PLR_DROP_GUN_ALL, - GR_PLR_DROP_GUN_ACTIVE, - GR_PLR_DROP_GUN_NO, - - GR_PLR_DROP_AMMO_ALL, - GR_PLR_DROP_AMMO_ACTIVE, - GR_PLR_DROP_AMMO_NO, -}; - -// custom enum -enum -{ - SCENARIO_BLOCK_TIME_EXPRIRED = (1 << 0), // flag "a" - SCENARIO_BLOCK_NEED_PLAYERS = (1 << 1), // flag "b" - SCENARIO_BLOCK_VIP_ESCAPE = (1 << 2), // flag "c" - SCENARIO_BLOCK_PRISON_ESCAPE = (1 << 3), // flag "d" - SCENARIO_BLOCK_BOMB = (1 << 4), // flag "e" - SCENARIO_BLOCK_TEAM_EXTERMINATION = (1 << 5), // flag "f" - SCENARIO_BLOCK_HOSTAGE_RESCUE = (1 << 6), // flag "g" -}; - -// Player relationship return codes -enum -{ - GR_NOTTEAMMATE = 0, - GR_TEAMMATE, - GR_ENEMY, - GR_ALLY, - GR_NEUTRAL, -}; - -class CItem; - -class CGameRules { -protected: - virtual ~CGameRules() {}; -public: - virtual void RefreshSkillData() = 0; // fill skill data struct with proper values - virtual void Think() = 0; // runs every server frame, should handle any timer tasks, periodic events, etc. - virtual BOOL IsAllowedToSpawn(CBaseEntity *pEntity) = 0; // Can this item spawn (eg monsters don't spawn in deathmatch). - - virtual BOOL FAllowFlashlight() = 0; // Are players allowed to switch on their flashlight? - virtual BOOL FShouldSwitchWeapon(CBasePlayer *pPlayer, CBasePlayerItem *pWeapon) = 0; // should the player switch to this weapon? - virtual BOOL GetNextBestWeapon(CBasePlayer *pPlayer, CBasePlayerItem *pCurrentWeapon) = 0; // I can't use this weapon anymore, get me the next best one. - - // Functions to verify the single/multiplayer status of a game - virtual BOOL IsMultiplayer() = 0; // is this a multiplayer game? (either coop or deathmatch) - virtual BOOL IsDeathmatch() = 0; // is this a deathmatch game? - virtual BOOL IsTeamplay() = 0; // is this deathmatch game being played with team rules? - virtual BOOL IsCoOp() = 0; // is this a coop game? - virtual const char *GetGameDescription() = 0; // this is the game name that gets seen in the server browser - - // Client connection/disconnection - virtual BOOL ClientConnected(edict_t *pEntity, const char *pszName, const char *pszAddress, char *szRejectReason) = 0; // a client just connected to the server (player hasn't spawned yet) - virtual void InitHUD(CBasePlayer *pl) = 0; // the client dll is ready for updating - virtual void ClientDisconnected(edict_t *pClient) = 0; // a client just disconnected from the server - virtual void UpdateGameMode(CBasePlayer *pPlayer) = 0; // the client needs to be informed of the current game mode - - // Client damage rules - virtual float FlPlayerFallDamage(CBasePlayer *pPlayer) = 0; - virtual BOOL FPlayerCanTakeDamage(CBasePlayer *pPlayer, CBaseEntity *pAttacker) = 0; // can this player take damage from this attacker? - virtual BOOL ShouldAutoAim(CBasePlayer *pPlayer, edict_t *target) = 0; - - // Client spawn/respawn control - virtual void PlayerSpawn(CBasePlayer *pPlayer) = 0; // called by CBasePlayer::Spawn just before releasing player into the game - virtual void PlayerThink(CBasePlayer *pPlayer) = 0; // called by CBasePlayer::PreThink every frame, before physics are run and after keys are accepted - virtual BOOL FPlayerCanRespawn(CBasePlayer *pPlayer) = 0; // is this player allowed to respawn now? - virtual float FlPlayerSpawnTime(CBasePlayer *pPlayer) = 0; // When in the future will this player be able to spawn? - virtual edict_t *GetPlayerSpawnSpot(CBasePlayer *pPlayer) = 0; // Place this player on their spawnspot and face them the proper direction. - - virtual BOOL AllowAutoTargetCrosshair() = 0; - virtual BOOL ClientCommand_DeadOrAlive(CBasePlayer *pPlayer, const char *pcmd) = 0; - virtual BOOL ClientCommand(CBasePlayer *pPlayer, const char *pcmd) = 0; // handles the user commands; returns TRUE if command handled properly - virtual void ClientUserInfoChanged(CBasePlayer *pPlayer, char *infobuffer) = 0; // the player has changed userinfo; can change it now - - // Client kills/scoring - virtual int IPointsForKill(CBasePlayer *pAttacker, CBasePlayer *pKilled) = 0; // how many points do I award whoever kills this player? - virtual void PlayerKilled(CBasePlayer *pVictim, entvars_t *pKiller, entvars_t *pInflictor) = 0; // Called each time a player dies - virtual void DeathNotice(CBasePlayer *pVictim, entvars_t *pKiller, entvars_t *pevInflictor) = 0; // Call this from within a GameRules class to report an obituary. - - // Weapon retrieval - virtual BOOL CanHavePlayerItem(CBasePlayer *pPlayer, CBasePlayerItem *pItem) = 0; // The player is touching an CBasePlayerItem, do I give it to him? - virtual void PlayerGotWeapon(CBasePlayer *pPlayer, CBasePlayerItem *pWeapon) = 0; // Called each time a player picks up a weapon from the ground - - // Weapon spawn/respawn control - virtual int WeaponShouldRespawn(CBasePlayerItem *pWeapon) = 0; // should this weapon respawn? - virtual float FlWeaponRespawnTime(CBasePlayerItem *pWeapon) = 0; // when may this weapon respawn? - virtual float FlWeaponTryRespawn(CBasePlayerItem *pWeapon) = 0; // can i respawn now, and if not, when should i try again? - virtual Vector VecWeaponRespawnSpot(CBasePlayerItem *pWeapon) = 0; // where in the world should this weapon respawn? - - // Item retrieval - virtual BOOL CanHaveItem(CBasePlayer *pPlayer, CItem *pItem) = 0; // is this player allowed to take this item? - virtual void PlayerGotItem(CBasePlayer *pPlayer, CItem *pItem) = 0; // call each time a player picks up an item (battery, healthkit, longjump) - - // Item spawn/respawn control - virtual int ItemShouldRespawn(CItem *pItem) = 0; // Should this item respawn? - virtual float FlItemRespawnTime(CItem *pItem) = 0; // when may this item respawn? - virtual Vector VecItemRespawnSpot(CItem *pItem) = 0; // where in the world should this item respawn? - - // Ammo retrieval - virtual BOOL CanHaveAmmo(CBasePlayer *pPlayer, const char *pszAmmoName, int iMaxCarry) = 0; // can this player take more of this ammo? - virtual void PlayerGotAmmo(CBasePlayer *pPlayer, char *szName, int iCount) = 0; // called each time a player picks up some ammo in the world - - // Ammo spawn/respawn control - virtual int AmmoShouldRespawn(CBasePlayerAmmo *pAmmo) = 0; // should this ammo item respawn? - virtual float FlAmmoRespawnTime(CBasePlayerAmmo *pAmmo) = 0; // when should this ammo item respawn? - virtual Vector VecAmmoRespawnSpot(CBasePlayerAmmo *pAmmo) = 0; // where in the world should this ammo item respawn? - - // Healthcharger respawn control - virtual float FlHealthChargerRechargeTime() = 0; // how long until a depleted HealthCharger recharges itself? - virtual float FlHEVChargerRechargeTime() = 0; // how long until a depleted HealthCharger recharges itself? - - // What happens to a dead player's weapons - virtual int DeadPlayerWeapons(CBasePlayer *pPlayer) = 0; // what do I do with a player's weapons when he's killed? - - // What happens to a dead player's ammo - virtual int DeadPlayerAmmo(CBasePlayer *pPlayer) = 0; // Do I drop ammo when the player dies? How much? - - // Teamplay stuff - virtual const char *GetTeamID(CBaseEntity *pEntity) = 0; // what team is this entity on? - virtual int PlayerRelationship(CBasePlayer *pPlayer, CBaseEntity *pTarget) = 0; // What is the player's relationship with this entity? - virtual int GetTeamIndex(const char *pTeamName) = 0; - virtual const char *GetIndexedTeamName(int teamIndex) = 0; - virtual BOOL IsValidTeam(const char *pTeamName) = 0; - virtual void ChangePlayerTeam(CBasePlayer *pPlayer, const char *pTeamName, BOOL bKill, BOOL bGib) = 0; - virtual const char *SetDefaultPlayerTeam(CBasePlayer *pPlayer) = 0; - - // Sounds - virtual BOOL PlayTextureSounds() = 0; - - // Monsters - virtual BOOL FAllowMonsters() = 0; // are monsters allowed - - // Immediately end a multiplayer game - virtual void EndMultiplayerGame() = 0; - - // Stuff that is shared between client and server. - virtual BOOL IsFreezePeriod() = 0; - virtual void ServerDeactivate() = 0; - virtual void CheckMapConditions() = 0; - - // inline function's - inline bool IsGameOver() const { return m_bGameOver; } - inline void SetGameOver() { m_bGameOver = true; } - -public: - BOOL m_bFreezePeriod; // TRUE at beginning of round, set to FALSE when the period expires - BOOL m_bBombDropped; - - // custom - char *m_GameDesc; - bool m_bGameOver; // intermission or finale (deprecated name g_fGameOver) -}; - -// CHalfLifeRules - rules for the single player Half-Life game. -class CHalfLifeRules: public CGameRules { -protected: - virtual ~CHalfLifeRules() {}; -public: - virtual void Think() = 0; - virtual BOOL IsAllowedToSpawn(CBaseEntity *pEntity) = 0; - virtual BOOL FAllowFlashlight() = 0; - - virtual BOOL FShouldSwitchWeapon(CBasePlayer *pPlayer, CBasePlayerItem *pWeapon) = 0; - virtual BOOL GetNextBestWeapon(CBasePlayer *pPlayer, CBasePlayerItem *pCurrentWeapon) = 0; - - // Functions to verify the single/multiplayer status of a game - virtual BOOL IsMultiplayer() = 0; - virtual BOOL IsDeathmatch() = 0; - virtual BOOL IsCoOp() = 0; - - // Client connection/disconnection - virtual BOOL ClientConnected(edict_t *pEntity, const char *pszName, const char *pszAddress, char szRejectReason[128]) = 0; - virtual void InitHUD(CBasePlayer *pl) = 0; // the client dll is ready for updating - virtual void ClientDisconnected(edict_t *pClient) = 0; - - // Client damage rules - virtual float FlPlayerFallDamage(CBasePlayer *pPlayer) = 0; - - // Client spawn/respawn control - virtual void PlayerSpawn(CBasePlayer *pPlayer) = 0; - virtual void PlayerThink(CBasePlayer *pPlayer) = 0; - virtual BOOL FPlayerCanRespawn(CBasePlayer *pPlayer) = 0; - virtual float FlPlayerSpawnTime(CBasePlayer *pPlayer) = 0; - virtual edict_t *GetPlayerSpawnSpot(CBasePlayer *pPlayer) = 0; - - virtual BOOL AllowAutoTargetCrosshair() = 0; - - // Client kills/scoring - virtual int IPointsForKill(CBasePlayer *pAttacker, CBasePlayer *pKilled) = 0; - virtual void PlayerKilled(CBasePlayer *pVictim, entvars_t *pKiller, entvars_t *pInflictor) = 0; - virtual void DeathNotice(CBasePlayer *pVictim, entvars_t *pKiller, entvars_t *pInflictor) = 0; - - // Weapon retrieval - virtual void PlayerGotWeapon(CBasePlayer *pPlayer, CBasePlayerItem *pWeapon) = 0; - - // Weapon spawn/respawn control - virtual int WeaponShouldRespawn(CBasePlayerItem *pWeapon) = 0; - virtual float FlWeaponRespawnTime(CBasePlayerItem *pWeapon) = 0; - virtual float FlWeaponTryRespawn(CBasePlayerItem *pWeapon) = 0; - virtual Vector VecWeaponRespawnSpot(CBasePlayerItem *pWeapon) = 0; - - // Item retrieval - virtual BOOL CanHaveItem(CBasePlayer *pPlayer, CItem *pItem) = 0; - virtual void PlayerGotItem(CBasePlayer *pPlayer, CItem *pItem) = 0; - - // Item spawn/respawn control - virtual int ItemShouldRespawn(CItem *pItem) = 0; - virtual float FlItemRespawnTime(CItem *pItem) = 0; - virtual Vector VecItemRespawnSpot(CItem *pItem) = 0; - - // Ammo retrieval - virtual void PlayerGotAmmo(CBasePlayer *pPlayer, char *szName, int iCount) = 0; - - // Ammo spawn/respawn control - virtual int AmmoShouldRespawn(CBasePlayerAmmo *pAmmo) = 0; - virtual float FlAmmoRespawnTime(CBasePlayerAmmo *pAmmo) = 0; - virtual Vector VecAmmoRespawnSpot(CBasePlayerAmmo *pAmmo) = 0; - - // Healthcharger respawn control - virtual float FlHealthChargerRechargeTime() = 0; - - // What happens to a dead player's weapons - virtual int DeadPlayerWeapons(CBasePlayer *pPlayer) = 0; - - // What happens to a dead player's ammo - virtual int DeadPlayerAmmo(CBasePlayer *pPlayer) = 0; - - // Teamplay stuff - virtual const char *GetTeamID(CBaseEntity *pEntity) = 0; - virtual int PlayerRelationship(CBasePlayer *pPlayer, CBaseEntity *pTarget) = 0; - - // Monsters - virtual BOOL FAllowMonsters() = 0; -}; - -// CHalfLifeMultiplay - rules for the basic half life multiplayer competition -class CHalfLifeMultiplay: public CGameRules { -protected: - virtual ~CHalfLifeMultiplay() {}; -public: - virtual void RefreshSkillData() = 0; - virtual void Think() = 0; - virtual BOOL IsAllowedToSpawn(CBaseEntity *pEntity) = 0; - virtual BOOL FAllowFlashlight() = 0; - - virtual BOOL FShouldSwitchWeapon(CBasePlayer *pPlayer, CBasePlayerItem *pWeapon) = 0; - virtual BOOL GetNextBestWeapon(CBasePlayer *pPlayer, CBasePlayerItem *pCurrentWeapon) = 0; - - virtual BOOL IsMultiplayer() = 0; - virtual BOOL IsDeathmatch() = 0; - virtual BOOL IsCoOp() = 0; - - // Client connection/disconnection - // If ClientConnected returns FALSE, the connection is rejected and the user is provided the reason specified in szRejectReason - // Only the client's name and remote address are provided to the dll for verification. - virtual BOOL ClientConnected(edict_t *pEntity, const char *pszName, const char *pszAddress, char szRejectReason[128]) = 0; - virtual void InitHUD(CBasePlayer *pl) = 0; - virtual void ClientDisconnected(edict_t *pClient) = 0; - virtual void UpdateGameMode(CBasePlayer *pPlayer) = 0; - - // Client damage rules - virtual float FlPlayerFallDamage(CBasePlayer *pPlayer) = 0; - virtual BOOL FPlayerCanTakeDamage(CBasePlayer *pPlayer, CBaseEntity *pAttacker) = 0; - - // Client spawn/respawn control - virtual void PlayerSpawn(CBasePlayer *pPlayer) = 0; - virtual void PlayerThink(CBasePlayer *pPlayer) = 0; - virtual BOOL FPlayerCanRespawn(CBasePlayer *pPlayer) = 0; - virtual float FlPlayerSpawnTime(CBasePlayer *pPlayer) = 0; - virtual edict_t *GetPlayerSpawnSpot(CBasePlayer *pPlayer) = 0; - - virtual BOOL AllowAutoTargetCrosshair() = 0; - - virtual BOOL ClientCommand_DeadOrAlive(CBasePlayer *pPlayer, const char *pcmd) = 0; - virtual BOOL ClientCommand(CBasePlayer *pPlayer, const char *pcmd) = 0; - virtual void ClientUserInfoChanged(CBasePlayer *pPlayer, char *infobuffer) = 0; - - // Client kills/scoring - virtual int IPointsForKill(CBasePlayer *pAttacker, CBasePlayer *pKilled) = 0; - virtual void PlayerKilled(CBasePlayer *pVictim, entvars_t *pKiller, entvars_t *pInflictor) = 0; - virtual void DeathNotice(CBasePlayer *pVictim, entvars_t *pKiller, entvars_t *pInflictor) = 0; - - // Weapon retrieval - virtual BOOL CanHavePlayerItem(CBasePlayer *pPlayer, CBasePlayerItem *pWeapon) = 0; - virtual void PlayerGotWeapon(CBasePlayer *pPlayer, CBasePlayerItem *pWeapon) = 0; - - // Weapon spawn/respawn control - virtual int WeaponShouldRespawn(CBasePlayerItem *pWeapon) = 0; - virtual float FlWeaponRespawnTime(CBasePlayerItem *pWeapon) = 0; - virtual float FlWeaponTryRespawn(CBasePlayerItem *pWeapon) = 0; - virtual Vector VecWeaponRespawnSpot(CBasePlayerItem *pWeapon) = 0; - - // Item retrieval - virtual BOOL CanHaveItem(CBasePlayer *pPlayer, CItem *pItem) = 0; - virtual void PlayerGotItem(CBasePlayer *pPlayer, CItem *pItem) = 0; - - // Item spawn/respawn control - virtual int ItemShouldRespawn(CItem *pItem) = 0; - virtual float FlItemRespawnTime(CItem *pItem) = 0; - virtual Vector VecItemRespawnSpot(CItem *pItem) = 0; - - // Ammo retrieval - virtual void PlayerGotAmmo(CBasePlayer *pPlayer, char *szName, int iCount) = 0; - - // Ammo spawn/respawn control - virtual int AmmoShouldRespawn(CBasePlayerAmmo *pAmmo) = 0; - virtual float FlAmmoRespawnTime(CBasePlayerAmmo *pAmmo) = 0; - virtual Vector VecAmmoRespawnSpot(CBasePlayerAmmo *pAmmo) = 0; - - // Healthcharger respawn control - virtual float FlHealthChargerRechargeTime() = 0; - virtual float FlHEVChargerRechargeTime() = 0; - - // What happens to a dead player's weapons - virtual int DeadPlayerWeapons(CBasePlayer *pPlayer) = 0; - - // What happens to a dead player's ammo - virtual int DeadPlayerAmmo(CBasePlayer *pPlayer) = 0; - - // Teamplay stuff - virtual const char *GetTeamID(CBaseEntity *pEntity) = 0; - virtual int PlayerRelationship(CBasePlayer *pPlayer, CBaseEntity *pTarget) = 0; - - virtual BOOL PlayTextureSounds() = 0; - - // Monsters - virtual BOOL FAllowMonsters() = 0; - - // Immediately end a multiplayer game - virtual void EndMultiplayerGame() = 0; - virtual void ServerDeactivate() = 0; - virtual void CheckMapConditions() = 0; - - // Recreate all the map entities from the map data (preserving their indices), - // then remove everything else except the players. - // Also get rid of all world decals. - virtual void CleanUpMap() = 0; - - virtual void RestartRound() = 0; - - // check if the scenario has been won/lost - virtual void CheckWinConditions() = 0; - virtual void RemoveGuns() = 0; - virtual void GiveC4() = 0; - virtual void ChangeLevel() = 0; - virtual void GoToIntermission() = 0; - - // Setup counts for m_iNumTerrorist, m_iNumCT, m_iNumSpawnableTerrorist, m_iNumSpawnableCT, etc. - virtual void InitializePlayerCounts(int &NumAliveTerrorist, int &NumAliveCT, int &NumDeadTerrorist, int &NumDeadCT) = 0; - - virtual void BalanceTeams() = 0; - virtual void SwapAllPlayers() = 0; - virtual void UpdateTeamScores() = 0; - virtual void EndRoundMessage(const char *sentence, int event) = 0; - virtual void SetAccountRules(RewardRules rules, int amount) = 0; - virtual RewardAccount GetAccountRules(RewardRules rules) const = 0; - - // BOMB MAP FUNCTIONS - virtual BOOL IsThereABomber() = 0; - virtual BOOL IsThereABomb() = 0; - virtual TeamName SelectDefaultTeam() = 0; - - virtual bool HasRoundTimeExpired() = 0; - virtual bool IsBombPlanted() = 0; - -public: - bool ShouldSkipShowMenu() const { return m_bSkipShowMenu; } - void MarkShowMenuSkipped() { m_bSkipShowMenu = false; } - - bool ShouldSkipSpawn() const { return m_bSkipSpawn; } - void MarkSpawnSkipped() { m_bSkipSpawn = false; } - - float GetRoundRemainingTime() const { return m_iRoundTimeSecs - gpGlobals->time + m_fRoundStartTime; } - float GetRoundRemainingTimeReal() const { return m_iRoundTimeSecs - gpGlobals->time + m_fRoundStartTimeReal; } - float GetTimeLeft() const { return m_flTimeLimit - gpGlobals->time; } - bool IsMatchStarted() { return (m_flRestartRoundTime != 0.0f || m_fCareerRoundMenuTime != 0.0f || m_fCareerMatchMenuTime != 0.0f); } - - void TerminateRound(float tmDelay, int iWinStatus); - -public: - CVoiceGameMgr m_VoiceGameMgr; - float m_flRestartRoundTime; // The global time when the round is supposed to end, if this is not 0 (deprecated name m_fTeamCount) - float m_flCheckWinConditions; - float m_fRoundStartTime; // Time round has started (deprecated name m_fRoundCount) - int m_iRoundTime; // (From mp_roundtime) - How many seconds long this round is. - int m_iRoundTimeSecs; - int m_iIntroRoundTime; // (From mp_freezetime) - How many seconds long the intro round (when players are frozen) is. - float m_fRoundStartTimeReal; // The global time when the intro round ends and the real one starts - // wrote the original "m_flRoundTime" comment for this variable). - int m_iAccountTerrorist; - int m_iAccountCT; - int m_iNumTerrorist; // The number of terrorists on the team (this is generated at the end of a round) - int m_iNumCT; // The number of CTs on the team (this is generated at the end of a round) - int m_iNumSpawnableTerrorist; - int m_iNumSpawnableCT; - int m_iSpawnPointCount_Terrorist; // Number of Terrorist spawn points - int m_iSpawnPointCount_CT; // Number of CT spawn points - int m_iHostagesRescued; - int m_iHostagesTouched; - int m_iRoundWinStatus; // 1 == CT's won last round, 2 == Terrorists did, 3 == Draw, no winner - - short m_iNumCTWins; - short m_iNumTerroristWins; - - bool m_bTargetBombed; // whether or not the bomb has been bombed - bool m_bBombDefused; // whether or not the bomb has been defused - - bool m_bMapHasBombTarget; - bool m_bMapHasBombZone; - bool m_bMapHasBuyZone; - bool m_bMapHasRescueZone; - bool m_bMapHasEscapeZone; - - BOOL m_bMapHasVIPSafetyZone; // TRUE = has VIP safety zone, FALSE = does not have VIP safetyzone - BOOL m_bMapHasCameras; - int m_iC4Timer; - int m_iC4Guy; // The current Terrorist who has the C4. - int m_iLoserBonus; // the amount of money the losing team gets. This scales up as they lose more rounds in a row - int m_iNumConsecutiveCTLoses; // the number of rounds the CTs have lost in a row. - int m_iNumConsecutiveTerroristLoses; // the number of rounds the Terrorists have lost in a row. - - float m_fMaxIdlePeriod; // For the idle kick functionality. This is tha max amount of time that the player has to be idle before being kicked - - int m_iLimitTeams; - bool m_bLevelInitialized; - bool m_bRoundTerminating; - bool m_bCompleteReset; // Set to TRUE to have the scores reset next time round restarts - float m_flRequiredEscapeRatio; - int m_iNumEscapers; - int m_iHaveEscaped; - bool m_bCTCantBuy; - bool m_bTCantBuy; // Who can and can't buy. - float m_flBombRadius; - int m_iConsecutiveVIP; - int m_iTotalGunCount; - int m_iTotalGrenadeCount; - int m_iTotalArmourCount; - int m_iUnBalancedRounds; // keeps track of the # of consecutive rounds that have gone by where one team outnumbers the other team by more than 2 - int m_iNumEscapeRounds; // keeps track of the # of consecutive rounds of escape played.. Teams will be swapped after 8 rounds - int m_iMapVotes[MAX_VOTE_MAPS]; - int m_iLastPick; - int m_iMaxMapTime; - int m_iMaxRounds; - int m_iTotalRoundsPlayed; - int m_iMaxRoundsWon; - int m_iStoredSpectValue; - float m_flForceCameraValue; - float m_flForceChaseCamValue; - float m_flFadeToBlackValue; - CBasePlayer *m_pVIP; - CBasePlayer *m_pVIPQueue[MAX_VIP_QUEUES]; - float m_flIntermissionEndTime; - float m_flIntermissionStartTime; - BOOL m_iEndIntermissionButtonHit; - float m_tmNextPeriodicThink; - bool m_bGameStarted; // TRUE = the game commencing when there is at least one CT and T, FALSE = scoring will not start until both teams have players (deprecated name m_bFirstConnected) - bool m_bInCareerGame; - float m_fCareerRoundMenuTime; - int m_iCareerMatchWins; - int m_iRoundWinDifference; - float m_fCareerMatchMenuTime; - bool m_bSkipSpawn; - - // custom - bool m_bSkipShowMenu; - bool m_bNeededPlayers; - float m_flEscapeRatio; - float m_flTimeLimit; - float m_flGameStartTime; -}; - -typedef struct mapcycle_item_s -{ - struct mapcycle_item_s *next; - char mapname[32]; - int minplayers; - int maxplayers; - char rulebuffer[MAX_RULE_BUFFER]; - -} mapcycle_item_t; - -typedef struct mapcycle_s -{ - struct mapcycle_item_s *items; - struct mapcycle_item_s *next_item; - -} mapcycle_t; - -class CCStrikeGameMgrHelper: public IVoiceGameMgrHelper { -public: - virtual bool CanPlayerHearPlayer(CBasePlayer *pListener, CBasePlayer *pSender) = 0; -}; - -extern CGameRules *g_pGameRules; - -// Gets us at the CS game rules -inline CHalfLifeMultiplay *CSGameRules() -{ - return static_cast(g_pGameRules); -} - -inline void CHalfLifeMultiplay::TerminateRound(float tmDelay, int iWinStatus) -{ - m_iRoundWinStatus = iWinStatus; - m_flRestartRoundTime = gpGlobals->time + tmDelay; - m_bRoundTerminating = true; -} diff --git a/regamedll/extra/cssdk/dlls/h_battery.h b/regamedll/extra/cssdk/dlls/h_battery.h deleted file mode 100644 index e523dd6c..00000000 --- a/regamedll/extra/cssdk/dlls/h_battery.h +++ /dev/null @@ -1,45 +0,0 @@ -/* -* -* This program is free software; you can redistribute it and/or modify it -* under the terms of the GNU General Public License as published by the -* Free Software Foundation; either version 2 of the License, or (at -* your option) any later version. -* -* This program 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 -* General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* -*/ -#pragma once - -class CRecharge: public CBaseToggle { -public: - virtual void Spawn() = 0; - virtual void Precache() = 0; - virtual void KeyValue(KeyValueData *pkvd) = 0; - virtual int Save(CSave &save) = 0; - virtual int Restore(CRestore &restore) = 0; - virtual int ObjectCaps() = 0; - virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) = 0; -public: - float m_flNextCharge; - int m_iReactivate; - int m_iJuice; - int m_iOn; - float m_flSoundTime; -}; diff --git a/regamedll/extra/cssdk/dlls/h_cycler.h b/regamedll/extra/cssdk/dlls/h_cycler.h deleted file mode 100644 index 5f9ab004..00000000 --- a/regamedll/extra/cssdk/dlls/h_cycler.h +++ /dev/null @@ -1,104 +0,0 @@ -/* -* -* This program is free software; you can redistribute it and/or modify it -* under the terms of the GNU General Public License as published by the -* Free Software Foundation; either version 2 of the License, or (at -* your option) any later version. -* -* This program 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 -* General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* -*/ -#pragma once - -class CCycler: public CBaseMonster { -public: - virtual void Spawn() = 0; - virtual int Save(CSave &save) = 0; - virtual int Restore(CRestore &restore) = 0; - virtual int ObjectCaps() = 0; - virtual BOOL TakeDamage(entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType) = 0; - - // Don't treat as a live target - virtual BOOL IsAlive() = 0; - virtual void Think() = 0; - virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) = 0; -public: - int m_animate; -}; - -// we should get rid of all the other cyclers and replace them with this. -class CGenericCycler: public CCycler { -public: - virtual void Spawn() = 0; -}; - -// Probe droid imported for tech demo compatibility -class CCyclerProbe: public CCycler { -public: - virtual void Spawn() = 0; -}; - -class CCyclerSprite: public CBaseEntity { -public: - virtual void Spawn() = 0; - virtual void Restart() = 0; - virtual int Save(CSave &save) = 0; - virtual int Restore(CRestore &restore) = 0; - virtual int ObjectCaps() = 0; - virtual BOOL TakeDamage(entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType) = 0; - virtual void Think() = 0; - virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) = 0; -public: - inline int ShouldAnimate() { return (m_animate && m_maxFrame > 1.0f); } -public: - int m_animate; - float m_lastTime; - float m_maxFrame; - int m_renderfx; - int m_rendermode; - float m_renderamt; - vec3_t m_rendercolor; -}; - -class CWeaponCycler: public CBasePlayerWeapon { -public: - virtual void Spawn() = 0; - virtual int GetItemInfo(ItemInfo *p) = 0; - virtual BOOL Deploy() = 0; - virtual void Holster(int skiplocal = 0) = 0; - virtual int iItemSlot() = 0; - virtual void PrimaryAttack() = 0; - virtual void SecondaryAttack() = 0; -public: - int m_iszModel; - int m_iModel; -}; - -// Flaming Wreakage -class CWreckage: public CBaseMonster { -public: - virtual void Spawn() = 0; - virtual void Precache() = 0; - virtual int Save(CSave &save) = 0; - virtual int Restore(CRestore &restore) = 0; - virtual void Think() = 0; -public: - int m_flStartTime; -}; diff --git a/regamedll/extra/cssdk/dlls/healthkit.h b/regamedll/extra/cssdk/dlls/healthkit.h deleted file mode 100644 index eb4e63d9..00000000 --- a/regamedll/extra/cssdk/dlls/healthkit.h +++ /dev/null @@ -1,52 +0,0 @@ -/* -* -* This program is free software; you can redistribute it and/or modify it -* under the terms of the GNU General Public License as published by the -* Free Software Foundation; either version 2 of the License, or (at -* your option) any later version. -* -* This program 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 -* General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* -*/ -#pragma once - -class CHealthKit: public CItem { -public: - virtual void Spawn() = 0; - virtual void Precache() = 0; - virtual BOOL MyTouch(CBasePlayer *pPlayer) = 0; -}; - -class CWallHealth: public CBaseToggle { -public: - virtual void Spawn() = 0; - virtual void Precache() = 0; - virtual void KeyValue(KeyValueData *pkvd) = 0; - virtual int Save(CSave &save) = 0; - virtual int Restore(CRestore &restore) = 0; - virtual int ObjectCaps() = 0; - virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) = 0; -public: - float m_flNextCharge; - int m_iReactivate; - int m_iJuice; - int m_iOn; - float m_flSoundTime; -}; diff --git a/regamedll/extra/cssdk/dlls/hintmessage.h b/regamedll/extra/cssdk/dlls/hintmessage.h deleted file mode 100644 index ce63fde3..00000000 --- a/regamedll/extra/cssdk/dlls/hintmessage.h +++ /dev/null @@ -1,81 +0,0 @@ -/* -* -* This program is free software; you can redistribute it and/or modify it -* under the terms of the GNU General Public License as published by the -* Free Software Foundation; either version 2 of the License, or (at -* your option) any later version. -* -* This program 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 -* General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* -*/ -#pragma once - -#include "utlvector.h" - -#define DHF_ROUND_STARTED (1<<1) -#define DHF_HOSTAGE_SEEN_FAR (1<<2) -#define DHF_HOSTAGE_SEEN_NEAR (1<<3) -#define DHF_HOSTAGE_USED (1<<4) -#define DHF_HOSTAGE_INJURED (1<<5) -#define DHF_HOSTAGE_KILLED (1<<6) -#define DHF_FRIEND_SEEN (1<<7) -#define DHF_ENEMY_SEEN (1<<8) -#define DHF_FRIEND_INJURED (1<<9) -#define DHF_FRIEND_KILLED (1<<10) -#define DHF_ENEMY_KILLED (1<<11) -#define DHF_BOMB_RETRIEVED (1<<12) -#define DHF_AMMO_EXHAUSTED (1<<15) -#define DHF_IN_TARGET_ZONE (1<<16) -#define DHF_IN_RESCUE_ZONE (1<<17) -#define DHF_IN_ESCAPE_ZONE (1<<18) -#define DHF_IN_VIPSAFETY_ZONE (1<<19) -#define DHF_NIGHTVISION (1<<20) -#define DHF_HOSTAGE_CTMOVE (1<<21) -#define DHF_SPEC_DUCK (1<<22) - -#define DHM_ROUND_CLEAR (DHF_ROUND_STARTED | DHF_HOSTAGE_KILLED | DHF_FRIEND_KILLED | DHF_BOMB_RETRIEVED) -#define DHM_CONNECT_CLEAR (DHF_HOSTAGE_SEEN_FAR | DHF_HOSTAGE_SEEN_NEAR | DHF_HOSTAGE_USED | DHF_HOSTAGE_INJURED | DHF_FRIEND_SEEN | DHF_ENEMY_SEEN | DHF_FRIEND_INJURED | DHF_ENEMY_KILLED | DHF_AMMO_EXHAUSTED | DHF_IN_TARGET_ZONE | DHF_IN_RESCUE_ZONE | DHF_IN_ESCAPE_ZONE | DHF_IN_VIPSAFETY_ZONE | DHF_HOSTAGE_CTMOVE | DHF_SPEC_DUCK) - -class CHintMessage { -public: - CHintMessage(const char *hintString, bool isHint, CUtlVector *args, float duration); - ~CHintMessage(); -public: - float GetDuration() const { return m_duration; } - void Send(CBaseEntity *client); - -private: - const char *m_hintString; - bool m_isHint; - CUtlVector m_args; - float m_duration; -}; - -class CHintMessageQueue { -public: - void Reset(); - void Update(CBaseEntity *client); - bool AddMessage(const char *message, float duration, bool isHint, CUtlVector *args); - bool IsEmpty() const { return m_messages.Count() == 0; } - -private: - float m_tmMessageEnd; - CUtlVector m_messages; -}; diff --git a/regamedll/extra/cssdk/dlls/hookchains.h b/regamedll/extra/cssdk/dlls/hookchains.h deleted file mode 100644 index 7ea472a6..00000000 --- a/regamedll/extra/cssdk/dlls/hookchains.h +++ /dev/null @@ -1,121 +0,0 @@ -/* -* -* This program is free software; you can redistribute it and/or modify it -* under the terms of the GNU General Public License as published by the -* Free Software Foundation; either version 2 of the License, or (at -* your option) any later version. -* -* This program 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 -* General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* -*/ -#pragma once - -template -class IHookChain { -protected: - virtual ~IHookChain() {} - -public: - virtual t_ret callNext(t_args... args) = 0; - virtual t_ret callOriginal(t_args... args) = 0; -}; - -template -class IHookChainClass { -protected: - virtual ~IHookChainClass() {} - -public: - virtual t_ret callNext(t_class *, t_args... args) = 0; - virtual t_ret callOriginal(t_class *, t_args... args) = 0; -}; - -template -class IVoidHookChain -{ -protected: - virtual ~IVoidHookChain() {} - -public: - virtual void callNext(t_args... args) = 0; - virtual void callOriginal(t_args... args) = 0; -}; - -template -class IVoidHookChainClass -{ -protected: - virtual ~IVoidHookChainClass() {} - -public: - virtual void callNext(t_class *, t_args... args) = 0; - virtual void callOriginal(t_class *, t_args... args) = 0; -}; - -// Specifies priorities for hooks call order in the chain. -// For equal priorities first registered hook will be called first. -enum HookChainPriority -{ - HC_PRIORITY_UNINTERRUPTABLE = 255, // Hook will be called before other hooks. - HC_PRIORITY_HIGH = 192, // Hook will be called before hooks with default priority. - HC_PRIORITY_DEFAULT = 128, // Default hook call priority. - HC_PRIORITY_MEDIUM = 64, // Hook will be called after hooks with default priority. - HC_PRIORITY_LOW = 0, // Hook will be called after all other hooks. -}; - -// Hook chain registry(for hooks [un]registration) -template -class IHookChainRegistry { -public: - typedef t_ret(*hookfunc_t)(IHookChain*, t_args...); - - virtual void registerHook(hookfunc_t hook, int priority = HC_PRIORITY_DEFAULT) = 0; - virtual void unregisterHook(hookfunc_t hook) = 0; -}; - -// Hook chain registry(for hooks [un]registration) -template -class IHookChainRegistryClass { -public: - typedef t_ret(*hookfunc_t)(IHookChainClass*, t_class *, t_args...); - - virtual void registerHook(hookfunc_t hook, int priority = HC_PRIORITY_DEFAULT) = 0; - virtual void unregisterHook(hookfunc_t hook) = 0; -}; - -// Hook chain registry(for hooks [un]registration) -template -class IVoidHookChainRegistry { -public: - typedef void(*hookfunc_t)(IVoidHookChain*, t_args...); - - virtual void registerHook(hookfunc_t hook, int priority = HC_PRIORITY_DEFAULT) = 0; - virtual void unregisterHook(hookfunc_t hook) = 0; -}; - -// Hook chain registry(for hooks [un]registration) -template -class IVoidHookChainRegistryClass { -public: - typedef void(*hookfunc_t)(IVoidHookChainClass*, t_class *, t_args...); - - virtual void registerHook(hookfunc_t hook, int priority = HC_PRIORITY_DEFAULT) = 0; - virtual void unregisterHook(hookfunc_t hook) = 0; -}; diff --git a/regamedll/extra/cssdk/dlls/hostage/hostage.h b/regamedll/extra/cssdk/dlls/hostage/hostage.h deleted file mode 100644 index a0be24c8..00000000 --- a/regamedll/extra/cssdk/dlls/hostage/hostage.h +++ /dev/null @@ -1,233 +0,0 @@ -/* -* -* This program is free software; you can redistribute it and/or modify it -* under the terms of the GNU General Public License as published by the -* Free Software Foundation; either version 2 of the License, or (at -* your option) any later version. -* -* This program 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 -* General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* -*/ -#pragma once - -#define MAX_NODES 100 -#define MAX_HOSTAGES 12 -#define MAX_HOSTAGES_NAV 20 - -#define HOSTAGE_STEPSIZE 26.0f -#define HOSTAGE_STEPSIZE_DEFAULT 18.0f - -#define VEC_HOSTAGE_VIEW Vector(0, 0, 12) -#define VEC_HOSTAGE_HULL_MIN Vector(-10, -10, 0) -#define VEC_HOSTAGE_HULL_MAX Vector(10, 10, 62) - -#define VEC_HOSTAGE_CROUCH Vector(10, 10, 30) -#define RESCUE_HOSTAGES_RADIUS 256.0f // rescue zones from legacy info_* - -class CHostage; -class CLocalNav; -class CHostageImprov; -class CHostageManager; - -enum HostageChatterType -{ - HOSTAGE_CHATTER_START_FOLLOW = 0, - HOSTAGE_CHATTER_STOP_FOLLOW, - HOSTAGE_CHATTER_INTIMIDATED, - HOSTAGE_CHATTER_PAIN, - HOSTAGE_CHATTER_SCARED_OF_GUNFIRE, - HOSTAGE_CHATTER_SCARED_OF_MURDER, - HOSTAGE_CHATTER_LOOK_OUT, - HOSTAGE_CHATTER_PLEASE_RESCUE_ME, - HOSTAGE_CHATTER_SEE_RESCUE_ZONE, - HOSTAGE_CHATTER_IMPATIENT_FOR_RESCUE, - HOSTAGE_CHATTER_CTS_WIN , - HOSTAGE_CHATTER_TERRORISTS_WIN, - HOSTAGE_CHATTER_RESCUED, - HOSTAGE_CHATTER_WARN_NEARBY, - HOSTAGE_CHATTER_WARN_SPOTTED, - HOSTAGE_CHATTER_CALL_TO_RESCUER, - HOSTAGE_CHATTER_RETREAT, - HOSTAGE_CHATTER_COUGH, - HOSTAGE_CHATTER_BLINDED, - HOSTAGE_CHATTER_SAW_HE_GRENADE, - HOSTAGE_CHATTER_DEATH_CRY, - NUM_HOSTAGE_CHATTER_TYPES, -}; - -// Improved the hostages from CZero -#include "hostage/hostage_improv.h" - -extern CHostageManager *g_pHostages; -extern int g_iHostageNumber; - -// A Counter-Strike Hostage Simple -class CHostage: public CBaseMonster { -public: - virtual void Spawn() = 0; - virtual void Precache() = 0; - virtual int ObjectCaps() = 0; // make hostage "useable" - virtual int Classify() = 0; - virtual void TraceAttack(entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType) = 0; - virtual BOOL TakeDamage(entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType) = 0; - virtual int BloodColor() = 0; - virtual void Touch(CBaseEntity *pOther) = 0; - virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) = 0; -public: - int GetActivity() { return m_Activity; } - - // queries - bool IsFollowingSomeone() { return IsFollowing(); } - CBaseEntity *GetLeader() // return our leader, or NULL - { - if (m_improv != NULL) - { - return m_improv->GetFollowLeader(); - } - - return m_hTargetEnt; - } - bool IsFollowing(const CBaseEntity *entity = NULL) - { - if (m_improv != NULL) - { - return m_improv->IsFollowing(); - } - - if (entity == NULL && m_hTargetEnt == NULL || (entity != NULL && m_hTargetEnt != entity)) - return false; - - if (m_State != FOLLOW) - return false; - - return true; - } - bool IsValid() const { return (pev->takedamage == DAMAGE_YES); } - bool IsDead() const { return (pev->deadflag == DEAD_DEAD); } - bool IsAtHome() const { return (pev->origin - m_vStart).IsLengthGreaterThan(20) != true; } - const Vector *GetHomePosition() const { return &m_vStart; } -public: - int m_Activity; - BOOL m_bTouched; - BOOL m_bRescueMe; - float m_flFlinchTime; - float m_flNextChange; - float m_flMarkPosition; - int m_iModel; - int m_iSkin; - float m_flNextRadarTime; - enum state { FOLLOW, STAND, DUCK, SCARED, IDLE, FOLLOWPATH } - m_State; - Vector m_vStart; - Vector m_vStartAngles; - Vector m_vPathToFollow[20]; - int m_iWaypoint; - CBasePlayer *m_target; - CLocalNav *m_LocalNav; - int nTargetNode; - Vector vecNodes[MAX_NODES]; - EHANDLE m_hStoppedTargetEnt; - float m_flNextFullThink; - float m_flPathCheckInterval; - float m_flLastPathCheck; - int m_nPathNodes; - BOOL m_fHasPath; - float m_flPathAcquired; - Vector m_vOldPos; - int m_iHostageIndex; - BOOL m_bStuck; - float m_flStuckTime; - CHostageImprov *m_improv; - - enum ModelType { REGULAR_GUY, OLD_GUY, BLACK_GUY, GOOFY_GUY } - m_whichModel; -}; - -class SimpleChatter { -public: - struct SoundFile - { - char *filename; - float duration; - }; - - struct ChatterSet - { - SoundFile file[32]; - int count; - int index; - bool needsShuffle; - }; -private: - ChatterSet m_chatter[21]; -}; - -class CHostageManager { -public: - SimpleChatter *GetChatter() - { - return &m_chatter; - } - // Iterate over all active hostages in the game, invoking functor on each. - // If functor returns false, stop iteration and return false. - template - inline bool ForEachHostage(Functor &func) const - { - for (int i = 0; i < m_hostageCount; i++) - { - CHostage *hostage = m_hostage[i]; - - if (hostage == NULL || hostage->pev->deadflag == DEAD_DEAD) - continue; - - if (func(hostage) == false) - return false; - } - - return true; - } - inline CHostage *GetClosestHostage(const Vector &pos, float *resultRange = NULL) - { - float range; - float closeRange = 1e8f; - CHostage *close = NULL; - - for (int i = 0; i < m_hostageCount; i++) - { - range = (m_hostage[i]->pev->origin - pos).Length(); - - if (range < closeRange) - { - closeRange = range; - close = m_hostage[i]; - } - } - - if (resultRange) - *resultRange = closeRange; - - return close; - } - -private: - CHostage *m_hostage[MAX_HOSTAGES]; - int m_hostageCount; - SimpleChatter m_chatter; -}; diff --git a/regamedll/extra/cssdk/dlls/hostage/hostage_improv.h b/regamedll/extra/cssdk/dlls/hostage/hostage_improv.h deleted file mode 100644 index 7616057a..00000000 --- a/regamedll/extra/cssdk/dlls/hostage/hostage_improv.h +++ /dev/null @@ -1,333 +0,0 @@ -/* -* -* This program is free software; you can redistribute it and/or modify it -* under the terms of the GNU General Public License as published by the -* Free Software Foundation; either version 2 of the License, or (at -* your option) any later version. -* -* This program 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 -* General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* -*/ -#pragma once - -#include "hostage/hostage.h" -#include "hostage/hostage_states.h" - -class CHostage; -enum HostageChatterType; - -// A Counter-Strike Hostage improved -class CHostageImprov: public CImprov { -public: - virtual ~CHostageImprov() {}; - - // invoked when an improv reaches its MoveTo goal - virtual void OnMoveToSuccess(const Vector &goal) = 0; - - // invoked when an improv fails to reach a MoveTo goal - virtual void OnMoveToFailure(const Vector &goal, MoveToFailureType reason) = 0; - virtual void OnInjury(float amount) = 0; - virtual bool IsAlive() const = 0; - virtual void MoveTo(const Vector &goal) = 0; - virtual void LookAt(const Vector &target) = 0; - virtual void ClearLookAt() = 0; - virtual void FaceTo(const Vector &goal) = 0; - virtual void ClearFaceTo() = 0; - virtual bool IsAtMoveGoal(float error = 20.0f) const = 0; - virtual bool HasLookAt() const = 0; - virtual bool HasFaceTo() const = 0; - virtual bool IsAtFaceGoal() const = 0; - virtual bool IsFriendInTheWay(const Vector &goalPos) const = 0; - virtual bool IsFriendInTheWay(CBaseEntity *myFriend, const Vector &goalPos) const = 0; - virtual void MoveForward() = 0; - virtual void MoveBackward() = 0; - virtual void StrafeLeft() = 0; - virtual void StrafeRight() = 0; - - #define HOSTAGE_MUST_JUMP true - virtual bool Jump() = 0; - - virtual void Crouch() = 0; - virtual void StandUp() = 0; - virtual void TrackPath(const Vector &pathGoal, float deltaT) = 0; // move along path by following "pathGoal" - virtual void StartLadder(const CNavLadder *ladder, NavTraverseType how, const Vector *approachPos, const Vector *departPos) = 0; - virtual bool TraverseLadder(const CNavLadder *ladder, NavTraverseType how, const Vector *approachPos, const Vector *departPos, float deltaT) = 0; - virtual bool GetSimpleGroundHeightWithFloor(const Vector *pos, float *height, Vector *normal = NULL) = 0; - virtual void Run() = 0; - virtual void Walk() = 0; - virtual void Stop() = 0; - virtual float GetMoveAngle() const = 0; - virtual float GetFaceAngle() const = 0; - virtual const Vector &GetFeet() const = 0; - virtual const Vector &GetCentroid() const = 0; - virtual const Vector &GetEyes() const = 0; - virtual bool IsRunning() const = 0; - virtual bool IsWalking() const = 0; - virtual bool IsStopped() const = 0; - virtual bool IsCrouching() const = 0; - virtual bool IsJumping() const = 0; - virtual bool IsUsingLadder() const = 0; - virtual bool IsOnGround() const = 0; - virtual bool IsMoving() const = 0; - virtual bool CanRun() const = 0; - virtual bool CanCrouch() const = 0; - virtual bool CanJump() const = 0; - virtual bool IsVisible(const Vector &pos, bool testFOV = false) const = 0; // return true if hostage can see position - virtual bool IsPlayerLookingAtMe(CBasePlayer *other, float cosTolerance = 0.95f) const = 0; - virtual CBasePlayer *IsAnyPlayerLookingAtMe(int team = 0, float cosTolerance = 0.95f) const = 0; - virtual CBasePlayer *GetClosestPlayerByTravelDistance(int team = 0, float *range = NULL) const = 0; - virtual CNavArea *GetLastKnownArea() const = 0; - virtual void OnUpdate(float deltaT) = 0; - virtual void OnUpkeep(float deltaT) = 0; - virtual void OnReset() = 0; - virtual void OnGameEvent(GameEventType event, CBaseEntity *entity = NULL, CBaseEntity *other = NULL) = 0; - virtual void OnTouch(CBaseEntity *other) = 0; // in contact with "other" -public: - enum MoveType { Stopped, Walking, Running }; - enum ScareType { NERVOUS, SCARED, TERRIFIED }; - - const Vector &GetKnownGoodPosition() const { return m_knownGoodPos; } - void ApplyForce(Vector force) { m_vel.x += force.x; m_vel.y += force.y; } // apply a force to the hostage - const Vector GetActualVelocity() const { return m_actualVel; } - void SetMoveLimit(MoveType limit) { m_moveLimit = limit; } - MoveType GetMoveLimit() const { return m_moveLimit; } - CNavPath *GetPath() { return &m_path; } - - // hostage states - // stand idle - void Idle() { m_behavior.SetState(&m_idleState); } - bool IsIdle() const { return m_behavior.IsState(&m_idleState); } - - // begin following "leader" - void Follow(CBasePlayer *leader) { m_followState.SetLeader(leader); m_behavior.SetState(&m_followState); } - bool IsFollowing(const CBaseEntity *leader = NULL) const { return m_behavior.IsState(&m_followState); } - - // Escape - void Escape() { m_behavior.SetState(&m_escapeState); } - bool IsEscaping() const { return m_behavior.IsState(&m_escapeState); } - - // Retreat - void Retreat() { m_behavior.SetState(&m_retreatState); } - bool IsRetreating() const { return m_behavior.IsState(&m_retreatState); } - - CBaseEntity *GetFollowLeader() const { return m_followState.GetLeader(); } - ScareType GetScareIntensity() const { return m_scareIntensity; } - bool IsIgnoringTerrorists() const { return m_ignoreTerroristTimer.IsElapsed(); } - float GetAggression() const { return m_aggression; } - bool IsTalking() const { return m_talkingTimer.IsElapsed(); } - CHostage *GetEntity() const { return m_hostage; } - void SetMoveAngle(float angle) { m_moveAngle = angle; } -public: - CountdownTimer m_coughTimer; - CountdownTimer m_grenadeTimer; -private: - CHostage *m_hostage; - CNavArea *m_lastKnownArea; // last area we were in - mutable Vector m_centroid; - mutable Vector m_eye; - HostageStateMachine m_behavior; - HostageIdleState m_idleState; - HostageEscapeState m_escapeState; - HostageRetreatState m_retreatState; - HostageFollowState m_followState; - HostageAnimateState m_animateState; - bool m_didFidget; - float m_aggression; - IntervalTimer m_lastSawCT; - IntervalTimer m_lastSawT; - CountdownTimer m_checkNearbyTerroristTimer; - bool m_isTerroristNearby; - CountdownTimer m_nearbyTerroristTimer; - CountdownTimer m_scaredTimer; - ScareType m_scareIntensity; - CountdownTimer m_ignoreTerroristTimer; - CountdownTimer m_blinkTimer; - char m_blinkCounter; - IntervalTimer m_lastInjuryTimer; - IntervalTimer m_lastNoiseTimer; - mutable CountdownTimer m_avoidFriendTimer; - mutable bool m_isFriendInTheWay; - CountdownTimer m_chatterTimer; - bool m_isDelayedChatterPending; - CountdownTimer m_delayedChatterTimer; - HostageChatterType m_delayedChatterType; - bool m_delayedChatterMustSpeak; - CountdownTimer m_talkingTimer; - unsigned int m_moveFlags; - Vector2D m_vel; - Vector m_actualVel; - Vector m_moveGoal; - Vector m_knownGoodPos; - bool m_hasKnownGoodPos; - Vector m_priorKnownGoodPos; - bool m_hasPriorKnownGoodPos; - CountdownTimer m_priorKnownGoodPosTimer; - IntervalTimer m_collisionTimer; - Vector m_viewGoal; - bool m_isLookingAt; - Vector m_faceGoal; - bool m_isFacingTo; - CNavPath m_path; // current path to follow - CNavPathFollower m_follower; - Vector m_lastPosition; - MoveType m_moveType; - MoveType m_moveLimit; - bool m_isCrouching; // true if hostage is crouching - CountdownTimer m_minCrouchTimer; - float m_moveAngle; - NavRelativeDirType m_wiggleDirection; - - CountdownTimer m_wiggleTimer; // for wiggling - CountdownTimer m_wiggleJumpTimer; - CountdownTimer m_inhibitObstacleAvoidance; - CountdownTimer m_jumpTimer; // if zero, we can jump - - bool m_hasJumped; - bool m_hasJumpedIntoAir; - Vector m_jumpTarget; - CountdownTimer m_clearPathTimer; - bool m_traversingLadder; - EHANDLE m_visiblePlayer[MAX_CLIENTS]; - int m_visiblePlayerCount; - CountdownTimer m_visionTimer; -}; - -class CheckWayFunctor { -public: - CheckWayFunctor(const CHostageImprov *me, const Vector &goalPos) - { - m_me = me; - m_goalPos = goalPos; - m_blocker = NULL; - } - bool operator()(CHostage *them) - { - if (((CBaseMonster *)them)->IsAlive() && m_me->IsFriendInTheWay((CBaseEntity *)them, m_goalPos)) - { - m_blocker = them; - return false; - } - - return true; - } - - const CHostageImprov *m_me; - Vector m_goalPos; - CHostage *m_blocker; -}; - -// Functor used with NavAreaBuildPath() for building Hostage paths. -// Once we hook up crouching and ladders, this can be removed and ShortestPathCost() can be used instead. -class HostagePathCost { -public: - float operator()(CNavArea *area, CNavArea *fromArea, const CNavLadder *ladder) - { - if (fromArea == NULL) - { - // first area in path, no cost - return 0.0f; - } - else - { - // compute distance travelled along path so far - float dist; - - if (ladder != NULL) - { - const float ladderCost = 10.0f; - return ladder->m_length * ladderCost + fromArea->GetCostSoFar(); - } - else - { - dist = (*area->GetCenter() - *fromArea->GetCenter()).Length(); - } - - float cost = dist + fromArea->GetCostSoFar(); - - // if this is a "crouch" area, add penalty - if (area->GetAttributes() & NAV_CROUCH) - { - const float crouchPenalty = 10.0f; - cost += crouchPenalty * dist; - } - - // if this is a "jump" area, add penalty - if (area->GetAttributes() & NAV_JUMP) - { - const float jumpPenalty = 10.0f; - cost += jumpPenalty * dist; - } - - return cost; - } - } -}; - -class KeepPersonalSpace { -public: - KeepPersonalSpace(CHostageImprov *improv) - { - m_improv = improv; - m_velDir = improv->GetActualVelocity(); - m_speed = m_velDir.NormalizeInPlace(); - } - bool operator()(CBaseEntity *entity) - { - const float space = 1.0f; - Vector to; - float range; - - if (entity == reinterpret_cast(m_improv->GetEntity())) - return true; - - if (entity->IsPlayer() && !entity->IsAlive()) - return true; - - to = entity->pev->origin - m_improv->GetCentroid(); - range = to.NormalizeInPlace(); - - CBasePlayer *player = static_cast(entity); - - const float spring = 50.0f; - const float damper = 1.0f; - - if (range >= spring) - return true; - - const float cosTolerance = 0.8f; - if (entity->IsPlayer() && player->m_iTeam == CT && !m_improv->IsFollowing() && m_improv->IsPlayerLookingAtMe(player, cosTolerance)) - return true; - - const float minSpace = (spring - range); - float ds = -minSpace; - - m_improv->ApplyForce(to * ds); - - const float force = 0.1f; - m_improv->ApplyForce(m_speed * -force * m_velDir); - - return true; - } - -private: - CHostageImprov *m_improv; - Vector m_velDir; - float m_speed; -}; diff --git a/regamedll/extra/cssdk/dlls/hostage/hostage_localnav.h b/regamedll/extra/cssdk/dlls/hostage/hostage_localnav.h deleted file mode 100644 index 5a40e6fa..00000000 --- a/regamedll/extra/cssdk/dlls/hostage/hostage_localnav.h +++ /dev/null @@ -1,58 +0,0 @@ -/* -* -* This program is free software; you can redistribute it and/or modify it -* under the terms of the GNU General Public License as published by the -* Free Software Foundation; either version 2 of the License, or (at -* your option) any later version. -* -* This program 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 -* General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* -*/ -#pragma once - -#define NODE_INVALID_EMPTY -1 - -#define PATH_TRAVERSABLE_EMPTY 0 -#define PATH_TRAVERSABLE_SLOPE 1 -#define PATH_TRAVERSABLE_STEP 2 -#define PATH_TRAVERSABLE_STEPJUMPABLE 3 - -typedef int node_index_t; - -typedef struct localnode_s -{ - Vector vecLoc; - int offsetX; - int offsetY; - byte bDepth; - BOOL fSearched; - node_index_t nindexParent; - -} localnode_t; - -class CLocalNav { -private: - CHostage *m_pOwner; - edict_t *m_pTargetEnt; - BOOL m_fTargetEntHit; - localnode_t *m_nodeArr; - node_index_t m_nindexAvailableNode; - Vector m_vecStartingLoc; -}; diff --git a/regamedll/extra/cssdk/dlls/hostage/hostage_states.h b/regamedll/extra/cssdk/dlls/hostage/hostage_states.h deleted file mode 100644 index 9ac99cfc..00000000 --- a/regamedll/extra/cssdk/dlls/hostage/hostage_states.h +++ /dev/null @@ -1,203 +0,0 @@ -/* -* -* This program is free software; you can redistribute it and/or modify it -* under the terms of the GNU General Public License as published by the -* Free Software Foundation; either version 2 of the License, or (at -* your option) any later version. -* -* This program 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 -* General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* -*/ -#pragma once - -class CHostageImprov; - -class HostageState: public SimpleState, public IImprovEvent { -public: - virtual ~HostageState() {} - virtual void UpdateStationaryAnimation(CHostageImprov *improv) {} -}; - -class HostageStateMachine: public SimpleStateMachine, public IImprovEvent { -public: - virtual void OnMoveToSuccess(const Vector &goal) {} - virtual void OnMoveToFailure(const Vector &goal, MoveToFailureType reason) {} - virtual void OnInjury(float amount) {} -}; - -class HostageIdleState: public HostageState { -public: - virtual ~HostageIdleState() {} - virtual void OnEnter(CHostageImprov *improv) {} - virtual void OnUpdate(CHostageImprov *improv) {} - virtual void OnExit(CHostageImprov *improv) {} - virtual const char *GetName() const { return "Idle"; } - virtual void UpdateStationaryAnimation(CHostageImprov *improv) {} - virtual void OnMoveToSuccess(const Vector &goal) {} - virtual void OnMoveToFailure(const Vector &goal, MoveToFailureType reason) {} - virtual void OnInjury(float amount = -1.0f) {} -private: - CountdownTimer m_waveTimer; - CountdownTimer m_fleeTimer; - CountdownTimer m_disagreeTimer; - CountdownTimer m_escapeTimer; - CountdownTimer m_askTimer; - IntervalTimer m_intimidatedTimer; - CountdownTimer m_pleadTimer; - - enum - { - NotMoving = 0, - Moving, - MoveDone, - MoveFailed, - } m_moveState; - - bool m_mustFlee; -}; - -class HostageEscapeToCoverState: public HostageState { -public: - virtual ~HostageEscapeToCoverState() {} - virtual void OnEnter(CHostageImprov *improv) {} - virtual void OnUpdate(CHostageImprov *improv) {} - virtual void OnExit(CHostageImprov *improv) {} - virtual const char *GetName() const { return "Escape:ToCover"; } - virtual void OnMoveToFailure(const Vector &goal, MoveToFailureType reason) {} -public: - void SetRescueGoal(const Vector &rescueGoal) { m_rescueGoal = rescueGoal; } - -private: - Vector m_rescueGoal; - Vector m_spot; - bool m_canEscape; -}; - -class HostageEscapeLookAroundState: public HostageState { -public: - virtual ~HostageEscapeLookAroundState() {} - virtual void OnEnter(CHostageImprov *improv) {} - virtual void OnUpdate(CHostageImprov *improv) {} - virtual void OnExit(CHostageImprov *improv) {} - virtual const char *GetName() const { return "Escape:LookAround"; } - -private: - CountdownTimer m_timer; -}; - -class HostageEscapeState: public HostageState { -public: - virtual ~HostageEscapeState() {} - virtual void OnEnter(CHostageImprov *improv) {} - virtual void OnUpdate(CHostageImprov *improv) {} - virtual void OnExit(CHostageImprov *improv) {} - virtual const char *GetName() const { return "Escape"; } - virtual void OnMoveToFailure(const Vector &goal, MoveToFailureType reason) {} -public: - void ToCover() { m_behavior.SetState(&m_toCoverState); } - void LookAround() { m_behavior.SetState(&m_lookAroundState); } -private: - HostageEscapeToCoverState m_toCoverState; - HostageEscapeLookAroundState m_lookAroundState; - HostageStateMachine m_behavior; - bool m_canEscape; - CountdownTimer m_runTimer; -}; - -class HostageRetreatState: public HostageState { -public: - virtual ~HostageRetreatState() {} - virtual void OnEnter(CHostageImprov *improv) {} - virtual void OnUpdate(CHostageImprov *improv) {} - virtual void OnExit(CHostageImprov *improv) {} - virtual const char *GetName() const { return "Retreat"; } -}; - -class HostageFollowState: public HostageState { -public: - virtual ~HostageFollowState() {} - virtual void OnEnter(CHostageImprov *improv) {} - virtual void OnUpdate(CHostageImprov *improv) {} - virtual void OnExit(CHostageImprov *improv) {} - virtual const char *GetName() const { return "Follow"; } - virtual void UpdateStationaryAnimation(CHostageImprov *improv) {} -public: - void SetLeader(CBaseEntity *leader) { m_leader = leader; } - CBaseEntity *GetLeader() const { return m_leader; } -private: - mutable EHANDLE m_leader; - Vector m_lastLeaderPos; - bool m_isWaiting; - float m_stopRange; - CountdownTimer m_makeWayTimer; - CountdownTimer m_impatientTimer; - CountdownTimer m_repathTimer; - bool m_isWaitingForFriend; - CountdownTimer m_waitForFriendTimer; -}; - -class HostageAnimateState: public HostageState { -public: - virtual ~HostageAnimateState() {} - virtual void OnEnter(CHostageImprov *improv) {} - virtual void OnUpdate(CHostageImprov *improv) {} - virtual void OnExit(CHostageImprov *improv) {} - virtual const char *GetName() const { return "Animate"; } -public: - struct SeqInfo - { - int seqID; - float holdTime; - float rate; - }; - - enum PerformanceType - { - None = 0, - Walk, - Run, - Jump, - Fall, - Crouch, - CrouchWalk, - Calm, - Anxious, - Afraid, - Sitting, - GettingUp, - Waving, - LookingAround, - Disagreeing, - Flinching, - }; - - bool IsBusy() const { return (m_sequenceCount > 0); } - int GetCurrentSequenceID() { return m_currentSequence; } - PerformanceType GetPerformance() const { return m_performance; } - void SetPerformance(PerformanceType performance) { m_performance = performance; } -private: - enum { MAX_SEQUENCES = 8 }; - struct SeqInfo m_sequence[MAX_SEQUENCES]; - int m_sequenceCount; - int m_currentSequence; - enum PerformanceType m_performance; - bool m_isHolding; - CountdownTimer m_holdTimer; -}; diff --git a/regamedll/extra/cssdk/dlls/items.h b/regamedll/extra/cssdk/dlls/items.h deleted file mode 100644 index 07a524e2..00000000 --- a/regamedll/extra/cssdk/dlls/items.h +++ /dev/null @@ -1,155 +0,0 @@ -/* -* -* This program is free software; you can redistribute it and/or modify it -* under the terms of the GNU General Public License as published by the -* Free Software Foundation; either version 2 of the License, or (at -* your option) any later version. -* -* This program 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 -* General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* -*/ -#pragma once - -enum ItemRestType -{ - ITEM_TYPE_BUYING, // when a player buying items - ITEM_TYPE_TOUCHED, // when the player touches with a weaponbox or armoury_entity - ITEM_TYPE_EQUIPPED // when an entity game_player_equip gives item to player or default item's on player spawn -}; - -// constant items -#define ITEM_ID_ANTIDOTE 2 -#define ITEM_ID_SECURITY 3 - -enum ItemID -{ - ITEM_NONE = -1, - ITEM_SHIELDGUN, - ITEM_P228, - ITEM_GLOCK, - ITEM_SCOUT, - ITEM_HEGRENADE, - ITEM_XM1014, - ITEM_C4, - ITEM_MAC10, - ITEM_AUG, - ITEM_SMOKEGRENADE, - ITEM_ELITE, - ITEM_FIVESEVEN, - ITEM_UMP45, - ITEM_SG550, - ITEM_GALIL, - ITEM_FAMAS, - ITEM_USP, - ITEM_GLOCK18, - ITEM_AWP, - ITEM_MP5N, - ITEM_M249, - ITEM_M3, - ITEM_M4A1, - ITEM_TMP, - ITEM_G3SG1, - ITEM_FLASHBANG, - ITEM_DEAGLE, - ITEM_SG552, - ITEM_AK47, - ITEM_KNIFE, - ITEM_P90, - ITEM_NVG, - ITEM_DEFUSEKIT, - ITEM_KEVLAR, - ITEM_ASSAULT, - ITEM_LONGJUMP, - ITEM_SODACAN, - ITEM_HEALTHKIT, - ITEM_ANTIDOTE, - ITEM_BATTERY -}; - -class CItem: public CBaseEntity { -public: - virtual void Spawn() = 0; - virtual CBaseEntity *Respawn() = 0; - virtual BOOL MyTouch(CBasePlayer *pPlayer) = 0; -}; - -class CWorldItem: public CBaseEntity { -public: - virtual void Spawn() = 0; - virtual void KeyValue(KeyValueData *pkvd) = 0; -public: - int m_iType; -}; - -class CItemSuit: public CItem { -public: - virtual void Spawn() = 0; - virtual void Precache() = 0; - virtual BOOL MyTouch(CBasePlayer *pPlayer) = 0; -}; - -class CItemBattery: public CItem { -public: - virtual void Spawn() = 0; - virtual void Precache() = 0; - virtual BOOL MyTouch(CBasePlayer *pPlayer) = 0; -}; - -class CItemAntidote: public CItem { -public: - virtual void Spawn() = 0; - virtual void Precache() = 0; - virtual BOOL MyTouch(CBasePlayer *pPlayer) = 0; -}; - -class CItemSecurity: public CItem { -public: - virtual void Spawn() = 0; - virtual void Precache() = 0; - virtual BOOL MyTouch(CBasePlayer *pPlayer) = 0; -}; - -class CItemLongJump: public CItem { -public: - virtual void Spawn() = 0; - virtual void Precache() = 0; - virtual BOOL MyTouch(CBasePlayer *pPlayer) = 0; -}; - -class CItemKevlar: public CItem { -public: - virtual void Spawn() = 0; - virtual void Precache() = 0; - virtual BOOL MyTouch(CBasePlayer *pPlayer) = 0; -}; - -class CItemAssaultSuit: public CItem { -public: - virtual void Spawn() = 0; - virtual void Precache() = 0; - virtual BOOL MyTouch(CBasePlayer *pPlayer) = 0; -}; - -class CItemThighPack: public CItem { -public: - virtual void Spawn() = 0; - virtual void Precache() = 0; - virtual BOOL MyTouch(CBasePlayer *pPlayer) = 0; -}; diff --git a/regamedll/extra/cssdk/dlls/lights.h b/regamedll/extra/cssdk/dlls/lights.h deleted file mode 100644 index df0fb68a..00000000 --- a/regamedll/extra/cssdk/dlls/lights.h +++ /dev/null @@ -1,50 +0,0 @@ -/* -* -* This program is free software; you can redistribute it and/or modify it -* under the terms of the GNU General Public License as published by the -* Free Software Foundation; either version 2 of the License, or (at -* your option) any later version. -* -* This program 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 -* General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* -*/ -#pragma once - -#define SF_LIGHT_START_OFF 1 - -class CLight: public CPointEntity { -public: - virtual void Spawn() = 0; - virtual void Restart() = 0; - virtual void KeyValue(KeyValueData *pkvd) = 0; - virtual int Save(CSave &save) = 0; - virtual int Restore(CRestore &restore) = 0; - virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) = 0; -private: - int m_iStyle; - int m_iszPattern; - BOOL m_iStartedOff; -}; - -class CEnvLight: public CLight { -public: - virtual void Spawn() = 0; - virtual void KeyValue(KeyValueData *pkvd) = 0; -}; diff --git a/regamedll/extra/cssdk/dlls/mapinfo.h b/regamedll/extra/cssdk/dlls/mapinfo.h deleted file mode 100644 index f6805fe6..00000000 --- a/regamedll/extra/cssdk/dlls/mapinfo.h +++ /dev/null @@ -1,41 +0,0 @@ -/* -* -* This program is free software; you can redistribute it and/or modify it -* under the terms of the GNU General Public License as published by the -* Free Software Foundation; either version 2 of the License, or (at -* your option) any later version. -* -* This program 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 -* General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* -*/ - -#pragma once - -class CMapInfo: public CPointEntity -{ -public: - virtual void Spawn() = 0; - virtual void KeyValue(KeyValueData *pkvd) = 0; - virtual void UpdateOnRemove() = 0; - -public: - InfoMapBuyParam m_iBuyingStatus; - float m_flBombRadius; -}; diff --git a/regamedll/extra/cssdk/dlls/maprules.h b/regamedll/extra/cssdk/dlls/maprules.h deleted file mode 100644 index dde173ed..00000000 --- a/regamedll/extra/cssdk/dlls/maprules.h +++ /dev/null @@ -1,236 +0,0 @@ -/* -* -* This program is free software; you can redistribute it and/or modify it -* under the terms of the GNU General Public License as published by the -* Free Software Foundation; either version 2 of the License, or (at -* your option) any later version. -* -* This program 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 -* General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* -*/ -#pragma once - -#define MAX_EQUIP 32 -#define SF_SCORE_NEGATIVE 0x0001 -#define SF_SCORE_TEAM 0x0002 - -#define SF_ENVTEXT_ALLPLAYERS 0x0001 - -#define SF_TEAMMASTER_FIREONCE 0x0001 -#define SF_TEAMMASTER_ANYTEAM 0x0002 - -#define SF_TEAMSET_FIREONCE 0x0001 -#define SF_TEAMSET_CLEARTEAM 0x0002 - -#define SF_PKILL_FIREONCE 0x0001 - -#define SF_GAMECOUNT_FIREONCE 0x0001 -#define SF_GAMECOUNT_RESET 0x0002 - -#define SF_GAMECOUNTSET_FIREONCE 0x0001 - -#define SF_PLAYEREQUIP_USEONLY 0x0001 - -#define SF_PTEAM_FIREONCE 0x0001 -#define SF_PTEAM_KILL 0x0002 -#define SF_PTEAM_GIB 0x0004 - -class CRuleEntity: public CBaseEntity { -public: - virtual void Spawn() = 0; - virtual void KeyValue(KeyValueData *pkvd) = 0; - virtual int Save(CSave &save) = 0; - virtual int Restore(CRestore &restore) = 0; -public: - void SetMaster(int iszMaster) { m_iszMaster = iszMaster; } - -private: - string_t m_iszMaster; -}; - -// CRulePointEntity -- base class for all rule "point" entities (not brushes) -class CRulePointEntity: public CRuleEntity { -public: - virtual void Spawn() = 0; -}; - -// CRuleBrushEntity -- base class for all rule "brush" entities (not brushes) -// Default behavior is to set up like a trigger, invisible, but keep the model for volume testing -class CRuleBrushEntity: public CRuleEntity { -public: - virtual void Spawn() = 0; -}; - -// CGameScore / game_score -- award points to player / team -// Points +/- total -// Flag: Allow negative scores SF_SCORE_NEGATIVE -// Flag: Award points to team in teamplay SF_SCORE_TEAM -class CGameScore: public CRulePointEntity { -public: - virtual void Spawn() = 0; - virtual void KeyValue(KeyValueData *pkvd) = 0; - virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) = 0; -public: - int Points() const { return int(pev->frags); } - BOOL AllowNegativeScore() { return pev->spawnflags & SF_SCORE_NEGATIVE; } - BOOL AwardToTeam() const { return pev->spawnflags & SF_SCORE_TEAM; } - void SetPoints(int points) { pev->frags = points; } -}; - -// CGameEnd / game_end -- Ends the game in MP -class CGameEnd: public CRulePointEntity { -public: - virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) = 0; -}; - -// CGameText / game_text -- NON-Localized HUD Message (use env_message to display a titles.txt message) -// Flag: All players SF_ENVTEXT_ALLPLAYERS -class CGameText: public CRulePointEntity { -public: - virtual void KeyValue(KeyValueData *pkvd) = 0; - virtual int Save(CSave &save) = 0; - virtual int Restore(CRestore &restore) = 0; - virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) = 0; - -public: - BOOL MessageToAll() const { return (pev->spawnflags & SF_ENVTEXT_ALLPLAYERS) == SF_ENVTEXT_ALLPLAYERS; } - void MessageSet(const char *pMessage) { pev->message = ALLOC_STRING(pMessage); } - const char *MessageGet() const { return STRING(pev->message); } - -private: - hudtextparms_t m_textParms; -}; - -// CGameTeamMaster / game_team_master -- "Masters" like multisource, but based on the team of the activator -// Only allows mastered entity to fire if the team matches my team -// -// team index (pulled from server team list "mp_teamlist" -// Flag: Remove on Fire -// Flag: Any team until set? -- Any team can use this until the team is set (otherwise no teams can use it) -class CGameTeamMaster: public CRulePointEntity { -public: - virtual void KeyValue(KeyValueData *pkvd) = 0; - virtual int ObjectCaps() = 0; - virtual BOOL IsTriggered(CBaseEntity *pActivator) = 0; - virtual const char *TeamID() = 0; - virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) = 0; -public: - BOOL RemoveOnFire() const { return (pev->spawnflags & SF_TEAMMASTER_FIREONCE) == SF_TEAMMASTER_FIREONCE; } - BOOL AnyTeam() const { return (pev->spawnflags & SF_TEAMMASTER_ANYTEAM) == SF_TEAMMASTER_ANYTEAM; } - -public: - int m_teamIndex; - USE_TYPE triggerType; -}; - -// CGameTeamSet / game_team_set -- Changes the team of the entity it targets to the activator's team -// Flag: Fire once -// Flag: Clear team -- Sets the team to "NONE" instead of activator -class CGameTeamSet: public CRulePointEntity { -public: - virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) = 0; -public: - BOOL RemoveOnFire() const { return (pev->spawnflags & SF_TEAMSET_FIREONCE) == SF_TEAMSET_FIREONCE; } - BOOL ShouldClearTeam() const { return (pev->spawnflags & SF_TEAMSET_CLEARTEAM) == SF_TEAMSET_CLEARTEAM; } -}; - -// CGamePlayerZone / game_player_zone -- players in the zone fire my target when I'm fired -// Needs master? -class CGamePlayerZone: public CRuleBrushEntity { -public: - virtual void KeyValue(KeyValueData *pkvd) = 0; - virtual int Save(CSave &save) = 0; - virtual int Restore(CRestore &restore) = 0; - virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) = 0; -private: - string_t m_iszInTarget; - string_t m_iszOutTarget; - string_t m_iszInCount; - string_t m_iszOutCount; -}; - -// CGamePlayerHurt / game_player_hurt -- Damages the player who fires it -// Flag: Fire once -class CGamePlayerHurt: public CRulePointEntity { -public: - virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) = 0; -public: - BOOL RemoveOnFire() const { return (pev->spawnflags & SF_PKILL_FIREONCE) == SF_PKILL_FIREONCE; } -}; - -// CGameCounter / game_counter -- Counts events and fires target -// Flag: Fire once -// Flag: Reset on Fire -class CGameCounter: public CRulePointEntity { -public: - virtual void Spawn() = 0; - virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) = 0; -public: - BOOL RemoveOnFire() const { return (pev->spawnflags & SF_GAMECOUNT_FIREONCE) == SF_GAMECOUNT_FIREONCE; } - BOOL ResetOnFire() const { return (pev->spawnflags & SF_GAMECOUNT_RESET) == SF_GAMECOUNT_RESET; } - - void CountUp() { pev->frags++; } - void CountDown() { pev->frags--; } - void ResetCount() { pev->frags = pev->dmg; } - - int CountValue() const { return int(pev->frags); } - int LimitValue() const { return int(pev->health); } - BOOL HitLimit() const { return CountValue() == LimitValue(); } - -private: - void SetCountValue(int value) { pev->frags = value; } - void SetInitialValue(int value) { pev->dmg = value; } -}; - -// CGameCounterSet / game_counter_set -- Sets the counter's value -// Flag: Fire once -class CGameCounterSet: public CRulePointEntity { -public: - virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) = 0; -public: - BOOL RemoveOnFire() const { return (pev->spawnflags & SF_GAMECOUNTSET_FIREONCE) == SF_GAMECOUNTSET_FIREONCE; } -}; - -// CGamePlayerEquip / game_playerequip -- Sets the default player equipment -// Flag: USE Only -class CGamePlayerEquip: public CRulePointEntity { -public: - virtual void KeyValue(KeyValueData *pkvd) = 0; - virtual void Touch(CBaseEntity *pOther) = 0; - virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) = 0; -public: - BOOL UseOnly() const { return (pev->spawnflags & SF_PLAYEREQUIP_USEONLY) == SF_PLAYEREQUIP_USEONLY; } -public: - string_t m_weaponNames[ MAX_EQUIP ]; - int m_weaponCount[ MAX_EQUIP ]; -}; - -// CGamePlayerTeam / game_player_team -- Changes the team of the player who fired it -// Flag: Fire once -// Flag: Kill Player -// Flag: Gib Player -class CGamePlayerTeam: public CRulePointEntity { -public: - virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) = 0; -private: - BOOL RemoveOnFire() const { return (pev->spawnflags & SF_PTEAM_FIREONCE) == SF_PTEAM_FIREONCE; } - BOOL ShouldKillPlayer() const { return (pev->spawnflags & SF_PTEAM_KILL) == SF_PTEAM_KILL; } - BOOL ShouldGibPlayer() const { return (pev->spawnflags & SF_PTEAM_GIB) == SF_PTEAM_GIB; } -}; diff --git a/regamedll/extra/cssdk/dlls/monsterevent.h b/regamedll/extra/cssdk/dlls/monsterevent.h deleted file mode 100644 index d3f32055..00000000 --- a/regamedll/extra/cssdk/dlls/monsterevent.h +++ /dev/null @@ -1,44 +0,0 @@ -/* -* -* This program is free software; you can redistribute it and/or modify it -* under the terms of the GNU General Public License as published by the -* Free Software Foundation; either version 2 of the License, or (at -* your option) any later version. -* -* This program 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 -* General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* -*/ -#pragma once - -typedef struct MonsterEvent_s -{ - int event; - char *options; - -} MonsterEvent_t; - -#define EVENT_SPECIFIC 0 -#define EVENT_SCRIPTED 1000 -#define EVENT_SHARED 2000 -#define EVENT_CLIENT 5000 - -#define MONSTER_EVENT_BODYDROP_LIGHT 2001 -#define MONSTER_EVENT_BODYDROP_HEAVY 2002 -#define MONSTER_EVENT_SWISHSOUND 2010 diff --git a/regamedll/extra/cssdk/dlls/monsters.h b/regamedll/extra/cssdk/dlls/monsters.h deleted file mode 100644 index 842e058c..00000000 --- a/regamedll/extra/cssdk/dlls/monsters.h +++ /dev/null @@ -1,113 +0,0 @@ -/* -* -* This program is free software; you can redistribute it and/or modify it -* under the terms of the GNU General Public License as published by the -* Free Software Foundation; either version 2 of the License, or (at -* your option) any later version. -* -* This program 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 -* General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* -*/ -#pragma once - -#define LOCALMOVE_INVALID 0 // move is not possible -#define LOCALMOVE_INVALID_DONT_TRIANGULATE 1 // move is not possible, don't try to triangulate -#define LOCALMOVE_VALID 2 // move is possible - -#define SF_MONSTER_WAIT_TILL_SEEN 1 // spawnflag that makes monsters wait until player can see them before attacking. -#define SF_MONSTER_GAG 2 // no idle noises from this monster -#define SF_MONSTER_HITMONSTERCLIP 4 -#define SF_MONSTER_PRISONER 16 // monster won't attack anyone, no one will attacke him. - -#define SF_MONSTER_WAIT_FOR_SCRIPT 128 //spawnflag that makes monsters wait to check for attacking until the script is done or they've been attacked -#define SF_MONSTER_PREDISASTER 256 //this is a predisaster scientist or barney. Influences how they speak. -#define SF_MONSTER_FADECORPSE 512 // Fade out corpse after death -#define SF_MONSTER_FALL_TO_GROUND 0x80000000 - -#define SF_MONSTER_TURRET_AUTOACTIVATE 32 -#define SF_MONSTER_TURRET_STARTINACTIVE 64 -#define SF_MONSTER_WAIT_UNTIL_PROVOKED 64 // don't attack the player unless provoked - -#define MOVE_START_TURN_DIST 64 // when this far away from moveGoal, start turning to face next goal -#define MOVE_STUCK_DIST 32 // if a monster can't step this far, it is stuck. - -#define MOVE_NORMAL 0 // normal move in the direction monster is facing -#define MOVE_STRAFE 1 // moves in direction specified, no matter which way monster is facing - -#define R_AL -2 // (ALLY) pals. Good alternative to R_NO when applicable. -#define R_FR -1 // (FEAR)will run -#define R_NO 0 // (NO RELATIONSHIP) disregard -#define R_DL 1 // (DISLIKE) will attack -#define R_HT 2 // (HATE)will attack this character instead of any visible DISLIKEd characters -#define R_NM 3 // (NEMESIS) A monster Will ALWAYS attack its nemsis, no matter what - -#define MEMORY_CLEAR 0 -#define bits_MEMORY_PROVOKED (1 << 0) // right now only used for houndeyes. -#define bits_MEMORY_INCOVER (1 << 1) // monster knows it is in a covered position. -#define bits_MEMORY_SUSPICIOUS (1 << 2) // Ally is suspicious of the player, and will move to provoked more easily -#define bits_MEMORY_PATH_FINISHED (1 << 3) // Finished monster path (just used by big momma for now) -#define bits_MEMORY_ON_PATH (1 << 4) // Moving on a path -#define bits_MEMORY_MOVE_FAILED (1 << 5) // Movement has already failed -#define bits_MEMORY_FLINCHED (1 << 6) // Has already flinched -#define bits_MEMORY_KILLED (1 << 7) // HACKHACK -- remember that I've already called my Killed() -#define bits_MEMORY_CUSTOM4 (1 << 28) // Monster-specific memory -#define bits_MEMORY_CUSTOM3 (1 << 29) // Monster-specific memory -#define bits_MEMORY_CUSTOM2 (1 << 30) // Monster-specific memory -#define bits_MEMORY_CUSTOM1 (1 << 31) // Monster-specific memory - -enum -{ - AITRIGGER_NONE = 0, - AITRIGGER_SEEPLAYER_ANGRY_AT_PLAYER, - AITRIGGER_TAKEDAMAGE, - AITRIGGER_HALFHEALTH, - AITRIGGER_DEATH, - AITRIGGER_SQUADMEMBERDIE, - AITRIGGER_SQUADLEADERDIE, - AITRIGGER_HEARWORLD, - AITRIGGER_HEARPLAYER, - AITRIGGER_HEARCOMBAT, - AITRIGGER_SEEPLAYER_UNCONDITIONAL, - AITRIGGER_SEEPLAYER_NOT_IN_COMBAT, -}; - -enum HitBoxGroup -{ - HITGROUP_GENERIC = 0, - HITGROUP_HEAD, - HITGROUP_CHEST, - HITGROUP_STOMACH, - HITGROUP_LEFTARM, - HITGROUP_RIGHTARM, - HITGROUP_LEFTLEG, - HITGROUP_RIGHTLEG, - HITGROUP_SHIELD, - NUM_HITGROUPS, -}; - -class CGib: public CBaseEntity { -public: - virtual int ObjectCaps() = 0; -public: - int m_bloodColor; - int m_cBloodDecals; - int m_material; - float m_lifeTime; -}; diff --git a/regamedll/extra/cssdk/dlls/observer.h b/regamedll/extra/cssdk/dlls/observer.h deleted file mode 100644 index 67585a54..00000000 --- a/regamedll/extra/cssdk/dlls/observer.h +++ /dev/null @@ -1,32 +0,0 @@ -/* -* -* This program is free software; you can redistribute it and/or modify it -* under the terms of the GNU General Public License as published by the -* Free Software Foundation; either version 2 of the License, or (at -* your option) any later version. -* -* This program 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 -* General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* -*/ -#pragma once - -#define CAMERA_MODE_SPEC_ANYONE 0 -#define CAMERA_MODE_SPEC_ONLY_TEAM 1 -#define CAMERA_MODE_SPEC_ONLY_FRIST_PERSON 2 diff --git a/regamedll/extra/cssdk/dlls/pathcorner.h b/regamedll/extra/cssdk/dlls/pathcorner.h deleted file mode 100644 index 5be28a3a..00000000 --- a/regamedll/extra/cssdk/dlls/pathcorner.h +++ /dev/null @@ -1,39 +0,0 @@ -/* -* -* This program is free software; you can redistribute it and/or modify it -* under the terms of the GNU General Public License as published by the -* Free Software Foundation; either version 2 of the License, or (at -* your option) any later version. -* -* This program 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 -* General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* -*/ -#pragma once - -class CPathCorner: public CPointEntity { -public: - virtual void Spawn() = 0; - virtual void KeyValue(KeyValueData *pkvd) = 0; - virtual int Save(CSave &save) = 0; - virtual int Restore(CRestore &restore) = 0; - virtual float GetDelay() = 0; -private: - float m_flWait; -}; diff --git a/regamedll/extra/cssdk/dlls/plats.h b/regamedll/extra/cssdk/dlls/plats.h deleted file mode 100644 index ec67be3f..00000000 --- a/regamedll/extra/cssdk/dlls/plats.h +++ /dev/null @@ -1,178 +0,0 @@ -/* -* -* This program is free software; you can redistribute it and/or modify it -* under the terms of the GNU General Public License as published by the -* Free Software Foundation; either version 2 of the License, or (at -* your option) any later version. -* -* This program 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 -* General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* -*/ -#pragma once - -#define SF_PLAT_TOGGLE 0x0001 - -#define TRAIN_STARTPITCH 60 -#define TRAIN_MAXPITCH 200 -#define TRAIN_MAXSPEED 1000 - -#define SF_TRACK_ACTIVATETRAIN 0x00000001 -#define SF_TRACK_RELINK 0x00000002 -#define SF_TRACK_ROTMOVE 0x00000004 -#define SF_TRACK_STARTBOTTOM 0x00000008 -#define SF_TRACK_DONT_MOVE 0x00000010 - -#define FGUNTARGET_START_ON 0x0001 - -class CBasePlatTrain: public CBaseToggle { -public: - virtual void Precache() = 0; - virtual void KeyValue(KeyValueData *pkvd) = 0; - virtual int Save(CSave &save) = 0; - virtual int Restore(CRestore &restore) = 0; - virtual int ObjectCaps() = 0; - - // This is done to fix spawn flag collisions between this class and a derived class - virtual BOOL IsTogglePlat() = 0; -public: - byte m_bMoveSnd; - byte m_bStopSnd; - float m_volume; -}; - -class CFuncPlat: public CBasePlatTrain { -public: - virtual void Spawn() = 0; - virtual void Precache() = 0; - virtual void Blocked(CBaseEntity *pOther) = 0; - virtual void GoUp() = 0; - virtual void GoDown() = 0; - virtual void HitTop() = 0; - virtual void HitBottom() = 0; -}; - -class CPlatTrigger: public CBaseEntity { -public: - virtual int ObjectCaps() = 0; - virtual void Touch(CBaseEntity *pOther) = 0; -public: - CFuncPlat *m_pPlatform; -}; - -class CFuncPlatRot: public CFuncPlat { -public: - virtual void Spawn() = 0; - virtual int Save(CSave &save) = 0; - virtual int Restore(CRestore &restore) = 0; - virtual void GoUp() = 0; - virtual void GoDown() = 0; - virtual void HitTop() = 0; - virtual void HitBottom() = 0; -public: - Vector m_end; - Vector m_start; -}; - -class CFuncTrain: public CBasePlatTrain { -public: - virtual void Spawn() = 0; - virtual void Precache() = 0; - virtual void Restart() = 0; - virtual void KeyValue(KeyValueData *pkvd) = 0; - virtual int Save(CSave &save) = 0; - virtual int Restore(CRestore &restore) = 0; - virtual void Activate() = 0; - virtual void OverrideReset() = 0; - virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) = 0; - virtual void Blocked(CBaseEntity *pOther) = 0; -public: - Vector m_vStartPosition; - entvars_t *m_pevFirstTarget; - entvars_t *m_pevCurrentTarget; - int m_sounds; - BOOL m_activated; -}; - -class CFuncTrainControls: public CBaseEntity { -public: - virtual void Spawn() = 0; - virtual int ObjectCaps() = 0; -}; - -class CFuncTrackChange: public CFuncPlatRot { -public: - virtual void Spawn() = 0; - virtual void Precache() = 0; - virtual void KeyValue(KeyValueData *pkvd) = 0; - virtual int Save(CSave &save) = 0; - virtual int Restore(CRestore &restore) = 0; - virtual void OverrideReset() = 0; - virtual void Touch(CBaseEntity *pOther) = 0; - virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) = 0; - virtual BOOL IsTogglePlat() = 0; - virtual void GoUp() = 0; - virtual void GoDown() = 0; - virtual void HitTop() = 0; - virtual void HitBottom() = 0; - virtual void UpdateAutoTargets(int toggleState) = 0; - -public: - void DisableUse() { m_use = 0; } - void EnableUse() { m_use = 1; } - - int UseEnabled() const { return m_use; } - -public: - static TYPEDESCRIPTION IMPL(m_SaveData)[9]; - - CPathTrack *m_trackTop; - CPathTrack *m_trackBottom; - CFuncTrackTrain *m_train; - - int m_trackTopName; - int m_trackBottomName; - int m_trainName; - - TRAIN_CODE m_code; - int m_targetState; - int m_use; -}; - -class CFuncTrackAuto: public CFuncTrackChange { -public: - virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) = 0; - virtual void UpdateAutoTargets(int toggleState) = 0; -}; - -class CGunTarget: public CBaseMonster { -public: - virtual void Spawn() = 0; - virtual int Save(CSave &save) = 0; - virtual int Restore(CRestore &restore) = 0; - virtual int ObjectCaps() = 0; - virtual void Activate() = 0; - virtual int Classify() = 0; - virtual BOOL TakeDamage(entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType) = 0; - virtual int BloodColor() = 0; - virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) = 0; - virtual Vector BodyTarget(const Vector &posSrc) = 0; -private: - BOOL m_on; -}; diff --git a/regamedll/extra/cssdk/dlls/player.h b/regamedll/extra/cssdk/dlls/player.h deleted file mode 100644 index 49ecf400..00000000 --- a/regamedll/extra/cssdk/dlls/player.h +++ /dev/null @@ -1,625 +0,0 @@ -/* -* -* This program is free software; you can redistribute it and/or modify it -* under the terms of the GNU General Public License as published by the -* Free Software Foundation; either version 2 of the License, or (at -* your option) any later version. -* -* This program 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 -* General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* -*/ -#pragma once - -#include "pm_materials.h" -#include "hintmessage.h" -#include "unisignals.h" - -#define MIN_BUY_TIME 15 // the minimum threshold values for cvar mp_buytime 15 sec's - -#define MAX_BUFFER_MENU 175 -#define MAX_BUFFER_MENU_BRIEFING 50 - -#define MAX_PLAYER_NAME_LENGTH 32 -#define MAX_AUTOBUY_LENGTH 256 -#define MAX_REBUY_LENGTH 256 - -#define MAX_RECENT_PATH 20 -#define MAX_HOSTAGE_ICON 4 // the maximum number of icons of the hostages in the HUD - -#define SUITUPDATETIME 3.5 -#define SUITFIRSTUPDATETIME 0.1 - -#define PLAYER_FATAL_FALL_SPEED 1100.0f -#define PLAYER_MAX_SAFE_FALL_SPEED 500.0f -#define PLAYER_USE_RADIUS 64.0f - -#define ARMOR_RATIO 0.5 // Armor Takes 50% of the damage -#define ARMOR_BONUS 0.5 // Each Point of Armor is work 1/x points of health - -#define FLASH_DRAIN_TIME 1.2 // 100 units/3 minutes -#define FLASH_CHARGE_TIME 0.2 // 100 units/20 seconds (seconds per unit) - -// damage per unit per second. -#define DAMAGE_FOR_FALL_SPEED 100.0f / (PLAYER_FATAL_FALL_SPEED - PLAYER_MAX_SAFE_FALL_SPEED) -#define PLAYER_MIN_BOUNCE_SPEED 350.0f - -// won't punch player's screen/make scrape noise unless player falling at least this fast. -#define PLAYER_FALL_PUNCH_THRESHHOLD 250.0f - -// Money blinks few of times on the freeze period -// NOTE: It works for CZ -#define MONEY_BLINK_AMOUNT 30 - -// Player physics flags bits -// CBasePlayer::m_afPhysicsFlags -#define PFLAG_ONLADDER (1<<0) -#define PFLAG_ONSWING (1<<0) -#define PFLAG_ONTRAIN (1<<1) -#define PFLAG_ONBARNACLE (1<<2) -#define PFLAG_DUCKING (1<<3) // In the process of ducking, but totally squatted yet -#define PFLAG_USING (1<<4) // Using a continuous entity -#define PFLAG_OBSERVER (1<<5) // player is locked in stationary cam mode. Spectators can move, observers can't. - -#define TRAIN_OFF 0x00 -#define TRAIN_NEUTRAL 0x01 -#define TRAIN_SLOW 0x02 -#define TRAIN_MEDIUM 0x03 -#define TRAIN_FAST 0x04 -#define TRAIN_BACK 0x05 - -#define TRAIN_ACTIVE 0x80 -#define TRAIN_NEW 0xc0 - -#define SIGNAL_BUY (1<<0) -#define SIGNAL_BOMB (1<<1) -#define SIGNAL_RESCUE (1<<2) -#define SIGNAL_ESCAPE (1<<3) -#define SIGNAL_VIPSAFETY (1<<4) - -#define IGNOREMSG_NONE 0 -#define IGNOREMSG_ENEMY 1 -#define IGNOREMSG_TEAM 2 - -// max of 4 suit sentences queued up at any time -#define CSUITPLAYLIST 4 - -#define SUIT_GROUP TRUE -#define SUIT_SENTENCE FALSE - -#define SUIT_REPEAT_OK 0 -#define SUIT_NEXT_IN_30SEC 30 -#define SUIT_NEXT_IN_1MIN 60 -#define SUIT_NEXT_IN_5MIN 300 -#define SUIT_NEXT_IN_10MIN 600 -#define SUIT_NEXT_IN_30MIN 1800 -#define SUIT_NEXT_IN_1HOUR 3600 - -#define TEAM_NAME_LENGTH 16 - -#define MAX_ID_RANGE 2048.0f -#define MAX_SPECTATOR_ID_RANGE 8192.0f -#define SBAR_STRING_SIZE 128 - -#define SBAR_TARGETTYPE_TEAMMATE 1 -#define SBAR_TARGETTYPE_ENEMY 2 -#define SBAR_TARGETTYPE_HOSTAGE 3 - -#define CHAT_INTERVAL 1.0f -#define CSUITNOREPEAT 32 - -#define AUTOAIM_2DEGREES 0.0348994967025 -#define AUTOAIM_5DEGREES 0.08715574274766 -#define AUTOAIM_8DEGREES 0.1391731009601 -#define AUTOAIM_10DEGREES 0.1736481776669 - -#define SOUND_FLASHLIGHT_ON "items/flashlight1.wav" -#define SOUND_FLASHLIGHT_OFF "items/flashlight1.wav" - -// custom enum -enum RewardType -{ - RT_NONE, - RT_ROUND_BONUS, - RT_PLAYER_RESET, - RT_PLAYER_JOIN, - RT_PLAYER_SPEC_JOIN, - RT_PLAYER_BOUGHT_SOMETHING, - RT_HOSTAGE_TOOK, - RT_HOSTAGE_RESCUED, - RT_HOSTAGE_DAMAGED, - RT_HOSTAGE_KILLED, - RT_TEAMMATES_KILLED, - RT_ENEMY_KILLED, - RT_INTO_GAME, - RT_VIP_KILLED, - RT_VIP_RESCUED_MYSELF -}; - -enum PLAYER_ANIM -{ - PLAYER_IDLE, - PLAYER_WALK, - PLAYER_JUMP, - PLAYER_SUPERJUMP, - PLAYER_DIE, - PLAYER_ATTACK1, - PLAYER_ATTACK2, - PLAYER_FLINCH, - PLAYER_LARGE_FLINCH, - PLAYER_RELOAD, - PLAYER_HOLDBOMB -}; - -enum _Menu -{ - Menu_OFF, - Menu_ChooseTeam, - Menu_IGChooseTeam, - Menu_ChooseAppearance, - Menu_Buy, - Menu_BuyPistol, - Menu_BuyRifle, - Menu_BuyMachineGun, - Menu_BuyShotgun, - Menu_BuySubMachineGun, - Menu_BuyItem, - Menu_Radio1, - Menu_Radio2, - Menu_Radio3, - Menu_ClientBuy -}; - -enum TeamName -{ - UNASSIGNED, - TERRORIST, - CT, - SPECTATOR, -}; - -enum ModelName -{ - MODEL_UNASSIGNED, - MODEL_URBAN, - MODEL_TERROR, - MODEL_LEET, - MODEL_ARCTIC, - MODEL_GSG9, - MODEL_GIGN, - MODEL_SAS, - MODEL_GUERILLA, - MODEL_VIP, - MODEL_MILITIA, - MODEL_SPETSNAZ, - MODEL_AUTO -}; - -enum JoinState -{ - JOINED, - SHOWLTEXT, - READINGLTEXT, - SHOWTEAMSELECT, - PICKINGTEAM, - GETINTOGAME -}; - -enum TrackCommands -{ - CMD_SAY = 0, - CMD_SAYTEAM, - CMD_FULLUPDATE, - CMD_VOTE, - CMD_VOTEMAP, - CMD_LISTMAPS, - CMD_LISTPLAYERS, - CMD_NIGHTVISION, - COMMANDS_TO_TRACK, -}; - -struct RebuyStruct -{ - int m_primaryWeapon; - int m_primaryAmmo; - int m_secondaryWeapon; - int m_secondaryAmmo; - int m_heGrenade; - int m_flashbang; - int m_smokeGrenade; - int m_defuser; - int m_nightVision; - ArmorType m_armor; -}; - -enum ThrowDirection -{ - THROW_NONE, - THROW_FORWARD, - THROW_BACKWARD, - THROW_HITVEL, - THROW_BOMB, - THROW_GRENADE, - THROW_HITVEL_MINUS_AIRVEL -}; - -enum sbar_data -{ - SBAR_ID_TARGETTYPE = 1, - SBAR_ID_TARGETNAME, - SBAR_ID_TARGETHEALTH, - SBAR_END -}; - -enum MusicState { SILENT, CALM, INTENSE }; - -class CCSPlayer; - -class CStripWeapons: public CPointEntity { -public: - virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) = 0; -}; - -// Multiplayer intermission spots. -class CInfoIntermission: public CPointEntity { -public: - virtual void Spawn() = 0; - virtual void Think() = 0; -}; - -// Dead HEV suit prop -class CDeadHEV: public CBaseMonster { -public: - virtual void Spawn() = 0; - virtual void KeyValue(KeyValueData *pkvd) = 0; - virtual int Classify() = 0; -public: - int m_iPose; // which sequence to display -- temporary, don't need to save - static char *m_szPoses[4]; -}; - -class CSprayCan: public CBaseEntity { -public: - virtual void Think() = 0; - virtual int ObjectCaps() = 0; -}; - -class CBloodSplat: public CBaseEntity { -public: -}; - -class CBasePlayer: public CBaseMonster { -public: - virtual void Spawn() = 0; - virtual void Precache() = 0; - virtual int Save(CSave &save) = 0; - virtual int Restore(CRestore &restore) = 0; - virtual int ObjectCaps() = 0; - virtual int Classify() = 0; - virtual void TraceAttack(entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType) = 0; - virtual BOOL TakeDamage(entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType) = 0; - virtual BOOL TakeHealth(float flHealth, int bitsDamageType) = 0; - virtual void Killed(entvars_t *pevAttacker, int iGib) = 0; - virtual void AddPoints(int score, BOOL bAllowNegativeScore) = 0; - virtual void AddPointsToTeam(int score, BOOL bAllowNegativeScore) = 0; - virtual BOOL AddPlayerItem(CBasePlayerItem *pItem) = 0; - virtual BOOL RemovePlayerItem(CBasePlayerItem *pItem) = 0; - virtual int GiveAmmo(int iAmount, const char *szName, int iMax = -1) = 0; - virtual void StartSneaking() = 0; - virtual void UpdateOnRemove() = 0; - virtual BOOL IsSneaking() = 0; - virtual BOOL IsAlive() = 0; - virtual BOOL IsPlayer() = 0; - virtual BOOL IsNetClient() = 0; - virtual const char *TeamID() = 0; - virtual BOOL FBecomeProne() = 0; - virtual Vector BodyTarget(const Vector &posSrc) = 0; - virtual int Illumination() = 0; - virtual BOOL ShouldFadeOnDeath() = 0; - virtual void ResetMaxSpeed() = 0; - virtual void Jump() = 0; - virtual void Duck() = 0; - virtual void PreThink() = 0; - virtual void PostThink() = 0; - virtual Vector GetGunPosition() = 0; - virtual BOOL IsBot() = 0; - virtual void UpdateClientData() = 0; - virtual void ImpulseCommands() = 0; - virtual void RoundRespawn() = 0; - virtual Vector GetAutoaimVector(float flDelta) = 0; - virtual void Blind(float flUntilTime, float flHoldTime, float flFadeTime, int iAlpha) = 0; - virtual void OnTouchingWeapon(CWeaponBox *pWeapon) = 0; -public: - static CBasePlayer *Instance(edict_t *pent) { return (CBasePlayer *)GET_PRIVATE(pent ? pent : ENT(0)); } - static CBasePlayer *Instance(entvars_t *pev) { return Instance(ENT(pev)); } - static CBasePlayer *Instance(int offset) { return Instance(ENT(offset)); } - - int IsObserver() { return pev->iuser1; } - void SetWeaponAnimType(const char *szExtention) { strcpy(m_szAnimExtention, szExtention); } - bool IsProtectedByShield() { return m_bOwnsShield && m_bShieldDrawn; } - bool IsReloading() const; - bool IsBlind() const { return (m_blindUntilTime > gpGlobals->time); } - bool IsAutoFollowAllowed() const { return (gpGlobals->time > m_allowAutoFollowTime); } - void InhibitAutoFollow(float duration) { m_allowAutoFollowTime = gpGlobals->time + duration; } - void AllowAutoFollow() { m_allowAutoFollowTime = 0; } - void SetObserverAutoDirector(bool val) { m_bObserverAutoDirector = val; } - bool CanSwitchObserverModes() const { return m_canSwitchObserverModes; } - CCSPlayer *CSPlayer() const; - - // templates - template - CBasePlayerItem *ForEachItem(int slot, const Functor &func) - { - auto item = m_rgpPlayerItems[ slot ]; - while (item) - { - if (func(item)) - return item; - - item = item->m_pNext; - } - return nullptr; - } - template - CBasePlayerItem *ForEachItem(const Functor &func) - { - for (auto item : m_rgpPlayerItems) - { - while (item) - { - if (func(item)) - return item; - - item = item->m_pNext; - } - } - return nullptr; - } -public: - enum { MaxLocationLen = 32 }; - - int random_seed; - unsigned short m_usPlayerBleed; - EHANDLE m_hObserverTarget; - float m_flNextObserverInput; - int m_iObserverWeapon; - int m_iObserverC4State; - bool m_bObserverHasDefuser; - int m_iObserverLastMode; - float m_flFlinchTime; - float m_flAnimTime; - bool m_bHighDamage; - float m_flVelocityModifier; - int m_iLastZoom; - bool m_bResumeZoom; - float m_flEjectBrass; - ArmorType m_iKevlar; - bool m_bNotKilled; - TeamName m_iTeam; - int m_iAccount; - bool m_bHasPrimary; - float m_flDeathThrowTime; - int m_iThrowDirection; - float m_flLastTalk; - bool m_bJustConnected; - bool m_bContextHelp; - JoinState m_iJoiningState; - CBaseEntity *m_pIntroCamera; - float m_fIntroCamTime; - float m_fLastMovement; - bool m_bMissionBriefing; - bool m_bTeamChanged; - ModelName m_iModelName; - int m_iTeamKills; - int m_iIgnoreGlobalChat; - bool m_bHasNightVision; - bool m_bNightVisionOn; - Vector m_vRecentPath[MAX_RECENT_PATH]; - float m_flIdleCheckTime; - float m_flRadioTime; - int m_iRadioMessages; - bool m_bIgnoreRadio; - bool m_bHasC4; - bool m_bHasDefuser; - bool m_bKilledByBomb; - Vector m_vBlastVector; - bool m_bKilledByGrenade; - CHintMessageQueue m_hintMessageQueue; - int m_flDisplayHistory; - _Menu m_iMenu; - int m_iChaseTarget; - CBaseEntity *m_pChaseTarget; - float m_fCamSwitch; - bool m_bEscaped; - bool m_bIsVIP; - float m_tmNextRadarUpdate; - Vector m_vLastOrigin; - int m_iCurrentKickVote; - float m_flNextVoteTime; - bool m_bJustKilledTeammate; - int m_iHostagesKilled; - int m_iMapVote; - bool m_bCanShoot; - float m_flLastFired; - float m_flLastAttackedTeammate; - bool m_bHeadshotKilled; - bool m_bPunishedForTK; - bool m_bReceivesNoMoneyNextRound; - int m_iTimeCheckAllowed; - bool m_bHasChangedName; - char m_szNewName[MAX_PLAYER_NAME_LENGTH]; - bool m_bIsDefusing; - float m_tmHandleSignals; - CUnifiedSignals m_signals; - edict_t *m_pentCurBombTarget; - int m_iPlayerSound; - int m_iTargetVolume; - int m_iWeaponVolume; - int m_iExtraSoundTypes; - int m_iWeaponFlash; - float m_flStopExtraSoundTime; - float m_flFlashLightTime; - int m_iFlashBattery; - int m_afButtonLast; - int m_afButtonPressed; - int m_afButtonReleased; - edict_t *m_pentSndLast; - float m_flSndRoomtype; - float m_flSndRange; - float m_flFallVelocity; - int m_rgItems[MAX_ITEMS]; - int m_fNewAmmo; - unsigned int m_afPhysicsFlags; - float m_fNextSuicideTime; - float m_flTimeStepSound; - float m_flTimeWeaponIdle; - float m_flSwimTime; - float m_flDuckTime; - float m_flWallJumpTime; - float m_flSuitUpdate; - int m_rgSuitPlayList[CSUITPLAYLIST]; - int m_iSuitPlayNext; - int m_rgiSuitNoRepeat[CSUITNOREPEAT]; - float m_rgflSuitNoRepeatTime[CSUITNOREPEAT]; - int m_lastDamageAmount; - float m_tbdPrev; - float m_flgeigerRange; - float m_flgeigerDelay; - int m_igeigerRangePrev; - int m_iStepLeft; - char m_szTextureName[CBTEXTURENAMEMAX]; - char m_chTextureType; - int m_idrowndmg; - int m_idrownrestored; - int m_bitsHUDDamage; - BOOL m_fInitHUD; - BOOL m_fGameHUDInitialized; - int m_iTrain; - BOOL m_fWeapon; - EHANDLE m_pTank; - float m_fDeadTime; - BOOL m_fNoPlayerSound; - BOOL m_fLongJump; - float m_tSneaking; - int m_iUpdateTime; - int m_iClientHealth; - int m_iClientBattery; - int m_iHideHUD; - int m_iClientHideHUD; - int m_iFOV; - int m_iClientFOV; - int m_iNumSpawns; - CBaseEntity *m_pObserver; - CBasePlayerItem *m_rgpPlayerItems[MAX_ITEM_TYPES]; - CBasePlayerItem *m_pActiveItem; - CBasePlayerItem *m_pClientActiveItem; - CBasePlayerItem *m_pLastItem; - int m_rgAmmo[MAX_AMMO_SLOTS]; - int m_rgAmmoLast[MAX_AMMO_SLOTS]; - Vector m_vecAutoAim; - BOOL m_fOnTarget; - int m_iDeaths; - int m_izSBarState[SBAR_END]; - float m_flNextSBarUpdateTime; - float m_flStatusBarDisappearDelay; - char m_SbarString0[SBAR_STRING_SIZE]; - int m_lastx; - int m_lasty; - int m_nCustomSprayFrames; - float m_flNextDecalTime; - char m_szTeamName[TEAM_NAME_LENGTH]; - int m_modelIndexPlayer; - char m_szAnimExtention[32]; - int m_iGaitsequence; - float m_flGaitframe; - float m_flGaityaw; - Vector m_prevgaitorigin; - float m_flPitch; - float m_flYaw; - float m_flGaitMovement; - int m_iAutoWepSwitch; - bool m_bVGUIMenus; - bool m_bShowHints; - bool m_bShieldDrawn; - bool m_bOwnsShield; - bool m_bWasFollowing; - float m_flNextFollowTime; - float m_flYawModifier; - float m_blindUntilTime; - float m_blindStartTime; - float m_blindHoldTime; - float m_blindFadeTime; - int m_blindAlpha; - float m_allowAutoFollowTime; - char m_autoBuyString[MAX_AUTOBUY_LENGTH]; - char *m_rebuyString; - RebuyStruct m_rebuyStruct; - bool m_bIsInRebuy; - float m_flLastUpdateTime; - char m_lastLocation[MaxLocationLen]; - float m_progressStart; - float m_progressEnd; - bool m_bObserverAutoDirector; - bool m_canSwitchObserverModes; - float m_heartBeatTime; - float m_intenseTimestamp; - float m_silentTimestamp; - MusicState m_musicState; - float m_flLastCommandTime[COMMANDS_TO_TRACK]; -}; - -class CWShield: public CBaseEntity { -public: - virtual void Spawn() = 0; - virtual void Touch(CBaseEntity *pOther) = 0; -public: - void SetCantBePickedUpByUser(CBaseEntity *pEntity, float time) { m_hEntToIgnoreTouchesFrom = pEntity; m_flTimeToIgnoreTouches = gpGlobals->time + time; } -public: - EHANDLE m_hEntToIgnoreTouchesFrom; - float m_flTimeToIgnoreTouches; -}; - -inline bool CBasePlayer::IsReloading() const -{ - CBasePlayerWeapon *weapon = static_cast(m_pActiveItem); - if (weapon && weapon->m_fInReload) - return true; - - return false; -} - -inline CCSPlayer *CBasePlayer::CSPlayer() const { - return reinterpret_cast(this->m_pEntity); -} - -// returns a CBaseEntity pointer to a player by index. Only returns if the player is spawned and connected otherwise returns NULL -// Index is 1 based -inline CBasePlayer *UTIL_PlayerByIndex(int playerIndex) -{ - return (CBasePlayer *)GET_PRIVATE(INDEXENT(playerIndex)); -} - -inline CBasePlayer *UTIL_PlayerByIndexSafe(int playerIndex) -{ - CBasePlayer *player = nullptr; - if (likely(playerIndex > 0 && playerIndex <= gpGlobals->maxClients)) - player = UTIL_PlayerByIndex(playerIndex); - - return player; -} diff --git a/regamedll/extra/cssdk/dlls/regamedll_api.h b/regamedll/extra/cssdk/dlls/regamedll_api.h deleted file mode 100644 index 5cefdd5a..00000000 --- a/regamedll/extra/cssdk/dlls/regamedll_api.h +++ /dev/null @@ -1,490 +0,0 @@ -/* -* -* This program is free software; you can redistribute it and/or modify it -* under the terms of the GNU General Public License as published by the -* Free Software Foundation; either version 2 of the License, or (at -* your option) any later version. -* -* This program 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 -* General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* -*/ -#pragma once -#include "archtypes.h" -#include "regamedll_interfaces.h" -#include "hookchains.h" -#include "interface.h" -#include "player.h" -#include "gamerules.h" -#include "client.h" -#include "items.h" - -#define REGAMEDLL_API_VERSION_MAJOR 5 -#define REGAMEDLL_API_VERSION_MINOR 3 - -// CBasePlayer::Spawn hook -typedef IVoidHookChainClass IReGameHook_CBasePlayer_Spawn; -typedef IVoidHookChainRegistryClass IReGameHookRegistry_CBasePlayer_Spawn; - -// CBasePlayer::Precache hook -typedef IVoidHookChainClass IReGameHook_CBasePlayer_Precache; -typedef IVoidHookChainRegistryClass IReGameHookRegistry_CBasePlayer_Precache; - -// CBasePlayer::ObjectCaps hook -typedef IHookChainClass IReGameHook_CBasePlayer_ObjectCaps; -typedef IHookChainRegistryClass IReGameHookRegistry_CBasePlayer_ObjectCaps; - -// CBasePlayer::Classify hook -typedef IHookChainClass IReGameHook_CBasePlayer_Classify; -typedef IHookChainRegistryClass IReGameHookRegistry_CBasePlayer_Classify; - -// CBasePlayer::TraceAttack hook -typedef IVoidHookChainClass IReGameHook_CBasePlayer_TraceAttack; -typedef IVoidHookChainRegistryClass IReGameHookRegistry_CBasePlayer_TraceAttack; - -// CBasePlayer::TakeDamage hook -typedef IHookChainClass IReGameHook_CBasePlayer_TakeDamage; -typedef IHookChainRegistryClass IReGameHookRegistry_CBasePlayer_TakeDamage; - -// CBasePlayer::TakeHealth hook -typedef IHookChainClass IReGameHook_CBasePlayer_TakeHealth; -typedef IHookChainRegistryClass IReGameHookRegistry_CBasePlayer_TakeHealth; - -// CBasePlayer::Killed hook -typedef IVoidHookChainClass IReGameHook_CBasePlayer_Killed; -typedef IVoidHookChainRegistryClass IReGameHookRegistry_CBasePlayer_Killed; - -// CBasePlayer::AddPoints hook -typedef IVoidHookChainClass IReGameHook_CBasePlayer_AddPoints; -typedef IVoidHookChainRegistryClass IReGameHookRegistry_CBasePlayer_AddPoints; - -// CBasePlayer::AddPointsToTeam hook -typedef IVoidHookChainClass IReGameHook_CBasePlayer_AddPointsToTeam; -typedef IVoidHookChainRegistryClass IReGameHookRegistry_CBasePlayer_AddPointsToTeam; - -// CBasePlayer::AddPlayerItem hook -typedef IHookChainClass IReGameHook_CBasePlayer_AddPlayerItem; -typedef IHookChainRegistryClass IReGameHookRegistry_CBasePlayer_AddPlayerItem; - -// CBasePlayer::RemovePlayerItem hook -typedef IHookChainClass IReGameHook_CBasePlayer_RemovePlayerItem; -typedef IHookChainRegistryClass IReGameHookRegistry_CBasePlayer_RemovePlayerItem; - -// CBasePlayer::GiveAmmo hook -typedef IHookChainClass IReGameHook_CBasePlayer_GiveAmmo; -typedef IHookChainRegistryClass IReGameHookRegistry_CBasePlayer_GiveAmmo; - -// CBasePlayer::ResetMaxSpeed hook -typedef IVoidHookChainClass IReGameHook_CBasePlayer_ResetMaxSpeed; -typedef IVoidHookChainRegistryClass IReGameHookRegistry_CBasePlayer_ResetMaxSpeed; - -// CBasePlayer::Jump hook -typedef IVoidHookChainClass IReGameHook_CBasePlayer_Jump; -typedef IVoidHookChainRegistryClass IReGameHookRegistry_CBasePlayer_Jump; - -// CBasePlayer::Duck hook -typedef IVoidHookChainClass IReGameHook_CBasePlayer_Duck; -typedef IVoidHookChainRegistryClass IReGameHookRegistry_CBasePlayer_Duck; - -// CBasePlayer::PreThink hook -typedef IVoidHookChainClass IReGameHook_CBasePlayer_PreThink; -typedef IVoidHookChainRegistryClass IReGameHookRegistry_CBasePlayer_PreThink; - -// CBasePlayer::PostThink hook -typedef IVoidHookChainClass IReGameHook_CBasePlayer_PostThink; -typedef IVoidHookChainRegistryClass IReGameHookRegistry_CBasePlayer_PostThink; - -// CBasePlayer::UpdateClientData hook -typedef IVoidHookChainClass IReGameHook_CBasePlayer_UpdateClientData; -typedef IVoidHookChainRegistryClass IReGameHookRegistry_CBasePlayer_UpdateClientData; - -// CBasePlayer::ImpulseCommands hook -typedef IVoidHookChainClass IReGameHook_CBasePlayer_ImpulseCommands; -typedef IVoidHookChainRegistryClass IReGameHookRegistry_CBasePlayer_ImpulseCommands; - -// CBasePlayer::RoundRespawn hook -typedef IVoidHookChainClass IReGameHook_CBasePlayer_RoundRespawn; -typedef IVoidHookChainRegistryClass IReGameHookRegistry_CBasePlayer_RoundRespawn; - -// CBasePlayer::Blind hook -typedef IVoidHookChainClass IReGameHook_CBasePlayer_Blind; -typedef IVoidHookChainRegistryClass IReGameHookRegistry_CBasePlayer_Blind; - -// CBasePlayer::Observer_IsValidTarget hook -typedef IHookChainClass IReGameHook_CBasePlayer_Observer_IsValidTarget; -typedef IHookChainRegistryClass IReGameHookRegistry_CBasePlayer_Observer_IsValidTarget; - -// CBasePlayer::SetAnimation hook -typedef IVoidHookChainClass IReGameHook_CBasePlayer_SetAnimation; -typedef IVoidHookChainRegistryClass IReGameHookRegistry_CBasePlayer_SetAnimation; - -// CBasePlayer::GiveDefaultItems hook -typedef IVoidHookChainClass IReGameHook_CBasePlayer_GiveDefaultItems; -typedef IVoidHookChainRegistryClass IReGameHookRegistry_CBasePlayer_GiveDefaultItems; - -// CBasePlayer::GiveNamedItem hook -typedef IHookChainClass IReGameHook_CBasePlayer_GiveNamedItem; -typedef IHookChainRegistryClass IReGameHookRegistry_CBasePlayer_GiveNamedItem; - -// CBasePlayer::AddAccount hook -typedef IVoidHookChainClass IReGameHook_CBasePlayer_AddAccount; -typedef IVoidHookChainRegistryClass IReGameHookRegistry_CBasePlayer_AddAccount; - -// CBasePlayer::GiveShield hook -typedef IVoidHookChainClass IReGameHook_CBasePlayer_GiveShield; -typedef IVoidHookChainRegistryClass IReGameHookRegistry_CBasePlayer_GiveShield; - -// CBasePlayer:SetClientUserInfoModel hook -typedef IVoidHookChainClass IReGameHook_CBasePlayer_SetClientUserInfoModel; -typedef IVoidHookChainRegistryClass IReGameHookRegistry_CBasePlayer_SetClientUserInfoModel; - -// CBasePlayer:SetClientUserInfoName hook -typedef IHookChainClass IReGameHook_CBasePlayer_SetClientUserInfoName; -typedef IHookChainRegistryClass IReGameHookRegistry_CBasePlayer_SetClientUserInfoName; - -// CBasePlayer::HasRestrictItem hook -typedef IHookChainClass IReGameHook_CBasePlayer_HasRestrictItem; -typedef IHookChainRegistryClass IReGameHookRegistry_CBasePlayer_HasRestrictItem; - -// CBasePlayer::DropPlayerItem hook -typedef IVoidHookChainClass IReGameHook_CBasePlayer_DropPlayerItem; -typedef IVoidHookChainRegistryClass IReGameHookRegistry_CBasePlayer_DropPlayerItem; - -// CBasePlayer::DropShield hook -typedef IVoidHookChainClass IReGameHook_CBasePlayer_DropShield; -typedef IVoidHookChainRegistryClass IReGameHookRegistry_CBasePlayer_DropShield; - -// CBasePlayer::OnSpawnEquip hook -typedef IVoidHookChainClass IReGameHook_CBasePlayer_OnSpawnEquip; -typedef IVoidHookChainRegistryClass IReGameHookRegistry_CBasePlayer_OnSpawnEquip; - -// CBasePlayer::Radio hook -typedef IVoidHookChainClass IReGameHook_CBasePlayer_Radio; -typedef IVoidHookChainRegistryClass IReGameHookRegistry_CBasePlayer_Radio; - -// CBasePlayer::Disappear hook -typedef IVoidHookChainClass IReGameHook_CBasePlayer_Disappear; -typedef IVoidHookChainRegistryClass IReGameHookRegistry_CBasePlayer_Disappear; - -// CBasePlayer::MakeVIP hook -typedef IVoidHookChainClass IReGameHook_CBasePlayer_MakeVIP; -typedef IVoidHookChainRegistryClass IReGameHookRegistry_CBasePlayer_MakeVIP; - -// CBasePlayer::MakeBomber hook -typedef IHookChainClass IReGameHook_CBasePlayer_MakeBomber; -typedef IHookChainRegistryClass IReGameHookRegistry_CBasePlayer_MakeBomber; - -// CBasePlayer::StartObserver hook -typedef IVoidHookChainClass IReGameHook_CBasePlayer_StartObserver; -typedef IVoidHookChainRegistryClass IReGameHookRegistry_CBasePlayer_StartObserver; - -// CBasePlayer::GetIntoGame hook -typedef IHookChainClass IReGameHook_CBasePlayer_GetIntoGame; -typedef IHookChainRegistryClass IReGameHookRegistry_CBasePlayer_GetIntoGame; - -// CBaseAnimating::ResetSequenceInfo hook -typedef IVoidHookChainClass IReGameHook_CBaseAnimating_ResetSequenceInfo; -typedef IVoidHookChainRegistryClass IReGameHookRegistry_CBaseAnimating_ResetSequenceInfo; - -// GetForceCamera hook -typedef IHookChain IReGameHook_GetForceCamera; -typedef IHookChainRegistry IReGameHookRegistry_GetForceCamera; - -// PlayerBlind hook -typedef IVoidHookChain IReGameHook_PlayerBlind; -typedef IVoidHookChainRegistry IReGameHookRegistry_PlayerBlind; - -// RadiusFlash_TraceLine hook -typedef IVoidHookChain IReGameHook_RadiusFlash_TraceLine; -typedef IVoidHookChainRegistry IReGameHookRegistry_RadiusFlash_TraceLine; - -// RoundEnd hook -typedef IHookChain IReGameHook_RoundEnd; -typedef IHookChainRegistry IReGameHookRegistry_RoundEnd; - -// InstallGameRules hook -typedef IHookChain IReGameHook_InstallGameRules; -typedef IHookChainRegistry IReGameHookRegistry_InstallGameRules; - -// PM_Init hook -typedef IVoidHookChain IReGameHook_PM_Init; -typedef IVoidHookChainRegistry IReGameHookRegistry_PM_Init; - -// PM_Move hook -typedef IVoidHookChain IReGameHook_PM_Move; -typedef IVoidHookChainRegistry IReGameHookRegistry_PM_Move; - -// PM_AirMove hook -typedef IVoidHookChain IReGameHook_PM_AirMove; -typedef IVoidHookChainRegistry IReGameHookRegistry_PM_AirMove; - -// HandleMenu_ChooseAppearance hook -typedef IVoidHookChain IReGameHook_HandleMenu_ChooseAppearance; -typedef IVoidHookChainRegistry IReGameHookRegistry_HandleMenu_ChooseAppearance; - -// HandleMenu_ChooseTeam hook -typedef IHookChain IReGameHook_HandleMenu_ChooseTeam; -typedef IHookChainRegistry IReGameHookRegistry_HandleMenu_ChooseTeam; - -// ShowMenu hook -typedef IVoidHookChain IReGameHook_ShowMenu; -typedef IVoidHookChainRegistry IReGameHookRegistry_ShowMenu; - -// ShowVGUIMenu hook -typedef IVoidHookChain IReGameHook_ShowVGUIMenu; -typedef IVoidHookChainRegistry IReGameHookRegistry_ShowVGUIMenu; - -// BuyGunAmmo hook -typedef IHookChain IReGameHook_BuyGunAmmo; -typedef IHookChainRegistry IReGameHookRegistry_BuyGunAmmo; - -// BuyWeaponByWeaponID hook -typedef IHookChain IReGameHook_BuyWeaponByWeaponID; -typedef IHookChainRegistry IReGameHookRegistry_BuyWeaponByWeaponID; - -// InternalCommand hook -typedef IHookChain IReGameHook_InternalCommand; -typedef IHookChainRegistry IReGameHookRegistry_InternalCommand; - -// CHalfLifeMultiplay::FShouldSwitchWeapon hook -typedef IHookChain IReGameHook_CSGameRules_FShouldSwitchWeapon; -typedef IHookChainRegistry IReGameHookRegistry_CSGameRules_FShouldSwitchWeapon; - -// CHalfLifeMultiplay::GetNextBestWeapon hook -typedef IHookChain IReGameHook_CSGameRules_GetNextBestWeapon; -typedef IHookChainRegistry IReGameHookRegistry_CSGameRules_GetNextBestWeapon; - -// CHalfLifeMultiplay::FlPlayerFallDamage hook -typedef IHookChain IReGameHook_CSGameRules_FlPlayerFallDamage; -typedef IHookChainRegistry IReGameHookRegistry_CSGameRules_FlPlayerFallDamage; - -// CHalfLifeMultiplay::FPlayerCanTakeDamage hook -typedef IHookChain IReGameHook_CSGameRules_FPlayerCanTakeDamage; -typedef IHookChainRegistry IReGameHookRegistry_CSGameRules_FPlayerCanTakeDamage; - -// CHalfLifeMultiplay::PlayerSpawn hook -typedef IVoidHookChain IReGameHook_CSGameRules_PlayerSpawn; -typedef IVoidHookChainRegistry IReGameHookRegistry_CSGameRules_PlayerSpawn; - -// CHalfLifeMultiplay::FPlayerCanRespawn hook -typedef IHookChain IReGameHook_CSGameRules_FPlayerCanRespawn; -typedef IHookChainRegistry IReGameHookRegistry_CSGameRules_FPlayerCanRespawn; - -// CHalfLifeMultiplay::GetPlayerSpawnSpot hook -typedef IHookChain IReGameHook_CSGameRules_GetPlayerSpawnSpot; -typedef IHookChainRegistry IReGameHookRegistry_CSGameRules_GetPlayerSpawnSpot; - -// CHalfLifeMultiplay::ClientUserInfoChanged hook -typedef IVoidHookChain IReGameHook_CSGameRules_ClientUserInfoChanged; -typedef IVoidHookChainRegistry IReGameHookRegistry_CSGameRules_ClientUserInfoChanged; - -// CHalfLifeMultiplay::PlayerKilled hook -typedef IVoidHookChain IReGameHook_CSGameRules_PlayerKilled; -typedef IVoidHookChainRegistry IReGameHookRegistry_CSGameRules_PlayerKilled; - -// CHalfLifeMultiplay::DeathNotice hook -typedef IVoidHookChain IReGameHook_CSGameRules_DeathNotice; -typedef IVoidHookChainRegistry IReGameHookRegistry_CSGameRules_DeathNotice; - -// CHalfLifeMultiplay::CanHavePlayerItem hook -typedef IHookChain IReGameHook_CSGameRules_CanHavePlayerItem; -typedef IHookChainRegistry IReGameHookRegistry_CSGameRules_CanHavePlayerItem; - -// CHalfLifeMultiplay::DeadPlayerWeapons hook -typedef IHookChain IReGameHook_CSGameRules_DeadPlayerWeapons; -typedef IHookChainRegistry IReGameHookRegistry_CSGameRules_DeadPlayerWeapons; - -// CHalfLifeMultiplay::ServerDeactivate hook -typedef IVoidHookChain<> IReGameHook_CSGameRules_ServerDeactivate; -typedef IVoidHookChainRegistry<> IReGameHookRegistry_CSGameRules_ServerDeactivate; - -// CHalfLifeMultiplay::CheckMapConditions hook -typedef IVoidHookChain<> IReGameHook_CSGameRules_CheckMapConditions; -typedef IVoidHookChainRegistry<> IReGameHookRegistry_CSGameRules_CheckMapConditions; - -// CHalfLifeMultiplay::CleanUpMap hook -typedef IVoidHookChain<> IReGameHook_CSGameRules_CleanUpMap; -typedef IVoidHookChainRegistry<> IReGameHookRegistry_CSGameRules_CleanUpMap; - -// CHalfLifeMultiplay::RestartRound hook -typedef IVoidHookChain<> IReGameHook_CSGameRules_RestartRound; -typedef IVoidHookChainRegistry<> IReGameHookRegistry_CSGameRules_RestartRound; - -// CHalfLifeMultiplay::CheckWinConditions hook -typedef IVoidHookChain<> IReGameHook_CSGameRules_CheckWinConditions; -typedef IVoidHookChainRegistry<> IReGameHookRegistry_CSGameRules_CheckWinConditions; - -// CHalfLifeMultiplay::RemoveGuns hook -typedef IVoidHookChain<> IReGameHook_CSGameRules_RemoveGuns; -typedef IVoidHookChainRegistry<> IReGameHookRegistry_CSGameRules_RemoveGuns; - -// CHalfLifeMultiplay::GiveC4 hook -typedef IVoidHookChain<> IReGameHook_CSGameRules_GiveC4; -typedef IVoidHookChainRegistry<> IReGameHookRegistry_CSGameRules_GiveC4; - -// CHalfLifeMultiplay::ChangeLevel hook -typedef IVoidHookChain<> IReGameHook_CSGameRules_ChangeLevel; -typedef IVoidHookChainRegistry<> IReGameHookRegistry_CSGameRules_ChangeLevel; - -// CHalfLifeMultiplay::GoToIntermission hook -typedef IVoidHookChain<> IReGameHook_CSGameRules_GoToIntermission; -typedef IVoidHookChainRegistry<> IReGameHookRegistry_CSGameRules_GoToIntermission; - -// CHalfLifeMultiplay::BalanceTeams hook -typedef IVoidHookChain<> IReGameHook_CSGameRules_BalanceTeams; -typedef IVoidHookChainRegistry<> IReGameHookRegistry_CSGameRules_BalanceTeams; - -// CHalfLifeMultiplay::OnRoundFreezeEnd hook -typedef IVoidHookChain<> IReGameHook_CSGameRules_OnRoundFreezeEnd; -typedef IVoidHookChainRegistry<> IReGameHookRegistry_CSGameRules_OnRoundFreezeEnd; - -// PM_UpdateStepSound hook -typedef IVoidHookChain<> IReGameHook_PM_UpdateStepSound; -typedef IVoidHookChainRegistry<> IReGameHookRegistry_PM_UpdateStepSound; - -// CBasePlayer::StartDeathCam hook -typedef IVoidHookChainClass IReGameHook_CBasePlayer_StartDeathCam; -typedef IVoidHookChainRegistryClass IReGameHookRegistry_CBasePlayer_StartDeathCam; - -class IReGameHookchains { -public: - virtual ~IReGameHookchains() {} - - // CBasePlayer virtual - virtual IReGameHookRegistry_CBasePlayer_Spawn* CBasePlayer_Spawn() = 0; - virtual IReGameHookRegistry_CBasePlayer_Precache* CBasePlayer_Precache() = 0; - virtual IReGameHookRegistry_CBasePlayer_ObjectCaps* CBasePlayer_ObjectCaps() = 0; - virtual IReGameHookRegistry_CBasePlayer_Classify* CBasePlayer_Classify() = 0; - virtual IReGameHookRegistry_CBasePlayer_TraceAttack* CBasePlayer_TraceAttack() = 0; - virtual IReGameHookRegistry_CBasePlayer_TakeDamage* CBasePlayer_TakeDamage() = 0; - virtual IReGameHookRegistry_CBasePlayer_TakeHealth* CBasePlayer_TakeHealth() = 0; - virtual IReGameHookRegistry_CBasePlayer_Killed* CBasePlayer_Killed() = 0; - virtual IReGameHookRegistry_CBasePlayer_AddPoints* CBasePlayer_AddPoints() = 0; - virtual IReGameHookRegistry_CBasePlayer_AddPointsToTeam* CBasePlayer_AddPointsToTeam() = 0; - virtual IReGameHookRegistry_CBasePlayer_AddPlayerItem* CBasePlayer_AddPlayerItem() = 0; - virtual IReGameHookRegistry_CBasePlayer_RemovePlayerItem* CBasePlayer_RemovePlayerItem() = 0; - virtual IReGameHookRegistry_CBasePlayer_GiveAmmo* CBasePlayer_GiveAmmo() = 0; - virtual IReGameHookRegistry_CBasePlayer_ResetMaxSpeed* CBasePlayer_ResetMaxSpeed() = 0; - virtual IReGameHookRegistry_CBasePlayer_Jump* CBasePlayer_Jump() = 0; - virtual IReGameHookRegistry_CBasePlayer_Duck* CBasePlayer_Duck() = 0; - virtual IReGameHookRegistry_CBasePlayer_PreThink* CBasePlayer_PreThink() = 0; - virtual IReGameHookRegistry_CBasePlayer_PostThink* CBasePlayer_PostThink() = 0; - virtual IReGameHookRegistry_CBasePlayer_UpdateClientData* CBasePlayer_UpdateClientData() = 0; - virtual IReGameHookRegistry_CBasePlayer_ImpulseCommands* CBasePlayer_ImpulseCommands() = 0; - virtual IReGameHookRegistry_CBasePlayer_RoundRespawn* CBasePlayer_RoundRespawn() = 0; - virtual IReGameHookRegistry_CBasePlayer_Blind* CBasePlayer_Blind() = 0; - - virtual IReGameHookRegistry_CBasePlayer_Observer_IsValidTarget* CBasePlayer_Observer_IsValidTarget() = 0; - virtual IReGameHookRegistry_CBasePlayer_SetAnimation* CBasePlayer_SetAnimation() = 0; - virtual IReGameHookRegistry_CBasePlayer_GiveDefaultItems* CBasePlayer_GiveDefaultItems() = 0; - virtual IReGameHookRegistry_CBasePlayer_GiveNamedItem* CBasePlayer_GiveNamedItem() = 0; - virtual IReGameHookRegistry_CBasePlayer_AddAccount* CBasePlayer_AddAccount() = 0; - virtual IReGameHookRegistry_CBasePlayer_GiveShield* CBasePlayer_GiveShield() = 0; - virtual IReGameHookRegistry_CBasePlayer_SetClientUserInfoModel* CBasePlayer_SetClientUserInfoModel() = 0; - virtual IReGameHookRegistry_CBasePlayer_SetClientUserInfoName* CBasePlayer_SetClientUserInfoName() = 0; - virtual IReGameHookRegistry_CBasePlayer_HasRestrictItem* CBasePlayer_HasRestrictItem() = 0; - virtual IReGameHookRegistry_CBasePlayer_DropPlayerItem* CBasePlayer_DropPlayerItem() = 0; - virtual IReGameHookRegistry_CBasePlayer_DropShield* CBasePlayer_DropShield() = 0; - virtual IReGameHookRegistry_CBasePlayer_OnSpawnEquip* CBasePlayer_OnSpawnEquip() = 0; - virtual IReGameHookRegistry_CBasePlayer_Radio* CBasePlayer_Radio() = 0; - virtual IReGameHookRegistry_CBasePlayer_Disappear* CBasePlayer_Disappear() = 0; - virtual IReGameHookRegistry_CBasePlayer_MakeVIP* CBasePlayer_MakeVIP() = 0; - virtual IReGameHookRegistry_CBasePlayer_MakeBomber* CBasePlayer_MakeBomber() = 0; - virtual IReGameHookRegistry_CBasePlayer_StartObserver* CBasePlayer_StartObserver() = 0; - virtual IReGameHookRegistry_CBasePlayer_GetIntoGame* CBasePlayer_GetIntoGame() = 0; - - virtual IReGameHookRegistry_CBaseAnimating_ResetSequenceInfo* CBaseAnimating_ResetSequenceInfo() = 0; - - virtual IReGameHookRegistry_GetForceCamera* GetForceCamera() = 0; - virtual IReGameHookRegistry_PlayerBlind* PlayerBlind() = 0; - virtual IReGameHookRegistry_RadiusFlash_TraceLine* RadiusFlash_TraceLine() = 0; - virtual IReGameHookRegistry_RoundEnd* RoundEnd() = 0; - virtual IReGameHookRegistry_InstallGameRules* InstallGameRules() = 0; - virtual IReGameHookRegistry_PM_Init* PM_Init() = 0; - virtual IReGameHookRegistry_PM_Move* PM_Move() = 0; - virtual IReGameHookRegistry_PM_AirMove* PM_AirMove() = 0; - virtual IReGameHookRegistry_HandleMenu_ChooseAppearance* HandleMenu_ChooseAppearance() = 0; - virtual IReGameHookRegistry_HandleMenu_ChooseTeam* HandleMenu_ChooseTeam() = 0; - virtual IReGameHookRegistry_ShowMenu* ShowMenu() = 0; - virtual IReGameHookRegistry_ShowVGUIMenu* ShowVGUIMenu() = 0; - virtual IReGameHookRegistry_BuyGunAmmo* BuyGunAmmo() = 0; - virtual IReGameHookRegistry_BuyWeaponByWeaponID* BuyWeaponByWeaponID() = 0; - virtual IReGameHookRegistry_InternalCommand* InternalCommand() = 0; - - virtual IReGameHookRegistry_CSGameRules_FShouldSwitchWeapon* CSGameRules_FShouldSwitchWeapon() = 0; - virtual IReGameHookRegistry_CSGameRules_GetNextBestWeapon* CSGameRules_GetNextBestWeapon() = 0; - virtual IReGameHookRegistry_CSGameRules_FlPlayerFallDamage* CSGameRules_FlPlayerFallDamage() = 0; - virtual IReGameHookRegistry_CSGameRules_FPlayerCanTakeDamage* CSGameRules_FPlayerCanTakeDamage() = 0; - virtual IReGameHookRegistry_CSGameRules_PlayerSpawn* CSGameRules_PlayerSpawn() = 0; - virtual IReGameHookRegistry_CSGameRules_FPlayerCanRespawn* CSGameRules_FPlayerCanRespawn() = 0; - virtual IReGameHookRegistry_CSGameRules_GetPlayerSpawnSpot* CSGameRules_GetPlayerSpawnSpot() = 0; - virtual IReGameHookRegistry_CSGameRules_ClientUserInfoChanged* CSGameRules_ClientUserInfoChanged() = 0; - virtual IReGameHookRegistry_CSGameRules_PlayerKilled* CSGameRules_PlayerKilled() = 0; - virtual IReGameHookRegistry_CSGameRules_DeathNotice* CSGameRules_DeathNotice() = 0; - virtual IReGameHookRegistry_CSGameRules_CanHavePlayerItem* CSGameRules_CanHavePlayerItem() = 0; - virtual IReGameHookRegistry_CSGameRules_DeadPlayerWeapons* CSGameRules_DeadPlayerWeapons() = 0; - virtual IReGameHookRegistry_CSGameRules_ServerDeactivate* CSGameRules_ServerDeactivate() = 0; - virtual IReGameHookRegistry_CSGameRules_CheckMapConditions* CSGameRules_CheckMapConditions() = 0; - virtual IReGameHookRegistry_CSGameRules_CleanUpMap* CSGameRules_CleanUpMap() = 0; - virtual IReGameHookRegistry_CSGameRules_RestartRound* CSGameRules_RestartRound() = 0; - virtual IReGameHookRegistry_CSGameRules_CheckWinConditions* CSGameRules_CheckWinConditions() = 0; - virtual IReGameHookRegistry_CSGameRules_RemoveGuns* CSGameRules_RemoveGuns() = 0; - virtual IReGameHookRegistry_CSGameRules_GiveC4* CSGameRules_GiveC4() = 0; - virtual IReGameHookRegistry_CSGameRules_ChangeLevel* CSGameRules_ChangeLevel() = 0; - virtual IReGameHookRegistry_CSGameRules_GoToIntermission* CSGameRules_GoToIntermission() = 0; - virtual IReGameHookRegistry_CSGameRules_BalanceTeams* CSGameRules_BalanceTeams() = 0; - virtual IReGameHookRegistry_CSGameRules_OnRoundFreezeEnd* CSGameRules_OnRoundFreezeEnd() = 0; - virtual IReGameHookRegistry_PM_UpdateStepSound* PM_UpdateStepSound() = 0; - virtual IReGameHookRegistry_CBasePlayer_StartDeathCam* CBasePlayer_StartDeathCam() = 0; -}; - -struct ReGameFuncs_t { - struct edict_s *(*CREATE_NAMED_ENTITY2)(string_t iClass); - void (*ChangeString)(char *&dest, const char *source); - void (*RadiusDamage)(Vector vecSrc, entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, float flRadius, int iClassIgnore, int bitsDamageType); - void (*ClearMultiDamage)(); - void (*ApplyMultiDamage)(entvars_t *pevInflictor, entvars_t *pevAttacker); - void (*AddMultiDamage)(entvars_t *pevInflictor, CBaseEntity *pEntity, float flDamage, int bitsDamageType); - class CBaseEntity *(*UTIL_FindEntityByString)(class CBaseEntity *pStartEntity, const char *szKeyword, const char *szValue); - void (*AddEntityHashValue)(entvars_t *pev, const char *value, hash_types_e fieldType); - void (*RemoveEntityHashValue)(entvars_t *pev, const char *value, hash_types_e fieldType); - int (*Cmd_Argc)(); - const char *(*Cmd_Argv)(int i); -}; - -class IReGameApi { -public: - virtual ~IReGameApi() {} - - virtual int GetMajorVersion() = 0; - virtual int GetMinorVersion() = 0; - virtual const ReGameFuncs_t* GetFuncs() = 0; - virtual IReGameHookchains* GetHookchains() = 0; - - virtual class CGameRules* GetGameRules() = 0; - virtual struct WeaponInfoStruct* GetWeaponInfo(int weaponID) = 0; - virtual struct WeaponInfoStruct* GetWeaponInfo(const char* weaponName) = 0; - virtual struct playermove_s* GetPlayerMove() = 0; - virtual struct WeaponSlotInfo* GetWeaponSlot(WeaponIdType weaponID) = 0; - virtual struct WeaponSlotInfo* GetWeaponSlot(const char* weaponName) = 0; - virtual struct ItemInfo* GetItemInfo(WeaponIdType weaponID) = 0; - virtual struct AmmoInfo* GetAmmoInfo(AmmoType ammoID) = 0; -}; - -#define VRE_GAMEDLL_API_VERSION "VRE_GAMEDLL_API_VERSION001" diff --git a/regamedll/extra/cssdk/dlls/regamedll_common.h b/regamedll/extra/cssdk/dlls/regamedll_common.h deleted file mode 100644 index 826b6ded..00000000 --- a/regamedll/extra/cssdk/dlls/regamedll_common.h +++ /dev/null @@ -1,96 +0,0 @@ -/* -* -* This program is free software; you can redistribute it and/or modify it -* under the terms of the GNU General Public License as published by the -* Free Software Foundation; either version 2 of the License, or (at -* your option) any later version. -* -* This program 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 -* General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* -*/ - -#pragma once - -#ifndef _WIN32 -#define _strlwr(p) for (int i = 0; p[i] != 0; i++) p[i] = tolower(p[i]); -#endif - -#define Q_isspace isspace -#define Q_isalnum isalnum -#define Q_isalpha isalpha - -#define Q_malloc malloc -#define Q_calloc calloc -#define Q_alloca alloca -#define Q_free free - -#define Q_min min -#define Q_max max -#define Q_clamp clamp -#define Q_access _access -#define Q_close _close -#define Q_write _write -#define Q_memset memset -#define Q_memcpy memcpy -#define Q_strlen strlen -#define Q_memcmp memcmp -#define Q_strcpy strcpy -#define Q_strncpy strncpy -#define Q_strrchr strrchr -#define Q_strcat strcat -#define Q_strncat strncat -#define Q_strcmp strcmp -#define Q_strncmp strncmp -#define Q_sscanf sscanf -#define Q_strdup _strdup -#define Q_stricmp _stricmp -#define Q_strnicmp _strnicmp -#define Q_strstr strstr -#define Q_strchr strchr -#define Q_strrchr strrchr -#define Q_strlwr _strlwr -#define Q_sprintf sprintf -#define Q_snprintf _snprintf -#define Q_atoi atoi -#define Q_atof atof -#define Q_toupper toupper -#define Q_memmove memmove -#define Q_vsnprintf _vsnprintf -#define Q_vsnwprintf _vsnwprintf -#define Q_abs abs -#define Q_fabs fabs -#define Q_tan tan -#define Q_atan atan -#define Q_atan2 atan2 -#define Q_acos acos -#define Q_cos cos -#define Q_sin sin -#define Q_pow pow -#define Q_fmod fmod -#define Q_fopen fopen -#define Q_fwrite fwrite -#define Q_fprintf fprintf -#define Q_fclose fclose - -#ifdef REGAMEDLL_FIXES -#define Q_sqrt M_sqrt -#else -#define Q_sqrt sqrt -#endif diff --git a/regamedll/extra/cssdk/dlls/regamedll_const.h b/regamedll/extra/cssdk/dlls/regamedll_const.h deleted file mode 100644 index 36d038b9..00000000 --- a/regamedll/extra/cssdk/dlls/regamedll_const.h +++ /dev/null @@ -1,104 +0,0 @@ -/* -* -* This program is free software; you can redistribute it and/or modify it -* under the terms of the GNU General Public License as published by the -* Free Software Foundation; either version 2 of the License, or (at -* your option) any later version. -* -* This program 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 -* General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* -*/ -#pragma once - -// These are caps bits to indicate what an object's capabilities (currently used for save/restore and level transitions) -#define FCAP_CUSTOMSAVE 0x00000001 -#define FCAP_ACROSS_TRANSITION 0x00000002 // should transfer between transitions -#define FCAP_MUST_SPAWN 0x00000004 // Spawn after restore -#define FCAP_DONT_SAVE 0x80000000 // Don't save this -#define FCAP_IMPULSE_USE 0x00000008 // can be used by the player -#define FCAP_CONTINUOUS_USE 0x00000010 // can be used by the player -#define FCAP_ONOFF_USE 0x00000020 // can be used by the player -#define FCAP_DIRECTIONAL_USE 0x00000040 // Player sends +/- 1 when using (currently only tracktrains) -#define FCAP_MASTER 0x00000080 // Can be used to "master" other entities (like multisource) - -// UNDONE: This will ignore transition volumes (trigger_transition), but not the PVS!!! -#define FCAP_FORCE_TRANSITION 0x00000080 // ALWAYS goes across transitions - -// for Classify -#define CLASS_NONE 0 -#define CLASS_MACHINE 1 -#define CLASS_PLAYER 2 -#define CLASS_HUMAN_PASSIVE 3 -#define CLASS_HUMAN_MILITARY 4 -#define CLASS_ALIEN_MILITARY 5 -#define CLASS_ALIEN_PASSIVE 6 -#define CLASS_ALIEN_MONSTER 7 -#define CLASS_ALIEN_PREY 8 -#define CLASS_ALIEN_PREDATOR 9 -#define CLASS_INSECT 10 -#define CLASS_PLAYER_ALLY 11 -#define CLASS_PLAYER_BIOWEAPON 12 // hornets and snarks.launched by players -#define CLASS_ALIEN_BIOWEAPON 13 // hornets and snarks.launched by the alien menace -#define CLASS_VEHICLE 14 -#define CLASS_BARNACLE 99 // special because no one pays attention to it, and it eats a wide cross-section of creatures. - -#define SF_NORESPAWN (1 << 30) // set this bit on guns and stuff that should never respawn. - -#define DMG_GENERIC 0 // generic damage was done -#define DMG_CRUSH (1<<0) // crushed by falling or moving object -#define DMG_BULLET (1<<1) // shot -#define DMG_SLASH (1<<2) // cut, clawed, stabbed -#define DMG_BURN (1<<3) // heat burned -#define DMG_FREEZE (1<<4) // frozen -#define DMG_FALL (1<<5) // fell too far -#define DMG_BLAST (1<<6) // explosive blast damage -#define DMG_CLUB (1<<7) // crowbar, punch, headbutt -#define DMG_SHOCK (1<<8) // electric shock -#define DMG_SONIC (1<<9) // sound pulse shockwave -#define DMG_ENERGYBEAM (1<<10) // laser or other high energy beam -#define DMG_NEVERGIB (1<<12) // with this bit OR'd in, no damage type will be able to gib victims upon death -#define DMG_ALWAYSGIB (1<<13) // with this bit OR'd in, any damage type can be made to gib victims upon death -#define DMG_DROWN (1<<14) // Drowning - -// time-based damage -#define DMG_TIMEBASED (~(0x3FFF)) // mask for time-based damage - -#define DMG_PARALYZE (1<<15) // slows affected creature down -#define DMG_NERVEGAS (1<<16) // nerve toxins, very bad -#define DMG_POISON (1<<17) // blood poisioning -#define DMG_RADIATION (1<<18) // radiation exposure -#define DMG_DROWNRECOVER (1<<19) // drowning recovery -#define DMG_ACID (1<<20) // toxic chemicals or acid burns -#define DMG_SLOWBURN (1<<21) // in an oven -#define DMG_SLOWFREEZE (1<<22) // in a subzero freezer -#define DMG_MORTAR (1<<23) // Hit by air raid (done to distinguish grenade from mortar) -#define DMG_EXPLOSION (1<<24) - -// these are the damage types that are allowed to gib corpses -#define DMG_GIB_CORPSE (DMG_CRUSH | DMG_FALL | DMG_BLAST | DMG_SONIC | DMG_CLUB) - -// these are the damage types that have client hud art -#define DMG_SHOWNHUD (DMG_POISON | DMG_ACID | DMG_FREEZE | DMG_SLOWFREEZE | DMG_DROWN | DMG_BURN | DMG_SLOWBURN | DMG_NERVEGAS | DMG_RADIATION | DMG_SHOCK) - -// when calling KILLED(), a value that governs gib behavior is expected to be -// one of these three values -#define GIB_NORMAL 0 // gib if entity was overkilled -#define GIB_NEVER 1 // never gib, no matter how much death damage is done ( freezing, etc ) -#define GIB_ALWAYS 2 // always gib ( Houndeye Shock, Barnacle Bite ) diff --git a/regamedll/extra/cssdk/dlls/regamedll_interfaces.h b/regamedll/extra/cssdk/dlls/regamedll_interfaces.h deleted file mode 100644 index 783cae96..00000000 --- a/regamedll/extra/cssdk/dlls/regamedll_interfaces.h +++ /dev/null @@ -1,302 +0,0 @@ -/* -* -* This program is free software; you can redistribute it and/or modify it -* under the terms of the GNU General Public License as published by the -* Free Software Foundation; either version 2 of the License, or (at -* your option) any later version. -* -* This program 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 -* General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* -*/ - -#pragma once - -class CBaseEntity; -class CBasePlayer; - -// Implementation wrapper -class CCSEntity { -public: - virtual ~CCSEntity() {} - virtual void FireBullets(int iShots, Vector &vecSrc, Vector &vecDirShooting, Vector &vecSpread, float flDistance, int iBulletType, int iTracerFreq, int iDamage, entvars_t *pevAttacker); - virtual Vector FireBullets3(Vector &vecSrc, Vector &vecDirShooting, float vecSpread, float flDistance, int iPenetration, int iBulletType, int iDamage, float flRangeModifier, entvars_t *pevAttacker, bool bPistol, int shared_rand); -public: - CBaseEntity *m_pContainingEntity; -}; - -class CCSDelay: public CCSEntity {}; -class CCSAnimating: public CCSDelay {}; -class CCSPlayerItem: public CCSAnimating {}; -class CCSToggle: public CCSAnimating {}; -class CCSMonster: public CCSToggle {}; -class CCSWeaponBox: public CCSEntity {}; -class CCSArmoury: public CCSEntity {}; - -class CCSPlayer: public CCSMonster { -public: - CCSPlayer() : m_bForceShowMenu(false) - { - m_szModel[0] = '\0'; - } - - virtual bool IsConnected() const; - virtual void SetAnimation(PLAYER_ANIM playerAnim); - virtual void AddAccount(int amount, RewardType type = RT_NONE, bool bTrackChange = true); - virtual CBaseEntity *GiveNamedItem(const char *pszName); - virtual CBaseEntity *GiveNamedItemEx(const char *pszName); - virtual void GiveDefaultItems(); - virtual void GiveShield(bool bDeploy = true); - virtual void DropShield(bool bDeploy = true); - virtual void DropPlayerItem(const char *pszItemName); - virtual void RemoveShield(); - virtual void RemoveAllItems(bool bRemoveSuit); - virtual bool RemovePlayerItem(const char* pszItemName); - virtual void SetPlayerModel(bool bHasC4); - virtual void SetPlayerModelEx(const char *modelName); - virtual void SetNewPlayerModel(const char *modelName); - virtual void ClientCommand(const char *cmd, const char *arg1 = nullptr, const char *arg2 = nullptr, const char *arg3 = nullptr); - virtual void SetProgressBarTime(int time); - virtual void SetProgressBarTime2(int time, float timeElapsed); - virtual struct edict_s *EntSelectSpawnPoint(); - virtual void SetBombIcon(bool bFlash = false); - virtual void SetScoreAttrib(CBasePlayer *dest); - virtual void SendItemStatus(); - virtual void ReloadWeapons(CBasePlayerItem *pWeapon = nullptr, bool bForceReload = false, bool bForceRefill = false); - virtual void Observer_SetMode(int iMode); - virtual bool SelectSpawnSpot(const char *pEntClassName, CBaseEntity* &pSpot); - virtual bool SwitchWeapon(CBasePlayerItem *pWeapon); - virtual void SwitchTeam(); - virtual bool JoinTeam(TeamName team); - virtual void StartObserver(Vector& vecPosition, Vector& vecViewAngle); - virtual void TeamChangeUpdate(); - virtual void DropSecondary(); - virtual void DropPrimary(); - virtual bool HasPlayerItem(CBasePlayerItem *pCheckItem); - virtual bool HasNamedPlayerItem(const char *pszItemName); - virtual CBasePlayerItem *GetItemById(WeaponIdType weaponID); - virtual CBasePlayerItem *GetItemByName(const char *itemName); - virtual void Disappear(); - virtual void MakeVIP(); - virtual bool MakeBomber(); - virtual void StartDeathCam(); - - CBasePlayer *BasePlayer() const; -public: - char m_szModel[32]; - bool m_bForceShowMenu; -}; - -class CAPI_Bot: public CCSPlayer {}; -class CAPI_CSBot: public CAPI_Bot {}; -class CCSShield: public CCSEntity {}; -class CCSDeadHEV: public CCSMonster {}; -class CCSSprayCan: public CCSEntity {}; -class CCSBloodSplat: public CCSEntity {}; -class CCSPlayerWeapon: public CCSPlayerItem {}; -class CCSWorld: public CCSEntity {}; -class CCSDecal: public CCSEntity {}; -class CCSCorpse: public CCSEntity {}; -class CCSGrenade: public CCSMonster {}; -class CCSAirtank: public CCSGrenade {}; -class CCSPlayerAmmo: public CCSEntity {}; -class CCS9MMAmmo: public CCSPlayerAmmo {}; -class CCSBuckShotAmmo: public CCSPlayerAmmo {}; -class CCS556NatoAmmo: public CCSPlayerAmmo {}; -class CCS556NatoBoxAmmo: public CCSPlayerAmmo {}; -class CCS762NatoAmmo: public CCSPlayerAmmo {}; -class CCS45ACPAmmo: public CCSPlayerAmmo {}; -class CCS50AEAmmo: public CCSPlayerAmmo {}; -class CCS338MagnumAmmo: public CCSPlayerAmmo {}; -class CCS57MMAmmo: public CCSPlayerAmmo {}; -class CCS357SIGAmmo: public CCSPlayerAmmo {}; -class CCSFuncWall: public CCSEntity {}; -class CCSFuncWallToggle: public CCSFuncWall {}; -class CCSFuncConveyor: public CCSFuncWall {}; -class CCSFuncIllusionary: public CCSToggle {}; -class CCSFuncMonsterClip: public CCSFuncWall {}; -class CCSFuncRotating: public CCSEntity {}; -class CCSPendulum: public CCSEntity {}; -class CCSPointEntity: public CCSEntity {}; -class CCSStripWeapons: public CCSPointEntity {}; -class CCSInfoIntermission: public CCSPointEntity {}; -class CCSRevertSaved: public CCSPointEntity {}; -class CCSEnvGlobal: public CCSPointEntity {}; -class CCSMultiSource: public CCSPointEntity {}; -class CCSButton: public CCSToggle {}; -class CCSRotButton: public CCSButton {}; -class CCSMomentaryRotButton: public CCSToggle {}; -class CCSEnvSpark: public CCSEntity {}; -class CCSButtonTarget: public CCSEntity {}; -class CCSDoor: public CCSToggle {}; -class CCSRotDoor: public CCSDoor {}; -class CCSMomentaryDoor: public CCSToggle {}; -class CCSGib: public CCSEntity {}; -class CCSBubbling: public CCSEntity {}; -class CCSBeam: public CCSEntity {}; -class CCSLightning: public CCSBeam {}; -class CCSLaser: public CCSBeam {}; -class CCSGlow: public CCSPointEntity {}; -class CCSSprite: public CCSPointEntity {}; -class CCSBombGlow: public CCSSprite {}; -class CCSGibShooter: public CCSDelay {}; -class CCSEnvShooter: public CCSGibShooter {}; -class CCSTestEffect: public CCSDelay {}; -class CCSBlood: public CCSPointEntity {}; -class CCSShake: public CCSPointEntity {}; -class CCSFade: public CCSPointEntity {}; -class CCSMessage: public CCSPointEntity {}; -class CCSEnvFunnel: public CCSDelay {}; -class CCSEnvBeverage: public CCSDelay {}; -class CCSItemSoda: public CCSEntity {}; -class CCSShower: public CCSEntity {}; -class CCSEnvExplosion: public CCSMonster {}; -class CCSBreakable: public CCSDelay {}; -class CCSPushable: public CCSBreakable {}; -class CCSFuncTank: public CCSEntity {}; -class CCSFuncTankGun: public CCSFuncTank {}; -class CCSFuncTankLaser: public CCSFuncTank {}; -class CCSFuncTankRocket: public CCSFuncTank {}; -class CCSFuncTankMortar: public CCSFuncTank {}; -class CCSFuncTankControls: public CCSEntity {}; -class CCSRecharge: public CCSToggle {}; -class CCSCycler: public CCSMonster {}; -class CCSGenericCycler: public CCSCycler {}; -class CCSCyclerProbe: public CCSCycler {}; -class CCSCyclerSprite: public CCSEntity {}; -class CCSWeaponCycler: public CCSPlayerWeapon {}; -class CCSWreckage: public CCSMonster {}; -class CCSWorldItem: public CCSEntity {}; -class CCSItem: public CCSEntity {}; -class CCSHealthKit: public CCSItem {}; -class CCSWallHealth: public CCSToggle {}; -class CCSItemSuit: public CCSItem {}; -class CCSItemBattery: public CCSItem {}; -class CCSItemAntidote: public CCSItem {}; -class CCSItemSecurity: public CCSItem {}; -class CCSItemLongJump: public CCSItem {}; -class CCSItemKevlar: public CCSItem {}; -class CCSItemAssaultSuit: public CCSItem {}; -class CCSItemThighPack: public CCSItem {}; -class CCSGrenCatch: public CCSEntity {}; -class CCSFuncWeaponCheck: public CCSEntity {}; -class CCSHostage: public CCSMonster {}; -class CCSLight: public CCSPointEntity {}; -class CCSEnvLight: public CCSLight {}; -class CCSRuleEntity: public CCSEntity {}; -class CCSRulePointEntity: public CCSRuleEntity {}; -class CCSRuleBrushEntity: public CCSRuleEntity {}; -class CCSGameScore: public CCSRulePointEntity {}; -class CCSGameEnd: public CCSRulePointEntity {}; -class CCSGameText: public CCSRulePointEntity {}; -class CCSGameTeamMaster: public CCSRulePointEntity {}; -class CCSGameTeamSet: public CCSRulePointEntity {}; -class CCSGamePlayerZone: public CCSRuleBrushEntity {}; -class CCSGamePlayerHurt: public CCSRulePointEntity {}; -class CCSGameCounter: public CCSRulePointEntity {}; -class CCSGameCounterSet: public CCSRulePointEntity {}; -class CCSGamePlayerEquip: public CCSRulePointEntity {}; -class CCSGamePlayerTeam: public CCSRulePointEntity {}; -class CCSFuncMortarField: public CCSToggle {}; -class CCSMortar: public CCSGrenade {}; -class CCSMapInfo: public CCSPointEntity {}; -class CCSPathCorner: public CCSPointEntity {}; -class CCSPathTrack: public CCSPointEntity {}; -class CCSFuncTrackTrain: public CCSEntity {}; -class CCSFuncVehicleControls: public CCSEntity {}; -class CCSFuncVehicle: public CCSEntity {}; -class CCSPlatTrain: public CCSToggle {}; -class CCSFuncPlat: public CCSPlatTrain {}; -class CCSPlatTrigger: public CCSEntity {}; -class CCSFuncPlatRot: public CCSFuncPlat {}; -class CCSFuncTrain: public CCSPlatTrain {}; -class CCSFuncTrainControls: public CCSEntity {}; -class CCSFuncTrackChange: public CCSFuncPlatRot {}; -class CCSFuncTrackAuto: public CCSFuncTrackChange {}; -class CCSGunTarget: public CCSMonster {}; -class CCSAmbientGeneric: public CCSEntity {}; -class CCSEnvSound: public CCSPointEntity {}; -class CCSSpeaker: public CCSEntity {}; -class CCSSoundEnt: public CCSEntity {}; -class CCSUSP: public CCSPlayerWeapon {}; -class CCSMP5N: public CCSPlayerWeapon {}; -class CCSSG552: public CCSPlayerWeapon {}; -class CCSAK47: public CCSPlayerWeapon {}; -class CCSAUG: public CCSPlayerWeapon {}; -class CCSAWP: public CCSPlayerWeapon {}; -class CCSC4: public CCSPlayerWeapon {}; -class CCSDEAGLE: public CCSPlayerWeapon {}; -class CCSFlashbang: public CCSPlayerWeapon {}; -class CCSG3SG1: public CCSPlayerWeapon {}; -class CCSGLOCK18: public CCSPlayerWeapon {}; -class CCSHEGrenade: public CCSPlayerWeapon {}; -class CCSKnife: public CCSPlayerWeapon {}; -class CCSM249: public CCSPlayerWeapon {}; -class CCSM3: public CCSPlayerWeapon {}; -class CCSM4A1: public CCSPlayerWeapon {}; -class CCSMAC10: public CCSPlayerWeapon {}; -class CCSP228: public CCSPlayerWeapon {}; -class CCSP90: public CCSPlayerWeapon {}; -class CCSSCOUT: public CCSPlayerWeapon {}; -class CCSSmokeGrenade: public CCSPlayerWeapon {}; -class CCSTMP: public CCSPlayerWeapon {}; -class CCSXM1014: public CCSPlayerWeapon {}; -class CCSELITE: public CCSPlayerWeapon {}; -class CCSFiveSeven: public CCSPlayerWeapon {}; -class CCSUMP45: public CCSPlayerWeapon {}; -class CCSSG550: public CCSPlayerWeapon {}; -class CCSGalil: public CCSPlayerWeapon {}; -class CCSFamas: public CCSPlayerWeapon {}; -class CCSNullEntity: public CCSEntity {}; -class CCSDMStart: public CCSPointEntity {}; -class CCSFrictionModifier: public CCSEntity {}; -class CCSAutoTrigger: public CCSDelay {}; -class CCSTriggerRelay: public CCSDelay {}; -class CCSMultiManager: public CCSToggle {}; -class CCSRenderFxManager: public CCSEntity {}; -class CCSTrigger: public CCSToggle {}; -class CCSTriggerHurt: public CCSTrigger {}; -class CCSTriggerMonsterJump: public CCSTrigger {}; -class CCSTriggerCDAudio: public CCSTrigger {}; -class CCSTargetCDAudio: public CCSPointEntity {}; -class CCSTriggerMultiple: public CCSTrigger {}; -class CCSTriggerOnce: public CCSTriggerMultiple {}; -class CCSTriggerCounter: public CCSTrigger {}; -class CCSTriggerVolume: public CCSPointEntity {}; -class CCSFireAndDie: public CCSDelay {}; -class CCSChangeLevel: public CCSTrigger {}; -class CCSLadder: public CCSTrigger {}; -class CCSTriggerPush: public CCSTrigger {}; -class CCSTriggerTeleport: public CCSTrigger {}; -class CCSBuyZone: public CCSTrigger {}; -class CCSBombTarget: public CCSTrigger {}; -class CCSHostageRescue: public CCSTrigger {}; -class CCSEscapeZone: public CCSTrigger {}; -class CCSVIP_SafetyZone: public CCSTrigger {}; -class CCSTriggerSave: public CCSTrigger {}; -class CCSTriggerEndSection: public CCSTrigger {}; -class CCSTriggerGravity: public CCSTrigger {}; -class CCSTriggerChangeTarget: public CCSDelay {}; -class CCSTriggerCamera: public CCSDelay {}; -class CCSWeather: public CCSTrigger {}; -class CCSClientFog: public CCSEntity {}; - -inline CBasePlayer *CCSPlayer::BasePlayer() const { - return reinterpret_cast(this->m_pContainingEntity); -} diff --git a/regamedll/extra/cssdk/dlls/revert_saved.h b/regamedll/extra/cssdk/dlls/revert_saved.h deleted file mode 100644 index f8bb4ee3..00000000 --- a/regamedll/extra/cssdk/dlls/revert_saved.h +++ /dev/null @@ -1,49 +0,0 @@ -/* -* -* This program is free software; you can redistribute it and/or modify it -* under the terms of the GNU General Public License as published by the -* Free Software Foundation; either version 2 of the License, or (at -* your option) any later version. -* -* This program 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 -* General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* -*/ -#pragma once - -class CRevertSaved: public CPointEntity { -public: - virtual void KeyValue(KeyValueData *pkvd) = 0; - virtual int Save(CSave &save) = 0; - virtual int Restore(CRestore &restore) = 0; - virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) = 0; -public: - float Duration() const { return pev->dmg_take; } - float HoldTime() const { return pev->dmg_save; } - float MessageTime() const { return m_messageTime; } - float LoadTime() const { return m_loadTime; } - - void SetDuration(float duration) { pev->dmg_take = duration; } - void SetHoldTime(float hold) { pev->dmg_save = hold; } - void SetMessageTime(float time) { m_messageTime = time; } - void SetLoadTime(float time) { m_loadTime = time; } -public: - float m_messageTime; - float m_loadTime; -}; diff --git a/regamedll/extra/cssdk/dlls/skill.h b/regamedll/extra/cssdk/dlls/skill.h deleted file mode 100644 index 95e2084d..00000000 --- a/regamedll/extra/cssdk/dlls/skill.h +++ /dev/null @@ -1,53 +0,0 @@ -/* -* -* This program is free software; you can redistribute it and/or modify it -* under the terms of the GNU General Public License as published by the -* Free Software Foundation; either version 2 of the License, or (at -* your option) any later version. -* -* This program 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 -* General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* -*/ -#pragma once - -#define SKILL_EASY 1 -#define SKILL_MEDIUM 2 -#define SKILL_HARD 3 - -struct skilldata_t -{ - int iSkillLevel; - float plrDmg9MM; - float plrDmg357; - float plrDmgMP5; - float plrDmgM203Grenade; - float plrDmgBuckshot; - float plrDmgCrossbowClient; - float plrDmgRPG; - float monDmg9MM; - float monDmgMP5; - float monDmg12MM; - float suitchargerCapacity; - float batteryCapacity; - float healthchargerCapacity; - float healthkitCapacity; -}; - -extern skilldata_t gSkillData; diff --git a/regamedll/extra/cssdk/dlls/sound.h b/regamedll/extra/cssdk/dlls/sound.h deleted file mode 100644 index c4e636c0..00000000 --- a/regamedll/extra/cssdk/dlls/sound.h +++ /dev/null @@ -1,141 +0,0 @@ -/* -* -* This program is free software; you can redistribute it and/or modify it -* under the terms of the GNU General Public License as published by the -* Free Software Foundation; either version 2 of the License, or (at -* your option) any later version. -* -* This program 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 -* General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* -*/ -#pragma once - -#define CSENTENCEG_MAX 200 // max number of sentence groups -#define CSENTENCE_LRU_MAX 32 // max number of elements per sentence group -#define CDPVPRESETMAX 27 - -// spawnflags -#define AMBIENT_SOUND_STATIC 0 // medium radius attenuation -#define AMBIENT_SOUND_EVERYWHERE 1 -#define AMBIENT_SOUND_SMALLRADIUS 2 -#define AMBIENT_SOUND_MEDIUMRADIUS 4 -#define AMBIENT_SOUND_LARGERADIUS 8 -#define AMBIENT_SOUND_START_SILENT 16 -#define AMBIENT_SOUND_NOT_LOOPING 32 - -#define ANNOUNCE_MINUTES_MIN 0.25 -#define ANNOUNCE_MINUTES_MAX 2.25 - -#define SPEAKER_START_SILENT 1 // wait for trigger 'on' to start announcements - -#define LFO_SQUARE 1 // square -#define LFO_TRIANGLE 2 // triangle -#define LFO_RANDOM 3 // random - -// group of related sentences -struct sentenceg -{ - char szgroupname[16]; - int count; - unsigned char rgblru[ CSENTENCE_LRU_MAX ]; -}; - -// runtime pitch shift and volume fadein/out structure - -// NOTE: IF YOU CHANGE THIS STRUCT YOU MUST CHANGE THE SAVE/RESTORE VERSION NUMBER -// SEE BELOW (in the typedescription for the class) -typedef struct dynpitchvol -{ - // NOTE: do not change the order of these parameters - // NOTE: unless you also change order of rgdpvpreset array elements! - int preset; - - int pitchrun; // pitch shift % when sound is running 0 - 255 - int pitchstart; // pitch shift % when sound stops or starts 0 - 255 - int spinup; // spinup time 0 - 100 - int spindown; // spindown time 0 - 100 - - int volrun; // volume change % when sound is running 0 - 10 - int volstart; // volume change % when sound stops or starts 0 - 10 - int fadein; // volume fade in time 0 - 100 - int fadeout; // volume fade out time 0 - 100 - - // Low Frequency Oscillator - int lfotype; // 0) off 1) square 2) triangle 3) random - int lforate; // 0 - 1000, how fast lfo osciallates - - int lfomodpitch; // 0-100 mod of current pitch. 0 is off. - int lfomodvol; // 0-100 mod of current volume. 0 is off. - - int cspinup; // each trigger hit increments counter and spinup pitch - - int cspincount; - int pitch; - int spinupsav; - int spindownsav; - int pitchfrac; - int vol; - int fadeinsav; - int fadeoutsav; - int volfrac; - int lfofrac; - int lfomult; - -} dynpitchvol_t; - -class CAmbientGeneric: public CBaseEntity { -public: - virtual void Spawn() = 0; - virtual void Precache() = 0; - virtual void Restart() = 0; - virtual void KeyValue(KeyValueData *pkvd) = 0; - virtual int Save(CSave &save) = 0; - virtual int Restore(CRestore &restore) = 0; - virtual int ObjectCaps() = 0; -public: - float m_flAttenuation; // attenuation value - dynpitchvol_t m_dpv; - BOOL m_fActive; // only TRUE when the entity is playing a looping sound - BOOL m_fLooping; // TRUE when the sound played will loop -}; - -class CEnvSound: public CPointEntity { -public: - virtual void Spawn() = 0; - virtual void KeyValue(KeyValueData *pkvd) = 0; - virtual int Save(CSave &save) = 0; - virtual int Restore(CRestore &restore) = 0; - virtual void Think() = 0; -public: - float m_flRadius; - float m_flRoomtype; -}; - -class CSpeaker: public CBaseEntity { -public: - virtual void Spawn() = 0; - virtual void Precache() = 0; - virtual void KeyValue(KeyValueData *pkvd) = 0; - virtual int Save(CSave &save) = 0; - virtual int Restore(CRestore &restore) = 0; - virtual int ObjectCaps() = 0; -public: - int m_preset; // preset number -}; diff --git a/regamedll/extra/cssdk/dlls/spectator.h b/regamedll/extra/cssdk/dlls/spectator.h deleted file mode 100644 index d42e05a5..00000000 --- a/regamedll/extra/cssdk/dlls/spectator.h +++ /dev/null @@ -1,33 +0,0 @@ -/* -* -* This program is free software; you can redistribute it and/or modify it -* under the terms of the GNU General Public License as published by the -* Free Software Foundation; either version 2 of the License, or (at -* your option) any later version. -* -* This program 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 -* General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* -*/ -#pragma once - -class CBaseSpectator: public CBaseEntity { -public: - virtual void Spawn(); -}; diff --git a/regamedll/extra/cssdk/dlls/training_gamerules.h b/regamedll/extra/cssdk/dlls/training_gamerules.h deleted file mode 100644 index 079e2be1..00000000 --- a/regamedll/extra/cssdk/dlls/training_gamerules.h +++ /dev/null @@ -1,84 +0,0 @@ -/* -* -* This program is free software; you can redistribute it and/or modify it -* under the terms of the GNU General Public License as published by the -* Free Software Foundation; either version 2 of the License, or (at -* your option) any later version. -* -* This program 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 -* General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* -*/ -#pragma once - -class CHalfLifeTraining: public CHalfLifeMultiplay { -protected: - virtual ~CHalfLifeTraining() {}; -public: - virtual BOOL IsMultiplayer() = 0; - virtual BOOL IsDeathmatch() = 0; - virtual void InitHUD(CBasePlayer *pl) = 0; - virtual void PlayerSpawn(CBasePlayer *pPlayer) = 0; - virtual void PlayerThink(CBasePlayer *pPlayer) = 0; - virtual BOOL FPlayerCanRespawn(CBasePlayer *pPlayer) = 0; - virtual edict_t *GetPlayerSpawnSpot(CBasePlayer *pPlayer) = 0; - virtual void PlayerKilled(CBasePlayer *pVictim, entvars_t *pKiller, entvars_t *pInflictor) = 0; - virtual int ItemShouldRespawn(CItem *pItem) = 0; - virtual void CheckMapConditions() = 0; - virtual void CheckWinConditions() = 0; -public: - float FillAccountTime; - float ServerRestartTime; - BOOL fInBuyArea; - BOOL fVisitedBuyArea; - bool fVGUIMenus; -}; - -class CBaseGrenCatch: public CBaseEntity { -public: - virtual void Spawn() = 0; - virtual void KeyValue(KeyValueData *pkvd) = 0; - virtual int Save(CSave &save) = 0; - virtual int Restore(CRestore &restore) = 0; - virtual int ObjectCaps() = 0; - virtual void Think() = 0; - virtual void Touch(CBaseEntity *pOther) = 0; -public: - int m_NeedGrenadeType; - string_t sTriggerOnGrenade; - string_t sDisableOnGrenade; - bool m_fSmokeTouching; - bool m_fFlashTouched; -}; - -class CFuncWeaponCheck: public CBaseEntity { -public: - virtual void Spawn() = 0; - virtual void KeyValue(KeyValueData *pkvd) = 0; - virtual int Save(CSave &save) = 0; - virtual int Restore(CRestore &restore) = 0; - virtual void Touch(CBaseEntity *pOther) = 0; -private: - string_t sTriggerWithItems; - string_t sTriggerNoItems; - string_t sMaster; - unsigned int sItemName[32]; - int iItemCount; - int iAnyWeapon; -}; diff --git a/regamedll/extra/cssdk/dlls/trains.h b/regamedll/extra/cssdk/dlls/trains.h deleted file mode 100644 index 10927b61..00000000 --- a/regamedll/extra/cssdk/dlls/trains.h +++ /dev/null @@ -1,149 +0,0 @@ -/* -* -* This program is free software; you can redistribute it and/or modify it -* under the terms of the GNU General Public License as published by the -* Free Software Foundation; either version 2 of the License, or (at -* your option) any later version. -* -* This program 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 -* General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* -*/ -#pragma once - -// Tracktrain spawn flags -#define SF_TRACKTRAIN_NOPITCH 0x0001 -#define SF_TRACKTRAIN_NOCONTROL 0x0002 -#define SF_TRACKTRAIN_FORWARDONLY 0x0004 -#define SF_TRACKTRAIN_PASSABLE 0x0008 - -// Spawnflag for CPathTrack -#define SF_PATH_DISABLED 0x00000001 -#define SF_PATH_FIREONCE 0x00000002 -#define SF_PATH_ALTREVERSE 0x00000004 -#define SF_PATH_DISABLE_TRAIN 0x00000008 -#define SF_PATH_ALTERNATE 0x00008000 - -// Spawnflags of CPathCorner -#define SF_CORNER_WAITFORTRIG 0x001 -#define SF_CORNER_TELEPORT 0x002 -#define SF_CORNER_FIREONCE 0x004 - -class CPathTrack: public CPointEntity { -public: - virtual void Spawn() = 0; - virtual void KeyValue(KeyValueData* pkvd) = 0; - virtual int Save(CSave &save) = 0; - virtual int Restore(CRestore &restore) = 0; - virtual void Activate() = 0; - virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) = 0; -public: - float m_length; - string_t m_altName; - CPathTrack *m_pnext; - CPathTrack *m_pprevious; - CPathTrack *m_paltpath; -}; - -class CFuncTrackTrain: public CBaseEntity { -public: - virtual void Spawn() = 0; - virtual void Precache() = 0; - virtual void Restart() = 0; - virtual void KeyValue(KeyValueData* pkvd) = 0; - virtual int Save(CSave &save) = 0; - virtual int Restore(CRestore &restore) = 0; - virtual int ObjectCaps() = 0; - virtual void OverrideReset() = 0; - virtual BOOL OnControls(entvars_t *pev) = 0; - virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) = 0; - virtual void Blocked(CBaseEntity *pOther) = 0; -public: - CPathTrack *m_ppath; - float m_length; - float m_height; - float m_speed; - float m_dir; - float m_startSpeed; - Vector m_controlMins; - Vector m_controlMaxs; - int m_soundPlaying; - int m_sounds; - float m_flVolume; - float m_flBank; - float m_oldSpeed; - float m_fTurnAngle; - float m_flSteeringWheelDecay; - float m_flAcceleratorDecay; - -private: - unsigned short m_usAdjustPitch; -}; - -class CFuncVehicle: public CBaseEntity { -public: - virtual void Spawn() = 0; - virtual void Precache() = 0; - virtual void Restart() = 0; - virtual void KeyValue(KeyValueData *pkvd) = 0; - virtual int Save(CSave &save) = 0; - virtual int Restore(CRestore &restore) = 0; - virtual int ObjectCaps() = 0; - virtual int Classify() = 0; - virtual void OverrideReset() = 0; - virtual BOOL OnControls(entvars_t *pev) = 0; - virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) = 0; - virtual void Blocked(CBaseEntity *pOther) = 0; -public: - CPathTrack *m_ppath; - float m_length; - float m_width; - float m_height; - float m_speed; - float m_dir; - float m_startSpeed; - Vector m_controlMins; - Vector m_controlMaxs; - int m_soundPlaying; - int m_sounds; - int m_acceleration; - float m_flVolume; - float m_flBank; - float m_oldSpeed; - int m_iTurnAngle; - float m_flSteeringWheelDecay; - float m_flAcceleratorDecay; - float m_flTurnStartTime; - float m_flLaunchTime; - float m_flLastNormalZ; - float m_flCanTurnNow; - float m_flUpdateSound; - Vector m_vFrontLeft; - Vector m_vFront; - Vector m_vFrontRight; - Vector m_vBackLeft; - Vector m_vBack; - Vector m_vBackRight; - Vector m_vSurfaceNormal; - Vector m_vVehicleDirection; - CBaseEntity *m_pDriver; - -private: - unsigned short m_usAdjustPitch; -}; diff --git a/regamedll/extra/cssdk/dlls/triggers.h b/regamedll/extra/cssdk/dlls/triggers.h deleted file mode 100644 index 7b5cb759..00000000 --- a/regamedll/extra/cssdk/dlls/triggers.h +++ /dev/null @@ -1,385 +0,0 @@ -/* -* -* This program is free software; you can redistribute it and/or modify it -* under the terms of the GNU General Public License as published by the -* Free Software Foundation; either version 2 of the License, or (at -* your option) any later version. -* -* This program 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 -* General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* -*/ -#pragma once - -#include "utlmap.h" - -#define GRENADETYPE_SMOKE 1 -#define GRENADETYPE_FLASH 2 - -#define SPAWNFLAG_NOMESSAGE 1 -#define SPAWNFLAG_NOTOUCH 1 -#define SPAWNFLAG_DROIDONLY 4 - -#define MAX_ITEM_COUNTS 32 -#define MAX_ENTITY 512 // We can only ever move 512 entities across a transition - -// triggers -#define SF_TRIGGER_ALLOWMONSTERS 1 // monsters allowed to fire this trigger -#define SF_TRIGGER_NOCLIENTS 2 // players not allowed to fire this trigger -#define SF_TRIGGER_PUSHABLES 4 // only pushables can fire this trigger -#define SF_TRIGGER_NO_RESET 64 // it is not allowed to be restarted on a new round - -#define SF_TRIGGER_PUSH_ONCE 1 -#define SF_TRIGGER_PUSH_START_OFF 2 // spawnflag that makes trigger_push spawn turned OFF - -#define SF_TRIGGER_HURT_TARGETONCE 1 // Only fire hurt target once -#define SF_TRIGGER_HURT_START_OFF 2 // spawnflag that makes trigger_push spawn turned OFF -#define SF_TRIGGER_HURT_NO_CLIENTS 8 // spawnflag that makes trigger_push spawn turned OFF -#define SF_TRIGGER_HURT_CLIENTONLYFIRE 16 // trigger hurt will only fire its target if it is hurting a client -#define SF_TRIGGER_HURT_CLIENTONLYTOUCH 32 // only clients may touch this trigger. - -#define SF_AUTO_FIREONCE 0x0001 -#define SF_AUTO_NO_RESET 0x0002 - -#define SF_RELAY_FIREONCE 0x0001 -#define SF_ENDSECTION_USEONLY 0x0001 - -#define SF_MULTIMAN_CLONE 0x80000000 -#define SF_MULTIMAN_THREAD 0x00000001 - -#define SF_CHANGELEVEL_USEONLY 0x0002 -#define SF_CAMERA_PLAYER_POSITION 1 -#define SF_CAMERA_PLAYER_TARGET 2 -#define SF_CAMERA_PLAYER_TAKECONTROL 4 - -// Flags to indicate masking off various render parameters that are normally copied to the targets -#define SF_RENDER_MASKFX (1 << 0) -#define SF_RENDER_MASKAMT (1 << 1) -#define SF_RENDER_MASKMODE (1 << 2) -#define SF_RENDER_MASKCOLOR (1 << 3) - -class CFrictionModifier: public CBaseEntity { -public: - virtual void Spawn() = 0; - virtual void KeyValue(KeyValueData *pkvd) = 0; - virtual int Save(CSave &save) = 0; - virtual int Restore(CRestore &restore) = 0; - virtual int ObjectCaps() = 0; -public: - float m_frictionFraction; -}; - -// This trigger will fire when the level spawns (or respawns if not fire once) -// It will check a global state before firing. It supports delay and killtargets -class CAutoTrigger: public CBaseDelay { -public: - virtual void Spawn() = 0; - virtual void Precache() = 0; - virtual void Restart() = 0; - virtual void KeyValue(KeyValueData *pkvd) = 0; - virtual int Save(CSave &save) = 0; - virtual int Restore(CRestore &restore) = 0; - virtual int ObjectCaps() = 0; - virtual void Think() = 0; -public: - int m_globalstate; - USE_TYPE triggerType; -}; - -class CTriggerRelay: public CBaseDelay { -public: - virtual void Spawn() = 0; - virtual void KeyValue(KeyValueData *pkvd) = 0; - virtual int Save(CSave &save) = 0; - virtual int Restore(CRestore &restore) = 0; - virtual int ObjectCaps() = 0; - virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) = 0; -public: - USE_TYPE triggerType; -}; - -// The Multimanager Entity - when fired, will fire up to 16 targets -// at specified times. -// FLAG: THREAD (create clones when triggered) -// FLAG: CLONE (this is a clone for a threaded execution) -class CMultiManager: public CBaseToggle { -public: - virtual void Spawn() = 0; - virtual void Restart() = 0; - virtual void KeyValue(KeyValueData *pkvd) = 0; - virtual int Save(CSave &save) = 0; - virtual int Restore(CRestore &restore) = 0; - virtual int ObjectCaps() = 0; - virtual BOOL HasTarget(string_t targetname) = 0; -public: - int m_cTargets; - int m_index; - float m_startTime; - int m_iTargetName[MAX_MULTI_TARGETS]; - float m_flTargetDelay[MAX_MULTI_TARGETS]; -}; - -// Render parameters trigger -// -// This entity will copy its render parameters (renderfx, rendermode, rendercolor, renderamt) -// to its targets when triggered. -class CRenderFxManager: public CBaseEntity { -public: - virtual void Spawn() = 0; - virtual void Restart() = 0; - virtual void UpdateOnRemove() = 0; - virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) = 0; -public: - struct RenderGroup_t - { - int rendermode; - float renderamt; - Vector rendercolor; - int renderfx; - }; - CUtlMap m_RenderGroups; -}; - -class CBaseTrigger: public CBaseToggle { -public: - virtual void KeyValue(KeyValueData *pkvd) = 0; - virtual int ObjectCaps() = 0; -}; - -// trigger_hurt - hurts anything that touches it. if the trigger has a targetname, firing it will toggle state -// int gfToggleState = 0; // used to determine when all radiation trigger hurts have called 'RadiationThink' -class CTriggerHurt: public CBaseTrigger { -public: - virtual void Spawn() = 0; - virtual void Restart() = 0; - virtual int ObjectCaps() = 0; -}; - -class CTriggerMonsterJump: public CBaseTrigger { -public: - virtual void Spawn() = 0; - virtual void Think() = 0; - virtual void Touch(CBaseEntity *pOther) = 0; -}; - -// trigger_cdaudio - starts/stops cd audio tracks -class CTriggerCDAudio: public CBaseTrigger { -public: - virtual void Spawn() = 0; - virtual void Touch(CBaseEntity *pOther) = 0; - virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) = 0; -}; - -// This plays a CD track when fired or when the player enters it's radius -class CTargetCDAudio: public CPointEntity { -public: - virtual void Spawn() = 0; - virtual void KeyValue(KeyValueData *pkvd) = 0; - virtual void Think() = 0; - virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) = 0; -}; - -// QUAKED trigger_multiple (.5 .5 .5) ? notouch -// Variable sized repeatable trigger. Must be targeted at one or more entities. -// If "health" is set, the trigger must be killed to activate each time. -// If "delay" is set, the trigger waits some time after activating before firing. -// "wait" : Seconds between triggerings. (.2 default) -// If notouch is set, the trigger is only fired by other entities, not by touching. -// NOTOUCH has been obsoleted by trigger_relay! -// sounds -// 1) secret -// 2) beep beep -// 3) large switch -// 4) -// NEW -// if a trigger has a NETNAME, that NETNAME will become the TARGET of the triggered object. -class CTriggerMultiple: public CBaseTrigger { -public: - virtual void Spawn() = 0; -}; - -// QUAKED trigger_once (.5 .5 .5) ? notouch -// Variable sized trigger. Triggers once, then removes itself. You must set the key "target" to the name of another object in the level that has a matching -// "targetname". If "health" is set, the trigger must be killed to activate. -// If notouch is set, the trigger is only fired by other entities, not by touching. -// if "killtarget" is set, any objects that have a matching "target" will be removed when the trigger is fired. -// if "angle" is set, the trigger will only fire when someone is facing the direction of the angle. Use "360" for an angle of 0. -// sounds -// 1) secret -// 2) beep beep -// 3) large switch -// 4) -class CTriggerOnce: public CTriggerMultiple { -public: - virtual void Spawn() = 0; - virtual void Restart() = 0; -}; - -// QUAKED trigger_counter (.5 .5 .5) ? nomessage -// Acts as an intermediary for an action that takes multiple inputs. -// If nomessage is not set, it will print "1 more.. " etc when triggered and -// "sequence complete" when finished. After the counter has been triggered "cTriggersLeft" -// times (default 2), it will fire all of it's targets and remove itself. -class CTriggerCounter: public CBaseTrigger { -public: - virtual void Spawn() = 0; -}; - -// Derive from point entity so this doesn't move across levels -class CTriggerVolume: public CPointEntity { -public: - virtual void Spawn() = 0; -}; - -// Fires a target after level transition and then dies -class CFireAndDie: public CBaseDelay { -public: - virtual void Spawn() = 0; - virtual void Precache() = 0; - virtual int ObjectCaps() = 0; // Always go across transitions - virtual void Think() = 0; -}; - -// QUAKED trigger_changelevel (0.5 0.5 0.5) ? NO_INTERMISSION -// When the player touches this, he gets sent to the map listed in the "map" variable. Unless the NO_INTERMISSION flag is set, the view will go to the info_intermission spot and display stats. -class CChangeLevel: public CBaseTrigger { -public: - virtual void Spawn() = 0; - virtual void KeyValue(KeyValueData *pkvd) = 0; - virtual int Save(CSave &save) = 0; - virtual int Restore(CRestore &restore) = 0; -public: - char m_szMapName[cchMapNameMost]; // trigger_changelevel only: next map - char m_szLandmarkName[cchMapNameMost]; // trigger_changelevel only: landmark on next map - int m_changeTarget; - float m_changeTargetDelay; -}; - -class CLadder: public CBaseTrigger { -public: - virtual void Spawn() = 0; - virtual void Precache() = 0; - virtual void KeyValue(KeyValueData *pkvd) = 0; -}; - -class CTriggerPush: public CBaseTrigger { -public: - virtual void Spawn() = 0; - virtual void Restart() = 0; - virtual void KeyValue(KeyValueData *pkvd) = 0; - virtual void Touch(CBaseEntity *pOther) = 0; -}; - -class CTriggerTeleport: public CBaseTrigger { -public: - virtual void Spawn() = 0; -}; - -class CBuyZone: public CBaseTrigger { -public: - virtual void Spawn() = 0; -}; - -class CBombTarget: public CBaseTrigger { -public: - virtual void Spawn() = 0; -}; - -class CHostageRescue: public CBaseTrigger { -public: - virtual void Spawn() = 0; -}; - -class CEscapeZone: public CBaseTrigger { -public: - virtual void Spawn() = 0; -}; - -class CVIP_SafetyZone: public CBaseTrigger { -public: - virtual void Spawn() = 0; -}; - -class CTriggerSave: public CBaseTrigger { -public: - virtual void Spawn() = 0; -}; - -class CTriggerEndSection: public CBaseTrigger { -public: - virtual void Spawn() = 0; - virtual void KeyValue(KeyValueData *pkvd) = 0; -}; - -class CTriggerGravity: public CBaseTrigger { -public: - virtual void Spawn() = 0; -}; - -// this is a really bad idea. -class CTriggerChangeTarget: public CBaseDelay { -public: - virtual void Spawn() = 0; - virtual void KeyValue(KeyValueData *pkvd) = 0; - virtual int Save(CSave &save) = 0; - virtual int Restore(CRestore &restore) = 0; - virtual int ObjectCaps() = 0; - virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) = 0; -private: - int m_iszNewTarget; -}; - -class CTriggerCamera: public CBaseDelay { -public: - virtual void Spawn() = 0; - virtual void KeyValue(KeyValueData *pkvd) = 0; - virtual int Save(CSave &save) = 0; - virtual int Restore(CRestore &restore) = 0; - virtual int ObjectCaps() = 0; - virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) = 0; -public: - EHANDLE m_hPlayer; - EHANDLE m_hTarget; - CBaseEntity *m_pentPath; - int m_sPath; - float m_flWait; - float m_flReturnTime; - float m_flStopTime; - float m_moveDistance; - float m_targetSpeed; - float m_initialSpeed; - float m_acceleration; - float m_deceleration; - int m_state; -}; - -class CWeather: public CBaseTrigger { -public: - virtual void Spawn() = 0; -}; - -class CClientFog: public CBaseEntity { -public: - virtual void Spawn() = 0; - virtual void KeyValue(KeyValueData *pkvd) = 0; -public: - int m_iStartDist; - int m_iEndDist; - float m_fDensity; -}; diff --git a/regamedll/extra/cssdk/dlls/unisignals.h b/regamedll/extra/cssdk/dlls/unisignals.h deleted file mode 100644 index 054bdc50..00000000 --- a/regamedll/extra/cssdk/dlls/unisignals.h +++ /dev/null @@ -1,57 +0,0 @@ -/* -* -* This program is free software; you can redistribute it and/or modify it -* under the terms of the GNU General Public License as published by the -* Free Software Foundation; either version 2 of the License, or (at -* your option) any later version. -* -* This program 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 -* General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* -*/ - -#ifndef UNISIGNALS_H -#define UNISIGNALS_H -#ifdef _WIN32 -#pragma once -#endif - -class CUnifiedSignals -{ -public: - CUnifiedSignals() - { - m_flSignal = 0; - m_flState = 0; - } -public: - void Update() - { - m_flState = m_flSignal; - m_flSignal = 0; - } - void Signal(int flags) { m_flSignal |= flags; } - int GetSignal() const { return m_flSignal; } - int GetState() const { return m_flState; } -public: - int m_flSignal; - int m_flState; -}; - -#endif // UNISIGNALS_H diff --git a/regamedll/extra/cssdk/dlls/util.h b/regamedll/extra/cssdk/dlls/util.h deleted file mode 100644 index 4eaafbf9..00000000 --- a/regamedll/extra/cssdk/dlls/util.h +++ /dev/null @@ -1,173 +0,0 @@ -/* -* -* This program is free software; you can redistribute it and/or modify it -* under the terms of the GNU General Public License as published by the -* Free Software Foundation; either version 2 of the License, or (at -* your option) any later version. -* -* This program 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 -* General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* -*/ -#pragma once - -#include "enginecallback.h" - -#define eoNullEntity 0 // Testing the three types of "entity" for nullity -#define iStringNull 0 // Testing strings for nullity - -#define cchMapNameMost 32 - -#define CBSENTENCENAME_MAX 16 -#define CVOXFILESENTENCEMAX 1536 // max number of sentences in game. NOTE: this must match CVOXFILESENTENCEMAX in engine\sound.h - -#define GROUP_OP_AND 0 -#define GROUP_OP_NAND 1 - -extern globalvars_t *gpGlobals; - -// Use this instead of ALLOC_STRING on constant strings -#define STRING(offset) ((const char *)(gpGlobals->pStringBase + (unsigned int)(offset))) -#define MAKE_STRING(str) ((uint64)(str) - (uint64)(STRING(0))) - -// Dot products for view cone checking -#define VIEW_FIELD_FULL -1.0 // +-180 degrees -#define VIEW_FIELD_WIDE -0.7 // +-135 degrees 0.1 // +-85 degrees, used for full FOV checks -#define VIEW_FIELD_NARROW 0.7 // +-45 degrees, more narrow check used to set up ranged attacks -#define VIEW_FIELD_ULTRA_NARROW 0.9 // +-25 degrees, more narrow check used to set up ranged attacks - -#define SND_SPAWNING (1<<8) // duplicated in protocol.h we're spawing, used in some cases for ambients -#define SND_STOP (1<<5) // duplicated in protocol.h stop sound -#define SND_CHANGE_VOL (1<<6) // duplicated in protocol.h change sound vol -#define SND_CHANGE_PITCH (1<<7) // duplicated in protocol.h change sound pitch - -// All monsters need this data -#define DONT_BLEED -1 -#define BLOOD_COLOR_RED (byte)247 -#define BLOOD_COLOR_YELLOW (byte)195 -#define BLOOD_COLOR_GREEN BLOOD_COLOR_YELLOW - -#define GERMAN_GIB_COUNT 4 -#define HUMAN_GIB_COUNT 6 -#define ALIEN_GIB_COUNT 4 - -#define LANGUAGE_ENGLISH 0 -#define LANGUAGE_GERMAN 1 -#define LANGUAGE_FRENCH 2 -#define LANGUAGE_BRITISH 3 - -#define SVC_TEMPENTITY 23 -#define SVC_INTERMISSION 30 -#define SVC_CDTRACK 32 -#define SVC_WEAPONANIM 35 -#define SVC_ROOMTYPE 37 -#define SVC_DIRECTOR 51 - -#define VEC_HULL_MIN_Z Vector(0, 0, -36) -#define VEC_DUCK_HULL_MIN_Z Vector(0, 0, -18) - -#define VEC_HULL_MIN Vector(-16, -16, -36) -#define VEC_HULL_MAX Vector(16, 16, 36) - -#define VEC_VIEW Vector(0, 0, 17) - -#define VEC_DUCK_HULL_MIN Vector(-16, -16, -18) -#define VEC_DUCK_HULL_MAX Vector(16, 16, 32) -#define VEC_DUCK_VIEW Vector(0, 0, 12) - -#define PRECACHE_SOUND_ARRAY(a) \ - { for (int i = 0; i < ARRAYSIZE(a); ++i) PRECACHE_SOUND((char *)a[i]); } - -// Inlines -inline edict_t *FIND_ENTITY_BY_CLASSNAME(edict_t *entStart, const char *pszName) { return FIND_ENTITY_BY_STRING(entStart, "classname", pszName); } -inline edict_t *FIND_ENTITY_BY_TARGETNAME(edict_t *entStart, const char *pszName) { return FIND_ENTITY_BY_STRING(entStart, "targetname", pszName); } - -inline edict_t *ENT(const entvars_t *pev) { return pev->pContainingEntity; } -inline edict_t *ENT(EOFFSET eoffset) { return (*g_engfuncs.pfnPEntityOfEntOffset)(eoffset); } -inline EOFFSET OFFSET(const edict_t *pent) { return (*g_engfuncs.pfnEntOffsetOfPEntity)(pent); } -inline EOFFSET OFFSET(const entvars_t *pev) { return OFFSET(ENT(pev)); } - -inline entvars_t *VARS(edict_t *pent) -{ - if (!pent) - return NULL; - - return &pent->v; -} - -inline entvars_t *VARS(EOFFSET eoffset) -{ - return VARS(ENT(eoffset)); -} - -#ifndef ENTINDEX -inline int ENTINDEX(const edict_t *pEdict) { return (*g_engfuncs.pfnIndexOfEdict)(pEdict); } -inline int ENTINDEX(const entvars_t *pev) { return (*g_engfuncs.pfnIndexOfEdict)(ENT(pev)); } -#endif // ENTINDEX - -#ifndef INDEXENT -inline edict_t *INDEXENT(int iEdictNum) { return (*g_engfuncs.pfnPEntityOfEntIndex)(iEdictNum); } -#endif // INDEXENT - -inline void MESSAGE_BEGIN(int msg_dest, int msg_type, const float *pOrigin, entvars_t *ent) { MESSAGE_BEGIN(msg_dest, msg_type, pOrigin, ENT(ent)); } -inline BOOL FNullEnt(EOFFSET eoffset) { return (eoffset == 0); } -inline BOOL FNullEnt(entvars_t *pev) { return (pev == NULL || FNullEnt(OFFSET(pev))); } -inline BOOL FNullEnt(const edict_t *pent) { return (pent == NULL || FNullEnt(OFFSET(pent))); } -inline BOOL FStringNull(int iString) { return (iString == iStringNull); } -inline BOOL FStrEq(const char *sz1, const char *sz2) { return (strcmp(sz1, sz2) == 0); } -inline BOOL FClassnameIs(entvars_t *pev, const char *szClassname) { return FStrEq(STRING(pev->classname), szClassname); } -inline BOOL FClassnameIs(edict_t *pent, const char *szClassname) { return FStrEq(STRING(VARS(pent)->classname), szClassname); } - -inline void UTIL_MakeVectorsPrivate(Vector vecAngles, float *p_vForward, float *p_vRight, float *p_vUp) { g_engfuncs.pfnAngleVectors(vecAngles, p_vForward, p_vRight, p_vUp); } - -// NOTE: use EMIT_SOUND_DYN to set the pitch of a sound. Pitch of 100 -// is no pitch shift. Pitch > 100 up to 255 is a higher pitch, pitch < 100 -// down to 1 is a lower pitch. 150 to 70 is the realistic range. -// EMIT_SOUND_DYN with pitch != 100 should be used sparingly, as it's not quite as -// fast as EMIT_SOUND (the pitchshift mixer is not native coded). -inline void EMIT_SOUND(edict_t *entity, int channel, const char *sample, float volume, float attenuation) -{ - EMIT_SOUND_DYN2(entity, channel, sample, volume, attenuation, 0, PITCH_NORM); -} - -inline void STOP_SOUND(edict_t *entity, int channel, const char *sample) -{ - EMIT_SOUND_DYN2(entity, channel, sample, 0, 0, SND_STOP, PITCH_NORM); -} - -inline void UTIL_SetSize(entvars_t *pev, const Vector &vecMin, const Vector &vecMax) -{ - SET_SIZE(ENT(pev), vecMin, vecMax); -} - -inline void UTIL_SetOrigin(entvars_t *pev, const Vector &vecOrigin) -{ - edict_t *ent = ENT(pev); - - if (ent != NULL) - SET_ORIGIN(ent, vecOrigin); -} - -inline void UTIL_TraceLine(const Vector &vecStart, const Vector &vecEnd, IGNORE_MONSTERS igmon, edict_t *pentIgnore, TraceResult *ptr) -{ - TRACE_LINE(vecStart, vecEnd, (igmon == ignore_monsters), pentIgnore, ptr); -} - -extern char *UTIL_VarArgs(char *format, ...); -extern void UTIL_LogPrintf(const char *fmt, ...); diff --git a/regamedll/extra/cssdk/dlls/vector.h b/regamedll/extra/cssdk/dlls/vector.h deleted file mode 100644 index 6427e1e8..00000000 --- a/regamedll/extra/cssdk/dlls/vector.h +++ /dev/null @@ -1,176 +0,0 @@ -/* -* -* This program is free software; you can redistribute it and/or modify it -* under the terms of the GNU General Public License as published by the -* Free Software Foundation; either version 2 of the License, or (at -* your option) any later version. -* -* This program 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 -* General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* -*/ -#pragma once - -// 2DVector - used for many pathfinding and many other -// operations that are treated as planar rather than 3d. -class Vector2D { -public: - inline Vector2D() : x(), y() {} - inline Vector2D(float X, float Y) : x(X), y(Y) {} - inline Vector2D(const Vector2D &v) { *(int*)&x = *(int*)&v.x; *(int*)&y = *(int*)&v.y; } - inline Vector2D operator+(const Vector2D &v) const { return Vector2D(x + v.x, y + v.y); } - inline Vector2D operator-(const Vector2D &v) const { return Vector2D(x - v.x, y - v.y); } - inline Vector2D operator*(float fl) const { return Vector2D(x * fl, y * fl); } - inline Vector2D operator/(float fl) const { return Vector2D(x / fl, y / fl); } - inline Vector2D operator/=(float fl) const { return Vector2D(x / fl, y / fl); } - - inline float Length() const { return sqrt(x * x + y * y); } - inline float LengthSquared() const { return (x * x + y * y); } - - operator float*() { return &x; } - operator const float*() const { return &x; } - - inline Vector2D Normalize() const - { - float flLen = Length(); - if (flLen == 0) - return Vector2D(0, 0); - - flLen = 1 / flLen; - return Vector2D(x * flLen, y * flLen); - } - - inline bool IsLengthLessThan(float length) const { return (LengthSquared() < length * length); } - inline bool IsLengthGreaterThan(float length) const { return (LengthSquared() > length * length); } - inline float NormalizeInPlace() - { - float flLen = Length(); - if (flLen == 0) - { - x = 1; y = 0; - } - else - { - flLen = 1 / flLen; - x *= flLen; y *= flLen; - } - - return flLen; - } - inline bool IsZero(float tolerance = 0.01f) const - { - return (x > -tolerance && x < tolerance && - y > -tolerance && y < tolerance); - } - - // Members - vec_t x, y; -}; - -inline float DotProduct(const Vector2D &a, const Vector2D &b) { return (a.x * b.x + a.y * b.y); } -inline Vector2D operator*(float fl, const Vector2D &v) { return v * fl; } - -// 3D Vector -// same data-layout as engine's vec3_t, which is a vec_t[3] -class Vector { -public: - // Construction/destruction - inline Vector() : x(), y(), z() {} - inline Vector(float X, float Y, float Z) : x(X), y(Y), z(Z) {} - inline Vector(const Vector &v) { *(int*)&x = *(int*)&v.x; *(int*)&y = *(int*)&v.y; *(int*)&z = *(int*)&v.z; } - inline Vector(const float rgfl[3]) { *(int*)&x = *(int*)&rgfl[0]; *(int*)&y = *(int*)&rgfl[1]; *(int*)&z = *(int*)&rgfl[2]; } - - // Operators - inline Vector operator-() const { return Vector(-x, -y, -z); } - inline int operator==(const Vector &v) const { return x == v.x && y == v.y && z == v.z; } - inline int operator!=(const Vector &v) const { return !(*this == v); } - inline Vector operator+(const Vector &v) const { return Vector(x + v.x, y + v.y, z + v.z); } - inline Vector operator-(const Vector &v) const { return Vector(x - v.x, y - v.y, z - v.z); } - inline Vector operator*(float fl) const { return Vector(x * fl, y * fl, z * fl); } - inline Vector operator/(float fl) const { return Vector(x / fl, y / fl, z / fl); } - inline Vector operator/=(float fl) const{ return Vector(x / fl, y / fl, z / fl); } - - // Methods - inline void CopyToArray(float *rgfl) const { *(int*)&rgfl[0] = *(int*)&x; *(int*)&rgfl[1] = *(int*)&y; *(int*)&rgfl[2] = *(int*)&z; } - inline float Length() const { return sqrt(x * x + y * y + z * z); } - inline float LengthSquared() const { return (x * x + y * y + z * z); } - - operator float*() { return &x; } // Vectors will now automatically convert to float * when needed - operator const float*() const { return &x; } // Vectors will now automatically convert to float * when needed - - inline Vector Normalize() - { - float flLen = Length(); - if (flLen == 0) - return Vector(0, 0, 1); - - flLen = 1 / flLen; - return Vector(x * flLen, y * flLen, z * flLen); - } - inline Vector2D Make2D() const - { - Vector2D Vec2; - *(int*)&Vec2.x = *(int*)&x; - *(int*)&Vec2.y = *(int*)&y; - return Vec2; - } - - inline float Length2D() const { return sqrt(x * x + y * y); } - - inline bool IsLengthLessThan(float length) const { return (LengthSquared() < length * length); } - inline bool IsLengthGreaterThan(float length) const { return (LengthSquared() > length * length); } - - inline float NormalizeInPlace() - { - float flLen = Length(); - if (flLen == 0) - { - x = 0; y = 0; z = 1; - } - else - { - flLen = 1 / flLen; - x *= flLen; y *= flLen; z *= flLen; - } - - return flLen; - } - inline bool IsZero(float tolerance = 0.01f) const - { - return (x > -tolerance && x < tolerance && - y > -tolerance && y < tolerance && - z > -tolerance && z < tolerance); - } - - // Members - vec_t x, y, z; -}; - -inline Vector operator*(float fl, const Vector &v) { return v * fl; } -inline float DotProduct(const Vector &a, const Vector &b) { return (a.x * b.x + a.y * b.y + a.z * b.z); } -inline float DotProduct2D(const Vector &a, const Vector &b) { return (a.x * b.x + a.y * b.y); } -inline Vector CrossProduct(const Vector &a, const Vector &b) { return Vector(a.y * b.z - a.z * b.y, a.z * b.x - a.x * b.z, a.x * b.y - a.y * b.x); } - -template -inline void SWAP(T &first, T &second) -{ - T temp = first; - first = second; - second = temp; -} diff --git a/regamedll/extra/cssdk/dlls/vehicle.h b/regamedll/extra/cssdk/dlls/vehicle.h deleted file mode 100644 index 8b7a0d01..00000000 --- a/regamedll/extra/cssdk/dlls/vehicle.h +++ /dev/null @@ -1,53 +0,0 @@ -/* -* -* This program is free software; you can redistribute it and/or modify it -* under the terms of the GNU General Public License as published by the -* Free Software Foundation; either version 2 of the License, or (at -* your option) any later version. -* -* This program 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 -* General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* -*/ -#pragma once - -#define VEHICLE_SPEED0_ACCELERATION 0.005000000000000000 -#define VEHICLE_SPEED1_ACCELERATION 0.002142857142857143 -#define VEHICLE_SPEED2_ACCELERATION 0.003333333333333334 -#define VEHICLE_SPEED3_ACCELERATION 0.004166666666666667 -#define VEHICLE_SPEED4_ACCELERATION 0.004000000000000000 -#define VEHICLE_SPEED5_ACCELERATION 0.003800000000000000 -#define VEHICLE_SPEED6_ACCELERATION 0.004500000000000000 -#define VEHICLE_SPEED7_ACCELERATION 0.004250000000000000 -#define VEHICLE_SPEED8_ACCELERATION 0.002666666666666667 -#define VEHICLE_SPEED9_ACCELERATION 0.002285714285714286 -#define VEHICLE_SPEED10_ACCELERATION 0.001875000000000000 -#define VEHICLE_SPEED11_ACCELERATION 0.001444444444444444 -#define VEHICLE_SPEED12_ACCELERATION 0.001200000000000000 -#define VEHICLE_SPEED13_ACCELERATION 0.000916666666666666 - -#define VEHICLE_STARTPITCH 60 -#define VEHICLE_MAXPITCH 200 -#define VEHICLE_MAXSPEED 1500 - -class CFuncVehicleControls: public CBaseEntity { -public: - virtual void Spawn() = 0; - virtual int ObjectCaps() = 0; -}; diff --git a/regamedll/extra/cssdk/dlls/weapons.h b/regamedll/extra/cssdk/dlls/weapons.h deleted file mode 100644 index c4da5013..00000000 --- a/regamedll/extra/cssdk/dlls/weapons.h +++ /dev/null @@ -1,909 +0,0 @@ -/* -* -* This program is free software; you can redistribute it and/or modify it -* under the terms of the GNU General Public License as published by the -* Free Software Foundation; either version 2 of the License, or (at -* your option) any later version. -* -* This program 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 -* General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* -*/ - -#pragma once - -#include "weapontype.h" - -class CBasePlayer; - -#define MAX_WEAPONS 32 -#define MAX_NORMAL_BATTERY 100.0f -#define DISTANCE_RELOAD_SOUND 512.0f - -#define ITEM_FLAG_SELECTONEMPTY 1 -#define ITEM_FLAG_NOAUTORELOAD 2 -#define ITEM_FLAG_NOAUTOSWITCHEMPTY 4 -#define ITEM_FLAG_LIMITINWORLD 8 -#define ITEM_FLAG_EXHAUSTIBLE 16 // A player can totally exhaust their ammo supply and lose this weapon - -#define WEAPON_IS_ONTARGET 0x40 - -// the maximum amount of ammo each weapon's clip can hold -#define WEAPON_NOCLIP -1 - -#define LOUD_GUN_VOLUME 1000 -#define NORMAL_GUN_VOLUME 600 -#define QUIET_GUN_VOLUME 200 - -#define BRIGHT_GUN_FLASH 512 -#define NORMAL_GUN_FLASH 256 -#define DIM_GUN_FLASH 128 - -#define BIG_EXPLOSION_VOLUME 2048 -#define NORMAL_EXPLOSION_VOLUME 1024 -#define SMALL_EXPLOSION_VOLUME 512 - -#define WEAPON_ACTIVITY_VOLUME 64 - -// spawn flags -#define SF_DETONATE 0x0001 // Grenades flagged with this will be triggered when the owner calls detonateSatchelCharges - -// custom enum -enum ArmorType -{ - ARMOR_NONE, // no armor - ARMOR_KEVLAR, // body vest only - ARMOR_VESTHELM, // vest and helmet -}; - -enum ArmouryItemPack -{ - ARMOURY_MP5NAVY, - ARMOURY_TMP, - ARMOURY_P90, - ARMOURY_MAC10, - ARMOURY_AK47, - ARMOURY_SG552, - ARMOURY_M4A1, - ARMOURY_AUG, - ARMOURY_SCOUT, - ARMOURY_G3SG1, - ARMOURY_AWP, - ARMOURY_M3, - ARMOURY_XM1014, - ARMOURY_M249, - ARMOURY_FLASHBANG, - ARMOURY_HEGRENADE, - ARMOURY_KEVLAR, - ARMOURY_ASSAULT, - ARMOURY_SMOKEGRENADE, - ARMOURY_GLOCK18, - ARMOURY_USP, - ARMOURY_ELITE, - ARMOURY_FIVESEVEN, - ARMOURY_P228, - ARMOURY_DEAGLE, - ARMOURY_FAMAS, - ARMOURY_SG550, - ARMOURY_GALIL, - ARMOURY_UMP45, - ARMOURY_SHIELD -}; - -struct ItemInfo -{ - int iSlot; - int iPosition; - const char *pszAmmo1; - int iMaxAmmo1; - const char *pszAmmo2; - int iMaxAmmo2; - const char *pszName; - int iMaxClip; - int iId; - int iFlags; - int iWeight; -}; - -struct AmmoInfo -{ - const char *pszName; - int iId; -}; - -struct MULTIDAMAGE -{ - CBaseEntity *pEntity; - float amount; - int type; -}; - -class CArmoury: public CBaseEntity { -public: - virtual void Spawn() = 0; - virtual void Precache() = 0; - virtual void Restart() = 0; - virtual void KeyValue(KeyValueData *pkvd) = 0; -public: - ArmouryItemPack m_iItem; - int m_iCount; - int m_iInitialCount; - bool m_bAlreadyCounted; -}; - -// Smoke Grenade / HE grenade / Flashbang grenade / C4 -class CGrenade: public CBaseMonster { -public: - virtual void Spawn() = 0; - virtual int Save(CSave &save) = 0; - virtual int Restore(CRestore &restore) = 0; - virtual int ObjectCaps() = 0; - virtual void Killed(entvars_t *pevAttacker, int iGib) = 0; - virtual int BloodColor() = 0; - virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) = 0; - virtual void BounceSound() = 0; -public: - bool m_bStartDefuse; - bool m_bIsC4; - EHANDLE m_pBombDefuser; - float m_flDefuseCountDown; - float m_flC4Blow; - float m_flNextFreqInterval; - float m_flNextBeep; - float m_flNextFreq; - char *m_sBeepName; - float m_fAttenu; - float m_flNextBlink; - float m_fNextDefuse; - bool m_bJustBlew; - int m_iTeam; - int m_iCurWave; - edict_t *m_pentCurBombTarget; - int m_SGSmoke; - int m_angle; - unsigned short m_usEvent; - bool m_bLightSmoke; - bool m_bDetonated; - Vector m_vSmokeDetonate; - int m_iBounceCount; - BOOL m_fRegisteredSound; // whether or not this grenade has issued its DANGER sound to the world sound list yet. -}; - -// Items that the player has in their inventory that they can use -class CBasePlayerItem: public CBaseAnimating { -public: - virtual int Save(CSave &save) = 0; - virtual int Restore(CRestore &restore) = 0; - virtual void SetObjectCollisionBox() = 0; - virtual CBaseEntity *Respawn() = 0; - virtual int AddToPlayer(CBasePlayer *pPlayer) = 0; // return TRUE if the item you want the item added to the player inventory - virtual int AddDuplicate(CBasePlayerItem *pItem) = 0; // return TRUE if you want your duplicate removed from world - virtual int GetItemInfo(ItemInfo *p) = 0; // returns 0 if struct not filled out - virtual BOOL CanDeploy() = 0; - virtual BOOL CanDrop() = 0; // returns is deploy was successful - virtual BOOL Deploy() = 0; - virtual BOOL IsWeapon() = 0; - virtual BOOL CanHolster() = 0; // can this weapon be put away right now? - virtual void Holster(int skiplocal = 0) = 0; - virtual void UpdateItemInfo() = 0; - virtual void ItemPreFrame() = 0; // called each frame by the player PreThink - virtual void ItemPostFrame() = 0; // called each frame by the player PostThink - virtual void Drop() = 0; - virtual void Kill() = 0; - virtual void AttachToPlayer(CBasePlayer *pPlayer) = 0; - virtual int PrimaryAmmoIndex() = 0; - virtual int SecondaryAmmoIndex() = 0; - virtual int UpdateClientData(CBasePlayer *pPlayer) = 0; - virtual CBasePlayerItem *GetWeaponPtr() = 0; - virtual float GetMaxSpeed() = 0; - virtual int iItemSlot() = 0; // return 0 to MAX_ITEMS_SLOTS, used in hud -public: - CBasePlayer *m_pPlayer; - CBasePlayerItem *m_pNext; - int m_iId; // WEAPON_??? -}; - -// inventory items that -class CBasePlayerWeapon: public CBasePlayerItem { -public: - virtual int Save(CSave &save) = 0; - virtual int Restore(CRestore &restore) = 0; - - // generic weapon versions of CBasePlayerItem calls - virtual int AddToPlayer(CBasePlayer *pPlayer) = 0; - virtual int AddDuplicate(CBasePlayerItem *pItem) = 0; - virtual BOOL CanDeploy() = 0; - virtual BOOL IsWeapon() = 0; - virtual void Holster(int skiplocal = 0) = 0; - virtual void UpdateItemInfo() = 0; - virtual void ItemPostFrame() = 0; - virtual int PrimaryAmmoIndex() = 0; - virtual int SecondaryAmmoIndex() = 0; - virtual int UpdateClientData(CBasePlayer *pPlayer) = 0; - virtual CBasePlayerItem *GetWeaponPtr() = 0; - virtual int ExtractAmmo(CBasePlayerWeapon *pWeapon) = 0; - virtual int ExtractClipAmmo(CBasePlayerWeapon *pWeapon) = 0; - virtual int AddWeapon() = 0; - virtual BOOL PlayEmptySound() = 0; - virtual void ResetEmptySound() = 0; - virtual void SendWeaponAnim(int iAnim, int skiplocal = 0) = 0; - virtual BOOL IsUseable() = 0; - virtual void PrimaryAttack() = 0; - virtual void SecondaryAttack() = 0; - virtual void Reload() = 0; - virtual void WeaponIdle() = 0; - virtual void RetireWeapon() = 0; - virtual BOOL ShouldWeaponIdle() = 0; - virtual BOOL UseDecrement() = 0; -public: - BOOL IsPistol() { return (m_iId == WEAPON_USP || m_iId == WEAPON_GLOCK18 || m_iId == WEAPON_P228 || m_iId == WEAPON_DEAGLE || m_iId == WEAPON_ELITE || m_iId == WEAPON_FIVESEVEN); } - - int m_iPlayEmptySound; - int m_fFireOnEmpty; - float m_flNextPrimaryAttack; // soonest time ItemPostFrame will call PrimaryAttack - float m_flNextSecondaryAttack; // soonest time ItemPostFrame will call SecondaryAttack - float m_flTimeWeaponIdle; // soonest time ItemPostFrame will call WeaponIdle - int m_iPrimaryAmmoType; // "primary" ammo index into players m_rgAmmo[] - int m_iSecondaryAmmoType; // "secondary" ammo index into players m_rgAmmo[] - int m_iClip; // number of shots left in the primary weapon clip, -1 it not used - int m_iClientClip; // the last version of m_iClip sent to hud dll - int m_iClientWeaponState; // the last version of the weapon state sent to hud dll (is current weapon, is on target) - int m_fInReload; // Are we in the middle of a reload; - int m_fInSpecialReload; // Are we in the middle of a reload for the shotguns - int m_iDefaultAmmo; // how much ammo you get when you pick up this weapon as placed by a level designer. - int m_iShellId; - float m_fMaxSpeed; - bool m_bDelayFire; - int m_iDirection; - bool m_bSecondarySilencerOn; - float m_flAccuracy; - float m_flLastFire; - int m_iShotsFired; - Vector m_vVecAiming; - string_t model_name; - float m_flGlock18Shoot; // time to shoot the remaining bullets of the glock18 burst fire - int m_iGlock18ShotsFired; // used to keep track of the shots fired during the Glock18 burst fire mode. - float m_flFamasShoot; - int m_iFamasShotsFired; - float m_fBurstSpread; - int m_iWeaponState; - float m_flNextReload; - float m_flDecreaseShotsFired; - unsigned short m_usFireGlock18; - unsigned short m_usFireFamas; - - // hle time creep vars - float m_flPrevPrimaryAttack; - float m_flLastFireTime; -}; - -class CBasePlayerAmmo: public CBaseEntity { -public: - virtual void Spawn() = 0; - virtual BOOL AddAmmo(CBaseEntity *pOther) = 0; - virtual CBaseEntity *Respawn() = 0; -}; - -class CWeaponBox: public CBaseEntity { -public: - virtual void Spawn() = 0; - virtual void Precache() = 0; - virtual void KeyValue(KeyValueData *pkvd) = 0; - virtual int Save(CSave &save) = 0; - virtual int Restore(CRestore &restore) = 0; - virtual void SetObjectCollisionBox() = 0; - virtual void Touch(CBaseEntity *pOther) = 0; -public: - CBasePlayerItem *m_rgpPlayerItems[MAX_ITEM_TYPES]; - int m_rgiszAmmo[MAX_AMMO_SLOTS]; - int m_rgAmmo[MAX_AMMO_SLOTS]; - int m_cAmmoTypes; - bool m_bIsBomb; -}; - -class CUSP: public CBasePlayerWeapon { -public: - virtual void Spawn() = 0; - virtual void Precache() = 0; - virtual int GetItemInfo(ItemInfo *p) = 0; - virtual BOOL Deploy() = 0; - virtual float GetMaxSpeed() = 0; - virtual int iItemSlot() = 0; - virtual void PrimaryAttack() = 0; - virtual void SecondaryAttack() = 0; - virtual void Reload() = 0; - virtual void WeaponIdle() = 0; - virtual BOOL UseDecrement() = 0; - virtual BOOL IsPistol() = 0; - -public: - int m_iShell; - unsigned short GetEventID() const { return m_usFireUSP; } -private: - unsigned short m_usFireUSP; -}; - -class CMP5N: public CBasePlayerWeapon { -public: - virtual void Spawn() = 0; - virtual void Precache() = 0; - virtual int GetItemInfo(ItemInfo *p) = 0; - virtual BOOL Deploy() = 0; - virtual float GetMaxSpeed() = 0; - virtual int iItemSlot() = 0; - virtual void PrimaryAttack() = 0; - virtual void Reload() = 0; - virtual void WeaponIdle() = 0; - virtual BOOL UseDecrement() = 0; -public: - int m_iShell; - int iShellOn; - unsigned short GetEventID() const { return m_usFireMP5N; } -private: - unsigned short m_usFireMP5N; -}; - -class CSG552: public CBasePlayerWeapon { -public: - virtual void Spawn() = 0; - virtual void Precache() = 0; - virtual int GetItemInfo(ItemInfo *p) = 0; - virtual BOOL Deploy() = 0; - virtual float GetMaxSpeed() = 0; - virtual int iItemSlot() = 0; - virtual void PrimaryAttack() = 0; - virtual void SecondaryAttack() = 0; - virtual void Reload() = 0; - virtual void WeaponIdle() = 0; - virtual BOOL UseDecrement() = 0; -public: - int m_iShell; - int iShellOn; - unsigned short GetEventID() const { return m_usFireSG552; } -private: - unsigned short m_usFireSG552; -}; - -class CAK47: public CBasePlayerWeapon { -public: - virtual void Spawn() = 0; - virtual void Precache() = 0; - virtual int GetItemInfo(ItemInfo *p) = 0; - virtual BOOL Deploy() = 0; - virtual float GetMaxSpeed() = 0; - virtual int iItemSlot() = 0; - virtual void PrimaryAttack() = 0; - virtual void SecondaryAttack() = 0; - virtual void Reload() = 0; - virtual void WeaponIdle() = 0; - virtual BOOL UseDecrement() = 0; -public: - int m_iShell; - int iShellOn; - unsigned short GetEventID() const { return m_usFireAK47; } -private: - unsigned short m_usFireAK47; -}; - -class CAUG: public CBasePlayerWeapon { -public: - virtual void Spawn() = 0; - virtual void Precache() = 0; - virtual int GetItemInfo(ItemInfo *p) = 0; - virtual BOOL Deploy() = 0; - virtual float GetMaxSpeed() = 0; - virtual int iItemSlot() = 0; - virtual void PrimaryAttack() = 0; - virtual void SecondaryAttack() = 0; - virtual void Reload() = 0; - virtual void WeaponIdle() = 0; - virtual BOOL UseDecrement() = 0; -public: - int m_iShell; - int iShellOn; - unsigned short GetEventID() const { return m_usFireAug; } -private: - unsigned short m_usFireAug; -}; - -class CAWP: public CBasePlayerWeapon { -public: - virtual void Spawn() = 0; - virtual void Precache() = 0; - virtual int GetItemInfo(ItemInfo *p) = 0; - virtual BOOL Deploy() = 0; - virtual float GetMaxSpeed() = 0; - virtual int iItemSlot() = 0; - virtual void PrimaryAttack() = 0; - virtual void SecondaryAttack() = 0; - virtual void Reload() = 0; - virtual void WeaponIdle() = 0; - virtual BOOL UseDecrement() = 0; -public: - int m_iShell; - unsigned short GetEventID() const { return m_usFireAWP; } -private: - unsigned short m_usFireAWP; -}; - -// for usermsg BombDrop -#define BOMB_FLAG_DROPPED 0 // if the bomb was dropped due to voluntary dropping or death/disconnect -#define BOMB_FLAG_PLANTED 1 // if the bomb has been planted will also trigger the round timer to hide will also show where the dropped bomb on the Terrorist team's radar. - -class CC4: public CBasePlayerWeapon { -public: - virtual void Spawn() = 0; - virtual void Precache() = 0; - virtual void KeyValue(KeyValueData *pkvd) = 0; - virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) = 0; - virtual int GetItemInfo(ItemInfo *p) = 0; - virtual BOOL Deploy() = 0; - virtual void Holster(int skiplocal) = 0; - virtual float GetMaxSpeed() = 0; - virtual int iItemSlot() = 0; - virtual void PrimaryAttack() = 0; - virtual void WeaponIdle() = 0; - virtual BOOL UseDecrement() = 0; -public: - bool m_bStartedArming; - bool m_bBombPlacedAnimation; - float m_fArmedTime; - bool HasShield() const { return m_bHasShield; } -private: - bool m_bHasShield; -}; - -class CDEAGLE: public CBasePlayerWeapon { -public: - virtual void Spawn() = 0; - virtual void Precache() = 0; - virtual int GetItemInfo(ItemInfo *p) = 0; - virtual BOOL Deploy() = 0; - virtual float GetMaxSpeed() = 0; - virtual int iItemSlot() = 0; - virtual void PrimaryAttack() = 0; - virtual void SecondaryAttack() = 0; - virtual void Reload() = 0; - virtual void WeaponIdle() = 0; - virtual BOOL UseDecrement() = 0; - virtual BOOL IsPistol() = 0; -public: - int m_iShell; - unsigned short GetEventID() const { return m_usFireDeagle; } -private: - unsigned short m_usFireDeagle; -}; - -class CFlashbang: public CBasePlayerWeapon { -public: - virtual void Spawn() = 0; - virtual void Precache() = 0; - virtual int GetItemInfo(ItemInfo *p) = 0; - virtual BOOL CanDeploy() = 0; - virtual BOOL CanDrop() = 0; - virtual BOOL Deploy() = 0; - virtual void Holster(int skiplocal) = 0; - virtual float GetMaxSpeed() = 0; - virtual int iItemSlot() = 0; - virtual void PrimaryAttack() = 0; - virtual void SecondaryAttack() = 0; - virtual void WeaponIdle() = 0; - virtual BOOL UseDecrement() = 0; - virtual BOOL IsPistol() = 0; -}; - -class CG3SG1: public CBasePlayerWeapon { -public: - virtual void Spawn() = 0; - virtual void Precache() = 0; - virtual int GetItemInfo(ItemInfo *p) = 0; - virtual BOOL Deploy() = 0; - virtual float GetMaxSpeed() = 0; - virtual int iItemSlot() = 0; - virtual void PrimaryAttack() = 0; - virtual void SecondaryAttack() = 0; - virtual void Reload() = 0; - virtual void WeaponIdle() = 0; - virtual BOOL UseDecrement() = 0; -public: - int m_iShell; - unsigned short GetEventID() const { return m_usFireG3SG1; } -private: - unsigned short m_usFireG3SG1; -}; - -class CGLOCK18: public CBasePlayerWeapon { -public: - virtual void Spawn() = 0; - virtual void Precache() = 0; - virtual int GetItemInfo(ItemInfo *p) = 0; - virtual BOOL Deploy() = 0; - virtual float GetMaxSpeed() = 0; - virtual int iItemSlot() = 0; - virtual void PrimaryAttack() = 0; - virtual void SecondaryAttack() = 0; - virtual void Reload() = 0; - virtual void WeaponIdle() = 0; - virtual BOOL UseDecrement() = 0; - virtual BOOL IsPistol() = 0; -public: - int m_iShell; - bool m_bBurstFire; -}; - -class CHEGrenade: public CBasePlayerWeapon { -public: - virtual void Spawn() = 0; - virtual void Precache() = 0; - virtual int GetItemInfo(ItemInfo *p) = 0; - virtual BOOL CanDeploy() = 0; - virtual BOOL CanDrop() = 0; - virtual BOOL Deploy() = 0; - virtual void Holster(int skiplocal) = 0; - virtual float GetMaxSpeed() = 0; - virtual int iItemSlot() = 0; - virtual void PrimaryAttack() = 0; - virtual void SecondaryAttack() = 0; - virtual void WeaponIdle() = 0; - virtual BOOL UseDecrement() = 0; -public: - unsigned short m_usCreateExplosion; -}; - -class CKnife: public CBasePlayerWeapon { -public: - virtual void Spawn() = 0; - virtual void Precache() = 0; - virtual int GetItemInfo(ItemInfo *p) = 0; - virtual BOOL CanDrop() = 0; - virtual BOOL Deploy() = 0; - virtual void Holster(int skiplocal) = 0; - virtual float GetMaxSpeed() = 0; - virtual int iItemSlot() = 0; - virtual void PrimaryAttack() = 0; - virtual void SecondaryAttack() = 0; - virtual BOOL UseDecrement() = 0; - virtual void WeaponIdle() = 0; -public: - TraceResult m_trHit; - unsigned short m_usKnife; -}; - -class CM249: public CBasePlayerWeapon { -public: - virtual void Spawn() = 0; - virtual void Precache() = 0; - virtual int GetItemInfo(ItemInfo *p) = 0; - virtual BOOL Deploy() = 0; - virtual float GetMaxSpeed() = 0; - virtual int iItemSlot() = 0; - virtual void PrimaryAttack() = 0; - virtual void Reload() = 0; - virtual void WeaponIdle() = 0; - virtual BOOL UseDecrement() = 0; -public: - int m_iShell; - int iShellOn; - unsigned short GetEventID() const { return m_usFireM249; } -private: - unsigned short m_usFireM249; -}; - -class CM3: public CBasePlayerWeapon { -public: - virtual void Spawn() = 0; - virtual void Precache() = 0; - virtual int GetItemInfo(ItemInfo *p) = 0; - virtual BOOL Deploy() = 0; - virtual float GetMaxSpeed() = 0; - virtual int iItemSlot() = 0; - virtual void PrimaryAttack() = 0; - virtual void Reload() = 0; - virtual void WeaponIdle() = 0; - virtual BOOL UseDecrement() = 0; -public: - int m_iShell; - float m_flPumpTime; - unsigned short GetEventID() const { return m_usFireM3; } -private: - unsigned short m_usFireM3; -}; - -class CM4A1: public CBasePlayerWeapon { -public: - virtual void Spawn() = 0; - virtual void Precache() = 0; - virtual int GetItemInfo(ItemInfo *p) = 0; - virtual BOOL Deploy() = 0; - virtual float GetMaxSpeed() = 0; - virtual int iItemSlot() = 0; - virtual void PrimaryAttack() = 0; - virtual void SecondaryAttack() = 0; - virtual void Reload() = 0; - virtual void WeaponIdle() = 0; - virtual BOOL UseDecrement() = 0; -public: - int m_iShell; - int iShellOn; - unsigned short GetEventID() const { return m_usFireM4A1; } -private: - unsigned short m_usFireM4A1; -}; - -class CMAC10: public CBasePlayerWeapon { -public: - virtual void Spawn() = 0; - virtual void Precache() = 0; - virtual int GetItemInfo(ItemInfo *p) = 0; - virtual BOOL Deploy() = 0; - virtual float GetMaxSpeed() = 0; - virtual int iItemSlot() = 0; - virtual void PrimaryAttack() = 0; - virtual void Reload() = 0; - virtual void WeaponIdle() = 0; - virtual BOOL UseDecrement() = 0; -public: - int m_iShell; - int iShellOn; - unsigned short GetEventID() const { return m_usFireMAC10; } -private: - unsigned short m_usFireMAC10; -}; - -class CP228: public CBasePlayerWeapon { -public: - virtual void Spawn() = 0; - virtual void Precache() = 0; - virtual int GetItemInfo(ItemInfo *p) = 0; - virtual BOOL Deploy() = 0; - virtual float GetMaxSpeed() = 0; - virtual int iItemSlot() = 0; - virtual void PrimaryAttack() = 0; - virtual void SecondaryAttack() = 0; - virtual void Reload() = 0; - virtual void WeaponIdle() = 0; - virtual BOOL UseDecrement() = 0; - virtual BOOL IsPistol() = 0; -public: - int m_iShell; - unsigned short GetEventID() const { return m_usFireP228; } -private: - unsigned short m_usFireP228; -}; - -class CP90: public CBasePlayerWeapon { -public: - virtual void Spawn() = 0; - virtual void Precache() = 0; - virtual int GetItemInfo(ItemInfo *p) = 0; - virtual BOOL Deploy() = 0; - virtual float GetMaxSpeed() = 0; - virtual int iItemSlot() = 0; - virtual void PrimaryAttack() = 0; - virtual void Reload() = 0; - virtual void WeaponIdle() = 0; - virtual BOOL UseDecrement() = 0; -public: - int m_iShell; - int iShellOn; - unsigned short GetEventID() const { return m_usFireP90; } -private: - unsigned short m_usFireP90; -}; - -class CSCOUT: public CBasePlayerWeapon { -public: - virtual void Spawn() = 0; - virtual void Precache() = 0; - virtual int GetItemInfo(ItemInfo *p) = 0; - virtual BOOL Deploy() = 0; - virtual float GetMaxSpeed() = 0; - virtual int iItemSlot() = 0; - virtual void PrimaryAttack() = 0; - virtual void SecondaryAttack() = 0; - virtual void Reload() = 0; - virtual void WeaponIdle() = 0; - virtual BOOL UseDecrement() = 0; -public: - int m_iShell; - unsigned short GetEventID() const { return m_usFireScout; } -private: - unsigned short m_usFireScout; -}; - -class CSmokeGrenade: public CBasePlayerWeapon { -public: - virtual void Spawn() = 0; - virtual void Precache() = 0; - virtual int GetItemInfo(ItemInfo *p) = 0; - virtual BOOL CanDeploy() = 0; - virtual BOOL CanDrop() = 0; - virtual BOOL Deploy() = 0; - virtual void Holster(int skiplocal) = 0; - virtual float GetMaxSpeed() = 0; - virtual int iItemSlot() = 0; - virtual void PrimaryAttack() = 0; - virtual void SecondaryAttack() = 0; - virtual void WeaponIdle() = 0; - virtual BOOL UseDecrement() = 0; -public: - unsigned short m_usCreateSmoke; -}; - -class CTMP: public CBasePlayerWeapon { -public: - virtual void Spawn() = 0; - virtual void Precache() = 0; - virtual int GetItemInfo(ItemInfo *p) = 0; - virtual BOOL Deploy() = 0; - virtual float GetMaxSpeed() = 0; - virtual int iItemSlot() = 0; - virtual void PrimaryAttack() = 0; - virtual void Reload() = 0; - virtual void WeaponIdle() = 0; - virtual BOOL UseDecrement() = 0; -public: - int m_iShell; - int iShellOn; - unsigned short GetEventID() const { return m_usFireTMP; } -private: - unsigned short m_usFireTMP; -}; - -class CXM1014: public CBasePlayerWeapon { -public: - virtual void Spawn() = 0; - virtual void Precache() = 0; - virtual int GetItemInfo(ItemInfo *p) = 0; - virtual BOOL Deploy() = 0; - virtual float GetMaxSpeed() = 0; - virtual int iItemSlot() = 0; - virtual void PrimaryAttack() = 0; - virtual void Reload() = 0; - virtual void WeaponIdle() = 0; - virtual BOOL UseDecrement() = 0; -public: - int m_iShell; - float m_flPumpTime; - unsigned short GetEventID() const { return m_usFireXM1014; } -private: - unsigned short m_usFireXM1014; -}; - -class CELITE: public CBasePlayerWeapon { -public: - virtual void Spawn() = 0; - virtual void Precache() = 0; - virtual int GetItemInfo(ItemInfo *p) = 0; - virtual BOOL Deploy() = 0; - virtual float GetMaxSpeed() = 0; - virtual int iItemSlot() = 0; - virtual void PrimaryAttack() = 0; - virtual void Reload() = 0; - virtual void WeaponIdle() = 0; - virtual BOOL UseDecrement() = 0; - virtual BOOL IsPistol() = 0; -public: - int m_iShell; - unsigned short GetEventID_Left() const { return m_usFireELITE_LEFT; } - unsigned short GetEventID_Right() const { return m_usFireELITE_RIGHT; } -private: - unsigned short m_usFireELITE_LEFT; - unsigned short m_usFireELITE_RIGHT; -}; - -class CFiveSeven: public CBasePlayerWeapon { -public: - virtual void Spawn() = 0; - virtual void Precache() = 0; - virtual int GetItemInfo(ItemInfo *p) = 0; - virtual BOOL Deploy() = 0; - virtual float GetMaxSpeed() = 0; - virtual int iItemSlot() = 0; - virtual void PrimaryAttack() = 0; - virtual void SecondaryAttack() = 0; - virtual void Reload() = 0; - virtual void WeaponIdle() = 0; - virtual BOOL UseDecrement() = 0; - virtual BOOL IsPistol() = 0; -public: - int m_iShell; - unsigned short GetEventID() const { return m_usFireFiveSeven; } -private: - unsigned short m_usFireFiveSeven; -}; - -class CUMP45: public CBasePlayerWeapon { -public: - virtual void Spawn() = 0; - virtual void Precache() = 0; - virtual int GetItemInfo(ItemInfo *p) = 0; - virtual BOOL Deploy() = 0; - virtual float GetMaxSpeed() = 0; - virtual int iItemSlot() = 0; - virtual void PrimaryAttack() = 0; - virtual void Reload() = 0; - virtual void WeaponIdle() = 0; - virtual BOOL UseDecrement() = 0; -public: - int m_iShell; - int iShellOn; - unsigned short GetEventID() const { return m_usFireUMP45; } -private: - unsigned short m_usFireUMP45; -}; - -class CSG550: public CBasePlayerWeapon { -public: - virtual void Spawn() = 0; - virtual void Precache() = 0; - virtual int GetItemInfo(ItemInfo *p) = 0; - virtual BOOL Deploy() = 0; - virtual float GetMaxSpeed() = 0; - virtual int iItemSlot() = 0; - virtual void PrimaryAttack() = 0; - virtual void SecondaryAttack() = 0; - virtual void Reload() = 0; - virtual void WeaponIdle() = 0; - virtual BOOL UseDecrement() = 0; -public: - int m_iShell; - unsigned short GetEventID() const { return m_usFireSG550; } -private: - unsigned short m_usFireSG550; -}; - -class CGalil: public CBasePlayerWeapon { -public: - virtual void Spawn() = 0; - virtual void Precache() = 0; - virtual int GetItemInfo(ItemInfo *p) = 0; - virtual BOOL Deploy() = 0; - virtual float GetMaxSpeed() = 0; - virtual int iItemSlot() = 0; - virtual void PrimaryAttack() = 0; - virtual void SecondaryAttack() = 0; - virtual void Reload() = 0; - virtual void WeaponIdle() = 0; - virtual BOOL UseDecrement() = 0; -public: - int m_iShell; - int iShellOn; - unsigned short GetEventID() const { return m_usFireGalil; } -private: - unsigned short m_usFireGalil; -}; - -class CFamas: public CBasePlayerWeapon { -public: - virtual void Spawn() = 0; - virtual void Precache() = 0; - virtual int GetItemInfo(ItemInfo *p) = 0; - virtual BOOL Deploy() = 0; - virtual float GetMaxSpeed() = 0; - virtual int iItemSlot() = 0; - virtual void PrimaryAttack() = 0; - virtual void SecondaryAttack() = 0; - virtual void Reload() = 0; - virtual void WeaponIdle() = 0; - virtual BOOL UseDecrement() = 0; -public: - int m_iShell; - int iShellOn; -}; diff --git a/regamedll/extra/cssdk/dlls/weapontype.h b/regamedll/extra/cssdk/dlls/weapontype.h deleted file mode 100644 index 784f8049..00000000 --- a/regamedll/extra/cssdk/dlls/weapontype.h +++ /dev/null @@ -1,417 +0,0 @@ -/* -* -* This program is free software; you can redistribute it and/or modify it -* under the terms of the GNU General Public License as published by the -* Free Software Foundation; either version 2 of the License, or (at -* your option) any later version. -* -* This program 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 -* General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* -*/ -#pragma once - -enum WeaponIdType -{ - WEAPON_NONE, - WEAPON_P228, - WEAPON_GLOCK, - WEAPON_SCOUT, - WEAPON_HEGRENADE, - WEAPON_XM1014, - WEAPON_C4, - WEAPON_MAC10, - WEAPON_AUG, - WEAPON_SMOKEGRENADE, - WEAPON_ELITE, - WEAPON_FIVESEVEN, - WEAPON_UMP45, - WEAPON_SG550, - WEAPON_GALIL, - WEAPON_FAMAS, - WEAPON_USP, - WEAPON_GLOCK18, - WEAPON_AWP, - WEAPON_MP5N, - WEAPON_M249, - WEAPON_M3, - WEAPON_M4A1, - WEAPON_TMP, - WEAPON_G3SG1, - WEAPON_FLASHBANG, - WEAPON_DEAGLE, - WEAPON_SG552, - WEAPON_AK47, - WEAPON_KNIFE, - WEAPON_P90, - WEAPON_SHIELDGUN = 99 -}; - -enum AutoBuyClassType -{ - AUTOBUYCLASS_NONE = 0, - AUTOBUYCLASS_PRIMARY = (1 << 0), - AUTOBUYCLASS_SECONDARY = (1 << 1), - AUTOBUYCLASS_AMMO = (1 << 2), - AUTOBUYCLASS_ARMOR = (1 << 3), - AUTOBUYCLASS_DEFUSER = (1 << 4), - AUTOBUYCLASS_PISTOL = (1 << 5), - AUTOBUYCLASS_SMG = (1 << 6), - AUTOBUYCLASS_RIFLE = (1 << 7), - AUTOBUYCLASS_SNIPERRIFLE = (1 << 8), - AUTOBUYCLASS_SHOTGUN = (1 << 9), - AUTOBUYCLASS_MACHINEGUN = (1 << 10), - AUTOBUYCLASS_GRENADE = (1 << 11), - AUTOBUYCLASS_NIGHTVISION = (1 << 12), - AUTOBUYCLASS_SHIELD = (1 << 13), -}; - -enum AmmoCostType -{ - AMMO_338MAG_PRICE = 125, - AMMO_357SIG_PRICE = 50, - AMMO_45ACP_PRICE = 25, - AMMO_50AE_PRICE = 40, - AMMO_556MM_PRICE = 60, - AMMO_57MM_PRICE = 50, - AMMO_762MM_PRICE = 80, - AMMO_9MM_PRICE = 20, - AMMO_BUCKSHOT_PRICE = 65, -}; - -enum WeaponCostType -{ - AK47_PRICE = 2500, - AWP_PRICE = 4750, - DEAGLE_PRICE = 650, - G3SG1_PRICE = 5000, - SG550_PRICE = 4200, - GLOCK18_PRICE = 400, - M249_PRICE = 5750, - M3_PRICE = 1700, - M4A1_PRICE = 3100, - AUG_PRICE = 3500, - MP5NAVY_PRICE = 1500, - P228_PRICE = 600, - P90_PRICE = 2350, - UMP45_PRICE = 1700, - MAC10_PRICE = 1400, - SCOUT_PRICE = 2750, - SG552_PRICE = 3500, - TMP_PRICE = 1250, - USP_PRICE = 500, - ELITE_PRICE = 800, - FIVESEVEN_PRICE = 750, - XM1014_PRICE = 3000, - GALIL_PRICE = 2000, - FAMAS_PRICE = 2250, - SHIELDGUN_PRICE = 2200, -}; - -enum WeaponState -{ - WPNSTATE_USP_SILENCED = (1 << 0), - WPNSTATE_GLOCK18_BURST_MODE = (1 << 1), - WPNSTATE_M4A1_SILENCED = (1 << 2), - WPNSTATE_ELITE_LEFT = (1 << 3), - WPNSTATE_FAMAS_BURST_MODE = (1 << 4), - WPNSTATE_SHIELD_DRAWN = (1 << 5), -}; - -// custom enum -// the default amount of ammo that comes with each gun when it spawns -enum ClipGiveDefault -{ - P228_DEFAULT_GIVE = 13, - GLOCK18_DEFAULT_GIVE = 20, - SCOUT_DEFAULT_GIVE = 10, - HEGRENADE_DEFAULT_GIVE = 1, - XM1014_DEFAULT_GIVE = 7, - C4_DEFAULT_GIVE = 1, - MAC10_DEFAULT_GIVE = 30, - AUG_DEFAULT_GIVE = 30, - SMOKEGRENADE_DEFAULT_GIVE = 1, - ELITE_DEFAULT_GIVE = 30, - FIVESEVEN_DEFAULT_GIVE = 20, - UMP45_DEFAULT_GIVE = 25, - SG550_DEFAULT_GIVE = 30, - GALIL_DEFAULT_GIVE = 35, - FAMAS_DEFAULT_GIVE = 25, - USP_DEFAULT_GIVE = 12, - AWP_DEFAULT_GIVE = 10, - MP5NAVY_DEFAULT_GIVE = 30, - M249_DEFAULT_GIVE = 100, - M3_DEFAULT_GIVE = 8, - M4A1_DEFAULT_GIVE = 30, - TMP_DEFAULT_GIVE = 30, - G3SG1_DEFAULT_GIVE = 20, - FLASHBANG_DEFAULT_GIVE = 1, - DEAGLE_DEFAULT_GIVE = 7, - SG552_DEFAULT_GIVE = 30, - AK47_DEFAULT_GIVE = 30, - /*KNIFE_DEFAULT_GIVE = 1,*/ - P90_DEFAULT_GIVE = 50, -}; - -enum ClipSizeType -{ - P228_MAX_CLIP = 13, - GLOCK18_MAX_CLIP = 20, - SCOUT_MAX_CLIP = 10, - XM1014_MAX_CLIP = 7, - MAC10_MAX_CLIP = 30, - AUG_MAX_CLIP = 30, - ELITE_MAX_CLIP = 30, - FIVESEVEN_MAX_CLIP = 20, - UMP45_MAX_CLIP = 25, - SG550_MAX_CLIP = 30, - GALIL_MAX_CLIP = 35, - FAMAS_MAX_CLIP = 25, - USP_MAX_CLIP = 12, - AWP_MAX_CLIP = 10, - MP5N_MAX_CLIP = 30, - M249_MAX_CLIP = 100, - M3_MAX_CLIP = 8, - M4A1_MAX_CLIP = 30, - TMP_MAX_CLIP = 30, - G3SG1_MAX_CLIP = 20, - DEAGLE_MAX_CLIP = 7, - SG552_MAX_CLIP = 30, - AK47_MAX_CLIP = 30, - P90_MAX_CLIP = 50, -}; - -enum WeightWeapon -{ - P228_WEIGHT = 5, - GLOCK18_WEIGHT = 5, - SCOUT_WEIGHT = 30, - HEGRENADE_WEIGHT = 2, - XM1014_WEIGHT = 20, - C4_WEIGHT = 3, - MAC10_WEIGHT = 25, - AUG_WEIGHT = 25, - SMOKEGRENADE_WEIGHT = 1, - ELITE_WEIGHT = 5, - FIVESEVEN_WEIGHT = 5, - UMP45_WEIGHT = 25, - SG550_WEIGHT = 20, - GALIL_WEIGHT = 25, - FAMAS_WEIGHT = 75, - USP_WEIGHT = 5, - AWP_WEIGHT = 30, - MP5NAVY_WEIGHT = 25, - M249_WEIGHT = 25, - M3_WEIGHT = 20, - M4A1_WEIGHT = 25, - TMP_WEIGHT = 25, - G3SG1_WEIGHT = 20, - FLASHBANG_WEIGHT = 1, - DEAGLE_WEIGHT = 7, - SG552_WEIGHT = 25, - AK47_WEIGHT = 25, - P90_WEIGHT = 26, - KNIFE_WEIGHT = 0, -}; - -enum MaxAmmoType -{ - MAX_AMMO_BUCKSHOT = 32, - MAX_AMMO_9MM = 120, - MAX_AMMO_556NATO = 90, - MAX_AMMO_556NATOBOX = 200, - MAX_AMMO_762NATO = 90, - MAX_AMMO_45ACP = 100, - MAX_AMMO_50AE = 35, - MAX_AMMO_338MAGNUM = 30, - MAX_AMMO_57MM = 100, - MAX_AMMO_357SIG = 52, - - // custom - MAX_AMMO_SMOKEGRENADE = 1, - MAX_AMMO_HEGRENADE = 1, - MAX_AMMO_FLASHBANG = 2, -}; - -enum AmmoType -{ - AMMO_NONE, - AMMO_338MAGNUM, - AMMO_762NATO, - AMMO_556NATOBOX, - AMMO_556NATO, - AMMO_BUCKSHOT, - AMMO_45ACP, - AMMO_57MM, - AMMO_50AE, - AMMO_357SIG, - AMMO_9MM, - AMMO_FLASHBANG, - AMMO_HEGRENADE, - AMMO_SMOKEGRENADE, - AMMO_C4, - - AMMO_MAX_TYPES -}; - -enum WeaponClassType -{ - WEAPONCLASS_NONE, - WEAPONCLASS_KNIFE, - WEAPONCLASS_PISTOL, - WEAPONCLASS_GRENADE, - WEAPONCLASS_SUBMACHINEGUN, - WEAPONCLASS_SHOTGUN, - WEAPONCLASS_MACHINEGUN, - WEAPONCLASS_RIFLE, - WEAPONCLASS_SNIPERRIFLE, - WEAPONCLASS_MAX, -}; - -enum AmmoBuyAmount -{ - AMMO_338MAG_BUY = 10, - AMMO_357SIG_BUY = 13, - AMMO_45ACP_BUY = 12, - AMMO_50AE_BUY = 7, - AMMO_556NATO_BUY = 30, - AMMO_556NATOBOX_BUY = 30, - AMMO_57MM_BUY = 50, - AMMO_762NATO_BUY = 30, - AMMO_9MM_BUY = 30, - AMMO_BUCKSHOT_BUY = 8, -}; - -enum ItemCostType -{ - ASSAULTSUIT_PRICE = 1000, - FLASHBANG_PRICE = 200, - HEGRENADE_PRICE = 300, - SMOKEGRENADE_PRICE = 300, - KEVLAR_PRICE = 650, - HELMET_PRICE = 350, - NVG_PRICE = 1250, - DEFUSEKIT_PRICE = 200, -}; - -enum shieldgun_e -{ - SHIELDGUN_IDLE, - SHIELDGUN_SHOOT1, - SHIELDGUN_SHOOT2, - SHIELDGUN_SHOOT_EMPTY, - SHIELDGUN_RELOAD, - SHIELDGUN_DRAW, - SHIELDGUN_DRAWN_IDLE, - SHIELDGUN_UP, - SHIELDGUN_DOWN, -}; - -// custom -enum shieldgren_e -{ - SHIELDREN_IDLE = 4, - SHIELDREN_UP, - SHIELDREN_DOWN -}; - -enum InventorySlotType -{ - NONE_SLOT, - PRIMARY_WEAPON_SLOT, - PISTOL_SLOT, - KNIFE_SLOT, - GRENADE_SLOT, - C4_SLOT, -}; - -enum Bullet -{ - BULLET_NONE, - BULLET_PLAYER_9MM, - BULLET_PLAYER_MP5, - BULLET_PLAYER_357, - BULLET_PLAYER_BUCKSHOT, - BULLET_PLAYER_CROWBAR, - BULLET_MONSTER_9MM, - BULLET_MONSTER_MP5, - BULLET_MONSTER_12MM, - BULLET_PLAYER_45ACP, - BULLET_PLAYER_338MAG, - BULLET_PLAYER_762MM, - BULLET_PLAYER_556MM, - BULLET_PLAYER_50AE, - BULLET_PLAYER_57MM, - BULLET_PLAYER_357SIG, -}; - -struct WeaponStruct -{ - int m_type; - int m_price; - int m_side; - int m_slot; - int m_ammoPrice; -}; - -struct AutoBuyInfoStruct -{ - AutoBuyClassType m_class; - char *m_command; - char *m_classname; -}; - -struct WeaponAliasInfo -{ - char *alias; - WeaponIdType id; -}; - -struct WeaponBuyAliasInfo -{ - char *alias; - WeaponIdType id; - char *failName; -}; - -struct WeaponClassAliasInfo -{ - char *alias; - WeaponClassType id; -}; - -struct WeaponInfoStruct -{ - int id; - int cost; - int clipCost; - int buyClipSize; - int gunClipSize; - int maxRounds; - int ammoType; - char *entityName; - const char *ammoName; -}; - -struct WeaponSlotInfo -{ - WeaponIdType id; - InventorySlotType slot; - const char *weaponName; -}; diff --git a/regamedll/extra/cssdk/dlls/wpn_shared.h b/regamedll/extra/cssdk/dlls/wpn_shared.h deleted file mode 100644 index 1ed2eea6..00000000 --- a/regamedll/extra/cssdk/dlls/wpn_shared.h +++ /dev/null @@ -1,598 +0,0 @@ -#pragma once - -//AK47 -#define AK47_MAX_SPEED 221 -#define AK47_DAMAGE 36 -#define AK47_RANGE_MODIFER 0.98 -#define AK47_RELOAD_TIME 2.45 - -enum ak47_e -{ - AK47_IDLE1, - AK47_RELOAD, - AK47_DRAW, - AK47_SHOOT1, - AK47_SHOOT2, - AK47_SHOOT3 -}; - - - -//AUG -#define AUG_MAX_SPEED 240 -#define AUG_DAMAGE 32 -#define AUG_RANGE_MODIFER 0.96 -#define AUG_RELOAD_TIME 3.3 - -enum aug_e -{ - AUG_IDLE1, - AUG_RELOAD, - AUG_DRAW, - AUG_SHOOT1, - AUG_SHOOT2, - AUG_SHOOT3 -}; - - - -//AWP -#define AWP_MAX_SPEED 210 -#define AWP_MAX_SPEED_ZOOM 150 -#define AWP_DAMAGE 115 -#define AWP_RANGE_MODIFER 0.99 -#define AWP_RELOAD_TIME 2.5 - -enum awp_e -{ - AWP_IDLE, - AWP_SHOOT, - AWP_SHOOT2, - AWP_SHOOT3, - AWP_RELOAD, - AWP_DRAW, -}; - - - -//C4 -#define C4_MAX_AMMO 1 -#define C4_MAX_SPEED 250.0 -#define C4_ARMING_ON_TIME 3.0 - -enum c4_e -{ - C4_IDLE1, - C4_DRAW, - C4_DROP, - C4_ARM -}; - - - -//Deagle -#define DEAGLE_MAX_SPEED 250 -#define DEAGLE_DAMAGE 54 -#define DEAGLE_RANGE_MODIFER 0.81 -#define DEAGLE_RELOAD_TIME 2.2 - -enum deagle_e -{ - DEAGLE_IDLE1, - DEAGLE_SHOOT1, - DEAGLE_SHOOT2, - DEAGLE_SHOOT_EMPTY, - DEAGLE_RELOAD, - DEAGLE_DRAW -}; - - - -//Elites -#define ELITE_MAX_SPEED 250 -#define ELITE_RELOAD_TIME 4.5 -#define ELITE_DAMAGE 36 -#define ELITE_RANGE_MODIFER 0.75 - -enum elite_e -{ - ELITE_IDLE, - ELITE_IDLE_LEFTEMPTY, - ELITE_SHOOTLEFT1, - ELITE_SHOOTLEFT2, - ELITE_SHOOTLEFT3, - ELITE_SHOOTLEFT4, - ELITE_SHOOTLEFT5, - ELITE_SHOOTLEFTLAST, - ELITE_SHOOTRIGHT1, - ELITE_SHOOTRIGHT2, - ELITE_SHOOTRIGHT3, - ELITE_SHOOTRIGHT4, - ELITE_SHOOTRIGHT5, - ELITE_SHOOTRIGHTLAST, - ELITE_RELOAD, - ELITE_DRAW -}; - - - -//Famas -#define FAMAS_MAX_SPEED 240 -#define FAMAS_RELOAD_TIME 3.3 -#define FAMAS_DAMAGE 30 -#define FAMAS_DAMAGE_BURST 34 -#define FAMAS_RANGE_MODIFER 0.96 - -enum famas_e -{ - FAMAS_IDLE1, - FAMAS_RELOAD, - FAMAS_DRAW, - FAMAS_SHOOT1, - FAMAS_SHOOT2, - FAMAS_SHOOT3 -}; - - - -//Fiveseven -#define FIVESEVEN_MAX_SPEED 250 -#define FIVESEVEN_DAMAGE 20 -#define FIVESEVEN_RANGE_MODIFER 0.885 -#define FIVESEVEN_RELOAD_TIME 2.7 - -enum fiveseven_e -{ - FIVESEVEN_IDLE, - FIVESEVEN_SHOOT1, - FIVESEVEN_SHOOT2, - FIVESEVEN_SHOOT_EMPTY, - FIVESEVEN_RELOAD, - FIVESEVEN_DRAW -}; - - - -//Flashbang -#define FLASHBANG_MAX_SPEED 250 -#define FLASHBANG_MAX_SPEED_SHIELD 180 - -enum flashbang_e -{ - FLASHBANG_IDLE, - FLASHBANG_PULLPIN, - FLASHBANG_THROW, - FLASHBANG_DRAW -}; - - - -//g3sg1 -#define G3SG1_MAX_SPEED 210 -#define G3SG1_MAX_SPEED_ZOOM 150 -#define G3SG1_DAMAGE 80 -#define G3SG1_RANGE_MODIFER 0.98 -#define G3SG1_RELOAD_TIME 3.5 - -enum g3sg1_e -{ - G3SG1_IDLE, - G3SG1_SHOOT, - G3SG1_SHOOT2, - G3SG1_RELOAD, - G3SG1_DRAW -}; - - - -//galil -#define GALIL_MAX_SPEED 240 -#define GALIL_DAMAGE 30 -#define GALIL_RANGE_MODIFER 0.98 -#define GALIL_RELOAD_TIME 2.45 - -enum galil_e -{ - GALIL_IDLE1, - GALIL_RELOAD, - GALIL_DRAW, - GALIL_SHOOT1, - GALIL_SHOOT2, - GALIL_SHOOT3 -}; - - - -//glock18 -#define GLOCK18_MAX_SPEED 250 -#define GLOCK18_DAMAGE 25 -#define GLOCK18_RANGE_MODIFER 0.75 -#define GLOCK18_RELOAD_TIME 2.2 - -enum glock18_e -{ - GLOCK18_IDLE1, - GLOCK18_IDLE2, - GLOCK18_IDLE3, - GLOCK18_SHOOT, - GLOCK18_SHOOT2, - GLOCK18_SHOOT3, - GLOCK18_SHOOT_EMPTY, - GLOCK18_RELOAD, - GLOCK18_DRAW, - GLOCK18_HOLSTER, - GLOCK18_ADD_SILENCER, - GLOCK18_DRAW2, - GLOCK18_RELOAD2 -}; - -enum glock18_shield_e -{ - GLOCK18_SHIELD_IDLE1, - GLOCK18_SHIELD_SHOOT, - GLOCK18_SHIELD_SHOOT2, - GLOCK18_SHIELD_SHOOT_EMPTY, - GLOCK18_SHIELD_RELOAD, - GLOCK18_SHIELD_DRAW, - GLOCK18_SHIELD_IDLE, - GLOCK18_SHIELD_UP, - GLOCK18_SHIELD_DOWN -}; - - - -//hegrenade -#define HEGRENADE_MAX_SPEED 250 -#define HEGRENADE_MAX_SPEED_SHIELD 180 - -enum hegrenade_e -{ - HEGRENADE_IDLE, - HEGRENADE_PULLPIN, - HEGRENADE_THROW, - HEGRENADE_DRAW -}; - - - -//knife -#define KNIFE_BODYHIT_VOLUME 128 -#define KNIFE_WALLHIT_VOLUME 512 -#define KNIFE_MAX_SPEED 250 -#define KNIFE_MAX_SPEED_SHIELD 180 - -enum knife_e -{ - KNIFE_IDLE, - KNIFE_ATTACK1HIT, - KNIFE_ATTACK2HIT, - KNIFE_DRAW, - KNIFE_STABHIT, - KNIFE_STABMISS, - KNIFE_MIDATTACK1HIT, - KNIFE_MIDATTACK2HIT -}; - -enum knife_shield_e -{ - KNIFE_SHIELD_IDLE, - KNIFE_SHIELD_SLASH, - KNIFE_SHIELD_ATTACKHIT, - KNIFE_SHIELD_DRAW, - KNIFE_SHIELD_UPIDLE, - KNIFE_SHIELD_UP, - KNIFE_SHIELD_DOWN -}; - - - -//m3 -#define M3_MAX_SPEED 230 -#define M3_CONE_VECTOR Vector(0.0675, 0.0675, 0.0) // special shotgun spreads - -enum m3_e -{ - M3_IDLE, - M3_FIRE1, - M3_FIRE2, - M3_RELOAD, - M3_PUMP, - M3_START_RELOAD, - M3_DRAW, - M3_HOLSTER -}; - - - -//m4a1 -#define M4A1_MAX_SPEED 230 -#define M4A1_DAMAGE 32 -#define M4A1_DAMAGE_SIL 33 -#define M4A1_RANGE_MODIFER 0.97 -#define M4A1_RANGE_MODIFER_SIL 0.95 -#define M4A1_RELOAD_TIME 3.05 - -enum m4a1_e -{ - M4A1_IDLE, - M4A1_SHOOT1, - M4A1_SHOOT2, - M4A1_SHOOT3, - M4A1_RELOAD, - M4A1_DRAW, - M4A1_ATTACH_SILENCER, - M4A1_UNSIL_IDLE, - M4A1_UNSIL_SHOOT1, - M4A1_UNSIL_SHOOT2, - M4A1_UNSIL_SHOOT3, - M4A1_UNSIL_RELOAD, - M4A1_UNSIL_DRAW, - M4A1_DETACH_SILENCER -}; - - - -//m249 -#define M249_MAX_SPEED 220 -#define M249_DAMAGE 32 -#define M249_RANGE_MODIFER 0.97 -#define M249_RELOAD_TIME 4.7 - -enum m249_e -{ - M249_IDLE1, - M249_SHOOT1, - M249_SHOOT2, - M249_RELOAD, - M249_DRAW -}; - - - -//mac10 -#define MAC10_MAX_SPEED 250 -#define MAC10_DAMAGE 29 -#define MAC10_RANGE_MODIFER 0.82 -#define MAC10_RELOAD_TIME 3.15 - -enum mac10_e -{ - MAC10_IDLE1, - MAC10_RELOAD, - MAC10_DRAW, - MAC10_SHOOT1, - MAC10_SHOOT2, - MAC10_SHOOT3 -}; - - - -//mp5navy -#define MP5N_MAX_SPEED 250 -#define MP5N_DAMAGE 26 -#define MP5N_RANGE_MODIFER 0.84 -#define MP5N_RELOAD_TIME 2.63 - -enum mp5n_e -{ - MP5N_IDLE1, - MP5N_RELOAD, - MP5N_DRAW, - MP5N_SHOOT1, - MP5N_SHOOT2, - MP5N_SHOOT3 -}; - - - -//p90 -#define P90_MAX_SPEED 245 -#define P90_DAMAGE 21 -#define P90_RANGE_MODIFER 0.885 -#define P90_RELOAD_TIME 3.4 - -enum p90_e -{ - P90_IDLE1, - P90_RELOAD, - P90_DRAW, - P90_SHOOT1, - P90_SHOOT2, - P90_SHOOT3 -}; - - - -//p228 -#define P228_MAX_SPEED 250 -#define P228_DAMAGE 32 -#define P228_RANGE_MODIFER 0.8 -#define P228_RELOAD_TIME 2.7 - -enum p228_e -{ - P228_IDLE, - P228_SHOOT1, - P228_SHOOT2, - P228_SHOOT3, - P228_SHOOT_EMPTY, - P228_RELOAD, - P228_DRAW -}; - -enum p228_shield_e -{ - P228_SHIELD_IDLE, - P228_SHIELD_SHOOT1, - P228_SHIELD_SHOOT2, - P228_SHIELD_SHOOT_EMPTY, - P228_SHIELD_RELOAD, - P228_SHIELD_DRAW, - P228_SHIELD_IDLE_UP, - P228_SHIELD_UP, - P228_SHIELD_DOWN -}; - - - -//scout -#define SCOUT_MAX_SPEED 260 -#define SCOUT_MAX_SPEED_ZOOM 220 -#define SCOUT_DAMAGE 75 -#define SCOUT_RANGE_MODIFER 0.98 -#define SCOUT_RELOAD_TIME 2 - -enum scout_e -{ - SCOUT_IDLE, - SCOUT_SHOOT, - SCOUT_SHOOT2, - SCOUT_RELOAD, - SCOUT_DRAW -}; - - - -//sg550 -#define SG550_MAX_SPEED 210 -#define SG550_MAX_SPEED_ZOOM 150 -#define SG550_DAMAGE 70 -#define SG550_RANGE_MODIFER 0.98 -#define SG550_RELOAD_TIME 3.35 - -enum sg550_e -{ - SG550_IDLE, - SG550_SHOOT, - SG550_SHOOT2, - SG550_RELOAD, - SG550_DRAW -}; - - - -//sg552 -#define SG552_MAX_SPEED 235 -#define SG552_MAX_SPEED_ZOOM 200 -#define SG552_DAMAGE 33 -#define SG552_RANGE_MODIFER 0.955 -#define SG552_RELOAD_TIME 3 - -enum sg552_e -{ - SG552_IDLE1, - SG552_RELOAD, - SG552_DRAW, - SG552_SHOOT1, - SG552_SHOOT2, - SG552_SHOOT3 -}; - - - -//smokegrenade -#define SMOKEGRENADE_MAX_SPEED 250 -#define SMOKEGRENADE_MAX_SPEED_SHIELD 180 - -enum smokegrenade_e -{ - SMOKEGRENADE_IDLE, - SMOKEGRENADE_PINPULL, - SMOKEGRENADE_THROW, - SMOKEGRENADE_DRAW -}; - - - -//tmp -#define TMP_MAX_SPEED 250 -#define TMP_DAMAGE 20 -#define TMP_RANGE_MODIFER 0.85 -#define TMP_RELOAD_TIME 2.12 - -enum tmp_e -{ - TMP_IDLE1, - TMP_RELOAD, - TMP_DRAW, - TMP_SHOOT1, - TMP_SHOOT2, - TMP_SHOOT3 -}; - - - -//ump45 -#define UMP45_MAX_SPEED 250 -#define UMP45_DAMAGE 30 -#define UMP45_RANGE_MODIFER 0.82 -#define UMP45_RELOAD_TIME 3.5 - -enum ump45_e -{ - UMP45_IDLE1, - UMP45_RELOAD, - UMP45_DRAW, - UMP45_SHOOT1, - UMP45_SHOOT2, - UMP45_SHOOT3 -}; - - - -//tmp -#define USP_MAX_SPEED 250 -#define USP_DAMAGE 34 -#define USP_DAMAGE_SIL 30 -#define USP_RANGE_MODIFER 0.79 -#define USP_RELOAD_TIME 2.7 - -enum usp_e -{ - USP_IDLE, - USP_SHOOT1, - USP_SHOOT2, - USP_SHOOT3, - USP_SHOOT_EMPTY, - USP_RELOAD, - USP_DRAW, - USP_ATTACH_SILENCER, - USP_UNSIL_IDLE, - USP_UNSIL_SHOOT1, - USP_UNSIL_SHOOT2, - USP_UNSIL_SHOOT3, - USP_UNSIL_SHOOT_EMPTY, - USP_UNSIL_RELOAD, - USP_UNSIL_DRAW, - USP_DETACH_SILENCER -}; - -enum usp_shield_e -{ - USP_SHIELD_IDLE, - USP_SHIELD_SHOOT1, - USP_SHIELD_SHOOT2, - USP_SHIELD_SHOOT_EMPTY, - USP_SHIELD_RELOAD, - USP_SHIELD_DRAW, - USP_SHIELD_UP_IDLE, - USP_SHIELD_UP, - USP_SHIELD_DOWN -}; - - - -//xm1014 -#define XM1014_MAX_SPEED 240 -#define XM1014_CONE_VECTOR Vector(0.0725, 0.0725, 0.0) // special shotgun spreads - -enum xm1014_e -{ - XM1014_IDLE, - XM1014_FIRE1, - XM1014_FIRE2, - XM1014_RELOAD, - XM1014_PUMP, - XM1014_START_RELOAD, - XM1014_DRAW -}; diff --git a/regamedll/extra/cssdk/engine/FlightRecorder.h b/regamedll/extra/cssdk/engine/FlightRecorder.h deleted file mode 100644 index 66a6477c..00000000 --- a/regamedll/extra/cssdk/engine/FlightRecorder.h +++ /dev/null @@ -1,61 +0,0 @@ -/* -* -* This program is free software; you can redistribute it and/or modify it -* under the terms of the GNU General Public License as published by the -* Free Software Foundation; either version 2 of the License, or (at -* your option) any later version. -* -* This program 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 -* General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* -*/ -#pragma once - -#include "archtypes.h" - -class IRehldsFlightRecorder -{ -public: - virtual ~IRehldsFlightRecorder() { } - - virtual uint16 RegisterMessage(const char* module, const char *message, unsigned int version, bool inOut) = 0; - - virtual void StartMessage(uint16 msg, bool entrance) = 0; - virtual void EndMessage(uint16 msg, bool entrance) = 0; - - virtual void WriteInt8(int8 v) = 0; - virtual void WriteUInt8(uint8 v) = 0; - - virtual void WriteInt16(int16 v) = 0; - virtual void WriteUInt16(uint16 v) = 0; - - virtual void WriteInt32(int32 v) = 0; - virtual void WriteUInt32(uint32 v) = 0; - - virtual void WriteInt64(int64 v) = 0; - virtual void WriteUInt64(uint64 v) = 0; - - virtual void WriteFloat(float v) = 0; - virtual void WriteDouble(double v) = 0; - - virtual void WriteString(const char* s) = 0; - - virtual void WriteBuffer(const void* data ,unsigned int len) = 0; - -}; diff --git a/regamedll/extra/cssdk/engine/Sequence.h b/regamedll/extra/cssdk/engine/Sequence.h deleted file mode 100644 index 62530183..00000000 --- a/regamedll/extra/cssdk/engine/Sequence.h +++ /dev/null @@ -1,201 +0,0 @@ -//--------------------------------------------------------------------------- -// -// S c r i p t e d S e q u e n c e s -// -//--------------------------------------------------------------------------- -#ifndef _INCLUDE_SEQUENCE_H_ -#define _INCLUDE_SEQUENCE_H_ - - -#ifndef _DEF_BYTE_ -typedef unsigned char byte; -#endif - -//--------------------------------------------------------------------------- -// client_textmessage_t -//--------------------------------------------------------------------------- -typedef struct client_textmessage_s -{ - int effect; - byte r1, g1, b1, a1; // 2 colors for effects - byte r2, g2, b2, a2; - float x; - float y; - float fadein; - float fadeout; - float holdtime; - float fxtime; - const char *pName; - const char *pMessage; -} client_textmessage_t; - - -//-------------------------------------------------------------------------- -// sequenceDefaultBits_e -// -// Enumerated list of possible modifiers for a command. This enumeration -// is used in a bitarray controlling what modifiers are specified for a command. -//--------------------------------------------------------------------------- -enum sequenceModifierBits -{ - SEQUENCE_MODIFIER_EFFECT_BIT = (1 << 1), - SEQUENCE_MODIFIER_POSITION_BIT = (1 << 2), - SEQUENCE_MODIFIER_COLOR_BIT = (1 << 3), - SEQUENCE_MODIFIER_COLOR2_BIT = (1 << 4), - SEQUENCE_MODIFIER_FADEIN_BIT = (1 << 5), - SEQUENCE_MODIFIER_FADEOUT_BIT = (1 << 6), - SEQUENCE_MODIFIER_HOLDTIME_BIT = (1 << 7), - SEQUENCE_MODIFIER_FXTIME_BIT = (1 << 8), - SEQUENCE_MODIFIER_SPEAKER_BIT = (1 << 9), - SEQUENCE_MODIFIER_LISTENER_BIT = (1 << 10), - SEQUENCE_MODIFIER_TEXTCHANNEL_BIT = (1 << 11), -}; -typedef enum sequenceModifierBits sequenceModifierBits_e ; - - -//--------------------------------------------------------------------------- -// sequenceCommandEnum_e -// -// Enumerated sequence command types. -//--------------------------------------------------------------------------- -enum sequenceCommandEnum_ -{ - SEQUENCE_COMMAND_ERROR = -1, - SEQUENCE_COMMAND_PAUSE = 0, - SEQUENCE_COMMAND_FIRETARGETS, - SEQUENCE_COMMAND_KILLTARGETS, - SEQUENCE_COMMAND_TEXT, - SEQUENCE_COMMAND_SOUND, - SEQUENCE_COMMAND_GOSUB, - SEQUENCE_COMMAND_SENTENCE, - SEQUENCE_COMMAND_REPEAT, - SEQUENCE_COMMAND_SETDEFAULTS, - SEQUENCE_COMMAND_MODIFIER, - SEQUENCE_COMMAND_POSTMODIFIER, - SEQUENCE_COMMAND_NOOP, - - SEQUENCE_MODIFIER_EFFECT, - SEQUENCE_MODIFIER_POSITION, - SEQUENCE_MODIFIER_COLOR, - SEQUENCE_MODIFIER_COLOR2, - SEQUENCE_MODIFIER_FADEIN, - SEQUENCE_MODIFIER_FADEOUT, - SEQUENCE_MODIFIER_HOLDTIME, - SEQUENCE_MODIFIER_FXTIME, - SEQUENCE_MODIFIER_SPEAKER, - SEQUENCE_MODIFIER_LISTENER, - SEQUENCE_MODIFIER_TEXTCHANNEL, -}; -typedef enum sequenceCommandEnum_ sequenceCommandEnum_e; - - -//--------------------------------------------------------------------------- -// sequenceCommandType_e -// -// Typeerated sequence command types. -//--------------------------------------------------------------------------- -enum sequenceCommandType_ -{ - SEQUENCE_TYPE_COMMAND, - SEQUENCE_TYPE_MODIFIER, -}; -typedef enum sequenceCommandType_ sequenceCommandType_e; - - -//--------------------------------------------------------------------------- -// sequenceCommandMapping_s -// -// A mapping of a command enumerated-value to its name. -//--------------------------------------------------------------------------- -typedef struct sequenceCommandMapping_ sequenceCommandMapping_s; -struct sequenceCommandMapping_ -{ - sequenceCommandEnum_e commandEnum; - const char* commandName; - sequenceCommandType_e commandType; -}; - - -//--------------------------------------------------------------------------- -// sequenceCommandLine_s -// -// Structure representing a single command (usually 1 line) from a -// .SEQ file entry. -//--------------------------------------------------------------------------- -typedef struct sequenceCommandLine_ sequenceCommandLine_s; -struct sequenceCommandLine_ -{ - int commandType; // Specifies the type of command - client_textmessage_t clientMessage; // Text HUD message struct - char* speakerName; // Targetname of speaking entity - char* listenerName; // Targetname of entity being spoken to - char* soundFileName; // Name of sound file to play - char* sentenceName; // Name of sentences.txt to play - char* fireTargetNames; // List of targetnames to fire - char* killTargetNames; // List of targetnames to remove - float delay; // Seconds 'till next command - int repeatCount; // If nonzero, reset execution pointer to top of block (N times, -1 = infinite) - int textChannel; // Display channel on which text message is sent - int modifierBitField; // Bit field to specify what clientmessage fields are valid - sequenceCommandLine_s* nextCommandLine; // Next command (linked list) -}; - - -//--------------------------------------------------------------------------- -// sequenceEntry_s -// -// Structure representing a single command (usually 1 line) from a -// .SEQ file entry. -//--------------------------------------------------------------------------- -typedef struct sequenceEntry_ sequenceEntry_s; -struct sequenceEntry_ -{ - char* fileName; // Name of sequence file without .SEQ extension - char* entryName; // Name of entry label in file - sequenceCommandLine_s* firstCommand; // Linked list of commands in entry - sequenceEntry_s* nextEntry; // Next loaded entry - qboolean isGlobal; // Is entry retained over level transitions? -}; - - - -//--------------------------------------------------------------------------- -// sentenceEntry_s -// Structure representing a single sentence of a group from a .SEQ -// file entry. Sentences are identical to entries in sentences.txt, but -// can be unique per level and are loaded/unloaded with the level. -//--------------------------------------------------------------------------- -typedef struct sentenceEntry_ sentenceEntry_s; -struct sentenceEntry_ -{ - char* data; // sentence data (ie "We have hostiles" ) - sentenceEntry_s* nextEntry; // Next loaded entry - qboolean isGlobal; // Is entry retained over level transitions? - unsigned int index; // this entry's position in the file. -}; - -//-------------------------------------------------------------------------- -// sentenceGroupEntry_s -// Structure representing a group of sentences found in a .SEQ file. -// A sentence group is defined by all sentences with the same name, ignoring -// the number at the end of the sentence name. Groups enable a sentence -// to be picked at random across a group. -//-------------------------------------------------------------------------- -typedef struct sentenceGroupEntry_ sentenceGroupEntry_s; -struct sentenceGroupEntry_ -{ - char* groupName; // name of the group (ie CT_ALERT ) - unsigned int numSentences; // number of sentences in group - sentenceEntry_s* firstSentence; // head of linked list of sentences in group - sentenceGroupEntry_s* nextEntry; // next loaded group -}; - -//--------------------------------------------------------------------------- -// Function declarations -//--------------------------------------------------------------------------- -sequenceEntry_s* SequenceGet( const char* fileName, const char* entryName ); -void Sequence_ParseFile( const char* fileName, qboolean isGlobal ); -void Sequence_OnLevelLoad( const char* mapName ); -sentenceEntry_s* SequencePickSentence( const char *groupName, int pickMethod, int *picked ); - -#endif /* _INCLUDE_SEQUENCE_H_ */ diff --git a/regamedll/extra/cssdk/engine/archtypes.h b/regamedll/extra/cssdk/engine/archtypes.h deleted file mode 100644 index e528a6d6..00000000 --- a/regamedll/extra/cssdk/engine/archtypes.h +++ /dev/null @@ -1,66 +0,0 @@ -/* -* -* This program is free software; you can redistribute it and/or modify it -* under the terms of the GNU General Public License as published by the -* Free Software Foundation; either version 2 of the License, or (at -* your option) any later version. -* -* This program 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 -* General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* -*/#ifndef ARCHTYPES_H -#define ARCHTYPES_H - -#ifdef __x86_64__ -#define X64BITS -#endif - -#if defined( _WIN32 ) && (! defined( __MINGW32__ )) - -typedef __int8 int8; -typedef unsigned __int8 uint8; -typedef __int16 int16; -typedef unsigned __int16 uint16; -typedef __int32 int32; -typedef unsigned __int32 uint32; -typedef __int64 int64; -typedef unsigned __int64 uint64; -typedef __int32 intp; // intp is an integer that can accomodate a pointer -typedef unsigned __int32 uintp; // (ie, sizeof(intp) >= sizeof(int) && sizeof(intp) >= sizeof(void *) - -#else /* _WIN32 */ -typedef char int8; -typedef unsigned char uint8; -typedef short int16; -typedef unsigned short uint16; -typedef int int32; -typedef unsigned int uint32; -typedef long long int64; -typedef unsigned long long uint64; -#ifdef X64BITS -typedef long long intp; -typedef unsigned long long uintp; -#else -typedef int intp; -typedef unsigned int uintp; -#endif - -#endif /* else _WIN32 */ - -#endif /* ARCHTYPES_H */ diff --git a/regamedll/extra/cssdk/engine/bspfile.h b/regamedll/extra/cssdk/engine/bspfile.h deleted file mode 100644 index b6d498c7..00000000 --- a/regamedll/extra/cssdk/engine/bspfile.h +++ /dev/null @@ -1,160 +0,0 @@ -/* -* -* This program is free software; you can redistribute it and/or modify it -* under the terms of the GNU General Public License as published by the -* Free Software Foundation; either version 2 of the License, or (at -* your option) any later version. -* -* This program 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 -* General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* -*/ -#pragma once - -// header -#define Q1BSP_VERSION 29 // quake1 regular version (beta is 28) -#define HLBSP_VERSION 30 // half-life regular version - -#define MAX_MAP_HULLS 4 - -#define CONTENTS_ORIGIN -7 // removed at csg time -#define CONTENTS_CLIP -8 // changed to contents_solid -#define CONTENTS_CURRENT_0 -9 -#define CONTENTS_CURRENT_90 -10 -#define CONTENTS_CURRENT_180 -11 -#define CONTENTS_CURRENT_270 -12 -#define CONTENTS_CURRENT_UP -13 -#define CONTENTS_CURRENT_DOWN -14 - -#define CONTENTS_TRANSLUCENT -15 - -#define LUMP_ENTITIES 0 -#define LUMP_PLANES 1 -#define LUMP_TEXTURES 2 -#define LUMP_VERTEXES 3 -#define LUMP_VISIBILITY 4 -#define LUMP_NODES 5 -#define LUMP_TEXINFO 6 -#define LUMP_FACES 7 -#define LUMP_LIGHTING 8 -#define LUMP_CLIPNODES 9 -#define LUMP_LEAFS 10 -#define LUMP_MARKSURFACES 11 -#define LUMP_EDGES 12 -#define LUMP_SURFEDGES 13 -#define LUMP_MODELS 14 - -#define HEADER_LUMPS 15 - -typedef struct lump_s -{ - int fileofs; - int filelen; -} lump_t; - -typedef struct dmodel_s -{ - float mins[3], maxs[3]; - float origin[3]; - int headnode[MAX_MAP_HULLS]; - int visleafs; // not including the solid leaf 0 - int firstface, numfaces; -} dmodel_t; - -typedef struct dheader_s -{ - int version; - lump_t lumps[15]; -} dheader_t; - -typedef struct dmiptexlump_s -{ - int _nummiptex; - int dataofs[4]; -} dmiptexlump_t; - -typedef struct miptex_s -{ - char name[16]; - unsigned width; - unsigned height; - unsigned offsets[4]; -} miptex_t; - -typedef struct dvertex_s -{ - float point[3]; -} dvertex_t; - -typedef struct dplane_s -{ - float normal[3]; - float dist; - int type; -} dplane_t; - -typedef struct dnode_s -{ - int planenum; - short children[2]; - short mins[3]; - short maxs[3]; - unsigned short firstface; - unsigned short numfaces; -} dnode_t; - -typedef struct dclipnode_s -{ - int planenum; - short children[2]; // negative numbers are contents -} dclipnode_t; - -typedef struct texinfo_s -{ - float vecs[2][4]; - int _miptex; - int flags; -} texinfo_t; - -typedef struct dedge_s -{ - unsigned short v[2]; -} dedge_t; - -typedef struct dface_s -{ - short planenum; - short side; - int firstedge; - short numedges; - short texinfo; - byte styles[4]; - int lightofs; -} dface_t; - -typedef struct dleaf_s -{ - int contents; - int visofs; - short mins[3]; - short maxs[3]; - unsigned short firstmarksurface; - unsigned short nummarksurfaces; - byte ambient_level[4]; -} dleaf_t; diff --git a/regamedll/extra/cssdk/engine/cmd_rehlds.h b/regamedll/extra/cssdk/engine/cmd_rehlds.h deleted file mode 100644 index efa8393d..00000000 --- a/regamedll/extra/cssdk/engine/cmd_rehlds.h +++ /dev/null @@ -1,49 +0,0 @@ -/* -* -* This program is free software; you can redistribute it and/or modify it -* under the terms of the GNU General Public License as published by the -* Free Software Foundation; either version 2 of the License, or (at -* your option) any later version. -* -* This program 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 -* General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* -*/ -#pragma once - -#include "archtypes.h" - -typedef void(*xcommand_t)(void); -typedef struct cmd_function_s -{ - struct cmd_function_s *next; - char *name; - xcommand_t function; - int flags; -} cmd_function_t; - -typedef enum cmd_source_s -{ - src_client = 0, // came in over a net connection as a clc_stringcmd. host_client will be valid during this state. - src_command = 1, // from the command buffer. -} cmd_source_t; - -#define FCMD_HUD_COMMAND BIT(0) -#define FCMD_GAME_COMMAND BIT(1) -#define FCMD_WRAPPER_COMMAND BIT(2) diff --git a/regamedll/extra/cssdk/engine/common_rehlds.h b/regamedll/extra/cssdk/engine/common_rehlds.h deleted file mode 100644 index 64a5d184..00000000 --- a/regamedll/extra/cssdk/engine/common_rehlds.h +++ /dev/null @@ -1,78 +0,0 @@ -/* -* -* This program is free software; you can redistribute it and/or modify it -* under the terms of the GNU General Public License as published by the -* Free Software Foundation; either version 2 of the License, or (at -* your option) any later version. -* -* This program 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 -* General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* -*/ -#pragma once - -#include "const.h" -#include "qlimits.h" - -#ifdef REHLDS_FIXES -#define COM_TOKEN_LEN 2048 -#else -#define COM_TOKEN_LEN 1024 -#endif - -// Don't allow overflow -#define SIZEBUF_CHECK_OVERFLOW 0 -#define SIZEBUF_ALLOW_OVERFLOW BIT(0) -#define SIZEBUF_OVERFLOWED BIT(1) - -#define MAX_NUM_ARGVS 50 -#define NUM_SAFE_ARGVS 7 - -#define COM_COPY_CHUNK_SIZE 1024 -#define COM_MAX_CMD_LINE 256 - -typedef struct sizebuf_s -{ - const char *buffername; - uint16 flags; - byte *data; - int maxsize; - int cursize; -} sizebuf_t; - -typedef struct downloadtime_s -{ - qboolean bUsed; - float fTime; - int nBytesRemaining; -} downloadtime_t; - -typedef struct incomingtransfer_s -{ - qboolean doneregistering; - int percent; - qboolean downloadrequested; - downloadtime_t rgStats[8]; - int nCurStat; - int nTotalSize; - int nTotalToTransfer; - int nRemainingToTransfer; - float fLastStatusUpdate; - qboolean custom; -} incomingtransfer_t; diff --git a/regamedll/extra/cssdk/engine/crc32c.cpp b/regamedll/extra/cssdk/engine/crc32c.cpp deleted file mode 100644 index 1220c507..00000000 --- a/regamedll/extra/cssdk/engine/crc32c.cpp +++ /dev/null @@ -1,143 +0,0 @@ -/* -Copyright (C) 2010 by Ronnie Sahlberg -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU Lesser 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 program 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 Lesser General Public License for more details. -You should have received a copy of the GNU Lesser General Public License -along with this program; if not, see . -*/ - -#include "crc32c.h" -#include "sys_shared.h" -#include "immintrin.h" - -/*****************************************************************/ -/* */ -/* CRC LOOKUP TABLE */ -/* ================ */ -/* The following CRC lookup table was generated automagically */ -/* by the Rocksoft^tm Model CRC Algorithm Table Generation */ -/* Program V1.0 using the following model parameters: */ -/* */ -/* Width : 4 bytes. */ -/* Poly : 0x1EDC6F41L */ -/* Reverse : TRUE. */ -/* */ -/* For more information on the Rocksoft^tm Model CRC Algorithm, */ -/* see the document titled "A Painless Guide to CRC Error */ -/* Detection Algorithms" by Ross Williams */ -/* (ross@guest.adelaide.edu.au.). This document is likely to be */ -/* in the FTP archive "ftp.adelaide.edu.au/pub/rocksoft". */ -/* */ -/*****************************************************************/ - -static uint32 crctable[256] = { - 0x00000000L, 0xF26B8303L, 0xE13B70F7L, 0x1350F3F4L, - 0xC79A971FL, 0x35F1141CL, 0x26A1E7E8L, 0xD4CA64EBL, - 0x8AD958CFL, 0x78B2DBCCL, 0x6BE22838L, 0x9989AB3BL, - 0x4D43CFD0L, 0xBF284CD3L, 0xAC78BF27L, 0x5E133C24L, - 0x105EC76FL, 0xE235446CL, 0xF165B798L, 0x030E349BL, - 0xD7C45070L, 0x25AFD373L, 0x36FF2087L, 0xC494A384L, - 0x9A879FA0L, 0x68EC1CA3L, 0x7BBCEF57L, 0x89D76C54L, - 0x5D1D08BFL, 0xAF768BBCL, 0xBC267848L, 0x4E4DFB4BL, - 0x20BD8EDEL, 0xD2D60DDDL, 0xC186FE29L, 0x33ED7D2AL, - 0xE72719C1L, 0x154C9AC2L, 0x061C6936L, 0xF477EA35L, - 0xAA64D611L, 0x580F5512L, 0x4B5FA6E6L, 0xB93425E5L, - 0x6DFE410EL, 0x9F95C20DL, 0x8CC531F9L, 0x7EAEB2FAL, - 0x30E349B1L, 0xC288CAB2L, 0xD1D83946L, 0x23B3BA45L, - 0xF779DEAEL, 0x05125DADL, 0x1642AE59L, 0xE4292D5AL, - 0xBA3A117EL, 0x4851927DL, 0x5B016189L, 0xA96AE28AL, - 0x7DA08661L, 0x8FCB0562L, 0x9C9BF696L, 0x6EF07595L, - 0x417B1DBCL, 0xB3109EBFL, 0xA0406D4BL, 0x522BEE48L, - 0x86E18AA3L, 0x748A09A0L, 0x67DAFA54L, 0x95B17957L, - 0xCBA24573L, 0x39C9C670L, 0x2A993584L, 0xD8F2B687L, - 0x0C38D26CL, 0xFE53516FL, 0xED03A29BL, 0x1F682198L, - 0x5125DAD3L, 0xA34E59D0L, 0xB01EAA24L, 0x42752927L, - 0x96BF4DCCL, 0x64D4CECFL, 0x77843D3BL, 0x85EFBE38L, - 0xDBFC821CL, 0x2997011FL, 0x3AC7F2EBL, 0xC8AC71E8L, - 0x1C661503L, 0xEE0D9600L, 0xFD5D65F4L, 0x0F36E6F7L, - 0x61C69362L, 0x93AD1061L, 0x80FDE395L, 0x72966096L, - 0xA65C047DL, 0x5437877EL, 0x4767748AL, 0xB50CF789L, - 0xEB1FCBADL, 0x197448AEL, 0x0A24BB5AL, 0xF84F3859L, - 0x2C855CB2L, 0xDEEEDFB1L, 0xCDBE2C45L, 0x3FD5AF46L, - 0x7198540DL, 0x83F3D70EL, 0x90A324FAL, 0x62C8A7F9L, - 0xB602C312L, 0x44694011L, 0x5739B3E5L, 0xA55230E6L, - 0xFB410CC2L, 0x092A8FC1L, 0x1A7A7C35L, 0xE811FF36L, - 0x3CDB9BDDL, 0xCEB018DEL, 0xDDE0EB2AL, 0x2F8B6829L, - 0x82F63B78L, 0x709DB87BL, 0x63CD4B8FL, 0x91A6C88CL, - 0x456CAC67L, 0xB7072F64L, 0xA457DC90L, 0x563C5F93L, - 0x082F63B7L, 0xFA44E0B4L, 0xE9141340L, 0x1B7F9043L, - 0xCFB5F4A8L, 0x3DDE77ABL, 0x2E8E845FL, 0xDCE5075CL, - 0x92A8FC17L, 0x60C37F14L, 0x73938CE0L, 0x81F80FE3L, - 0x55326B08L, 0xA759E80BL, 0xB4091BFFL, 0x466298FCL, - 0x1871A4D8L, 0xEA1A27DBL, 0xF94AD42FL, 0x0B21572CL, - 0xDFEB33C7L, 0x2D80B0C4L, 0x3ED04330L, 0xCCBBC033L, - 0xA24BB5A6L, 0x502036A5L, 0x4370C551L, 0xB11B4652L, - 0x65D122B9L, 0x97BAA1BAL, 0x84EA524EL, 0x7681D14DL, - 0x2892ED69L, 0xDAF96E6AL, 0xC9A99D9EL, 0x3BC21E9DL, - 0xEF087A76L, 0x1D63F975L, 0x0E330A81L, 0xFC588982L, - 0xB21572C9L, 0x407EF1CAL, 0x532E023EL, 0xA145813DL, - 0x758FE5D6L, 0x87E466D5L, 0x94B49521L, 0x66DF1622L, - 0x38CC2A06L, 0xCAA7A905L, 0xD9F75AF1L, 0x2B9CD9F2L, - 0xFF56BD19L, 0x0D3D3E1AL, 0x1E6DCDEEL, 0xEC064EEDL, - 0xC38D26C4L, 0x31E6A5C7L, 0x22B65633L, 0xD0DDD530L, - 0x0417B1DBL, 0xF67C32D8L, 0xE52CC12CL, 0x1747422FL, - 0x49547E0BL, 0xBB3FFD08L, 0xA86F0EFCL, 0x5A048DFFL, - 0x8ECEE914L, 0x7CA56A17L, 0x6FF599E3L, 0x9D9E1AE0L, - 0xD3D3E1ABL, 0x21B862A8L, 0x32E8915CL, 0xC083125FL, - 0x144976B4L, 0xE622F5B7L, 0xF5720643L, 0x07198540L, - 0x590AB964L, 0xAB613A67L, 0xB831C993L, 0x4A5A4A90L, - 0x9E902E7BL, 0x6CFBAD78L, 0x7FAB5E8CL, 0x8DC0DD8FL, - 0xE330A81AL, 0x115B2B19L, 0x020BD8EDL, 0xF0605BEEL, - 0x24AA3F05L, 0xD6C1BC06L, 0xC5914FF2L, 0x37FACCF1L, - 0x69E9F0D5L, 0x9B8273D6L, 0x88D28022L, 0x7AB90321L, - 0xAE7367CAL, 0x5C18E4C9L, 0x4F48173DL, 0xBD23943EL, - 0xF36E6F75L, 0x0105EC76L, 0x12551F82L, 0xE03E9C81L, - 0x34F4F86AL, 0xC69F7B69L, 0xD5CF889DL, 0x27A40B9EL, - 0x79B737BAL, 0x8BDCB4B9L, 0x988C474DL, 0x6AE7C44EL, - 0xBE2DA0A5L, 0x4C4623A6L, 0x5F16D052L, 0xAD7D5351L -}; - -uint32 crc32c_t8_nosse(uint32 iCRC, uint8 u8) { - return (iCRC >> 8) ^ crctable[(iCRC ^ u8) & 0xFF]; -} - -uint32 crc32c_t_nosse(uint32 iCRC, const uint8 *buf, int len) { - uint32 crc = iCRC; - while (len-- > 0) { - crc = (crc >> 8) ^ crctable[(crc ^ (*buf++)) & 0xFF]; - } - return crc; -} - -uint32 crc32c_t8_sse(uint32 iCRC, uint8 u8) { - return _mm_crc32_u8(iCRC, u8); -} - -uint32 crc32c_t_sse(uint32 iCRC, const uint8 *buf, unsigned int len) { - uint32 crc32cval = iCRC; - unsigned int i = 0; - - for (; i < (len >> 2); i += 4) { - crc32cval = _mm_crc32_u32(crc32cval, *(uint32*)&buf[i]); - } - - for (; i < len; i++) { - crc32cval = _mm_crc32_u8(crc32cval, buf[i]); - } - - return crc32cval; -} - -uint32 crc32c_t(uint32 iCRC, const uint8 *buf, unsigned int len) { - return cpuinfo.sse4_2 ? crc32c_t_sse(iCRC, buf, len) : crc32c_t_nosse(iCRC, buf, len); -} - -uint32 crc32c(const uint8 *buf, int len) { - return crc32c_t(0xffffffff, buf, len); -} diff --git a/regamedll/extra/cssdk/engine/crc32c.h b/regamedll/extra/cssdk/engine/crc32c.h deleted file mode 100644 index 892919be..00000000 --- a/regamedll/extra/cssdk/engine/crc32c.h +++ /dev/null @@ -1,22 +0,0 @@ -/* -Copyright (C) 2010 by Ronnie Sahlberg -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU Lesser 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 program 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 Lesser General Public License for more details. -You should have received a copy of the GNU Lesser General Public License -along with this program; if not, see . -*/ -#pragma once -#include "archtypes.h" - -extern uint32 crc32c_t8_nosse(uint32 iCRC, uint8 u8); -extern uint32 crc32c_t8_sse(uint32 iCRC, uint8 u8); -extern uint32 crc32c_t_nosse(uint32 iCRC, const uint8 *buf, int len); -extern uint32 crc32c_t_sse(uint32 iCRC, const uint8 *buf, unsigned int len); -extern uint32 crc32c_t(uint32 iCRC, const uint8 *buf, unsigned int len); -extern uint32 crc32c(const uint8 *buf, int len); diff --git a/regamedll/extra/cssdk/engine/custom.h b/regamedll/extra/cssdk/engine/custom.h deleted file mode 100644 index 5a5156e6..00000000 --- a/regamedll/extra/cssdk/engine/custom.h +++ /dev/null @@ -1,96 +0,0 @@ -/*** -* -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ -// Customization.h -#pragma once - -#include "const.h" - -#define MAX_QPATH 64 // Must match value in quakedefs.h -#define MAX_RESOURCE_LIST 1280 - -///////////////// -// Customization -// passed to pfnPlayerCustomization -// For automatic downloading. -typedef enum -{ - t_sound = 0, - t_skin, - t_model, - t_decal, - t_generic, - t_eventscript, - t_world, // Fake type for world, is really t_model - rt_unk, - - rt_max -} resourcetype_t; - - -typedef struct -{ - int size; -} _resourceinfo_t; - -typedef struct resourceinfo_s -{ - _resourceinfo_t info[ rt_max ]; -} resourceinfo_t; - -#define RES_FATALIFMISSING (1<<0) // Disconnect if we can't get this file. -#define RES_WASMISSING (1<<1) // Do we have the file locally, did we get it ok? -#define RES_CUSTOM (1<<2) // Is this resource one that corresponds to another player's customization - // or is it a server startup resource. -#define RES_REQUESTED (1<<3) // Already requested a download of this one -#define RES_PRECACHED (1<<4) // Already precached -#define RES_ALWAYS (1<<5) // download always even if available on client -#define RES_UNK_6 (1<<6) // TODO: what is it? -#define RES_CHECKFILE (1<<7) // check file on client - -#include "crc.h" - -typedef struct resource_s -{ - char szFileName[MAX_QPATH]; // File name to download/precache. - resourcetype_t type; // t_sound, t_skin, t_model, t_decal. - int nIndex; // For t_decals - int nDownloadSize; // Size in Bytes if this must be downloaded. - unsigned char ucFlags; - -// For handling client to client resource propagation - unsigned char rgucMD5_hash[16]; // To determine if we already have it. - unsigned char playernum; // Which player index this resource is associated with, if it's a custom resource. - - unsigned char rguc_reserved[ 32 ]; // For future expansion - struct resource_s *pNext; // Next in chain. - struct resource_s *pPrev; -} resource_t; - -typedef struct customization_s -{ - qboolean bInUse; // Is this customization in use; - resource_t resource; // The resource_t for this customization - qboolean bTranslated; // Has the raw data been translated into a useable format? - // (e.g., raw decal .wad make into texture_t *) - int nUserData1; // Customization specific data - int nUserData2; // Customization specific data - void *pInfo; // Buffer that holds the data structure that references the data (e.g., the cachewad_t) - void *pBuffer; // Buffer that holds the data for the customization (the raw .wad data) - struct customization_s *pNext; // Next in chain -} customization_t; - -#define FCUST_FROMHPAK ( 1<<0 ) -#define FCUST_WIPEDATA ( 1<<1 ) -#define FCUST_IGNOREINIT ( 1<<2 ) diff --git a/regamedll/extra/cssdk/engine/customentity.h b/regamedll/extra/cssdk/engine/customentity.h deleted file mode 100644 index 0895bee6..00000000 --- a/regamedll/extra/cssdk/engine/customentity.h +++ /dev/null @@ -1,38 +0,0 @@ -/*** -* -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ -#ifndef CUSTOMENTITY_H -#define CUSTOMENTITY_H - -// Custom Entities - -// Start/End Entity is encoded as 12 bits of entity index, and 4 bits of attachment (4:12) -#define BEAMENT_ENTITY(x) ((x)&0xFFF) -#define BEAMENT_ATTACHMENT(x) (((x)>>12)&0xF) - -// Beam types, encoded as a byte -enum -{ - BEAM_POINTS = 0, - BEAM_ENTPOINT, - BEAM_ENTS, - BEAM_HOSE, -}; - -#define BEAM_FSINE 0x10 -#define BEAM_FSOLID 0x20 -#define BEAM_FSHADEIN 0x40 -#define BEAM_FSHADEOUT 0x80 - -#endif //CUSTOMENTITY_H diff --git a/regamedll/extra/cssdk/engine/d_local.h b/regamedll/extra/cssdk/engine/d_local.h deleted file mode 100644 index c2d2f590..00000000 --- a/regamedll/extra/cssdk/engine/d_local.h +++ /dev/null @@ -1,43 +0,0 @@ -/* -* -* This program is free software; you can redistribute it and/or modify it -* under the terms of the GNU General Public License as published by the -* Free Software Foundation; either version 2 of the License, or (at -* your option) any later version. -* -* This program 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 -* General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* -*/ - -#pragma once - -typedef struct surfcache_s -{ - struct surfcache_s *next; - struct surfcache_s **owner; - int lightadj[4]; - int dlight; - int size; - unsigned width; - unsigned height; - float mipscale; - struct texture_s *texture; - unsigned char data[4]; -} surfcache_t; diff --git a/regamedll/extra/cssdk/engine/edict.h b/regamedll/extra/cssdk/engine/edict.h deleted file mode 100644 index 9a389938..00000000 --- a/regamedll/extra/cssdk/engine/edict.h +++ /dev/null @@ -1,36 +0,0 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ -// -// Purpose: -// -// $NoKeywords: $ -//============================================================================= - -#if !defined EDICT_H -#define EDICT_H -#ifdef _WIN32 -#pragma once -#endif -#define MAX_ENT_LEAFS 48 - -#include "progdefs.h" - -struct edict_s -{ - qboolean free; - int serialnumber; - link_t area; // linked to a division node or leaf - - int headnode; // -1 to use normal leaf check - int num_leafs; - short leafnums[MAX_ENT_LEAFS]; - - float freetime; // sv.time when the object was freed - - void* pvPrivateData; // Alloced and freed by engine, used by DLLs - - entvars_t v; // C exported fields from progs - - // other fields from progs come immediately after -}; - -#endif diff --git a/regamedll/extra/cssdk/engine/eiface.h b/regamedll/extra/cssdk/engine/eiface.h deleted file mode 100644 index d2f072dd..00000000 --- a/regamedll/extra/cssdk/engine/eiface.h +++ /dev/null @@ -1,540 +0,0 @@ -/*** -* -* Copyright (c) 1999, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ -#pragma once - -#include "archtypes.h" // DAL - -#ifdef HLDEMO_BUILD -#define INTERFACE_VERSION 001 -#else // !HLDEMO_BUILD, i.e., regular version of HL -#define INTERFACE_VERSION 140 -#endif // !HLDEMO_BUILD - -#include -#include "custom.h" -#include "cvardef.h" -#include "Sequence.h" -// -// Defines entity interface between engine and DLLs. -// This header file included by engine files and DLL files. -// -// Before including this header, DLLs must: -// include progdefs.h -// This is conveniently done for them in extdll.h -// - -/* -#ifdef _WIN32 -#define DLLEXPORT __stdcall -#else -#define DLLEXPORT __attribute__ ((visibility("default"))) -#endif -*/ - -enum ALERT_TYPE -{ - at_notice, - at_console, // same as at_notice, but forces a ConPrintf, not a message box - at_aiconsole, // same as at_console, but only shown if developer level is 2! - at_warning, - at_error, - at_logged // Server print to console ( only in multiplayer games ). -}; - -// 4-22-98 JOHN: added for use in pfnClientPrintf -enum PRINT_TYPE -{ - print_console, - print_center, - print_chat, -}; - -// For integrity checking of content on clients -enum FORCE_TYPE -{ - force_exactfile, // File on client must exactly match server's file - force_model_samebounds, // For model files only, the geometry must fit in the same bbox - force_model_specifybounds, // For model files only, the geometry must fit in the specified bbox - force_model_specifybounds_if_avail, // For Steam model files only, the geometry must fit in the specified bbox (if the file is available) -}; - -// Returned by TraceLine -struct TraceResult -{ - int fAllSolid; // if true, plane is not valid - int fStartSolid; // if true, the initial point was in a solid area - int fInOpen; - int fInWater; - float flFraction; // time completed, 1.0 = didn't hit anything - vec3_t vecEndPos; // final position - float flPlaneDist; - vec3_t vecPlaneNormal; // surface normal at impact - edict_t *pHit; // entity the surface is on - int iHitgroup; // 0 == generic, non zero is specific body part -}; - -// CD audio status -typedef struct -{ - int fPlaying;// is sound playing right now? - int fWasPlaying;// if not, CD is paused if WasPlaying is true. - int fInitialized; - int fEnabled; - int fPlayLooping; - float cdvolume; - //BYTE remap[100]; - int fCDRom; - int fPlayTrack; -} CDStatus; - -#include "../common/crc.h" - - -// Engine hands this to DLLs for functionality callbacks -typedef struct enginefuncs_s -{ - int (*pfnPrecacheModel) (const char* s); - int (*pfnPrecacheSound) (const char* s); - void (*pfnSetModel) (edict_t *e, const char *m); - int (*pfnModelIndex) (const char *m); - int (*pfnModelFrames) (int modelIndex); - void (*pfnSetSize) (edict_t *e, const float *rgflMin, const float *rgflMax); - void (*pfnChangeLevel) (const char* s1, const char* s2); - void (*pfnGetSpawnParms) (edict_t *ent); - void (*pfnSaveSpawnParms) (edict_t *ent); - float (*pfnVecToYaw) (const float *rgflVector); - void (*pfnVecToAngles) (const float *rgflVectorIn, float *rgflVectorOut); - void (*pfnMoveToOrigin) (edict_t *ent, const float *pflGoal, float dist, int iMoveType); - void (*pfnChangeYaw) (edict_t* ent); - void (*pfnChangePitch) (edict_t* ent); - edict_t* (*pfnFindEntityByString) (edict_t *pEdictStartSearchAfter, const char *pszField, const char *pszValue); - int (*pfnGetEntityIllum) (edict_t* pEnt); - edict_t* (*pfnFindEntityInSphere) (edict_t *pEdictStartSearchAfter, const float *org, float rad); - edict_t* (*pfnFindClientInPVS) (edict_t *pEdict); - edict_t* (*pfnEntitiesInPVS) (edict_t *pplayer); - void (*pfnMakeVectors) (const float *rgflVector); - void (*pfnAngleVectors) (const float *rgflVector, float *forward, float *right, float *up); - edict_t* (*pfnCreateEntity) (void); - void (*pfnRemoveEntity) (edict_t* e); - edict_t* (*pfnCreateNamedEntity) (int className); - void (*pfnMakeStatic) (edict_t *ent); - int (*pfnEntIsOnFloor) (edict_t *e); - int (*pfnDropToFloor) (edict_t* e); - int (*pfnWalkMove) (edict_t *ent, float yaw, float dist, int iMode); - void (*pfnSetOrigin) (edict_t *e, const float *rgflOrigin); - void (*pfnEmitSound) (edict_t *entity, int channel, const char *sample, /*int*/float volume, float attenuation, int fFlags, int pitch); - void (*pfnEmitAmbientSound) (edict_t *entity, float *pos, const char *samp, float vol, float attenuation, int fFlags, int pitch); - void (*pfnTraceLine) (const float *v1, const float *v2, int fNoMonsters, edict_t *pentToSkip, TraceResult *ptr); - void (*pfnTraceToss) (edict_t* pent, edict_t* pentToIgnore, TraceResult *ptr); - int (*pfnTraceMonsterHull) (edict_t *pEdict, const float *v1, const float *v2, int fNoMonsters, edict_t *pentToSkip, TraceResult *ptr); - void (*pfnTraceHull) (const float *v1, const float *v2, int fNoMonsters, int hullNumber, edict_t *pentToSkip, TraceResult *ptr); - void (*pfnTraceModel) (const float *v1, const float *v2, int hullNumber, edict_t *pent, TraceResult *ptr); - const char *(*pfnTraceTexture) (edict_t *pTextureEntity, const float *v1, const float *v2 ); - void (*pfnTraceSphere) (const float *v1, const float *v2, int fNoMonsters, float radius, edict_t *pentToSkip, TraceResult *ptr); - void (*pfnGetAimVector) (edict_t* ent, float speed, float *rgflReturn); - void (*pfnServerCommand) (char* str); - void (*pfnServerExecute) (void); - void (*pfnClientCommand) (edict_t* pEdict, char* szFmt, ...); - void (*pfnParticleEffect) (const float *org, const float *dir, float color, float count); - void (*pfnLightStyle) (int style, char* val); - int (*pfnDecalIndex) (const char *name); - int (*pfnPointContents) (const float *rgflVector); - void (*pfnMessageBegin) (int msg_dest, int msg_type, const float *pOrigin, edict_t *ed); - void (*pfnMessageEnd) (void); - void (*pfnWriteByte) (int iValue); - void (*pfnWriteChar) (int iValue); - void (*pfnWriteShort) (int iValue); - void (*pfnWriteLong) (int iValue); - void (*pfnWriteAngle) (float flValue); - void (*pfnWriteCoord) (float flValue); - void (*pfnWriteString) (const char *sz); - void (*pfnWriteEntity) (int iValue); - void (*pfnCVarRegister) (cvar_t *pCvar); - float (*pfnCVarGetFloat) (const char *szVarName); - const char* (*pfnCVarGetString) (const char *szVarName); - void (*pfnCVarSetFloat) (const char *szVarName, float flValue); - void (*pfnCVarSetString) (const char *szVarName, const char *szValue); - void (*pfnAlertMessage) (ALERT_TYPE atype, const char *szFmt, ...); - void (*pfnEngineFprintf) (void *pfile, const char *szFmt, ...); - void* (*pfnPvAllocEntPrivateData) (edict_t *pEdict, int32 cb); - void* (*pfnPvEntPrivateData) (edict_t *pEdict); - void (*pfnFreeEntPrivateData) (edict_t *pEdict); - const char* (*pfnSzFromIndex) (int iString); - int (*pfnAllocString) (const char *szValue); - struct entvars_s* (*pfnGetVarsOfEnt) (edict_t *pEdict); - edict_t* (*pfnPEntityOfEntOffset) (int iEntOffset); - int (*pfnEntOffsetOfPEntity) (const edict_t *pEdict); - int (*pfnIndexOfEdict) (const edict_t *pEdict); - edict_t* (*pfnPEntityOfEntIndex) (int iEntIndex); - edict_t* (*pfnFindEntityByVars) (struct entvars_s* pvars); - void* (*pfnGetModelPtr) (edict_t* pEdict); - int (*pfnRegUserMsg) (const char *pszName, int iSize); - void (*pfnAnimationAutomove) (const edict_t* pEdict, float flTime); - void (*pfnGetBonePosition) (const edict_t* pEdict, int iBone, float *rgflOrigin, float *rgflAngles ); - uint32 (*pfnFunctionFromName) ( const char *pName ); - const char *(*pfnNameForFunction) ( uint32 function ); - void (*pfnClientPrintf) ( edict_t* pEdict, PRINT_TYPE ptype, const char *szMsg ); // JOHN: engine callbacks so game DLL can print messages to individual clients - void (*pfnServerPrint) ( const char *szMsg ); - const char *(*pfnCmd_Args) ( void ); // these 3 added - const char *(*pfnCmd_Argv) ( int argc ); // so game DLL can easily - int (*pfnCmd_Argc) ( void ); // access client 'cmd' strings - void (*pfnGetAttachment) (const edict_t *pEdict, int iAttachment, float *rgflOrigin, float *rgflAngles ); - void (*pfnCRC32_Init) (CRC32_t *pulCRC); - void (*pfnCRC32_ProcessBuffer) (CRC32_t *pulCRC, void *p, int len); - void (*pfnCRC32_ProcessByte) (CRC32_t *pulCRC, unsigned char ch); - CRC32_t (*pfnCRC32_Final) (CRC32_t pulCRC); - int32 (*pfnRandomLong) (int32 lLow, int32 lHigh); - float (*pfnRandomFloat) (float flLow, float flHigh); - void (*pfnSetView) (const edict_t *pClient, const edict_t *pViewent ); - float (*pfnTime) ( void ); - void (*pfnCrosshairAngle) (const edict_t *pClient, float pitch, float yaw); - byte * (*pfnLoadFileForMe) (char *filename, int *pLength); - void (*pfnFreeFile) (void *buffer); - void (*pfnEndSection) (const char *pszSectionName); // trigger_endsection - int (*pfnCompareFileTime) (char *filename1, char *filename2, int *iCompare); - void (*pfnGetGameDir) (char *szGetGameDir); - void (*pfnCvar_RegisterVariable) (cvar_t *variable); - void (*pfnFadeClientVolume) (const edict_t *pEdict, int fadePercent, int fadeOutSeconds, int holdTime, int fadeInSeconds); - void (*pfnSetClientMaxspeed) (edict_t *pEdict, float fNewMaxspeed); - edict_t * (*pfnCreateFakeClient) (const char *netname); // returns NULL if fake client can't be created - void (*pfnRunPlayerMove) (edict_t *fakeclient, const float *viewangles, float forwardmove, float sidemove, float upmove, unsigned short buttons, byte impulse, byte msec ); - int (*pfnNumberOfEntities) (void); - char* (*pfnGetInfoKeyBuffer) (edict_t *e); // passing in NULL gets the serverinfo - char* (*pfnInfoKeyValue) (char *infobuffer, const char *key); - void (*pfnSetKeyValue) (char *infobuffer, const char *key, const char *value); - void (*pfnSetClientKeyValue) (int clientIndex, char *infobuffer, const char *key, const char *value); - int (*pfnIsMapValid) (char *filename); - void (*pfnStaticDecal) ( const float *origin, int decalIndex, int entityIndex, int modelIndex ); - int (*pfnPrecacheGeneric) (char* s); - int (*pfnGetPlayerUserId) (edict_t *e ); // returns the server assigned userid for this player. useful for logging frags, etc. returns -1 if the edict couldn't be found in the list of clients - void (*pfnBuildSoundMsg) (edict_t *entity, int channel, const char *sample, /*int*/float volume, float attenuation, int fFlags, int pitch, int msg_dest, int msg_type, const float *pOrigin, edict_t *ed); - int (*pfnIsDedicatedServer) (void);// is this a dedicated server? - cvar_t *(*pfnCVarGetPointer) (const char *szVarName); - unsigned int (*pfnGetPlayerWONId) (edict_t *e); // returns the server assigned WONid for this player. useful for logging frags, etc. returns -1 if the edict couldn't be found in the list of clients - - // YWB 8/1/99 TFF Physics additions - void (*pfnInfo_RemoveKey) ( char *s, const char *key ); - const char *(*pfnGetPhysicsKeyValue) ( const edict_t *pClient, const char *key ); - void (*pfnSetPhysicsKeyValue) ( const edict_t *pClient, const char *key, const char *value ); - const char *(*pfnGetPhysicsInfoString) ( const edict_t *pClient ); - unsigned short (*pfnPrecacheEvent) ( int type, const char*psz ); - void (*pfnPlaybackEvent) ( int flags, const edict_t *pInvoker, unsigned short eventindex, float delay, float *origin, float *angles, float fparam1, float fparam2, int iparam1, int iparam2, int bparam1, int bparam2 ); - - unsigned char *(*pfnSetFatPVS) ( float *org ); - unsigned char *(*pfnSetFatPAS) ( float *org ); - - int (*pfnCheckVisibility ) ( edict_t *entity, unsigned char *pset ); - - void (*pfnDeltaSetField) ( struct delta_s *pFields, const char *fieldname ); - void (*pfnDeltaUnsetField) ( struct delta_s *pFields, const char *fieldname ); - void (*pfnDeltaAddEncoder) ( char *name, void (*conditionalencode)( struct delta_s *pFields, const unsigned char *from, const unsigned char *to ) ); - int (*pfnGetCurrentPlayer) ( void ); - int (*pfnCanSkipPlayer) ( const edict_t *player ); - int (*pfnDeltaFindField) ( struct delta_s *pFields, const char *fieldname ); - void (*pfnDeltaSetFieldByIndex) ( struct delta_s *pFields, int fieldNumber ); - void (*pfnDeltaUnsetFieldByIndex)( struct delta_s *pFields, int fieldNumber ); - - void (*pfnSetGroupMask) ( int mask, int op ); - - int (*pfnCreateInstancedBaseline) ( int classname, struct entity_state_s *baseline ); - void (*pfnCvar_DirectSet) ( struct cvar_s *var, const char *value ); - - // Forces the client and server to be running with the same version of the specified file - // ( e.g., a player model ). - // Calling this has no effect in single player - void (*pfnForceUnmodified) ( FORCE_TYPE type, float *mins, float *maxs, const char *filename ); - - void (*pfnGetPlayerStats) ( const edict_t *pClient, int *ping, int *packet_loss ); - - void (*pfnAddServerCommand) ( char *cmd_name, void (*function) (void) ); - - // For voice communications, set which clients hear eachother. - // NOTE: these functions take player entity indices (starting at 1). - qboolean (*pfnVoice_GetClientListening)(int iReceiver, int iSender); - qboolean (*pfnVoice_SetClientListening)(int iReceiver, int iSender, qboolean bListen); - - const char *(*pfnGetPlayerAuthId) ( edict_t *e ); - - // PSV: Added for CZ training map -// const char *(*pfnKeyNameForBinding) ( const char* pBinding ); - - sequenceEntry_s* (*pfnSequenceGet) ( const char* fileName, const char* entryName ); - sentenceEntry_s* (*pfnSequencePickSentence) ( const char* groupName, int pickMethod, int *picked ); - - // LH: Give access to filesize via filesystem - int (*pfnGetFileSize) ( char *filename ); - - unsigned int (*pfnGetApproxWavePlayLen) (const char *filepath); - // MDC: Added for CZ career-mode - int (*pfnIsCareerMatch) ( void ); - - // BGC: return the number of characters of the localized string referenced by using "label" - int (*pfnGetLocalizedStringLength) (const char *label); - - // BGC: added to facilitate persistent storage of tutor message decay values for - // different career game profiles. Also needs to persist regardless of mp.dll being - // destroyed and recreated. - void (*pfnRegisterTutorMessageShown) (int mid); - int (*pfnGetTimesTutorMessageShown) (int mid); - void (*pfnProcessTutorMessageDecayBuffer) (int *buffer, int bufferLength); - void (*pfnConstructTutorMessageDecayBuffer) (int *buffer, int bufferLength); - void (*pfnResetTutorMessageDecayData) ( void ); - - // Added 2005/08/11 (no SDK update): - void(*pfnQueryClientCvarValue) (const edict_t *player, const char *cvarName); - - // Added 2005/11/21 (no SDK update): - void(*pfnQueryClientCvarValue2) (const edict_t *player, const char *cvarName, int requestID); - -// Comment out this, for compatibility with older versions metamod - s1lent -#if !defined(CSSDK_COMPAT_OLD_METAMOD) - // Added 2009/06/19 (no SDK update): - int(*pfnEngCheckParm) (const char *pchCmdLineToken, char **ppnext); -#endif - -} enginefuncs_t; - - -// ONLY ADD NEW FUNCTIONS TO THE END OF THIS STRUCT. INTERFACE VERSION IS FROZEN AT 138 - -// Passed to pfnKeyValue -typedef struct KeyValueData_s -{ - char *szClassName; // in: entity classname - char *szKeyName; // in: name of key - char *szValue; // in: value of key - qboolean fHandled; // out: DLL sets to true if key-value pair was understood -} KeyValueData; - - -typedef struct -{ - char mapName[ 32 ]; - char landmarkName[ 32 ]; - edict_t *pentLandmark; - vec3_t vecLandmarkOrigin; -} LEVELLIST; -#define MAX_LEVEL_CONNECTIONS 16 // These are encoded in the lower 16bits of ENTITYTABLE->flags - -typedef struct -{ - int id; // Ordinal ID of this entity (used for entity <--> pointer conversions) - edict_t *pent; // Pointer to the in-game entity - - int location; // Offset from the base data of this entity - int size; // Byte size of this entity's data - int flags; // This could be a short -- bit mask of transitions that this entity is in the PVS of - string_t classname; // entity class name - -} ENTITYTABLE; - -#define FENTTABLE_PLAYER 0x80000000 -#define FENTTABLE_REMOVED 0x40000000 -#define FENTTABLE_MOVEABLE 0x20000000 -#define FENTTABLE_GLOBAL 0x10000000 - -typedef struct saverestore_s SAVERESTOREDATA; - -#ifdef _WIN32 -typedef -#endif -struct saverestore_s -{ - char *pBaseData; // Start of all entity save data - char *pCurrentData; // Current buffer pointer for sequential access - int size; // Current data size - int bufferSize; // Total space for data - int tokenSize; // Size of the linear list of tokens - int tokenCount; // Number of elements in the pTokens table - char **pTokens; // Hash table of entity strings (sparse) - int currentIndex; // Holds a global entity table ID - int tableCount; // Number of elements in the entity table - int connectionCount;// Number of elements in the levelList[] - ENTITYTABLE *pTable; // Array of ENTITYTABLE elements (1 for each entity) - LEVELLIST levelList[ MAX_LEVEL_CONNECTIONS ]; // List of connections from this level - - // smooth transition - int fUseLandmark; - char szLandmarkName[20];// landmark we'll spawn near in next level - vec3_t vecLandmarkOffset;// for landmark transitions - float time; - char szCurrentMapName[32]; // To check global entities - -} -#ifdef _WIN32 -SAVERESTOREDATA -#endif -; - -typedef enum _fieldtypes -{ - FIELD_FLOAT = 0, // Any floating point value - FIELD_STRING, // A string ID (return from ALLOC_STRING) - FIELD_ENTITY, // An entity offset (EOFFSET) - FIELD_CLASSPTR, // CBaseEntity * - FIELD_EHANDLE, // Entity handle - FIELD_EVARS, // EVARS * - FIELD_EDICT, // edict_t *, or edict_t * (same thing) - FIELD_VECTOR, // Any vector - FIELD_POSITION_VECTOR, // A world coordinate (these are fixed up across level transitions automagically) - FIELD_POINTER, // Arbitrary data pointer... to be removed, use an array of FIELD_CHARACTER - FIELD_INTEGER, // Any integer or enum - FIELD_FUNCTION, // A class function pointer (Think, Use, etc) - FIELD_BOOLEAN, // boolean, implemented as an int, I may use this as a hint for compression - FIELD_SHORT, // 2 byte integer - FIELD_CHARACTER, // a byte - FIELD_TIME, // a floating point time (these are fixed up automatically too!) - FIELD_MODELNAME, // Engine string that is a model name (needs precache) - FIELD_SOUNDNAME, // Engine string that is a sound name (needs precache) - - FIELD_TYPECOUNT, // MUST BE LAST -} FIELDTYPE; - -#if !defined(offsetof) && !defined(GNUC) -#define offsetof(s,m) (size_t)&(((s *)0)->m) -#endif - -#define _FIELD(type,name,fieldtype,count,flags) { fieldtype, #name, offsetof(type, name), count, flags } -#define DEFINE_FIELD(type,name,fieldtype) _FIELD(type, name, fieldtype, 1, 0) -#define DEFINE_ARRAY(type,name,fieldtype,count) _FIELD(type, name, fieldtype, count, 0) -#define DEFINE_ENTITY_FIELD(name,fieldtype) _FIELD(entvars_t, name, fieldtype, 1, 0 ) -#define DEFINE_ENTITY_GLOBAL_FIELD(name,fieldtype) _FIELD(entvars_t, name, fieldtype, 1, FTYPEDESC_GLOBAL ) -#define DEFINE_GLOBAL_FIELD(type,name,fieldtype) _FIELD(type, name, fieldtype, 1, FTYPEDESC_GLOBAL ) - - -#define FTYPEDESC_GLOBAL 0x0001 // This field is masked for global entity save/restore - -typedef struct -{ - FIELDTYPE fieldType; - char *fieldName; - int fieldOffset; - short fieldSize; - short flags; -} TYPEDESCRIPTION; - -#ifndef ARRAYSIZE -#define ARRAYSIZE(p) (sizeof(p)/sizeof(p[0])) -#endif - -typedef struct -{ - // Initialize/shutdown the game (one-time call after loading of game .dll ) - void (*pfnGameInit) ( void ); - int (*pfnSpawn) ( edict_t *pent ); - void (*pfnThink) ( edict_t *pent ); - void (*pfnUse) ( edict_t *pentUsed, edict_t *pentOther ); - void (*pfnTouch) ( edict_t *pentTouched, edict_t *pentOther ); - void (*pfnBlocked) ( edict_t *pentBlocked, edict_t *pentOther ); - void (*pfnKeyValue) ( edict_t *pentKeyvalue, KeyValueData *pkvd ); - void (*pfnSave) ( edict_t *pent, SAVERESTOREDATA *pSaveData ); - int (*pfnRestore) ( edict_t *pent, SAVERESTOREDATA *pSaveData, int globalEntity ); - void (*pfnSetAbsBox) ( edict_t *pent ); - - void (*pfnSaveWriteFields) ( SAVERESTOREDATA *, const char *, void *, TYPEDESCRIPTION *, int ); - void (*pfnSaveReadFields) ( SAVERESTOREDATA *, const char *, void *, TYPEDESCRIPTION *, int ); - - void (*pfnSaveGlobalState) ( SAVERESTOREDATA * ); - void (*pfnRestoreGlobalState) ( SAVERESTOREDATA * ); - void (*pfnResetGlobalState) ( void ); - - qboolean (*pfnClientConnect) ( edict_t *pEntity, const char *pszName, const char *pszAddress, char szRejectReason[ 128 ] ); - - void (*pfnClientDisconnect) ( edict_t *pEntity ); - void (*pfnClientKill) ( edict_t *pEntity ); - void (*pfnClientPutInServer) ( edict_t *pEntity ); - void (*pfnClientCommand) ( edict_t *pEntity ); - void (*pfnClientUserInfoChanged)( edict_t *pEntity, char *infobuffer ); - - void (*pfnServerActivate) ( edict_t *pEdictList, int edictCount, int clientMax ); - void (*pfnServerDeactivate) ( void ); - - void (*pfnPlayerPreThink) ( edict_t *pEntity ); - void (*pfnPlayerPostThink) ( edict_t *pEntity ); - - void (*pfnStartFrame) ( void ); - void (*pfnParmsNewLevel) ( void ); - void (*pfnParmsChangeLevel) ( void ); - - // Returns string describing current .dll. E.g., TeamFotrress 2, Half-Life - const char *(*pfnGetGameDescription)( void ); - - // Notify dll about a player customization. - void (*pfnPlayerCustomization) ( edict_t *pEntity, customization_t *pCustom ); - - // Spectator funcs - void (*pfnSpectatorConnect) ( edict_t *pEntity ); - void (*pfnSpectatorDisconnect) ( edict_t *pEntity ); - void (*pfnSpectatorThink) ( edict_t *pEntity ); - - // Notify game .dll that engine is going to shut down. Allows mod authors to set a breakpoint. - void (*pfnSys_Error) ( const char *error_string ); - - void (*pfnPM_Move) ( struct playermove_s *ppmove, qboolean server ); - void (*pfnPM_Init) ( struct playermove_s *ppmove ); - char (*pfnPM_FindTextureType)( char *name ); - void (*pfnSetupVisibility)( struct edict_s *pViewEntity, struct edict_s *pClient, unsigned char **pvs, unsigned char **pas ); - void (*pfnUpdateClientData) ( const struct edict_s *ent, int sendweapons, struct clientdata_s *cd ); - int (*pfnAddToFullPack)( struct entity_state_s *state, int e, edict_t *ent, edict_t *host, int hostflags, int player, unsigned char *pSet ); - void (*pfnCreateBaseline) ( int player, int eindex, struct entity_state_s *baseline, struct edict_s *entity, int playermodelindex, vec3_t player_mins, vec3_t player_maxs ); - void (*pfnRegisterEncoders) ( void ); - int (*pfnGetWeaponData) ( struct edict_s *player, struct weapon_data_s *info ); - - void (*pfnCmdStart) ( const edict_t *player, const struct usercmd_s *cmd, unsigned int random_seed ); - void (*pfnCmdEnd) ( const edict_t *player ); - - // Return 1 if the packet is valid. Set response_buffer_size if you want to send a response packet. Incoming, it holds the max - // size of the response_buffer, so you must zero it out if you choose not to respond. - int (*pfnConnectionlessPacket ) ( const struct netadr_s *net_from_, const char *args, char *response_buffer, int *response_buffer_size ); - - // Enumerates player hulls. Returns 0 if the hull number doesn't exist, 1 otherwise - int (*pfnGetHullBounds) ( int hullnumber, float *mins, float *maxs ); - - // Create baselines for certain "unplaced" items. - void (*pfnCreateInstancedBaselines) ( void ); - - // One of the pfnForceUnmodified files failed the consistency check for the specified player - // Return 0 to allow the client to continue, 1 to force immediate disconnection ( with an optional disconnect message of up to 256 characters ) - int (*pfnInconsistentFile)( const struct edict_s *player, const char *filename, char *disconnect_message ); - - // The game .dll should return 1 if lag compensation should be allowed ( could also just set - // the sv_unlag cvar. - // Most games right now should return 0, until client-side weapon prediction code is written - // and tested for them. - int (*pfnAllowLagCompensation)( void ); -} DLL_FUNCTIONS; - -extern DLL_FUNCTIONS gEntityInterface; - -// Current version. -#define NEW_DLL_FUNCTIONS_VERSION 1 - -typedef struct -{ - // Called right before the object's memory is freed. - // Calls its destructor. - void (*pfnOnFreeEntPrivateData)(edict_t *pEnt); - void (*pfnGameShutdown)(void); - int (*pfnShouldCollide)( edict_t *pentTouched, edict_t *pentOther ); - void (*pfnCvarValue)( const edict_t *pEnt, const char *value ); - void (*pfnCvarValue2)( const edict_t *pEnt, int requestID, const char *cvarName, const char *value ); -} NEW_DLL_FUNCTIONS; -typedef int(*NEW_DLL_FUNCTIONS_FN)(NEW_DLL_FUNCTIONS *pFunctionTable, int *interfaceVersion); - -// Pointers will be null if the game DLL doesn't support this API. -extern NEW_DLL_FUNCTIONS gNewDLLFunctions; - -typedef int(*APIFUNCTION)(DLL_FUNCTIONS *pFunctionTable, int interfaceVersion); -typedef int(*APIFUNCTION2)(DLL_FUNCTIONS *pFunctionTable, int *interfaceVersion); diff --git a/regamedll/extra/cssdk/engine/keydefs.h b/regamedll/extra/cssdk/engine/keydefs.h deleted file mode 100644 index ef9b2fca..00000000 --- a/regamedll/extra/cssdk/engine/keydefs.h +++ /dev/null @@ -1,131 +0,0 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ -// -// Purpose: -// -// $NoKeywords: $ -//============================================================================= - -// keydefs.h -#ifndef KEYDEFS_H -#define KEYDEFS_H -#ifdef _WIN32 -#ifndef __MINGW32__ -#pragma once -#endif /* not __MINGW32__ */ -#endif - -// -// these are the key numbers that should be passed to Key_Event -// -#define K_TAB 9 -#define K_ENTER 13 -#define K_ESCAPE 27 -#define K_SPACE 32 - -// normal keys should be passed as lowercased ascii - -#define K_BACKSPACE 127 -#define K_UPARROW 128 -#define K_DOWNARROW 129 -#define K_LEFTARROW 130 -#define K_RIGHTARROW 131 - -#define K_ALT 132 -#define K_CTRL 133 -#define K_SHIFT 134 -#define K_F1 135 -#define K_F2 136 -#define K_F3 137 -#define K_F4 138 -#define K_F5 139 -#define K_F6 140 -#define K_F7 141 -#define K_F8 142 -#define K_F9 143 -#define K_F10 144 -#define K_F11 145 -#define K_F12 146 -#define K_INS 147 -#define K_DEL 148 -#define K_PGDN 149 -#define K_PGUP 150 -#define K_HOME 151 -#define K_END 152 - -#define K_KP_HOME 160 -#define K_KP_UPARROW 161 -#define K_KP_PGUP 162 -#define K_KP_LEFTARROW 163 -#define K_KP_5 164 -#define K_KP_RIGHTARROW 165 -#define K_KP_END 166 -#define K_KP_DOWNARROW 167 -#define K_KP_PGDN 168 -#define K_KP_ENTER 169 -#define K_KP_INS 170 -#define K_KP_DEL 171 -#define K_KP_SLASH 172 -#define K_KP_MINUS 173 -#define K_KP_PLUS 174 -#define K_CAPSLOCK 175 - - -// -// joystick buttons -// -#define K_JOY1 203 -#define K_JOY2 204 -#define K_JOY3 205 -#define K_JOY4 206 - -// -// aux keys are for multi-buttoned joysticks to generate so they can use -// the normal binding process -// -#define K_AUX1 207 -#define K_AUX2 208 -#define K_AUX3 209 -#define K_AUX4 210 -#define K_AUX5 211 -#define K_AUX6 212 -#define K_AUX7 213 -#define K_AUX8 214 -#define K_AUX9 215 -#define K_AUX10 216 -#define K_AUX11 217 -#define K_AUX12 218 -#define K_AUX13 219 -#define K_AUX14 220 -#define K_AUX15 221 -#define K_AUX16 222 -#define K_AUX17 223 -#define K_AUX18 224 -#define K_AUX19 225 -#define K_AUX20 226 -#define K_AUX21 227 -#define K_AUX22 228 -#define K_AUX23 229 -#define K_AUX24 230 -#define K_AUX25 231 -#define K_AUX26 232 -#define K_AUX27 233 -#define K_AUX28 234 -#define K_AUX29 235 -#define K_AUX30 236 -#define K_AUX31 237 -#define K_AUX32 238 -#define K_MWHEELDOWN 239 -#define K_MWHEELUP 240 - -#define K_PAUSE 255 - -// -// mouse buttons generate virtual keys -// -#define K_MOUSE1 241 -#define K_MOUSE2 242 -#define K_MOUSE3 243 -#define K_MOUSE4 244 -#define K_MOUSE5 245 - -#endif // KEYDEFS_H diff --git a/regamedll/extra/cssdk/engine/maintypes.h b/regamedll/extra/cssdk/engine/maintypes.h deleted file mode 100644 index 40ae20cb..00000000 --- a/regamedll/extra/cssdk/engine/maintypes.h +++ /dev/null @@ -1,52 +0,0 @@ -/* -* -* This program is free software; you can redistribute it and/or modify it -* under the terms of the GNU General Public License as published by the -* Free Software Foundation; either version 2 of the License, or (at -* your option) any later version. -* -* This program 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 -* General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* -*/ - -#ifndef MAINTYPES_H -#define MAINTYPES_H -#ifdef _WIN32 -#pragma once -#endif - - -#include "osconfig.h" -#include "mathlib.h" - - -// Has no references on server side. -#define NOXREF -// Function body is not implemented. -#define NOBODY -// Function is not tested at all. -#define UNTESTED - -#define BIT(n) (1<<(n)) - - -typedef unsigned int string_t; // from engine's pr_comp.h; - -#endif // MAINTYPES_H diff --git a/regamedll/extra/cssdk/engine/model.h b/regamedll/extra/cssdk/engine/model.h deleted file mode 100644 index ba5d6384..00000000 --- a/regamedll/extra/cssdk/engine/model.h +++ /dev/null @@ -1,409 +0,0 @@ -/* -* -* This program is free software; you can redistribute it and/or modify it -* under the terms of the GNU General Public License as published by the -* Free Software Foundation; either version 2 of the License, or (at -* your option) any later version. -* -* This program 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 -* General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* -*/ -#pragma once - -#include "const.h" -#include "modelgen.h" -#include "spritegn.h" -#include "bspfile.h" -#include "crc.h" -#include "com_model.h" -#include "commonmacros.h" - -// header -#define ALIAS_MODEL_VERSION 0x006 -#define IDPOLYHEADER MAKEID('I', 'D', 'P', 'O') // little-endian "IDPO" - -#define MAX_LBM_HEIGHT 480 -#define MAX_ALIAS_MODEL_VERTS 2000 - -#define SURF_PLANEBACK 2 -#define SURF_DRAWSKY 4 -#define SURF_DRAWSPRITE 8 -#define SURF_DRAWTURB 0x10 -#define SURF_DRAWTILED 0x20 -#define SURF_DRAWBACKGROUND 0x40 - -#define MAX_MODEL_NAME 64 -#define MIPLEVELS 4 -#define NUM_AMBIENTS 4 // automatic ambient sounds -#define MAXLIGHTMAPS 4 -#define MAX_KNOWN_MODELS 1024 - -typedef struct mvertex_s -{ - vec3_t position; -} mvertex_t; - -typedef struct mplane_s -{ - vec3_t normal; // surface normal - float dist; // closest appoach to origin - byte type; // for texture axis selection and fast side tests - byte signbits; // signx + signy<<1 + signz<<1 - byte pad[2]; -} mplane_t; - -typedef struct texture_s -{ - char name[16]; - unsigned width, height; - -#ifndef SWDS - int gl_texturenum; - struct msurface_s * texturechain; -#endif - - int anim_total; // total tenths in sequence ( 0 = no) - int anim_min, anim_max; // time for this frame min <=time< max - struct texture_s *anim_next; // in the animation sequence - struct texture_s *alternate_anims; // bmodels in frame 1 use these - unsigned offsets[MIPLEVELS]; // four mip maps stored - -#ifdef SWDS - unsigned paloffset; -#else - byte *pPal; -#endif - -} texture_t; - -typedef struct medge_s -{ - unsigned short v[2]; - unsigned int cachededgeoffset; -} medge_t; - -typedef struct mtexinfo_s -{ - float vecs[2][4]; // [s/t] unit vectors in world space. - // [i][3] is the s/t offset relative to the origin. - // s or t = dot(3Dpoint,vecs[i])+vecs[i][3] - float mipadjust; // ?? mipmap limits for very small surfaces - texture_t *texture; - int flags; // sky or slime, no lightmap or 256 subdivision -} mtexinfo_t; -#define TEX_SPECIAL 1 // sky or slime, no lightmap or 256 subdivision - -typedef struct msurface_s msurface_t; -typedef struct decal_s decal_t; - -// JAY: Compress this as much as possible -struct decal_s -{ - decal_t *pnext; // linked list for each surface - msurface_t *psurface; // Surface id for persistence / unlinking - short dx; // Offsets into surface texture (in texture coordinates, so we don't need floats) - short dy; - short texture; // Decal texture - byte scale; // Pixel scale - byte flags; // Decal flags - - short entityIndex; // Entity this is attached to -}; - -struct msurface_s -{ - int visframe; // should be drawn when node is crossed - - int dlightframe; // last frame the surface was checked by an animated light - int dlightbits; // dynamically generated. Indicates if the surface illumination - // is modified by an animated light. - - mplane_t *plane; // pointer to shared plane - int flags; // see SURF_ #defines - - int firstedge; // look up in model->surfedges[], negative numbers - int numedges; // are backwards edges - - // surface generation data - struct surfcache_s *cachespots[MIPLEVELS]; - - short texturemins[2]; // smallest s/t position on the surface. - short extents[2]; // ?? s/t texture size, 1..256 for all non-sky surfaces - - mtexinfo_t *texinfo; - - // lighting info - byte styles[MAXLIGHTMAPS]; // index into d_lightstylevalue[] for animated lights - // no one surface can be effected by more than 4 - // animated lights. - color24 *samples; - - decal_t *pdecals; -}; - -typedef struct mnode_s -{ - // common with leaf - int contents; // 0, to differentiate from leafs - int visframe; // node needs to be traversed if current - - short minmaxs[6]; // for bounding box culling - - struct mnode_s *parent; - - // node specific - mplane_t *plane; - struct mnode_s *children[2]; - - unsigned short firstsurface; - unsigned short numsurfaces; -} mnode_t; - -typedef struct mleaf_s -{ - // common with node - int contents; // wil be a negative contents number - int visframe; // node needs to be traversed if current - - short minmaxs[6]; // for bounding box culling - - struct mnode_s *parent; - - // leaf specific - byte *compressed_vis; - struct efrag_s *efrags; - - msurface_t **firstmarksurface; - int nummarksurfaces; - int key; // BSP sequence number for leaf's contents - byte ambient_sound_level[NUM_AMBIENTS]; -} mleaf_t; - -typedef struct hull_s -{ - dclipnode_t *clipnodes; - mplane_t *planes; - int firstclipnode; - int lastclipnode; - vec3_t clip_mins, clip_maxs; -} hull_t; - -typedef struct mspriteframe_t -{ - int width; - int height; - void *pcachespot; - float up, down, left, right; - byte pixels[4]; -} mspriteframe_s; - -typedef struct mspritegroup_s -{ - int numframes; - float *intervals; - mspriteframe_t *frames[1]; -} mspritegroup_t; - -typedef struct mspriteframedesc_s -{ - spriteframetype_t type; - mspriteframe_t *frameptr; -} mspriteframedesc_t; - -typedef struct msprite_s -{ - short int type; - short int texFormat; - int maxwidth, maxheight; - int numframes; - int paloffset; - float beamlength; - void *cachespot; - mspriteframedesc_t frames[1]; -} msprite_t; - -typedef struct maliasframedesc_s -{ - aliasframetype_t type; - trivertx_t bboxmin, bboxmax; - int frame; - char name[16]; -} maliasframedesc_t; - -typedef struct maliasskindesc_s -{ - aliasskintype_t type; - void *pcachespot; - int skin; -} maliasskindesc_t; - -typedef struct maliasgroupframedesc_s -{ - trivertx_t bboxmin, bboxmax; - int frame; -} maliasgroupframedesc_t; - -typedef struct maliasgroup_s -{ - int numframes; - int intervals; - maliasgroupframedesc_t frames[1]; -} maliasgroup_t; - -typedef struct maliasskingroup_s -{ - int numskins; - int intervals; - maliasskindesc_t skindescs[1]; -} maliasskingroup_t; - -typedef struct mtriangle_s -{ - int facesfront; - int vertindex[3]; -} mtriangle_t; - -typedef struct aliashdr_s -{ - int model; - int stverts; - int skindesc; - int triangles; - int palette; - maliasframedesc_t frames[1]; -} aliashdr_t; - -typedef enum modtype_e -{ - mod_bad = -1, - mod_brush, - mod_sprite, - mod_alias, - mod_studio, -} modtype_t; - -typedef struct model_s -{ - char name[MAX_MODEL_NAME]; - - int needload; // bmodels and sprites don't cache normally - - modtype_t type; - int numframes; - synctype_t synctype; - - int flags; - - // - // volume occupied by the model - // - vec3_t mins, maxs; - float radius; - - // - // brush model - // - int firstmodelsurface, nummodelsurfaces; - - int numsubmodels; - dmodel_t *submodels; - - int numplanes; - mplane_t *planes; - - int numleafs; // number of visible leafs, not counting 0 - struct mleaf_s *leafs; - - int numvertexes; - mvertex_t *vertexes; - - int numedges; - medge_t *edges; - - int numnodes; - mnode_t *nodes; - - int numtexinfo; - mtexinfo_t *texinfo; - - int numsurfaces; - msurface_t *surfaces; - - int numsurfedges; - int *surfedges; - - int numclipnodes; - dclipnode_t *clipnodes; - - int nummarksurfaces; - msurface_t **marksurfaces; - - hull_t hulls[MAX_MAP_HULLS]; - - int numtextures; - texture_t **textures; - - byte *visdata; - - color24 *lightdata; - - char *entities; - - // - // additional model data - // - cache_user_t cache; // only access through Mod_Extradata -} model_t; - -typedef struct cachepic_s -{ - char name[64]; - cache_user_t cache; -} cachepic_t; - -typedef struct cachewad_s cachewad_t; - -typedef void(*PFNCACHE)(cachewad_t *, unsigned char *); - -typedef struct cachewad_s -{ - char *name; - cachepic_t *cache; - int cacheCount; - int cacheMax; - struct lumpinfo_s *lumps; - int lumpCount; - int cacheExtra; - PFNCACHE pfnCacheBuild; - int numpaths; - char **basedirs; - int *lumppathindices; -#ifndef SWDS - int tempWad; -#endif // SWDS -} cachewad_t; - -typedef struct mod_known_info_s -{ - qboolean shouldCRC; - qboolean firstCRCDone; - CRC32_t initialCRC; -} mod_known_info_t; - diff --git a/regamedll/extra/cssdk/engine/modelgen.h b/regamedll/extra/cssdk/engine/modelgen.h deleted file mode 100644 index 48fd9b84..00000000 --- a/regamedll/extra/cssdk/engine/modelgen.h +++ /dev/null @@ -1,128 +0,0 @@ -/* -* -* This program is free software; you can redistribute it and/or modify it -* under the terms of the GNU General Public License as published by the -* Free Software Foundation; either version 2 of the License, or (at -* your option) any later version. -* -* This program 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 -* General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* -*/ - -#ifndef MODELGEN_H -#define MODELGEN_H -#ifdef _WIN32 -#pragma once -#endif - -typedef enum synctype_e -{ - ST_SYNC = 0, - ST_RAND = 1, -} synctype_t; - -typedef enum aliasframetype_s -{ - ALIAS_SINGLE = 0, - ALIAS_GROUP = 1, -} aliasframetype_t; - -typedef enum aliasskintype_s -{ - ALIAS_SKIN_SINGLE = 0, - ALIAS_SKIN_GROUP = 1, -} aliasskintype_t; - -typedef struct mdl_s -{ - int ident; - int version; - vec3_t scale; - vec3_t scale_origin; - float boundingradius; - vec3_t eyeposition; - int numskins; - int skinwidth; - int skinheight; - int numverts; - int numtris; - int numframes; - synctype_t synctype; - int flags; - float size; -} mdl_t; - -typedef struct stvert_s -{ - int onseam; - int s; - int t; -} stvert_t; - -typedef struct dtriangle_s -{ - int facesfront; - int vertindex[3]; -} dtriangle_t; - -typedef struct trivertx_s -{ - byte v[3]; - byte lightnormalindex; -} trivertx_t; - -typedef struct daliasframe_s -{ - trivertx_t bboxmin, bboxmax; - char name[16]; -} daliasframe_t; - -typedef struct daliasgroup_s -{ - int numframes; - trivertx_t bboxmin, bboxmax; -} daliasgroup_t; - -typedef struct daliasskingroup_s -{ - int numskins; -} daliasskingroup_t; - -typedef struct daliasinterval_s -{ - float interval; -} daliasinterval_t; - -typedef struct daliasskininterval_s -{ - float interval; -} daliasskininterval_t; - -typedef struct daliasframetype_s -{ - aliasframetype_t type; -} daliasframetype_t; - -typedef struct daliasskintype_s -{ - aliasskintype_t type; -} daliasskintype_t; - -#endif // MODELGEN_H diff --git a/regamedll/extra/cssdk/engine/osconfig.h b/regamedll/extra/cssdk/engine/osconfig.h deleted file mode 100644 index bf1585e1..00000000 --- a/regamedll/extra/cssdk/engine/osconfig.h +++ /dev/null @@ -1,195 +0,0 @@ -/* -* -* This program is free software; you can redistribute it and/or modify it -* under the terms of the GNU General Public License as published by the -* Free Software Foundation; either version 2 of the License, or (at -* your option) any later version. -* -* This program 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 -* General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* -*/ - -#ifndef _OSCONFIG_H -#define _OSCONFIG_H - -#ifdef _WIN32 // WINDOWS - #pragma warning(disable : 4005) -#endif // _WIN32 - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#ifdef _WIN32 // WINDOWS - #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers - #include - #include - #include // for support IPX - #define PSAPI_VERSION 1 - #include - #include - #include - #include - #include - #include -#else // _WIN32 - #include - #include - //#include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - - // Deail with stupid macro in kernel.h - #undef __FUNCTION__ -#endif // _WIN32 - -#include -#include -#include -#include - -#include -#include - -#ifdef _WIN32 // WINDOWS - #define _CRT_SECURE_NO_WARNINGS - #define WIN32_LEAN_AND_MEAN - - #ifndef CDECL - #define CDECL __cdecl - #endif - #define STDCALL __stdcall - #define HIDDEN - #define NOINLINE __declspec(noinline) - #define ALIGN16 __declspec(align(16)) - #define NORETURN __declspec(noreturn) - #define FORCE_STACK_ALIGN - - //inline bool SOCKET_FIONBIO(SOCKET s, int m) { return (ioctlsocket(s, FIONBIO, (u_long*)&m) == 0); } - //inline int SOCKET_MSGLEN(SOCKET s, u_long& r) { return ioctlsocket(s, FIONREAD, (u_long*)&r); } - typedef int socklen_t; - #define SOCKET_FIONBIO(s, m) ioctlsocket(s, FIONBIO, (u_long*)&m) - #define SOCKET_MSGLEN(s, r) ioctlsocket(s, FIONREAD, (u_long*)&r) - #define SIN_GET_ADDR(saddr, r) r = (saddr)->S_un.S_addr - #define SIN_SET_ADDR(saddr, r) (saddr)->S_un.S_addr = (r) - #define SOCKET_CLOSE(s) closesocket(s) - #define SOCKET_AGAIN() (WSAGetLastError() == WSAEWOULDBLOCK) - - inline void* sys_allocmem(unsigned int size) { - return VirtualAlloc(NULL, size, MEM_COMMIT, PAGE_READWRITE); - } - - inline void sys_freemem(void* ptr, unsigned int size) { - VirtualFree(ptr, 0, MEM_RELEASE); - } -#else // _WIN32 - #ifdef __FUNCTION__ - #undef __FUNCTION__ - #endif - #define __FUNCTION__ __func__ - - #ifndef PAGESIZE - #define PAGESIZE 4096 - #endif - #define ALIGN(addr) (size_t)((size_t)addr & ~(PAGESIZE-1)) - #define ARRAYSIZE(p) (sizeof(p)/sizeof(p[0])) - - #define _MAX_FNAME NAME_MAX - #define MAX_PATH 260 - - typedef void *HWND; - - typedef unsigned long DWORD; - typedef unsigned short WORD; - typedef unsigned int UNINT32; - - #define CDECL __attribute__ ((cdecl)) - #define STDCALL __attribute__ ((stdcall)) - #define HIDDEN __attribute__((visibility("hidden"))) - #define NOINLINE __attribute__((noinline)) - #define ALIGN16 __attribute__((aligned(16))) - #define NORETURN __attribute__((noreturn)) - #define FORCE_STACK_ALIGN __attribute__((force_align_arg_pointer)) - - //inline bool SOCKET_FIONBIO(SOCKET s, int m) { return (ioctl(s, FIONBIO, (int*)&m) == 0); } - //inline int SOCKET_MSGLEN(SOCKET s, u_long& r) { return ioctl(s, FIONREAD, (int*)&r); } - typedef int SOCKET; - #define INVALID_SOCKET (SOCKET)(~0) - #define SOCKET_FIONBIO(s, m) ioctl(s, FIONBIO, (char*)&m) - #define SOCKET_MSGLEN(s, r) ioctl(s, FIONREAD, (char*)&r) - #define SIN_GET_ADDR(saddr, r) r = (saddr)->s_addr - #define SIN_SET_ADDR(saddr, r) (saddr)->s_addr = (r) - #define SOCKET_CLOSE(s) close(s) - #define SOCKET_AGAIN() (errno == EAGAIN) - #define SOCKET_ERROR -1 - - inline void* sys_allocmem(unsigned int size) { - return mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); - } - inline void sys_freemem(void* ptr, unsigned int size) { - munmap(ptr, size); - } - - #define WSAENOPROTOOPT ENOPROTOOPT - - #ifndef FALSE - #define FALSE 0 - #endif - #ifndef TRUE - #define TRUE 1 - #endif -#endif // _WIN32 - -#ifdef _WIN32 - static const bool __isWindows = true; - static const bool __isLinux = false; -#else - static const bool __isWindows = false; - static const bool __isLinux = true; -#endif - -#define EXT_FUNC FORCE_STACK_ALIGN - -#endif // _OSCONFIG_H diff --git a/regamedll/extra/cssdk/engine/progdefs.h b/regamedll/extra/cssdk/engine/progdefs.h deleted file mode 100644 index e27dc507..00000000 --- a/regamedll/extra/cssdk/engine/progdefs.h +++ /dev/null @@ -1,224 +0,0 @@ -/*** -* -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ -#ifndef PROGDEFS_H -#define PROGDEFS_H -#ifdef _WIN32 -#pragma once -#endif - -typedef struct globalvars_s -{ - float time; - float frametime; - float force_retouch; - string_t mapname; - string_t startspot; - float deathmatch_; - float coop_; - float teamplay; - float serverflags; - float found_secrets; - vec3_t v_forward; - vec3_t v_up; - vec3_t v_right; - float trace_allsolid; - float trace_startsolid; - float trace_fraction; - vec3_t trace_endpos; - vec3_t trace_plane_normal; - float trace_plane_dist; - edict_t *trace_ent; - float trace_inopen; - float trace_inwater; - int trace_hitgroup; - int trace_flags; - int msg_entity; - int cdAudioTrack; - int maxClients; - int maxEntities; - const char *pStringBase; - - void *pSaveData; - vec3_t vecLandmarkOffset; -} globalvars_t; - - -typedef struct entvars_s -{ - string_t classname; - string_t globalname; - - vec3_t origin; - vec3_t oldorigin; - vec3_t velocity; - vec3_t basevelocity; - vec3_t clbasevelocity; // Base velocity that was passed in to server physics so - // client can predict conveyors correctly. Server zeroes it, so we need to store here, too. - vec3_t movedir; - - vec3_t angles; // Model angles - vec3_t avelocity; // angle velocity (degrees per second) - vec3_t punchangle; // auto-decaying view angle adjustment - vec3_t v_angle; // Viewing angle (player only) - - // For parametric entities - vec3_t endpos; - vec3_t startpos; - float impacttime; - float starttime; - - int fixangle; // 0:nothing, 1:force view angles, 2:add avelocity - float idealpitch; - float pitch_speed; - float ideal_yaw; - float yaw_speed; - - int modelindex; - string_t model; - - int viewmodel; // player's viewmodel - int weaponmodel; // what other players see - - vec3_t absmin; // BB max translated to world coord - vec3_t absmax; // BB max translated to world coord - vec3_t mins; // local BB min - vec3_t maxs; // local BB max - vec3_t size; // maxs - mins - - float ltime; - float nextthink; - - int movetype; - int solid; - - int skin; - int body; // sub-model selection for studiomodels - int effects; - - float gravity; // % of "normal" gravity - float friction; // inverse elasticity of MOVETYPE_BOUNCE - - int light_level; - - int sequence; // animation sequence - int gaitsequence; // movement animation sequence for player (0 for none) - float frame; // % playback position in animation sequences (0..255) - float animtime; // world time when frame was set - float framerate; // animation playback rate (-8x to 8x) - byte controller[4]; // bone controller setting (0..255) - byte blending[2]; // blending amount between sub-sequences (0..255) - - float scale; // sprite rendering scale (0..255) - - int rendermode; - float renderamt; - vec3_t rendercolor; - int renderfx; - - float health; - float frags; - int weapons; // bit mask for available weapons - float takedamage; - - int deadflag; - vec3_t view_ofs; // eye position - - int button; - int impulse; - - edict_t *chain; // Entity pointer when linked into a linked list - edict_t *dmg_inflictor; - edict_t *enemy; - edict_t *aiment; // entity pointer when MOVETYPE_FOLLOW - edict_t *owner; - edict_t *groundentity; - - int spawnflags; - int flags; - - int colormap; // lowbyte topcolor, highbyte bottomcolor - int team; - - float max_health; - float teleport_time; - float armortype; - float armorvalue; - int waterlevel; - int watertype; - - string_t target; - string_t targetname; - string_t netname; - string_t message; - - float dmg_take; - float dmg_save; - float dmg; - float dmgtime; - - string_t noise; - string_t noise1; - string_t noise2; - string_t noise3; - - float speed; - float air_finished; - float pain_finished; - float radsuit_finished; - - edict_t *pContainingEntity; - - int playerclass; - float maxspeed; - - float fov; - int weaponanim; - - int pushmsec; - - int bInDuck; - int flTimeStepSound; - int flSwimTime; - int flDuckTime; - int iStepLeft; - float flFallVelocity; - - int gamestate; - - int oldbuttons; - - int groupinfo; - - // For mods - int iuser1; - int iuser2; - int iuser3; - int iuser4; - float fuser1; - float fuser2; - float fuser3; - float fuser4; - vec3_t vuser1; - vec3_t vuser2; - vec3_t vuser3; - vec3_t vuser4; - edict_t *euser1; - edict_t *euser2; - edict_t *euser3; - edict_t *euser4; -} entvars_t; - - -#endif // PROGDEFS_H diff --git a/regamedll/extra/cssdk/engine/progs.h b/regamedll/extra/cssdk/engine/progs.h deleted file mode 100644 index fe4796e6..00000000 --- a/regamedll/extra/cssdk/engine/progs.h +++ /dev/null @@ -1,82 +0,0 @@ -/*** -* -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ -#ifndef PROGS_H -#define PROGS_H - -#include "progdefs.h" - -// 16 simultaneous events, max -#define MAX_EVENT_QUEUE 64 - -#define DEFAULT_EVENT_RESENDS 1 - -#include "event_flags.h" - -typedef struct event_info_s event_info_t; - -#include "event_args.h" - -struct event_info_s -{ - unsigned short index; // 0 implies not in use - - short packet_index; // Use data from state info for entity in delta_packet . -1 implies separate info based on event - // parameter signature - short entity_index; // The edict this event is associated with - - float fire_time; // if non-zero, the time when the event should be fired ( fixed up on the client ) - - event_args_t args; - -// CLIENT ONLY - int flags; // Reliable or not, etc. - -}; - -typedef struct event_state_s event_state_t; - -struct event_state_s -{ - struct event_info_s ei[ MAX_EVENT_QUEUE ]; -}; - -#if !defined( ENTITY_STATEH ) -#include "entity_state.h" -#endif - -#if !defined( EDICT_H ) -#include "edict.h" -#endif - -#define STRUCT_FROM_LINK(l,t,m) ((t *)((byte *)l - (int)&(((t *)0)->m))) -#define EDICT_FROM_AREA(l) STRUCT_FROM_LINK(l,edict_t,area) - -//============================================================================ - -extern char *pr_strings; -extern globalvars_t gGlobalVariables; - -//============================================================================ - -edict_t *ED_Alloc (void); -void ED_Free (edict_t *ed); -void ED_LoadFromFile (char *data); - -edict_t *EDICT_NUM(int n); -int NUM_FOR_EDICT(const edict_t *e); - -#define PROG_TO_EDICT(e) ((edict_t *)((byte *)sv.edicts + e)) - -#endif // PROGS_H diff --git a/regamedll/extra/cssdk/engine/rehlds_api.h b/regamedll/extra/cssdk/engine/rehlds_api.h deleted file mode 100644 index 2f4a1152..00000000 --- a/regamedll/extra/cssdk/engine/rehlds_api.h +++ /dev/null @@ -1,300 +0,0 @@ -/* -* -* This program is free software; you can redistribute it and/or modify it -* under the terms of the GNU General Public License as published by the -* Free Software Foundation; either version 2 of the License, or (at -* your option) any later version. -* -* This program 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 -* General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* -*/ -#pragma once -#include "archtypes.h" -#include "cmd_rehlds.h" -#include "rehlds_interfaces.h" -#include "hookchains.h" -#include "FlightRecorder.h" -#include "interface.h" -#include "model.h" - -#define REHLDS_API_VERSION_MAJOR 3 -#define REHLDS_API_VERSION_MINOR 0 - -//Steam_NotifyClientConnect hook -typedef IHookChain IRehldsHook_Steam_NotifyClientConnect; -typedef IHookChainRegistry IRehldsHookRegistry_Steam_NotifyClientConnect; - -//SV_ConnectClient hook -typedef IVoidHookChain<> IRehldsHook_SV_ConnectClient; -typedef IVoidHookChainRegistry<> IRehldsHookRegistry_SV_ConnectClient; - -//SV_GetIDString hook -typedef IHookChain IRehldsHook_SV_GetIDString; -typedef IHookChainRegistry IRehldsHookRegistry_SV_GetIDString; - -//SV_SendServerinfo hook -typedef IVoidHookChain IRehldsHook_SV_SendServerinfo; -typedef IVoidHookChainRegistry IRehldsHookRegistry_SV_SendServerinfo; - -//SV_CheckProtocol hook -typedef IHookChain IRehldsHook_SV_CheckProtocol; -typedef IHookChainRegistry IRehldsHookRegistry_SV_CheckProtocol; - -//SVC_GetChallenge_mod hook -typedef IVoidHookChain IRehldsHook_SVC_GetChallenge_mod; -typedef IVoidHookChainRegistry IRehldsHookRegistry_SVC_GetChallenge_mod; - -//SV_CheckKeyInfo hook -typedef IHookChain IRehldsHook_SV_CheckKeyInfo; -typedef IHookChainRegistry IRehldsHookRegistry_SV_CheckKeyInfo; - -//SV_CheckIPRestrictions hook -typedef IHookChain IRehldsHook_SV_CheckIPRestrictions; -typedef IHookChainRegistry IRehldsHookRegistry_SV_CheckIPRestrictions; - -//SV_FinishCertificateCheck hook -typedef IHookChain IRehldsHook_SV_FinishCertificateCheck; -typedef IHookChainRegistry IRehldsHookRegistry_SV_FinishCertificateCheck; - -//Steam_NotifyBotConnect hook -typedef IHookChain IRehldsHook_Steam_NotifyBotConnect; -typedef IHookChainRegistry IRehldsHookRegistry_Steam_NotifyBotConnect; - -//SerializeSteamId -typedef IVoidHookChain IRehldsHook_SerializeSteamId; -typedef IVoidHookChainRegistry IRehldsHookRegistry_SerializeSteamId; - -//SV_CompareUserID hook -typedef IHookChain IRehldsHook_SV_CompareUserID; -typedef IHookChainRegistry IRehldsHookRegistry_SV_CompareUserID; - -//Steam_NotifyClientDisconnect -typedef IVoidHookChain IRehldsHook_Steam_NotifyClientDisconnect; -typedef IVoidHookChainRegistry IRehldsHookRegistry_Steam_NotifyClientDisconnect; - -//PreProcessPacket -typedef IHookChain IRehldsHook_PreprocessPacket; -typedef IHookChainRegistry IRehldsHookRegistry_PreprocessPacket; - -//ValidateCommand -typedef IHookChain IRehldsHook_ValidateCommand; -typedef IHookChainRegistry IRehldsHookRegistry_ValidateCommand; - -//ExecuteServerStringCmd -typedef IVoidHookChain IRehldsHook_ExecuteServerStringCmd; -typedef IVoidHookChainRegistry IRehldsHookRegistry_ExecuteServerStringCmd; - -//ClientConnected -typedef IVoidHookChain IRehldsHook_ClientConnected; -typedef IVoidHookChainRegistry IRehldsHookRegistry_ClientConnected; - -//HandleNetCommand -typedef IVoidHookChain IRehldsHook_HandleNetCommand; -typedef IVoidHookChainRegistry IRehldsHookRegistry_HandleNetCommand; - -//Mod_LoadBrushModel -typedef IVoidHookChain IRehldsHook_Mod_LoadBrushModel; -typedef IVoidHookChainRegistry IRehldsHookRegistry_Mod_LoadBrushModel; - -//Mod_LoadStudioModel -typedef IVoidHookChain IRehldsHook_Mod_LoadStudioModel; -typedef IVoidHookChainRegistry IRehldsHookRegistry_Mod_LoadStudioModel; - -//SV_EmitEvents hook -typedef IVoidHookChain IRehldsHook_SV_EmitEvents; -typedef IVoidHookChainRegistry IRehldsHookRegistry_SV_EmitEvents; - -//EV_PlayReliableEvent hook -typedef IVoidHookChain IRehldsHook_EV_PlayReliableEvent; -typedef IVoidHookChainRegistry IRehldsHookRegistry_EV_PlayReliableEvent; - -//SV_StartSound hook -typedef IVoidHookChain IRehldsHook_SV_StartSound; -typedef IVoidHookChainRegistry IRehldsHookRegistry_SV_StartSound; - -//PF_Remove_I hook -typedef IVoidHookChain IRehldsHook_PF_Remove_I; -typedef IVoidHookChainRegistry IRehldsHookRegistry_PF_Remove_I; - -//PF_BuildSoundMsg_I hook -typedef IVoidHookChain IRehldsHook_PF_BuildSoundMsg_I; -typedef IVoidHookChainRegistry IRehldsHookRegistry_PF_BuildSoundMsg_I; - -//SV_WriteFullClientUpdate hook -typedef IVoidHookChain IRehldsHook_SV_WriteFullClientUpdate; -typedef IVoidHookChainRegistry IRehldsHookRegistry_SV_WriteFullClientUpdate; - -//SV_CheckConsistencyResponse hook -typedef IHookChain IRehldsHook_SV_CheckConsistencyResponse; -typedef IHookChainRegistry IRehldsHookRegistry_SV_CheckConsistencyResponse; - -//SV_DropClient hook -typedef IVoidHookChain IRehldsHook_SV_DropClient; -typedef IVoidHookChainRegistry IRehldsHookRegistry_SV_DropClient; - -//SV_ActivateServer hook -typedef IVoidHookChain IRehldsHook_SV_ActivateServer; -typedef IVoidHookChainRegistry IRehldsHookRegistry_SV_ActivateServer; - -//SV_WriteVoiceCodec hook -typedef IVoidHookChain IRehldsHook_SV_WriteVoiceCodec; -typedef IVoidHookChainRegistry IRehldsHookRegistry_SV_WriteVoiceCodec; - -//Steam_GSGetSteamID hook -typedef IHookChain IRehldsHook_Steam_GSGetSteamID; -typedef IHookChainRegistry IRehldsHookRegistry_Steam_GSGetSteamID; - -//SV_TransferConsistencyInfo hook -typedef IHookChain IRehldsHook_SV_TransferConsistencyInfo; -typedef IHookChainRegistry IRehldsHookRegistry_SV_TransferConsistencyInfo; - -//Steam_GSBUpdateUserData hook -typedef IHookChain IRehldsHook_Steam_GSBUpdateUserData; -typedef IHookChainRegistry IRehldsHookRegistry_Steam_GSBUpdateUserData; - -//Cvar_DirectSet hook -typedef IVoidHookChain IRehldsHook_Cvar_DirectSet; -typedef IVoidHookChainRegistry IRehldsHookRegistry_Cvar_DirectSet; - -//SV_EstablishTimeBase hook -typedef IVoidHookChain IRehldsHook_SV_EstablishTimeBase; -typedef IVoidHookChainRegistry IRehldsHookRegistry_SV_EstablishTimeBase; - -//SV_Spawn_f hook -typedef IVoidHookChain<> IRehldsHook_SV_Spawn_f; -typedef IVoidHookChainRegistry<> IRehldsHookRegistry_SV_Spawn_f; - -//SV_CreatePacketEntities hook -typedef IHookChain IRehldsHook_SV_CreatePacketEntities; -typedef IHookChainRegistry IRehldsHookRegistry_SV_CreatePacketEntities; - -//SV_EmitSound2 hook -typedef IHookChain IRehldsHook_SV_EmitSound2; -typedef IHookChainRegistry IRehldsHookRegistry_SV_EmitSound2; - -class IRehldsHookchains { -public: - virtual ~IRehldsHookchains() { } - - virtual IRehldsHookRegistry_Steam_NotifyClientConnect* Steam_NotifyClientConnect() = 0; - virtual IRehldsHookRegistry_SV_ConnectClient* SV_ConnectClient() = 0; - virtual IRehldsHookRegistry_SV_GetIDString* SV_GetIDString() = 0; - virtual IRehldsHookRegistry_SV_SendServerinfo* SV_SendServerinfo() = 0; - virtual IRehldsHookRegistry_SV_CheckProtocol* SV_CheckProtocol() = 0; - virtual IRehldsHookRegistry_SVC_GetChallenge_mod* SVC_GetChallenge_mod() = 0; - virtual IRehldsHookRegistry_SV_CheckKeyInfo* SV_CheckKeyInfo() = 0; - virtual IRehldsHookRegistry_SV_CheckIPRestrictions* SV_CheckIPRestrictions() = 0; - virtual IRehldsHookRegistry_SV_FinishCertificateCheck* SV_FinishCertificateCheck() = 0; - virtual IRehldsHookRegistry_Steam_NotifyBotConnect* Steam_NotifyBotConnect() = 0; - virtual IRehldsHookRegistry_SerializeSteamId* SerializeSteamId() = 0; - virtual IRehldsHookRegistry_SV_CompareUserID* SV_CompareUserID() = 0; - virtual IRehldsHookRegistry_Steam_NotifyClientDisconnect* Steam_NotifyClientDisconnect() = 0; - virtual IRehldsHookRegistry_PreprocessPacket* PreprocessPacket() = 0; - virtual IRehldsHookRegistry_ValidateCommand* ValidateCommand() = 0; - virtual IRehldsHookRegistry_ClientConnected* ClientConnected() = 0; - virtual IRehldsHookRegistry_HandleNetCommand* HandleNetCommand() = 0; - virtual IRehldsHookRegistry_Mod_LoadBrushModel* Mod_LoadBrushModel() = 0; - virtual IRehldsHookRegistry_Mod_LoadStudioModel* Mod_LoadStudioModel() = 0; - virtual IRehldsHookRegistry_ExecuteServerStringCmd* ExecuteServerStringCmd() = 0; - virtual IRehldsHookRegistry_SV_EmitEvents* SV_EmitEvents() = 0; - virtual IRehldsHookRegistry_EV_PlayReliableEvent* EV_PlayReliableEvent() = 0; - virtual IRehldsHookRegistry_SV_StartSound* SV_StartSound() = 0; - virtual IRehldsHookRegistry_PF_Remove_I* PF_Remove_I() = 0; - virtual IRehldsHookRegistry_PF_BuildSoundMsg_I* PF_BuildSoundMsg_I() = 0; - virtual IRehldsHookRegistry_SV_WriteFullClientUpdate* SV_WriteFullClientUpdate() = 0; - virtual IRehldsHookRegistry_SV_CheckConsistencyResponse* SV_CheckConsistencyResponse() = 0; - virtual IRehldsHookRegistry_SV_DropClient* SV_DropClient() = 0; - virtual IRehldsHookRegistry_SV_ActivateServer* SV_ActivateServer() = 0; - virtual IRehldsHookRegistry_SV_WriteVoiceCodec* SV_WriteVoiceCodec() = 0; - virtual IRehldsHookRegistry_Steam_GSGetSteamID* Steam_GSGetSteamID() = 0; - virtual IRehldsHookRegistry_SV_TransferConsistencyInfo* SV_TransferConsistencyInfo() = 0; - virtual IRehldsHookRegistry_Steam_GSBUpdateUserData* Steam_GSBUpdateUserData() = 0; - virtual IRehldsHookRegistry_Cvar_DirectSet* Cvar_DirectSet() = 0; - virtual IRehldsHookRegistry_SV_EstablishTimeBase* SV_EstablishTimeBase() = 0; - virtual IRehldsHookRegistry_SV_Spawn_f* SV_Spawn_f() = 0; - virtual IRehldsHookRegistry_SV_CreatePacketEntities* SV_CreatePacketEntities() = 0; - virtual IRehldsHookRegistry_SV_EmitSound2* SV_EmitSound2() = 0; -}; - -struct RehldsFuncs_t { - void(*DropClient)(IGameClient* cl, bool crash, const char* fmt, ...); - void(*RejectConnection)(netadr_t *adr, char *fmt, ...); - qboolean(*SteamNotifyBotConnect)(IGameClient* cl); - sizebuf_t*(*GetNetMessage)(); - IGameClient*(*GetHostClient)(); - int*(*GetMsgReadCount)(); - qboolean(*FilterUser)(USERID_t*); - void(*NET_SendPacket)(unsigned int length, void *data, const netadr_t &to); - void(*TokenizeString)(char* s); - bool(*CheckChallenge)(const netadr_t& adr, int challenge); - void(*SendUserReg)(sizebuf_t* msg); - void(*WriteDeltaDescriptionsToClient)(sizebuf_t* msg); - void(*SetMoveVars)(); - void(*WriteMovevarsToClient)(sizebuf_t* msg); - char*(*GetClientFallback)(); - int*(*GetAllowCheats)(); - bool(*GSBSecure)(); - int(*GetBuildNumber)(); - double(*GetRealTime)(); - int*(*GetMsgBadRead)(); - cmd_source_t*(*GetCmdSource)(); - void(*Log)(const char* prefix, const char* msg); - DLL_FUNCTIONS *(*GetEntityInterface)(); - void(*EV_PlayReliableEvent)(IGameClient *cl, int entindex, unsigned short eventindex, float delay, struct event_args_s *pargs); - int(*SV_LookupSoundIndex)(const char *sample); - void(*MSG_StartBitWriting)(sizebuf_t *buf); - void(*MSG_WriteBits)(uint32 data, int numbits); - void(*MSG_WriteBitVec3Coord)(const float *fa); - void(*MSG_EndBitWriting)(sizebuf_t *buf); - void*(*SZ_GetSpace)(sizebuf_t *buf, int length); - cvar_t*(*GetCvarVars)(); - int (*SV_GetChallenge)(const netadr_t& adr); - void (*SV_AddResource)(resourcetype_t type, const char *name, int size, unsigned char flags, int index); - int(*MSG_ReadShort)(void); - int(*MSG_ReadBuf)(int iSize, void *pbuf); - void(*MSG_WriteBuf)(sizebuf_t *sb, int iSize, void *buf); - void(*MSG_WriteByte)(sizebuf_t *sb, int c); - void(*MSG_WriteShort)(sizebuf_t *sb, int c); - void(*MSG_WriteString)(sizebuf_t *sb, const char *s); - void*(*GetPluginApi)(const char *name); - void(*RegisterPluginApi)(const char *name, void *impl); - qboolean(*SV_FileInConsistencyList)(const char *filename, struct consistency_s **ppconsist); - qboolean(*Steam_NotifyClientConnect)(IGameClient *cl, const void *pvSteam2Key, unsigned int ucbSteam2Key); - void(*Steam_NotifyClientDisconnect)(IGameClient* cl); - void(*SV_StartSound)(int recipients, edict_t *entity, int channel, const char *sample, int volume, float attenuation, int flags, int pitch); - bool(*SV_EmitSound2)(edict_t *entity, IGameClient *receiver, int channel, const char *sample, float volume, float attenuation, int flags, int pitch, int emitFlags, const float *pOrigin); - void(*SV_UpdateUserInfo)(IGameClient *pGameClient); - bool(*StripUnprintableAndSpace)(char *pch); -}; - -class IRehldsApi { -public: - virtual ~IRehldsApi() { } - - virtual int GetMajorVersion() = 0; - virtual int GetMinorVersion() = 0; - virtual const RehldsFuncs_t* GetFuncs() = 0; - virtual IRehldsHookchains* GetHookchains() = 0; - virtual IRehldsServerStatic* GetServerStatic() = 0; - virtual IRehldsServerData* GetServerData() = 0; - virtual IRehldsFlightRecorder* GetFlightRecorder() = 0; -}; - -#define VREHLDS_HLDS_API_VERSION "VREHLDS_HLDS_API_VERSION001" \ No newline at end of file diff --git a/regamedll/extra/cssdk/engine/rehlds_interfaces.h b/regamedll/extra/cssdk/engine/rehlds_interfaces.h deleted file mode 100644 index e2b909fa..00000000 --- a/regamedll/extra/cssdk/engine/rehlds_interfaces.h +++ /dev/null @@ -1,132 +0,0 @@ -/* -* -* This program is free software; you can redistribute it and/or modify it -* under the terms of the GNU General Public License as published by the -* Free Software Foundation; either version 2 of the License, or (at -* your option) any later version. -* -* This program 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 -* General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* -*/ -#pragma once - -class INetChan; -class IGameClient; - -#include "archtypes.h" -#include "const.h" -#include "netadr.h" - -#include "common_rehlds.h" -#include "userid_rehlds.h" - -#ifdef REHLDS_SELF -#include "server.h" -#endif - -class INetChan; -class IGameClient; - -class IGameClient { -public: - virtual int GetId() = 0; - - virtual bool IsActive() = 0; - virtual void SetActive(bool active) = 0; - - virtual bool IsSpawned() = 0; - virtual void SetSpawned(bool spawned) = 0; - - virtual INetChan* GetNetChan() = 0; - - virtual sizebuf_t* GetDatagram() = 0; - - virtual edict_t* GetEdict() = 0; - - virtual USERID_t* GetNetworkUserID() = 0; - - virtual const char* GetName() = 0; - - virtual bool IsConnected() = 0; - virtual void SetConnected(bool connected) = 0; - - virtual uint32 GetVoiceStream(int stream_id) = 0; - virtual void SetLastVoiceTime(double time) = 0; - virtual double GetLastVoiceTime() = 0; - virtual bool GetLoopback() = 0; - virtual struct usercmd_s *GetLastCmd() = 0; - - // this must be the last virtual function in class -#ifdef REHLDS_SELF - virtual client_t* GetClient() = 0; -#endif -}; - -class INetChan { -public: - virtual const netadr_t* GetRemoteAdr() = 0; - virtual sizebuf_t* GetMessageBuf() = 0; - - - // this must be the last virtual function in class -#ifdef REHLDS_SELF - virtual netchan_t* GetChan() = 0; -#endif -}; - -#ifndef REHLDS_SELF -struct client_t; -#endif - -class IRehldsServerStatic { -public: - virtual ~IRehldsServerStatic() { } - - virtual int GetMaxClients() = 0; - virtual bool IsLogActive() = 0; - virtual IGameClient* GetClient(int id) = 0; - virtual client_t* GetClient_t(int id) = 0; - virtual int GetIndexOfClient_t(client_t* client) = 0; -}; - -class IRehldsServerData { -public: - virtual ~IRehldsServerData() { } - - virtual const char* GetModelName() = 0; - virtual const char* GetName() = 0; - virtual uint32 GetWorldmapCrc() = 0; - virtual uint8* GetClientDllMd5() = 0; - virtual sizebuf_t* GetDatagram() = 0; - virtual sizebuf_t* GetReliableDatagram() = 0; - - virtual void SetModelName(const char* modelname) = 0; - virtual void SetConsistencyNum(int num) = 0; - virtual int GetConsistencyNum() = 0; - virtual int GetResourcesNum() = 0; - virtual int GetDecalNameNum() = 0; - - virtual double GetTime() = 0; - virtual void SetResourcesNum(int num) = 0; - virtual struct resource_s *GetResource(int index) = 0; - virtual void SetName(const char* name) = 0; - virtual class ISteamGameServer *GetSteamGameServer() = 0; - virtual struct netadr_s *GetNetFrom() = 0; -}; diff --git a/regamedll/extra/cssdk/engine/shake.h b/regamedll/extra/cssdk/engine/shake.h deleted file mode 100644 index 1146a5e7..00000000 --- a/regamedll/extra/cssdk/engine/shake.h +++ /dev/null @@ -1,57 +0,0 @@ -/*** -* -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ -#ifndef SHAKE_H -#define SHAKE_H - -// Screen / View effects - -// screen shake -extern int gmsgShake; - -// This structure is sent over the net to describe a screen shake event -typedef struct -{ - unsigned short amplitude; // FIXED 4.12 amount of shake - unsigned short duration; // FIXED 4.12 seconds duration - unsigned short frequency; // FIXED 8.8 noise frequency (low frequency is a jerk,high frequency is a rumble) -} ScreenShake; - -extern void V_ApplyShake( float *origin, float *angles, float factor ); -extern void V_CalcShake( void ); -extern int V_ScreenShake( const char *pszName, int iSize, void *pbuf ); -extern int V_ScreenFade( const char *pszName, int iSize, void *pbuf ); - - -// Fade in/out -extern int gmsgFade; - -#define FFADE_IN 0x0000 // Just here so we don't pass 0 into the function -#define FFADE_OUT 0x0001 // Fade out (not in) -#define FFADE_MODULATE 0x0002 // Modulate (don't blend) -#define FFADE_STAYOUT 0x0004 // ignores the duration, stays faded out until new ScreenFade message received -#define FFADE_LONGFADE 0x0008 // used to indicate the fade can be longer than 16 seconds (added for czero) - - -// This structure is sent over the net to describe a screen fade event -typedef struct -{ - unsigned short duration; // FIXED 4.12 seconds duration - unsigned short holdTime; // FIXED 4.12 seconds duration until reset (fade & hold) - short fadeFlags; // flags - byte r, g, b, a; // fade to color ( max alpha ) -} ScreenFade; - -#endif // SHAKE_H - diff --git a/regamedll/extra/cssdk/engine/spritegn.h b/regamedll/extra/cssdk/engine/spritegn.h deleted file mode 100644 index f6145d78..00000000 --- a/regamedll/extra/cssdk/engine/spritegn.h +++ /dev/null @@ -1,84 +0,0 @@ -/* -* -* This program is free software; you can redistribute it and/or modify it -* under the terms of the GNU General Public License as published by the -* Free Software Foundation; either version 2 of the License, or (at -* your option) any later version. -* -* This program 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 -* General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* -*/ - -#ifndef SPRITEGN_H -#define SPRITEGN_H -#ifdef _WIN32 -#pragma once -#endif - -#include "modelgen.h" -#include "commonmacros.h" - -#define SPRITE_VERSION 2 // Half-Life sprites -#define IDSPRITEHEADER MAKEID('I', 'D', 'S', 'P') // little-endian "IDSP" - -typedef enum spriteframetype_e -{ - SPR_SINGLE = 0, - SPR_GROUP, - SPR_ANGLED -} spriteframetype_t; - -typedef struct dsprite_s -{ - int ident; - int version; - int type; - int texFormat; - float boundingradius; - int width; - int height; - int numframes; - float beamlength; - synctype_t synctype; -} dsprite_t; - -typedef struct dspriteframe_s -{ - int origin[2]; - int width; - int height; -} dspriteframe_t; - -typedef struct dspritegroup_s -{ - int numframes; -} dspritegroup_t; - -typedef struct dspriteinterval_s -{ - float interval; -} dspriteinterval_t; - -typedef struct dspriteframetype_s -{ - spriteframetype_t type; -} dspriteframetype_t; - -#endif // SPRITEGN_H diff --git a/regamedll/extra/cssdk/engine/static_map.h b/regamedll/extra/cssdk/engine/static_map.h deleted file mode 100644 index 2ec89c70..00000000 --- a/regamedll/extra/cssdk/engine/static_map.h +++ /dev/null @@ -1,257 +0,0 @@ -#pragma once - -#include "archtypes.h" -#include "crc32c.h" - -template -class CStaticMap { -protected: - virtual uint32 hash(const T_KEY& val) { - return crc32c((const unsigned char*)&val, sizeof(T_KEY)); - } - - virtual bool equals(const T_KEY& val1, const T_KEY& val2) { - return 0 == memcmp(&val1, &val2, sizeof(T_KEY)); - } - - struct map_node_t { - map_node_t* prev; - map_node_t* next; - T_KEY key; - T_VAL val; - }; - -private: - map_node_t* m_RootNodes[1 << ASSOC_2N]; - map_node_t m_AllNodes[MAX_VALS]; - map_node_t* m_FreeRoot; - - unsigned int GetRoodNodeId(const T_KEY& val) { return hash(val) & (0xFFFFFFFF >> (32 - ASSOC_2N)); } - - void unlink(map_node_t* node) { - map_node_t* prev = node->prev; - map_node_t* next = node->next; - - if (prev) { - prev->next = next; - } - - if (next) { - next->prev = prev; - } - - if (!prev) { - // this was a root node - unsigned int rootId = GetRoodNodeId(node->key); - if (m_RootNodes[rootId] != node) { - Sys_Error("%s: invalid root node", __FUNCTION__); - return; - } - - m_RootNodes[rootId] = next; - } - } - - void link(map_node_t* node) { - unsigned int rootId = GetRoodNodeId(node->key); - map_node_t* root = m_RootNodes[rootId]; - node->prev = NULL; - node->next = root; - - if (root) { - root->prev = node; - } - - m_RootNodes[rootId] = node; - } - - void linkToFreeStack(map_node_t* node) { - node->next = m_FreeRoot; - if (m_FreeRoot) { - m_FreeRoot->prev = node; - } - m_FreeRoot = node; - } - -public: - CStaticMap() { - clear(); - } - - void clear() { - memset(m_RootNodes, 0, sizeof(m_RootNodes)); - memset(m_AllNodes, 0, sizeof(m_AllNodes)); - m_FreeRoot = NULL; - - for (int i = 0; i < MAX_VALS; i++) { - linkToFreeStack(&m_AllNodes[i]); - } - } - - map_node_t* get(const T_KEY& key) { - unsigned int rootId = GetRoodNodeId(key); - map_node_t* n = m_RootNodes[rootId]; - while (n) { - if (equals(n->key, key)) { - return n; - } - n = n->next; - } - return NULL; - } - - bool put(const T_KEY& key, T_VAL& val) { - map_node_t* n = get(key); - if (n) { - n->val = val; - return true; - } - - if (!m_FreeRoot) { - return false; - } - - n = m_FreeRoot; - m_FreeRoot = m_FreeRoot->next; - - n->key = key; - n->val = val; - - unsigned int rootId = GetRoodNodeId(key); - map_node_t* root = m_RootNodes[rootId]; - - if (root) { - root->prev = n; - } - - n->prev = NULL; - n->next = root; - m_RootNodes[rootId] = n; - - return true; - } - - void remove(map_node_t* node) { - unlink(node); - linkToFreeStack(node); - } - - bool remove(const T_KEY& key) { - map_node_t* n = get(key); - if (!n) { - return false; - } - - remove(n); - return true; - } - - class Iterator { - friend class CStaticMap; - protected: - CStaticMap* m_Map; - map_node_t** m_RootNodes; - unsigned int m_NextRootNode; - map_node_t* m_CurNode; - - void searchForNextNode() { - if (m_CurNode && m_CurNode->next) { - m_CurNode = m_CurNode->next; - return; - } - - m_CurNode = NULL; - while (!m_CurNode) { - if (m_NextRootNode >= (1 << ASSOC_2N)) { - return; - } - m_CurNode = m_RootNodes[m_NextRootNode++]; - } - } - - - Iterator(CStaticMap* m) { - m_Map = m; - m_RootNodes = m_Map->m_RootNodes; - m_NextRootNode = 0; - m_CurNode = NULL; - searchForNextNode(); - } - - public: - map_node_t* next() { - searchForNextNode(); - return m_CurNode; - } - - map_node_t* current() { - return m_CurNode; - } - - void remove() { - m_Map->remove(m_CurNode); - m_CurNode = NULL; - } - - bool hasElement() { - return m_CurNode != NULL; - } - }; - - Iterator iterator() { - return Iterator(this); - } -}; - -template -class CStringKeyStaticMap : public CStaticMap { -protected: - virtual uint32 hash(const char* const &val) { - return crc32c((const unsigned char*)val, strlen(val)); - } - - virtual bool equals(const char* const &val1, const char* const &val2) { - return !strcmp(val1, val2); - } - -public: - CStringKeyStaticMap() { - } - -}; - -template -class CICaseStringKeyStaticMap : public CStaticMap { -protected: - virtual uint32 hash(const char* const &val) { - uint32 cksum = 0; - const char* pcc = val; - if (cpuinfo.sse4_2) { - while (*pcc) { - char cc = *(pcc++); - if (cc >= 'A' || cc <= 'Z') { - cc |= 0x20; - } - cksum = crc32c_t8_sse(cksum, cc); - } - } else { - while (*pcc) { - char cc = *(pcc++); - if (cc >= 'A' || cc <= 'Z') { - cc |= 0x20; - } - cksum = crc32c_t8_nosse(cksum, cc); - } - } - return cksum; - } - - virtual bool equals(const char* const &val1, const char* const &val2) { - return !_stricmp(val1, val2); - } - -public: - CICaseStringKeyStaticMap() { - } - -}; diff --git a/regamedll/extra/cssdk/engine/studio.h b/regamedll/extra/cssdk/engine/studio.h deleted file mode 100644 index 412543e1..00000000 --- a/regamedll/extra/cssdk/engine/studio.h +++ /dev/null @@ -1,361 +0,0 @@ -/*** -* -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ -#pragma once - -/* -============================================================================== - -STUDIO MODELS - -Studio models are position independent, so the cache manager can move them. -============================================================================== -*/ - - -#define MAXSTUDIOTRIANGLES 20000 // TODO: tune this -#define MAXSTUDIOVERTS 2048 // TODO: tune this -#define MAXSTUDIOSEQUENCES 2048 // total animation sequences -#define MAXSTUDIOSKINS 100 // total textures -#define MAXSTUDIOSRCBONES 512 // bones allowed at source movement -#define MAXSTUDIOBONES 128 // total bones actually used -#define MAXSTUDIOMODELS 32 // sub-models per model -#define MAXSTUDIOBODYPARTS 32 -#define MAXSTUDIOGROUPS 16 -#define MAXSTUDIOANIMATIONS 2048 // per sequence -#define MAXSTUDIOMESHES 256 -#define MAXSTUDIOEVENTS 1024 -#define MAXSTUDIOPIVOTS 256 -#define MAXSTUDIOCONTROLLERS 8 - -typedef struct -{ - int id; - int version; - - char name[64]; - int length; - - vec3_t eyeposition; // ideal eye position - vec3_t min; // ideal movement hull size - vec3_t max; - - vec3_t bbmin; // clipping bounding box - vec3_t bbmax; - - int flags; - - int numbones; // bones - int boneindex; - - int numbonecontrollers; // bone controllers - int bonecontrollerindex; - - int numhitboxes; // complex bounding boxes - int hitboxindex; - - int numseq; // animation sequences - int seqindex; - - int numseqgroups; // demand loaded sequences - int seqgroupindex; - - int numtextures; // raw textures - int textureindex; - int texturedataindex; - - int numskinref; // replaceable textures - int numskinfamilies; - int skinindex; - - int numbodyparts; - int bodypartindex; - - int numattachments; // queryable attachable points - int attachmentindex; - - int soundtable; - int soundindex; - int soundgroups; - int soundgroupindex; - - int numtransitions; // animation node to animation node transition graph - int transitionindex; -} studiohdr_t; - -// header for demand loaded sequence group data -typedef struct -{ - int id; - int version; - - char name[64]; - int length; -} studioseqhdr_t; - -// bones -typedef struct -{ - char name[32]; // bone name for symbolic links - int parent; // parent bone - int flags; // ?? - int bonecontroller[6]; // bone controller index, -1 == none - float value[6]; // default DoF values - float scale[6]; // scale for delta DoF values -} mstudiobone_t; - - -// bone controllers -typedef struct -{ - int bone; // -1 == 0 - int type; // X, Y, Z, XR, YR, ZR, M - float start; - float end; - int rest; // byte index value at rest - int index; // 0-3 user set controller, 4 mouth -} mstudiobonecontroller_t; - -// intersection boxes -typedef struct -{ - int bone; - int group; // intersection group - vec3_t bbmin; // bounding box - vec3_t bbmax; -} mstudiobbox_t; - -// demand loaded sequence groups -typedef struct -{ - char label[32]; // textual name - char name[64]; // file name - int32 unused1; // was "cache" - index pointer - int unused2; // was "data" - hack for group 0 -} mstudioseqgroup_t; - -// sequence descriptions -typedef struct -{ - char label[32]; // sequence label - - float fps; // frames per second - int flags; // looping/non-looping flags - - int activity; - int actweight; - - int numevents; - int eventindex; - - int numframes; // number of frames per sequence - - int numpivots; // number of foot pivots - int pivotindex; - - int motiontype; - int motionbone; - vec3_t linearmovement; - int automoveposindex; - int automoveangleindex; - - vec3_t bbmin; // per sequence bounding box - vec3_t bbmax; - - int numblends; - int animindex; // mstudioanim_t pointer relative to start of sequence group data - // [blend][bone][X, Y, Z, XR, YR, ZR] - - int blendtype[2]; // X, Y, Z, XR, YR, ZR - float blendstart[2]; // starting value - float blendend[2]; // ending value - int blendparent; - - int seqgroup; // sequence group for demand loading - - int entrynode; // transition node at entry - int exitnode; // transition node at exit - int nodeflags; // transition rules - - int nextseq; // auto advancing sequences -} mstudioseqdesc_t; - -// events -#include "studio_event.h" -/* -typedef struct -{ - int frame; - int event; - int type; - char options[64]; -} mstudioevent_t; -*/ - -// pivots -typedef struct -{ - vec3_t org; // pivot point - int start; - int end; -} mstudiopivot_t; - -// attachment -typedef struct -{ - char name[32]; - int type; - int bone; - vec3_t org; // attachment point - vec3_t vectors[3]; -} mstudioattachment_t; - -typedef struct -{ - unsigned short offset[6]; -} mstudioanim_t; - -// animation frames -typedef union -{ - struct { - byte valid; - byte total; - } num; - short value; -} mstudioanimvalue_t; - - - -// body part index -typedef struct -{ - char name[64]; - int nummodels; - int base; - int modelindex; // index into models array -} mstudiobodyparts_t; - - - -// skin info -typedef struct -{ - char name[64]; - int flags; - int width; - int height; - int index; -} mstudiotexture_t; - - -// skin families -// short index[skinfamilies][skinref] - -// studio models -typedef struct -{ - char name[64]; - - int type; - - float boundingradius; - - int nummesh; - int meshindex; - - int numverts; // number of unique vertices - int vertinfoindex; // vertex bone info - int vertindex; // vertex vec3_t - int numnorms; // number of unique surface normals - int norminfoindex; // normal bone info - int normindex; // normal vec3_t - - int numgroups; // deformation groups - int groupindex; -} mstudiomodel_t; - - -// vec3_t boundingbox[model][bone][2]; // complex intersection info - - -// meshes -typedef struct -{ - int numtris; - int triindex; - int skinref; - int numnorms; // per mesh normals - int normindex; // normal vec3_t -} mstudiomesh_t; - -// triangles -#if 0 -typedef struct -{ - short vertindex; // index into vertex array - short normindex; // index into normal array - short s,t; // s,t position on skin -} mstudiotrivert_t; -#endif - -#define STUDIO_DYNAMIC_LIGHT 0x0100 // dynamically get lighting from floor or ceil (flying monsters) -#define STUDIO_TRACE_HITBOX 0x0200 // always use hitbox trace instead of bbox - -// lighting options -#define STUDIO_NF_FLATSHADE 0x0001 -#define STUDIO_NF_CHROME 0x0002 -#define STUDIO_NF_FULLBRIGHT 0x0004 -#define STUDIO_NF_NOMIPS 0x0008 -#define STUDIO_NF_ALPHA 0x0010 -#define STUDIO_NF_ADDITIVE 0x0020 -#define STUDIO_NF_MASKED 0x0040 - -// motion flags -#define STUDIO_X 0x0001 -#define STUDIO_Y 0x0002 -#define STUDIO_Z 0x0004 -#define STUDIO_XR 0x0008 -#define STUDIO_YR 0x0010 -#define STUDIO_ZR 0x0020 -#define STUDIO_LX 0x0040 -#define STUDIO_LY 0x0080 -#define STUDIO_LZ 0x0100 -#define STUDIO_AX 0x0200 -#define STUDIO_AY 0x0400 -#define STUDIO_AZ 0x0800 -#define STUDIO_AXR 0x1000 -#define STUDIO_AYR 0x2000 -#define STUDIO_AZR 0x4000 -#define STUDIO_TYPES 0x7FFF -#define STUDIO_RLOOP 0x8000 // controller that wraps shortest distance - -// sequence flags -#define STUDIO_LOOPING 0x0001 - -// bone flags -#define STUDIO_HAS_NORMALS 0x0001 -#define STUDIO_HAS_VERTICES 0x0002 -#define STUDIO_HAS_BBOX 0x0004 -#define STUDIO_HAS_CHROME 0x0008 // if any of the textures have chrome on them - -#define RAD_TO_STUDIO (32768.0/M_PI) -#define STUDIO_TO_RAD (M_PI/32768.0) - - -#define STUDIO_NUM_HULLS 128 -#define STUDIO_NUM_PLANES (STUDIO_NUM_HULLS * 6) -#define STUDIO_CACHE_SIZE 16 - - diff --git a/regamedll/extra/cssdk/engine/sys_shared.cpp b/regamedll/extra/cssdk/engine/sys_shared.cpp deleted file mode 100644 index a642c768..00000000 --- a/regamedll/extra/cssdk/engine/sys_shared.cpp +++ /dev/null @@ -1,72 +0,0 @@ -/* -* -* This program is free software; you can redistribute it and/or modify it -* under the terms of the GNU General Public License as published by the -* Free Software Foundation; either version 2 of the License, or (at -* your option) any later version. -* -* This program 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 -* General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* -*/ -#include "sys_shared.h" - -#if defined(__GNUC__) -#include -#endif - -#define SSE3_FLAG (1<<0) -#define SSSE3_FLAG (1<<9) -#define SSE4_1_FLAG (1<<19) -#define SSE4_2_FLAG (1<<20) -#define POPCNT_FLAG (1<<23) -#define AVX_FLAG (1<<28) -#define AVX2_FLAG (1<<5) - -cpuinfo_t cpuinfo; - -void Sys_CheckCpuInstructionsSupport(void) -{ - unsigned int cpuid_data[4]; - -#if defined ASMLIB_H - cpuid_ex((int *)cpuid_data, 1, 0); -#elif defined(__GNUC__) - __get_cpuid(0x1, &cpuid_data[0], &cpuid_data[1], &cpuid_data[2], &cpuid_data[3]); -#else - __cpuidex((int *)cpuid_data, 1, 0); -#endif - - cpuinfo.sse3 = (cpuid_data[2] & SSE3_FLAG) ? 1 : 0; // ecx - cpuinfo.ssse3 = (cpuid_data[2] & SSSE3_FLAG) ? 1 : 0; - cpuinfo.sse4_1 = (cpuid_data[2] & SSE4_1_FLAG) ? 1 : 0; - cpuinfo.sse4_2 = (cpuid_data[2] & SSE4_2_FLAG) ? 1 : 0; - cpuinfo.popcnt = (cpuid_data[2] & POPCNT_FLAG) ? 1 : 0; - cpuinfo.avx = (cpuid_data[2] & AVX_FLAG) ? 1 : 0; - -#if defined ASMLIB_H - cpuid_ex((int *)cpuid_data, 7, 0); -#elif defined(__GNUC__) - __get_cpuid(0x7, &cpuid_data[0], &cpuid_data[1], &cpuid_data[2], &cpuid_data[3]); -#else - __cpuidex((int *)cpuid_data, 7, 0); -#endif - - cpuinfo.avx2 = (cpuid_data[1] & AVX2_FLAG) ? 1 : 0; // ebx -} \ No newline at end of file diff --git a/regamedll/extra/cssdk/engine/sys_shared.h b/regamedll/extra/cssdk/engine/sys_shared.h deleted file mode 100644 index 5b5da981..00000000 --- a/regamedll/extra/cssdk/engine/sys_shared.h +++ /dev/null @@ -1,39 +0,0 @@ -/* -* -* This program is free software; you can redistribute it and/or modify it -* under the terms of the GNU General Public License as published by the -* Free Software Foundation; either version 2 of the License, or (at -* your option) any later version. -* -* This program 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 -* General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* -*/ -#pragma once - -#include - -typedef struct cpuinfo_s -{ - uint8 sse3, ssse3, sse4_1, sse4_2, avx, avx2, popcnt; -} cpuinfo_t; - -extern cpuinfo_t cpuinfo; - -void Sys_CheckCpuInstructionsSupport(void); diff --git a/regamedll/extra/cssdk/engine/userid_rehlds.h b/regamedll/extra/cssdk/engine/userid_rehlds.h deleted file mode 100644 index 53b76f4b..00000000 --- a/regamedll/extra/cssdk/engine/userid_rehlds.h +++ /dev/null @@ -1,46 +0,0 @@ -/* -* -* This program is free software; you can redistribute it and/or modify it -* under the terms of the GNU General Public License as published by the -* Free Software Foundation; either version 2 of the License, or (at -* your option) any later version. -* -* This program 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 -* General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* -*/ -#pragma once - -#include "archtypes.h" - -// Authentication types -enum AUTH_IDTYPE -{ - AUTH_IDTYPE_UNKNOWN = 0, - AUTH_IDTYPE_STEAM = 1, - AUTH_IDTYPE_VALVE = 2, - AUTH_IDTYPE_LOCAL = 3 -}; - -typedef struct USERID_s -{ - int idtype; - uint64 m_SteamID; - unsigned int clientip; -} USERID_t; diff --git a/regamedll/extra/cssdk/game_shared/GameEvent.h b/regamedll/extra/cssdk/game_shared/GameEvent.h deleted file mode 100644 index c585ffff..00000000 --- a/regamedll/extra/cssdk/game_shared/GameEvent.h +++ /dev/null @@ -1,138 +0,0 @@ -/* -* -* This program is free software; you can redistribute it and/or modify it -* under the terms of the GNU General Public License as published by the -* Free Software Foundation; either version 2 of the License, or (at -* your option) any later version. -* -* This program 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 -* General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* -*/ -#pragma once - -enum GameEventType -{ - EVENT_INVALID = 0, - EVENT_WEAPON_FIRED, // tell bots the player is attack (argumens: 1 = attacker, 2 = NULL) - EVENT_WEAPON_FIRED_ON_EMPTY, // tell bots the player is attack without clip ammo (argumens: 1 = attacker, 2 = NULL) - EVENT_WEAPON_RELOADED, // tell bots the player is reloading his weapon (argumens: 1 = reloader, 2 = NULL) - - EVENT_HE_GRENADE_EXPLODED, // tell bots the HE grenade is exploded (argumens: 1 = grenade thrower, 2 = NULL) - EVENT_FLASHBANG_GRENADE_EXPLODED, // tell bots the flashbang grenade is exploded (argumens: 1 = grenade thrower, 2 = explosion origin) - EVENT_SMOKE_GRENADE_EXPLODED, // tell bots the smoke grenade is exploded (argumens: 1 = grenade thrower, 2 = NULL) - EVENT_GRENADE_BOUNCED, - - EVENT_BEING_SHOT_AT, - EVENT_PLAYER_BLINDED_BY_FLASHBANG, // tell bots the player is flashed (argumens: 1 = flashed player, 2 = NULL) - EVENT_PLAYER_FOOTSTEP, // tell bots the player is running (argumens: 1 = runner, 2 = NULL) - EVENT_PLAYER_JUMPED, // tell bots the player is jumped (argumens: 1 = jumper, 2 = NULL) - EVENT_PLAYER_DIED, // tell bots the player is killed (argumens: 1 = victim, 2 = killer) - EVENT_PLAYER_LANDED_FROM_HEIGHT, // tell bots the player is fell with some damage (argumens: 1 = felled player, 2 = NULL) - EVENT_PLAYER_TOOK_DAMAGE, // tell bots the player is take damage (argumens: 1 = victim, 2 = attacker) - EVENT_HOSTAGE_DAMAGED, // tell bots the player has injured a hostage (argumens: 1 = hostage, 2 = injurer) - EVENT_HOSTAGE_KILLED, // tell bots the player has killed a hostage (argumens: 1 = hostage, 2 = killer) - - EVENT_DOOR, // tell bots the door is moving (argumens: 1 = door, 2 = NULL) - EVENT_BREAK_GLASS, // tell bots the glass has break (argumens: 1 = glass, 2 = NULL) - EVENT_BREAK_WOOD, // tell bots the wood has break (argumens: 1 = wood, 2 = NULL) - EVENT_BREAK_METAL, // tell bots the metal/computer has break (argumens: 1 = metal/computer, 2 = NULL) - EVENT_BREAK_FLESH, // tell bots the flesh has break (argumens: 1 = flesh, 2 = NULL) - EVENT_BREAK_CONCRETE, // tell bots the concrete has break (argumens: 1 = concrete, 2 = NULL) - - EVENT_BOMB_PLANTED, // tell bots the bomb has been planted (argumens: 1 = planter, 2 = NULL) - EVENT_BOMB_DROPPED, // tell bots the bomb has been dropped (argumens: 1 = NULL, 2 = NULL) - EVENT_BOMB_PICKED_UP, // let the bots hear the bomb pickup (argumens: 1 = player that pickup c4, 2 = NULL) - EVENT_BOMB_BEEP, // let the bots hear the bomb beeping (argumens: 1 = c4, 2 = NULL) - EVENT_BOMB_DEFUSING, // tell the bots someone has started defusing (argumens: 1 = defuser, 2 = NULL) - EVENT_BOMB_DEFUSE_ABORTED, // tell the bots someone has aborted defusing (argumens: 1 = NULL, 2 = NULL) - EVENT_BOMB_DEFUSED, // tell the bots the bomb is defused (argumens: 1 = defuser, 2 = NULL) - EVENT_BOMB_EXPLODED, // let the bots hear the bomb exploding (argumens: 1 = NULL, 2 = NULL) - - EVENT_HOSTAGE_USED, // tell bots the hostage is used (argumens: 1 = user, 2 = NULL) - EVENT_HOSTAGE_RESCUED, // tell bots the hostage is rescued (argumens: 1 = rescuer (CBasePlayer *), 2 = hostage (CHostage *)) - EVENT_ALL_HOSTAGES_RESCUED, // tell bots the all hostages are rescued (argumens: 1 = NULL, 2 = NULL) - - EVENT_VIP_ESCAPED, // tell bots the VIP is escaped (argumens: 1 = NULL, 2 = NULL) - EVENT_VIP_ASSASSINATED, // tell bots the VIP is assassinated (argumens: 1 = NULL, 2 = NULL) - EVENT_TERRORISTS_WIN, // tell bots the terrorists won the round (argumens: 1 = NULL, 2 = NULL) - EVENT_CTS_WIN, // tell bots the CTs won the round (argumens: 1 = NULL, 2 = NULL) - EVENT_ROUND_DRAW, // tell bots the round was a draw (argumens: 1 = NULL, 2 = NULL) - EVENT_ROUND_WIN, // tell carreer the round was a win (argumens: 1 = NULL, 2 = NULL) - EVENT_ROUND_LOSS, // tell carreer the round was a loss (argumens: 1 = NULL, 2 = NULL) - EVENT_ROUND_START, // tell bots the round was started (when freeze period is expired) (argumens: 1 = NULL, 2 = NULL) - EVENT_PLAYER_SPAWNED, // tell bots the player is spawned (argumens: 1 = spawned player, 2 = NULL) - EVENT_CLIENT_CORPSE_SPAWNED, - EVENT_BUY_TIME_START, - EVENT_PLAYER_LEFT_BUY_ZONE, - EVENT_DEATH_CAMERA_START, - EVENT_KILL_ALL, - EVENT_ROUND_TIME, - EVENT_DIE, - EVENT_KILL, - EVENT_HEADSHOT, - EVENT_KILL_FLASHBANGED, - EVENT_TUTOR_BUY_MENU_OPENNED, - EVENT_TUTOR_AUTOBUY, - EVENT_PLAYER_BOUGHT_SOMETHING, - EVENT_TUTOR_NOT_BUYING_ANYTHING, - EVENT_TUTOR_NEED_TO_BUY_PRIMARY_WEAPON, - EVENT_TUTOR_NEED_TO_BUY_PRIMARY_AMMO, - EVENT_TUTOR_NEED_TO_BUY_SECONDARY_AMMO, - EVENT_TUTOR_NEED_TO_BUY_ARMOR, - EVENT_TUTOR_NEED_TO_BUY_DEFUSE_KIT, - EVENT_TUTOR_NEED_TO_BUY_GRENADE, - EVENT_CAREER_TASK_DONE, - - EVENT_START_RADIO_1, - EVENT_RADIO_COVER_ME, - EVENT_RADIO_YOU_TAKE_THE_POINT, - EVENT_RADIO_HOLD_THIS_POSITION, - EVENT_RADIO_REGROUP_TEAM, - EVENT_RADIO_FOLLOW_ME, - EVENT_RADIO_TAKING_FIRE, - EVENT_START_RADIO_2, - EVENT_RADIO_GO_GO_GO, - EVENT_RADIO_TEAM_FALL_BACK, - EVENT_RADIO_STICK_TOGETHER_TEAM, - EVENT_RADIO_GET_IN_POSITION_AND_WAIT, - EVENT_RADIO_STORM_THE_FRONT, - EVENT_RADIO_REPORT_IN_TEAM, - EVENT_START_RADIO_3, - EVENT_RADIO_AFFIRMATIVE, - EVENT_RADIO_ENEMY_SPOTTED, - EVENT_RADIO_NEED_BACKUP, - EVENT_RADIO_SECTOR_CLEAR, - EVENT_RADIO_IN_POSITION, - EVENT_RADIO_REPORTING_IN, - EVENT_RADIO_GET_OUT_OF_THERE, - EVENT_RADIO_NEGATIVE, - EVENT_RADIO_ENEMY_DOWN, - EVENT_END_RADIO, - - EVENT_NEW_MATCH, // tell bots the game is new (argumens: 1 = NULL, 2 = NULL) - EVENT_PLAYER_CHANGED_TEAM, // tell bots the player is switch his team (also called from ClientPutInServer()) (argumens: 1 = switcher, 2 = NULL) - EVENT_BULLET_IMPACT, // tell bots the player is shoot at wall (argumens: 1 = shooter, 2 = shoot trace end position) - EVENT_GAME_COMMENCE, // tell bots the game is commencing (argumens: 1 = NULL, 2 = NULL) - EVENT_WEAPON_ZOOMED, // tell bots the player is switch weapon zoom (argumens: 1 = zoom switcher, 2 = NULL) - EVENT_HOSTAGE_CALLED_FOR_HELP, // tell bots the hostage is talking (argumens: 1 = listener, 2 = NULL) - NUM_GAME_EVENTS, -}; - -extern const char *GameEventName[ NUM_GAME_EVENTS + 1 ]; diff --git a/regamedll/extra/cssdk/game_shared/bitvec.h b/regamedll/extra/cssdk/game_shared/bitvec.h deleted file mode 100644 index f541bff3..00000000 --- a/regamedll/extra/cssdk/game_shared/bitvec.h +++ /dev/null @@ -1,157 +0,0 @@ -/* -* -* This program is free software; you can redistribute it and/or modify it -* under the terms of the GNU General Public License as published by the -* Free Software Foundation; either version 2 of the License, or (at -* your option) any later version. -* -* This program 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 -* General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* -*/ -#pragma once - -class CBitVecAccessor { -public: - CBitVecAccessor(uint32 *pDWords, int iBit); - - void operator=(int val); - operator uint32(); - -private: - uint32 *m_pDWords; - int m_iBit; -}; - -// CBitVec allows you to store a list of bits and do operations on them like they were -// an atomic type -template -class CBitVec { -public: - CBitVec(); - - // Set all values to the specified value (0 or 1..) - void Init(int val = 0); - - // Access the bits like an array. - CBitVecAccessor operator[](int i); - - // Operations on other bit vectors. - CBitVec &operator=(CBitVec const &other); - bool operator==(CBitVec const &other); - bool operator!=(CBitVec const &other); - - // Get underlying dword representations of the bits. - int GetNumDWords() { return NUM_DWORDS; } - uint32 GetDWord(int i); - void SetDWord(int i, uint32 val); - int GetNumBits(); - -private: - enum { NUM_DWORDS = NUM_BITS / 32 + !!(NUM_BITS & 31) }; - - unsigned int m_DWords[ NUM_DWORDS ]; -}; - -inline CBitVecAccessor::CBitVecAccessor(uint32 *pDWords, int iBit) -{ - m_pDWords = pDWords; - m_iBit = iBit; -} - -inline void CBitVecAccessor::operator=(int val) -{ - if (val) - m_pDWords[m_iBit >> 5] |= (1 << (m_iBit & 31)); - else - m_pDWords[m_iBit >> 5] &= ~(uint32)(1 << (m_iBit & 31)); -} - -inline CBitVecAccessor::operator uint32() -{ - return m_pDWords[m_iBit >> 5] & (1 << (m_iBit & 31)); -} - -template -inline int CBitVec::GetNumBits() -{ - return NUM_BITS; -} - -template -inline CBitVec::CBitVec() -{ - for (int i = 0; i < NUM_DWORDS; ++i) - m_DWords[i] = 0; -} - -template -inline void CBitVec::Init(int val) -{ - for (int i = 0; i < GetNumBits(); ++i) - { - (*this)[i] = val; - } -} - -template -inline CBitVec &CBitVec::operator=(CBitVec const &other) -{ - Q_memcpy(m_DWords, other.m_DWords, sizeof(m_DWords)); - return *this; -} - -template -inline CBitVecAccessor CBitVec::operator[](int i) -{ - assert(i >= 0 && i < GetNumBits()); - return CBitVecAccessor(m_DWords, i); -} - -template -inline bool CBitVec::operator==(CBitVec const &other) -{ - for (int i = 0; i < NUM_DWORDS; ++i) - { - if (m_DWords[i] != other.m_DWords[i]) - return false; - } - - return true; -} - -template -inline bool CBitVec::operator!=(CBitVec const &other) -{ - return !(*this == other); -} - -template -inline uint32 CBitVec::GetDWord(int i) -{ - assert(i >= 0 && i < NUM_DWORDS); - return m_DWords[i]; -} - -template -inline void CBitVec::SetDWord(int i, uint32 val) -{ - assert(i >= 0 && i < NUM_DWORDS); - m_DWords[i] = val; -} diff --git a/regamedll/extra/cssdk/game_shared/bot/bot.h b/regamedll/extra/cssdk/game_shared/bot/bot.h deleted file mode 100644 index c391ec21..00000000 --- a/regamedll/extra/cssdk/game_shared/bot/bot.h +++ /dev/null @@ -1,164 +0,0 @@ -/* -* -* This program is free software; you can redistribute it and/or modify it -* under the terms of the GNU General Public License as published by the -* Free Software Foundation; either version 2 of the License, or (at -* your option) any later version. -* -* This program 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 -* General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* -*/ -#pragma once - -class BotProfile; - -// The base bot class from which bots for specific games are derived -class CBot: public CBasePlayer { -public: - virtual void Spawn() = 0; - - // invoked when injured by something - virtual BOOL TakeDamage(entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType) = 0; - - // invoked when killed - virtual void Killed(entvars_t *pevAttacker, int iGib) = 0; - virtual BOOL IsNetClient() = 0; - virtual void Think() = 0; - virtual BOOL IsBot() = 0; - virtual Vector GetAutoaimVector(float flDelta) = 0; - - // invoked when in contact with a CWeaponBox - virtual void OnTouchingWeapon(CWeaponBox *box) = 0; - virtual bool Initialize(const BotProfile *profile) = 0; - virtual void SpawnBot() = 0; - - // lightweight maintenance, invoked frequently - virtual void Upkeep() = 0; - - // heavyweight algorithms, invoked less often - virtual void Update() = 0; - - virtual void Run() = 0; - virtual void Walk() = 0; - virtual void Crouch() = 0; - virtual void StandUp() = 0; - virtual void MoveForward() = 0; - virtual void MoveBackward() = 0; - virtual void StrafeLeft() = 0; - virtual void StrafeRight() = 0; - - // returns true if jump was started - #define MUST_JUMP true - virtual bool Jump(bool mustJump = false) = 0; - - // zero any MoveForward(), Jump(), etc - virtual void ClearMovement() = 0; - - // Weapon interface - virtual void UseEnvironment() = 0; - virtual void PrimaryAttack() = 0; - virtual void ClearPrimaryAttack() = 0; - virtual void TogglePrimaryAttack() = 0; - virtual void SecondaryAttack() = 0; - virtual void Reload() = 0; - - // invoked when event occurs in the game (some events have NULL entities) - virtual void OnEvent(GameEventType event, CBaseEntity *entity = NULL, CBaseEntity *other = NULL) = 0; - - // return true if we can see the point - virtual bool IsVisible(const Vector *pos, bool testFOV = false) const = 0; - - // return true if we can see any part of the player - virtual bool IsVisible(CBasePlayer *player, bool testFOV = false, unsigned char *visParts = NULL) const = 0; - - enum VisiblePartType:uint8 - { - NONE = 0x00, - CHEST = 0x01, - HEAD = 0x02, - LEFT_SIDE = 0x04, // the left side of the object from our point of view (not their left side) - RIGHT_SIDE = 0x08, // the right side of the object from our point of view (not their right side) - FEET = 0x10 - }; - - // if enemy is visible, return the part we see - virtual bool IsEnemyPartVisible(VisiblePartType part) const = 0; - - // return true if player is facing towards us - virtual bool IsPlayerFacingMe(CBasePlayer *other) const = 0; - - // returns true if other player is pointing right at us - virtual bool IsPlayerLookingAtMe(CBasePlayer *other) const = 0; - virtual void ExecuteCommand() = 0; - virtual void SetModel(const char *modelName) = 0; - -public: - unsigned int GetID() const { return m_id; } - bool IsRunning() const { return m_isRunning; } - bool IsCrouching() const { return m_isCrouching; } - - // return time last jump began - float GetJumpTimestamp() const { return m_jumpTimestamp; } - - // return our personality profile - const BotProfile *GetProfile() const { return m_profile; } - -public: - // the "personality" profile of this bot - const BotProfile *m_profile; - - // unique bot ID - unsigned int m_id; - - // Think mechanism variables - float m_flNextBotThink; - float m_flNextFullBotThink; - - // Command interface variables - float m_flPreviousCommandTime; - - // run/walk mode - bool m_isRunning; - - // true if crouching (ducking) - bool m_isCrouching; - float m_forwardSpeed; - float m_strafeSpeed; - float m_verticalSpeed; - - // bitfield of movement buttons - unsigned short m_buttonFlags; - - // time when we last began a jump - float m_jumpTimestamp; - - // the PostureContext represents the current settings of walking and crouching - struct PostureContext - { - bool isRunning; - bool isCrouching; - }; - - enum { MAX_POSTURE_STACK = 8 }; - PostureContext m_postureStack[MAX_POSTURE_STACK]; - - // index of top of stack - int m_postureStackIndex; -}; diff --git a/regamedll/extra/cssdk/game_shared/bot/bot_constants.h b/regamedll/extra/cssdk/game_shared/bot/bot_constants.h deleted file mode 100644 index 14438b5c..00000000 --- a/regamedll/extra/cssdk/game_shared/bot/bot_constants.h +++ /dev/null @@ -1,47 +0,0 @@ -/* -* -* This program is free software; you can redistribute it and/or modify it -* under the terms of the GNU General Public License as published by the -* Free Software Foundation; either version 2 of the License, or (at -* your option) any later version. -* -* This program 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 -* General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* -*/ -#pragma once - -// We'll define our own version of this, because everyone else does. -// This needs to stay in sync with MAX_CLIENTS, but there's no header with the #define. -#define BOT_MAX_CLIENTS 32 - -// version number is MAJOR.MINOR -#define BOT_VERSION_MAJOR 1 -#define BOT_VERSION_MINOR 50 - -// Difficulty levels -enum BotDifficultyType -{ - BOT_EASY = 0, - BOT_NORMAL, - BOT_HARD, - BOT_EXPERT, - - NUM_DIFFICULTY_LEVELS -}; diff --git a/regamedll/extra/cssdk/game_shared/bot/bot_manager.h b/regamedll/extra/cssdk/game_shared/bot/bot_manager.h deleted file mode 100644 index 5be97b06..00000000 --- a/regamedll/extra/cssdk/game_shared/bot/bot_manager.h +++ /dev/null @@ -1,72 +0,0 @@ -/* -* -* This program is free software; you can redistribute it and/or modify it -* under the terms of the GNU General Public License as published by the -* Free Software Foundation; either version 2 of the License, or (at -* your option) any later version. -* -* This program 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 -* General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* -*/ -#pragma once - -// STL uses exceptions, but we are not compiling with them - ignore warning -#pragma warning(disable : 4530) - -#include - -class CNavArea; -class CGrenade; - -class ActiveGrenade { -public: - int m_id; - CGrenade *m_entity; - Vector m_detonationPosition; - float m_dieTimestamp; -}; - -typedef std::list ActiveGrenadeList; - -class CBotManager { -public: - virtual ~CBotManager() {} - - virtual void ClientDisconnect(CBasePlayer *pPlayer) = 0; - virtual BOOL ClientCommand(CBasePlayer *pPlayer, const char *pcmd) = 0; - - virtual void ServerActivate() = 0; - virtual void ServerDeactivate() = 0; - - virtual void ServerCommand(const char *pcmd) = 0; - virtual void AddServerCommand(const char *cmd) = 0; - virtual void AddServerCommands() = 0; - - virtual void RestartRound() = 0; - virtual void StartFrame() = 0; - - // Events are propogated to all bots. - virtual void OnEvent(GameEventType event, CBaseEntity *entity = NULL, CBaseEntity *other = NULL) = 0; // Invoked when event occurs in the game (some events have NULL entity). - virtual unsigned int GetPlayerPriority(CBasePlayer *player) const = 0; // return priority of player (0 = max pri) - -public: - // the list of active grenades the bots are aware of - ActiveGrenadeList m_activeGrenadeList; -}; diff --git a/regamedll/extra/cssdk/game_shared/bot/bot_profile.h b/regamedll/extra/cssdk/game_shared/bot/bot_profile.h deleted file mode 100644 index 5f000f54..00000000 --- a/regamedll/extra/cssdk/game_shared/bot/bot_profile.h +++ /dev/null @@ -1,116 +0,0 @@ -/* -* -* This program is free software; you can redistribute it and/or modify it -* under the terms of the GNU General Public License as published by the -* Free Software Foundation; either version 2 of the License, or (at -* your option) any later version. -* -* This program 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 -* General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* -*/ -#pragma once - -// long STL names get truncated in browse info. -#pragma warning(disable : 4786) - -#ifndef _WIN32 -#include -#include -#endif // _WIN32 - -#undef min -#undef max - -#include -#include - -#include "bot_constants.h" - -enum -{ - FirstCustomSkin = 100, - NumCustomSkins = 100, - LastCustomSkin = FirstCustomSkin + NumCustomSkins - 1, -}; - -enum BotProfileTeamType -{ - BOT_TEAM_T, - BOT_TEAM_CT, - BOT_TEAM_ANY -}; - -class BotProfile { -public: - const char *GetName() const { return m_name; } - float GetAggression() const { return m_aggression; } - float GetSkill() const { return m_skill; } - float GetTeamwork() const { return m_teamwork; } - int GetWeaponPreference(int i) const { return m_weaponPreference[i]; } - int GetWeaponPreferenceCount() const { return m_weaponPreferenceCount; } - int GetCost() const { return m_cost; } - int GetSkin() const { return m_skin; } - int GetVoicePitch() const { return m_voicePitch; } - float GetReactionTime() const { return m_reactionTime; } - float GetAttackDelay() const { return m_attackDelay; } - int GetVoiceBank() const { return m_voiceBank; } - bool PrefersSilencer() const { return m_prefersSilencer; } -public: - friend class BotProfileManager; - - char *m_name; - float m_aggression; - float m_skill; - float m_teamwork; - - enum { MAX_WEAPON_PREFS = 16 }; - - int m_weaponPreference[MAX_WEAPON_PREFS]; - int m_weaponPreferenceCount; - - int m_cost; - int m_skin; - - unsigned char m_difficultyFlags; - int m_voicePitch; - float m_reactionTime; - float m_attackDelay; - enum BotProfileTeamType m_teams; - bool m_prefersSilencer; - int m_voiceBank; -}; - -typedef std::list BotProfileList; - -class BotProfileManager { -public: - typedef std::vector VoiceBankList; - const BotProfileList *GetProfileList() const { return &m_profileList; } - const VoiceBankList *GetVoiceBanks() const { return &m_voiceBanks; } - -public: - BotProfileList m_profileList; - VoiceBankList m_voiceBanks; - - char *m_skins[NumCustomSkins]; - char *m_skinModelnames[NumCustomSkins]; - char *m_skinFilenames[NumCustomSkins]; - int m_nextSkin; -}; diff --git a/regamedll/extra/cssdk/game_shared/bot/bot_util.h b/regamedll/extra/cssdk/game_shared/bot/bot_util.h deleted file mode 100644 index 776d4212..00000000 --- a/regamedll/extra/cssdk/game_shared/bot/bot_util.h +++ /dev/null @@ -1,141 +0,0 @@ -/* -* -* This program is free software; you can redistribute it and/or modify it -* under the terms of the GNU General Public License as published by the -* Free Software Foundation; either version 2 of the License, or (at -* your option) any later version. -* -* This program 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 -* General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* -*/ -#pragma once - -#define COS_TABLE_SIZE 256 - -#define RAD_TO_DEG(deg) ((deg) * 180.0 / M_PI) -#define DEG_TO_RAD(rad) ((rad) * M_PI / 180.0) - -#define SIGN(num) (((num) < 0) ? -1 : 1) -#define ABS(num) (SIGN(num) * (num)) - -class CBasePlayer; -class BotProfile; - -enum PriorityType -{ - PRIORITY_LOW, PRIORITY_MEDIUM, PRIORITY_HIGH, PRIORITY_UNINTERRUPTABLE -}; - -// Simple class for tracking intervals of game time -class IntervalTimer { -public: - IntervalTimer() { m_timestamp = -1.0f; } - void Reset() { m_timestamp = gpGlobals->time; } - void Start() { m_timestamp = gpGlobals->time; } - void Invalidate() { m_timestamp = -1.0f; } - - bool HasStarted() const { return (m_timestamp > 0.0f); } - - // if not started, elapsed time is very large - float GetElapsedTime() const { return (HasStarted()) ? (gpGlobals->time - m_timestamp) : 99999.9f; } - bool IsLessThen(float duration) const { return (gpGlobals->time - m_timestamp < duration) ? true : false; } - bool IsGreaterThen(float duration) const { return (gpGlobals->time - m_timestamp > duration) ? true : false; } - -private: - float m_timestamp; -}; - -// Simple class for counting down a short interval of time -class CountdownTimer { -public: - CountdownTimer() { m_timestamp = -1.0f; m_duration = 0.0f; } - void Reset() { m_timestamp = gpGlobals->time + m_duration; } - - void Start(float duration) { m_timestamp = gpGlobals->time + duration; m_duration = duration; } - bool HasStarted() const { return (m_timestamp > 0.0f); } - - void Invalidate() { m_timestamp = -1.0f; } - bool IsElapsed() const { return (gpGlobals->time > m_timestamp); } - -private: - float m_duration; - float m_timestamp; -}; - -// Return true if the given entity is valid -inline bool IsEntityValid(CBaseEntity *entity) -{ - if (entity == NULL) - return false; - - if (FNullEnt(entity->pev)) - return false; - - if (FStrEq(STRING(entity->pev->netname), "")) - return false; - - if (entity->pev->flags & FL_DORMANT) - return false; - - return true; -} - -// Given two line segments: startA to endA, and startB to endB, return true if they intesect -// and put the intersection point in "result". -// Note that this computes the intersection of the 2D (x,y) projection of the line segments. -inline bool IsIntersecting2D(const Vector &startA, const Vector &endA, const Vector &startB, const Vector &endB, Vector *result = NULL) -{ - float denom = (endA.x - startA.x) * (endB.y - startB.y) - (endA.y - startA.y) * (endB.x - startB.x); - if (denom == 0.0f) - { - // parallel - return false; - } - - float numS = (startA.y - startB.y) * (endB.x - startB.x) - (startA.x - startB.x) * (endB.y - startB.y); - if (numS == 0.0f) - { - // coincident - return true; - } - - float numT = (startA.y - startB.y) * (endA.x - startA.x) - (startA.x - startB.x) * (endA.y - startA.y); - float s = numS / denom; - if (s < 0.0f || s > 1.0f) - { - // intersection is not within line segment of startA to endA - return false; - } - - float t = numT / denom; - if (t < 0.0f || t > 1.0f) - { - // intersection is not within line segment of startB to endB - return false; - } - - // compute intesection point - if (result != NULL) - { - *result = startA + s * (endA - startA); - } - - return true; -} diff --git a/regamedll/extra/cssdk/game_shared/bot/improv.h b/regamedll/extra/cssdk/game_shared/bot/improv.h deleted file mode 100644 index e04d26d2..00000000 --- a/regamedll/extra/cssdk/game_shared/bot/improv.h +++ /dev/null @@ -1,120 +0,0 @@ -/* -* -* This program is free software; you can redistribute it and/or modify it -* under the terms of the GNU General Public License as published by the -* Free Software Foundation; either version 2 of the License, or (at -* your option) any later version. -* -* This program 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 -* General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* -*/ -#pragma once - -class CBaseEntity; -class CNavLadder; - -// Improv-specific events -class IImprovEvent { -public: - virtual void OnMoveToSuccess(const Vector &goal) {}; // invoked when an improv reaches its MoveTo goal - - enum MoveToFailureType - { - FAIL_INVALID_PATH = 0, - FAIL_STUCK, - FAIL_FELL_OFF, - }; - - virtual void OnMoveToFailure(const Vector &goal, MoveToFailureType reason) {} // invoked when an improv fails to reach a MoveTo goal - virtual void OnInjury(float amount) {} // invoked when the improv is injured -}; - -// The Improv interface definition -// An "Improv" is an improvisational actor that simulates the -// behavor of a human in an unscripted, "make it up as you go" manner. -class CImprov: public IImprovEvent { -public: - virtual ~CImprov() {} - virtual bool IsAlive() const = 0; // return true if this improv is alive - - virtual void MoveTo(const Vector &goal) = 0; // move improv towards far-away goal (pathfind) - virtual void LookAt(const Vector &target) = 0; // define desired view target - virtual void ClearLookAt() = 0; // remove view goal - virtual void FaceTo(const Vector &goal) = 0; // orient body towards goal - virtual void ClearFaceTo() = 0; // remove body orientation goal - - virtual bool IsAtMoveGoal(float error = 20.0f) const = 0; // return true if improv is standing on its movement goal - virtual bool HasLookAt() const = 0; // return true if improv has a look at goal - virtual bool HasFaceTo() const = 0; // return true if improv has a face to goal - virtual bool IsAtFaceGoal() const = 0; // return true if improv is facing towards its face goal - virtual bool IsFriendInTheWay(const Vector &goalPos) const = 0; // return true if a friend is blocking our line to the given goal position - virtual bool IsFriendInTheWay(CBaseEntity *myFriend, const Vector &goalPos) const = 0; // return true if the given friend is blocking our line to the given goal position - - virtual void MoveForward() = 0; - virtual void MoveBackward() = 0; - virtual void StrafeLeft() = 0; - virtual void StrafeRight() = 0; - virtual bool Jump() = 0; - virtual void Crouch() = 0; - virtual void StandUp() = 0; // "un-crouch" - - virtual void TrackPath(const Vector &pathGoal, float deltaT) = 0; // move along path by following "pathGoal" - virtual void StartLadder(const CNavLadder *ladder, enum NavTraverseType how, const Vector *approachPos, const Vector *departPos) = 0; // invoked when a ladder is encountered while following a path - - virtual bool TraverseLadder(const CNavLadder *ladder, enum NavTraverseType how, const Vector *approachPos, const Vector *departPos, float deltaT) = 0; // traverse given ladder - virtual bool GetSimpleGroundHeightWithFloor(const Vector *pos, float *height, Vector *normal = NULL) = 0; // find "simple" ground height, treating current nav area as part of the floor - - virtual void Run() = 0; - virtual void Walk() = 0; - virtual void Stop() = 0; - - virtual float GetMoveAngle() const = 0; // return direction of movement - virtual float GetFaceAngle() const = 0; // return direction of view - - virtual const Vector &GetFeet() const = 0; // return position of "feet" - point below centroid of improv at feet level - virtual const Vector &GetCentroid() const = 0; - virtual const Vector &GetEyes() const = 0; - - virtual bool IsRunning() const = 0; - virtual bool IsWalking() const = 0; - virtual bool IsStopped() const = 0; - - virtual bool IsCrouching() const = 0; - virtual bool IsJumping() const = 0; - virtual bool IsUsingLadder() const = 0; - virtual bool IsOnGround() const = 0; - virtual bool IsMoving() const = 0; // if true, improv is walking, crawling, running somewhere - - virtual bool CanRun() const = 0; - virtual bool CanCrouch() const = 0; - virtual bool CanJump() const = 0; - virtual bool IsVisible(const Vector &pos, bool testFOV = false) const = 0; // return true if improv can see position - virtual bool IsPlayerLookingAtMe(CBasePlayer *other, float cosTolerance = 0.95f) const = 0; // return true if 'other' is looking right at me - virtual CBasePlayer *IsAnyPlayerLookingAtMe(int team = 0, float cosTolerance = 0.95f) const = 0; // return player on given team that is looking right at me (team == 0 means any team), NULL otherwise - - virtual CBasePlayer *GetClosestPlayerByTravelDistance(int team = 0, float *range = NULL) const = 0; // return actual travel distance to closest player on given team (team == 0 means any team) - virtual CNavArea *GetLastKnownArea() const = 0; - - virtual void OnUpdate(float deltaT) = 0; // a less frequent, full update 'tick' - virtual void OnUpkeep(float deltaT) = 0; // a frequent, lightweight update 'tick' - virtual void OnReset() = 0; // reset improv to initial state - virtual void OnGameEvent(GameEventType event, CBaseEntity *entity, CBaseEntity *other) = 0; // invoked when an event occurs in the game - virtual void OnTouch(CBaseEntity *other) = 0; // "other" has touched us -}; diff --git a/regamedll/extra/cssdk/game_shared/bot/nav.h b/regamedll/extra/cssdk/game_shared/bot/nav.h deleted file mode 100644 index 7f6cf34f..00000000 --- a/regamedll/extra/cssdk/game_shared/bot/nav.h +++ /dev/null @@ -1,409 +0,0 @@ -/* -* -* This program is free software; you can redistribute it and/or modify it -* under the terms of the GNU General Public License as published by the -* Free Software Foundation; either version 2 of the License, or (at -* your option) any later version. -* -* This program 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 -* General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* -*/ -#pragma once - -// STL uses exceptions, but we are not compiling with them - ignore warning -#pragma warning(disable : 4530) - -// to help identify nav files -#define NAV_MAGIC_NUMBER 0xFEEDFACE - -// version -// 1 = hiding spots as plain vector array -// 2 = hiding spots as HidingSpot objects -// 3 = Encounter spots use HidingSpot ID's instead of storing vector again -// 4 = Includes size of source bsp file to verify nav data correlation -// ---- Beta Release at V4 ----- -// 5 = Added Place info -#define NAV_VERSION 5 - -// A place is a named group of navigation areas -typedef unsigned int Place; - -// ie: "no place" -#define UNDEFINED_PLACE 0 -#define ANY_PLACE 0xFFFF - -#define WALK_THRU_DOORS 0x01 -#define WALK_THRU_BREAKABLES 0x02 -#define WALK_THRU_EVERYTHING (WALK_THRU_DOORS | WALK_THRU_BREAKABLES) - -enum NavErrorType -{ - NAV_OK, - NAV_CANT_ACCESS_FILE, - NAV_INVALID_FILE, - NAV_BAD_FILE_VERSION, - NAV_CORRUPT_DATA, -}; - -enum NavAttributeType -{ - NAV_CROUCH = 0x01, // must crouch to use this node/area - NAV_JUMP = 0x02, // must jump to traverse this area - NAV_PRECISE = 0x04, // do not adjust for obstacles, just move along area - NAV_NO_JUMP = 0x08, // inhibit discontinuity jumping -}; - -enum NavDirType -{ - NORTH = 0, - EAST, - SOUTH, - WEST, - - NUM_DIRECTIONS -}; - -// Defines possible ways to move from one area to another -enum NavTraverseType -{ - // NOTE: First 4 directions MUST match NavDirType - GO_NORTH = 0, - GO_EAST, - GO_SOUTH, - GO_WEST, - GO_LADDER_UP, - GO_LADDER_DOWN, - GO_JUMP, - - NUM_TRAVERSE_TYPES -}; - -enum NavCornerType -{ - NORTH_WEST = 0, - NORTH_EAST, - SOUTH_EAST, - SOUTH_WEST, - - NUM_CORNERS -}; - -enum NavRelativeDirType -{ - FORWARD = 0, - RIGHT, - BACKWARD, - LEFT, - UP, - DOWN, - - NUM_RELATIVE_DIRECTIONS -}; - -const float GenerationStepSize = 25.0f; // (30) was 20, but bots can't fit always fit -const float StepHeight = 18.0f; // if delta Z is greater than this, we have to jump to get up -const float JumpHeight = 41.8f; // if delta Z is less than this, we can jump up on it -const float JumpCrouchHeight = 58.0f; // (48) if delta Z is less than or equal to this, we can jumpcrouch up on it - -// Strictly speaking, you CAN get up a slope of 1.643 (about 59 degrees), but you move very, very slowly -// This slope will represent the slope you can navigate without much slowdown -// rise/run - if greater than this, we can't move up it (de_survivor canyon ramps) -const float MaxSlope = 1.4f; - -// instead of MaxSlope, we are using the following max Z component of a unit normal -const float MaxUnitZSlope = 0.7f; - -const float BotRadius = 10.0f; // circular extent that contains bot -const float DeathDrop = 200.0f; // (300) distance at which we will die if we fall - should be about 600, and pay attention to fall damage during pathfind - -const float HalfHumanWidth = 16.0f; -const float HalfHumanHeight = 36.0f; -const float HumanHeight = 72.0f; - -struct Extent -{ - Vector lo; - Vector hi; - - float SizeX() const { return hi.x - lo.x; } - float SizeY() const { return hi.y - lo.y; } - float SizeZ() const { return hi.z - lo.z; } - float Area() const { return SizeX() * SizeY(); } - - // return true if 'pos' is inside of this extent - bool Contains(const Vector *pos) const - { - return (pos->x >= lo.x && pos->x <= hi.x && - pos->y >= lo.y && pos->y <= hi.y && - pos->z >= lo.z && pos->z <= hi.z); - } -}; - -struct Ray -{ - Vector from; - Vector to; -}; - -inline NavDirType OppositeDirection(NavDirType dir) -{ - switch (dir) - { - case NORTH: - return SOUTH; - case EAST: - return WEST; - case SOUTH: - return NORTH; - case WEST: - return EAST; - } - - return NORTH; -} - -inline NavDirType DirectionLeft(NavDirType dir) -{ - switch (dir) - { - case NORTH: - return WEST; - case SOUTH: - return EAST; - case EAST: - return NORTH; - case WEST: - return SOUTH; - } - - return NORTH; -} - -inline NavDirType DirectionRight(NavDirType dir) -{ - switch (dir) - { - case NORTH: - return EAST; - case SOUTH: - return WEST; - case EAST: - return SOUTH; - case WEST: - return NORTH; - } - - return NORTH; -} - -inline void AddDirectionVector(Vector *v, NavDirType dir, float amount) -{ - switch (dir) - { - case NORTH: - v->y -= amount; - return; - case SOUTH: - v->y += amount; - return; - case EAST: - v->x += amount; - return; - case WEST: - v->x -= amount; - return; - } -} - -inline float DirectionToAngle(NavDirType dir) -{ - switch (dir) - { - case NORTH: - return 270.0f; - case EAST: - return 0.0f; - case SOUTH: - return 90.0f; - case WEST: - return 180.0f; - } - - return 0.0f; -} - -inline NavDirType AngleToDirection(float angle) -{ - while (angle < 0.0f) - angle += 360.0f; - - while (angle > 360.0f) - angle -= 360.0f; - - if (angle < 45 || angle > 315) - return EAST; - - if (angle >= 45 && angle < 135) - return SOUTH; - - if (angle >= 135 && angle < 225) - return WEST; - - return NORTH; -} - -inline void DirectionToVector2D(NavDirType dir, Vector2D *v) -{ - switch (dir) - { - case NORTH: - v->x = 0.0f; - v->y = -1.0f; - break; - case SOUTH: - v->x = 0.0f; - v->y = 1.0f; - break; - case EAST: - v->x = 1.0f; - v->y = 0.0f; - break; - case WEST: - v->x = -1.0f; - v->y = 0.0f; - break; - } -} - -inline void SnapToGrid(Vector *pos) -{ - int cx = pos->x / GenerationStepSize; - int cy = pos->y / GenerationStepSize; - pos->x = cx * GenerationStepSize; - pos->y = cy * GenerationStepSize; -} - -inline void SnapToGrid(float *value) -{ - int c = *value / GenerationStepSize; - *value = c * GenerationStepSize; -} - -// custom -inline float SnapToGrid(float value) -{ - int c = value / GenerationStepSize; - return c * GenerationStepSize; -} - -inline float NormalizeAngle(float angle) -{ - while (angle < -180.0f) - angle += 360.0f; - - while (angle > 180.0f) - angle -= 360.0f; - - return angle; -} - -inline float NormalizeAnglePositive(float angle) -{ - while (angle < 0.0f) - angle += 360.0f; - - while (angle >= 360.0f) - angle -= 360.0f; - - return angle; -} - -inline float AngleDifference(float a, float b) -{ - float angleDiff = a - b; - - while (angleDiff > 180.0f) - angleDiff -= 360.0f; - - while (angleDiff < -180.0f) - angleDiff += 360.0f; - - return angleDiff; -} - -inline bool AnglesAreEqual(float a, float b, float tolerance = 5.0f) -{ - if (abs(int64(AngleDifference(a, b))) < tolerance) - return true; - - return false; -} - -inline bool VectorsAreEqual(const Vector *a, const Vector *b, float tolerance = 0.1f) -{ - if (abs(a->x - b->x) < tolerance - && abs(a->y - b->y) < tolerance - && abs(a->z - b->z) < tolerance) - return true; - - return false; -} - -inline bool IsEntityWalkable(entvars_t *entity, unsigned int flags) -{ - // if we hit a door, assume its walkable because it will open when we touch it - if (FClassnameIs(entity, "func_door") || FClassnameIs(entity, "func_door_rotating")) - return (flags & WALK_THRU_DOORS) ? true : false; - - // if we hit a breakable object, assume its walkable because we will shoot it when we touch it - if (FClassnameIs(entity, "func_breakable") && entity->takedamage == DAMAGE_YES) - return (flags & WALK_THRU_BREAKABLES) ? true : false; - - return false; -} - -// Check LOS, ignoring any entities that we can walk through -inline bool IsWalkableTraceLineClear(Vector &from, Vector &to, unsigned int flags = 0) -{ - TraceResult result; - edict_t *ignore = NULL; - Vector useFrom = from; - - while (true) - { - UTIL_TraceLine(useFrom, to, ignore_monsters, ignore, &result); - - if (result.flFraction != 1.0f && IsEntityWalkable(VARS(result.pHit), flags)) - { - ignore = result.pHit; - - Vector dir = to - from; - dir.NormalizeInPlace(); - useFrom = result.vecEndPos + 5.0f * dir; - } - else - break; - } - - if (result.flFraction == 1.0f) - return true; - - return false; -} diff --git a/regamedll/extra/cssdk/game_shared/bot/nav_area.h b/regamedll/extra/cssdk/game_shared/bot/nav_area.h deleted file mode 100644 index 5c40b2a7..00000000 --- a/regamedll/extra/cssdk/game_shared/bot/nav_area.h +++ /dev/null @@ -1,320 +0,0 @@ -/* -* -* This program is free software; you can redistribute it and/or modify it -* under the terms of the GNU General Public License as published by the -* Free Software Foundation; either version 2 of the License, or (at -* your option) any later version. -* -* This program 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 -* General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* -*/ -#pragma once - -#include - -class CNavArea; -enum NavEditCmdType -{ - EDIT_NONE, - EDIT_DELETE, // delete current area - EDIT_SPLIT, // split current area - EDIT_MERGE, // merge adjacent areas - EDIT_JOIN, // define connection between areas - EDIT_BREAK, // break connection between areas - EDIT_MARK, // mark an area for further operations - EDIT_ATTRIB_CROUCH, // toggle crouch attribute on current area - EDIT_ATTRIB_JUMP, // toggle jump attribute on current area - EDIT_ATTRIB_PRECISE, // toggle precise attribute on current area - EDIT_ATTRIB_NO_JUMP, // toggle inhibiting discontinuity jumping in current area - EDIT_BEGIN_AREA, // begin creating a new nav area - EDIT_END_AREA, // end creation of the new nav area - EDIT_CONNECT, // connect marked area to selected area - EDIT_DISCONNECT, // disconnect marked area from selected area - EDIT_SPLICE, // create new area in between marked and selected areas - EDIT_TOGGLE_PLACE_MODE, // switch between normal and place editing - EDIT_TOGGLE_PLACE_PAINTING, // switch between "painting" places onto areas - EDIT_PLACE_FLOODFILL, // floodfill areas out from current area - EDIT_PLACE_PICK, // "pick up" the place at the current area - EDIT_MARK_UNNAMED, // mark an unnamed area for further operations - EDIT_WARP_TO_MARK, // warp a spectating local player to the selected mark - EDIT_SELECT_CORNER, // select a corner on the current area - EDIT_RAISE_CORNER, // raise a corner on the current area - EDIT_LOWER_CORNER, // lower a corner on the current area -}; - -enum RouteType -{ - FASTEST_ROUTE, - SAFEST_ROUTE, -}; - -union NavConnect -{ - unsigned int id; - CNavArea *area; - - bool operator==(const NavConnect &other) const { return (area == other.area) ? true : false; } -}; - -typedef std::list NavConnectList; - -enum LadderDirectionType -{ - LADDER_UP = 0, - LADDER_DOWN, - NUM_LADDER_DIRECTIONS -}; - -class CNavLadder { -public: - Vector m_top; - Vector m_bottom; - float m_length; - NavDirType m_dir; - Vector2D m_dirVector; - CBaseEntity *m_entity; - - CNavArea *m_topForwardArea; - CNavArea *m_topLeftArea; - CNavArea *m_topRightArea; - CNavArea *m_topBehindArea; - CNavArea *m_bottomArea; - - bool m_isDangling; - - void OnDestroyNotify(CNavArea *dead) - { - if (dead == m_topForwardArea) - m_topForwardArea = NULL; - - if (dead == m_topLeftArea) - m_topLeftArea = NULL; - - if (dead == m_topRightArea) - m_topRightArea = NULL; - - if (dead == m_topBehindArea) - m_topBehindArea = NULL; - - if (dead == m_bottomArea) - m_bottomArea = NULL; - } -}; - -typedef std::list NavLadderList; - -class HidingSpot { -public: - enum - { - IN_COVER = 0x01, - GOOD_SNIPER_SPOT = 0x02, - IDEAL_SNIPER_SPOT = 0x04 - }; - - bool HasGoodCover() const { return (m_flags & IN_COVER) ? true : false; } - bool IsGoodSniperSpot() const { return (m_flags & GOOD_SNIPER_SPOT) ? true : false; } - bool IsIdealSniperSpot() const { return (m_flags & IDEAL_SNIPER_SPOT) ? true : false; } - - void SetFlags(unsigned char flags) { m_flags |= flags; } - unsigned char GetFlags() const { return m_flags; } - - const Vector *GetPosition() const { return &m_pos; } - unsigned int GetID() const { return m_id; } - -private: - Vector m_pos; - unsigned int m_id; - unsigned int m_marker; - unsigned char m_flags; -}; - -typedef std::list HidingSpotList; - -struct SpotOrder -{ - float t; - union - { - HidingSpot *spot; - unsigned int id; - }; -}; - -typedef std::list SpotOrderList; - -struct SpotEncounter -{ - NavConnect from; - NavDirType fromDir; - NavConnect to; - NavDirType toDir; - Ray path; // the path segment - SpotOrderList spotList; // list of spots to look at, in order of occurrence -}; - -typedef std::list SpotEncounterList; -typedef std::list NavAreaList; - -// A CNavArea is a rectangular region defining a walkable area in the map -class CNavArea { -public: - unsigned int GetID() const { return m_id; } - void SetAttributes(unsigned char bits) { m_attributeFlags = bits; } - unsigned char GetAttributes() const { return m_attributeFlags; } - void SetPlace(Place place) { m_place = place; } // set place descriptor - Place GetPlace() const { return m_place; } // get place descriptor - - int GetAdjacentCount(NavDirType dir) const { return m_connect[dir].size(); } // return number of connected areas in given direction - const NavConnectList *GetAdjacentList(NavDirType dir) const { return &m_connect[dir]; } - - const NavLadderList *GetLadderList(LadderDirectionType dir) const { return &m_ladder[dir]; } - - // for hunting algorithm - void SetClearedTimestamp(int teamID) { m_clearedTimestamp[teamID] = gpGlobals->time; } // set this area's "clear" timestamp to now - float GetClearedTimestamp(int teamID) { return m_clearedTimestamp[teamID]; } // get time this area was marked "clear" - - // hiding spots - const HidingSpotList *GetHidingSpotList() const { return &m_hidingSpotList; } - - float GetSizeX() const { return m_extent.hi.x - m_extent.lo.x; } - float GetSizeY() const { return m_extent.hi.y - m_extent.lo.y; } - - const Extent *GetExtent() const { return &m_extent; } - const Vector *GetCenter() const { return &m_center; } - - // approach areas - struct ApproachInfo - { - NavConnect here; // the approach area - NavConnect prev; // the area just before the approach area on the path - NavTraverseType prevToHereHow; - NavConnect next; // the area just after the approach area on the path - NavTraverseType hereToNextHow; - }; - - const ApproachInfo *GetApproachInfo(int i) const { return &m_approach[i]; } - int GetApproachInfoCount() const { return m_approachCount; } - - void SetParent(CNavArea *parent, NavTraverseType how = NUM_TRAVERSE_TYPES) { m_parent = parent; m_parentHow = how; } - CNavArea *GetParent() const { return m_parent; } - NavTraverseType GetParentHow() const { return m_parentHow; } - - void SetTotalCost(float value) { m_totalCost = value; } - float GetTotalCost() const { return m_totalCost; } - - void SetCostSoFar(float value) { m_costSoFar = value; } - float GetCostSoFar() const { return m_costSoFar; } - -public: - friend class CNavAreaGrid; - friend class CCSBotManager; - - unsigned int m_id; // unique area ID - Extent m_extent; // extents of area in world coords (NOTE: lo.z is not necessarily the minimum Z, but corresponds to Z at point (lo.x, lo.y), etc - Vector m_center; // centroid of area - unsigned char m_attributeFlags; // set of attribute bit flags (see NavAttributeType) - Place m_place; // place descriptor - - // height of the implicit corners - float m_neZ; - float m_swZ; - - enum { MAX_AREA_TEAMS = 2 }; - - // for hunting - float m_clearedTimestamp[MAX_AREA_TEAMS]; // time this area was last "cleared" of enemies - - // danger - float m_danger[MAX_AREA_TEAMS]; // danger of this area, allowing bots to avoid areas where they died in the past - zero is no danger - float m_dangerTimestamp[MAX_AREA_TEAMS]; // time when danger value was set - used for decaying - - // hiding spots - HidingSpotList m_hidingSpotList; - - // encounter spots - SpotEncounterList m_spotEncounterList; // list of possible ways to move thru this area, and the spots to look at as we do - - // approach areas - enum { MAX_APPROACH_AREAS = 16 }; - ApproachInfo m_approach[MAX_APPROACH_AREAS]; - unsigned char m_approachCount; - - // A* pathfinding algorithm - unsigned int m_marker; // used to flag the area as visited - CNavArea *m_parent; // the area just prior to this on in the search path - NavTraverseType m_parentHow; // how we get from parent to us - float m_totalCost; // the distance so far plus an estimate of the distance left - float m_costSoFar; // distance travelled so far - - CNavArea *m_nextOpen, *m_prevOpen; // only valid if m_openMarker == m_masterMarker - unsigned int m_openMarker; // if this equals the current marker value, we are on the open list - - // connections to adjacent areas - NavConnectList m_connect[ NUM_DIRECTIONS ]; // a list of adjacent areas for each direction - NavLadderList m_ladder[ NUM_LADDER_DIRECTIONS ]; // list of ladders leading up and down from this area - - CNavNode *m_node[ NUM_CORNERS ]; // nav nodes at each corner of the area - NavAreaList m_overlapList; // list of areas that overlap this area - - CNavArea *m_prevHash, *m_nextHash; // for hash table in CNavAreaGrid -}; - -// The CNavAreaGrid is used to efficiently access navigation areas by world position -// Each cell of the grid contains a list of areas that overlap it -// Given a world position, the corresponding grid cell is ( x/cellsize, y/cellsize ) -class CNavAreaGrid { -public: - const float m_cellSize; - NavAreaList *m_grid; - int m_gridSizeX; - int m_gridSizeY; - float m_minX; - float m_minY; - unsigned int m_areaCount; // total number of nav areas - - enum { HASH_TABLE_SIZE = 256 }; - CNavArea *m_hashTable[HASH_TABLE_SIZE]; // hash table to optimize lookup by ID - inline int ComputeHashKey(unsigned int id) const // returns a hash key for the given nav area ID - { - return id & 0xFF; - } - inline int WorldToGridX(float wx) const - { - int x = (wx - m_minX) / m_cellSize; - if (x < 0) - x = 0; - - else if (x >= m_gridSizeX) - x = m_gridSizeX - 1; - - return x; - } - inline int WorldToGridY(float wy) const - { - int y = (wy - m_minY) / m_cellSize; - if (y < 0) - y = 0; - else if (y >= m_gridSizeY) - y = m_gridSizeY - 1; - - return y; - } -}; diff --git a/regamedll/extra/cssdk/game_shared/bot/nav_node.h b/regamedll/extra/cssdk/game_shared/bot/nav_node.h deleted file mode 100644 index 4c434a1f..00000000 --- a/regamedll/extra/cssdk/game_shared/bot/nav_node.h +++ /dev/null @@ -1,110 +0,0 @@ -/* -* -* This program is free software; you can redistribute it and/or modify it -* under the terms of the GNU General Public License as published by the -* Free Software Foundation; either version 2 of the License, or (at -* your option) any later version. -* -* This program 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 -* General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* -*/ -#pragma once - -class CNavNode { -public: - // get navigation node connected in given direction, or NULL if cant go that way - CNavNode *GetConnectedNode(NavDirType dir) const; - const Vector *GetPosition() const; - const Vector *GetNormal() const { return &m_normal; } - unsigned int GetID() const { return m_id; } - - CNavNode *GetNext() { return m_next; } - - // create a connection FROM this node TO the given node, in the given direction - CNavNode *GetParent() const; - - void MarkAsVisited(NavDirType dir); // mark the given direction as having been visited - BOOL HasVisited(NavDirType dir); // return TRUE if the given direction has already been searched - - void Cover() { m_isCovered = true; } // TODO: Should pass in area that is covering - BOOL IsCovered() const { return m_isCovered; } // return true if this node has been covered by an area - - void AssignArea(CNavArea *area); // assign the given area to this node - CNavArea *GetArea() const; // return associated area - - void SetAttributes(unsigned char bits) { m_attributeFlags = bits; } - unsigned char GetAttributes() const { return m_attributeFlags; } - -public: - friend void DestroyNavigationMap(); - - Vector m_pos; // position of this node in the world - Vector m_normal; // surface normal at this location - CNavNode *m_to[ NUM_DIRECTIONS ]; // links to north, south, east, and west. NULL if no link - unsigned int m_id; // unique ID of this node - unsigned char m_attributeFlags; // set of attribute bit flags (see NavAttributeType) - - CNavNode *m_next; // next link in master list - - // below are only needed when generating - // flags for automatic node generation. If direction bit is clear, that direction hasn't been explored yet. - unsigned char m_visited; - CNavNode *m_parent; // the node prior to this in the search, which we pop back to when this node's search is done (a stack) - BOOL m_isCovered; // true when this node is "covered" by a CNavArea - CNavArea *m_area; // the area this node is contained within -}; - -inline CNavNode *CNavNode::GetConnectedNode(NavDirType dir) const -{ - return m_to[ dir ]; -} - -inline const Vector *CNavNode::GetPosition() const -{ - return &m_pos; -} - -inline CNavNode *CNavNode::GetParent() const -{ - return m_parent; -} - -inline void CNavNode::MarkAsVisited(NavDirType dir) -{ - m_visited |= (1 << dir); -} - -inline BOOL CNavNode::HasVisited(NavDirType dir) -{ - if (m_visited & (1 << dir)) - return true; - - return false; -} - -inline void CNavNode::AssignArea(CNavArea *area) -{ - m_area = area; -} - -inline CNavArea *CNavNode::GetArea() const -{ - return m_area; -} diff --git a/regamedll/extra/cssdk/game_shared/bot/nav_path.h b/regamedll/extra/cssdk/game_shared/bot/nav_path.h deleted file mode 100644 index 614aa06c..00000000 --- a/regamedll/extra/cssdk/game_shared/bot/nav_path.h +++ /dev/null @@ -1,99 +0,0 @@ -/* -* -* This program is free software; you can redistribute it and/or modify it -* under the terms of the GNU General Public License as published by the -* Free Software Foundation; either version 2 of the License, or (at -* your option) any later version. -* -* This program 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 -* General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* -*/ -#pragma once - -// STL uses exceptions, but we are not compiling with them - ignore warning -#pragma warning(disable : 4530) - -class CNavPath { -public: - CNavPath() { m_segmentCount = 0; } - - struct PathSegment - { - CNavArea *area; // the area along the path - NavTraverseType how; // how to enter this area from the previous one - Vector pos; // our movement goal position at this point in the path - const CNavLadder *ladder; // if "how" refers to a ladder, this is it - }; - - const PathSegment *operator[](int i) { return (i >= 0 && i < m_segmentCount) ? &m_path[i] : NULL; } - int GetSegmentCount() const { return m_segmentCount; } - const Vector &GetEndpoint() const { return m_path[ m_segmentCount - 1 ].pos; } - - bool IsValid() const { return (m_segmentCount > 0); } - void Invalidate() { m_segmentCount = 0; } -public: - enum { MAX_PATH_SEGMENTS = 256 }; - PathSegment m_path[ MAX_PATH_SEGMENTS ]; - int m_segmentCount; - - bool ComputePathPositions(); // determine actual path positions - bool BuildTrivialPath(const Vector *start, const Vector *goal); // utility function for when start and goal are in the same area - int FindNextOccludedNode(int anchor_); // used by Optimize() -}; - -// Monitor improv movement and determine if it becomes stuck -class CStuckMonitor { -public: - bool IsStuck() const { return m_isStuck; } - float GetDuration() const { return m_isStuck ? m_stuckTimer.GetElapsedTime() : 0.0f; } -public: - bool m_isStuck; // if true, we are stuck - Vector m_stuckSpot; // the location where we became stuck - IntervalTimer m_stuckTimer; // how long we have been stuck - - enum { MAX_VEL_SAMPLES = 5 }; - - float m_avgVel[ MAX_VEL_SAMPLES ]; - int m_avgVelIndex; - int m_avgVelCount; - Vector m_lastCentroid; - float m_lastTime; -}; - -// The CNavPathFollower class implements path following behavior -class CNavPathFollower { -public: - void SetImprov(CImprov *improv) { m_improv = improv; } - void SetPath(CNavPath *path) { m_path = path; } - - void Debug(bool status) { m_isDebug = status; } // turn debugging on/off -public: - int FindOurPositionOnPath(Vector *close, bool local) const; // return the closest point to our current position on current path - int FindPathPoint(float aheadRange, Vector *point, int *prevIndex); // compute a point a fixed distance ahead along our path. - - CImprov *m_improv; // who is doing the path following - CNavPath *m_path; // the path being followed - int m_segmentIndex; // the point on the path the improv is moving towards - int m_behindIndex; // index of the node on the path just behind us - Vector m_goal; // last computed follow goal - bool m_isLadderStarted; - bool m_isDebug; - CStuckMonitor m_stuckMonitor; -}; diff --git a/regamedll/extra/cssdk/game_shared/bot/simple_state_machine.h b/regamedll/extra/cssdk/game_shared/bot/simple_state_machine.h deleted file mode 100644 index baa931ed..00000000 --- a/regamedll/extra/cssdk/game_shared/bot/simple_state_machine.h +++ /dev/null @@ -1,101 +0,0 @@ -/* -* -* This program is free software; you can redistribute it and/or modify it -* under the terms of the GNU General Public License as published by the -* Free Software Foundation; either version 2 of the License, or (at -* your option) any later version. -* -* This program 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 -* General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* -*/ -#pragma once - -// Encapsulation of a finite-state-machine state -template -class SimpleState { -public: - SimpleState() { m_parent = NULL; } - - virtual ~SimpleState() {}; - virtual void OnEnter(T userData) {}; // when state is entered - virtual void OnUpdate(T userData) {}; // state behavior - virtual void OnExit(T userData) {}; // when state exited - virtual const char *GetName() const = 0; // return state name - - void SetParent(SimpleState *parent) - { - m_parent = parent; - } - SimpleState *GetParent() const - { - return m_parent; - } - -private: - // the parent state that contains this state - SimpleState *m_parent; -}; - -// Encapsulation of a finite state machine -template -class SimpleStateMachine { -public: - SimpleStateMachine() - { - m_state = NULL; - } - void Reset(T userData) - { - m_userData = userData; - m_state = NULL; - } - // change behavior state - WARNING: not re-entrant. Do not SetState() from within OnEnter() or OnExit() - void SetState(S *newState) - { - if (m_state) - m_state->OnExit(m_userData); - - newState->OnEnter(m_userData); - - m_state = newState; - m_stateTimer.Start(); - } - // how long have we been in the current state - float GetStateDuration() const - { - return m_stateTimer.GetElapsedTime(); - } - // return true if given state is current state of machine - bool IsState(const S *state) const - { - return (state == m_state); - } - // execute current state of machine - void Update() - { - if (m_state) - m_state->OnUpdate(m_userData); - } - -protected: - S *m_state; // current behavior state - IntervalTimer m_stateTimer; // how long have we been in the current state - T m_userData; -}; diff --git a/regamedll/extra/cssdk/game_shared/counter.h b/regamedll/extra/cssdk/game_shared/counter.h deleted file mode 100644 index 0b55e02c..00000000 --- a/regamedll/extra/cssdk/game_shared/counter.h +++ /dev/null @@ -1,188 +0,0 @@ -/* -* -* This program is free software; you can redistribute it and/or modify it -* under the terms of the GNU General Public License as published by the -* Free Software Foundation; either version 2 of the License, or (at -* your option) any later version. -* -* This program 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 -* General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* -*/ - -#pragma once - -#ifdef _WIN32 - #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers - #include - #include - #include -#else - #include - #include - #include - #include - #ifdef OSX - #include - #else - #include - #endif - #include -#endif - -#include -#include -#include -#include -#include - -class CCounter -{ -public: - CCounter(); - - bool Init(); - double GetCurTime(); - -private: - int m_iLowShift; - double m_flPerfCounterFreq; - double m_flCurrentTime; - double m_flLastCurrentTime; -}; - -inline CCounter::CCounter() : - m_iLowShift(0), - m_flPerfCounterFreq(0), - m_flCurrentTime(0), - m_flLastCurrentTime(0) -{ - Init(); -} - -inline bool CCounter::Init() -{ -#ifdef _WIN32 - - LARGE_INTEGER performanceFreq; - if (!QueryPerformanceFrequency(&performanceFreq)) - return false; - - // get 32 out of the 64 time bits such that we have around - // 1 microsecond resolution - unsigned int lowpart, highpart; - lowpart = (unsigned int)performanceFreq.LowPart; - highpart = (unsigned int)performanceFreq.HighPart; - m_iLowShift = 0; - - while (highpart || (lowpart > 2000000.0)) - { - m_iLowShift++; - lowpart >>= 1; - lowpart |= (highpart & 1) << 31; - highpart >>= 1; - } - - m_flPerfCounterFreq = 1.0 / (double)lowpart; - -#endif // _WIN32 - - return true; -} - -inline double CCounter::GetCurTime() -{ -#ifdef _WIN32 - - static int sametimecount; - static unsigned int oldtime; - static int first = 1; - LARGE_INTEGER PerformanceCount; - unsigned int temp, t2; - double time; - - QueryPerformanceCounter(&PerformanceCount); - if (m_iLowShift == 0) - { - temp = (unsigned int)PerformanceCount.LowPart; - } - else - { - temp = ((unsigned int)PerformanceCount.LowPart >> m_iLowShift) | - ((unsigned int)PerformanceCount.HighPart << (32 - m_iLowShift)); - } - - if (first) - { - oldtime = temp; - first = 0; - } - else - { - // check for turnover or backward time - if ((temp <= oldtime) && ((oldtime - temp) < 0x10000000)) - { - // so we can't get stuck - oldtime = temp; - } - else - { - t2 = temp - oldtime; - - time = (double)t2 * m_flPerfCounterFreq; - oldtime = temp; - - m_flCurrentTime += time; - - if (m_flCurrentTime == m_flLastCurrentTime) - { - if (++sametimecount > 100000) - { - m_flCurrentTime += 1.0; - sametimecount = 0; - } - } - else - { - sametimecount = 0; - } - - m_flLastCurrentTime = m_flCurrentTime; - } - } - - return m_flCurrentTime; - -#else // _WIN32 - - struct timeval tp; - static int secbase = 0; - - gettimeofday(&tp, NULL); - - if (!secbase) - { - secbase = tp.tv_sec; - return (tp.tv_usec / 1000000.0); - } - - return ((tp.tv_sec - secbase) + tp.tv_usec / 1000000.0); - -#endif // _WIN32 -} diff --git a/regamedll/extra/cssdk/game_shared/shared_util.h b/regamedll/extra/cssdk/game_shared/shared_util.h deleted file mode 100644 index c12156fc..00000000 --- a/regamedll/extra/cssdk/game_shared/shared_util.h +++ /dev/null @@ -1,63 +0,0 @@ -/* -* -* This program is free software; you can redistribute it and/or modify it -* under the terms of the GNU General Public License as published by the -* Free Software Foundation; either version 2 of the License, or (at -* your option) any later version. -* -* This program 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 -* General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* -*/ -#pragma once - -#ifndef _WIN32 -#include -#include -#endif - -// Simple utility function to allocate memory and duplicate a string -inline char *CloneString(const char *str) -{ - if (!str) - { - char *cloneStr = new char[1]; - cloneStr[0] = '\0'; - return cloneStr; - } - - char *cloneStr = new char [strlen(str) + 1]; - strcpy(cloneStr, str); - return cloneStr; -} - -// Simple utility function to allocate memory and duplicate a wide string -inline wchar_t *CloneWString(const wchar_t *str) -{ - if (!str) - { - wchar_t *cloneStr = new wchar_t[1]; - cloneStr[0] = L'\0'; - return cloneStr; - } - - wchar_t *cloneStr = new wchar_t [wcslen(str) + 1]; - wcscpy(cloneStr, str); - return cloneStr; -} diff --git a/regamedll/extra/cssdk/game_shared/simple_checksum.h b/regamedll/extra/cssdk/game_shared/simple_checksum.h deleted file mode 100644 index 236e7653..00000000 --- a/regamedll/extra/cssdk/game_shared/simple_checksum.h +++ /dev/null @@ -1,49 +0,0 @@ -/* -* -* This program is free software; you can redistribute it and/or modify it -* under the terms of the GNU General Public License as published by the -* Free Software Foundation; either version 2 of the License, or (at -* your option) any later version. -* -* This program 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 -* General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* -*/ - -#ifndef SIMPLE_CHECKSUM_H -#define SIMPLE_CHECKSUM_H -#ifdef _WIN32 -#pragma once -#endif - -// Compute a simple checksum for the given data. -// Each byte in the data is multiplied by its position to track re-ordering changes -inline unsigned int ComputeSimpleChecksum(const unsigned char *dataPointer, int dataLength) -{ - unsigned int checksum = 0; - for (int i = 1; i <= dataLength; i++) - { - checksum += (*dataPointer) * i; - ++dataPointer; - } - - return checksum; -} - -#endif // SIMPLE_CHECKSUM_H diff --git a/regamedll/extra/cssdk/game_shared/steam_util.h b/regamedll/extra/cssdk/game_shared/steam_util.h deleted file mode 100644 index 54316798..00000000 --- a/regamedll/extra/cssdk/game_shared/steam_util.h +++ /dev/null @@ -1,76 +0,0 @@ -/* -* -* This program is free software; you can redistribute it and/or modify it -* under the terms of the GNU General Public License as published by the -* Free Software Foundation; either version 2 of the License, or (at -* your option) any later version. -* -* This program 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 -* General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* -*/ -#pragma once - -class SteamFile -{ -public: - SteamFile(const char *filename); - ~SteamFile(); - - bool IsValid() const { return (m_fileData) ? true : false; } - bool Read(void *data, int length); - -private: - byte *m_fileData; - int m_fileDataLength; - - byte *m_cursor; - int m_bytesLeft; -}; - -inline SteamFile::SteamFile(const char *filename) -{ - m_fileData = (byte *)LOAD_FILE_FOR_ME(const_cast(filename), &m_fileDataLength); - m_cursor = m_fileData; - m_bytesLeft = m_fileDataLength; -} - -inline SteamFile::~SteamFile() -{ - if (m_fileData) - { - FREE_FILE(m_fileData); - m_fileData = NULL; - } -} - -inline bool SteamFile::Read(void *data, int length) -{ - if (length > m_bytesLeft || m_cursor == NULL || m_bytesLeft <= 0) - return false; - - byte *readCursor = static_cast(data); - for (int i = 0; i < length; ++i) - { - *readCursor++ = *m_cursor++; - --m_bytesLeft; - } - - return true; -} diff --git a/regamedll/extra/cssdk/game_shared/voice_common.h b/regamedll/extra/cssdk/game_shared/voice_common.h deleted file mode 100644 index 82dfb39f..00000000 --- a/regamedll/extra/cssdk/game_shared/voice_common.h +++ /dev/null @@ -1,36 +0,0 @@ -/* -* -* This program is free software; you can redistribute it and/or modify it -* under the terms of the GNU General Public License as published by the -* Free Software Foundation; either version 2 of the License, or (at -* your option) any later version. -* -* This program 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 -* General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* -*/ -#pragma once - -#include "bitvec.h" - -// TODO: this should just be set to MAX_CLIENTS -#define VOICE_MAX_PLAYERS 32 -#define VOICE_MAX_PLAYERS_DW ((VOICE_MAX_PLAYERS / 32) + !!(VOICE_MAX_PLAYERS & 31)) - -typedef CBitVec< VOICE_MAX_PLAYERS > CPlayerBitVec; diff --git a/regamedll/extra/cssdk/game_shared/voice_gamemgr.h b/regamedll/extra/cssdk/game_shared/voice_gamemgr.h deleted file mode 100644 index 851c93ae..00000000 --- a/regamedll/extra/cssdk/game_shared/voice_gamemgr.h +++ /dev/null @@ -1,56 +0,0 @@ -/* -* -* This program is free software; you can redistribute it and/or modify it -* under the terms of the GNU General Public License as published by the -* Free Software Foundation; either version 2 of the License, or (at -* your option) any later version. -* -* This program 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 -* General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* -*/ -#pragma once - -#define UPDATE_INTERVAL 0.3 - -#include "voice_common.h" - -class CGameRules; -class CBasePlayer; - -class IVoiceGameMgrHelper { -public: - virtual ~IVoiceGameMgrHelper() = 0; - - // Called each frame to determine which players are allowed to hear each other. This overrides - // whatever squelch settings players have. - virtual bool CanPlayerHearPlayer(CBasePlayer *pListener, CBasePlayer *pTalker) = 0; -}; - -// CVoiceGameMgr manages which clients can hear which other clients. -class CVoiceGameMgr { -public: - virtual ~CVoiceGameMgr() {}; -public: - int m_msgPlayerVoiceMask; - int m_msgRequestState; - IVoiceGameMgrHelper *m_pHelper; - int m_nMaxPlayers; - double m_UpdateInterval; // How long since the last update. -}; diff --git a/regamedll/extra/cssdk/pm_shared/pm_defs.h b/regamedll/extra/cssdk/pm_shared/pm_defs.h deleted file mode 100644 index 04bea265..00000000 --- a/regamedll/extra/cssdk/pm_shared/pm_defs.h +++ /dev/null @@ -1,192 +0,0 @@ -/* -* -* This program is free software; you can redistribute it and/or modify it -* under the terms of the GNU General Public License as published by the -* Free Software Foundation; either version 2 of the License, or (at -* your option) any later version. -* -* This program 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 -* General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* -*/ -#pragma once - -#include "pm_info.h" -#include "pmtrace.h" - -#ifndef USERCMD_H -#include "usercmd.h" -#endif - -#include "const.h" - -#define MAX_PHYSENTS 600 // Must have room for all entities in the world. -#define MAX_MOVEENTS 64 -#define MAX_CLIP_PLANES 5 - -#define PM_NORMAL 0x00000000 -#define PM_STUDIO_IGNORE 0x00000001 // Skip studio models -#define PM_STUDIO_BOX 0x00000002 // Use boxes for non-complex studio models (even in traceline) -#define PM_GLASS_IGNORE 0x00000004 // Ignore entities with non-normal rendermode -#define PM_WORLD_ONLY 0x00000008 // Only trace against the world - -#define PM_TRACELINE_PHYSENTSONLY 0 -#define PM_TRACELINE_ANYVISIBLE 1 - -typedef struct physent_s -{ - char name[32]; // Name of model, or "player" or "world". - int player; - vec3_t origin; // Model's origin in world coordinates. - struct model_s *model; // only for bsp models - struct model_s *studiomodel; // SOLID_BBOX, but studio clip intersections. - vec3_t mins, maxs; // only for non-bsp models - int info; // For client or server to use to identify (index into edicts or cl_entities) - vec3_t angles; // rotated entities need this info for hull testing to work. - - int solid; // Triggers and func_door type WATER brushes are SOLID_NOT - int skin; // BSP Contents for such things like fun_door water brushes. - int rendermode; // So we can ignore glass - - float frame; - int sequence; - byte controller[4]; - byte blending[2]; - - int movetype; - int takedamage; - int blooddecal; - int team; - int classnumber; - - int iuser1; - int iuser2; - int iuser3; - int iuser4; - float fuser1; - float fuser2; - float fuser3; - float fuser4; - vec3_t vuser1; - vec3_t vuser2; - vec3_t vuser3; - vec3_t vuser4; - -} physent_t; - -typedef struct playermove_s -{ - int player_index; // So we don't try to run the PM_CheckStuck nudging too quickly. - qboolean server; // For debugging, are we running physics code on server side? - qboolean multiplayer; // 1 == multiplayer server - float time; // realtime on host, for reckoning duck timing - float frametime; // Duration of this frame - vec3_t forward, right, up; // Vectors for angles - vec3_t origin; // Movement origin. - vec3_t angles; // Movement view angles. - vec3_t oldangles; // Angles before movement view angles were looked at. - vec3_t velocity; // Current movement direction. - vec3_t movedir; // For waterjumping, a forced forward velocity so we can fly over lip of ledge. - vec3_t basevelocity; // Velocity of the conveyor we are standing, e.g. - vec3_t view_ofs; // For ducking/dead - // Our eye position. - float flDuckTime; // Time we started duck - qboolean bInDuck; // In process of ducking or ducked already? - int flTimeStepSound; // For walking/falling - // Next time we can play a step sound - int iStepLeft; - float flFallVelocity; - vec3_t punchangle; - float flSwimTime; - float flNextPrimaryAttack; - int effects; // MUZZLE FLASH, e.g. - int flags; // FL_ONGROUND, FL_DUCKING, etc. - int usehull; // 0 = regular player hull, 1 = ducked player hull, 2 = point hull - float gravity; // Our current gravity and friction. - float friction; - int oldbuttons; // Buttons last usercmd - float waterjumptime; // Amount of time left in jumping out of water cycle. - qboolean dead; // Are we a dead player? - int deadflag; - int spectator; // Should we use spectator physics model? - int movetype; // Our movement type, NOCLIP, WALK, FLY - int onground; // -1 = in air, else pmove entity number - int waterlevel; - int watertype; - int oldwaterlevel; - char sztexturename[256]; - char chtexturetype; - float maxspeed; - float clientmaxspeed; - int iuser1; - int iuser2; - int iuser3; - int iuser4; - float fuser1; - float fuser2; - float fuser3; - float fuser4; - vec3_t vuser1; - vec3_t vuser2; - vec3_t vuser3; - vec3_t vuser4; - int numphysent; // world state - // Number of entities to clip against. - physent_t physents[MAX_PHYSENTS]; - int nummoveent; // Number of momvement entities (ladders) - physent_t moveents[MAX_MOVEENTS]; // just a list of ladders - int numvisent; // All things being rendered, for tracing against things you don't actually collide with - physent_t visents[MAX_PHYSENTS]; - usercmd_t cmd; // input to run through physics. - int numtouch; // Trace results for objects we collided with. - pmtrace_t touchindex[MAX_PHYSENTS]; - char physinfo[MAX_PHYSINFO_STRING]; // Physics info string - struct movevars_s *movevars; - vec_t _player_mins[4][3]; - vec_t _player_maxs[4][3]; - - const char *(*PM_Info_ValueForKey)(const char *s, const char *key); - void (*PM_Particle)(float *origin, int color, float life, int zpos, int zvel); - int (*PM_TestPlayerPosition)(float *pos, pmtrace_t *ptrace); - void (*Con_NPrintf)(int idx, char *fmt, ...); - void (*Con_DPrintf)(char *fmt, ...); - void (*Con_Printf)(char *fmt, ...); - double (*Sys_FloatTime)(); - void (*PM_StuckTouch)(int hitent, pmtrace_t *ptraceresult); - int (*PM_PointContents)(float *p, int *truecontents); - int (*PM_TruePointContents)(float *p); - int (*PM_HullPointContents)(struct hull_s *hull, int num, float *p); - pmtrace_t (*PM_PlayerTrace)(float *start, float *end, int traceFlags, int ignore_pe); - struct pmtrace_s *(*PM_TraceLine)(float *start, float *end, int flags, int usehulll, int ignore_pe); - int32 (*RandomLong)(int32 lLow, int32 lHigh); - float (*RandomFloat)(float flLow, float flHigh); - int (*PM_GetModelType)(struct model_s *mod); - void (*PM_GetModelBounds)(struct model_s *mod, float *mins, float *maxs); - void *(*PM_HullForBsp)(physent_t *pe, float *offset); - float (*PM_TraceModel)(physent_t *pEnt, float *start, float *end, trace_t *trace); - int (*COM_FileSize)(char *filename); - byte *(*COM_LoadFile)(char *path, int usehunk, int *pLength); - void (*COM_FreeFile)(void *buffer); - char *(*memfgets)(byte *pMemFile, int fileSize, int *pFilePos, char *pBuffer, int bufferSize); - qboolean runfuncs; - void (*PM_PlaySound)(int channel, const char *sample, float volume, float attenuation, int fFlags, int pitch); - const char *(*PM_TraceTexture)(int ground, float *vstart, float *vend); - void (*PM_PlaybackEventFull)(int flags, int clientindex, unsigned short eventindex, float delay, float *origin, float *angles, float fparam1, float fparam2, int iparam1, int iparam2, int bparam1, int bparam2); - -} playermove_t; diff --git a/regamedll/extra/cssdk/pm_shared/pm_info.h b/regamedll/extra/cssdk/pm_shared/pm_info.h deleted file mode 100644 index 68375db0..00000000 --- a/regamedll/extra/cssdk/pm_shared/pm_info.h +++ /dev/null @@ -1,30 +0,0 @@ -/* -* -* This program is free software; you can redistribute it and/or modify it -* under the terms of the GNU General Public License as published by the -* Free Software Foundation; either version 2 of the License, or (at -* your option) any later version. -* -* This program 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 -* General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* -*/ -#pragma once - -#define MAX_PHYSINFO_STRING 256 diff --git a/regamedll/extra/cssdk/pm_shared/pm_materials.h b/regamedll/extra/cssdk/pm_shared/pm_materials.h deleted file mode 100644 index 6468273b..00000000 --- a/regamedll/extra/cssdk/pm_shared/pm_materials.h +++ /dev/null @@ -1,45 +0,0 @@ -/* -* -* This program is free software; you can redistribute it and/or modify it -* under the terms of the GNU General Public License as published by the -* Free Software Foundation; either version 2 of the License, or (at -* your option) any later version. -* -* This program 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 -* General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* -*/ -#pragma once - -#define CTEXTURESMAX 1024 // max number of textures loaded -#define CBTEXTURENAMEMAX 17 // only load first n chars of name - -#define CHAR_TEX_CONCRETE 'C' // texture types -#define CHAR_TEX_METAL 'M' -#define CHAR_TEX_DIRT 'D' -#define CHAR_TEX_VENT 'V' -#define CHAR_TEX_GRATE 'G' -#define CHAR_TEX_TILE 'T' -#define CHAR_TEX_SLOSH 'S' -#define CHAR_TEX_WOOD 'W' -#define CHAR_TEX_COMPUTER 'P' -#define CHAR_TEX_GRASS 'X' -#define CHAR_TEX_GLASS 'Y' -#define CHAR_TEX_FLESH 'F' -#define CHAR_TEX_SNOW 'N' diff --git a/regamedll/extra/cssdk/pm_shared/pm_movevars.h b/regamedll/extra/cssdk/pm_shared/pm_movevars.h deleted file mode 100644 index 9d22d021..00000000 --- a/regamedll/extra/cssdk/pm_shared/pm_movevars.h +++ /dev/null @@ -1,59 +0,0 @@ -/* -* -* This program is free software; you can redistribute it and/or modify it -* under the terms of the GNU General Public License as published by the -* Free Software Foundation; either version 2 of the License, or (at -* your option) any later version. -* -* This program 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 -* General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* -*/ -#pragma once - -typedef struct movevars_s -{ - float gravity; // Gravity for map - float stopspeed; // Deceleration when not moving - float maxspeed; // Max allowed speed - float spectatormaxspeed; - float accelerate; // Acceleration factor - float airaccelerate; // Same for when in open air - float wateraccelerate; // Same for when in water - float friction; - float edgefriction; // Extra friction near dropofs - float waterfriction; // Less in water - float entgravity; // 1.0 - float bounce; // Wall bounce value. 1.0 - float stepsize; // sv_stepsize; - float maxvelocity; // maximum server velocity. - float zmax; // Max z-buffer range (for GL) - float waveHeight; // Water wave height (for GL) - qboolean footsteps; // Play footstep sounds - char skyName[32]; // Name of the sky map - float rollangle; - float rollspeed; - float skycolor_r; // Sky color - float skycolor_g; - float skycolor_b; - float skyvec_x; // Sky vector - float skyvec_y; - float skyvec_z; - -} movevars_t; diff --git a/regamedll/extra/cssdk/pm_shared/pm_shared.h b/regamedll/extra/cssdk/pm_shared/pm_shared.h deleted file mode 100644 index 73a5371b..00000000 --- a/regamedll/extra/cssdk/pm_shared/pm_shared.h +++ /dev/null @@ -1,75 +0,0 @@ -/* -* -* This program is free software; you can redistribute it and/or modify it -* under the terms of the GNU General Public License as published by the -* Free Software Foundation; either version 2 of the License, or (at -* your option) any later version. -* -* This program 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 -* General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* -*/ -#pragma once - -#define PM_DEAD_VIEWHEIGHT -8 - -#define OBS_NONE 0 -#define OBS_CHASE_LOCKED 1 -#define OBS_CHASE_FREE 2 -#define OBS_ROAMING 3 -#define OBS_IN_EYE 4 -#define OBS_MAP_FREE 5 -#define OBS_MAP_CHASE 6 - -#define STEP_CONCRETE 0 -#define STEP_METAL 1 -#define STEP_DIRT 2 -#define STEP_VENT 3 -#define STEP_GRATE 4 -#define STEP_TILE 5 -#define STEP_SLOSH 6 -#define STEP_WADE 7 -#define STEP_LADDER 8 -#define STEP_SNOW 9 - -#define WJ_HEIGHT 8 -#define STOP_EPSILON 0.1 -#define MAX_CLIMB_SPEED 200 -#define PLAYER_DUCKING_MULTIPLIER 0.333 -#define PM_CHECKSTUCK_MINTIME 0.05 // Don't check again too quickly. - -#define PLAYER_LONGJUMP_SPEED 350.0f // how fast we longjump - -// Ducking time -#define TIME_TO_DUCK 0.4 -#define STUCK_MOVEUP 1 - -#define PM_VEC_DUCK_HULL_MIN -18 -#define PM_VEC_HULL_MIN -36 -#define PM_VEC_DUCK_VIEW 12 -#define PM_VEC_VIEW 17 - -#define PM_PLAYER_MAX_SAFE_FALL_SPEED 580 // approx 20 feet -#define PM_PLAYER_MIN_BOUNCE_SPEED 350 -#define PM_PLAYER_FALL_PUNCH_THRESHHOLD 250 // won't punch player's screen/make scrape noise unless player falling at least this fast. - -// Only allow bunny jumping up to 1.2x server / player maxspeed setting -#define BUNNYJUMP_MAX_SPEED_FACTOR 1.2f - -extern struct playermove_s *pmove; diff --git a/regamedll/extra/cssdk/public/FileSystem.h b/regamedll/extra/cssdk/public/FileSystem.h deleted file mode 100644 index e1ce53cf..00000000 --- a/regamedll/extra/cssdk/public/FileSystem.h +++ /dev/null @@ -1,189 +0,0 @@ -//========= Copyright � 1996-2001, Valve LLC, All rights reserved. ============ -// -// Purpose: -// -// $NoKeywords: $ -//============================================================================= - -#ifndef FILESYSTEM_H -#define FILESYSTEM_H -#ifdef _WIN32 -#pragma once -#endif - -#include "interface.h" -#include -#include - - -//----------------------------------------------------------------------------- -// Forward declarations -//----------------------------------------------------------------------------- -typedef FILE * FileHandle_t; -typedef int FileFindHandle_t; -typedef int WaitForResourcesHandle_t; - - -//----------------------------------------------------------------------------- -// Enums used by the interface -//----------------------------------------------------------------------------- -#ifndef FILESYSTEM_INTERNAL_H -typedef enum -{ - FILESYSTEM_SEEK_HEAD = 0, - FILESYSTEM_SEEK_CURRENT, - FILESYSTEM_SEEK_TAIL, -} FileSystemSeek_t; - -enum -{ - FILESYSTEM_INVALID_FIND_HANDLE = -1 -}; - -typedef enum -{ - // Don't print anything - FILESYSTEM_WARNING_QUIET = 0, - - // On shutdown, report names of files left unclosed - FILESYSTEM_WARNING_REPORTUNCLOSED, - - // Report number of times a file was opened, closed - FILESYSTEM_WARNING_REPORTUSAGE, - - // Report all open/close events to console ( !slow! ) - FILESYSTEM_WARNING_REPORTALLACCESSES -} FileWarningLevel_t; - -#define FILESYSTEM_INVALID_HANDLE ( FileHandle_t )0 -#endif - -// turn off any windows defines -#undef GetCurrentDirectory - -//----------------------------------------------------------------------------- -// Purpose: Main file system interface -//----------------------------------------------------------------------------- -class IFileSystem : public IBaseInterface -{ -public: - // Mount and unmount the filesystem - virtual void Mount( void ) = 0; - virtual void Unmount( void ) = 0; - - // Remove all search paths (including write path?) - virtual void RemoveAllSearchPaths( void ) = 0; - - // Add paths in priority order (mod dir, game dir, ....) - // If one or more .pak files are in the specified directory, then they are - // added after the file system path - // If the path is the relative path to a .bsp file, then any previous .bsp file - // override is cleared and the current .bsp is searched for an embedded PAK file - // and this file becomes the highest priority search path ( i.e., it's looked at first - // even before the mod's file system path ). - virtual void AddSearchPath( const char *pPath, const char *pathID ) = 0; - virtual bool RemoveSearchPath( const char *pPath ) = 0; - - // Deletes a file - virtual void RemoveFile( const char *pRelativePath, const char *pathID ) = 0; - - // this isn't implementable on STEAM as is. - virtual void CreateDirHierarchy( const char *path, const char *pathID ) = 0; - - // File I/O and info - virtual bool FileExists( const char *pFileName ) = 0; - virtual bool IsDirectory( const char *pFileName ) = 0; - - // opens a file - // if pathID is NULL, all paths will be searched for the file - virtual FileHandle_t Open( const char *pFileName, const char *pOptions, const char *pathID = 0L ) = 0; - - virtual void Close( FileHandle_t file ) = 0; - - virtual void Seek( FileHandle_t file, int pos, FileSystemSeek_t seekType ) = 0; - virtual unsigned int Tell( FileHandle_t file ) = 0; - - virtual unsigned int Size( FileHandle_t file ) = 0; - virtual unsigned int Size( const char *pFileName ) = 0; - - virtual long GetFileTime( const char *pFileName ) = 0; - virtual void FileTimeToString( char* pStrip, int maxCharsIncludingTerminator, long fileTime ) = 0; - - virtual bool IsOk( FileHandle_t file ) = 0; - - virtual void Flush( FileHandle_t file ) = 0; - virtual bool EndOfFile( FileHandle_t file ) = 0; - - virtual int Read( void* pOutput, int size, FileHandle_t file ) = 0; - virtual int Write( void const* pInput, int size, FileHandle_t file ) = 0; - virtual char *ReadLine( char *pOutput, int maxChars, FileHandle_t file ) = 0; - virtual int FPrintf( FileHandle_t file, char *pFormat, ... ) = 0; - - // direct filesystem buffer access - // returns a handle to a buffer containing the file data - // this is the optimal way to access the complete data for a file, - // since the file preloader has probably already got it in memory - virtual void *GetReadBuffer( FileHandle_t file, int *outBufferSize, bool failIfNotInCache ) = 0; - virtual void ReleaseReadBuffer( FileHandle_t file, void *readBuffer ) = 0; - - // FindFirst/FindNext - virtual const char *FindFirst( const char *pWildCard, FileFindHandle_t *pHandle, const char *pathID = 0L ) = 0; - virtual const char *FindNext( FileFindHandle_t handle ) = 0; - virtual bool FindIsDirectory( FileFindHandle_t handle ) = 0; - virtual void FindClose( FileFindHandle_t handle ) = 0; - - virtual void GetLocalCopy( const char *pFileName ) = 0; - - virtual const char *GetLocalPath( const char *pFileName, char *pLocalPath, int localPathBufferSize ) = 0; - - // Note: This is sort of a secondary feature; but it's really useful to have it here - virtual char *ParseFile( char* pFileBytes, char* pToken, bool* pWasQuoted ) = 0; - - // Returns true on success ( based on current list of search paths, otherwise false if it can't be resolved ) - virtual bool FullPathToRelativePath( const char *pFullpath, char *pRelative ) = 0; - - // Gets the current working directory - virtual bool GetCurrentDirectory( char* pDirectory, int maxlen ) = 0; - - // Dump to printf/OutputDebugString the list of files that have not been closed - virtual void PrintOpenedFiles( void ) = 0; - - virtual void SetWarningFunc( void (*pfnWarning)( const char *fmt, ... ) ) = 0; - virtual void SetWarningLevel( FileWarningLevel_t level ) = 0; - - virtual void LogLevelLoadStarted( const char *name ) = 0; - virtual void LogLevelLoadFinished( const char *name ) = 0; - virtual int HintResourceNeed( const char *hintlist, int forgetEverything ) = 0; - virtual int PauseResourcePreloading( void ) = 0; - virtual int ResumeResourcePreloading( void ) = 0; - virtual int SetVBuf( FileHandle_t stream, char *buffer, int mode, long size ) = 0; - virtual void GetInterfaceVersion( char *p, int maxlen ) = 0; - virtual bool IsFileImmediatelyAvailable(const char *pFileName) = 0; - - // starts waiting for resources to be available - // returns FILESYSTEM_INVALID_HANDLE if there is nothing to wait on - virtual WaitForResourcesHandle_t WaitForResources( const char *resourcelist ) = 0; - // get progress on waiting for resources; progress is a float [0, 1], complete is true on the waiting being done - // returns false if no progress is available - // any calls after complete is true or on an invalid handle will return false, 0.0f, true - virtual bool GetWaitForResourcesProgress( WaitForResourcesHandle_t handle, float *progress /* out */ , bool *complete /* out */ ) = 0; - // cancels a progress call - virtual void CancelWaitForResources( WaitForResourcesHandle_t handle ) = 0; - // returns true if the appID has all its caches fully preloaded - virtual bool IsAppReadyForOfflinePlay( int appID ) = 0; - - // interface for custom pack files > 4Gb - virtual bool AddPackFile( const char *fullpath, const char *pathID ) = 0; - - // open a file but force the data to come from the steam cache, NOT from disk - virtual FileHandle_t OpenFromCacheForRead( const char *pFileName, const char *pOptions, const char *pathID = 0L ) = 0; - - virtual void AddSearchPathNoWrite( const char *pPath, const char *pathID ) = 0; -}; - -// Steam3/Src compat -#define IBaseFileSystem IFileSystem - -#define FILESYSTEM_INTERFACE_VERSION "VFileSystem009" - -#endif // FILESYSTEM_H diff --git a/regamedll/extra/cssdk/public/basetypes.h b/regamedll/extra/cssdk/public/basetypes.h deleted file mode 100644 index 9078a04c..00000000 --- a/regamedll/extra/cssdk/public/basetypes.h +++ /dev/null @@ -1,275 +0,0 @@ -//========= Copyright 1996-2001, Valve LLC, All rights reserved. ============ -// -// Purpose: -// -// $NoKeywords: $ -//============================================================================= - -#ifndef BASETYPES_H -#define BASETYPES_H -#ifdef _WIN32 -#pragma once -#endif - -#include "osconfig.h" -#include "protected_things.h" -#include "commonmacros.h" - -#include "mathlib.h" - -// For backward compatibilty only... -#include "tier0/platform.h" - -// stdio.h -#ifndef NULL -#define NULL 0 -#endif - - -#define ExecuteNTimes( nTimes, x ) \ - { \ - static int __executeCount=0;\ - if ( __executeCount < nTimes )\ - { \ - x; \ - ++__executeCount; \ - } \ - } - - -#define ExecuteOnce( x ) ExecuteNTimes( 1, x ) - - -// Pad a number so it lies on an N byte boundary. -// So PAD_NUMBER(0,4) is 0 and PAD_NUMBER(1,4) is 4 -#define PAD_NUMBER(number, boundary) \ - ( ((number) + ((boundary)-1)) / (boundary) ) * (boundary) - -#ifndef FALSE -#define FALSE 0 -#define TRUE (!FALSE) -#endif - - -typedef int BOOL; -typedef int qboolean; -typedef unsigned long ULONG; -typedef unsigned char BYTE; -typedef unsigned char byte; -typedef unsigned short word; - -typedef float vec_t; - - -// FIXME: this should move -#ifndef __cplusplus -#define true TRUE -#define false FALSE -#endif - -//----------------------------------------------------------------------------- -// look for NANs, infinities, and underflows. -// This assumes the ANSI/IEEE 754-1985 standard -//----------------------------------------------------------------------------- - -#ifdef __cplusplus - -inline unsigned long& FloatBits(vec_t& f) -{ - return *reinterpret_cast(&f); -} - -inline unsigned long const& FloatBits(vec_t const& f) -{ - return *reinterpret_cast(&f); -} - -inline vec_t BitsToFloat(unsigned long i) -{ - return *reinterpret_cast(&i); -} - -inline bool IsFinite(vec_t f) -{ - return ((FloatBits(f) & 0x7F800000) != 0x7F800000); -} - -inline unsigned long FloatAbsBits(vec_t f) -{ - return FloatBits(f) & 0x7FFFFFFF; -} - -inline float FloatMakeNegative(vec_t f) -{ - return BitsToFloat(FloatBits(f) | 0x80000000); -} - -#if defined( WIN32 ) - -//#include -// Just use prototype from math.h -#ifdef __cplusplus -extern "C" -{ -#endif - double __cdecl fabs(double); -#ifdef __cplusplus -} -#endif - -// In win32 try to use the intrinsic fabs so the optimizer can do it's thing inline in the code -#pragma intrinsic( fabs ) -// Also, alias float make positive to use fabs, too -// NOTE: Is there a perf issue with double<->float conversion? -inline float FloatMakePositive(vec_t f) -{ - return fabs(f); -} -#else -inline float FloatMakePositive(vec_t f) -{ - return BitsToFloat(FloatBits(f) & 0x7FFFFFFF); -} -#endif - -inline float FloatNegate(vec_t f) -{ - return BitsToFloat(FloatBits(f) ^ 0x80000000); -} - - -#define FLOAT32_NAN_BITS (unsigned long)0x7FC00000 // not a number! -#define FLOAT32_NAN BitsToFloat( FLOAT32_NAN_BITS ) - -#define VEC_T_NAN FLOAT32_NAN - -#endif - -// FIXME: why are these here? Hardly anyone actually needs them. -struct valve_color24 -{ - byte r, g, b; -}; - -typedef struct valve_color32_s -{ - bool operator!=(const struct valve_color32_s &other) const; - - byte r, g, b, a; -} valve_color32; - -inline bool valve_color32::operator!=(const valve_color32 &other) const -{ - return r != other.r || g != other.g || b != other.b || a != other.a; -} - -struct valve_colorRGBExp32 -{ - byte r, g, b; - signed char exponent; -}; - -struct valve_colorVec -{ - unsigned r, g, b, a; -}; - - -#ifndef UNUSED -#define UNUSED(x) (x = x) // for pesky compiler / lint warnings -#endif - -#ifdef __cplusplus - -struct vrect_t -{ - int x, y, width, height; - vrect_t *pnext; -}; - -#endif - - -//----------------------------------------------------------------------------- -// MaterialRect_t struct - used for DrawDebugText -//----------------------------------------------------------------------------- -struct Rect_t -{ - int x, y; - int width, height; -}; - - -//----------------------------------------------------------------------------- -// Declares a type-safe handle type; you can't assign one handle to the next -//----------------------------------------------------------------------------- - -// 32-bit pointer handles. - -// Typesafe 8-bit and 16-bit handles. -template< class HandleType > -class CBaseIntHandle -{ -public: - - inline bool operator==(const CBaseIntHandle &other) { return m_Handle == other.m_Handle; } - inline bool operator!=(const CBaseIntHandle &other) { return m_Handle != other.m_Handle; } - - // Only the code that doles out these handles should use these functions. - // Everyone else should treat them as a transparent type. - inline HandleType GetHandleValue() { return m_Handle; } - inline void SetHandleValue(HandleType val) { m_Handle = val; } - - typedef HandleType HANDLE_TYPE; - -protected: - - HandleType m_Handle; -}; - -template< class DummyType > -class CIntHandle16 : public CBaseIntHandle < unsigned short > -{ -public: - inline CIntHandle16() {} - - static inline CIntHandle16 MakeHandle(HANDLE_TYPE val) - { - return CIntHandle16(val); - } - -protected: - inline CIntHandle16(HANDLE_TYPE val) - { - m_Handle = val; - } -}; - - -template< class DummyType > -class CIntHandle32 : public CBaseIntHandle < unsigned long > -{ -public: - inline CIntHandle32() {} - - static inline CIntHandle32 MakeHandle(HANDLE_TYPE val) - { - return CIntHandle32(val); - } - -protected: - inline CIntHandle32(HANDLE_TYPE val) - { - m_Handle = val; - } -}; - - -// NOTE: This macro is the same as windows uses; so don't change the guts of it -#define DECLARE_HANDLE_16BIT(name) typedef CIntHandle16< struct name##__handle * > name; -#define DECLARE_HANDLE_32BIT(name) typedef CIntHandle32< struct name##__handle * > name; - -#define DECLARE_POINTER_HANDLE(name) struct name##__ { int unused; }; typedef struct name##__ *name -#define FORWARD_DECLARE_HANDLE(name) typedef struct name##__ *name - -#endif // BASETYPES_H diff --git a/regamedll/extra/cssdk/public/commonmacros.h b/regamedll/extra/cssdk/public/commonmacros.h deleted file mode 100644 index e82bfd65..00000000 --- a/regamedll/extra/cssdk/public/commonmacros.h +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef COMMONMACROS_H -#define COMMONMACROS_H -#pragma once - - -// ------------------------------------------------------- -// -// commonmacros.h -// -// This should contain ONLY general purpose macros that are -// appropriate for use in engine/launcher/all tools -// -// ------------------------------------------------------- - -#include "osconfig.h" -// Makes a 4-byte "packed ID" int out of 4 characters -#define MAKEID(d,c,b,a) ( ((int)(a) << 24) | ((int)(b) << 16) | ((int)(c) << 8) | ((int)(d)) ) - -// Compares a string with a 4-byte packed ID constant -#define STRING_MATCHES_ID( p, id ) ( (*((int *)(p)) == (id) ) ? true : false ) -#define ID_TO_STRING( id, p ) ( (p)[3] = (((id)>>24) & 0xFF), (p)[2] = (((id)>>16) & 0xFF), (p)[1] = (((id)>>8) & 0xFF), (p)[0] = (((id)>>0) & 0xFF) ) - -#define ARRAYSIZE(p) (sizeof(p)/sizeof(p[0])) - -// Keeps clutter down a bit, when using a float as a bit-vector -#define SetBits(flBitVector, bits) ((flBitVector) = (int)(flBitVector) | (bits)) -#define ClearBits(flBitVector, bits) ((flBitVector) = (int)(flBitVector) & ~(bits)) -#define FBitSet(flBitVector, bit) ((int)(flBitVector) & (bit)) - -#endif // COMMONMACROS_H diff --git a/regamedll/extra/cssdk/public/interface.cpp b/regamedll/extra/cssdk/public/interface.cpp deleted file mode 100644 index 9a12eef6..00000000 --- a/regamedll/extra/cssdk/public/interface.cpp +++ /dev/null @@ -1,263 +0,0 @@ -#include "precompiled.h" -#include "interface.h" - -#if !defined ( _WIN32 ) -// Linux doesn't have this function so this emulates its functionality -// -// -void *GetModuleHandle(const char *name) -{ - void *handle; - - if (name == NULL) - { - // hmm, how can this be handled under linux.... - // is it even needed? - return NULL; - } - - if ((handle=dlopen(name, RTLD_NOW)) == NULL) - { - //printf("Error:%s\n",dlerror()); - // couldn't open this file - return NULL; - } - - // read "man dlopen" for details - // in short dlopen() inc a ref count - // so dec the ref count by performing the close - dlclose(handle); - return handle; -} -#endif - -// ------------------------------------------------------------------------------------ // -// InterfaceReg. -// ------------------------------------------------------------------------------------ // -InterfaceReg *InterfaceReg::s_pInterfaceRegs = NULL; - - -InterfaceReg::InterfaceReg( InstantiateInterfaceFn fn, const char *pName ) : m_pName(pName) -{ - m_CreateFn = fn; - m_pNext = s_pInterfaceRegs; - s_pInterfaceRegs = this; -} - - - -// ------------------------------------------------------------------------------------ // -// CreateInterface. -// ------------------------------------------------------------------------------------ // -EXPORT_FUNCTION IBaseInterface *CreateInterface( const char *pName, int *pReturnCode ) -{ - InterfaceReg *pCur; - - for(pCur=InterfaceReg::s_pInterfaceRegs; pCur; pCur=pCur->m_pNext) - { - if(strcmp(pCur->m_pName, pName) == 0) - { - if ( pReturnCode ) - { - *pReturnCode = IFACE_OK; - } - return pCur->m_CreateFn(); - } - } - - if ( pReturnCode ) - { - *pReturnCode = IFACE_FAILED; - } - return NULL; -} - -#ifdef LINUX -static IBaseInterface *CreateInterfaceLocal( const char *pName, int *pReturnCode ) -{ - InterfaceReg *pCur; - - for(pCur=InterfaceReg::s_pInterfaceRegs; pCur; pCur=pCur->m_pNext) - { - if(strcmp(pCur->m_pName, pName) == 0) - { - if ( pReturnCode ) - { - *pReturnCode = IFACE_OK; - } - return pCur->m_CreateFn(); - } - } - - if ( pReturnCode ) - { - *pReturnCode = IFACE_FAILED; - } - return NULL; -} -#endif - -#ifdef _WIN32 -#define WIN32_LEAN_AND_MEAN -#include "windows.h" -#endif - -//----------------------------------------------------------------------------- -// Purpose: returns a pointer to a function, given a module -// Input : pModuleName - module name -// *pName - proc name -//----------------------------------------------------------------------------- -//static hlds_run wants to use this function -void *Sys_GetProcAddress( const char *pModuleName, const char *pName ) -{ - return GetProcAddress( GetModuleHandle(pModuleName), pName ); -} - -//----------------------------------------------------------------------------- -// Purpose: returns a pointer to a function, given a module -// Input : pModuleName - module name -// *pName - proc name -//----------------------------------------------------------------------------- -// hlds_run wants to use this function -void *Sys_GetProcAddress( void *pModuleHandle, const char *pName ) -{ -#if defined ( _WIN32 ) - return GetProcAddress( (HINSTANCE)pModuleHandle, pName ); -#else - return GetProcAddress( pModuleHandle, pName ); -#endif -} - -//----------------------------------------------------------------------------- -// Purpose: Loads a DLL/component from disk and returns a handle to it -// Input : *pModuleName - filename of the component -// Output : opaque handle to the module (hides system dependency) -//----------------------------------------------------------------------------- -CSysModule *Sys_LoadModule( const char *pModuleName ) -{ -#if defined ( _WIN32 ) - HMODULE hDLL = LoadLibrary( pModuleName ); -#else - HMODULE hDLL = NULL; - char szAbsoluteModuleName[1024]; - szAbsoluteModuleName[0] = 0; - if ( pModuleName[0] != '/' ) - { - char szCwd[1024]; - char szAbsoluteModuleName[1024]; - - getcwd( szCwd, sizeof( szCwd ) ); - if ( szCwd[ strlen( szCwd ) - 1 ] == '/' ) - szCwd[ strlen( szCwd ) - 1 ] = 0; - - _snprintf( szAbsoluteModuleName, sizeof(szAbsoluteModuleName), "%s/%s", szCwd, pModuleName ); - - hDLL = dlopen( szAbsoluteModuleName, RTLD_NOW ); - } - else - { - _snprintf( szAbsoluteModuleName, sizeof(szAbsoluteModuleName), "%s", pModuleName ); - hDLL = dlopen( pModuleName, RTLD_NOW ); - } -#endif - - if( !hDLL ) - { - char str[512]; -#if defined ( _WIN32 ) - _snprintf( str, sizeof(str), "%s.dll", pModuleName ); - hDLL = LoadLibrary( str ); -#elif defined(OSX) - printf("Error:%s\n",dlerror()); - _snprintf( str, sizeof(str), "%s.dylib", szAbsoluteModuleName ); - hDLL = dlopen(str, RTLD_NOW); -#else - printf("Error:%s\n",dlerror()); - _snprintf( str, sizeof(str), "%s.so", szAbsoluteModuleName ); - hDLL = dlopen(str, RTLD_NOW); -#endif - } - - return reinterpret_cast(hDLL); -} - -//----------------------------------------------------------------------------- -// Purpose: Unloads a DLL/component from -// Input : *pModuleName - filename of the component -// Output : opaque handle to the module (hides system dependency) -//----------------------------------------------------------------------------- -void Sys_UnloadModule( CSysModule *pModule ) -{ - if ( !pModule ) - return; - - HMODULE hDLL = reinterpret_cast(pModule); -#if defined ( _WIN32 ) - FreeLibrary( hDLL ); -#else - dlclose((void *)hDLL); -#endif - -} - -//----------------------------------------------------------------------------- -// Purpose: returns a pointer to a function, given a module -// Input : module - windows HMODULE from Sys_LoadModule() -// *pName - proc name -// Output : factory for this module -//----------------------------------------------------------------------------- -CreateInterfaceFn Sys_GetFactory( CSysModule *pModule ) -{ - if ( !pModule ) - return NULL; - - HMODULE hDLL = reinterpret_cast(pModule); -#if defined ( _WIN32 ) - return reinterpret_cast(GetProcAddress( hDLL, CREATEINTERFACE_PROCNAME )); -#else -// Linux gives this error: -//../public/interface.cpp: In function `IBaseInterface *(*Sys_GetFactory -//(CSysModule *)) (const char *, int *)': -//../public/interface.cpp:154: ISO C++ forbids casting between -//pointer-to-function and pointer-to-object -// -// so lets get around it :) - return (CreateInterfaceFn)(GetProcAddress( hDLL, CREATEINTERFACE_PROCNAME )); -#endif -} - - - -//----------------------------------------------------------------------------- -// Purpose: returns the instance of this module -// Output : interface_instance_t -//----------------------------------------------------------------------------- -CreateInterfaceFn Sys_GetFactoryThis( void ) -{ -#ifdef LINUX - return CreateInterfaceLocal; -#else - return CreateInterface; -#endif -} - -//----------------------------------------------------------------------------- -// Purpose: returns the instance of the named module -// Input : *pModuleName - name of the module -// Output : interface_instance_t - instance of that module -//----------------------------------------------------------------------------- -CreateInterfaceFn Sys_GetFactory( const char *pModuleName ) -{ -#if defined ( _WIN32 ) - return static_cast( Sys_GetProcAddress( pModuleName, CREATEINTERFACE_PROCNAME ) ); -#else -// Linux gives this error: -//../public/interface.cpp: In function `IBaseInterface *(*Sys_GetFactory -//(const char *)) (const char *, int *)': -//../public/interface.cpp:186: invalid static_cast from type `void *' to -//type `IBaseInterface *(*) (const char *, int *)' -// -// so lets use the old style cast. - return (CreateInterfaceFn)( Sys_GetProcAddress( pModuleName, CREATEINTERFACE_PROCNAME ) ); -#endif -} diff --git a/regamedll/extra/cssdk/public/interface.h b/regamedll/extra/cssdk/public/interface.h deleted file mode 100644 index 3349146c..00000000 --- a/regamedll/extra/cssdk/public/interface.h +++ /dev/null @@ -1,150 +0,0 @@ - -// This header defines the interface convention used in the valve engine. -// To make an interface and expose it: -// 1. Derive from IBaseInterface. -// 2. The interface must be ALL pure virtuals, and have no data members. -// 3. Define a name for it. -// 4. In its implementation file, use EXPOSE_INTERFACE or EXPOSE_SINGLE_INTERFACE. - -// Versioning -// There are two versioning cases that are handled by this: -// 1. You add functions to the end of an interface, so it is binary compatible with the previous interface. In this case, -// you need two EXPOSE_INTERFACEs: one to expose your class as the old interface and one to expose it as the new interface. -// 2. You update an interface so it's not compatible anymore (but you still want to be able to expose the old interface -// for legacy code). In this case, you need to make a new version name for your new interface, and make a wrapper interface and -// expose it for the old interface. - -//#if _MSC_VER >= 1300 // VC7 -//#include "tier1/interface.h" -//#else - -#ifndef INTERFACE_H -#define INTERFACE_H - -#if !defined ( _WIN32 ) - -#include // dlopen,dlclose, et al -#include - -#define HMODULE void * -#define GetProcAddress dlsym - -#define _snprintf snprintf - -#endif - -void *Sys_GetProcAddress(const char *pModuleName, const char *pName); -void *Sys_GetProcAddress(void *pModuleHandle, const char *pName); - -// All interfaces derive from this. -class IBaseInterface -{ -public: - - virtual ~IBaseInterface() {} -}; - - -#define CREATEINTERFACE_PROCNAME "CreateInterface" -typedef IBaseInterface* (*CreateInterfaceFn)(const char *pName, int *pReturnCode); - - -typedef IBaseInterface* (*InstantiateInterfaceFn)(); - - -// Used internally to register classes. -class InterfaceReg -{ -public: - InterfaceReg(InstantiateInterfaceFn fn, const char *pName); - -public: - - InstantiateInterfaceFn m_CreateFn; - const char *m_pName; - - InterfaceReg *m_pNext; // For the global list. - static InterfaceReg *s_pInterfaceRegs; -}; - - -// Use this to expose an interface that can have multiple instances. -// e.g.: -// EXPOSE_INTERFACE( CInterfaceImp, IInterface, "MyInterface001" ) -// This will expose a class called CInterfaceImp that implements IInterface (a pure class) -// clients can receive a pointer to this class by calling CreateInterface( "MyInterface001" ) -// -// In practice, the shared header file defines the interface (IInterface) and version name ("MyInterface001") -// so that each component can use these names/vtables to communicate -// -// A single class can support multiple interfaces through multiple inheritance -// -// Use this if you want to write the factory function. -#define EXPOSE_INTERFACE_FN(functionName, interfaceName, versionName) \ - static InterfaceReg __g_Create##className##_reg(functionName, versionName); - -#define EXPOSE_INTERFACE(className, interfaceName, versionName) \ - static IBaseInterface* __Create##className##_interface() {return (interfaceName *)new className;}\ - static InterfaceReg __g_Create##className##_reg(__Create##className##_interface, versionName ); - -// Use this to expose a singleton interface with a global variable you've created. -#define EXPOSE_SINGLE_INTERFACE_GLOBALVAR(className, interfaceName, versionName, globalVarName) \ - static IBaseInterface* __Create##className##interfaceName##_interface() {return (IBaseInterface *)&globalVarName;}\ - static InterfaceReg __g_Create##className##interfaceName##_reg(__Create##className##interfaceName##_interface, versionName); - -// Use this to expose a singleton interface. This creates the global variable for you automatically. -#define EXPOSE_SINGLE_INTERFACE(className, interfaceName, versionName) \ - static className __g_##className##_singleton;\ - EXPOSE_SINGLE_INTERFACE_GLOBALVAR(className, interfaceName, versionName, __g_##className##_singleton) - - -#ifdef _WIN32 - #define EXPORT_FUNCTION __declspec(dllexport) -#else - #define EXPORT_FUNCTION __attribute__ ((visibility("default"))) -#endif - - -// This function is automatically exported and allows you to access any interfaces exposed with the above macros. -// if pReturnCode is set, it will return one of the following values -// extend this for other error conditions/code -enum -{ - IFACE_OK = 0, - IFACE_FAILED -}; - - -extern "C" -{ - EXPORT_FUNCTION IBaseInterface* CreateInterface(const char *pName, int *pReturnCode); -}; - - -extern CreateInterfaceFn Sys_GetFactoryThis( void ); - - -//----------------------------------------------------------------------------- -// UNDONE: This is obsolete, use the module load/unload/get instead!!! -//----------------------------------------------------------------------------- -extern CreateInterfaceFn Sys_GetFactory( const char *pModuleName ); - - -// load/unload components -class CSysModule; - -//----------------------------------------------------------------------------- -// Load & Unload should be called in exactly one place for each module -// The factory for that module should be passed on to dependent components for -// proper versioning. -//----------------------------------------------------------------------------- -extern CSysModule *Sys_LoadModule( const char *pModuleName ); -extern void Sys_UnloadModule( CSysModule *pModule ); - -extern CreateInterfaceFn Sys_GetFactory( CSysModule *pModule ); - - -#endif -//#endif // MSVC 6.0 - - diff --git a/regamedll/extra/cssdk/public/protected_things.h b/regamedll/extra/cssdk/public/protected_things.h deleted file mode 100644 index 201438e8..00000000 --- a/regamedll/extra/cssdk/public/protected_things.h +++ /dev/null @@ -1,187 +0,0 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ -// -// Purpose: -// -// $NoKeywords: $ -//============================================================================= - -#ifndef PROTECTED_THINGS_H -#define PROTECTED_THINGS_H -#ifdef _WIN32 -#pragma once -#endif - - -// This header tries to prevent people from using potentially dangerous functions -// (like the notorious non-null-terminating strncpy) and functions that will break -// VCR mode (like time, input, registry, etc). -// -// This header should be included by ALL of our source code. - -// Eventually, ALL of these should be protected, but one man can only accomplish so much in -// one day AND work on features too! -#if defined( PROTECT_STRING_FUNCTIONS ) -#if defined( strncpy ) -#undef strncpy -#endif -#define strncpy strncpy__HEY_YOU__USE_VSTDLIB - - -#if defined( _snprintf ) -#undef _snprintf -#endif -#define _snprintf snprintf__HEY_YOU__USE_VSTDLIB - - -#if defined( sprintf ) -#undef sprintf -#endif -#define sprintf sprintf__HEY_YOU__USE_VSTDLIB - - -#if defined( _vsnprintf ) -#undef _vsnprintf -#endif -#define _vsnprintf vsnprintf__HEY_YOU__USE_VSTDLIB - - -#if defined( strcat ) -#undef strcat -#endif -#define strcat strcat__HEY_YOU__USE_VSTDLIB -#endif - - -#if defined( PROTECT_FILEIO_FUNCTIONS ) -#if defined( fopen ) -#undef fopen -#endif -#define fopen fopen_USE_FILESYSTEM_INSTEAD -#endif - - -#if defined( PROTECTED_THINGS_ENABLE ) - -#if defined( GetTickCount ) -#undef GetTickCount -#endif -#define GetTickCount GetTickCount__HEY_YOU__USE_PLATFORM_LIB - - -#if defined( timeGetTime ) -#undef timeGetTime -#endif -#define timeGetTime timeGetTime__HEY_YOU__USE_PLATFORM_LIB - - -#if defined( clock ) -#undef clock -#endif -#define time time__HEY_YOU__USE_PLATFORM_LIB - - -#if defined( recvfrom ) -#undef recvfrom -#endif -#define recvfrom recvfrom__HEY_YOU__USE_PLATFORM_LIB - - -#if defined( GetCursorPos ) -#undef GetCursorPos -#endif -#define GetCursorPos GetCursorPos__HEY_YOU__USE_PLATFORM_LIB - - -#if defined( ScreenToClient ) -#undef ScreenToClient -#endif -#define ScreenToClient ScreenToClient__HEY_YOU__USE_PLATFORM_LIB - - -#if defined( GetCommandLine ) -#undef GetCommandLine -#endif -#define GetCommandLine GetCommandLine__HEY_YOU__USE_PLATFORM_LIB - - -#if defined( RegOpenKeyEx ) -#undef RegOpenKeyEx -#endif -#define RegOpenKeyEx RegOpenKeyEx__HEY_YOU__USE_PLATFORM_LIB - - -#if defined( RegOpenKey ) -#undef RegOpenKey -#endif -#define RegOpenKey RegOpenKey__HEY_YOU__USE_PLATFORM_LIB - - -#if defined( RegSetValueEx ) -#undef RegSetValueEx -#endif -#define RegSetValueEx RegSetValueEx__HEY_YOU__USE_PLATFORM_LIB - - -#if defined( RegSetValue ) -#undef RegSetValue -#endif -#define RegSetValue RegSetValue__HEY_YOU__USE_PLATFORM_LIB - - -#if defined( RegQueryValueEx ) -#undef RegQueryValueEx -#endif -#define RegQueryValueEx RegQueryValueEx__HEY_YOU__USE_PLATFORM_LIB - - -#if defined( RegQueryValue ) -#undef RegQueryValue -#endif -#define RegQueryValue RegQueryValue__HEY_YOU__USE_PLATFORM_LIB - - -#if defined( RegCreateKeyEx ) -#undef RegCreateKeyEx -#endif -#define RegCreateKeyEx RegCreateKeyEx__HEY_YOU__USE_PLATFORM_LIB - - -#if defined( RegCreateKey ) -#undef RegCreateKey -#endif -#define RegCreateKey RegCreateKey__HEY_YOU__USE_PLATFORM_LIB - - -#if defined( RegCloseKey ) -#undef RegCloseKey -#endif -#define RegCloseKey RegCloseKey__HEY_YOU__USE_PLATFORM_LIB - - -#if defined( GetNumberOfConsoleInputEvents ) -#undef GetNumberOfConsoleInputEvents -#endif -#define GetNumberOfConsoleInputEvents GetNumberOfConsoleInputEvents__HEY_YOU__USE_PLATFORM_LIB - - -#if defined( ReadConsoleInput ) -#undef ReadConsoleInput -#endif -#define ReadConsoleInput ReadConsoleInput__HEY_YOU__USE_PLATFORM_LIB - - -#if defined( GetAsyncKeyState ) -#undef GetAsyncKeyState -#endif -#define GetAsyncKeyState GetAsyncKeyState__HEY_YOU__USE_PLATFORM_LIB - - -#if defined( GetKeyState ) -#undef GetKeyState -#endif -#define GetKeyState GetKeyState__HEY_YOU__USE_PLATFORM_LIB - -#endif - - -#endif // PROTECTED_THINGS_H diff --git a/regamedll/extra/cssdk/public/tier0/dbg.cpp b/regamedll/extra/cssdk/public/tier0/dbg.cpp deleted file mode 100644 index 36994aaa..00000000 --- a/regamedll/extra/cssdk/public/tier0/dbg.cpp +++ /dev/null @@ -1,435 +0,0 @@ -//=========== (C) Copyright 1999 Valve, L.L.C. All rights reserved. =========== -// -// The copyright to the contents herein is the property of Valve, L.L.C. -// The contents may be used and/or copied only with the written permission of -// Valve, L.L.C., or in accordance with the terms and conditions stipulated in -// the agreement/contract under which the contents have been supplied. -// -// $Header: $ -// $NoKeywords: $ -// -// The main debug library implementation -//============================================================================= - -#include "precompiled.h" - -//----------------------------------------------------------------------------- -// internal structures -//----------------------------------------------------------------------------- - -enum -{ - MAX_GROUP_NAME_LENGTH = 48 -}; - -struct SpewGroup_t -{ - char m_GroupName[MAX_GROUP_NAME_LENGTH]; - int m_Level; -}; - - -//----------------------------------------------------------------------------- -// Templates to assist in validating pointers: - -void _AssertValidReadPtr(void* ptr, int count/* = 1*/) -{ -#ifdef _WIN32 - Assert(!IsBadReadPtr(ptr, count)); -#else - Assert(ptr); -#endif - -} - -void _AssertValidWritePtr(void* ptr, int count/* = 1*/) -{ -#ifdef _WIN32 - Assert(!IsBadWritePtr(ptr, count)); -#else - Assert(ptr); -#endif -} - -void _AssertValidReadWritePtr(void* ptr, int count/* = 1*/) -{ -#ifdef _WIN32 - Assert(!(IsBadWritePtr(ptr, count) || IsBadReadPtr(ptr, count))); -#else - Assert(ptr); -#endif -} - -void AssertValidStringPtr(const char* ptr, int maxchar/* = 0xFFFFFF */) -{ -#ifdef _WIN32 - Assert(!IsBadStringPtr(ptr, maxchar)); -#else - Assert(ptr); -#endif -} - - -//----------------------------------------------------------------------------- -// globals -//----------------------------------------------------------------------------- - -SpewRetval_t DefaultSpewFunc(SpewType_t type, char const *pMsg) -{ - printf("%s", pMsg); - if (type == SPEW_ASSERT) - return SPEW_DEBUGGER; - else if (type == SPEW_ERROR) - return SPEW_ABORT; - else - return SPEW_CONTINUE; -} - -static SpewOutputFunc_t s_SpewOutputFunc = DefaultSpewFunc; - -static char const* s_pFileName; -static int s_Line; -static SpewType_t s_SpewType; - -static SpewGroup_t* s_pSpewGroups = 0; -static int s_GroupCount = 0; -static int s_DefaultLevel = 0; - - - -//----------------------------------------------------------------------------- -// Spew output management. -//----------------------------------------------------------------------------- - -void SpewOutputFunc(SpewOutputFunc_t func) -{ - s_SpewOutputFunc = func ? func : DefaultSpewFunc; -} - -SpewOutputFunc_t GetSpewOutputFunc(void) -{ - if (s_SpewOutputFunc) - { - return s_SpewOutputFunc; - } - else - { - return DefaultSpewFunc; - } -} - -//----------------------------------------------------------------------------- -// Spew functions -//----------------------------------------------------------------------------- - -void _SpewInfo(SpewType_t type, char const* pFile, int line) -{ - // Only grab the file name. Ignore the path. - char const* pSlash = strrchr(pFile, '\\'); - char const* pSlash2 = strrchr(pFile, '/'); - if (pSlash < pSlash2) pSlash = pSlash2; - - s_pFileName = pSlash ? pSlash + 1 : pFile; - s_Line = line; - s_SpewType = type; -} - -SpewRetval_t _SpewMessage(SpewType_t spewType, char const* pMsgFormat, va_list args) -{ - char pTempBuffer[1024]; - - /* Printf the file and line for warning + assert only... */ - int len = 0; - if ((spewType == SPEW_ASSERT)) - { - len = sprintf(pTempBuffer, "%s (%d) : ", s_pFileName, s_Line); - } - - /* Create the message.... */ - len += vsprintf(&pTempBuffer[len], pMsgFormat, args); - - // Add \n for warning and assert - if ((spewType == SPEW_ASSERT)) - { - len += sprintf(&pTempBuffer[len], "\n"); - } - - assert(len < 1024); /* use normal assert here; to avoid recursion. */ - assert(s_SpewOutputFunc); - - /* direct it to the appropriate target(s) */ - SpewRetval_t ret = s_SpewOutputFunc(spewType, pTempBuffer); - switch (ret) - { - // Put the break into the macro so it would occur in the right place - // case SPEW_DEBUGGER: - // DebuggerBreak(); - // break; - - case SPEW_ABORT: - // MessageBox(NULL,"Error in _SpewMessage","Error",MB_OK); - exit(0); - default: - break; - } - - return ret; -} - -SpewRetval_t _SpewMessage(char const* pMsgFormat, ...) -{ - va_list args; - va_start(args, pMsgFormat); - SpewRetval_t ret = _SpewMessage(s_SpewType, pMsgFormat, args); - va_end(args); - return ret; -} - -SpewRetval_t _DSpewMessage(char const *pGroupName, int level, char const* pMsgFormat, ...) -{ - if (!IsSpewActive(pGroupName, level)) - return SPEW_CONTINUE; - - va_list args; - va_start(args, pMsgFormat); - SpewRetval_t ret = _SpewMessage(s_SpewType, pMsgFormat, args); - va_end(args); - return ret; -} - -void Msg(char const* pMsgFormat, ...) -{ - va_list args; - va_start(args, pMsgFormat); - _SpewMessage(SPEW_MESSAGE, pMsgFormat, args); - va_end(args); -} - -void DMsg(char const *pGroupName, int level, char const *pMsgFormat, ...) -{ - if (!IsSpewActive(pGroupName, level)) - return; - - va_list args; - va_start(args, pMsgFormat); - _SpewMessage(SPEW_MESSAGE, pMsgFormat, args); - va_end(args); -} - -void Warning(char const *pMsgFormat, ...) -{ - va_list args; - va_start(args, pMsgFormat); - _SpewMessage(SPEW_WARNING, pMsgFormat, args); - va_end(args); -} - -void DWarning(char const *pGroupName, int level, char const *pMsgFormat, ...) -{ - if (!IsSpewActive(pGroupName, level)) - return; - - va_list args; - va_start(args, pMsgFormat); - _SpewMessage(SPEW_WARNING, pMsgFormat, args); - va_end(args); -} - -void Log(char const *pMsgFormat, ...) -{ - va_list args; - va_start(args, pMsgFormat); - _SpewMessage(SPEW_LOG, pMsgFormat, args); - va_end(args); -} - -void DLog(char const *pGroupName, int level, char const *pMsgFormat, ...) -{ - if (!IsSpewActive(pGroupName, level)) - return; - - va_list args; - va_start(args, pMsgFormat); - _SpewMessage(SPEW_LOG, pMsgFormat, args); - va_end(args); -} - -void Error(char const *pMsgFormat, ...) -{ - va_list args; - va_start(args, pMsgFormat); - _SpewMessage(SPEW_ERROR, pMsgFormat, args); - va_end(args); -} - - -//----------------------------------------------------------------------------- -// A couple of super-common dynamic spew messages, here for convenience -// These looked at the "developer" group, print if it's level 1 or higher -//----------------------------------------------------------------------------- - -void DevMsg(int level, char const* pMsgFormat, ...) -{ - if (!IsSpewActive("developer", level)) - return; - - va_list args; - va_start(args, pMsgFormat); - _SpewMessage(SPEW_MESSAGE, pMsgFormat, args); - va_end(args); -} - -void DevWarning(int level, char const *pMsgFormat, ...) -{ - if (!IsSpewActive("developer", level)) - return; - - va_list args; - va_start(args, pMsgFormat); - _SpewMessage(SPEW_WARNING, pMsgFormat, args); - va_end(args); -} - -void DevLog(int level, char const *pMsgFormat, ...) -{ - if (!IsSpewActive("developer", level)) - return; - - va_list args; - va_start(args, pMsgFormat); - _SpewMessage(SPEW_LOG, pMsgFormat, args); - va_end(args); -} - -void DevMsg(char const *pMsgFormat, ...) -{ - if (!IsSpewActive("developer", 1)) - return; - - va_list args; - va_start(args, pMsgFormat); - _SpewMessage(SPEW_MESSAGE, pMsgFormat, args); - va_end(args); -} - -void DevWarning(char const *pMsgFormat, ...) -{ - va_list args; - va_start(args, pMsgFormat); - _SpewMessage(SPEW_WARNING, pMsgFormat, args); - va_end(args); -} - -void DevLog(char const *pMsgFormat, ...) -{ - va_list args; - va_start(args, pMsgFormat); - _SpewMessage(SPEW_LOG, pMsgFormat, args); - va_end(args); -} - -//----------------------------------------------------------------------------- -// Find a group, return true if found, false if not. Return in ind the -// index of the found group, or the index of the group right before where the -// group should be inserted into the list to maintain sorted order. -//----------------------------------------------------------------------------- - -bool FindSpewGroup(char const* pGroupName, int* pInd) -{ - int s = 0; - if (s_GroupCount) - { - int e = (int)(s_GroupCount - 1); - while (s <= e) - { - int m = (s + e) >> 1; - int cmp = Q_stricmp(pGroupName, s_pSpewGroups[m].m_GroupName); - if (!cmp) - { - *pInd = m; - return true; - } - if (cmp < 0) - e = m - 1; - else - s = m + 1; - } - } - *pInd = s; - return false; -} - - -//----------------------------------------------------------------------------- -// Sets the priority level for a spew group -//----------------------------------------------------------------------------- - -void SpewActivate(char const* pGroupName, int level) -{ - Assert(pGroupName); - - // check for the default group first... - if ((pGroupName[0] == '*') && (pGroupName[1] == '\0')) - { - s_DefaultLevel = level; - return; - } - - // Normal case, search in group list using binary search. - // If not found, grow the list of groups and insert it into the - // right place to maintain sorted order. Then set the level. - int ind; - if (!FindSpewGroup(pGroupName, &ind)) - { - // not defined yet, insert an entry. - ++s_GroupCount; - if (s_pSpewGroups) - { - s_pSpewGroups = (SpewGroup_t*)realloc(s_pSpewGroups, - s_GroupCount * sizeof(SpewGroup_t)); - - // shift elements down to preserve order - int numToMove = s_GroupCount - ind - 1; - memmove(&s_pSpewGroups[ind + 1], &s_pSpewGroups[ind], - numToMove * sizeof(SpewGroup_t)); - } - else - s_pSpewGroups = (SpewGroup_t*)malloc(s_GroupCount * sizeof(SpewGroup_t)); - - Assert(strlen(pGroupName) < MAX_GROUP_NAME_LENGTH); - strcpy(s_pSpewGroups[ind].m_GroupName, pGroupName); - } - s_pSpewGroups[ind].m_Level = level; -} - - -//----------------------------------------------------------------------------- -// Tests to see if a particular spew is active -//----------------------------------------------------------------------------- - -bool IsSpewActive(char const* pGroupName, int level) -{ - // If we don't find the spew group, use the default level. - int ind; - if (FindSpewGroup(pGroupName, &ind)) - return s_pSpewGroups[ind].m_Level >= level; - else - return s_DefaultLevel >= level; -} - - -// If we don't have a function from math.h, then it doesn't link certain floating-point -// functions in and printfs with %f cause runtime errors in the C libraries. -float CrackSmokingCompiler(float a) -{ - return fabs(a); -} - -void* Plat_SimpleLog(const char* file, int line) -{ - FILE* f = fopen("simple.log", "at+"); - fprintf(f, "%s:%i\n", file, line); - fclose(f); - - return NULL; -} \ No newline at end of file diff --git a/regamedll/extra/cssdk/public/tier0/dbg.h b/regamedll/extra/cssdk/public/tier0/dbg.h deleted file mode 100644 index d4b07aa9..00000000 --- a/regamedll/extra/cssdk/public/tier0/dbg.h +++ /dev/null @@ -1,453 +0,0 @@ -//=========== (C) Copyright 1999 Valve, L.L.C. All rights reserved. =========== -// -// The copyright to the contents herein is the property of Valve, L.L.C. -// The contents may be used and/or copied only with the written permission of -// Valve, L.L.C., or in accordance with the terms and conditions stipulated in -// the agreement/contract under which the contents have been supplied. -// -// $Header: $ -// $NoKeywords: $ -// -// The main debug library interfaces -//============================================================================= - - -#ifndef DBG_H -#define DBG_H - -#ifdef _WIN32 -#pragma once -#endif - -#include "osconfig.h" -#include "basetypes.h" -#include "tier0/platform.h" -#include -#include -#include - - -//----------------------------------------------------------------------------- -// dll export stuff -//----------------------------------------------------------------------------- - -#ifdef TIER0_DLL_EXPORT -#define DBG_INTERFACE DLL_EXPORT -#define DBG_OVERLOAD DLL_GLOBAL_EXPORT -#define DBG_CLASS DLL_CLASS_EXPORT -#else -#define DBG_INTERFACE DLL_IMPORT -#define DBG_OVERLOAD DLL_GLOBAL_IMPORT -#define DBG_CLASS DLL_CLASS_IMPORT -#endif - - -//----------------------------------------------------------------------------- -// Usage model for the Dbg library -// -// 1. Spew. -// -// Spew can be used in a static and a dynamic mode. The static -// mode allows us to display assertions and other messages either only -// in debug builds, or in non-release builds. The dynamic mode allows us to -// turn on and off certain spew messages while the application is running. -// -// Static Spew messages: -// -// Assertions are used to detect and warn about invalid states -// Spews are used to display a particular status/warning message. -// -// To use an assertion, use -// -// Assert( (f == 5) ); -// AssertMsg( (f == 5), ("F needs to be %d here!\n", 5) ); -// AssertFunc( (f == 5), BadFunc() ); -// AssertEquals( f, 5 ); -// AssertFloatEquals( f, 5.0f, 1e-3 ); -// -// The first will simply report that an assertion failed on a particular -// code file and line. The second version will display a print-f formatted message -// along with the file and line, the third will display a generic message and -// will also cause the function BadFunc to be executed, and the last two -// will report an error if f is not equal to 5 (the last one asserts within -// a particular tolerance). -// -// To use a warning, use -// -// Warning("Oh I feel so %s all over\n", "yummy"); -// -// Warning will do its magic in only Debug builds. To perform spew in *all* -// builds, use RelWarning. -// -// Three other spew types, Msg, Log, and Error, are compiled into all builds. -// These error types do *not* need two sets of parenthesis. -// -// Msg( "Isn't this exciting %d?", 5 ); -// Error( "I'm just thrilled" ); -// -// Dynamic Spew messages -// -// It is possible to dynamically turn spew on and off. Dynamic spew is -// identified by a spew group and priority level. To turn spew on for a -// particular spew group, use SpewActivate( "group", level ). This will -// cause all spew in that particular group with priority levels <= the -// level specified in the SpewActivate function to be printed. Use DSpew -// to perform the spew: -// -// DWarning( "group", level, "Oh I feel even yummier!\n" ); -// -// Priority level 0 means that the spew will *always* be printed, and group -// '*' is the default spew group. If a DWarning is encountered using a group -// whose priority has not been set, it will use the priority of the default -// group. The priority of the default group is initially set to 0. -// -// Spew output -// -// The output of the spew system can be redirected to an externally-supplied -// function which is responsible for outputting the spew. By default, the -// spew is simply printed using printf. -// -// To redirect spew output, call SpewOutput. -// -// SpewOutputFunc( OutputFunc ); -// -// This will cause OutputFunc to be called every time a spew message is -// generated. OutputFunc will be passed a spew type and a message to print. -// It must return a value indicating whether the debugger should be invoked, -// whether the program should continue running, or whether the program -// should abort. -// -// 2. Code activation -// -// To cause code to be run only in debug builds, use DBG_CODE: -// An example is below. -// -// DBG_CODE( -// { -// int x = 5; -// ++x; -// } -// ); -// -// Code can be activated based on the dynamic spew groups also. Use -// -// DBG_DCODE( "group", level, -// { int x = 5; ++x; } -// ); -// -// 3. Breaking into the debugger. -// -// To cause an unconditional break into the debugger in debug builds only, use DBG_BREAK -// -// DBG_BREAK(); -// -// You can force a break in any build (release or debug) using -// -// DebuggerBreak(); -//----------------------------------------------------------------------------- - -/* Various types of spew messages */ -// I'm sure you're asking yourself why SPEW_ instead of DBG_ ? -// It's because DBG_ is used all over the place in windows.h -// For example, DBG_CONTINUE is defined. Feh. -enum SpewType_t -{ - SPEW_MESSAGE = 0, - SPEW_WARNING, - SPEW_ASSERT, - SPEW_ERROR, - SPEW_LOG, - - SPEW_TYPE_COUNT -}; - -enum SpewRetval_t -{ - SPEW_DEBUGGER = 0, - SPEW_CONTINUE, - SPEW_ABORT -}; - -/* type of externally defined function used to display debug spew */ -typedef SpewRetval_t(*SpewOutputFunc_t)(SpewType_t spewType, char const *pMsg); - -/* Used to redirect spew output */ -void SpewOutputFunc(SpewOutputFunc_t func); - -/* Used ot get the current spew output function */ -SpewOutputFunc_t GetSpewOutputFunc(void); - -/* Used to manage spew groups and subgroups */ -void SpewActivate(char const* pGroupName, int level); -bool IsSpewActive(char const* pGroupName, int level); - -/* Used to display messages, should never be called directly. */ -void _SpewInfo(SpewType_t type, char const* pFile, int line); -SpewRetval_t _SpewMessage(char const* pMsg, ...); -SpewRetval_t _DSpewMessage(char const *pGroupName, int level, char const* pMsg, ...); - -/* Used to define macros, never use these directly. */ -#define _Assert( _exp ) do { \ - if (!(_exp)) \ - { \ - _SpewInfo( SPEW_ASSERT, __FILE__, __LINE__ ); \ - if (_SpewMessage("Assertion Failed: " #_exp) == SPEW_DEBUGGER) \ - { \ - DebuggerBreak(); \ - } \ - } \ - } while (0) - -#define _AssertMsg( _exp, _msg ) do { \ - if (!(_exp)) \ - { \ - _SpewInfo( SPEW_ASSERT, __FILE__, __LINE__ ); \ - if (_SpewMessage(_msg) == SPEW_DEBUGGER) \ - { \ - DebuggerBreak(); \ - } \ - } \ - } while (0) - -#define _AssertFunc( _exp, _f ) do { \ - if (!(_exp)) \ - { \ - _SpewInfo( SPEW_ASSERT, __FILE__, __LINE__ ); \ - SpewRetval_t ret = _SpewMessage("Assertion Failed!" #_exp); \ - _f; \ - if (ret == SPEW_DEBUGGER) \ - { \ - DebuggerBreak(); \ - } \ - } \ - } while (0) - -#define _AssertEquals( _exp, _expectedValue ) \ - do { \ - if ((_exp) != (_expectedValue)) \ - { \ - _SpewInfo( SPEW_ASSERT, __FILE__, __LINE__ ); \ - SpewRetval_t ret = _SpewMessage("Expected %d but got %d!", (_expectedValue), (_exp)); \ - if (ret == SPEW_DEBUGGER) \ - { \ - DebuggerBreak(); \ - } \ - } \ - } while (0) - -#define _AssertFloatEquals( _exp, _expectedValue, _tol ) \ - do { \ - if (fabs((_exp) - (_expectedValue)) > (_tol)) \ - { \ - _SpewInfo( SPEW_ASSERT, __FILE__, __LINE__ ); \ - SpewRetval_t ret = _SpewMessage("Expected %f but got %f!", (_expectedValue), (_exp)); \ - if (ret == SPEW_DEBUGGER) \ - { \ - DebuggerBreak(); \ - } \ - } \ - } while (0) - -/* Spew macros... */ - -#ifdef _DEBUG - -#define Assert( _exp ) _Assert( _exp ) -#define AssertMsg( _exp, _msg ) _AssertMsg( _exp, _msg ) -#define AssertFunc( _exp, _f ) _AssertFunc( _exp, _f ) -#define AssertEquals( _exp, _expectedValue ) _AssertEquals( _exp, _expectedValue ) -#define AssertFloatEquals( _exp, _expectedValue, _tol ) _AssertFloatEquals( _exp, _expectedValue, _tol ) -#define Verify( _exp ) _Assert( _exp ) - -#define AssertMsg1( _exp, _msg, a1 ) _AssertMsg( _exp, CDbgFmtMsg( _msg, a1 ) ) -#define AssertMsg2( _exp, _msg, a1, a2 ) _AssertMsg( _exp, CDbgFmtMsg( _msg, a1, a2 ) ) -#define AssertMsg3( _exp, _msg, a1, a2, a3 ) _AssertMsg( _exp, CDbgFmtMsg( _msg, a1, a2, a3 ) ) -#define AssertMsg4( _exp, _msg, a1, a2, a3, a4 ) _AssertMsg( _exp, CDbgFmtMsg( _msg, a1, a2, a3, a4 ) ) -#define AssertMsg5( _exp, _msg, a1, a2, a3, a4, a5 ) _AssertMsg( _exp, CDbgFmtMsg( _msg, a1, a2, a3, a4, a5 ) ) -#define AssertMsg6( _exp, _msg, a1, a2, a3, a4, a5, a6 ) _AssertMsg( _exp, CDbgFmtMsg( _msg, a1, a2, a3, a4, a5, a6 ) ) -#define AssertMsg6( _exp, _msg, a1, a2, a3, a4, a5, a6 ) _AssertMsg( _exp, CDbgFmtMsg( _msg, a1, a2, a3, a4, a5, a6 ) ) -#define AssertMsg7( _exp, _msg, a1, a2, a3, a4, a5, a6, a7 ) _AssertMsg( _exp, CDbgFmtMsg( _msg, a1, a2, a3, a4, a5, a6, a7 ) ) -#define AssertMsg8( _exp, _msg, a1, a2, a3, a4, a5, a6, a7, a8 ) _AssertMsg( _exp, CDbgFmtMsg( _msg, a1, a2, a3, a4, a5, a6, a7, a8 ) ) -#define AssertMsg9( _exp, _msg, a1, a2, a3, a4, a5, a6, a7, a8, a9 ) _AssertMsg( _exp, CDbgFmtMsg( _msg, a1, a2, a3, a4, a5, a6, a7, a8, a9 ) ) - - -#else /* Not _DEBUG */ - -#define Assert( _exp ) ((void)0) -#define AssertMsg( _exp, _msg ) ((void)0) -#define AssertFunc( _exp, _f ) ((void)0) -#define AssertEquals( _exp, _expectedValue ) ((void)0) -#define AssertFloatEquals( _exp, _expectedValue, _tol ) ((void)0) -#define Verify( _exp ) (_exp) - -#define AssertMsg1( _exp, _msg, a1 ) ((void)0) -#define AssertMsg2( _exp, _msg, a1, a2 ) ((void)0) -#define AssertMsg3( _exp, _msg, a1, a2, a3 ) ((void)0) -#define AssertMsg4( _exp, _msg, a1, a2, a3, a4 ) ((void)0) -#define AssertMsg5( _exp, _msg, a1, a2, a3, a4, a5 ) ((void)0) -#define AssertMsg6( _exp, _msg, a1, a2, a3, a4, a5, a6 ) ((void)0) -#define AssertMsg6( _exp, _msg, a1, a2, a3, a4, a5, a6 ) ((void)0) -#define AssertMsg7( _exp, _msg, a1, a2, a3, a4, a5, a6, a7 ) ((void)0) -#define AssertMsg8( _exp, _msg, a1, a2, a3, a4, a5, a6, a7, a8 ) ((void)0) -#define AssertMsg9( _exp, _msg, a1, a2, a3, a4, a5, a6, a7, a8, a9 ) ((void)0) - -#endif /* _DEBUG */ - - - -/* These are always compiled in */ -void Msg(char const* pMsg, ...); -void DMsg(char const *pGroupName, int level, char const *pMsg, ...); - -void Warning(char const *pMsg, ...); -void DWarning(char const *pGroupName, int level, char const *pMsg, ...); - -void Log(char const *pMsg, ...); -void DLog(char const *pGroupName, int level, char const *pMsg, ...); - -void Error(char const *pMsg, ...); - -// You can use this macro like a runtime assert macro. -// If the condition fails, then Error is called with the message. This macro is called -// like AssertMsg, where msg must be enclosed in parenthesis: -// -// ErrorIfNot( bCondition, ("a b c %d %d %d", 1, 2, 3) ); -#define ErrorIfNot( condition, msg ) \ - if ( (condition) ) \ - ; \ - else \ - { \ - Error msg; \ - } - -/* A couple of super-common dynamic spew messages, here for convenience */ -/* These looked at the "developer" group */ -void DevMsg(int level, char const* pMsg, ...); -void DevWarning(int level, char const *pMsg, ...); -void DevLog(int level, char const *pMsg, ...); - -/* default level versions (level 1) */ -void DevMsg(char const* pMsg, ...); -void DevWarning(char const *pMsg, ...); -void DevLog(char const *pMsg, ...); - -/* Code macros, debugger interface */ - -#ifdef _DEBUG - -#define DBG_CODE( _code ) if (0) ; else { _code } -#define DBG_DCODE( _g, _l, _code ) if (IsSpewActive( _g, _l )) { _code } else {} -#define DBG_BREAK() DebuggerBreak() /* defined in platform.h */ - -#else /* not _DEBUG */ - -#define DBG_CODE( _code ) ((void)0) -#define DBG_DCODE( _g, _l, _code ) ((void)0) -#define DBG_BREAK() ((void)0) - -#endif /* _DEBUG */ - -//----------------------------------------------------------------------------- -// Macro to assist in asserting constant invariants during compilation - -#define UID_PREFIX generated_id_ -#define UID_CAT1(a,c) a ## c -#define UID_CAT2(a,c) UID_CAT1(a,c) -#define UNIQUE_ID UID_CAT2(UID_PREFIX,__LINE__) - - -#ifdef _DEBUG -#define COMPILE_TIME_ASSERT( pred ) switch(0){case 0:case pred:;} -#define ASSERT_INVARIANT( pred ) static void UNIQUE_ID() { COMPILE_TIME_ASSERT( pred ) } -#else -#define COMPILE_TIME_ASSERT( pred ) -#define ASSERT_INVARIANT( pred ) -#endif - - -//----------------------------------------------------------------------------- -// Templates to assist in validating pointers: - -// Have to use these stubs so we don't have to include windows.h here. -void _AssertValidReadPtr(void* ptr, int count = 1); -void _AssertValidWritePtr(void* ptr, int count = 1); -void _AssertValidReadWritePtr(void* ptr, int count = 1); - - void AssertValidStringPtr(const char* ptr, int maxchar = 0xFFFFFF); -template inline void AssertValidReadPtr(T* ptr, int count = 1) { _AssertValidReadPtr((void*)ptr, count); } -template inline void AssertValidWritePtr(T* ptr, int count = 1) { _AssertValidWritePtr((void*)ptr, count); } -template inline void AssertValidReadWritePtr(T* ptr, int count = 1) { _AssertValidReadWritePtr((void*)ptr, count); } - -#define AssertValidThis() AssertValidReadWritePtr(this,sizeof(*this)) - -//----------------------------------------------------------------------------- -// Macro to protect functions that are not reentrant - -#ifdef _DEBUG -class CReentryGuard -{ -public: - CReentryGuard(int *pSemaphore) - : m_pSemaphore(pSemaphore) - { - ++(*m_pSemaphore); - } - - ~CReentryGuard() - { - --(*m_pSemaphore); - } - -private: - int *m_pSemaphore; -}; - -#define ASSERT_NO_REENTRY() \ - static int fSemaphore##__LINE__; \ - Assert( !fSemaphore##__LINE__ ); \ - CReentryGuard ReentryGuard##__LINE__( &fSemaphore##__LINE__ ) -#else -#define ASSERT_NO_REENTRY() -#endif - -//----------------------------------------------------------------------------- -// -// Purpose: Inline string formatter -// - -class CDbgFmtMsg -{ -public: - CDbgFmtMsg(const char *pszFormat, ...) - { - va_list arg_ptr; - - va_start(arg_ptr, pszFormat); - _vsnprintf(m_szBuf, sizeof(m_szBuf) - 1, pszFormat, arg_ptr); - va_end(arg_ptr); - - m_szBuf[sizeof(m_szBuf) - 1] = 0; - } - - operator const char *() const - { - return m_szBuf; - } - -private: - char m_szBuf[256]; -}; - -//----------------------------------------------------------------------------- -// -// Purpose: Embed debug info in each file. -// - -//#ifdef _WIN32 -//#ifdef _DEBUG -//#pragma comment(compiler) -//#pragma comment(exestr,"*** DEBUG file detected, Last Compile: " __DATE__ ", " __TIME__ " ***") -//#endif -//#endif - -#endif /* DBG_H */ \ No newline at end of file diff --git a/regamedll/extra/cssdk/public/tier0/platform.h b/regamedll/extra/cssdk/public/tier0/platform.h deleted file mode 100644 index f9e4e6c2..00000000 --- a/regamedll/extra/cssdk/public/tier0/platform.h +++ /dev/null @@ -1,630 +0,0 @@ -//=========== (C) Copyright 1999 Valve, L.L.C. All rights reserved. =========== -// -// The copyright to the contents herein is the property of Valve, L.L.C. -// The contents may be used and/or copied only with the written permission of -// Valve, L.L.C., or in accordance with the terms and conditions stipulated in -// the agreement/contract under which the contents have been supplied. -// -// $Header: $ -// $NoKeywords: $ -// -// Extremely low-level platform-specific stuff -//============================================================================= - - -#ifndef PLATFORM_H -#define PLATFORM_H - -#ifdef _WIN32 -#pragma once -#endif - -#include "osconfig.h" - -// need this for _alloca -#include - -// need this for memset -#include - -#include "archtypes.h" - -typedef float float32; -typedef double float64; - -// for when we don't care about how many bits we use -typedef unsigned int uint; - -// This can be used to ensure the size of pointers to members when declaring -// a pointer type for a class that has only been forward declared -#ifdef _MSC_VER -#define SINGLE_INHERITANCE __single_inheritance -#define MULTIPLE_INHERITANCE __multiple_inheritance -#else -#define SINGLE_INHERITANCE -#define MULTIPLE_INHERITANCE -#endif - -/* -FIXME: Enable this when we no longer fear change =) - -// need these for the limits -#include -#include - -// Maximum and minimum representable values -#define INT8_MAX SCHAR_MAX -#define INT16_MAX SHRT_MAX -#define INT32_MAX LONG_MAX -#define INT64_MAX (((int64)~0) >> 1) - -#define INT8_MIN SCHAR_MIN -#define INT16_MIN SHRT_MIN -#define INT32_MIN LONG_MIN -#define INT64_MIN (((int64)1) << 63) - -#define UINT8_MAX ((uint8)~0) -#define UINT16_MAX ((uint16)~0) -#define UINT32_MAX ((uint32)~0) -#define UINT64_MAX ((uint64)~0) - -#define UINT8_MIN 0 -#define UINT16_MIN 0 -#define UINT32_MIN 0 -#define UINT64_MIN 0 - -#ifndef UINT_MIN -#define UINT_MIN UINT32_MIN -#endif - -#define FLOAT32_MAX FLT_MAX -#define FLOAT64_MAX DBL_MAX - -#define FLOAT32_MIN FLT_MIN -#define FLOAT64_MIN DBL_MIN -*/ - -// portability / compiler settings -#if defined(_WIN32) && !defined(WINDED) - -#if defined(_M_IX86) -#define __i386__ 1 -#endif - -#elif __linux__ -typedef void * HINSTANCE; -#define _MAX_PATH PATH_MAX -#endif // defined(_WIN32) && !defined(WINDED) - - -// Defines MAX_PATH -#ifndef MAX_PATH -#define MAX_PATH 260 -#endif - -// Used to step into the debugger -#define DebuggerBreak() __asm { int 3 } - -// C functions for external declarations that call the appropriate C++ methods -#ifndef EXPORT -#ifdef _WIN32 -#define EXPORT _declspec( dllexport ) -#else -#define EXPORT /* */ -#endif -#endif - -#if defined __i386__ && !defined __linux__ -#define id386 1 -#else -#define id386 0 -#endif // __i386__ - -#ifdef _WIN32 -// Used for dll exporting and importing -#define DLL_EXPORT extern "C" __declspec( dllexport ) -#define DLL_IMPORT extern "C" __declspec( dllimport ) - -// Can't use extern "C" when DLL exporting a class -#define DLL_CLASS_EXPORT __declspec( dllexport ) -#define DLL_CLASS_IMPORT __declspec( dllimport ) - -// Can't use extern "C" when DLL exporting a global -#define DLL_GLOBAL_EXPORT extern __declspec( dllexport ) -#define DLL_GLOBAL_IMPORT extern __declspec( dllimport ) -#elif defined __linux__ - -// Used for dll exporting and importing -#define DLL_EXPORT extern "C" -#define DLL_IMPORT extern "C" - -// Can't use extern "C" when DLL exporting a class -#define DLL_CLASS_EXPORT -#define DLL_CLASS_IMPORT - -// Can't use extern "C" when DLL exporting a global -#define DLL_GLOBAL_EXPORT extern -#define DLL_GLOBAL_IMPORT extern - -#else -#error "Unsupported Platform." -#endif - -// Used for standard calling conventions -#ifdef _WIN32 -#define FASTCALL __fastcall -#define FORCEINLINE __forceinline -#else -#define FASTCALL -#define FORCEINLINE inline -#endif - -// Force a function call site -not- to inlined. (useful for profiling) -#define DONT_INLINE(a) (((int)(a)+1)?(a):(a)) - -// Pass hints to the compiler to prevent it from generating unnessecary / stupid code -// in certain situations. Several compilers other than MSVC also have an equivilent -// construct. -// -// Essentially the 'Hint' is that the condition specified is assumed to be true at -// that point in the compilation. If '0' is passed, then the compiler assumes that -// any subsequent code in the same 'basic block' is unreachable, and thus usually -// removed. -#ifdef _MSC_VER -#define HINT(THE_HINT) __assume((THE_HINT)) -#else -#define HINT(THE_HINT) 0 -#endif - -// Marks the codepath from here until the next branch entry point as unreachable, -// and asserts if any attempt is made to execute it. -#define UNREACHABLE() { Assert(0); HINT(0); } - -// In cases where no default is present or appropriate, this causes MSVC to generate -// as little code as possible, and throw an assertion in debug. -#define NO_DEFAULT default: UNREACHABLE(); - -#ifdef _WIN32 -// Alloca defined for this platform -#define stackalloc( _size ) _alloca( _size ) -#define stackfree( _p ) 0 -#elif __linux__ -// Alloca defined for this platform -#define stackalloc( _size ) alloca( _size ) -#define stackfree( _p ) 0 -#endif - -#ifdef _WIN32 -// Remove warnings from warning level 4. -#pragma warning(disable : 4514) // warning C4514: 'acosl' : unreferenced inline function has been removed -#pragma warning(disable : 4100) // warning C4100: 'hwnd' : unreferenced formal parameter -#pragma warning(disable : 4127) // warning C4127: conditional expression is constant -#pragma warning(disable : 4512) // warning C4512: 'InFileRIFF' : assignment operator could not be generated -#pragma warning(disable : 4611) // warning C4611: interaction between '_setjmp' and C++ object destruction is non-portable -#pragma warning(disable : 4706) // warning C4706: assignment within conditional expression -#pragma warning(disable : 4710) // warning C4710: function 'x' not inlined -#pragma warning(disable : 4702) // warning C4702: unreachable code -#pragma warning(disable : 4505) // unreferenced local function has been removed -#pragma warning(disable : 4239) // nonstandard extension used : 'argument' ( conversion from class Vector to class Vector& ) -#pragma warning(disable : 4097) // typedef-name 'BaseClass' used as synonym for class-name 'CFlexCycler::CBaseFlex' -#pragma warning(disable : 4324) // Padding was added at the end of a structure -#pragma warning(disable : 4244) // type conversion warning. -#pragma warning(disable : 4305) // truncation from 'const double ' to 'float ' -#pragma warning(disable : 4786) // Disable warnings about long symbol names - -#if _MSC_VER >= 1300 -#pragma warning(disable : 4511) // Disable warnings about private copy constructors -#endif -#endif -//----------------------------------------------------------------------------- -// Purpose: Standard functions for handling endian-ness -//----------------------------------------------------------------------------- - -//------------------------------------- -// Basic swaps -//------------------------------------- - -template -inline T WordSwapC(T w) -{ - uint16 temp; - - temp = ((*((uint16 *)&w) & 0xff00) >> 8); - temp |= ((*((uint16 *)&w) & 0x00ff) << 8); - - return *((T*)&temp); -} - -template -inline T DWordSwapC(T dw) -{ - uint32 temp; - - temp = *((uint32 *)&dw) >> 24; - temp |= ((*((uint32 *)&dw) & 0x00FF0000) >> 8); - temp |= ((*((uint32 *)&dw) & 0x0000FF00) << 8); - temp |= ((*((uint32 *)&dw) & 0x000000FF) << 24); - - return *((T*)&temp); -} - -//------------------------------------- -// Fast swaps -//------------------------------------- - -#ifdef _MSC_VER - -#define WordSwap WordSwapAsm -#define DWordSwap DWordSwapAsm - -#pragma warning(push) -#pragma warning (disable:4035) // no return value - -template -inline T WordSwapAsm(T w) -{ - __asm - { - mov ax, w - xchg al, ah - } -} - -template -inline T DWordSwapAsm(T dw) -{ - __asm - { - mov eax, dw - bswap eax - } -} - -#pragma warning(pop) - -// The assembly implementation is not compatible with floats -template <> -inline float DWordSwapAsm(float f) -{ - return DWordSwapC(f); -} - -#else - -#define WordSwap WordSwapC -#define DWordSwap DWordSwapC - -#endif - -//------------------------------------- -// The typically used methods. -//------------------------------------- - -#if defined(__i386__) -#define VALVE_LITTLE_ENDIAN 1 -#endif - -#ifdef _SGI_SOURCE -#define VALVE_BIG_ENDIAN 1 -#endif - -#if defined(VALVE_LITTLE_ENDIAN) - -#define Valve_BigShort( val ) WordSwap( val ) -#define Valve_BigWord( val ) WordSwap( val ) -#define Valve_BigLong( val ) DWordSwap( val ) -#define Valve_BigDWord( val ) DWordSwap( val ) -#define Valve_BigFloat( val ) DWordSwap( val ) -#define Valve_LittleShort( val ) ( val ) -#define Valve_LittleWord( val ) ( val ) -#define Valve_LittleLong( val ) ( val ) -#define Valve_LittleDWord( val ) ( val ) -#define Valve_LittleFloat( val ) ( val ) - -#elif defined(BIG_ENDIAN) - -#define Valve_BigShort( val ) ( val ) -#define Valve_BigWord( val ) ( val ) -#define Valve_BigLong( val ) ( val ) -#define Valve_BigDWord( val ) ( val ) -#define Valve_BigFloat( val ) ( val ) -#define Valve_LittleShort( val ) WordSwap( val ) -#define Valve_LittleWord( val ) WordSwap( val ) -#define Valve_LittleLong( val ) DWordSwap( val ) -#define Valve_LittleDWord( val ) DWordSwap( val ) -#define Valve_LittleFloat( val ) DWordSwap( val ) - -#else - -// @Note (toml 05-02-02): this technique expects the compiler to -// optimize the expression and eliminate the other path. On any new -// platform/compiler this should be tested. -inline short BigShort(short val) { int test = 1; return (*(char *)&test == 1) ? WordSwap(val) : val; } -inline uint16 BigWord(uint16 val) { int test = 1; return (*(char *)&test == 1) ? WordSwap(val) : val; } -inline long BigLong(long val) { int test = 1; return (*(char *)&test == 1) ? DWordSwap(val) : val; } -inline uint32 BigDWord(uint32 val) { int test = 1; return (*(char *)&test == 1) ? DWordSwap(val) : val; } -inline float BigFloat(float val) { int test = 1; return (*(char *)&test == 1) ? DWordSwap(val) : val; } -inline short LittleShort(short val) { int test = 1; return (*(char *)&test == 1) ? val : WordSwap(val); } -inline uint16 LittleWord(uint16 val) { int test = 1; return (*(char *)&test == 1) ? val : WordSwap(val); } -inline long LittleLong(long val) { int test = 1; return (*(char *)&test == 1) ? val : DWordSwap(val); } -inline uint32 LittleDWord(uint32 val) { int test = 1; return (*(char *)&test == 1) ? val : DWordSwap(val); } -inline float LittleFloat(float val) { int test = 1; return (*(char *)&test == 1) ? val : DWordSwap(val); } - -#endif - - - -#ifdef TIER0_DLL_EXPORT -#define PLATFORM_INTERFACE DLL_EXPORT -#define PLATFORM_OVERLOAD DLL_GLOBAL_EXPORT -#else -#define PLATFORM_INTERFACE DLL_IMPORT -#define PLATFORM_OVERLOAD DLL_GLOBAL_IMPORT -#endif - -/* -PLATFORM_INTERFACE double Plat_FloatTime(); // Returns time in seconds since the module was loaded. -PLATFORM_INTERFACE unsigned long Plat_MSTime(); // Time in milliseconds. - -// b/w compatibility -#define Sys_FloatTime Plat_FloatTime -*/ - -// Processor Information: -struct CPUInformation -{ - int m_Size; // Size of this structure, for forward compatability. - - bool m_bRDTSC : 1, // Is RDTSC supported? - m_bCMOV : 1, // Is CMOV supported? - m_bFCMOV : 1, // Is FCMOV supported? - m_bSSE : 1, // Is SSE supported? - m_bSSE2 : 1, // Is SSE2 Supported? - m_b3DNow : 1, // Is 3DNow! Supported? - m_bMMX : 1, // Is MMX supported? - m_bHT : 1; // Is HyperThreading supported? - - unsigned char m_nLogicalProcessors, // Number op logical processors. - m_nPhysicalProcessors; // Number of physical processors - - int64 m_Speed; // In cycles per second. - - char* m_szProcessorID; // Processor vendor Identification. -}; - -PLATFORM_INTERFACE const CPUInformation& GetCPUInformation(); - - -//----------------------------------------------------------------------------- -// Thread related functions -//----------------------------------------------------------------------------- -// Registers the current thread with Tier0's thread management system. -// This should be called on every thread created in the game. -PLATFORM_INTERFACE unsigned long Plat_RegisterThread(const char *pName = "Source Thread"); - -// Registers the current thread as the primary thread. -PLATFORM_INTERFACE unsigned long Plat_RegisterPrimaryThread(); - -// VC-specific. Sets the thread's name so it has a friendly name in the debugger. -// This should generally only be handled by Plat_RegisterThread and Plat_RegisterPrimaryThread -PLATFORM_INTERFACE void Plat_SetThreadName(unsigned long dwThreadID, const char *pName); - -// These would be private if it were possible to export private variables from a .DLL. -// They need to be variables because they are checked by inline functions at performance -// critical places. -PLATFORM_INTERFACE unsigned long Plat_PrimaryThreadID; - -// Returns the ID of the currently executing thread. -PLATFORM_INTERFACE unsigned long Plat_GetCurrentThreadID(); - -// Returns the ID of the primary thread. -inline unsigned long Plat_GetPrimaryThreadID() -{ - return Plat_PrimaryThreadID; -} - -// Returns true if the current thread is the primary thread. -inline bool Plat_IsPrimaryThread() -{ - //return true; - return (Plat_GetPrimaryThreadID() == Plat_GetCurrentThreadID()); -} - -//----------------------------------------------------------------------------- -// Security related functions -//----------------------------------------------------------------------------- -// Ensure that the hardware key's drivers have been installed. -PLATFORM_INTERFACE bool Plat_VerifyHardwareKeyDriver(); - -// Ok, so this isn't a very secure way to verify the hardware key for now. It -// is primarially depending on the fact that all the binaries have been wrapped -// with the secure wrapper provided by the hardware keys vendor. -PLATFORM_INTERFACE bool Plat_VerifyHardwareKey(); - -// The same as above, but notifies user with a message box when the key isn't in -// and gives him an opportunity to correct the situation. -PLATFORM_INTERFACE bool Plat_VerifyHardwareKeyPrompt(); - -// Can be called in real time, doesn't perform the verify every frame. Mainly just -// here to allow the game to drop out quickly when the key is removed, rather than -// allowing the wrapper to pop up it's own blocking dialog, which the engine doesn't -// like much. -PLATFORM_INTERFACE bool Plat_FastVerifyHardwareKey(); - - - -//----------------------------------------------------------------------------- -// Include additional dependant header components. -//----------------------------------------------------------------------------- -//#include "tier0/fasttimer.h" - - -//----------------------------------------------------------------------------- -// Just logs file and line to simple.log -//----------------------------------------------------------------------------- -void* Plat_SimpleLog(const char* file, int line); - -//#define Plat_dynamic_cast Plat_SimpleLog(__FILE__,__LINE__),dynamic_cast - -//----------------------------------------------------------------------------- -// Methods to invoke the constructor, copy constructor, and destructor -//----------------------------------------------------------------------------- - -template -inline void Construct(T* pMemory) -{ - new(pMemory)T; -} - -template -inline void CopyConstruct(T* pMemory, T const& src) -{ - new(pMemory)T(src); -} - -template -inline void Destruct(T* pMemory) -{ - pMemory->~T(); - -#ifdef _DEBUG - memset(pMemory, 0xDD, sizeof(T)); -#endif -} - - -// -// GET_OUTER() -// -// A platform-independent way for a contained class to get a pointer to its -// owner. If you know a class is exclusively used in the context of some -// "outer" class, this is a much more space efficient way to get at the outer -// class than having the inner class store a pointer to it. -// -// class COuter -// { -// class CInner // Note: this does not need to be a nested class to work -// { -// void PrintAddressOfOuter() -// { -// printf( "Outer is at 0x%x\n", GET_OUTER( COuter, m_Inner ) ); -// } -// }; -// -// CInner m_Inner; -// friend class CInner; -// }; - -#define GET_OUTER( OuterType, OuterMember ) \ - ( ( OuterType * ) ( (char *)this - offsetof( OuterType, OuterMember ) ) ) - - -/* TEMPLATE_FUNCTION_TABLE() - -(Note added to platform.h so platforms that correctly support templated -functions can handle portions as templated functions rather than wrapped -functions) - -Helps automate the process of creating an array of function -templates that are all specialized by a single integer. -This sort of thing is often useful in optimization work. - -For example, using TEMPLATE_FUNCTION_TABLE, this: - -TEMPLATE_FUNCTION_TABLE(int, Function, ( int blah, int blah ), 10) -{ -return argument * argument; -} - -is equivilent to the following: - -(NOTE: the function has to be wrapped in a class due to code -generation bugs involved with directly specializing a function -based on a constant.) - -template -class FunctionWrapper -{ -public: -int Function( int blah, int blah ) -{ -return argument*argument; -} -} - -typedef int (*FunctionType)( int blah, int blah ); - -class FunctionName -{ -public: -enum { count = 10 }; -FunctionType functions[10]; -}; - -FunctionType FunctionName::functions[] = -{ -FunctionWrapper<0>::Function, -FunctionWrapper<1>::Function, -FunctionWrapper<2>::Function, -FunctionWrapper<3>::Function, -FunctionWrapper<4>::Function, -FunctionWrapper<5>::Function, -FunctionWrapper<6>::Function, -FunctionWrapper<7>::Function, -FunctionWrapper<8>::Function, -FunctionWrapper<9>::Function -}; -*/ - -bool vtune(bool resume); - - -#define TEMPLATE_FUNCTION_TABLE(RETURN_TYPE, NAME, ARGS, COUNT) \ - \ -typedef RETURN_TYPE (FASTCALL *__Type_##NAME) ARGS; \ - \ -template \ -struct __Function_##NAME \ -{ \ - static RETURN_TYPE FASTCALL Run ARGS; \ -}; \ - \ -template \ -struct __MetaLooper_##NAME : __MetaLooper_##NAME \ -{ \ - __Type_##NAME func; \ - inline __MetaLooper_##NAME() { func = __Function_##NAME::Run; } \ -}; \ - \ -template<> \ -struct __MetaLooper_##NAME<0> \ -{ \ - __Type_##NAME func; \ - inline __MetaLooper_##NAME() { func = __Function_##NAME<0>::Run; } \ -}; \ - \ -class NAME \ -{ \ -private: \ - static const __MetaLooper_##NAME m; \ -public: \ - enum { count = COUNT }; \ - static const __Type_##NAME* functions; \ -}; \ -const __MetaLooper_##NAME NAME::m; \ -const __Type_##NAME* NAME::functions = (__Type_##NAME*)&m; \ -template \ -RETURN_TYPE FASTCALL __Function_##NAME::Run ARGS - - -#define LOOP_INTERCHANGE(BOOLEAN, CODE)\ - if( (BOOLEAN) )\ - {\ - CODE;\ - } else\ - {\ - CODE;\ - } - - -#endif /* PLATFORM_H */ \ No newline at end of file diff --git a/regamedll/extra/cssdk/public/utlmemory.h b/regamedll/extra/cssdk/public/utlmemory.h deleted file mode 100644 index 4f75f81f..00000000 --- a/regamedll/extra/cssdk/public/utlmemory.h +++ /dev/null @@ -1,357 +0,0 @@ -/* -* -* This program is free software; you can redistribute it and/or modify it -* under the terms of the GNU General Public License as published by the -* Free Software Foundation; either version 2 of the License, or (at -* your option) any later version. -* -* This program 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 -* General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* -*/ - -#ifndef UTLMEMORY_H -#define UTLMEMORY_H - -#ifdef _WIN32 -#pragma once -#endif - -#include "osconfig.h" -#include "tier0/dbg.h" -#include - -#pragma warning (disable:4100) -#pragma warning (disable:4514) - -/*template -inline void Construct(T *pMemory) -{ - ::new(pMemory) T; -} - -template -inline void CopyConstruct(T *pMemory,T const& src) -{ - ::new(pMemory) T(src); -} - -template -inline void Destruct(T *pMemory) -{ - pMemory->~T(); - -#ifdef _DEBUG - memset(pMemory,0xDD,sizeof(T)); -#endif -}*/ -//----------------------------------------------------------------------------- -// The CUtlMemory class: -// A growable memory class which doubles in size by default. -//----------------------------------------------------------------------------- -template< class T > -class CUtlMemory -{ -public: - // constructor, destructor - CUtlMemory(int nGrowSize = 0, int nInitSize = 0); - CUtlMemory(T* pMemory, int numElements); - ~CUtlMemory(); - - // element access - T& operator[](int i); - T const& operator[](int i) const; - T& Element(int i); - T const& Element(int i) const; - - // Can we use this index? - bool IsIdxValid(int i) const; - - // Gets the base address (can change when adding elements!) - T* Base(); - T const* Base() const; - - // Attaches the buffer to external memory.... - void SetExternalBuffer(T* pMemory, int numElements); - - // Size - int NumAllocated() const; - int Count() const; - - // Grows the memory, so that at least allocated + num elements are allocated - void Grow(int num = 1); - - // Makes sure we've got at least this much memory - void EnsureCapacity(int num); - - // Memory deallocation - void Purge(); - - // is the memory externally allocated? - bool IsExternallyAllocated() const; - - // Set the size by which the memory grows - void SetGrowSize(int size); - -private: - enum - { - EXTERNAL_BUFFER_MARKER = -1, - }; - - T* m_pMemory; - int m_nAllocationCount; - int m_nGrowSize; -}; - - -//----------------------------------------------------------------------------- -// constructor, destructor -//----------------------------------------------------------------------------- -template< class T > -CUtlMemory::CUtlMemory(int nGrowSize, int nInitAllocationCount) : m_pMemory(0), -m_nAllocationCount(nInitAllocationCount), m_nGrowSize(nGrowSize) -{ - Assert((nGrowSize >= 0) && (nGrowSize != EXTERNAL_BUFFER_MARKER)); - if (m_nAllocationCount) - { - m_pMemory = (T*)malloc(m_nAllocationCount * sizeof(T)); - } -} - -template< class T > -CUtlMemory::CUtlMemory(T* pMemory, int numElements) : m_pMemory(pMemory), -m_nAllocationCount(numElements) -{ - // Special marker indicating externally supplied memory - m_nGrowSize = EXTERNAL_BUFFER_MARKER; -} - -template< class T > -CUtlMemory::~CUtlMemory() -{ - Purge(); -} - - -//----------------------------------------------------------------------------- -// Attaches the buffer to external memory.... -//----------------------------------------------------------------------------- -template< class T > -void CUtlMemory::SetExternalBuffer(T* pMemory, int numElements) -{ - // Blow away any existing allocated memory - Purge(); - - m_pMemory = pMemory; - m_nAllocationCount = numElements; - - // Indicate that we don't own the memory - m_nGrowSize = EXTERNAL_BUFFER_MARKER; -} - - -//----------------------------------------------------------------------------- -// element access -//----------------------------------------------------------------------------- -template< class T > -inline T& CUtlMemory::operator[](int i) -{ - Assert(IsIdxValid(i)); - return m_pMemory[i]; -} - -template< class T > -inline T const& CUtlMemory::operator[](int i) const -{ - Assert(IsIdxValid(i)); - return m_pMemory[i]; -} - -template< class T > -inline T& CUtlMemory::Element(int i) -{ - Assert(IsIdxValid(i)); - return m_pMemory[i]; -} - -template< class T > -inline T const& CUtlMemory::Element(int i) const -{ - Assert(IsIdxValid(i)); - return m_pMemory[i]; -} - - -//----------------------------------------------------------------------------- -// is the memory externally allocated? -//----------------------------------------------------------------------------- -template< class T > -bool CUtlMemory::IsExternallyAllocated() const -{ - return m_nGrowSize == EXTERNAL_BUFFER_MARKER; -} - - -template< class T > -void CUtlMemory::SetGrowSize(int nSize) -{ - Assert((nSize >= 0) && (nSize != EXTERNAL_BUFFER_MARKER)); - m_nGrowSize = nSize; -} - - -//----------------------------------------------------------------------------- -// Gets the base address (can change when adding elements!) -//----------------------------------------------------------------------------- -template< class T > -inline T* CUtlMemory::Base() -{ - return m_pMemory; -} - -template< class T > -inline T const* CUtlMemory::Base() const -{ - return m_pMemory; -} - - -//----------------------------------------------------------------------------- -// Size -//----------------------------------------------------------------------------- -template< class T > -inline int CUtlMemory::NumAllocated() const -{ - return m_nAllocationCount; -} - -template< class T > -inline int CUtlMemory::Count() const -{ - return m_nAllocationCount; -} - - -//----------------------------------------------------------------------------- -// Is element index valid? -//----------------------------------------------------------------------------- -template< class T > -inline bool CUtlMemory::IsIdxValid(int i) const -{ - return (i >= 0) && (i < m_nAllocationCount); -} - - -//----------------------------------------------------------------------------- -// Grows the memory -//----------------------------------------------------------------------------- -template< class T > -void CUtlMemory::Grow(int num) -{ - Assert(num > 0); - - if (IsExternallyAllocated()) - { - // Can't grow a buffer whose memory was externally allocated - Assert(0); - return; - } - - // Make sure we have at least numallocated + num allocations. - // Use the grow rules specified for this memory (in m_nGrowSize) - int nAllocationRequested = m_nAllocationCount + num; - while (m_nAllocationCount < nAllocationRequested) - { - if (m_nAllocationCount != 0) - { - if (m_nGrowSize) - { - m_nAllocationCount += m_nGrowSize; - } - else - { - m_nAllocationCount += m_nAllocationCount; - } - } - else - { - // Compute an allocation which is at least as big as a cache line... - m_nAllocationCount = (31 + sizeof(T)) / sizeof(T); - Assert(m_nAllocationCount != 0); - } - } - - if (m_pMemory) - { - m_pMemory = (T*)realloc(m_pMemory, m_nAllocationCount * sizeof(T)); - } - else - { - m_pMemory = (T*)malloc(m_nAllocationCount * sizeof(T)); - } -} - - -//----------------------------------------------------------------------------- -// Makes sure we've got at least this much memory -//----------------------------------------------------------------------------- -template< class T > -inline void CUtlMemory::EnsureCapacity(int num) -{ - if (m_nAllocationCount >= num) - return; - - if (IsExternallyAllocated()) - { - // Can't grow a buffer whose memory was externally allocated - Assert(0); - return; - } - - m_nAllocationCount = num; - if (m_pMemory) - { - m_pMemory = (T*)realloc(m_pMemory, m_nAllocationCount * sizeof(T)); - } - else - { - m_pMemory = (T*)malloc(m_nAllocationCount * sizeof(T)); - } -} - - -//----------------------------------------------------------------------------- -// Memory deallocation -//----------------------------------------------------------------------------- -template< class T > -void CUtlMemory::Purge() -{ - if (!IsExternallyAllocated()) - { - if (m_pMemory) - { - free((void*)m_pMemory); - m_pMemory = 0; - } - m_nAllocationCount = 0; - } -} - -#endif // UTLMEMORY_H diff --git a/regamedll/extra/cssdk/public/utlvector.h b/regamedll/extra/cssdk/public/utlvector.h deleted file mode 100644 index 263e72f8..00000000 --- a/regamedll/extra/cssdk/public/utlvector.h +++ /dev/null @@ -1,565 +0,0 @@ -#ifndef UTLVECTOR_H -#define UTLVECTOR_H -#ifdef _WIN32 -#pragma once -#endif - -#include "utlmemory.h" - -template -class CUtlVector -{ -public: - typedef T ElemType_t; - - // constructor, destructor - CUtlVector(int growSize = 0, int initSize = 0); - CUtlVector(T* pMemory, int numElements); - ~CUtlVector(); - - // Copy the array. - CUtlVector& operator=(const CUtlVector &other); - - // element access - T& operator[](int i); - T const& operator[](int i) const; - T& Element(int i); - T const& Element(int i) const; - - // Gets the base address (can change when adding elements!) - T* Base(); - T const* Base() const; - - // Returns the number of elements in the vector - // SIZE IS DEPRECATED! - int Count() const; - int Size() const; // don't use me! - - // Is element index valid? - bool IsValidIndex(int i) const; - static int InvalidIndex(void); - - // Adds an element, uses default constructor - int AddToHead(); - int AddToTail(); - int InsertBefore(int elem); - int InsertAfter(int elem); - - // Adds an element, uses copy constructor - int AddToHead(T const& src); - int AddToTail(T const& src); - int InsertBefore(int elem, T const& src); - int InsertAfter(int elem, T const& src); - - // Adds multiple elements, uses default constructor - int AddMultipleToHead(int num); - int AddMultipleToTail(int num, const T *pToCopy=NULL); - int InsertMultipleBefore(int elem, int num, const T *pToCopy=NULL); // If pToCopy is set, then it's an array of length 'num' and - int InsertMultipleAfter(int elem, int num); - - // Calls RemoveAll() then AddMultipleToTail. - void SetSize(int size); - void SetCount(int count); - - // Calls SetSize and copies each element. - void CopyArray(T const *pArray, int size); - - // Add the specified array to the tail. - int AddVectorToTail(CUtlVector const &src); - - // Finds an element (element needs operator== defined) - int Find(T const& src) const; - - bool HasElement(T const& src); - - // Makes sure we have enough memory allocated to store a requested # of elements - void EnsureCapacity(int num); - - // Makes sure we have at least this many elements - void EnsureCount(int num); - - // Element removal - void FastRemove(int elem); // doesn't preserve order - void Remove(int elem); // preserves order, shifts elements - void FindAndRemove(T const& src); // removes first occurrence of src, preserves order, shifts elements - void RemoveMultiple(int elem, int num); // preserves order, shifts elements - void RemoveAll(); // doesn't deallocate memory - - // Memory deallocation - void Purge(); - - // Purges the list and calls delete on each element in it. - void PurgeAndDeleteElements(); - - // Set the size by which it grows when it needs to allocate more memory. - void SetGrowSize(int size); - -protected: - // Can't copy this unless we explicitly do it! - CUtlVector(CUtlVector const& vec) { assert(0); } - - // Grows the vector - void GrowVector(int num = 1); - - // Shifts elements.... - void ShiftElementsRight(int elem, int num = 1); - void ShiftElementsLeft(int elem, int num = 1); - - // For easier access to the elements through the debugger - void ResetDbgInfo(); - - CUtlMemory m_Memory; - int m_Size; - - // For easier access to the elements through the debugger - // it's in release builds so this can be used in libraries correctly - T *m_pElements; -}; - -//----------------------------------------------------------------------------- -// For easier access to the elements through the debugger -//----------------------------------------------------------------------------- - -template< class T > -inline void CUtlVector::ResetDbgInfo() -{ - m_pElements = m_Memory.Base(); -} - -//----------------------------------------------------------------------------- -// constructor, destructor -//----------------------------------------------------------------------------- - -template< class T > -inline CUtlVector::CUtlVector(int growSize, int initSize) : - m_Memory(growSize, initSize), m_Size(0) -{ - ResetDbgInfo(); -} - -template< class T > -inline CUtlVector::CUtlVector(T* pMemory, int numElements) : - m_Memory(pMemory, numElements), m_Size(0) -{ - ResetDbgInfo(); -} - -template< class T > -inline CUtlVector::~CUtlVector() -{ - Purge(); -} - -template -inline CUtlVector& CUtlVector::operator=(const CUtlVector &other) -{ - CopyArray(other.Base(), other.Count()); - return *this; -} - -//----------------------------------------------------------------------------- -// element access -//----------------------------------------------------------------------------- - -template< class T > -inline T& CUtlVector::operator[](int i) -{ - assert(IsValidIndex(i)); - return m_Memory[i]; -} - -template< class T > -inline T const& CUtlVector::operator[](int i) const -{ - assert(IsValidIndex(i)); - return m_Memory[i]; -} - -template< class T > -inline T& CUtlVector::Element(int i) -{ - assert(IsValidIndex(i)); - return m_Memory[i]; -} - -template< class T > -inline T const& CUtlVector::Element(int i) const -{ - assert(IsValidIndex(i)); - return m_Memory[i]; -} - -//----------------------------------------------------------------------------- -// Gets the base address (can change when adding elements!) -//----------------------------------------------------------------------------- - -template< class T > -inline T* CUtlVector::Base() -{ - return m_Memory.Base(); -} - -template< class T > -inline T const* CUtlVector::Base() const -{ - return m_Memory.Base(); -} - -//----------------------------------------------------------------------------- -// Count -//----------------------------------------------------------------------------- - -template< class T > -inline int CUtlVector::Size() const -{ - return m_Size; -} - -template< class T > -inline int CUtlVector::Count() const -{ - return m_Size; -} - -//----------------------------------------------------------------------------- -// Is element index valid? -//----------------------------------------------------------------------------- - -template< class T > -inline bool CUtlVector::IsValidIndex(int i) const -{ - return (i >= 0) && (i < m_Size); -} - -//----------------------------------------------------------------------------- -// Returns in invalid index -//----------------------------------------------------------------------------- -template< class T > -inline int CUtlVector::InvalidIndex(void) -{ - return -1; -} - -//----------------------------------------------------------------------------- -// Grows the vector -//----------------------------------------------------------------------------- -template< class T > -void CUtlVector::GrowVector(int num) -{ - if (m_Size + num - 1 >= m_Memory.NumAllocated()) - { - m_Memory.Grow(m_Size + num - m_Memory.NumAllocated()); - } - - m_Size += num; - ResetDbgInfo(); -} - -//----------------------------------------------------------------------------- -// Makes sure we have enough memory allocated to store a requested # of elements -//----------------------------------------------------------------------------- -template< class T > -void CUtlVector::EnsureCapacity(int num) -{ - m_Memory.EnsureCapacity(num); - ResetDbgInfo(); -} - -//----------------------------------------------------------------------------- -// Makes sure we have at least this many elements -//----------------------------------------------------------------------------- -template< class T > -void CUtlVector::EnsureCount(int num) -{ - if (Count() < num) - AddMultipleToTail(num - Count()); -} - -//----------------------------------------------------------------------------- -// Shifts elements -//----------------------------------------------------------------------------- -template< class T > -void CUtlVector::ShiftElementsRight(int elem, int num) -{ - assert(IsValidIndex(elem) || (m_Size == 0) || (num == 0)); - int numToMove = m_Size - elem - num; - if ((numToMove > 0) && (num > 0)) - memmove(&Element(elem+num), &Element(elem), numToMove * sizeof(T)); -} - -template< class T > -void CUtlVector::ShiftElementsLeft(int elem, int num) -{ - assert(IsValidIndex(elem) || (m_Size == 0) || (num == 0)); - int numToMove = m_Size - elem - num; - if ((numToMove > 0) && (num > 0)) - { - memmove(&Element(elem), &Element(elem+num), numToMove * sizeof(T)); - -#ifdef _DEBUG - memset(&Element(m_Size-num), 0xDD, num * sizeof(T)); -#endif - } -} - -//----------------------------------------------------------------------------- -// Adds an element, uses default constructor -//----------------------------------------------------------------------------- - -template< class T > -inline int CUtlVector::AddToHead() -{ - return InsertBefore(0); -} - -template< class T > -inline int CUtlVector::AddToTail() -{ - return InsertBefore(m_Size); -} - -template< class T > -inline int CUtlVector::InsertAfter(int elem) -{ - return InsertBefore(elem + 1); -} - -template< class T > -int CUtlVector::InsertBefore(int elem) -{ - // Can insert at the end - assert((elem == Count()) || IsValidIndex(elem)); - - GrowVector(); - ShiftElementsRight(elem); - Construct(&Element(elem)); - return elem; -} - -//----------------------------------------------------------------------------- -// Adds an element, uses copy constructor -//----------------------------------------------------------------------------- - -template< class T > -inline int CUtlVector::AddToHead(T const& src) -{ - return InsertBefore(0, src); -} - -template< class T > -inline int CUtlVector::AddToTail(T const& src) -{ - return InsertBefore(m_Size, src); -} - -template< class T > -inline int CUtlVector::InsertAfter(int elem, T const& src) -{ - return InsertBefore(elem + 1, src); -} - -template< class T > -int CUtlVector::InsertBefore(int elem, T const& src) -{ - // Can insert at the end - assert((elem == Count()) || IsValidIndex(elem)); - - GrowVector(); - ShiftElementsRight(elem); - CopyConstruct(&Element(elem), src); - return elem; -} - - -//----------------------------------------------------------------------------- -// Adds multiple elements, uses default constructor -//----------------------------------------------------------------------------- - -template< class T > -inline int CUtlVector::AddMultipleToHead(int num) -{ - return InsertMultipleBefore(0, num); -} - -template< class T > -inline int CUtlVector::AddMultipleToTail(int num, const T *pToCopy) -{ - return InsertMultipleBefore(m_Size, num, pToCopy); -} - -template< class T > -int CUtlVector::InsertMultipleAfter(int elem, int num) -{ - return InsertMultipleBefore(elem + 1, num); -} - - -template< class T > -void CUtlVector::SetCount(int count) -{ - RemoveAll(); - AddMultipleToTail(count); -} - -template< class T > -inline void CUtlVector::SetSize(int size) -{ - SetCount(size); -} - -template< class T > -void CUtlVector::CopyArray(T const *pArray, int size) -{ - SetSize(size); - for(int i=0; i < size; i++) - (*this)[i] = pArray[i]; -} - -template< class T > -int CUtlVector::AddVectorToTail(CUtlVector const &src) -{ - int base = Count(); - - // Make space. - AddMultipleToTail(src.Count()); - - // Copy the elements. - for (int i=0; i < src.Count(); i++) - (*this)[base + i] = src[i]; - - return base; -} - -template< class T > -inline int CUtlVector::InsertMultipleBefore(int elem, int num, const T *pToInsert) -{ - if(num == 0) - return elem; - - // Can insert at the end - assert((elem == Count()) || IsValidIndex(elem)); - - GrowVector(num); - ShiftElementsRight(elem, num); - - // Invoke default constructors - for (int i = 0; i < num; ++i) - Construct(&Element(elem+i)); - - // Copy stuff in? - if (pToInsert) - { - for (int i=0; i < num; i++) - { - Element(elem+i) = pToInsert[i]; - } - } - - return elem; -} - -//----------------------------------------------------------------------------- -// Finds an element (element needs operator== defined) -//----------------------------------------------------------------------------- -template< class T > -int CUtlVector::Find(T const& src) const -{ - for (int i = 0; i < Count(); ++i) - { - if (Element(i) == src) - return i; - } - return -1; -} - -template< class T > -bool CUtlVector::HasElement(T const& src) -{ - return (Find(src) >= 0); -} - -//----------------------------------------------------------------------------- -// Element removal -//----------------------------------------------------------------------------- - -template< class T > -void CUtlVector::FastRemove(int elem) -{ - assert(IsValidIndex(elem)); - - Destruct(&Element(elem)); - if (m_Size > 0) - { - Q_memcpy(&Element(elem), &Element(m_Size-1), sizeof(T)); - --m_Size; - } -} - -template< class T > -void CUtlVector::Remove(int elem) -{ - Destruct(&Element(elem)); - ShiftElementsLeft(elem); - --m_Size; -} - -template< class T > -void CUtlVector::FindAndRemove(T const& src) -{ - int elem = Find(src); - if (elem != -1) - { - Remove(elem); - } -} - -template< class T > -void CUtlVector::RemoveMultiple(int elem, int num) -{ - assert(IsValidIndex(elem)); - assert(elem + num <= Count()); - - for (int i = elem + num; --i >= elem;) - Destruct(&Element(i)); - - ShiftElementsLeft(elem, num); - m_Size -= num; -} - -template< class T > -void CUtlVector::RemoveAll() -{ - for (int i = m_Size; --i >= 0;) - Destruct(&Element(i)); - - m_Size = 0; -} - -//----------------------------------------------------------------------------- -// Memory deallocation -//----------------------------------------------------------------------------- - -template< class T > -void CUtlVector::Purge() -{ - RemoveAll(); - m_Memory.Purge(); - ResetDbgInfo(); -} - -template -inline void CUtlVector::PurgeAndDeleteElements() -{ - for (int i = 0; i < m_Size; i++) - delete Element(i); - - Purge(); -} - -template< class T > -void CUtlVector::SetGrowSize(int size) -{ - m_Memory.SetGrowSize(size); -} - -#endif // CCVECTOR_H diff --git a/regamedll/game_shared/GameEvent.h b/regamedll/game_shared/GameEvent.h index 2474e55d..f767d314 100644 --- a/regamedll/game_shared/GameEvent.h +++ b/regamedll/game_shared/GameEvent.h @@ -26,11 +26,7 @@ * */ -#ifndef GAME_EVENT_H -#define GAME_EVENT_H -#ifdef _WIN32 #pragma once -#endif enum GameEventType { @@ -141,5 +137,3 @@ enum GameEventType }; extern const char *GameEventName[ NUM_GAME_EVENTS + 1 ]; - -#endif // GAME_EVENT_H diff --git a/regamedll/game_shared/bitvec.h b/regamedll/game_shared/bitvec.h index a4c79848..1cb0072f 100644 --- a/regamedll/game_shared/bitvec.h +++ b/regamedll/game_shared/bitvec.h @@ -26,11 +26,7 @@ * */ -#ifndef BITVEC_H -#define BITVEC_H -#ifdef _WIN32 #pragma once -#endif class CBitVecAccessor { @@ -166,5 +162,3 @@ inline void CBitVec::SetDWord(int i, uint32 val) assert(i >= 0 && i < NUM_DWORDS); m_DWords[i] = val; } - -#endif // BITVEC_H diff --git a/regamedll/game_shared/bot/bot.cpp b/regamedll/game_shared/bot/bot.cpp index 5042c957..57005d13 100644 --- a/regamedll/game_shared/bot/bot.cpp +++ b/regamedll/game_shared/bot/bot.cpp @@ -20,7 +20,7 @@ bool UseBotArgs = false; CBot::CBot() { // the profile will be attached after this instance is constructed - m_profile = NULL; + m_profile = nullptr; // assign this bot a unique ID static unsigned int nextID = 1; @@ -49,7 +49,7 @@ void CBot::Spawn() pev->flags |= (FL_CLIENT | FL_FAKECLIENT); // Bots use their own thinking mechanism - SetThink(NULL); + SetThink(nullptr); pev->nextthink = -1; m_flNextBotThink = gpGlobals->time + g_flBotCommandInterval; @@ -494,7 +494,7 @@ void ActiveGrenade::OnEntityGone() m_dieTimestamp = gpGlobals->time + smokeLingerTime; } - m_entity = NULL; + m_entity = nullptr; } bool ActiveGrenade::IsValid() const diff --git a/regamedll/game_shared/bot/bot.h b/regamedll/game_shared/bot/bot.h index 571f5b13..18dc731e 100644 --- a/regamedll/game_shared/bot/bot.h +++ b/regamedll/game_shared/bot/bot.h @@ -26,11 +26,7 @@ * */ -#ifndef BOT_H -#define BOT_H -#ifdef _WIN32 #pragma once -#endif #include "gamerules.h" @@ -137,7 +133,7 @@ public: // return true if we can see any part of the player virtual bool IsVisible(CBasePlayer *player, bool testFOV = false, unsigned char *visParts = NULL) const = 0; - enum VisiblePartType:uint8 + enum VisiblePartType : uint8 { NONE = 0x00, CHEST = 0x01, @@ -419,5 +415,3 @@ extern const char *BotArgs[4]; extern bool UseBotArgs; extern bool AreBotsAllowed(); - -#endif // BOT_H diff --git a/regamedll/game_shared/bot/bot_constants.h b/regamedll/game_shared/bot/bot_constants.h index 44b1c74d..5098ab61 100644 --- a/regamedll/game_shared/bot/bot_constants.h +++ b/regamedll/game_shared/bot/bot_constants.h @@ -26,19 +26,11 @@ * */ -#ifndef BOT_CONSTANTS_H -#define BOT_CONSTANTS_H -#ifdef _WIN32 #pragma once -#endif - -// We'll define our own version of this, because everyone else does. -// This needs to stay in sync with MAX_CLIENTS, but there's no header with the #define. -#define BOT_MAX_CLIENTS 32 // version number is MAJOR.MINOR -#define BOT_VERSION_MAJOR 1 -#define BOT_VERSION_MINOR 50 +const int BOT_VERSION_MAJOR = 1; +const int BOT_VERSION_MINOR = 50; // Difficulty levels enum BotDifficultyType @@ -50,5 +42,3 @@ enum BotDifficultyType NUM_DIFFICULTY_LEVELS }; - -#endif // BOT_CONSTANTS_H diff --git a/regamedll/game_shared/bot/bot_manager.cpp b/regamedll/game_shared/bot/bot_manager.cpp index c6ec7e2e..129c17fe 100644 --- a/regamedll/game_shared/bot/bot_manager.cpp +++ b/regamedll/game_shared/bot/bot_manager.cpp @@ -102,7 +102,7 @@ const char *GameEventName[NUM_GAME_EVENTS + 1] = "EVENT_GAME_COMMENCE", "EVENT_WEAPON_ZOOMED", "EVENT_HOSTAGE_CALLED_FOR_HELP", - NULL, + nullptr, }; #endif // HOOK_GAMEDLL @@ -116,10 +116,13 @@ const float smokeRadius = 115.0f; // for smoke grenades // TODO: Find more appropriate place for this function GameEventType NameToGameEvent(const char *name) { - for (int i = 0; GameEventName[i] != NULL; ++i) + int index = 0; + for (auto event : GameEventName) { - if (!Q_stricmp(GameEventName[i], name)) - return static_cast(i); + if (!Q_stricmp(event, name)) + return static_cast(index); + + index++; } return EVENT_INVALID; @@ -144,7 +147,7 @@ void CBotManager::StartFrame() { Vector edge, lastEdge; - ActiveGrenadeList::iterator iter = m_activeGrenadeList.begin(); + auto iter = m_activeGrenadeList.begin(); while (iter != m_activeGrenadeList.end()) { ActiveGrenade *ag = (*iter); @@ -157,7 +160,9 @@ void CBotManager::StartFrame() continue; } else - ++iter; + { + iter++; + } const Vector *pos = ag->GetDetonationPosition(); @@ -191,7 +196,7 @@ void CBotManager::StartFrame() } // Process each active bot - for (int i = 1; i <= gpGlobals->maxClients; ++i) + for (int i = 1; i <= gpGlobals->maxClients; i++) { CBasePlayer *pPlayer = UTIL_PlayerByIndex(i); @@ -220,7 +225,7 @@ const char *CBotManager::GetNavMapFilename() const void CBotManager::OnEvent(GameEventType event, CBaseEntity *entity, CBaseEntity *other) { // propogate event to all bots - for (int i = 1; i <= gpGlobals->maxClients; ++i) + for (int i = 1; i <= gpGlobals->maxClients; i++) { CBasePlayer *player = UTIL_PlayerByIndex(i); @@ -266,7 +271,7 @@ void CBotManager::AddGrenade(int type, CGrenade *grenade) // The grenade entity in the world is going away void CBotManager::RemoveGrenade(CGrenade *grenade) { - for (ActiveGrenadeList::iterator iter = m_activeGrenadeList.begin(); iter != m_activeGrenadeList.end(); ++iter) + for (auto iter = m_activeGrenadeList.begin(); iter != m_activeGrenadeList.end(); iter++) { ActiveGrenade *ag = (*iter); @@ -281,7 +286,7 @@ void CBotManager::RemoveGrenade(CGrenade *grenade) // Destroy any invalid active grenades NOXREF void CBotManager::ValidateActiveGrenades() { - ActiveGrenadeList::iterator iter = m_activeGrenadeList.begin(); + auto iter = m_activeGrenadeList.begin(); while (iter != m_activeGrenadeList.end()) { ActiveGrenade *ag = (*iter); @@ -292,14 +297,16 @@ NOXREF void CBotManager::ValidateActiveGrenades() iter = m_activeGrenadeList.erase(iter); } else - ++iter; + { + iter++; + } } } void CBotManager::DestroyAllGrenades() { - for (ActiveGrenadeList::iterator iter = m_activeGrenadeList.begin(); iter != m_activeGrenadeList.end(); iter++) - delete (*iter); + for (auto grenade : m_activeGrenadeList) + delete grenade; m_activeGrenadeList.clear(); } @@ -307,7 +314,7 @@ void CBotManager::DestroyAllGrenades() // Return true if position is inside a smoke cloud bool CBotManager::IsInsideSmokeCloud(const Vector *pos) { - ActiveGrenadeList::iterator iter = m_activeGrenadeList.begin(); + auto iter = m_activeGrenadeList.begin(); while (iter != m_activeGrenadeList.end()) { ActiveGrenade *ag = (*iter); @@ -320,7 +327,9 @@ bool CBotManager::IsInsideSmokeCloud(const Vector *pos) continue; } else - ++iter; + { + iter++; + } if (ag->GetID() == WEAPON_SMOKEGRENADE) { @@ -349,7 +358,7 @@ bool CBotManager::IsLineBlockedBySmoke(const Vector *from, const Vector *to) Vector sightDir = *to - *from; float sightLength = sightDir.NormalizeInPlace(); - ActiveGrenadeList::iterator iter = m_activeGrenadeList.begin(); + auto iter = m_activeGrenadeList.begin(); while (iter != m_activeGrenadeList.end()) { ActiveGrenade *ag = (*iter); @@ -362,7 +371,9 @@ bool CBotManager::IsLineBlockedBySmoke(const Vector *from, const Vector *to) continue; } else - ++iter; + { + iter++; + } if (ag->GetID() == WEAPON_SMOKEGRENADE) { diff --git a/regamedll/game_shared/bot/bot_manager.h b/regamedll/game_shared/bot/bot_manager.h index 1dae1171..bead0e9d 100644 --- a/regamedll/game_shared/bot/bot_manager.h +++ b/regamedll/game_shared/bot/bot_manager.h @@ -26,11 +26,7 @@ * */ -#ifndef BOT_MANAGER_H -#define BOT_MANAGER_H -#ifdef _WIN32 #pragma once -#endif // STL uses exceptions, but we are not compiling with them - ignore warning #pragma warning(disable : 4530) @@ -51,7 +47,6 @@ public: bool IsEntity(CGrenade *grenade) const { return (grenade == m_entity) ? true : false; } int GetID() const { return m_id; } const Vector *GetDetonationPosition() const { return &m_detonationPosition; } - const Vector *GetPosition() const; private: @@ -83,7 +78,7 @@ public: virtual void StartFrame(); // Events are propogated to all bots. - virtual void OnEvent(GameEventType event, CBaseEntity *entity = NULL, CBaseEntity *other = NULL); // Invoked when event occurs in the game (some events have NULL entity). + virtual void OnEvent(GameEventType event, CBaseEntity *entity = nullptr, CBaseEntity *other = nullptr); // Invoked when event occurs in the game (some events have NULL entity). virtual unsigned int GetPlayerPriority(CBasePlayer *player) const = 0; // return priority of player (0 = max pri) public: @@ -103,5 +98,3 @@ private: }; GameEventType NameToGameEvent(const char *name); - -#endif // BOT_MANAGER_H diff --git a/regamedll/game_shared/bot/bot_profile.cpp b/regamedll/game_shared/bot/bot_profile.cpp index 32a047d5..7bd70ff9 100644 --- a/regamedll/game_shared/bot/bot_profile.cpp +++ b/regamedll/game_shared/bot/bot_profile.cpp @@ -6,8 +6,8 @@ */ #ifndef HOOK_GAMEDLL -BotProfileManager *TheBotProfiles = NULL; -char *BotDifficultyName[] = { "EASY", "NORMAL", "HARD", "EXPERT", NULL }; +BotProfileManager *TheBotProfiles = nullptr; +char *BotDifficultyName[] = { "EASY", "NORMAL", "HARD", "EXPERT", nullptr }; #endif @@ -23,7 +23,7 @@ const char *GetDecoratedSkinName(const char *name, const char *filename) const char *BotProfile::GetWeaponPreferenceAsString(int i) const { if (i < 0 || i >= m_weaponPreferenceCount) - return NULL; + return nullptr; return WeaponIDToAlias(m_weaponPreference[i]); } @@ -31,7 +31,7 @@ const char *BotProfile::GetWeaponPreferenceAsString(int i) const // Return true if this profile has a primary weapon preference bool BotProfile::HasPrimaryPreference() const { - for (int i = 0; i < m_weaponPreferenceCount; ++i) + for (int i = 0; i < m_weaponPreferenceCount; i++) { int weaponClass = AliasToWeaponClass(WeaponIDToAlias(m_weaponPreference[i])); @@ -49,7 +49,7 @@ bool BotProfile::HasPrimaryPreference() const // Return true if this profile has a pistol weapon preference bool BotProfile::HasPistolPreference() const { - for (int i = 0; i < m_weaponPreferenceCount; ++i) + for (int i = 0; i < m_weaponPreferenceCount; i++) { if (AliasToWeaponClass(WeaponIDToAlias(m_weaponPreference[i])) == WEAPONCLASS_PISTOL) return true; @@ -67,11 +67,11 @@ bool BotProfile::IsValidForTeam(BotProfileTeamType team) const BotProfileManager::BotProfileManager() { m_nextSkin = 0; - for (int i = 0; i < NumCustomSkins; ++i) + for (int i = 0; i < NumCustomSkins; i++) { - m_skins[i] = NULL; - m_skinFilenames[i] = NULL; - m_skinModelnames[i] = NULL; + m_skins[i] = nullptr; + m_skinFilenames[i] = nullptr; + m_skinModelnames[i] = nullptr; } } @@ -80,9 +80,9 @@ void BotProfileManager::Init(const char *filename, unsigned int *checksum) { int dataLength; char *dataPointer = (char *)LOAD_FILE_FOR_ME(const_cast(filename), &dataLength); - const char *dataFile = dataPointer; + char *dataFile = dataPointer; - if (dataFile == NULL) + if (!dataFile) { if (AreBotsAllowed()) { @@ -182,13 +182,13 @@ void BotProfileManager::Init(const char *filename, unsigned int *checksum) if (m_nextSkin < NumCustomSkins && !skinExists) { // decorate the name - m_skins[ m_nextSkin ] = CloneString(decoratedName); + m_skins[m_nextSkin] = CloneString(decoratedName); // construct the model filename - m_skinModelnames[ m_nextSkin ] = CloneString(token); - m_skinFilenames[ m_nextSkin ] = new char[ Q_strlen(token) * 2 + Q_strlen("models/player//.mdl") + 1 ]; - Q_sprintf(m_skinFilenames[ m_nextSkin ], "models/player/%s/%s.mdl", token, token); - ++m_nextSkin; + m_skinModelnames[m_nextSkin] = CloneString(token); + m_skinFilenames[m_nextSkin] = new char[Q_strlen(token) * 2 + Q_strlen("models/player//.mdl") + 1]; + Q_sprintf(m_skinFilenames[m_nextSkin], "models/player/%s/%s.mdl", token, token); + m_nextSkin++; } // eat 'End' @@ -228,7 +228,7 @@ void BotProfileManager::Init(const char *filename, unsigned int *checksum) // do inheritance in order of appearance if (!isTemplate && !isDefault) { - const BotProfile *inherit = NULL; + const BotProfile *inherit = nullptr; // template names are separated by "+" while (true) @@ -238,16 +238,16 @@ void BotProfileManager::Init(const char *filename, unsigned int *checksum) *c = '\0'; // find the given template name - for (BotProfileList::iterator iter = templateList.begin(); iter != templateList.end(); ++iter) + for (auto templates : templateList) { - if (!Q_stricmp((*iter)->GetName(), token)) + if (!Q_stricmp(templates->GetName(), token)) { - inherit = (*iter); + inherit = templates; break; } } - if (inherit == NULL) + if (!inherit) { CONSOLE_ECHO("Error parsing '%s' - invalid template reference '%s'\n", filename, token); FREE_FILE(dataPointer); @@ -257,7 +257,7 @@ void BotProfileManager::Init(const char *filename, unsigned int *checksum) // inherit the data profile->Inherit(inherit, &defaultProfile); - if (c == NULL) + if (c == nullptr) break; token = c + 1; @@ -389,7 +389,7 @@ void BotProfileManager::Init(const char *filename, unsigned int *checksum) { if (profile->m_weaponPreferenceCount < BotProfile::MAX_WEAPON_PREFS) { - profile->m_weaponPreference[ profile->m_weaponPreferenceCount++ ] = AliasToWeaponID(token); + profile->m_weaponPreference[profile->m_weaponPreferenceCount++] = AliasToWeaponID(token); } } } @@ -420,13 +420,13 @@ void BotProfileManager::Init(const char *filename, unsigned int *checksum) if (c) *c = '\0'; - for (int i = 0; i < NUM_DIFFICULTY_LEVELS; ++i) + for (int i = 0; i < NUM_DIFFICULTY_LEVELS; i++) { if (!Q_stricmp(BotDifficultyName[i], token)) - profile->m_difficultyFlags |= (1 << i); + profile->m_difficultyFlags |= (1< LastCustomSkin) { - return NULL; + return nullptr; } - return m_skins[ index - FirstCustomSkin ]; + return m_skins[index - FirstCustomSkin]; } // Returns custom skin filename at a particular index @@ -531,10 +531,10 @@ const char *BotProfileManager::GetCustomSkinFname(int index) { if (index < FirstCustomSkin || index > LastCustomSkin) { - return NULL; + return nullptr; } - return m_skinFilenames[ index - FirstCustomSkin ]; + return m_skinFilenames[index - FirstCustomSkin]; } // Returns custom skin modelname at a particular index @@ -542,22 +542,22 @@ const char *BotProfileManager::GetCustomSkinModelname(int index) { if (index < FirstCustomSkin || index > LastCustomSkin) { - return NULL; + return nullptr; } - return m_skinModelnames[ index - FirstCustomSkin ]; + return m_skinModelnames[index - FirstCustomSkin]; } // Looks up a custom skin index by filename-decorated name (will decorate the name if filename is given) int BotProfileManager::GetCustomSkinIndex(const char *name, const char *filename) { const char *skinName = name; - if (filename != NULL) + if (filename) { skinName = GetDecoratedSkinName(name, filename); } - for (int i = 0; i < NumCustomSkins; ++i) + for (int i = 0; i < NumCustomSkins; i++) { if (m_skins[i]) { @@ -575,12 +575,12 @@ int BotProfileManager::GetCustomSkinIndex(const char *name, const char *filename int BotProfileManager::FindVoiceBankIndex(const char *filename) { int index = 0; - for (VoiceBankList::const_iterator it = m_voiceBanks.begin(); it != m_voiceBanks.end(); ++it, ++index) + for (auto phrase : m_voiceBanks) { - if (!Q_stricmp(filename, *it)) - { + if (!Q_stricmp(filename, phrase)) return index; - } + + index++; } m_voiceBanks.push_back(CloneString(filename)); @@ -595,24 +595,19 @@ const BotProfile *BotProfileManager::GetRandomProfile(BotDifficultyType difficul // count up valid profiles int validCount = 0; - for (iter = m_profileList.begin(); iter != m_profileList.end(); ++iter) + for (auto profile : m_profileList) { - const BotProfile *profile = (*iter); - if (profile->IsDifficulty(difficulty) && !UTIL_IsNameTaken(profile->GetName()) && profile->IsValidForTeam(team)) - ++validCount; + validCount++; } if (validCount == 0) - return NULL; + return nullptr; // select one at random int which = RANDOM_LONG(0, validCount - 1); - - for (iter = m_profileList.begin(); iter != m_profileList.end(); ++iter) + for (auto profile : m_profileList) { - const BotProfile *profile = (*iter); - if (profile->IsDifficulty(difficulty) && !UTIL_IsNameTaken(profile->GetName()) && profile->IsValidForTeam(team)) { if (which-- == 0) @@ -620,9 +615,9 @@ const BotProfile *BotProfileManager::GetRandomProfile(BotDifficultyType difficul } } - return NULL; + return nullptr; #else // we don't need random profiles when we're not in the game dll - return NULL; + return nullptr; #endif // RANDOM_LONG } diff --git a/regamedll/game_shared/bot/bot_profile.h b/regamedll/game_shared/bot/bot_profile.h index 9270a3bf..adddebc7 100644 --- a/regamedll/game_shared/bot/bot_profile.h +++ b/regamedll/game_shared/bot/bot_profile.h @@ -26,11 +26,7 @@ * */ -#ifndef BOT_PROFILE -#define BOT_PROFILE -#ifdef _WIN32 #pragma once -#endif // long STL names get truncated in browse info. #pragma warning(disable : 4786) @@ -67,7 +63,7 @@ class BotProfile public: BotProfile() { - m_name = NULL; + m_name = nullptr; m_aggression = 0.0f; m_skill = 0.0f; m_teamwork = 0.0f; @@ -183,7 +179,7 @@ public: BotProfileManager(); ~BotProfileManager(); - void Init(const char *filename, unsigned int *checksum = NULL); + void Init(const char *filename, unsigned int *checksum = nullptr); void Reset(); const BotProfile *GetProfile(const char *name, BotProfileTeamType team) const @@ -194,7 +190,7 @@ public: return (*iter); } - return NULL; + return nullptr; } const BotProfileList *GetProfileList() const { return &m_profileList; } const BotProfile *GetRandomProfile(BotDifficultyType difficulty, BotProfileTeamType team) const; @@ -202,7 +198,7 @@ public: const char *GetCustomSkin(int index); const char *GetCustomSkinModelname(int index); const char *GetCustomSkinFname(int index); - int GetCustomSkinIndex(const char *name, const char *filename = NULL); + int GetCustomSkinIndex(const char *name, const char *filename = nullptr); typedef std::STD_VECTOR VoiceBankList; @@ -220,5 +216,3 @@ protected: }; extern BotProfileManager *TheBotProfiles; - -#endif // BOT_PROFILE diff --git a/regamedll/game_shared/bot/bot_util.cpp b/regamedll/game_shared/bot/bot_util.cpp index 82f50417..22ed99e3 100644 --- a/regamedll/game_shared/bot/bot_util.cpp +++ b/regamedll/game_shared/bot/bot_util.cpp @@ -6,30 +6,30 @@ #ifndef HOOK_GAMEDLL short s_iBeamSprite = 0; -float cosTable[ COS_TABLE_SIZE ]; +float cosTable[COS_TABLE_SIZE]; #endif bool UTIL_IsNameTaken(const char *name, bool ignoreHumans) { - for (int i = 1; i <= gpGlobals->maxClients; ++i) + for (int i = 1; i <= gpGlobals->maxClients; i++) { - CBaseEntity *player = UTIL_PlayerByIndex(i); + CBasePlayer *pPlayer = UTIL_PlayerByIndex(i); - if (player == NULL) + if (!pPlayer) continue; - if (FNullEnt(player->pev)) + if (FNullEnt(pPlayer->pev)) continue; - if (FStrEq(STRING(player->pev->netname), "")) + if (FStrEq(STRING(pPlayer->pev->netname), "")) continue; - if (player->IsPlayer() && ((CBasePlayer *)player)->IsBot()) + if (pPlayer->IsPlayer() && pPlayer->IsBot()) { // bots can have prefixes so we need to check the name // against the profile name instead. - CBot *bot = static_cast(player); + CBot *bot = static_cast(pPlayer); if (FStrEq(name, bot->GetProfile()->GetName())) { return true; @@ -39,7 +39,7 @@ bool UTIL_IsNameTaken(const char *name, bool ignoreHumans) { if (!ignoreHumans) { - if (FStrEq(name, STRING(player->pev->netname))) + if (FStrEq(name, STRING(pPlayer->pev->netname))) return true; } } @@ -51,11 +51,11 @@ bool UTIL_IsNameTaken(const char *name, bool ignoreHumans) int UTIL_ClientsInGame() { int iCount = 0; - for (int iIndex = 1; iIndex <= gpGlobals->maxClients; ++iIndex) + for (int iIndex = 1; iIndex <= gpGlobals->maxClients; iIndex++) { CBaseEntity *pPlayer = UTIL_PlayerByIndex(iIndex); - if (pPlayer == NULL) + if (!pPlayer) continue; if (FNullEnt(pPlayer->pev)) @@ -64,7 +64,7 @@ int UTIL_ClientsInGame() if (FStrEq(STRING(pPlayer->pev->netname), "")) continue; - ++iCount; + iCount++; } return iCount; @@ -73,27 +73,27 @@ int UTIL_ClientsInGame() int UTIL_ActivePlayersInGame() { int iCount = 0; - for (int iIndex = 1; iIndex <= gpGlobals->maxClients; ++iIndex) + for (int iIndex = 1; iIndex <= gpGlobals->maxClients; iIndex++) { - CBasePlayer *player = UTIL_PlayerByIndex(iIndex); + CBasePlayer *pPlayer = UTIL_PlayerByIndex(iIndex); - if (player == NULL) + if (!pPlayer) continue; - if (FNullEnt(player->pev)) + if (FNullEnt(pPlayer->pev)) continue; - if (FStrEq(STRING(player->pev->netname), "")) + if (FStrEq(STRING(pPlayer->pev->netname), "")) continue; // ignore spectators - if (player->m_iTeam != TERRORIST && player->m_iTeam != CT) + if (pPlayer->m_iTeam != TERRORIST && pPlayer->m_iTeam != CT) continue; - if (player->m_iJoiningState != JOINED) + if (pPlayer->m_iJoiningState != JOINED) continue; - ++iCount; + iCount++; } return iCount; @@ -103,29 +103,29 @@ int UTIL_HumansInGame(bool ignoreSpectators) { int iCount = 0; - for (int iIndex = 1; iIndex <= gpGlobals->maxClients; ++iIndex) + for (int iIndex = 1; iIndex <= gpGlobals->maxClients; iIndex++) { - CBasePlayer *player = UTIL_PlayerByIndex(iIndex); + CBasePlayer *pPlayer = UTIL_PlayerByIndex(iIndex); - if (player == NULL) + if (!pPlayer) continue; - if (FNullEnt(player->pev)) + if (FNullEnt(pPlayer->pev)) continue; - if (FStrEq(STRING(player->pev->netname), "")) + if (FStrEq(STRING(pPlayer->pev->netname), "")) continue; - if (player->IsBot()) + if (pPlayer->IsBot()) continue; - if (ignoreSpectators && player->m_iTeam != TERRORIST && player->m_iTeam != CT) + if (ignoreSpectators && pPlayer->m_iTeam != TERRORIST && pPlayer->m_iTeam != CT) continue; - if (ignoreSpectators && player->m_iJoiningState != JOINED) + if (ignoreSpectators && pPlayer->m_iJoiningState != JOINED) continue; - ++iCount; + iCount++; } return iCount; @@ -134,29 +134,29 @@ int UTIL_HumansInGame(bool ignoreSpectators) int UTIL_HumansOnTeam(int teamID, bool isAlive) { int iCount = 0; - for (int iIndex = 1; iIndex <= gpGlobals->maxClients; ++iIndex) + for (int iIndex = 1; iIndex <= gpGlobals->maxClients; iIndex++) { - CBasePlayer *player = UTIL_PlayerByIndex(iIndex); + CBasePlayer *pPlayer = UTIL_PlayerByIndex(iIndex); - if (player == NULL) + if (!pPlayer) continue; - if (FNullEnt(player->pev)) + if (FNullEnt(pPlayer->pev)) continue; - if (FStrEq(STRING(player->pev->netname), "")) + if (FStrEq(STRING(pPlayer->pev->netname), "")) continue; - if (player->IsBot()) + if (pPlayer->IsBot()) continue; - if (player->m_iTeam != teamID) + if (pPlayer->m_iTeam != teamID) continue; - if (isAlive && !player->IsAlive()) + if (isAlive && !pPlayer->IsAlive()) continue; - ++iCount; + iCount++; } return iCount; @@ -166,11 +166,11 @@ int UTIL_BotsInGame() { int iCount = 0; - for (int iIndex = 1; iIndex <= gpGlobals->maxClients; ++iIndex) + for (int iIndex = 1; iIndex <= gpGlobals->maxClients; iIndex++) { CBasePlayer *pPlayer = UTIL_PlayerByIndex(iIndex); - if (pPlayer == NULL) + if (!pPlayer) continue; if (FNullEnt(pPlayer->pev)) @@ -182,7 +182,7 @@ int UTIL_BotsInGame() if (!pPlayer->IsBot()) continue; - ++iCount; + iCount++; } return iCount; @@ -193,53 +193,53 @@ bool UTIL_KickBotFromTeam(TeamName kickTeam) int i; // try to kick a dead bot first - for (i = 1; i <= gpGlobals->maxClients; ++i) + for (i = 1; i <= gpGlobals->maxClients; i++) { - CBasePlayer *player = UTIL_PlayerByIndex(i); + CBasePlayer *pPlayer = UTIL_PlayerByIndex(i); - if (player == NULL) + if (!pPlayer) continue; - if (FNullEnt(player->pev)) + if (FNullEnt(pPlayer->pev)) continue; - const char *name = STRING(player->pev->netname); + const char *name = STRING(pPlayer->pev->netname); if (FStrEq(name, "")) continue; - if (!player->IsBot()) + if (!pPlayer->IsBot()) continue; - if (!player->IsAlive() && player->m_iTeam == kickTeam) + if (!pPlayer->IsAlive() && pPlayer->m_iTeam == kickTeam) { // its a bot on the right team - kick it - SERVER_COMMAND(UTIL_VarArgs("kick \"%s\"\n", STRING(player->pev->netname))); + SERVER_COMMAND(UTIL_VarArgs("kick \"%s\"\n", STRING(pPlayer->pev->netname))); return true; } } // no dead bots, kick any bot on the given team - for (i = 1; i <= gpGlobals->maxClients; ++i) + for (i = 1; i <= gpGlobals->maxClients; i++) { - CBasePlayer *player = UTIL_PlayerByIndex(i); + CBasePlayer *pPlayer = UTIL_PlayerByIndex(i); - if (player == NULL) + if (!pPlayer) continue; - if (FNullEnt(player->pev)) + if (FNullEnt(pPlayer->pev)) continue; - const char *name = STRING(player->pev->netname); + const char *name = STRING(pPlayer->pev->netname); if (FStrEq(name, "")) continue; - if (!player->IsBot()) + if (!pPlayer->IsBot()) continue; - if (player->m_iTeam == kickTeam) + if (pPlayer->m_iTeam == kickTeam) { // its a bot on the right team - kick it - SERVER_COMMAND(UTIL_VarArgs("kick \"%s\"\n", STRING(player->pev->netname))); + SERVER_COMMAND(UTIL_VarArgs("kick \"%s\"\n", STRING(pPlayer->pev->netname))); return true; } } @@ -250,26 +250,26 @@ bool UTIL_KickBotFromTeam(TeamName kickTeam) bool UTIL_IsTeamAllBots(int team) { int botCount = 0; - for (int i = 1; i <= gpGlobals->maxClients; ++i) + for (int i = 1; i <= gpGlobals->maxClients; i++) { - CBasePlayer *player = UTIL_PlayerByIndex(i); + CBasePlayer *pPlayer = UTIL_PlayerByIndex(i); - if (player == NULL) + if (!pPlayer) continue; - if (player->m_iTeam != team) + if (pPlayer->m_iTeam != team) continue; - if (FNullEnt(player->pev)) + if (FNullEnt(pPlayer->pev)) continue; - if (FStrEq(STRING(player->pev->netname), "")) + if (FStrEq(STRING(pPlayer->pev->netname), "")) continue; - if (!(player->pev->flags & FL_FAKECLIENT)) + if (!(pPlayer->pev->flags & FL_FAKECLIENT)) return false; - ++botCount; + botCount++; } return botCount ? true : false; @@ -279,24 +279,24 @@ bool UTIL_IsTeamAllBots(int team) // If 'distance' is non-NULL, the distance to the closest player is returned in it. extern CBasePlayer *UTIL_GetClosestPlayer(const Vector *pos, float *distance) { - CBasePlayer *closePlayer = NULL; + CBasePlayer *closePlayer = nullptr; float closeDistSq = 1.0e12f; // 999999999999.9f - for (int i = 1; i <= gpGlobals->maxClients; ++i) + for (int i = 1; i <= gpGlobals->maxClients; i++) { - CBasePlayer *player = UTIL_PlayerByIndex(i); + CBasePlayer *pPlayer = UTIL_PlayerByIndex(i); - if (!IsEntityValid(player)) + if (!IsEntityValid(pPlayer)) continue; - if (!player->IsAlive()) + if (!pPlayer->IsAlive()) continue; - float distSq = (player->pev->origin - *pos).LengthSquared(); + float distSq = (pPlayer->pev->origin - *pos).LengthSquared(); if (distSq < closeDistSq) { closeDistSq = distSq; - closePlayer = player; + closePlayer = pPlayer; } } @@ -310,27 +310,27 @@ extern CBasePlayer *UTIL_GetClosestPlayer(const Vector *pos, float *distance) // If 'distance' is non-NULL, the distance to the closest player is returned in it. extern CBasePlayer *UTIL_GetClosestPlayer(const Vector *pos, int team, float *distance) { - CBasePlayer *closePlayer = NULL; + CBasePlayer *closePlayer = nullptr; float closeDistSq = 1.0e12f; // 999999999999.9f - for (int i = 1; i <= gpGlobals->maxClients; ++i) + for (int i = 1; i <= gpGlobals->maxClients; i++) { - CBasePlayer *player = UTIL_PlayerByIndex(i); + CBasePlayer *pPlayer = UTIL_PlayerByIndex(i); - if (!IsEntityValid(player)) + if (!IsEntityValid(pPlayer)) continue; - if (!player->IsAlive()) + if (!pPlayer->IsAlive()) continue; - if (player->m_iTeam != team) + if (pPlayer->m_iTeam != team) continue; - float distSq = (player->pev->origin - *pos).LengthSquared(); + float distSq = (pPlayer->pev->origin - *pos).LengthSquared(); if (distSq < closeDistSq) { closeDistSq = distSq; - closePlayer = player; + closePlayer = pPlayer; } } @@ -347,16 +347,17 @@ const char *UTIL_GetBotPrefix() void UTIL_ConstructBotNetName(char *name, int nameLength, const BotProfile *profile) { - if (profile == NULL) + if (!profile) { name[0] = '\0'; return; } // if there is no bot prefix just use the profile name. - if ((UTIL_GetBotPrefix() == NULL) || (Q_strlen(UTIL_GetBotPrefix()) == 0)) + if (!UTIL_GetBotPrefix() || Q_strlen(UTIL_GetBotPrefix()) == 0) { - Q_strncpy(name, profile->GetName(), nameLength); + Q_strncpy(name, profile->GetName(), nameLength - 1); + name[nameLength - 1] = '\0'; return; } @@ -365,30 +366,30 @@ void UTIL_ConstructBotNetName(char *name, int nameLength, const BotProfile *prof bool UTIL_IsVisibleToTeam(const Vector &spot, int team, float maxRange) { - for (int i = 1; i <= gpGlobals->maxClients; ++i) + for (int i = 1; i <= gpGlobals->maxClients; i++) { - CBasePlayer *player = UTIL_PlayerByIndex(i); + CBasePlayer *pPlayer = UTIL_PlayerByIndex(i); - if (player == NULL) + if (!pPlayer) continue; - if (FNullEnt(player->pev)) + if (FNullEnt(pPlayer->pev)) continue; - if (FStrEq(STRING(player->pev->netname), "")) + if (FStrEq(STRING(pPlayer->pev->netname), "")) continue; - if (!player->IsAlive()) + if (!pPlayer->IsAlive()) continue; - if (player->m_iTeam != team) + if (pPlayer->m_iTeam != team) continue; - if (maxRange > 0.0f && (spot - player->Center()).IsLengthGreaterThan(maxRange)) + if (maxRange > 0.0f && (spot - pPlayer->Center()).IsLengthGreaterThan(maxRange)) continue; TraceResult result; - UTIL_TraceLine(player->EyePosition(), spot, ignore_monsters, ignore_glass, ENT(player->pev), &result); + UTIL_TraceLine(pPlayer->EyePosition(), spot, ignore_monsters, ignore_glass, ENT(pPlayer->pev), &result); if (result.flFraction == 1.0f) return true; @@ -402,7 +403,7 @@ CBasePlayer *UTIL_GetLocalPlayer() if (!IS_DEDICATED_SERVER()) return UTIL_PlayerByIndex(1); - return NULL; + return nullptr; } NOXREF Vector UTIL_ComputeOrigin(entvars_t *pevVars) @@ -514,7 +515,7 @@ void BotPrecache() void InitBotTrig() { - for (int i = 0; i < COS_TABLE_SIZE; ++i) + for (int i = 0; i < COS_TABLE_SIZE; i++) { float_precision angle = 2.0f * M_PI * float(i) / float(COS_TABLE_SIZE - 1); cosTable[i] = Q_cos(angle); @@ -525,23 +526,23 @@ float BotCOS(float angle) { angle = NormalizeAnglePositive(angle); int i = angle * ((COS_TABLE_SIZE - 1) / 360.0f); - return cosTable[ i ]; + return cosTable[i]; } float BotSIN(float angle) { angle = NormalizeAnglePositive(angle - 90); int i = angle * ((COS_TABLE_SIZE - 1) / 360.0f); - return cosTable[ i ]; + return cosTable[i]; } // Determine if this event is audible, and if so, return its audible range and priority bool IsGameEventAudible(GameEventType event, CBaseEntity *entity, CBaseEntity *other, float *range, PriorityType *priority, bool *isHostile) { - CBasePlayer *player = static_cast(entity); + CBasePlayer *pPlayer = static_cast(entity); - if (entity == NULL || !player->IsPlayer()) - player = NULL; + if (!entity || !pPlayer->IsPlayer()) + pPlayer = nullptr; const float ShortRange = 1000.0f; const float NormalRange = 2000.0f; @@ -552,10 +553,10 @@ bool IsGameEventAudible(GameEventType event, CBaseEntity *entity, CBaseEntity *o // TODO: Use actual volume, account for silencers, etc. case EVENT_WEAPON_FIRED: { - if (player->m_pActiveItem == NULL) + if (!pPlayer->m_pActiveItem) return false; - switch (player->m_pActiveItem->m_iId) + switch (pPlayer->m_pActiveItem->m_iId) { // silent "firing" case WEAPON_HEGRENADE: @@ -572,7 +573,7 @@ bool IsGameEventAudible(GameEventType event, CBaseEntity *entity, CBaseEntity *o // M4A1 - check for silencer case WEAPON_M4A1: { - CBasePlayerWeapon *pWeapon = static_cast(player->m_pActiveItem); + CBasePlayerWeapon *pWeapon = static_cast(pPlayer->m_pActiveItem); if (pWeapon->m_iWeaponState & WPNSTATE_M4A1_SILENCED) *range = ShortRange; else @@ -582,7 +583,7 @@ bool IsGameEventAudible(GameEventType event, CBaseEntity *entity, CBaseEntity *o // USP - check for silencer case WEAPON_USP: { - CBasePlayerWeapon *pWeapon = static_cast(player->m_pActiveItem); + CBasePlayerWeapon *pWeapon = static_cast(pPlayer->m_pActiveItem); if (pWeapon->m_iWeaponState & WPNSTATE_USP_SILENCED) *range = ShortRange; else diff --git a/regamedll/game_shared/bot/bot_util.h b/regamedll/game_shared/bot/bot_util.h index 85a0c76e..6d43b0d3 100644 --- a/regamedll/game_shared/bot/bot_util.h +++ b/regamedll/game_shared/bot/bot_util.h @@ -26,19 +26,15 @@ * */ -#ifndef BOT_UTIL_H -#define BOT_UTIL_H -#ifdef _WIN32 #pragma once -#endif -#define COS_TABLE_SIZE 256 +#define COS_TABLE_SIZE 256 -#define RAD_TO_DEG(deg) ((deg) * 180.0 / M_PI) -#define DEG_TO_RAD(rad) ((rad) * M_PI / 180.0) +#define RAD_TO_DEG(deg) ((deg) * 180.0 / M_PI) +#define DEG_TO_RAD(rad) ((rad) * M_PI / 180.0) -#define SIGN(num) (((num) < 0) ? -1 : 1) -#define ABS(num) (SIGN(num) * (num)) +#define SIGN(num) (((num) < 0) ? -1 : 1) +#define ABS(num) (SIGN(num) * (num)) class CBasePlayer; class BotProfile; @@ -89,7 +85,7 @@ private: // Return true if the given entity is valid inline bool IsEntityValid(CBaseEntity *entity) { - if (entity == NULL) + if (!entity) return false; if (FNullEnt(entity->pev)) @@ -107,7 +103,7 @@ inline bool IsEntityValid(CBaseEntity *entity) // Given two line segments: startA to endA, and startB to endB, return true if they intesect // and put the intersection point in "result". // Note that this computes the intersection of the 2D (x,y) projection of the line segments. -inline bool IsIntersecting2D(const Vector &startA, const Vector &endA, const Vector &startB, const Vector &endB, Vector *result = NULL) +inline bool IsIntersecting2D(const Vector &startA, const Vector &endA, const Vector &startB, const Vector &endB, Vector *result = nullptr) { float denom = (endA.x - startA.x) * (endB.y - startB.y) - (endA.y - startA.y) * (endB.x - startB.x); if (denom == 0.0f) @@ -139,7 +135,7 @@ inline bool IsIntersecting2D(const Vector &startA, const Vector &endA, const Vec } // compute intesection point - if (result != NULL) + if (result) { *result = startA + s * (endA - startA); } @@ -225,8 +221,8 @@ int UTIL_ActivePlayersInGame(); int UTIL_BotsInGame(); bool UTIL_KickBotFromTeam(TeamName kickTeam); bool UTIL_IsTeamAllBots(int team); -CBasePlayer *UTIL_GetClosestPlayer(const Vector *pos, float *distance = NULL); -CBasePlayer *UTIL_GetClosestPlayer(const Vector *pos, int team, float *distance = NULL); +CBasePlayer *UTIL_GetClosestPlayer(const Vector *pos, float *distance = nullptr); +CBasePlayer *UTIL_GetClosestPlayer(const Vector *pos, int team, float *distance = nullptr); const char *UTIL_GetBotPrefix(); void UTIL_ConstructBotNetName(char *name, int nameLength, const BotProfile *profile); bool UTIL_IsVisibleToTeam(const Vector &spot, int team, float maxRange = -1.0f); @@ -248,5 +244,3 @@ float BotCOS(float angle); float BotSIN(float angle); bool IsGameEventAudible(enum GameEventType event, CBaseEntity *entity, CBaseEntity *other, float *range, PriorityType *priority, bool *isHostile); void HintMessageToAllPlayers(const char *message); - -#endif // BOT_UTIL_H diff --git a/regamedll/game_shared/bot/improv.h b/regamedll/game_shared/bot/improv.h index 69ab5840..a72d102a 100644 --- a/regamedll/game_shared/bot/improv.h +++ b/regamedll/game_shared/bot/improv.h @@ -26,11 +26,7 @@ * */ -#ifndef IMPROV_H -#define IMPROV_H -#ifdef _WIN32 #pragma once -#endif class CBaseEntity; class CNavLadder; @@ -49,7 +45,7 @@ public: }; virtual void OnMoveToFailure(const Vector &goal, MoveToFailureType reason) {}; // invoked when an improv fails to reach a MoveTo goal - virtual void OnInjury(float amount) {}; // invoked when the improv is injured + virtual void OnInjury(float amount) {}; // invoked when the improv is injured }; // The Improv interface definition @@ -62,18 +58,18 @@ public: virtual bool IsAlive() const = 0; // return true if this improv is alive - virtual void MoveTo(const Vector &goal) = 0; // move improv towards far-away goal (pathfind) - virtual void LookAt(const Vector &target) = 0; // define desired view target + virtual void MoveTo(const Vector &goal) = 0; // move improv towards far-away goal (pathfind) + virtual void LookAt(const Vector &target) = 0; // define desired view target virtual void ClearLookAt() = 0; // remove view goal - virtual void FaceTo(const Vector &goal) = 0; // orient body towards goal + virtual void FaceTo(const Vector &goal) = 0; // orient body towards goal virtual void ClearFaceTo() = 0; // remove body orientation goal - virtual bool IsAtMoveGoal(float error = 20.0f) const = 0; // return true if improv is standing on its movement goal - virtual bool HasLookAt() const = 0; // return true if improv has a look at goal - virtual bool HasFaceTo() const = 0; // return true if improv has a face to goal - virtual bool IsAtFaceGoal() const = 0; // return true if improv is facing towards its face goal - virtual bool IsFriendInTheWay(const Vector &goalPos) const = 0; // return true if a friend is blocking our line to the given goal position - virtual bool IsFriendInTheWay(CBaseEntity *myFriend, const Vector &goalPos) const = 0; // return true if the given friend is blocking our line to the given goal position + virtual bool IsAtMoveGoal(float error = 20.0f) const = 0; // return true if improv is standing on its movement goal + virtual bool HasLookAt() const = 0; // return true if improv has a look at goal + virtual bool HasFaceTo() const = 0; // return true if improv has a face to goal + virtual bool IsAtFaceGoal() const = 0; // return true if improv is facing towards its face goal + virtual bool IsFriendInTheWay(const Vector &goalPos) const = 0; // return true if a friend is blocking our line to the given goal position + virtual bool IsFriendInTheWay(CBaseEntity *myFriend, const Vector &goalPos) const = 0; // return true if the given friend is blocking our line to the given goal position virtual void MoveForward() = 0; virtual void MoveBackward() = 0; @@ -83,11 +79,11 @@ public: virtual void Crouch() = 0; virtual void StandUp() = 0; // "un-crouch" - virtual void TrackPath(const Vector &pathGoal, float deltaT) = 0; // move along path by following "pathGoal" - virtual void StartLadder(const CNavLadder *ladder, enum NavTraverseType how, const Vector *approachPos, const Vector *departPos) = 0; // invoked when a ladder is encountered while following a path + virtual void TrackPath(const Vector &pathGoal, float deltaT) = 0; // move along path by following "pathGoal" + virtual void StartLadder(const CNavLadder *ladder, enum NavTraverseType how, const Vector *approachPos, const Vector *departPos) = 0; // invoked when a ladder is encountered while following a path virtual bool TraverseLadder(const CNavLadder *ladder, enum NavTraverseType how, const Vector *approachPos, const Vector *departPos, float deltaT) = 0; // traverse given ladder - virtual bool GetSimpleGroundHeightWithFloor(const Vector *pos, float *height, Vector *normal = NULL) = 0; // find "simple" ground height, treating current nav area as part of the floor + virtual bool GetSimpleGroundHeightWithFloor(const Vector *pos, float *height, Vector *normal = NULL) = 0; // find "simple" ground height, treating current nav area as part of the floor virtual void Run() = 0; virtual void Walk() = 0; @@ -113,8 +109,8 @@ public: virtual bool CanRun() const = 0; virtual bool CanCrouch() const = 0; virtual bool CanJump() const = 0; - virtual bool IsVisible(const Vector &pos, bool testFOV = false) const = 0; // return true if improv can see position - virtual bool IsPlayerLookingAtMe(CBasePlayer *other, float cosTolerance = 0.95f) const = 0; // return true if 'other' is looking right at me + virtual bool IsVisible(const Vector &pos, bool testFOV = false) const = 0; // return true if improv can see position + virtual bool IsPlayerLookingAtMe(CBasePlayer *other, float cosTolerance = 0.95f) const = 0; // return true if 'other' is looking right at me virtual CBasePlayer *IsAnyPlayerLookingAtMe(int team = 0, float cosTolerance = 0.95f) const = 0; // return player on given team that is looking right at me (team == 0 means any team), NULL otherwise virtual CBasePlayer *GetClosestPlayerByTravelDistance(int team = 0, float *range = NULL) const = 0; // return actual travel distance to closest player on given team (team == 0 means any team) @@ -122,9 +118,7 @@ public: virtual void OnUpdate(float deltaT) = 0; // a less frequent, full update 'tick' virtual void OnUpkeep(float deltaT) = 0; // a frequent, lightweight update 'tick' - virtual void OnReset() = 0; // reset improv to initial state + virtual void OnReset() = 0; // reset improv to initial state virtual void OnGameEvent(GameEventType event, CBaseEntity *entity, CBaseEntity *other) = 0; // invoked when an event occurs in the game - virtual void OnTouch(CBaseEntity *other) = 0; // "other" has touched us + virtual void OnTouch(CBaseEntity *other) = 0; // "other" has touched us }; - -#endif // IMPROV_H diff --git a/regamedll/game_shared/bot/nav.h b/regamedll/game_shared/bot/nav.h index a68d2038..468748a6 100644 --- a/regamedll/game_shared/bot/nav.h +++ b/regamedll/game_shared/bot/nav.h @@ -26,17 +26,13 @@ * */ -#ifndef NAV_H -#define NAV_H -#ifdef _WIN32 #pragma once -#endif // STL uses exceptions, but we are not compiling with them - ignore warning #pragma warning(disable : 4530) // to help identify nav files -#define NAV_MAGIC_NUMBER 0xFEEDFACE +#define NAV_MAGIC_NUMBER 0xFEEDFACE // version // 1 = hiding spots as plain vector array @@ -45,18 +41,18 @@ // 4 = Includes size of source bsp file to verify nav data correlation // ---- Beta Release at V4 ----- // 5 = Added Place info -#define NAV_VERSION 5 +#define NAV_VERSION 5 // A place is a named group of navigation areas typedef unsigned int Place; // ie: "no place" -#define UNDEFINED_PLACE 0 -#define ANY_PLACE 0xFFFF +#define UNDEFINED_PLACE 0 +#define ANY_PLACE 0xFFFF -#define WALK_THRU_DOORS 0x01 -#define WALK_THRU_BREAKABLES 0x02 -#define WALK_THRU_EVERYTHING (WALK_THRU_DOORS | WALK_THRU_BREAKABLES) +#define WALK_THRU_DOORS 0x01 +#define WALK_THRU_BREAKABLES 0x02 +#define WALK_THRU_EVERYTHING (WALK_THRU_DOORS | WALK_THRU_BREAKABLES) enum NavErrorType { @@ -69,10 +65,10 @@ enum NavErrorType enum NavAttributeType { - NAV_CROUCH = 0x01, // must crouch to use this node/area - NAV_JUMP = 0x02, // must jump to traverse this area - NAV_PRECISE = 0x04, // do not adjust for obstacles, just move along area - NAV_NO_JUMP = 0x08, // inhibit discontinuity jumping + NAV_CROUCH = 0x01, // must crouch to use this node/area + NAV_JUMP = 0x02, // must jump to traverse this area + NAV_PRECISE = 0x04, // do not adjust for obstacles, just move along area + NAV_NO_JUMP = 0x08, // inhibit discontinuity jumping }; enum NavDirType @@ -122,25 +118,25 @@ enum NavRelativeDirType NUM_RELATIVE_DIRECTIONS }; -const float GenerationStepSize = 25.0f; // (30) was 20, but bots can't fit always fit -const float StepHeight = 18.0f; // if delta Z is greater than this, we have to jump to get up -const float JumpHeight = 41.8f; // if delta Z is less than this, we can jump up on it -const float JumpCrouchHeight = 58.0f; // (48) if delta Z is less than or equal to this, we can jumpcrouch up on it +const double GenerationStepSize = 25.0; // (30) was 20, but bots can't fit always fit +const float StepHeight = 18.0f; // if delta Z is greater than this, we have to jump to get up +const float JumpHeight = 41.8f; // if delta Z is less than this, we can jump up on it +const float JumpCrouchHeight = 58.0f; // (48) if delta Z is less than or equal to this, we can jumpcrouch up on it // Strictly speaking, you CAN get up a slope of 1.643 (about 59 degrees), but you move very, very slowly // This slope will represent the slope you can navigate without much slowdown // rise/run - if greater than this, we can't move up it (de_survivor canyon ramps) -const float MaxSlope = 1.4f; +const float MaxSlope = 1.4f; // instead of MaxSlope, we are using the following max Z component of a unit normal const float MaxUnitZSlope = 0.7f; -const float BotRadius = 10.0f; // circular extent that contains bot -const float DeathDrop = 200.0f; // (300) distance at which we will die if we fall - should be about 600, and pay attention to fall damage during pathfind +const float BotRadius = 10.0f; // circular extent that contains bot +const float DeathDrop = 200.0f; // (300) distance at which we will die if we fall - should be about 600, and pay attention to fall damage during pathfind -const float HalfHumanWidth = 16.0f; +const float HalfHumanWidth = 16.0f; const float HalfHumanHeight = 36.0f; -const float HumanHeight = 72.0f; +const float HumanHeight = 72.0f; struct Extent { @@ -311,7 +307,6 @@ inline void SnapToGrid(float *value) *value = c * GenerationStepSize; } -// custom inline float SnapToGrid(float value) { int c = value / GenerationStepSize; @@ -388,16 +383,16 @@ inline bool IsEntityWalkable(entvars_t *entity, unsigned int flags) inline bool IsWalkableTraceLineClear(Vector &from, Vector &to, unsigned int flags = 0) { TraceResult result; - edict_t *ignore = NULL; + edict_t *pEntIgnore = nullptr; Vector useFrom = from; while (true) { - UTIL_TraceLine(useFrom, to, ignore_monsters, ignore, &result); + UTIL_TraceLine(useFrom, to, ignore_monsters, pEntIgnore, &result); if (result.flFraction != 1.0f && IsEntityWalkable(VARS(result.pHit), flags)) { - ignore = result.pHit; + pEntIgnore = result.pHit; Vector dir = to - from; dir.NormalizeInPlace(); @@ -412,5 +407,3 @@ inline bool IsWalkableTraceLineClear(Vector &from, Vector &to, unsigned int flag return false; } - -#endif // NAV_H diff --git a/regamedll/game_shared/bot/nav_area.cpp b/regamedll/game_shared/bot/nav_area.cpp index 6d83a20f..cc85342b 100644 --- a/regamedll/game_shared/bot/nav_area.cpp +++ b/regamedll/game_shared/bot/nav_area.cpp @@ -40,14 +40,14 @@ NavAreaList TheNavAreaList; // The singleton for accessing the grid CNavAreaGrid TheNavAreaGrid; -CNavArea *CNavArea::m_openList = NULL; +CNavArea *CNavArea::m_openList = nullptr; bool CNavArea::m_isReset = false; float lastDrawTimestamp = 0.0f; NavAreaList goodSizedAreaList; -CNavArea *markedArea = NULL; -CNavArea *lastSelectedArea = NULL; +CNavArea *markedArea = nullptr; +CNavArea *lastSelectedArea = nullptr; NavCornerType markedCorner = NUM_CORNERS; bool isCreatingNavArea = false; @@ -59,7 +59,7 @@ bool isPlacePainting = false; float editTimestamp = 0.0f; -unsigned int BlockedID[ MAX_BLOCKED_AREAS ]; +unsigned int BlockedID[MAX_BLOCKED_AREAS]; int BlockedIDCount = 0; #endif // HOOK_GAMEDLL @@ -122,9 +122,9 @@ HidingSpot::HidingSpot(const Vector *pos, unsigned char flags) void HidingSpot::Save(int fd, unsigned int version) const { - Q_write(fd, &m_id, sizeof(unsigned int)); - Q_write(fd, &m_pos, 3 * sizeof(float)); - Q_write(fd, &m_flags, sizeof(unsigned char)); + _write(fd, &m_id, sizeof(unsigned int)); + _write(fd, &m_pos, 3 * sizeof(float)); + _write(fd, &m_flags, sizeof(unsigned char)); } void HidingSpot::Load(SteamFile *file, unsigned int version) @@ -141,7 +141,7 @@ void HidingSpot::Load(SteamFile *file, unsigned int version) // Given a HidingSpot ID, return the associated HidingSpot HidingSpot *GetHidingSpotByID(unsigned int id) { - for (HidingSpotList::iterator iter = TheHidingSpotList.begin(); iter != TheHidingSpotList.end(); ++iter) + for (HidingSpotList::iterator iter = TheHidingSpotList.begin(); iter != TheHidingSpotList.end(); iter++) { HidingSpot *spot = (*iter); @@ -149,19 +149,19 @@ HidingSpot *GetHidingSpotByID(unsigned int id) return spot; } - return NULL; + return nullptr; } // To keep constructors consistent void CNavArea::Initialize() { m_marker = 0; - m_parent = NULL; + m_parent = nullptr; m_parentHow = GO_NORTH; m_attributeFlags = 0; m_place = 0; - for (int i = 0; i < MAX_AREA_TEAMS; ++i) + for (int i = 0; i < MAX_AREA_TEAMS; i++) { m_danger[i] = 0.0f; m_dangerTimestamp[i] = 0.0f; @@ -173,8 +173,8 @@ void CNavArea::Initialize() // set an ID for splitting and other interactive editing - loads will overwrite this m_id = IMPL(m_nextID)++; - m_prevHash = NULL; - m_nextHash = NULL; + m_prevHash = nullptr; + m_nextHash = nullptr; } // Constructor used during normal runtime @@ -251,10 +251,10 @@ CNavArea::CNavArea(CNavNode *nwNode, class CNavNode *neNode, class CNavNode *seN m_neZ = neNode->GetPosition()->z; m_swZ = swNode->GetPosition()->z; - m_node[ NORTH_WEST ] = nwNode; - m_node[ NORTH_EAST ] = neNode; - m_node[ SOUTH_EAST ] = seNode; - m_node[ SOUTH_WEST ] = swNode; + m_node[NORTH_WEST] = nwNode; + m_node[NORTH_EAST] = neNode; + m_node[SOUTH_EAST] = seNode; + m_node[SOUTH_WEST] = swNode; // mark internal nodes as part of this area AssignNodes(this); @@ -269,7 +269,7 @@ CNavArea::~CNavArea() // tell the other areas we are going away NavAreaList::iterator iter; - for (iter = TheNavAreaList.begin(); iter != TheNavAreaList.end(); ++iter) + for (iter = TheNavAreaList.begin(); iter != TheNavAreaList.end(); iter++) { CNavArea *area = (*iter); @@ -280,9 +280,9 @@ CNavArea::~CNavArea() } // unhook from ladders - for (int i = 0; i < NUM_LADDER_DIRECTIONS; ++i) + for (int i = 0; i < NUM_LADDER_DIRECTIONS; i++) { - for (NavLadderList::iterator liter = m_ladder[i].begin(); liter != m_ladder[i].end(); ++liter) + for (NavLadderList::iterator liter = m_ladder[i].begin(); liter != m_ladder[i].end(); liter++) { CNavLadder *ladder = *liter; ladder->OnDestroyNotify(this); @@ -299,7 +299,7 @@ void CNavArea::OnDestroyNotify(CNavArea *dead) { NavConnect con; con.area = dead; - for (int d = 0; d < NUM_DIRECTIONS; ++d) + for (int d = 0; d < NUM_DIRECTIONS; d++) m_connect[d].remove(con); m_overlapList.remove(dead); @@ -309,7 +309,7 @@ void CNavArea::OnDestroyNotify(CNavArea *dead) void CNavArea::ConnectTo(CNavArea *area, NavDirType dir) { // check if already connected - for (NavConnectList::iterator iter = m_connect[dir].begin(); iter != m_connect[dir].end(); ++iter) + for (NavConnectList::iterator iter = m_connect[dir].begin(); iter != m_connect[dir].end(); iter++) { if ((*iter).area == area) return; @@ -320,7 +320,7 @@ void CNavArea::ConnectTo(CNavArea *area, NavDirType dir) m_connect[dir].push_back(con); //static char *dirName[] = { "NORTH", "EAST", "SOUTH", "WEST" }; - //CONSOLE_ECHO(" Connected area #%d to #%d, %s\n", m_id, area->m_id, dirName[ dir ]); + //CONSOLE_ECHO(" Connected area #%d to #%d, %s\n", m_id, area->m_id, dirName[dir]); } // Disconnect this area from given area @@ -329,7 +329,7 @@ void CNavArea::Disconnect(CNavArea *area) NavConnect connect; connect.area = area; - for (int dir = 0; dirGetPosition(); - m_extent.hi = *m_node[ SOUTH_EAST ]->GetPosition(); + m_extent.lo = *m_node[NORTH_WEST]->GetPosition(); + m_extent.hi = *m_node[SOUTH_EAST]->GetPosition(); m_center.x = (m_extent.lo.x + m_extent.hi.x) / 2.0f; m_center.y = (m_extent.lo.y + m_extent.hi.y) / 2.0f; m_center.z = (m_extent.lo.z + m_extent.hi.z) / 2.0f; - m_neZ = m_node[ NORTH_EAST ]->GetPosition()->z; - m_swZ = m_node[ SOUTH_WEST ]->GetPosition()->z; + m_neZ = m_node[NORTH_EAST]->GetPosition()->z; + m_swZ = m_node[SOUTH_WEST]->GetPosition()->z; // reassign the adjacent area's internal nodes to the final area adjArea->AssignNodes(this); @@ -365,9 +365,9 @@ void CNavArea::MergeAdjacentConnections(CNavArea *adjArea) // merge adjacency links - we gain all the connections that adjArea had NavConnectList::iterator iter; int dir; - for (dir = 0; dirm_connect[ dir ].begin(); iter != adjArea->m_connect[ dir ].end(); ++iter) + for (iter = adjArea->m_connect[dir].begin(); iter != adjArea->m_connect[dir].end(); iter++) { NavConnect connect = (*iter); @@ -377,7 +377,7 @@ void CNavArea::MergeAdjacentConnections(CNavArea *adjArea) } // remove any references from this area to the adjacent area, since it is now part of us - for (dir = 0; dir < NUM_DIRECTIONS; ++dir) + for (dir = 0; dir < NUM_DIRECTIONS; dir++) { NavConnect connect; connect.area = adjArea; @@ -391,18 +391,18 @@ void CNavArea::MergeAdjacentConnections(CNavArea *adjArea) // into the merged area, one for each of the adjacent subsumed smaller ones. // If an area has a connection to the merged area, we must remove all references to adjArea, and add // a single connection to us. - for (NavAreaList::iterator areaIter = TheNavAreaList.begin(); areaIter != TheNavAreaList.end(); ++areaIter) + for (NavAreaList::iterator areaIter = TheNavAreaList.begin(); areaIter != TheNavAreaList.end(); areaIter++) { CNavArea *area = *areaIter; if (area == this || area == adjArea) continue; - for (dir = 0; dir < NUM_DIRECTIONS; ++dir) + for (dir = 0; dir < NUM_DIRECTIONS; dir++) { // check if there are any references to adjArea in this direction bool connected = false; - for (iter = area->m_connect[ dir ].begin(); iter != area->m_connect[ dir ].end(); ++iter) + for (iter = area->m_connect[dir].begin(); iter != area->m_connect[dir].end(); iter++) { NavConnect connect = (*iter); @@ -436,9 +436,8 @@ void CNavArea::MergeAdjacentConnections(CNavArea *adjArea) // NOTE: "internal" nodes do not include the east or south border nodes void CNavArea::AssignNodes(CNavArea *area) { - CNavNode *horizLast = m_node[ NORTH_EAST ]; - - for (CNavNode *vertNode = m_node[ NORTH_WEST ]; vertNode != m_node[ SOUTH_WEST ]; vertNode = vertNode->GetConnectedNode(SOUTH)) + CNavNode *horizLast = m_node[NORTH_EAST]; + for (CNavNode *vertNode = m_node[NORTH_WEST]; vertNode != m_node[SOUTH_WEST]; vertNode = vertNode->GetConnectedNode(SOUTH)) { for (CNavNode *horizNode = vertNode; horizNode != horizLast; horizNode = horizNode->GetConnectedNode(EAST)) { @@ -454,8 +453,8 @@ void CNavArea::AssignNodes(CNavArea *area) // NOTE: This does not update node connections, only areas. bool CNavArea::SplitEdit(bool splitAlongX, float splitEdge, CNavArea **outAlpha, CNavArea **outBeta) { - CNavArea *alpha = NULL; - CNavArea *beta = NULL; + CNavArea *alpha = nullptr; + CNavArea *beta = nullptr; if (splitAlongX) { @@ -568,9 +567,9 @@ bool CNavArea::IsConnected(const CNavArea *area, NavDirType dir) const if (dir == NUM_DIRECTIONS) { // search all directions - for (int d = 0; d < NUM_DIRECTIONS; ++d) + for (int d = 0; d < NUM_DIRECTIONS; d++) { - for (iter = m_connect[ d ].begin(); iter != m_connect[ d ].end(); ++iter) + for (iter = m_connect[d].begin(); iter != m_connect[d].end(); iter++) { if (area == (*iter).area) return true; @@ -579,7 +578,7 @@ bool CNavArea::IsConnected(const CNavArea *area, NavDirType dir) const // check ladder connections NavLadderList::const_iterator liter; - for (liter = m_ladder[ LADDER_UP ].begin(); liter != m_ladder[ LADDER_UP ].end(); ++liter) + for (liter = m_ladder[LADDER_UP].begin(); liter != m_ladder[LADDER_UP].end(); liter++) { CNavLadder *ladder = *liter; @@ -587,7 +586,7 @@ bool CNavArea::IsConnected(const CNavArea *area, NavDirType dir) const return true; } - for (liter = m_ladder[ LADDER_DOWN ].begin(); liter != m_ladder[ LADDER_DOWN ].end(); ++liter) + for (liter = m_ladder[LADDER_DOWN].begin(); liter != m_ladder[LADDER_DOWN].end(); liter++) { CNavLadder *ladder = *liter; @@ -598,7 +597,7 @@ bool CNavArea::IsConnected(const CNavArea *area, NavDirType dir) const else { // check specific direction - for (iter = m_connect[ dir ].begin(); iter != m_connect[ dir ].end(); ++iter) + for (iter = m_connect[dir].begin(); iter != m_connect[dir].end(); iter++) { if (area == (*iter).area) return true; @@ -630,14 +629,13 @@ void CNavArea::FinishSplitEdit(CNavArea *newArea, NavDirType ignoreEdge) newArea->m_swZ = GetZ(newArea->m_extent.lo.x, newArea->m_extent.hi.y); // connect to adjacent areas - for (int d = 0; d < NUM_DIRECTIONS; ++d) + for (int d = 0; d < NUM_DIRECTIONS; d++) { if (d == ignoreEdge) continue; int count = GetAdjacentCount((NavDirType)d); - - for (int a = 0; a < count; ++a) + for (int a = 0; a < count; a++) { CNavArea *adj = GetAdjacentArea((NavDirType)d, a); @@ -677,7 +675,7 @@ void CNavArea::FinishSplitEdit(CNavArea *newArea, NavDirType ignoreEdge) // Create a new area between this area and given area bool CNavArea::SpliceEdit(CNavArea *other) { - CNavArea *newArea = NULL; + CNavArea *newArea = nullptr; Vector nw, ne, se, sw; if (m_extent.lo.x > other->m_extent.hi.x) @@ -833,7 +831,6 @@ bool CNavArea::SpliceEdit(CNavArea *other) TheNavAreaList.push_back(newArea); TheNavAreaGrid.AddNavArea(newArea); - return true; } @@ -938,7 +935,7 @@ void DestroyNavigationMap() delete node; } - IMPL_CLASS(CNavNode, m_list) = NULL; + IMPL_CLASS(CNavNode, m_list) = nullptr; // reset the grid TheNavAreaGrid.Reset(); @@ -948,7 +945,7 @@ void DestroyNavigationMap() void StripNavigationAreas() { - for (NavAreaList::iterator iter = TheNavAreaList.begin(); iter != TheNavAreaList.end(); ++iter) + for (NavAreaList::iterator iter = TheNavAreaList.begin(); iter != TheNavAreaList.end(); iter++) { CNavArea *area = (*iter); area->Strip(); @@ -963,13 +960,13 @@ void CNavArea::Strip() } // Start at given position and find first area in given direction -inline CNavArea *FindFirstAreaInDirection(const Vector *start, NavDirType dir, float range, float beneathLimit, CBaseEntity *traceIgnore = NULL, Vector *closePos = NULL) +inline CNavArea *FindFirstAreaInDirection(const Vector *start, NavDirType dir, float range, float beneathLimit, CBaseEntity *traceIgnore = nullptr, Vector *closePos = nullptr) { - CNavArea *area = NULL; + CNavArea *area = nullptr; Vector pos = *start; int end = int((range / GenerationStepSize) + 0.5f); - for (int i = 1; i <= end; ++i) + for (int i = 1; i <= end; i++) { AddDirectionVector(&pos, dir, GenerationStepSize); @@ -979,14 +976,14 @@ inline CNavArea *FindFirstAreaInDirection(const Vector *start, NavDirType dir, f if (traceIgnore) UTIL_TraceLine(*start, pos, ignore_monsters, ENT(traceIgnore->pev), &result); else - UTIL_TraceLine(*start, pos, ignore_monsters, NULL, &result); + UTIL_TraceLine(*start, pos, ignore_monsters, nullptr, &result); if (result.flFraction != 1.0f) break; area = TheNavAreaGrid.GetNavArea(&pos, beneathLimit); - if (area != NULL) + if (area) { if (closePos) { @@ -1025,13 +1022,13 @@ inline bool testJumpDown(const Vector *fromPos, const Vector *toPos) Vector to(toPos->x, toPos->y, from.z); TraceResult result; - UTIL_TraceLine(from, to, ignore_monsters, NULL, &result); + UTIL_TraceLine(from, to, ignore_monsters, nullptr, &result); if (result.flFraction != 1.0f || result.fStartSolid) return false; from = to; to.z = toPos->z + 2.0f; - UTIL_TraceLine(from, to, ignore_monsters, NULL, &result); + UTIL_TraceLine(from, to, ignore_monsters, nullptr, &result); if (result.flFraction != 1.0f || result.fStartSolid) return false; @@ -1044,12 +1041,12 @@ inline CNavArea *findJumpDownArea(const Vector *fromPos, NavDirType dir) AddDirectionVector(&start, dir, GenerationStepSize / 2.0f); Vector toPos; - CNavArea *downArea = FindFirstAreaInDirection(&start, dir, 4.0f * GenerationStepSize, DeathDrop, NULL, &toPos); + CNavArea *downArea = FindFirstAreaInDirection(&start, dir, 4.0f * GenerationStepSize, DeathDrop, nullptr, &toPos); if (downArea && testJumpDown(fromPos, &toPos)) return downArea; - return NULL; + return nullptr; } // Define connections between adjacent generated areas @@ -1057,7 +1054,7 @@ void ConnectGeneratedAreas() { CONSOLE_ECHO(" Connecting navigation areas...\n"); - for (NavAreaList::iterator iter = TheNavAreaList.begin(); iter != TheNavAreaList.end(); ++iter) + for (NavAreaList::iterator iter = TheNavAreaList.begin(); iter != TheNavAreaList.end(); iter++) { CNavArea *area = (*iter); @@ -1066,35 +1063,35 @@ void ConnectGeneratedAreas() // north edge CNavNode *node; - for (node = area->m_node[ NORTH_WEST ]; node != area->m_node[ NORTH_EAST ]; node = node->GetConnectedNode(EAST)) + for (node = area->m_node[NORTH_WEST]; node != area->m_node[NORTH_EAST]; node = node->GetConnectedNode(EAST)) { CNavNode *adj = node->GetConnectedNode(NORTH); - if (adj != NULL && adj->GetArea() && adj->GetConnectedNode(SOUTH) == node) + if (adj && adj->GetArea() && adj->GetConnectedNode(SOUTH) == node) { area->ConnectTo(adj->GetArea(), NORTH); } else { CNavArea *downArea = findJumpDownArea(node->GetPosition(), NORTH); - if (downArea != NULL && downArea != area) + if (downArea && downArea != area) area->ConnectTo(downArea, NORTH); } } // west edge - for (node = area->m_node[ NORTH_WEST ]; node != area->m_node[ SOUTH_WEST ]; node = node->GetConnectedNode(SOUTH)) + for (node = area->m_node[NORTH_WEST]; node != area->m_node[SOUTH_WEST]; node = node->GetConnectedNode(SOUTH)) { CNavNode *adj = node->GetConnectedNode(WEST); - if (adj != NULL && adj->GetArea() && adj->GetConnectedNode(EAST) == node) + if (adj && adj->GetArea() && adj->GetConnectedNode(EAST) == node) { area->ConnectTo(adj->GetArea(), WEST); } else { CNavArea *downArea = findJumpDownArea(node->GetPosition(), WEST); - if (downArea != NULL && downArea != area) + if (downArea && downArea != area) area->ConnectTo(downArea, WEST); } } @@ -1102,47 +1099,47 @@ void ConnectGeneratedAreas() // south edge - this edge's nodes are actually part of adjacent areas // move one node north, and scan west to east // TODO: This allows one-node-wide areas - do we want this? - node = area->m_node[ SOUTH_WEST ]; + node = area->m_node[SOUTH_WEST]; node = node->GetConnectedNode(NORTH); - if (node != NULL) + if (node) { - CNavNode *end = area->m_node[ SOUTH_EAST ]->GetConnectedNode(NORTH); + CNavNode *end = area->m_node[SOUTH_EAST]->GetConnectedNode(NORTH); // TODO: Figure out why cs_backalley gets a NULL node in here... - for (; node != NULL && node != end; node = node->GetConnectedNode(EAST)) + for (; node && node != end; node = node->GetConnectedNode(EAST)) { CNavNode *adj = node->GetConnectedNode(SOUTH); - if (adj != NULL && adj->GetArea() && adj->GetConnectedNode(NORTH) == node) + if (adj && adj->GetArea() && adj->GetConnectedNode(NORTH) == node) { area->ConnectTo(adj->GetArea(), SOUTH); } else { CNavArea *downArea = findJumpDownArea(node->GetPosition(), SOUTH); - if (downArea != NULL && downArea != area) + if (downArea && downArea != area) area->ConnectTo(downArea, SOUTH); } } } // east edge - this edge's nodes are actually part of adjacent areas - node = area->m_node[ NORTH_EAST ]; + node = area->m_node[NORTH_EAST]; node = node->GetConnectedNode(WEST); - if (node != NULL) + if (node) { - CNavNode *end = area->m_node[ SOUTH_EAST ]->GetConnectedNode(WEST); - for (; node != NULL && node != end; node = node->GetConnectedNode(SOUTH)) + CNavNode *end = area->m_node[SOUTH_EAST]->GetConnectedNode(WEST); + for (; node && node != end; node = node->GetConnectedNode(SOUTH)) { CNavNode *adj = node->GetConnectedNode(EAST); - if (adj != NULL && adj->GetArea() && adj->GetConnectedNode(WEST) == node) + if (adj && adj->GetArea() && adj->GetConnectedNode(WEST) == node) { area->ConnectTo(adj->GetArea(), EAST); } else { CNavArea *downArea = findJumpDownArea(node->GetPosition(), EAST); - if (downArea != NULL && downArea != area) + if (downArea && downArea != area) area->ConnectTo(downArea, EAST); } } @@ -1162,24 +1159,24 @@ void MergeGeneratedAreas() { merged = false; - for (NavAreaList::iterator iter = TheNavAreaList.begin(); iter != TheNavAreaList.end(); ++iter) + for (NavAreaList::iterator iter = TheNavAreaList.begin(); iter != TheNavAreaList.end(); iter++) { CNavArea *area = (*iter); // north edge NavConnectList::iterator citer; - for (citer = area->m_connect[ NORTH ].begin(); citer != area->m_connect[ NORTH ].end(); ++citer) + for (citer = area->m_connect[NORTH].begin(); citer != area->m_connect[NORTH].end(); citer++) { CNavArea *adjArea = (*citer).area; - if (area->m_node[ NORTH_WEST ] == adjArea->m_node[ SOUTH_WEST ] && - area->m_node[ NORTH_EAST ] == adjArea->m_node[ SOUTH_EAST ] && + if (area->m_node[NORTH_WEST] == adjArea->m_node[SOUTH_WEST] && + area->m_node[NORTH_EAST] == adjArea->m_node[SOUTH_EAST] && area->GetAttributes() == adjArea->GetAttributes() && area->IsCoplanar(adjArea)) { // merge vertical - area->m_node[ NORTH_WEST ] = adjArea->m_node[ NORTH_WEST ]; - area->m_node[ NORTH_EAST ] = adjArea->m_node[ NORTH_EAST ]; + area->m_node[NORTH_WEST] = adjArea->m_node[NORTH_WEST]; + area->m_node[NORTH_EAST] = adjArea->m_node[NORTH_EAST]; merged = true; //CONSOLE_ECHO(" Merged (north) areas #%d and #%d\n", area->m_id, adjArea->m_id); @@ -1195,18 +1192,18 @@ void MergeGeneratedAreas() break; // south edge - for (citer = area->m_connect[ SOUTH ].begin(); citer != area->m_connect[ SOUTH ].end(); ++citer) + for (citer = area->m_connect[SOUTH].begin(); citer != area->m_connect[SOUTH].end(); citer++) { CNavArea *adjArea = (*citer).area; - if (adjArea->m_node[ NORTH_WEST ] == area->m_node[ SOUTH_WEST ] && - adjArea->m_node[ NORTH_EAST ] == area->m_node[ SOUTH_EAST ] && + if (adjArea->m_node[NORTH_WEST] == area->m_node[SOUTH_WEST] && + adjArea->m_node[NORTH_EAST] == area->m_node[SOUTH_EAST] && area->GetAttributes() == adjArea->GetAttributes() && area->IsCoplanar(adjArea)) { // merge vertical - area->m_node[ SOUTH_WEST ] = adjArea->m_node[ SOUTH_WEST ]; - area->m_node[ SOUTH_EAST ] = adjArea->m_node[ SOUTH_EAST ]; + area->m_node[SOUTH_WEST] = adjArea->m_node[SOUTH_WEST]; + area->m_node[SOUTH_EAST] = adjArea->m_node[SOUTH_EAST]; merged = true; //CONSOLE_ECHO(" Merged (south) areas #%d and #%d\n", area->m_id, adjArea->m_id); @@ -1222,20 +1219,19 @@ void MergeGeneratedAreas() if (merged) break; - // west edge - for (citer = area->m_connect[ WEST ].begin(); citer != area->m_connect[ WEST ].end(); ++citer) + for (citer = area->m_connect[WEST].begin(); citer != area->m_connect[WEST].end(); citer++) { CNavArea *adjArea = (*citer).area; - if (area->m_node[ NORTH_WEST ] == adjArea->m_node[ NORTH_EAST ] && - area->m_node[ SOUTH_WEST ] == adjArea->m_node[ SOUTH_EAST ] && + if (area->m_node[NORTH_WEST] == adjArea->m_node[NORTH_EAST] && + area->m_node[SOUTH_WEST] == adjArea->m_node[SOUTH_EAST] && area->GetAttributes() == adjArea->GetAttributes() && area->IsCoplanar(adjArea)) { // merge horizontal - area->m_node[ NORTH_WEST ] = adjArea->m_node[ NORTH_WEST ]; - area->m_node[ SOUTH_WEST ] = adjArea->m_node[ SOUTH_WEST ]; + area->m_node[NORTH_WEST] = adjArea->m_node[NORTH_WEST]; + area->m_node[SOUTH_WEST] = adjArea->m_node[SOUTH_WEST]; merged = true; //CONSOLE_ECHO(" Merged (west) areas #%d and #%d\n", area->m_id, adjArea->m_id); @@ -1252,18 +1248,18 @@ void MergeGeneratedAreas() break; // east edge - for (citer = area->m_connect[ EAST ].begin(); citer != area->m_connect[ EAST ].end(); ++citer) + for (citer = area->m_connect[EAST].begin(); citer != area->m_connect[EAST].end(); citer++) { CNavArea *adjArea = (*citer).area; - if (adjArea->m_node[ NORTH_WEST ] == area->m_node[ NORTH_EAST ] && - adjArea->m_node[ SOUTH_WEST ] == area->m_node[ SOUTH_EAST ] && + if (adjArea->m_node[NORTH_WEST] == area->m_node[NORTH_EAST] && + adjArea->m_node[SOUTH_WEST] == area->m_node[SOUTH_EAST] && area->GetAttributes() == adjArea->GetAttributes() && area->IsCoplanar(adjArea)) { // merge horizontal - area->m_node[ NORTH_EAST ] = adjArea->m_node[ NORTH_EAST ]; - area->m_node[ SOUTH_EAST ] = adjArea->m_node[ SOUTH_EAST ]; + area->m_node[NORTH_EAST] = adjArea->m_node[NORTH_EAST]; + area->m_node[SOUTH_EAST] = adjArea->m_node[SOUTH_EAST]; merged = true; //CONSOLE_ECHO(" Merged (east) areas #%d and #%d\n", area->m_id, adjArea->m_id); @@ -1355,12 +1351,11 @@ void SplitY(CNavArea *area) // Split any long, thin, areas into roughly square chunks. void SquareUpAreas() { - NavAreaList::iterator iter = TheNavAreaList.begin(); - + auto iter = TheNavAreaList.begin(); while (iter != TheNavAreaList.end()) { CNavArea *area = (*iter); - ++iter; + iter++; if (!IsAreaRoughlySquare(area)) { @@ -1389,11 +1384,11 @@ bool TestArea(CNavNode *node, int width, int height) CNavNode *vertNode, *horizNode; vertNode = node; - for (int y = 0; y < height; ++y) + for (int y = 0; y < height; y++) { horizNode = vertNode; - for (int x = 0; x < width; ++x) + for (int x = 0; x < width; x++) { // all nodes must have the same attributes if (horizNode->GetAttributes() != node->GetAttributes()) @@ -1406,7 +1401,7 @@ bool TestArea(CNavNode *node, int width, int height) return false; horizNode = horizNode->GetConnectedNode(EAST); - if (horizNode == NULL) + if (!horizNode) return false; // nodes must lie on/near the plane @@ -1419,7 +1414,7 @@ bool TestArea(CNavNode *node, int width, int height) } vertNode = vertNode->GetConnectedNode(SOUTH); - if (vertNode == NULL) + if (!vertNode) return false; // nodes must lie on/near the plane @@ -1436,10 +1431,10 @@ bool TestArea(CNavNode *node, int width, int height) { horizNode = vertNode; - for (int x = 0; x < width; ++x) + for (int x = 0; x < width; x++) { horizNode = horizNode->GetConnectedNode(EAST); - if (horizNode == NULL) + if (!horizNode) return false; // nodes must lie on/near the plane @@ -1460,23 +1455,22 @@ int BuildArea(CNavNode *node, int width, int height) //CONSOLE_ECHO("BuildArea(#%d, %d, %d)\n", node->GetID(), width, height); CNavNode *nwNode = node; - CNavNode *neNode = NULL; - CNavNode *swNode = NULL; - CNavNode *seNode = NULL; + CNavNode *neNode = nullptr; + CNavNode *swNode = nullptr; + CNavNode *seNode = nullptr; CNavNode *vertNode = node; CNavNode *horizNode; int coveredNodes = 0; - - for (int y = 0; y < height; ++y) + for (int y = 0; y < height; y++) { horizNode = vertNode; - for (int x = 0; x < width; ++x) + for (int x = 0; x < width; x++) { horizNode->Cover(); - ++coveredNodes; + coveredNodes++; horizNode = horizNode->GetConnectedNode(EAST); } @@ -1490,12 +1484,12 @@ int BuildArea(CNavNode *node, int width, int height) swNode = vertNode; horizNode = vertNode; - for (int x = 0; x < width; ++x) + for (int x = 0; x < width; x++) { horizNode = horizNode->GetConnectedNode(EAST); } - seNode = horizNode; + seNode = horizNode; if (!nwNode || !neNode || !seNode || !swNode) { CONSOLE_ECHO("ERROR: BuildArea - NULL node. (%p)(%p)(%p)(%p)\n", nwNode, neNode, seNode, swNode); @@ -1509,7 +1503,6 @@ int BuildArea(CNavNode *node, int width, int height) area->SetAttributes(node->GetAttributes()); //Q_fprintf(fp, "f %d %d %d %d\n", nwNode->m_id, neNode->m_id, seNode->m_id, swNode->m_id); - return coveredNodes; } @@ -1520,23 +1513,23 @@ void BuildLadders() DestroyLadders(); TraceResult result; - CBaseEntity *entity = UTIL_FindEntityByClassname(NULL, "func_ladder"); - while (entity && !FNullEnt(entity->edict())) + CBaseEntity *pEntity = UTIL_FindEntityByClassname(nullptr, "func_ladder"); + while (pEntity && !FNullEnt(pEntity->edict())) { CNavLadder *ladder = new CNavLadder; // compute top & bottom of ladder - ladder->m_top.x = (entity->pev->absmin.x + entity->pev->absmax.x) / 2.0f; - ladder->m_top.y = (entity->pev->absmin.y + entity->pev->absmax.y) / 2.0f; - ladder->m_top.z = entity->pev->absmax.z; + ladder->m_top.x = (pEntity->pev->absmin.x + pEntity->pev->absmax.x) / 2.0f; + ladder->m_top.y = (pEntity->pev->absmin.y + pEntity->pev->absmax.y) / 2.0f; + ladder->m_top.z = pEntity->pev->absmax.z; ladder->m_bottom.x = ladder->m_top.x; ladder->m_bottom.y = ladder->m_top.y; - ladder->m_bottom.z = entity->pev->absmin.z; + ladder->m_bottom.z = pEntity->pev->absmin.z; // determine facing - assumes "normal" runged ladder - float xSize = entity->pev->absmax.x - entity->pev->absmin.x; - float ySize = entity->pev->absmax.y - entity->pev->absmin.y; + float xSize = pEntity->pev->absmax.x - pEntity->pev->absmin.x; + float ySize = pEntity->pev->absmax.y - pEntity->pev->absmin.y; if (xSize > ySize) { @@ -1545,7 +1538,7 @@ void BuildLadders() Vector from = ladder->m_bottom + Vector(0.0f, GenerationStepSize, GenerationStepSize); Vector to = ladder->m_top + Vector(0.0f, GenerationStepSize, -GenerationStepSize); - UTIL_TraceLine(from, to, ignore_monsters, ENT(entity->pev), &result); + UTIL_TraceLine(from, to, ignore_monsters, ENT(pEntity->pev), &result); if (result.flFraction != 1.0f || result.fStartSolid) ladder->m_dir = NORTH; @@ -1558,7 +1551,7 @@ void BuildLadders() Vector from = ladder->m_bottom + Vector(GenerationStepSize, 0.0f, GenerationStepSize); Vector to = ladder->m_top + Vector(GenerationStepSize, 0.0f, -GenerationStepSize); - UTIL_TraceLine(from, to, ignore_monsters, ENT(entity->pev), &result); + UTIL_TraceLine(from, to, ignore_monsters, ENT(pEntity->pev), &result); if (result.flFraction != 1.0f || result.fStartSolid) ladder->m_dir = WEST; @@ -1584,7 +1577,7 @@ void BuildLadders() out = on; AddDirectionVector(&out, ladder->m_dir, minLadderClearance); - UTIL_TraceLine(on, out, ignore_monsters, ENT(entity->pev), &result); + UTIL_TraceLine(on, out, ignore_monsters, ENT(pEntity->pev), &result); if (result.flFraction == 1.0f && !result.fStartSolid) { @@ -1601,7 +1594,7 @@ void BuildLadders() out = on; AddDirectionVector(&out, ladder->m_dir, minLadderClearance); - UTIL_TraceLine(on, out, ignore_monsters, ENT(entity->pev), &result); + UTIL_TraceLine(on, out, ignore_monsters, ENT(pEntity->pev), &result); if (result.flFraction == 1.0f && !result.fStartSolid) { @@ -1614,7 +1607,7 @@ void BuildLadders() ladder->m_length = (ladder->m_top - ladder->m_bottom).Length(); DirectionToVector2D(ladder->m_dir, &ladder->m_dirVector); - ladder->m_entity = entity; + ladder->m_entity = pEntity; const float nearLadderRange = 75.0f; // Find naviagtion area at bottom of ladder @@ -1640,24 +1633,24 @@ void BuildLadders() AddDirectionVector(¢er, ladder->m_dir, HalfHumanWidth); // find "ahead" area - ladder->m_topForwardArea = FindFirstAreaInDirection(¢er, OppositeDirection(ladder->m_dir), nearLadderRange, 120.0f, entity); + ladder->m_topForwardArea = FindFirstAreaInDirection(¢er, OppositeDirection(ladder->m_dir), nearLadderRange, 120.0f, pEntity); if (ladder->m_topForwardArea == ladder->m_bottomArea) - ladder->m_topForwardArea = NULL; + ladder->m_topForwardArea = nullptr; // find "left" area - ladder->m_topLeftArea = FindFirstAreaInDirection(¢er, DirectionLeft(ladder->m_dir), nearLadderRange, 120.0f, entity); + ladder->m_topLeftArea = FindFirstAreaInDirection(¢er, DirectionLeft(ladder->m_dir), nearLadderRange, 120.0f, pEntity); if (ladder->m_topLeftArea == ladder->m_bottomArea) - ladder->m_topLeftArea = NULL; + ladder->m_topLeftArea = nullptr; // find "right" area - ladder->m_topRightArea = FindFirstAreaInDirection(¢er, DirectionRight(ladder->m_dir), nearLadderRange, 120.0f, entity); + ladder->m_topRightArea = FindFirstAreaInDirection(¢er, DirectionRight(ladder->m_dir), nearLadderRange, 120.0f, pEntity); if (ladder->m_topRightArea == ladder->m_bottomArea) - ladder->m_topRightArea = NULL; + ladder->m_topRightArea = nullptr; // find "behind" area - must look farther, since ladder is against the wall away from this area - ladder->m_topBehindArea = FindFirstAreaInDirection(¢er, ladder->m_dir, 2.0f * nearLadderRange, 120.0f, entity); + ladder->m_topBehindArea = FindFirstAreaInDirection(¢er, ladder->m_dir, 2.0f * nearLadderRange, 120.0f, pEntity); if (ladder->m_topBehindArea == ladder->m_bottomArea) - ladder->m_topBehindArea = NULL; + ladder->m_topBehindArea = nullptr; // can't include behind area, since it is not used when going up a ladder if (!ladder->m_topForwardArea && !ladder->m_topLeftArea && !ladder->m_topRightArea) @@ -1680,16 +1673,16 @@ void BuildLadders() float topZ = -99999.9f; bool topAdjusted = false; - CNavArea *topAreaList[4]; - topAreaList[0] = ladder->m_topForwardArea; - topAreaList[1] = ladder->m_topLeftArea; - topAreaList[2] = ladder->m_topRightArea; - topAreaList[3] = ladder->m_topBehindArea; + CNavArea *topAreaList[NUM_CORNERS]; + topAreaList[NORTH_WEST] = ladder->m_topForwardArea; + topAreaList[NORTH_EAST] = ladder->m_topLeftArea; + topAreaList[SOUTH_EAST] = ladder->m_topRightArea; + topAreaList[SOUTH_WEST] = ladder->m_topBehindArea; - for (int a = 0; a < 4; ++a) + for (int a = 0; a < NUM_CORNERS; a++) { CNavArea *topArea = topAreaList[a]; - if (topArea == NULL) + if (!topArea) continue; Vector close; @@ -1717,7 +1710,7 @@ void BuildLadders() // add ladder to global list TheNavLadderList.push_back(ladder); - entity = UTIL_FindEntityByClassname(entity, "func_ladder"); + pEntity = UTIL_FindEntityByClassname(pEntity, "func_ladder"); } } @@ -1725,7 +1718,7 @@ void BuildLadders() // This currently relies on jump areas having extreme slope. void MarkJumpAreas() { - for (NavAreaList::iterator iter = TheNavAreaList.begin(); iter != TheNavAreaList.end(); ++iter) + for (NavAreaList::iterator iter = TheNavAreaList.begin(); iter != TheNavAreaList.end(); iter++) { CNavArea *area = (*iter); Vector u, v; @@ -1763,7 +1756,7 @@ void GenerateNavigationAreaMesh() while (uncoveredNodes > 0) { - for (CNavNode *node = CNavNode::GetFirst(); node != NULL; node = node->GetNext()) + for (CNavNode *node = CNavNode::GetFirst(); node; node = node->GetNext()) { if (node->IsCovered()) continue; @@ -1782,9 +1775,9 @@ void GenerateNavigationAreaMesh() } if (tryWidth >= tryHeight) - --tryWidth; + tryWidth--; else - --tryHeight; + tryHeight--; if (tryWidth <= 0 || tryHeight <= 0) break; @@ -1797,10 +1790,8 @@ void GenerateNavigationAreaMesh() extent.hi.y = -9999999999.9f; // compute total extent - NavAreaList::iterator iter; - for (iter = TheNavAreaList.begin(); iter != TheNavAreaList.end(); ++iter) + for (auto area : TheNavAreaList) { - CNavArea *area = (*iter); const Extent *areaExtent = area->GetExtent(); if (areaExtent->lo.x < extent.lo.x) @@ -1816,8 +1807,10 @@ void GenerateNavigationAreaMesh() // add the areas to the grid TheNavAreaGrid.Initialize(extent.lo.x, extent.hi.x, extent.lo.y, extent.hi.y); - for (iter = TheNavAreaList.begin(); iter != TheNavAreaList.end(); ++iter) - TheNavAreaGrid.AddNavArea(*iter); + for (auto area : TheNavAreaList) + { + TheNavAreaGrid.AddNavArea(area); + } ConnectGeneratedAreas(); MergeGeneratedAreas(); @@ -1877,7 +1870,7 @@ bool CNavArea::Contains(const Vector *pos) const if (ourZ > pos->z) return false; - for (NavAreaList::const_iterator iter = m_overlapList.begin(); iter != m_overlapList.end(); ++iter) + for (NavAreaList::const_iterator iter = m_overlapList.begin(); iter != m_overlapList.end(); iter++) { const CNavArea *area = (*iter); @@ -2121,20 +2114,20 @@ float CNavArea::GetDistanceSquaredToPoint(const Vector *pos) const CNavArea *CNavArea::GetRandomAdjacentArea(NavDirType dir) const { - int count = m_connect[ dir ].size(); + int count = m_connect[dir].size(); int which = RANDOM_LONG(0, count - 1); int i = 0; NavConnectList::const_iterator iter; - for (iter = m_connect[ dir ].begin(); iter != m_connect[ dir ].end(); ++iter) + for (iter = m_connect[dir].begin(); iter != m_connect[dir].end(); iter++) { if (i == which) return (*iter).area; - ++i; + i++; } - return NULL; + return nullptr; } // Compute "portal" between to adjacent areas. @@ -2269,7 +2262,7 @@ void CNavArea::ComputeClosestPointInPortal(const CNavArea *to, NavDirType dir, c // Return true if there are no bi-directional links on the given side bool CNavArea::IsEdge(NavDirType dir) const { - for (NavConnectList::const_iterator it = m_connect[ dir ].begin(); it != m_connect[ dir ].end(); ++it) + for (NavConnectList::const_iterator it = m_connect[dir].begin(); it != m_connect[dir].end(); it++) { const NavConnect connect = (*it); @@ -2437,16 +2430,16 @@ void CNavArea::AddToOpenList() m_openMarker = IMPL(m_masterMarker); // if list is empty, add and return - if (IMPL(m_openList) == NULL) + if (!IMPL(m_openList)) { IMPL(m_openList) = this; - this->m_prevOpen = NULL; - this->m_nextOpen = NULL; + this->m_prevOpen = nullptr; + this->m_nextOpen = nullptr; return; } // insert self in ascending cost order - CNavArea *area, *last = NULL; + CNavArea *area, *last = nullptr; for (area = IMPL(m_openList); area; area = area->m_nextOpen) { if (this->GetTotalCost() < area->GetTotalCost()) @@ -2473,7 +2466,7 @@ void CNavArea::AddToOpenList() last->m_nextOpen = this; this->m_prevOpen = last; - this->m_nextOpen = NULL; + this->m_nextOpen = nullptr; } } @@ -2495,12 +2488,12 @@ void CNavArea::UpdateOnOpenList() other->m_prevOpen = this; other->m_nextOpen = after; - if (before != NULL) + if (before) before->m_nextOpen = this; else IMPL(m_openList) = this; - if (after != NULL) + if (after) after->m_prevOpen = other; } } @@ -2523,7 +2516,7 @@ void CNavArea::RemoveFromOpenList() void CNavArea::ClearSearchLists() { CNavArea::MakeNewMarker(); - IMPL(m_openList) = NULL; + IMPL(m_openList) = nullptr; } // Return the coordinates of the area's corner. @@ -2553,7 +2546,7 @@ const Vector *CNavArea::GetCorner(NavCornerType corner) const return &m_extent.hi; } - return NULL; + return nullptr; } // Returns true if an existing hiding spot is too close to given position @@ -2561,7 +2554,7 @@ bool CNavArea::IsHidingSpotCollision(const Vector *pos) const { const float collisionRange = 30.0f; - for (HidingSpotList::const_iterator iter = m_hidingSpotList.begin(); iter != m_hidingSpotList.end(); ++iter) + for (HidingSpotList::const_iterator iter = m_hidingSpotList.begin(); iter != m_hidingSpotList.end(); iter++) { const HidingSpot *spot = (*iter); @@ -2584,7 +2577,7 @@ bool IsHidingSpotInCover(const Vector *spot) // if we are crouched underneath something, that counts as good cover to = from + Vector(0, 0, 20.0f); - UTIL_TraceLine(from, to, ignore_monsters, NULL, &result); + UTIL_TraceLine(from, to, ignore_monsters, nullptr, &result); if (result.flFraction != 1.0f) return true; @@ -2595,11 +2588,11 @@ bool IsHidingSpotInCover(const Vector *spot) { to = from + Vector(coverRange * Q_cos(angle), coverRange * Q_sin(angle), HalfHumanHeight); - UTIL_TraceLine(from, to, ignore_monsters, NULL, &result); + UTIL_TraceLine(from, to, ignore_monsters, nullptr, &result); // if traceline hit something, it hit "cover" if (result.flFraction != 1.0f) - ++coverCount; + coverCount++; } // if more than half of the circle has no cover, the spot is not "in cover" @@ -2623,23 +2616,20 @@ void CNavArea::ComputeHidingSpots() return; int cornerCount[NUM_CORNERS]; - for (int i = 0; i < NUM_CORNERS; ++i) + for (int i = 0; i < NUM_CORNERS; i++) cornerCount[i] = 0; const float cornerSize = 20.0f; // for each direction, find extents of adjacent areas along the wall - for (int d = 0; d < NUM_DIRECTIONS; ++d) + for (int d = 0; d < NUM_DIRECTIONS; d++) { extent.lo = 999999.9f; extent.hi = -999999.9f; bool isHoriz = (d == NORTH || d == SOUTH) ? true : false; - - for (NavConnectList::iterator iter = m_connect[d].begin(); iter != m_connect[d].end(); ++iter) + for (auto &connect : m_connect[d]) { - NavConnect connect = (*iter); - // if connection is only one-way, it's a "jump down" connection (ie: a discontinuity that may mean cover) // ignore it if (connect.area->IsConnected(this, OppositeDirection(static_cast(d))) == false) @@ -2671,34 +2661,34 @@ void CNavArea::ComputeHidingSpots() { case NORTH: if (extent.lo - m_extent.lo.x >= cornerSize) - ++cornerCount[ NORTH_WEST ]; + cornerCount[NORTH_WEST]++; if (m_extent.hi.x - extent.hi >= cornerSize) - ++cornerCount[ NORTH_EAST ]; + cornerCount[NORTH_EAST]++; break; case SOUTH: if (extent.lo - m_extent.lo.x >= cornerSize) - ++cornerCount[ SOUTH_WEST ]; + cornerCount[SOUTH_WEST]++; if (m_extent.hi.x - extent.hi >= cornerSize) - ++cornerCount[ SOUTH_EAST ]; + cornerCount[SOUTH_EAST]++; break; case EAST: if (extent.lo - m_extent.lo.y >= cornerSize) - ++cornerCount[ NORTH_EAST ]; + cornerCount[NORTH_EAST]++; if (m_extent.hi.y - extent.hi >= cornerSize) - ++cornerCount[ SOUTH_EAST ]; + cornerCount[SOUTH_EAST]++; break; case WEST: if (extent.lo - m_extent.lo.y >= cornerSize) - ++cornerCount[ NORTH_WEST ]; + cornerCount[NORTH_WEST]++; if (m_extent.hi.y - extent.hi >= cornerSize) - ++cornerCount[ SOUTH_WEST ]; + cornerCount[SOUTH_WEST]++; break; } } @@ -2706,25 +2696,25 @@ void CNavArea::ComputeHidingSpots() // if a corner count is 2, then it really is a corner (walls on both sides) float offset = 12.5f; - if (cornerCount[ NORTH_WEST ] == 2) + if (cornerCount[NORTH_WEST] == 2) { Vector pos = *GetCorner(NORTH_WEST) + Vector(offset, offset, 0.0f); m_hidingSpotList.push_back(new HidingSpot(&pos, (IsHidingSpotInCover(&pos)) ? HidingSpot::IN_COVER : 0)); } - if (cornerCount[ NORTH_EAST ] == 2) + if (cornerCount[NORTH_EAST] == 2) { Vector pos = *GetCorner(NORTH_EAST) + Vector(-offset, offset, 0.0f); if (!IsHidingSpotCollision(&pos)) m_hidingSpotList.push_back(new HidingSpot(&pos, (IsHidingSpotInCover(&pos)) ? HidingSpot::IN_COVER : 0)); } - if (cornerCount[ SOUTH_WEST ] == 2) + if (cornerCount[SOUTH_WEST] == 2) { Vector pos = *GetCorner(SOUTH_WEST) + Vector(offset, -offset, 0.0f); if (!IsHidingSpotCollision(&pos)) m_hidingSpotList.push_back(new HidingSpot(&pos, (IsHidingSpotInCover(&pos)) ? HidingSpot::IN_COVER : 0)); } - if (cornerCount[ SOUTH_EAST ] == 2) + if (cornerCount[SOUTH_EAST] == 2) { Vector pos = *GetCorner(SOUTH_EAST) + Vector(-offset, -offset, 0.0f); if (!IsHidingSpotCollision(&pos)) @@ -2745,7 +2735,7 @@ void ClassifySniperSpot(HidingSpot *spot) const float minSniperRangeSq = 1000.0f * 1000.0f; bool found = false; - for (NavAreaList::iterator iter = TheNavAreaList.begin(); iter != TheNavAreaList.end(); ++iter) + for (NavAreaList::iterator iter = TheNavAreaList.begin(); iter != TheNavAreaList.end(); iter++) { CNavArea *area = (*iter); @@ -2759,7 +2749,7 @@ void ClassifySniperSpot(HidingSpot *spot) walkable.z = area->GetZ(&walkable) + HalfHumanHeight; // check line of sight - UTIL_TraceLine(eye, walkable, ignore_monsters, ignore_glass, NULL, &result); + UTIL_TraceLine(eye, walkable, ignore_monsters, ignore_glass, nullptr, &result); if (result.flFraction == 1.0f && !result.fStartSolid) { @@ -2821,7 +2811,7 @@ void CNavArea::ComputeSniperSpots() if (cv_bot_quicksave.value > 0.0f) return; - for (HidingSpotList::iterator iter = m_hidingSpotList.begin(); iter != m_hidingSpotList.end(); ++iter) + for (HidingSpotList::iterator iter = m_hidingSpotList.begin(); iter != m_hidingSpotList.end(); iter++) { HidingSpot *spot = (*iter); ClassifySniperSpot(spot); @@ -2831,11 +2821,11 @@ void CNavArea::ComputeSniperSpots() // Given the areas we are moving between, return the spots we will encounter SpotEncounter *CNavArea::GetSpotEncounter(const CNavArea *from, const CNavArea *to) { - if (from != NULL && to != NULL) + if (from && to) { SpotEncounter *e; - for (SpotEncounterList::iterator iter = m_spotEncounterList.begin(); iter != m_spotEncounterList.end(); ++iter) + for (SpotEncounterList::iterator iter = m_spotEncounterList.begin(); iter != m_spotEncounterList.end(); iter++) { e = &(*iter); @@ -2844,7 +2834,7 @@ SpotEncounter *CNavArea::GetSpotEncounter(const CNavArea *from, const CNavArea * } } - return NULL; + return nullptr; } // Add spot encounter data when moving from area to area @@ -2896,7 +2886,7 @@ void CNavArea::AddSpotEncounters(const class CNavArea *from, NavDirType fromDir, eye = e.path.from + along * dir; // check each hiding spot for visibility - for (HidingSpotList::iterator iter = TheHidingSpotList.begin(); iter != TheHidingSpotList.end(); ++iter) + for (HidingSpotList::iterator iter = TheHidingSpotList.begin(); iter != TheHidingSpotList.end(); iter++) { spot = (*iter); @@ -2918,7 +2908,7 @@ void CNavArea::AddSpotEncounters(const class CNavArea *from, NavDirType fromDir, continue; // check if we have LOS - UTIL_TraceLine(eye, Vector(spotPos->x, spotPos->y, spotPos->z + HalfHumanHeight), ignore_monsters, ignore_glass, NULL, &result); + UTIL_TraceLine(eye, Vector(spotPos->x, spotPos->y, spotPos->z + HalfHumanHeight), ignore_monsters, ignore_glass, nullptr, &result); if (result.flFraction != 1.0f) continue; @@ -2957,16 +2947,16 @@ void CNavArea::ComputeSpotEncounters() return; // for each adjacent area - for (int fromDir = 0; fromDir < NUM_DIRECTIONS; ++fromDir) + for (int fromDir = 0; fromDir < NUM_DIRECTIONS; fromDir++) { - for (NavConnectList::iterator fromIter = m_connect[ fromDir ].begin(); fromIter != m_connect[ fromDir ].end(); ++fromIter) + for (NavConnectList::iterator fromIter = m_connect[fromDir].begin(); fromIter != m_connect[fromDir].end(); fromIter++) { NavConnect *fromCon = &(*fromIter); // compute encounter data for path to each adjacent area - for (int toDir = 0; toDir < NUM_DIRECTIONS; ++toDir) + for (int toDir = 0; toDir < NUM_DIRECTIONS; toDir++) { - for (NavConnectList::iterator toIter = m_connect[ toDir ].begin(); toIter != m_connect[ toDir ].end(); ++toIter) + for (NavConnectList::iterator toIter = m_connect[toDir].begin(); toIter != m_connect[toDir].end(); toIter++) { NavConnect *toCon = &(*toIter); @@ -2987,7 +2977,7 @@ void CNavArea::DecayDanger() // one kill == 1.0, which we will forget about in two minutes const float decayRate = 1.0f / 120.0f; - for (int i = 0; i < MAX_AREA_TEAMS; ++i) + for (int i = 0; i < MAX_AREA_TEAMS; i++) { float deltaT = gpGlobals->time - m_dangerTimestamp[i]; float decayAmount = decayRate * deltaT; @@ -3007,21 +2997,21 @@ void CNavArea::IncreaseDanger(int teamID, float amount) // before we add the new value, decay what's there DecayDanger(); - m_danger[ teamID ] += amount; - m_dangerTimestamp[ teamID ] = gpGlobals->time; + m_danger[teamID] += amount; + m_dangerTimestamp[teamID] = gpGlobals->time; } // Return the danger of this area (decays over time) float CNavArea::GetDanger(int teamID) { DecayDanger(); - return m_danger[ teamID ]; + return m_danger[teamID]; } // Increase the danger of nav areas containing and near the given position void IncreaseDangerNearby(int teamID, float amount, class CNavArea *startArea, const Vector *pos, float maxRadius) { - if (startArea == NULL) + if (!startArea) return; CNavArea::MakeNewMarker(); @@ -3038,10 +3028,10 @@ void IncreaseDangerNearby(int teamID, float amount, class CNavArea *startArea, c CNavArea *area = CNavArea::PopOpenList(); // area has no hiding spots, explore adjacent areas - for (int dir = 0; dir < NUM_DIRECTIONS; ++dir) + for (int dir = 0; dir < NUM_DIRECTIONS; dir++) { int count = area->GetAdjacentCount((NavDirType)dir); - for (int i = 0; i < count; ++i) + for (int i = 0; i < count; i++) { CNavArea *adjArea = area->GetAdjacentArea((NavDirType)dir, i); @@ -3065,7 +3055,7 @@ void IncreaseDangerNearby(int teamID, float amount, class CNavArea *startArea, c // Show danger levels for debugging void DrawDanger() { - for (NavAreaList::iterator iter = TheNavAreaList.begin(); iter != TheNavAreaList.end(); ++iter) + for (NavAreaList::iterator iter = TheNavAreaList.begin(); iter != TheNavAreaList.end(); iter++) { CNavArea *area = (*iter); @@ -3104,15 +3094,15 @@ bool IsSpotOccupied(CBaseEntity *me, const Vector *pos) if (player != me) { - if (player != NULL && range < closeRange) + if (player && range < closeRange) return true; } // is there is a hostage in this spot - if (g_pHostages != NULL) + if (g_pHostages) { CHostage *hostage = g_pHostages->GetClosestHostage(*pos, &range); - if (hostage != NULL && hostage != me && range < closeRange) + if (hostage && hostage != me && range < closeRange) return true; } @@ -3143,13 +3133,13 @@ public: // collect all the hiding spots in this area const HidingSpotList *list = area->GetHidingSpotList(); - for (HidingSpotList::const_iterator iter = list->begin(); iter != list->end() && m_count < MAX_SPOTS; ++iter) + for (HidingSpotList::const_iterator iter = list->begin(); iter != list->end() && m_count < MAX_SPOTS; iter++) { const HidingSpot *spot = (*iter); if (m_useCrouchAreas == false) { CNavArea *area = TheNavAreaGrid.GetNavArea(spot->GetPosition()); - if (area != NULL && (area->GetAttributes() & NAV_CROUCH)) + if (area && (area->GetAttributes() & NAV_CROUCH)) continue; } @@ -3187,10 +3177,10 @@ public: if (m_count == 0) return; - for (int j = i + 1; j < m_count; ++j) + for (int j = i + 1; j < m_count; j++) m_hidingSpot[j - 1] = m_hidingSpot[j]; - --m_count; + m_count--; } CBaseEntity *m_me; @@ -3210,8 +3200,8 @@ public: // TODO: Clean up this mess const Vector *FindNearbyHidingSpot(CBaseEntity *me, const Vector *pos, CNavArea *startArea, float maxRange, bool isSniper, bool useNearest) { - if (startArea == NULL) - return NULL; + if (!startArea) + return nullptr; // collect set of nearby hiding spots if (isSniper) @@ -3222,7 +3212,7 @@ const Vector *FindNearbyHidingSpot(CBaseEntity *me, const Vector *pos, CNavArea if (collector.m_count) { int which = RANDOM_LONG(0, collector.m_count - 1); - return collector.m_hidingSpot[ which ]; + return collector.m_hidingSpot[which]; } else { @@ -3233,7 +3223,7 @@ const Vector *FindNearbyHidingSpot(CBaseEntity *me, const Vector *pos, CNavArea if (collector.m_count) { int which = RANDOM_LONG(0, collector.m_count - 1); - return collector.m_hidingSpot[ which ]; + return collector.m_hidingSpot[which]; } // no sniping spots at all.. fall through and pick a normal hiding spot @@ -3245,14 +3235,14 @@ const Vector *FindNearbyHidingSpot(CBaseEntity *me, const Vector *pos, CNavArea SearchSurroundingAreas(startArea, pos, collector, maxRange); if (collector.m_count == 0) - return NULL; + return nullptr; if (useNearest) { // return closest hiding spot - const Vector *closest = NULL; + const Vector *closest = nullptr; float closeRangeSq = 9999999999.9f; - for (int i = 0; i < collector.m_count; ++i) + for (int i = 0; i < collector.m_count; i++) { float rangeSq = (*collector.m_hidingSpot[i] - *pos).LengthSquared(); if (rangeSq < closeRangeSq) @@ -3267,7 +3257,7 @@ const Vector *FindNearbyHidingSpot(CBaseEntity *me, const Vector *pos, CNavArea // select a hiding spot at random int which = RANDOM_LONG(0, collector.m_count - 1); - return collector.m_hidingSpot[ which ]; + return collector.m_hidingSpot[which]; } // Return true if moving from "start" to "finish" will cross a player's line of fire @@ -3275,7 +3265,7 @@ const Vector *FindNearbyHidingSpot(CBaseEntity *me, const Vector *pos, CNavArea // "start" and "finish" are assumed to be points on the ground bool IsCrossingLineOfFire(const Vector &start, const Vector &finish, CBaseEntity *ignore, int ignoreTeam) { - for (int p = 1; p <= gpGlobals->maxClients; ++p) + for (int p = 1; p <= gpGlobals->maxClients; p++) { CBasePlayer *player = UTIL_PlayerByIndex(p); @@ -3325,24 +3315,24 @@ const Vector *FindRandomHidingSpot(CBaseEntity *me, Place place, bool isSniper) // collect set of nearby hiding spots if (isSniper) { - CollectHidingSpotsFunctor collector(me, NULL, -1.0f, HidingSpot::IDEAL_SNIPER_SPOT, place); + CollectHidingSpotsFunctor collector(me, nullptr, -1.0f, HidingSpot::IDEAL_SNIPER_SPOT, place); ForAllAreas(collector); if (collector.m_count) { int which = RANDOM_LONG(0, collector.m_count - 1); - return collector.m_hidingSpot[ which ]; + return collector.m_hidingSpot[which]; } else { // no ideal sniping spots, look for "good" sniping spots - CollectHidingSpotsFunctor collector(me, NULL, -1.0f, HidingSpot::GOOD_SNIPER_SPOT, place); + CollectHidingSpotsFunctor collector(me, nullptr, -1.0f, HidingSpot::GOOD_SNIPER_SPOT, place); ForAllAreas(collector); if (collector.m_count) { int which = RANDOM_LONG(0, collector.m_count - 1); - return collector.m_hidingSpot[ which ]; + return collector.m_hidingSpot[which]; } // no sniping spots at all.. fall through and pick a normal hiding spot @@ -3350,15 +3340,15 @@ const Vector *FindRandomHidingSpot(CBaseEntity *me, Place place, bool isSniper) } // collect hiding spots with decent "cover" - CollectHidingSpotsFunctor collector(me, NULL, -1.0f, HidingSpot::IN_COVER, place); + CollectHidingSpotsFunctor collector(me, nullptr, -1.0f, HidingSpot::IN_COVER, place); ForAllAreas(collector); if (collector.m_count == 0) - return NULL; + return nullptr; // select a hiding spot at random int which = RANDOM_LONG(0, collector.m_count - 1); - return collector.m_hidingSpot[ which ]; + return collector.m_hidingSpot[which]; } // Select a nearby retreat spot. @@ -3366,25 +3356,25 @@ const Vector *FindRandomHidingSpot(CBaseEntity *me, Place place, bool isSniper) // If "avoidTeam" is nonzero, avoid getting close to members of that team. const Vector *FindNearbyRetreatSpot(CBaseEntity *me, const Vector *start, CNavArea *startArea, float maxRange, int avoidTeam, bool useCrouchAreas) { - if (startArea == NULL) - return NULL; + if (!startArea) + return nullptr; // collect hiding spots with decent "cover" CollectHidingSpotsFunctor collector(me, start, maxRange, HidingSpot::IN_COVER, UNDEFINED_PLACE, useCrouchAreas); SearchSurroundingAreas(startArea, start, collector, maxRange); if (collector.m_count == 0) - return NULL; + return nullptr; // find the closest unoccupied hiding spot that crosses the least lines of fire and has the best cover - for (int i = 0; i < collector.m_count; ++i) + for (int i = 0; i < collector.m_count; i++) { // check if we would have to cross a line of fire to reach this hiding spot if (IsCrossingLineOfFire(*start, *collector.m_hidingSpot[i], me)) { collector.RemoveSpot(i); // back up a step, so iteration won't skip a spot - --i; + i--; continue; } @@ -3401,7 +3391,7 @@ const Vector *FindNearbyRetreatSpot(CBaseEntity *me, const Vector *start, CNavAr collector.RemoveSpot(i); // back up a step, so iteration won't skip a spot - --i; + i--; continue; } } @@ -3409,7 +3399,7 @@ const Vector *FindNearbyRetreatSpot(CBaseEntity *me, const Vector *start, CNavAr } if (collector.m_count <= 0) - return NULL; + return nullptr; // all remaining spots are ok - pick one at random int which = RANDOM_LONG(0, collector.m_count - 1); @@ -3420,9 +3410,8 @@ const Vector *FindNearbyRetreatSpot(CBaseEntity *me, const Vector *start, CNavAr // TODO: Keep pointers to contained Players to make this a zero-time query int CNavArea::GetPlayerCount(int teamID, CBasePlayer *ignore) const { - int count = 0; - - for (int i = 1; i <= gpGlobals->maxClients; ++i) + int nCount = 0; + for (int i = 1; i <= gpGlobals->maxClients; i++) { CBasePlayer *player = UTIL_PlayerByIndex(i); @@ -3439,11 +3428,13 @@ int CNavArea::GetPlayerCount(int teamID, CBasePlayer *ignore) const continue; if (teamID == UNASSIGNED || player->m_iTeam == teamID) + { if (Contains(&player->pev->origin)) - ++count; + nCount++; + } } - return count; + return nCount; } CNavArea *GetMarkedArea() @@ -3453,8 +3444,8 @@ CNavArea *GetMarkedArea() void EditNavAreasReset() { - markedArea = NULL; - lastSelectedArea = NULL; + markedArea = nullptr; + lastSelectedArea = nullptr; isCreatingNavArea = false; isPlacePainting = false; @@ -3465,7 +3456,7 @@ void EditNavAreasReset() void DrawHidingSpots(const class CNavArea *area) { const HidingSpotList *list = area->GetHidingSpotList(); - for (HidingSpotList::const_iterator iter = list->begin(); iter != list->end(); ++iter) + for (HidingSpotList::const_iterator iter = list->begin(); iter != list->end(); iter++) { const HidingSpot *spot = (*iter); int r, g, b; @@ -3494,8 +3485,8 @@ void DrawHidingSpots(const class CNavArea *area) // Draw ourselves and adjacent areas void CNavArea::DrawConnectedAreas() { - CBasePlayer *player = UTIL_GetLocalPlayer(); - if (player == NULL) + CBasePlayer *pLocalPlayer = UTIL_GetLocalPlayer(); + if (!pLocalPlayer) return; const float maxRange = 500.0f; @@ -3518,13 +3509,13 @@ void CNavArea::DrawConnectedAreas() // randomize order of directions to make sure all connected areas are // drawn, since we may have too many to render all at once - int dirSet[ NUM_DIRECTIONS ]; + int dirSet[NUM_DIRECTIONS]; int i; - for (i = 0; i < NUM_DIRECTIONS; ++i) + for (i = 0; i < NUM_DIRECTIONS; i++) dirSet[i] = i; // shuffle dirSet[] - for (int swapCount = 0; swapCount < 3; ++swapCount) + for (int swapCount = 0; swapCount < 3; swapCount++) { int swapI = RANDOM_LONG(0, NUM_DIRECTIONS - 1); int nextI = swapI + 1; @@ -3537,12 +3528,12 @@ void CNavArea::DrawConnectedAreas() } // draw connected areas - for (i = 0; i < NUM_DIRECTIONS; ++i) + for (i = 0; i < NUM_DIRECTIONS; i++) { NavDirType dir = (NavDirType)dirSet[i]; int count = GetAdjacentCount(dir); - for (int a = 0; a < count; ++a) + for (int a = 0; a < count; a++) { CNavArea *adj = GetAdjacentArea(dir, a); @@ -3679,8 +3670,8 @@ private: // Draw navigation areas and edit them void EditNavAreas(NavEditCmdType cmd) { - CBasePlayer *player = UTIL_GetLocalPlayer(); - if (player == NULL) + CBasePlayer *pLocalPlayer = UTIL_GetLocalPlayer(); + if (!pLocalPlayer) return; // don't draw too often on fast video cards or the areas may not appear (odd video effect) @@ -3704,12 +3695,12 @@ void EditNavAreas(NavEditCmdType cmd) if (doDraw) { // show ladder connections - for (NavLadderList::iterator iter = TheNavLadderList.begin(); iter != TheNavLadderList.end(); ++iter) + for (NavLadderList::iterator iter = TheNavLadderList.begin(); iter != TheNavLadderList.end(); iter++) { CNavLadder *ladder = (*iter); - float dx = player->pev->origin.x - ladder->m_bottom.x; - float dy = player->pev->origin.y - ladder->m_bottom.y; + float dx = pLocalPlayer->pev->origin.x - ladder->m_bottom.x; + float dy = pLocalPlayer->pev->origin.y - ladder->m_bottom.y; if (dx * dx + dy * dy > maxRange*maxRange) continue; @@ -3740,11 +3731,11 @@ void EditNavAreas(NavEditCmdType cmd) } // draw approach points for marked area - if (cv_bot_traceview.value == 3 && markedArea != NULL) + if (cv_bot_traceview.value == 3 && markedArea) { Vector ap; float halfWidth; - for (int i = 0; i < markedArea->GetApproachInfoCount(); ++i) + for (int i = 0; i < markedArea->GetApproachInfoCount(); i++) { const CNavArea::ApproachInfo *info = markedArea->GetApproachInfo(i); @@ -3769,14 +3760,14 @@ void EditNavAreas(NavEditCmdType cmd) } Vector dir; - UTIL_MakeVectorsPrivate(player->pev->v_angle, dir, NULL, NULL); + UTIL_MakeVectorsPrivate(pLocalPlayer->pev->v_angle, dir, nullptr, nullptr); // eye position - Vector from = player->pev->origin + player->pev->view_ofs; + Vector from = pLocalPlayer->pev->origin + pLocalPlayer->pev->view_ofs; Vector to = from + maxRange * dir; TraceResult result; - UTIL_TraceLine(from, to, ignore_monsters, ignore_glass, ENT(player->pev), &result); + UTIL_TraceLine(from, to, ignore_monsters, ignore_glass, ENT(pLocalPlayer->pev), &result); if (result.flFraction != 1.0f) { @@ -3819,7 +3810,7 @@ void EditNavAreas(NavEditCmdType cmd) // find the area the player is pointing at CNavArea *area = TheNavAreaGrid.GetNearestNavArea(&result.vecEndPos); - if (area != NULL) + if (area) { // if area changed, print its ID if (area != lastSelectedArea) @@ -3833,7 +3824,7 @@ void EditNavAreas(NavEditCmdType cmd) if (area->GetPlace()) { const char *name = TheBotPhrases->IDToName(area->GetPlace()); - if (name != NULL) + if (name) Q_strcpy(locName, name); else Q_strcpy(locName, "ERROR"); @@ -3857,7 +3848,7 @@ void EditNavAreas(NavEditCmdType cmd) } Q_sprintf(buffer, "Area #%d %s %s\n", area->GetID(), locName, attrib); - UTIL_SayTextAll(buffer, player); + UTIL_SayTextAll(buffer, pLocalPlayer); // do "place painting" if (isPlacePainting) @@ -3865,7 +3856,7 @@ void EditNavAreas(NavEditCmdType cmd) if (area->GetPlace() != TheCSBots()->GetNavPlace()) { area->SetPlace(TheCSBots()->GetNavPlace()); - EMIT_SOUND_DYN(ENT(UTIL_GetLocalPlayer()->pev), CHAN_ITEM, "buttons/lightswitch2.wav", 1, ATTN_NORM, 0, 100); + EMIT_SOUND_DYN(ENT(pLocalPlayer->pev), CHAN_ITEM, "buttons/lightswitch2.wav", 1, ATTN_NORM, 0, 100); } } } @@ -3877,7 +3868,7 @@ void EditNavAreas(NavEditCmdType cmd) switch (cmd) { case EDIT_TOGGLE_PLACE_MODE: - EMIT_SOUND_DYN(ENT(UTIL_GetLocalPlayer()->pev), CHAN_ITEM, "buttons/blip1.wav", 1, ATTN_NORM, 0, 100); + EMIT_SOUND_DYN(ENT(pLocalPlayer->pev), CHAN_ITEM, "buttons/blip1.wav", 1, ATTN_NORM, 0, 100); isPlaceMode = false; return; @@ -3886,12 +3877,12 @@ void EditNavAreas(NavEditCmdType cmd) if (isPlacePainting) { isPlacePainting = false; - EMIT_SOUND_DYN(ENT(UTIL_GetLocalPlayer()->pev), CHAN_ITEM, "buttons/latchunlocked2.wav", 1, ATTN_NORM, 0, 100); + EMIT_SOUND_DYN(ENT(pLocalPlayer->pev), CHAN_ITEM, "buttons/latchunlocked2.wav", 1, ATTN_NORM, 0, 100); } else { isPlacePainting = true; - EMIT_SOUND_DYN(ENT(UTIL_GetLocalPlayer()->pev), CHAN_ITEM, "buttons/lightswitch2.wav", 1, ATTN_NORM, 0, 100); + EMIT_SOUND_DYN(ENT(pLocalPlayer->pev), CHAN_ITEM, "buttons/lightswitch2.wav", 1, ATTN_NORM, 0, 100); // paint the initial area area->SetPlace(TheCSBots()->GetNavPlace()); @@ -3899,7 +3890,7 @@ void EditNavAreas(NavEditCmdType cmd) break; } case EDIT_PLACE_PICK: - EMIT_SOUND_DYN(ENT(UTIL_GetLocalPlayer()->pev), CHAN_ITEM, "buttons/blip1.wav", 1, ATTN_NORM, 0, 100); + EMIT_SOUND_DYN(ENT(pLocalPlayer->pev), CHAN_ITEM, "buttons/blip1.wav", 1, ATTN_NORM, 0, 100); TheCSBots()->SetNavPlace(area->GetPlace()); break; case EDIT_PLACE_FLOODFILL: @@ -3911,7 +3902,7 @@ void EditNavAreas(NavEditCmdType cmd) else // normal editing mode { // draw the "marked" area - if (markedArea != NULL && doDraw) + if (markedArea && doDraw) { markedArea->Draw(0, 255, 255, beamTime); if (markedCorner != NUM_CORNERS) @@ -3927,7 +3918,7 @@ void EditNavAreas(NavEditCmdType cmd) // draw split line const Extent *extent = area->GetExtent(); - float yaw = player->pev->v_angle.y; + float yaw = pLocalPlayer->pev->v_angle.y; while (yaw > 360.0f) yaw -= 360.0f; @@ -3970,66 +3961,66 @@ void EditNavAreas(NavEditCmdType cmd) UTIL_DrawBeamPoints(from, to, beamTime, 255, 255, 255); // draw the area we are pointing at and all connected areas - if (doDraw && (cv_bot_traceview.value != 11 || markedArea == NULL)) + if (doDraw && (cv_bot_traceview.value != 11 || !markedArea)) area->DrawConnectedAreas(); // do area-dependant edit commands, if any switch (cmd) { case EDIT_TOGGLE_PLACE_MODE: - EMIT_SOUND_DYN(ENT(UTIL_GetLocalPlayer()->pev), CHAN_ITEM, "buttons/blip1.wav", 1, ATTN_NORM, 0, 100); + EMIT_SOUND_DYN(ENT(pLocalPlayer->pev), CHAN_ITEM, "buttons/blip1.wav", 1, ATTN_NORM, 0, 100); isPlaceMode = true; return; case EDIT_DELETE: - EMIT_SOUND_DYN(ENT(UTIL_GetLocalPlayer()->pev), CHAN_ITEM, "buttons/blip1.wav", 1, ATTN_NORM, 0, 100); + EMIT_SOUND_DYN(ENT(pLocalPlayer->pev), CHAN_ITEM, "buttons/blip1.wav", 1, ATTN_NORM, 0, 100); TheNavAreaList.remove(area); delete area; return; case EDIT_ATTRIB_CROUCH: - EMIT_SOUND_DYN(ENT(UTIL_GetLocalPlayer()->pev), CHAN_ITEM, "buttons/bell1.wav", 1, ATTN_NORM, 0, 100); + EMIT_SOUND_DYN(ENT(pLocalPlayer->pev), CHAN_ITEM, "buttons/bell1.wav", 1, ATTN_NORM, 0, 100); area->SetAttributes(area->GetAttributes() ^ NAV_CROUCH); break; case EDIT_ATTRIB_JUMP: - EMIT_SOUND_DYN(ENT(UTIL_GetLocalPlayer()->pev), CHAN_ITEM, "buttons/bell1.wav", 1, ATTN_NORM, 0, 100); + EMIT_SOUND_DYN(ENT(pLocalPlayer->pev), CHAN_ITEM, "buttons/bell1.wav", 1, ATTN_NORM, 0, 100); area->SetAttributes(area->GetAttributes() ^ NAV_JUMP); break; case EDIT_ATTRIB_PRECISE: - EMIT_SOUND_DYN(ENT(UTIL_GetLocalPlayer()->pev), CHAN_ITEM, "buttons/bell1.wav", 1, ATTN_NORM, 0, 100); + EMIT_SOUND_DYN(ENT(pLocalPlayer->pev), CHAN_ITEM, "buttons/bell1.wav", 1, ATTN_NORM, 0, 100); area->SetAttributes(area->GetAttributes() ^ NAV_PRECISE); break; case EDIT_ATTRIB_NO_JUMP: - EMIT_SOUND_DYN(ENT(UTIL_GetLocalPlayer()->pev), CHAN_ITEM, "buttons/bell1.wav", 1, ATTN_NORM, 0, 100); + EMIT_SOUND_DYN(ENT(pLocalPlayer->pev), CHAN_ITEM, "buttons/bell1.wav", 1, ATTN_NORM, 0, 100); area->SetAttributes(area->GetAttributes() ^ NAV_NO_JUMP); break; case EDIT_SPLIT: if (area->SplitEdit(splitAlongX, splitEdge)) - EMIT_SOUND_DYN(ENT(UTIL_GetLocalPlayer()->pev), CHAN_ITEM, "weapons/knife_hitwall1.wav", 1, ATTN_NORM, 0, 100); + EMIT_SOUND_DYN(ENT(pLocalPlayer->pev), CHAN_ITEM, "weapons/knife_hitwall1.wav", 1, ATTN_NORM, 0, 100); else - EMIT_SOUND_DYN(ENT(UTIL_GetLocalPlayer()->pev), CHAN_ITEM, "buttons/button11.wav", 1, ATTN_NORM, 0, 100); + EMIT_SOUND_DYN(ENT(pLocalPlayer->pev), CHAN_ITEM, "buttons/button11.wav", 1, ATTN_NORM, 0, 100); break; case EDIT_MERGE: if (markedArea) { if (area->MergeEdit(markedArea)) - EMIT_SOUND_DYN(ENT(UTIL_GetLocalPlayer()->pev), CHAN_ITEM, "buttons/blip1.wav", 1, ATTN_NORM, 0, 100); + EMIT_SOUND_DYN(ENT(pLocalPlayer->pev), CHAN_ITEM, "buttons/blip1.wav", 1, ATTN_NORM, 0, 100); else - EMIT_SOUND_DYN(ENT(UTIL_GetLocalPlayer()->pev), CHAN_ITEM, "buttons/button11.wav", 1, ATTN_NORM, 0, 100); + EMIT_SOUND_DYN(ENT(pLocalPlayer->pev), CHAN_ITEM, "buttons/button11.wav", 1, ATTN_NORM, 0, 100); } else { HintMessageToAllPlayers("To merge, mark an area, highlight a second area, then invoke the merge command"); - EMIT_SOUND_DYN(ENT(UTIL_GetLocalPlayer()->pev), CHAN_ITEM, "buttons/button11.wav", 1, ATTN_NORM, 0, 100); + EMIT_SOUND_DYN(ENT(pLocalPlayer->pev), CHAN_ITEM, "buttons/button11.wav", 1, ATTN_NORM, 0, 100); } break; case EDIT_MARK: if (markedArea) { - EMIT_SOUND_DYN(ENT(UTIL_GetLocalPlayer()->pev), CHAN_ITEM, "buttons/blip1.wav", 1, ATTN_NORM, 0, 100); - markedArea = NULL; + EMIT_SOUND_DYN(ENT(pLocalPlayer->pev), CHAN_ITEM, "buttons/blip1.wav", 1, ATTN_NORM, 0, 100); + markedArea = nullptr; } else { - EMIT_SOUND_DYN(ENT(UTIL_GetLocalPlayer()->pev), CHAN_ITEM, "buttons/blip2.wav", 1, ATTN_NORM, 0, 100); + EMIT_SOUND_DYN(ENT(pLocalPlayer->pev), CHAN_ITEM, "buttons/blip2.wav", 1, ATTN_NORM, 0, 100); markedArea = area; int connected = 0; @@ -4040,19 +4031,19 @@ void EditNavAreas(NavEditCmdType cmd) char buffer[80]; Q_sprintf(buffer, "Marked Area is connected to %d other Areas\n", connected); - UTIL_SayTextAll(buffer, player); + UTIL_SayTextAll(buffer, pLocalPlayer); } break; case EDIT_MARK_UNNAMED: if (markedArea) { - EMIT_SOUND_DYN(ENT(UTIL_GetLocalPlayer()->pev), CHAN_ITEM, "buttons/blip1.wav", 1, ATTN_NORM, 0, 100); - markedArea = NULL; + EMIT_SOUND_DYN(ENT(pLocalPlayer->pev), CHAN_ITEM, "buttons/blip1.wav", 1, ATTN_NORM, 0, 100); + markedArea = nullptr; } else { - markedArea = NULL; - for (NavAreaList::iterator iter = TheNavAreaList.begin(); iter != TheNavAreaList.end(); ++iter) + markedArea = nullptr; + for (NavAreaList::iterator iter = TheNavAreaList.begin(); iter != TheNavAreaList.end(); iter++) { CNavArea *area = (*iter); if (area->GetPlace() == 0) @@ -4063,11 +4054,11 @@ void EditNavAreas(NavEditCmdType cmd) } if (!markedArea) { - EMIT_SOUND_DYN(ENT(UTIL_GetLocalPlayer()->pev), CHAN_ITEM, "buttons/blip1.wav", 1, ATTN_NORM, 0, 100); + EMIT_SOUND_DYN(ENT(pLocalPlayer->pev), CHAN_ITEM, "buttons/blip1.wav", 1, ATTN_NORM, 0, 100); } else { - EMIT_SOUND_DYN(ENT(UTIL_GetLocalPlayer()->pev), CHAN_ITEM, "buttons/blip2.wav", 1, ATTN_NORM, 0, 100); + EMIT_SOUND_DYN(ENT(pLocalPlayer->pev), CHAN_ITEM, "buttons/blip2.wav", 1, ATTN_NORM, 0, 100); int connected = 0; connected += markedArea->GetAdjacentCount(NORTH); @@ -4076,26 +4067,25 @@ void EditNavAreas(NavEditCmdType cmd) connected += markedArea->GetAdjacentCount(WEST); int totalUnnamedAreas = 0; - for (NavAreaList::iterator iter = TheNavAreaList.begin(); iter != TheNavAreaList.end(); ++iter) + for (NavAreaList::iterator iter = TheNavAreaList.begin(); iter != TheNavAreaList.end(); iter++) { CNavArea *area = (*iter); if (area->GetPlace() == 0) { - ++totalUnnamedAreas; + totalUnnamedAreas++; } } char buffer[80]; Q_sprintf(buffer, "Marked Area is connected to %d other Areas - there are %d total unnamed areas\n", connected, totalUnnamedAreas); - UTIL_SayTextAll(buffer, player); + UTIL_SayTextAll(buffer, pLocalPlayer); } } break; case EDIT_WARP_TO_MARK: if (markedArea) { - CBasePlayer *pLocalPlayer = UTIL_GetLocalPlayer(); - if (pLocalPlayer && pLocalPlayer->m_iTeam == SPECTATOR && pLocalPlayer->pev->iuser1 == OBS_ROAMING) + if (pLocalPlayer->m_iTeam == SPECTATOR && pLocalPlayer->pev->iuser1 == OBS_ROAMING) { Vector origin = *markedArea->GetCenter() + Vector(0, 0, 0.75f * HumanHeight); UTIL_SetOrigin(pLocalPlayer->pev, origin); @@ -4103,7 +4093,7 @@ void EditNavAreas(NavEditCmdType cmd) } else { - EMIT_SOUND_DYN(ENT(UTIL_GetLocalPlayer()->pev), CHAN_ITEM, "buttons/button11.wav", 1, ATTN_NORM, 0, 100); + EMIT_SOUND_DYN(ENT(pLocalPlayer->pev), CHAN_ITEM, "buttons/button11.wav", 1, ATTN_NORM, 0, 100); } break; case EDIT_CONNECT: @@ -4112,18 +4102,18 @@ void EditNavAreas(NavEditCmdType cmd) NavDirType dir = markedArea->ComputeDirection(&cursor); if (dir == NUM_DIRECTIONS) { - EMIT_SOUND_DYN(ENT(UTIL_GetLocalPlayer()->pev), CHAN_ITEM, "buttons/button11.wav", 1, ATTN_NORM, 0, 100); + EMIT_SOUND_DYN(ENT(pLocalPlayer->pev), CHAN_ITEM, "buttons/button11.wav", 1, ATTN_NORM, 0, 100); } else { markedArea->ConnectTo(area, dir); - EMIT_SOUND_DYN(ENT(UTIL_GetLocalPlayer()->pev), CHAN_ITEM, "buttons/blip1.wav", 1, ATTN_NORM, 0, 100); + EMIT_SOUND_DYN(ENT(pLocalPlayer->pev), CHAN_ITEM, "buttons/blip1.wav", 1, ATTN_NORM, 0, 100); } } else { HintMessageToAllPlayers("To connect areas, mark an area, highlight a second area, then invoke the connect command. Make sure the cursor is directly north, south, east, or west of the marked area."); - EMIT_SOUND_DYN(ENT(UTIL_GetLocalPlayer()->pev), CHAN_ITEM, "buttons/button11.wav", 1, ATTN_NORM, 0, 100); + EMIT_SOUND_DYN(ENT(pLocalPlayer->pev), CHAN_ITEM, "buttons/button11.wav", 1, ATTN_NORM, 0, 100); } break; case EDIT_DISCONNECT: @@ -4131,26 +4121,26 @@ void EditNavAreas(NavEditCmdType cmd) { markedArea->Disconnect(area); area->Disconnect(markedArea); - EMIT_SOUND_DYN(ENT(UTIL_GetLocalPlayer()->pev), CHAN_ITEM, "buttons/blip1.wav", 1, ATTN_NORM, 0, 100); + EMIT_SOUND_DYN(ENT(pLocalPlayer->pev), CHAN_ITEM, "buttons/blip1.wav", 1, ATTN_NORM, 0, 100); } else { HintMessageToAllPlayers("To disconnect areas, mark an area, highlight a second area, then invoke the disconnect command. This will remove all connections between the two areas."); - EMIT_SOUND_DYN(ENT(UTIL_GetLocalPlayer()->pev), CHAN_ITEM, "buttons/button11.wav", 1, ATTN_NORM, 0, 100); + EMIT_SOUND_DYN(ENT(pLocalPlayer->pev), CHAN_ITEM, "buttons/button11.wav", 1, ATTN_NORM, 0, 100); } break; case EDIT_SPLICE: if (markedArea) { if (area->SpliceEdit(markedArea)) - EMIT_SOUND_DYN(ENT(UTIL_GetLocalPlayer()->pev), CHAN_ITEM, "buttons/blip1.wav", 1, ATTN_NORM, 0, 100); + EMIT_SOUND_DYN(ENT(pLocalPlayer->pev), CHAN_ITEM, "buttons/blip1.wav", 1, ATTN_NORM, 0, 100); else - EMIT_SOUND_DYN(ENT(UTIL_GetLocalPlayer()->pev), CHAN_ITEM, "buttons/button11.wav", 1, ATTN_NORM, 0, 100); + EMIT_SOUND_DYN(ENT(pLocalPlayer->pev), CHAN_ITEM, "buttons/button11.wav", 1, ATTN_NORM, 0, 100); } else { HintMessageToAllPlayers("To splice, mark an area, highlight a second area, then invoke the splice command to create an area between them"); - EMIT_SOUND_DYN(ENT(UTIL_GetLocalPlayer()->pev), CHAN_ITEM, "buttons/button11.wav", 1, ATTN_NORM, 0, 100); + EMIT_SOUND_DYN(ENT(pLocalPlayer->pev), CHAN_ITEM, "buttons/button11.wav", 1, ATTN_NORM, 0, 100); } break; case EDIT_SELECT_CORNER: @@ -4158,33 +4148,33 @@ void EditNavAreas(NavEditCmdType cmd) { int corner = (markedCorner + 1) % (NUM_CORNERS + 1); markedCorner = (NavCornerType)corner; - EMIT_SOUND_DYN(ENT(UTIL_GetLocalPlayer()->pev), CHAN_ITEM, "buttons/blip1.wav", 1, ATTN_NORM, 0, 100); + EMIT_SOUND_DYN(ENT(pLocalPlayer->pev), CHAN_ITEM, "buttons/blip1.wav", 1, ATTN_NORM, 0, 100); } else { - EMIT_SOUND_DYN(ENT(UTIL_GetLocalPlayer()->pev), CHAN_ITEM, "buttons/button11.wav", 1, ATTN_NORM, 0, 100); + EMIT_SOUND_DYN(ENT(pLocalPlayer->pev), CHAN_ITEM, "buttons/button11.wav", 1, ATTN_NORM, 0, 100); } break; case EDIT_RAISE_CORNER: if (markedArea) { markedArea->RaiseCorner(markedCorner, 1); - EMIT_SOUND_DYN(ENT(UTIL_GetLocalPlayer()->pev), CHAN_ITEM, "buttons/blip1.wav", 1, ATTN_NORM, 0, 100); + EMIT_SOUND_DYN(ENT(pLocalPlayer->pev), CHAN_ITEM, "buttons/blip1.wav", 1, ATTN_NORM, 0, 100); } else { - EMIT_SOUND_DYN(ENT(UTIL_GetLocalPlayer()->pev), CHAN_ITEM, "buttons/button11.wav", 1, ATTN_NORM, 0, 100); + EMIT_SOUND_DYN(ENT(pLocalPlayer->pev), CHAN_ITEM, "buttons/button11.wav", 1, ATTN_NORM, 0, 100); } break; case EDIT_LOWER_CORNER: if (markedArea) { markedArea->RaiseCorner(markedCorner, -1); - EMIT_SOUND_DYN(ENT(UTIL_GetLocalPlayer()->pev), CHAN_ITEM, "buttons/blip1.wav", 1, ATTN_NORM, 0, 100); + EMIT_SOUND_DYN(ENT(pLocalPlayer->pev), CHAN_ITEM, "buttons/blip1.wav", 1, ATTN_NORM, 0, 100); } else { - EMIT_SOUND_DYN(ENT(UTIL_GetLocalPlayer()->pev), CHAN_ITEM, "buttons/button11.wav", 1, ATTN_NORM, 0, 100); + EMIT_SOUND_DYN(ENT(pLocalPlayer->pev), CHAN_ITEM, "buttons/button11.wav", 1, ATTN_NORM, 0, 100); } break; } @@ -4199,11 +4189,11 @@ void EditNavAreas(NavEditCmdType cmd) if (isCreatingNavArea) { isCreatingNavArea = false; - EMIT_SOUND_DYN(ENT(UTIL_GetLocalPlayer()->pev), CHAN_ITEM, "buttons/button11.wav", 1, ATTN_NORM, 0, 100); + EMIT_SOUND_DYN(ENT(pLocalPlayer->pev), CHAN_ITEM, "buttons/button11.wav", 1, ATTN_NORM, 0, 100); } else { - EMIT_SOUND_DYN(ENT(UTIL_GetLocalPlayer()->pev), CHAN_ITEM, "buttons/blip2.wav", 1, ATTN_NORM, 0, 100); + EMIT_SOUND_DYN(ENT(pLocalPlayer->pev), CHAN_ITEM, "buttons/blip2.wav", 1, ATTN_NORM, 0, 100); isCreatingNavArea = true; isAnchored = false; } @@ -4227,7 +4217,7 @@ void EditNavAreas(NavEditCmdType cmd) TheNavAreaList.push_back(newArea); TheNavAreaGrid.AddNavArea(newArea); - EMIT_SOUND_DYN(ENT(UTIL_GetLocalPlayer()->pev), CHAN_ITEM, "buttons/blip1.wav", 1, ATTN_NORM, 0, 100); + EMIT_SOUND_DYN(ENT(pLocalPlayer->pev), CHAN_ITEM, "buttons/blip1.wav", 1, ATTN_NORM, 0, 100); // if we have a marked area, inter-connect the two if (markedArea) @@ -4263,7 +4253,7 @@ void EditNavAreas(NavEditCmdType cmd) } else { - EMIT_SOUND_DYN(ENT(UTIL_GetLocalPlayer()->pev), CHAN_ITEM, "buttons/button11.wav", 1, ATTN_NORM, 0, 100); + EMIT_SOUND_DYN(ENT(pLocalPlayer->pev), CHAN_ITEM, "buttons/button11.wav", 1, ATTN_NORM, 0, 100); } break; @@ -4276,7 +4266,7 @@ void EditNavAreas(NavEditCmdType cmd) cmd != EDIT_MARK_UNNAMED && cmd != EDIT_WARP_TO_MARK && cmd != EDIT_SELECT_CORNER && cmd != EDIT_RAISE_CORNER && cmd != EDIT_LOWER_CORNER && cmd != EDIT_NONE) - markedArea = NULL; + markedArea = nullptr; // if our last command was not affecting the corner, clear the corner selection if (cmd != EDIT_SELECT_CORNER && cmd != EDIT_RAISE_CORNER && cmd != EDIT_LOWER_CORNER && cmd != EDIT_NONE) @@ -4296,7 +4286,7 @@ bool GetGroundHeight(const Vector *pos, float *height, Vector *normal) float offset; Vector from; TraceResult result; - edict_t *ignore = NULL; + edict_t *ignore = nullptr; float ground = 0.0f; const float maxOffset = 100.0f; @@ -4335,7 +4325,7 @@ bool GetGroundHeight(const Vector *pos, float *height, Vector *normal) { layer[layerCount].ground = result.vecEndPos.z; layer[layerCount].normal = result.vecPlaneNormal; - ++layerCount; + layerCount++; if (layerCount == MAX_GROUND_LAYERS) break; @@ -4347,7 +4337,7 @@ bool GetGroundHeight(const Vector *pos, float *height, Vector *normal) return false; int i; - for (i = 0; i < layerCount - 1; ++i) + for (i = 0; i < layerCount - 1; i++) { if (layer[i + 1].ground - layer[i].ground >= HalfHumanHeight) break; @@ -4375,14 +4365,14 @@ bool GetSimpleGroundHeight(const Vector *pos, float *height, Vector *normal) TraceResult result; - UTIL_TraceLine(*pos, to, ignore_monsters, dont_ignore_glass, NULL, &result); + UTIL_TraceLine(*pos, to, ignore_monsters, dont_ignore_glass, nullptr, &result); if (result.fStartSolid) return false; *height = result.vecEndPos.z; - if (normal != NULL) + if (normal) { *normal = result.vecPlaneNormal; } @@ -4397,14 +4387,14 @@ public: float operator()(CNavArea *area, CNavArea *fromArea, const CNavLadder *ladder) { // check if this area is "blocked" - for (int i = 0; i < BlockedIDCount; ++i) + for (int i = 0; i < BlockedIDCount; i++) { if (area->GetID() == BlockedID[i]) return -1.0f; } // first area in path, no cost - if (fromArea == NULL) + if (!fromArea) return 0.0f; else { @@ -4429,12 +4419,12 @@ inline bool IsAreaVisible(const Vector *pos, const CNavArea *area) Vector corner; TraceResult result; - for (int c = 0; c < NUM_CORNERS; ++c) + for (int c = 0; c < NUM_CORNERS; c++) { corner = *area->GetCorner((NavCornerType)c); corner.z += 0.75f * HumanHeight; - UTIL_TraceLine(*pos, corner, ignore_monsters, NULL, &result); + UTIL_TraceLine(*pos, corner, ignore_monsters, nullptr, &result); if (result.flFraction == 1.0f) { // we can see this area @@ -4467,18 +4457,13 @@ void CNavArea::ComputeApproachAreas() eye.z += 0.9f * HumanHeight; enum { MAX_PATH_LENGTH = 256 }; - CNavArea *path[ MAX_PATH_LENGTH ]; + CNavArea *path[MAX_PATH_LENGTH]; - // // In order to enumerate all of the approach areas, we need to // run the algorithm many times, once for each "far away" area // and keep the union of the approach area sets - // - NavAreaList::iterator iter; - for (iter = goodSizedAreaList.begin(); iter != goodSizedAreaList.end(); ++iter) + for (auto farArea : goodSizedAreaList) { - CNavArea *farArea = (*iter); - BlockedIDCount = 0; // if we can see 'farArea', try again - the whole point is to go "around the bend", so to speak @@ -4487,7 +4472,7 @@ void CNavArea::ComputeApproachAreas() // make first path to far away area ApproachAreaCost cost; - if (NavAreaBuildPath(this, farArea, NULL, cost) == false) + if (NavAreaBuildPath(this, farArea, nullptr, cost) == false) continue; // @@ -4501,7 +4486,7 @@ void CNavArea::ComputeApproachAreas() int count = 0; CNavArea *area; for (area = farArea; area; area = area->GetParent()) - ++count; + count++; if (count > MAX_PATH_LENGTH) count = MAX_PATH_LENGTH; @@ -4509,10 +4494,12 @@ void CNavArea::ComputeApproachAreas() // build path in correct order - from eye outwards int i = count; for (area = farArea; i && area; area = area->GetParent()) - path[ --i ] = area; + { + path[--i] = area; + } // traverse path to find first area we cannot see (skip the first area) - for (i = 1; i < count; ++i) + for (i = 1; i < count; i++) { // if we see this area, continue on if (IsAreaVisible(&eye, path[i])) @@ -4530,28 +4517,25 @@ void CNavArea::ComputeApproachAreas() // (blocking farArea will cause all subsequent pathfinds to fail) int block = (path[i] == farArea) ? i - 1 : i; - BlockedID[ BlockedIDCount++ ] = path[ block ]->GetID(); + BlockedID[BlockedIDCount++] = path[block]->GetID(); if (block == 0) break; // store new approach area if not already in set int a; - for (a = 0; a < m_approachCount; ++a) + for (a = 0; a < m_approachCount; a++) if (m_approach[a].here.area == path[block - 1]) break; if (a == m_approachCount) { - m_approach[ m_approachCount ].prev.area = (block >= 2) ? path[block-2] : NULL; - - m_approach[ m_approachCount ].here.area = path[block - 1]; - m_approach[ m_approachCount ].prevToHereHow = path[block - 1]->GetParentHow(); - - m_approach[ m_approachCount ].next.area = path[block]; - m_approach[ m_approachCount ].hereToNextHow = path[block]->GetParentHow(); - - ++m_approachCount; + m_approach[m_approachCount].prev.area = (block >= 2) ? path[block-2] : nullptr; + m_approach[m_approachCount].here.area = path[block - 1]; + m_approach[m_approachCount].prevToHereHow = path[block - 1]->GetParentHow(); + m_approach[m_approachCount].next.area = path[block]; + m_approach[m_approachCount].hereToNextHow = path[block]->GetParentHow(); + m_approachCount++; } // we are done with this path @@ -4560,7 +4544,7 @@ void CNavArea::ComputeApproachAreas() // find another path to 'farArea' ApproachAreaCost cost; - if (NavAreaBuildPath(this, farArea, NULL, cost) == false) + if (NavAreaBuildPath(this, farArea, nullptr, cost) == false) { // can't find a path to 'farArea' means all exits have been already tested and blocked break; @@ -4571,31 +4555,31 @@ void CNavArea::ComputeApproachAreas() CNavAreaGrid::CNavAreaGrid() : m_cellSize(300.0f) { - m_grid = NULL; + m_grid = nullptr; Reset(); } CNavAreaGrid::~CNavAreaGrid() { delete[] m_grid; - m_grid = NULL; + m_grid = nullptr; } // Clear the grid void CNavAreaGrid::Reset() { - if (m_grid != NULL) + if (m_grid) { delete[] m_grid; - m_grid = NULL; + m_grid = nullptr; } m_gridSizeX = 0; m_gridSizeY = 0; // clear the hash table - for (int i = 0; i < HASH_TABLE_SIZE; ++i) - m_hashTable[i] = NULL; + for (int i = 0; i < HASH_TABLE_SIZE; i++) + m_hashTable[i] = nullptr; m_areaCount = 0; @@ -4615,7 +4599,7 @@ void CNavAreaGrid::Initialize(float minX, float maxX, float minY, float maxY) m_gridSizeX = int((maxX - minX) / m_cellSize + 1); m_gridSizeY = int((maxY - minY) / m_cellSize + 1); - m_grid = new NavAreaList[ m_gridSizeX * m_gridSizeY ]; + m_grid = new NavAreaList[m_gridSizeX * m_gridSizeY]; } // Add an area to the grid @@ -4629,10 +4613,10 @@ void CNavAreaGrid::AddNavArea(CNavArea *area) int hiX = WorldToGridX(extent->hi.x); int hiY = WorldToGridY(extent->hi.y); - for (int y = loY; y <= hiY; ++y) + for (int y = loY; y <= hiY; y++) { - for (int x = loX; x <= hiX; ++x) - m_grid[ x + y * m_gridSizeX ].push_back(const_cast(area)); + for (int x = loX; x <= hiX; x++) + m_grid[x + y * m_gridSizeX].push_back(const_cast(area)); } // add to hash table @@ -4641,7 +4625,7 @@ void CNavAreaGrid::AddNavArea(CNavArea *area) if (m_hashTable[key]) { // add to head of list in this slot - area->m_prevHash = NULL; + area->m_prevHash = nullptr; area->m_nextHash = m_hashTable[key]; m_hashTable[key]->m_prevHash = area; m_hashTable[key] = area; @@ -4650,11 +4634,11 @@ void CNavAreaGrid::AddNavArea(CNavArea *area) { // first entry in this slot m_hashTable[key] = area; - area->m_nextHash = NULL; - area->m_prevHash = NULL; + area->m_nextHash = nullptr; + area->m_prevHash = nullptr; } - ++m_areaCount; + m_areaCount++; } // Remove an area from the grid @@ -4668,9 +4652,9 @@ void CNavAreaGrid::RemoveNavArea(CNavArea *area) int hiX = WorldToGridX(extent->hi.x); int hiY = WorldToGridY(extent->hi.y); - for (int y = loY; y <= hiY; ++y) + for (int y = loY; y <= hiY; y++) { - for (int x = loX; x <= hiX; ++x) + for (int x = loX; x <= hiX; x++) { m_grid[x + y * m_gridSizeX].remove(area); } @@ -4689,7 +4673,7 @@ void CNavAreaGrid::RemoveNavArea(CNavArea *area) m_hashTable[key] = area->m_nextHash; if (m_hashTable[key]) - m_hashTable[key]->m_prevHash = NULL; + m_hashTable[key]->m_prevHash = nullptr; } if (area->m_nextHash) @@ -4697,14 +4681,14 @@ void CNavAreaGrid::RemoveNavArea(CNavArea *area) area->m_nextHash->m_prevHash = area->m_prevHash; } - --m_areaCount; + m_areaCount--; } // Given a position, return the nav area that IsOverlapping and is *immediately* beneath it CNavArea *CNavAreaGrid::GetNavArea(const Vector *pos, float beneathLimit) const { - if (m_grid == NULL) - return NULL; + if (!m_grid) + return nullptr; // get list in cell that contains position int x = WorldToGridX(pos->x); @@ -4712,11 +4696,11 @@ CNavArea *CNavAreaGrid::GetNavArea(const Vector *pos, float beneathLimit) const NavAreaList *list = &m_grid[x + y * m_gridSizeX]; // search cell list to find correct area - CNavArea *use = NULL; + CNavArea *use = nullptr; float useZ = -99999999.9f; Vector testPos = *pos + Vector(0, 0, 5); - for (NavAreaList::iterator iter = list->begin(); iter != list->end(); ++iter) + for (NavAreaList::iterator iter = list->begin(); iter != list->end(); iter++) { CNavArea *area = (*iter); @@ -4751,10 +4735,10 @@ CNavArea *CNavAreaGrid::GetNavArea(const Vector *pos, float beneathLimit) const // Used to find initial area if we start off of the mesh. CNavArea *CNavAreaGrid::GetNearestNavArea(const Vector *pos, bool anyZ) const { - if (m_grid == NULL) - return NULL; + if (!m_grid) + return nullptr; - CNavArea *close = NULL; + CNavArea *close = nullptr; float closeDistSq = 100000000.0f; // quick check @@ -4768,14 +4752,14 @@ CNavArea *CNavAreaGrid::GetNearestNavArea(const Vector *pos, bool anyZ) const source.y = pos->y; if (GetGroundHeight(pos, &source.z) == false) - return NULL; + return nullptr; source.z += HalfHumanHeight; // TODO: Step incrementally using grid for speed // find closest nav area - for (NavAreaList::iterator iter = TheNavAreaList.begin(); iter != TheNavAreaList.end(); ++iter) + for (NavAreaList::iterator iter = TheNavAreaList.begin(); iter != TheNavAreaList.end(); iter++) { CNavArea *area = (*iter); @@ -4791,10 +4775,11 @@ CNavArea *CNavAreaGrid::GetNearestNavArea(const Vector *pos, bool anyZ) const if (!anyZ) { TraceResult result; - UTIL_TraceLine(source, areaPos + Vector(0, 0, HalfHumanHeight), ignore_monsters, ignore_glass, NULL, &result); + UTIL_TraceLine(source, areaPos + Vector(0, 0, HalfHumanHeight), ignore_monsters, ignore_glass, nullptr, &result); if (result.flFraction != 1.0f) continue; } + closeDistSq = distSq; close = area; } @@ -4807,23 +4792,23 @@ CNavArea *CNavAreaGrid::GetNearestNavArea(const Vector *pos, bool anyZ) const CNavArea *CNavAreaGrid::GetNavAreaByID(unsigned int id) const { if (id == 0) - return NULL; + return nullptr; int key = ComputeHashKey(id); - for (CNavArea *area = m_hashTable[key]; area; area = area->m_nextHash) + { if (area->GetID() == id) return area; + } - return NULL; + return nullptr; } // Return radio chatter place for given coordinate Place CNavAreaGrid::GetPlace(const Vector *pos) const { CNavArea *area = GetNearestNavArea(pos, true); - - if (area != NULL) + if (area) { return area->GetPlace(); } diff --git a/regamedll/game_shared/bot/nav_area.h b/regamedll/game_shared/bot/nav_area.h index 7b68cc97..e8f8496f 100644 --- a/regamedll/game_shared/bot/nav_area.h +++ b/regamedll/game_shared/bot/nav_area.h @@ -26,11 +26,7 @@ * */ -#ifndef NAV_AREA_H -#define NAV_AREA_H -#ifdef _WIN32 #pragma once -#endif #include @@ -45,30 +41,30 @@ void DestroyNavigationMap(); enum NavEditCmdType { EDIT_NONE, - EDIT_DELETE, // delete current area - EDIT_SPLIT, // split current area - EDIT_MERGE, // merge adjacent areas - EDIT_JOIN, // define connection between areas - EDIT_BREAK, // break connection between areas - EDIT_MARK, // mark an area for further operations - EDIT_ATTRIB_CROUCH, // toggle crouch attribute on current area - EDIT_ATTRIB_JUMP, // toggle jump attribute on current area + EDIT_DELETE, // delete current area + EDIT_SPLIT, // split current area + EDIT_MERGE, // merge adjacent areas + EDIT_JOIN, // define connection between areas + EDIT_BREAK, // break connection between areas + EDIT_MARK, // mark an area for further operations + EDIT_ATTRIB_CROUCH, // toggle crouch attribute on current area + EDIT_ATTRIB_JUMP, // toggle jump attribute on current area EDIT_ATTRIB_PRECISE, // toggle precise attribute on current area EDIT_ATTRIB_NO_JUMP, // toggle inhibiting discontinuity jumping in current area - EDIT_BEGIN_AREA, // begin creating a new nav area - EDIT_END_AREA, // end creation of the new nav area - EDIT_CONNECT, // connect marked area to selected area - EDIT_DISCONNECT, // disconnect marked area from selected area - EDIT_SPLICE, // create new area in between marked and selected areas + EDIT_BEGIN_AREA, // begin creating a new nav area + EDIT_END_AREA, // end creation of the new nav area + EDIT_CONNECT, // connect marked area to selected area + EDIT_DISCONNECT, // disconnect marked area from selected area + EDIT_SPLICE, // create new area in between marked and selected areas EDIT_TOGGLE_PLACE_MODE, // switch between normal and place editing EDIT_TOGGLE_PLACE_PAINTING, // switch between "painting" places onto areas EDIT_PLACE_FLOODFILL, // floodfill areas out from current area - EDIT_PLACE_PICK, // "pick up" the place at the current area - EDIT_MARK_UNNAMED, // mark an unnamed area for further operations - EDIT_WARP_TO_MARK, // warp a spectating local player to the selected mark - EDIT_SELECT_CORNER, // select a corner on the current area - EDIT_RAISE_CORNER, // raise a corner on the current area - EDIT_LOWER_CORNER, // lower a corner on the current area + EDIT_PLACE_PICK, // "pick up" the place at the current area + EDIT_MARK_UNNAMED, // mark an unnamed area for further operations + EDIT_WARP_TO_MARK, // warp a spectating local player to the selected mark + EDIT_SELECT_CORNER, // select a corner on the current area + EDIT_RAISE_CORNER, // raise a corner on the current area + EDIT_LOWER_CORNER, // lower a corner on the current area }; enum RouteType @@ -99,12 +95,12 @@ class CNavLadder public: CNavLadder() { - m_topForwardArea = NULL; - m_topRightArea = NULL; - m_topLeftArea = NULL; - m_topBehindArea = NULL; - m_bottomArea = NULL; - m_entity = NULL; + m_topForwardArea = nullptr; + m_topRightArea = nullptr; + m_topLeftArea = nullptr; + m_topBehindArea = nullptr; + m_bottomArea = nullptr; + m_entity = nullptr; } Vector m_top; @@ -125,19 +121,19 @@ public: void OnDestroyNotify(CNavArea *dead) { if (dead == m_topForwardArea) - m_topForwardArea = NULL; + m_topForwardArea = nullptr; if (dead == m_topLeftArea) - m_topLeftArea = NULL; + m_topLeftArea = nullptr; if (dead == m_topRightArea) - m_topRightArea = NULL; + m_topRightArea = nullptr; if (dead == m_topBehindArea) - m_topBehindArea = NULL; + m_topBehindArea = nullptr; if (dead == m_bottomArea) - m_bottomArea = NULL; + m_bottomArea = nullptr; } }; @@ -173,7 +169,7 @@ public: void Mark() { m_marker = IMPL(m_masterMarker); } bool IsMarked() const { return (m_marker == IMPL(m_masterMarker)) ? true : false; } - static void ChangeMasterMarker() { ++IMPL(m_masterMarker); } + static void ChangeMasterMarker() { IMPL(m_masterMarker)++; } private: friend void DestroyHidingSpots(); @@ -209,7 +205,7 @@ struct SpotEncounter NavConnect to; NavDirType toDir; Ray path; // the path segment - SpotOrderList spotList; // list of spots to look at, in order of occurrence + SpotOrderList spotList; // list of spots to look at, in order of occurrence }; typedef std::STD_LIST SpotEncounterList; @@ -226,7 +222,7 @@ public: ~CNavArea(); - void ConnectTo(CNavArea *area, NavDirType dir); // connect this area to given area in given direction + void ConnectTo(CNavArea *area, NavDirType dir); // connect this area to given area in given direction void Disconnect(CNavArea *area); // disconnect this area from given area void Save(FILE *fp) const; @@ -239,37 +235,37 @@ public: void SetAttributes(unsigned char bits) { m_attributeFlags = bits; } unsigned char GetAttributes() const { return m_attributeFlags; } void SetPlace(Place place) { m_place = place; } // set place descriptor - Place GetPlace() const { return m_place; } // get place descriptor + Place GetPlace() const { return m_place; } // get place descriptor bool IsOverlapping(const Vector *pos) const; // return true if 'pos' is within 2D extents of area bool IsOverlapping(const CNavArea *area) const; // return true if 'area' overlaps our 2D extents bool IsOverlappingX(const CNavArea *area) const; // return true if 'area' overlaps our X extent bool IsOverlappingY(const CNavArea *area) const; // return true if 'area' overlaps our Y extent - int GetPlayerCount(int teamID = 0, CBasePlayer *ignore = NULL) const; // return number of players with given teamID in this area (teamID == 0 means any/all) - float GetZ(const Vector *pos) const; // return Z of area at (x,y) of 'pos' - float GetZ(float x, float y) const; // return Z of area at (x,y) of 'pos' - bool Contains(const Vector *pos) const; // return true if given point is on or above this area, but no others + int GetPlayerCount(int teamID = 0, CBasePlayer *ignore = nullptr) const; // return number of players with given teamID in this area (teamID == 0 means any/all) + float GetZ(const Vector *pos) const; // return Z of area at (x,y) of 'pos' + float GetZ(float x, float y) const; // return Z of area at (x,y) of 'pos' + bool Contains(const Vector *pos) const; // return true if given point is on or above this area, but no others bool IsCoplanar(const CNavArea *area) const; // return true if this area and given area are approximately co-planar - void GetClosestPointOnArea(const Vector *pos, Vector *close) const; // return closest point to 'pos' on this area - returned point in 'close' - float GetDistanceSquaredToPoint(const Vector *pos) const; // return shortest distance between point and this area - bool IsDegenerate() const; // return true if this area is badly formed - bool IsEdge(NavDirType dir) const; // return true if there are no bi-directional links on the given side + void GetClosestPointOnArea(const Vector *pos, Vector *close) const; // return closest point to 'pos' on this area - returned point in 'close' + float GetDistanceSquaredToPoint(const Vector *pos) const; // return shortest distance between point and this area + bool IsDegenerate() const; // return true if this area is badly formed + bool IsEdge(NavDirType dir) const; // return true if there are no bi-directional links on the given side int GetAdjacentCount(NavDirType dir) const { return m_connect[dir].size(); } // return number of connected areas in given direction - CNavArea *GetAdjacentArea(NavDirType dir, int i) const; // return the i'th adjacent area in the given direction + CNavArea *GetAdjacentArea(NavDirType dir, int i) const; // return the i'th adjacent area in the given direction CNavArea *GetRandomAdjacentArea(NavDirType dir) const; const NavConnectList *GetAdjacentList(NavDirType dir) const { return &m_connect[dir]; } - bool IsConnected(const CNavArea *area, NavDirType dir) const; // return true if given area is connected in given direction + bool IsConnected(const CNavArea *area, NavDirType dir) const; // return true if given area is connected in given direction float ComputeHeightChange(const CNavArea *area); // compute change in height from this area to given area const NavLadderList *GetLadderList(LadderDirectionType dir) const { return &m_ladder[dir]; } - void ComputePortal(const CNavArea *to, NavDirType dir, Vector *center, float *halfWidth) const; // compute portal to adjacent area + void ComputePortal(const CNavArea *to, NavDirType dir, Vector *center, float *halfWidth) const; // compute portal to adjacent area void ComputeClosestPointInPortal(const CNavArea *to, NavDirType dir, const Vector *fromPos, Vector *closePos) const; // compute closest point within the "portal" between to adjacent areas NavDirType ComputeDirection(Vector *point) const; // return direction from this area to the given point // for hunting algorithm void SetClearedTimestamp(int teamID) { m_clearedTimestamp[teamID] = gpGlobals->time; } // set this area's "clear" timestamp to now - float GetClearedTimestamp(int teamID) { return m_clearedTimestamp[teamID]; } // get time this area was marked "clear" + float GetClearedTimestamp(int teamID) { return m_clearedTimestamp[teamID]; } // get time this area was marked "clear" // hiding spots const HidingSpotList *GetHidingSpotList() const { return &m_hidingSpotList; } @@ -281,7 +277,7 @@ public: void ComputeSpotEncounters(); // compute spot encounter data - for map learning // danger - void IncreaseDanger(int teamID, float amount); // increase the danger of this area for the given team + void IncreaseDanger(int teamID, float amount); // increase the danger of this area for the given team float GetDanger(int teamID); // return the danger of this area (decays over time) float GetSizeX() const { return m_extent.hi.x - m_extent.lo.x; } @@ -324,8 +320,8 @@ public: static bool IsOpenListEmpty(); static CNavArea *PopOpenList(); // remove and return the first element of the open list - bool IsClosed() const; // true if on "closed list" - void AddToClosedList(); // add to the closed list + bool IsClosed() const; // true if on "closed list" + void AddToClosedList(); // add to the closed list void RemoveFromClosedList(); static void ClearSearchLists(); // clears the open and closed lists for a new search @@ -340,10 +336,10 @@ public: void Draw(byte red, byte green, byte blue, int duration = 50); // draw area for debugging & editing void DrawConnectedAreas(); void DrawMarkedCorner(NavCornerType corner, byte red, byte green, byte blue, int duration = 50); - bool SplitEdit(bool splitAlongX, float splitEdge, CNavArea **outAlpha = NULL, CNavArea **outBeta = NULL); // split this area into two areas at the given edge + bool SplitEdit(bool splitAlongX, float splitEdge, CNavArea **outAlpha = nullptr, CNavArea **outBeta = nullptr); // split this area into two areas at the given edge bool MergeEdit(CNavArea *adj); // merge this area and given adjacent area bool SpliceEdit(CNavArea *other); // create a new area between this area and given area - void RaiseCorner(NavCornerType corner, int amount); // raise/lower a corner (or all corners if corner == NUM_CORNERS) + void RaiseCorner(NavCornerType corner, int amount); // raise/lower a corner (or all corners if corner == NUM_CORNERS) // ladders void AddLadderUp(CNavLadder *ladder) { m_ladder[LADDER_UP].push_back(ladder); } @@ -362,14 +358,14 @@ private: friend class CCSBotManager; void Initialize(); // to keep constructors consistent - static bool IMPL(m_isReset); // if true, don't bother cleaning up in destructor since everything is going away + static bool IMPL(m_isReset); // if true, don't bother cleaning up in destructor since everything is going away static unsigned int IMPL(m_nextID); // used to allocate unique IDs - unsigned int m_id; // unique area ID - Extent m_extent; // extents of area in world coords (NOTE: lo.z is not necessarily the minimum Z, but corresponds to Z at point (lo.x, lo.y), etc - Vector m_center; // centroid of area + unsigned int m_id; // unique area ID + Extent m_extent; // extents of area in world coords (NOTE: lo.z is not necessarily the minimum Z, but corresponds to Z at point (lo.x, lo.y), etc + Vector m_center; // centroid of area unsigned char m_attributeFlags; // set of attribute bit flags (see NavAttributeType) - Place m_place; // place descriptor + Place m_place; // place descriptor // height of the implicit corners float m_neZ; @@ -381,7 +377,7 @@ private: float m_clearedTimestamp[MAX_AREA_TEAMS]; // time this area was last "cleared" of enemies // danger - float m_danger[MAX_AREA_TEAMS]; // danger of this area, allowing bots to avoid areas where they died in the past - zero is no danger + float m_danger[MAX_AREA_TEAMS]; // danger of this area, allowing bots to avoid areas where they died in the past - zero is no danger float m_dangerTimestamp[MAX_AREA_TEAMS]; // time when danger value was set - used for decaying void DecayDanger(); @@ -402,29 +398,29 @@ private: // A* pathfinding algorithm static unsigned int IMPL(m_masterMarker); - unsigned int m_marker; // used to flag the area as visited + unsigned int m_marker; // used to flag the area as visited CNavArea *m_parent; // the area just prior to this on in the search path - NavTraverseType m_parentHow; // how we get from parent to us + NavTraverseType m_parentHow; // how we get from parent to us float m_totalCost; // the distance so far plus an estimate of the distance left float m_costSoFar; // distance travelled so far static CNavArea *IMPL(m_openList); - CNavArea *m_nextOpen, *m_prevOpen; // only valid if m_openMarker == m_masterMarker + CNavArea *m_nextOpen, *m_prevOpen; // only valid if m_openMarker == m_masterMarker unsigned int m_openMarker; // if this equals the current marker value, we are on the open list // connections to adjacent areas - NavConnectList m_connect[ NUM_DIRECTIONS ]; // a list of adjacent areas for each direction - NavLadderList m_ladder[ NUM_LADDER_DIRECTIONS ]; // list of ladders leading up and down from this area + NavConnectList m_connect[NUM_DIRECTIONS]; // a list of adjacent areas for each direction + NavLadderList m_ladder[NUM_LADDER_DIRECTIONS]; // list of ladders leading up and down from this area - CNavNode *m_node[ NUM_CORNERS ]; // nav nodes at each corner of the area + CNavNode *m_node[NUM_CORNERS]; // nav nodes at each corner of the area - void FinishMerge(CNavArea *adjArea); // recompute internal data once nodes have been adjusted during merge - void MergeAdjacentConnections(CNavArea *adjArea); // for merging with "adjArea" - pick up all of "adjArea"s connections + void FinishMerge(CNavArea *adjArea); // recompute internal data once nodes have been adjusted during merge + void MergeAdjacentConnections(CNavArea *adjArea); // for merging with "adjArea" - pick up all of "adjArea"s connections void AssignNodes(CNavArea *area); // assign internal nodes to the given area void FinishSplitEdit(CNavArea *newArea, NavDirType ignoreEdge); // given the portion of the original area, update its internal data - NavAreaList m_overlapList; // list of areas that overlap this area - void OnDestroyNotify(CNavArea *dead); // invoked when given area is going away + NavAreaList m_overlapList; // list of areas that overlap this area + void OnDestroyNotify(CNavArea *dead); // invoked when given area is going away CNavArea *m_prevHash, *m_nextHash; // for hash table in CNavAreaGrid }; @@ -438,15 +434,14 @@ inline bool CNavArea::IsDegenerate() const inline CNavArea *CNavArea::GetAdjacentArea(NavDirType dir, int i) const { - NavConnectList::const_iterator iter; - for (iter = m_connect[dir].begin(); iter != m_connect[dir].end(); ++iter) + for (auto &con : m_connect[dir]) { if (i == 0) - return (*iter).area; - --i; + return con.area; + i--; } - return NULL; + return nullptr; } inline bool CNavArea::IsOpen() const @@ -456,7 +451,7 @@ inline bool CNavArea::IsOpen() const inline bool CNavArea::IsOpenListEmpty() { - return (IMPL(m_openList) != NULL) ? false : true; + return (IMPL(m_openList) != nullptr) ? false : true; } inline CNavArea *CNavArea::PopOpenList() @@ -470,7 +465,7 @@ inline CNavArea *CNavArea::PopOpenList() return area; } - return NULL; + return nullptr; } inline bool CNavArea::IsClosed() const @@ -502,10 +497,10 @@ public: void Reset(); // clear the grid to empty void Initialize(float minX, float maxX, float minY, float maxY); // clear and reset the grid to the given extents - void AddNavArea(CNavArea *area); // add an area to the grid - void RemoveNavArea(CNavArea *area); // remove an area from the grid + void AddNavArea(CNavArea *area); // add an area to the grid + void RemoveNavArea(CNavArea *area); // remove an area from the grid unsigned int GetNavAreaCount() const { return m_areaCount; } // return total number of nav areas - CNavArea *GetNavArea(const Vector *pos, float beneathLimt = 120.0f) const; // given a position, return the nav area that IsOverlapping and is *immediately* beneath it + CNavArea *GetNavArea(const Vector *pos, float beneathLimt = 120.0f) const; // given a position, return the nav area that IsOverlapping and is *immediately* beneath it CNavArea *GetNavAreaByID(unsigned int id) const; CNavArea *GetNearestNavArea(const Vector *pos, bool anyZ = false) const; @@ -521,7 +516,7 @@ private: unsigned int m_areaCount; // total number of nav areas enum { HASH_TABLE_SIZE = 256 }; - CNavArea *m_hashTable[HASH_TABLE_SIZE]; // hash table to optimize lookup by ID + CNavArea *m_hashTable[HASH_TABLE_SIZE]; // hash table to optimize lookup by ID inline int ComputeHashKey(unsigned int id) const // returns a hash key for the given nav area ID { return id & 0xFF; @@ -557,7 +552,7 @@ class ShortestPathCost public: float operator()(CNavArea *area, CNavArea *fromArea, const CNavLadder *ladder) { - if (fromArea == NULL) + if (!fromArea) { // first area in path, no cost return 0.0f; @@ -602,36 +597,36 @@ public: // If 'goalPos' is NULL, will use the center of 'goalArea' as the goal position. // Returns true if a path exists. template -bool NavAreaBuildPath(CNavArea *startArea, CNavArea *goalArea, const Vector *goalPos, CostFunctor &costFunc, CNavArea **closestArea = NULL) +bool NavAreaBuildPath(CNavArea *startArea, CNavArea *goalArea, const Vector *goalPos, CostFunctor &costFunc, CNavArea **closestArea = nullptr) { - if (closestArea != NULL) - *closestArea = NULL; + if (closestArea) + *closestArea = nullptr; - if (startArea == NULL) + if (!startArea) return false; // If goalArea is NULL, this function will return the closest area to the goal. // However, if there is also no goal, we can't do anything. - if (goalArea == NULL && goalPos == NULL) + if (!goalArea && !goalPos) { return false; } - startArea->SetParent(NULL); + startArea->SetParent(nullptr); // if we are already in the goal area, build trivial path if (startArea == goalArea) { - goalArea->SetParent(NULL); + goalArea->SetParent(nullptr); - if (closestArea != NULL) + if (closestArea) *closestArea = goalArea; return true; } // determine actual goal position - Vector actualGoalPos = (goalPos != NULL) ? (*goalPos) : (*goalArea->GetCenter()); + Vector actualGoalPos = (goalPos != nullptr) ? (*goalPos) : (*goalArea->GetCenter()); // start search CNavArea::ClearSearchLists(); @@ -640,7 +635,7 @@ bool NavAreaBuildPath(CNavArea *startArea, CNavArea *goalArea, const Vector *goa // TODO: Cost might work as "manhattan distance" startArea->SetTotalCost((*startArea->GetCenter() - actualGoalPos).Length()); - float_precision initCost = costFunc(startArea, NULL, NULL); + float_precision initCost = costFunc(startArea, nullptr, nullptr); if (initCost < 0.0f) return false; @@ -648,7 +643,7 @@ bool NavAreaBuildPath(CNavArea *startArea, CNavArea *goalArea, const Vector *goa startArea->AddToOpenList(); // keep track of the area we visit that is closest to the goal - if (closestArea != NULL) + if (closestArea) *closestArea = startArea; float closestAreaDist = startArea->GetTotalCost(); @@ -662,7 +657,7 @@ bool NavAreaBuildPath(CNavArea *startArea, CNavArea *goalArea, const Vector *goa // check if we have found the goal area if (area == goalArea) { - if (closestArea != NULL) + if (closestArea) *closestArea = goalArea; return true; @@ -672,10 +667,10 @@ bool NavAreaBuildPath(CNavArea *startArea, CNavArea *goalArea, const Vector *goa bool searchFloor = true; int dir = NORTH; const NavConnectList *floorList = area->GetAdjacentList(NORTH); - NavConnectList::const_iterator floorIter = floorList->begin(); + auto floorIter = floorList->begin(); bool ladderUp = true; - const NavLadderList *ladderList = NULL; + const NavLadderList *ladderList = nullptr; NavLadderList::const_iterator ladderIter; enum { @@ -691,7 +686,7 @@ bool NavAreaBuildPath(CNavArea *startArea, CNavArea *goalArea, const Vector *goa { CNavArea *newArea; NavTraverseType how; - const CNavLadder *ladder = NULL; + const CNavLadder *ladder = nullptr; // Get next adjacent area - either on floor or via ladder if (searchFloor) @@ -699,7 +694,7 @@ bool NavAreaBuildPath(CNavArea *startArea, CNavArea *goalArea, const Vector *goa // if exhausted adjacent connections in current direction, begin checking next direction if (floorIter == floorList->end()) { - ++dir; + dir++; if (dir == NUM_DIRECTIONS) { @@ -721,7 +716,7 @@ bool NavAreaBuildPath(CNavArea *startArea, CNavArea *goalArea, const Vector *goa newArea = (*floorIter).area; how = (NavTraverseType)dir; - ++floorIter; + floorIter++; } // search ladders else @@ -750,7 +745,7 @@ bool NavAreaBuildPath(CNavArea *startArea, CNavArea *goalArea, const Vector *goa // cannot use this ladder if the ladder bottom is hanging above our head if (ladder->m_isDangling) { - ++ladderIter; + ladderIter++; continue; } @@ -763,22 +758,22 @@ bool NavAreaBuildPath(CNavArea *startArea, CNavArea *goalArea, const Vector *goa newArea = ladder->m_topRightArea; else { - ++ladderIter; + ladderIter++; continue; } how = GO_LADDER_UP; - ++ladderTopDir; + ladderTopDir++; } else { newArea = (*ladderIter)->m_bottomArea; how = GO_LADDER_DOWN; ladder = (*ladderIter); - ++ladderIter; + ladderIter++; } - if (newArea == NULL) + if (!newArea) continue; } @@ -803,7 +798,7 @@ bool NavAreaBuildPath(CNavArea *startArea, CNavArea *goalArea, const Vector *goa float_precision newCostRemaining = (*newArea->GetCenter() - actualGoalPos).Length(); // track closest area to goal in case path fails - if (closestArea != NULL && newCostRemaining < closestAreaDist) + if (closestArea && newCostRemaining < closestAreaDist) { *closestArea = newArea; closestAreaDist = newCostRemaining; @@ -837,17 +832,17 @@ bool NavAreaBuildPath(CNavArea *startArea, CNavArea *goalArea, const Vector *goa template float_precision NavAreaTravelDistance(CNavArea *startArea, CNavArea *endArea, CostFunctor &costFunc) { - if (startArea == NULL) + if (!startArea) return -1.0f; - if (endArea == NULL) + if (!endArea) return -1.0f; if (startArea == endArea) return 0.0f; // compute path between areas using given cost heuristic - if (NavAreaBuildPath(startArea, endArea, NULL, costFunc) == false) + if (NavAreaBuildPath(startArea, endArea, nullptr, costFunc) == false) return -1.0f; // compute distance along path @@ -864,7 +859,7 @@ float_precision NavAreaTravelDistance(CNavArea *startArea, CNavArea *endArea, Co template float NavAreaTravelDistance(const Vector *startPos, CNavArea *startArea, const Vector *goalPos, CostFunctor &costFunc) { - if (startArea == NULL || startPos == NULL || goalPos == NULL) + if (!startArea || !startPos || !goalPos) return -1.0f; // compute path between areas using given cost heuristic @@ -872,11 +867,11 @@ float NavAreaTravelDistance(const Vector *startPos, CNavArea *startArea, const V if (NavAreaBuildPath(startArea, TheNavAreaGrid.GetNearestNavArea(goalPos), goalPos, costFunc, &goalArea) == false) return -1.0f; - if (goalArea == NULL) + if (!goalArea) return -1.0f; // compute distance along path - if (goalArea->GetParent() == NULL) + if (!goalArea->GetParent()) { return (*goalPos - *startPos).Length(); } @@ -904,7 +899,7 @@ float NavAreaTravelDistance(const Vector *startPos, CNavArea *startArea, const V // helper function inline void AddAreaToOpenList(CNavArea *area, CNavArea *parent, const Vector *startPos, float maxRange) { - if (area == NULL) + if (!area) return; if (!area->IsMarked()) @@ -941,7 +936,7 @@ inline void AddAreaToOpenList(CNavArea *area, CNavArea *parent, const Vector *st template void SearchSurroundingAreas(CNavArea *startArea, const Vector *startPos, Functor &func, float maxRange = -1.0f) { - if (startArea == NULL || startPos == NULL) + if (!startArea || !startPos) return; CNavArea::MakeNewMarker(); @@ -950,7 +945,7 @@ void SearchSurroundingAreas(CNavArea *startArea, const Vector *startPos, Functor startArea->AddToOpenList(); startArea->SetTotalCost(0.0f); startArea->SetCostSoFar(0.0f); - startArea->SetParent(NULL); + startArea->SetParent(nullptr); startArea->Mark(); while (!CNavArea::IsOpenListEmpty()) @@ -962,10 +957,10 @@ void SearchSurroundingAreas(CNavArea *startArea, const Vector *startPos, Functor if (func(area)) { // explore adjacent floor areas - for (int dir = 0; dir < NUM_DIRECTIONS; ++dir) + for (int dir = 0; dir < NUM_DIRECTIONS; dir++) { int count = area->GetAdjacentCount((NavDirType)dir); - for (int i = 0; i < count; ++i) + for (int i = 0; i < count; i++) { CNavArea *adjArea = area->GetAdjacentArea((NavDirType)dir, i); AddAreaToOpenList(adjArea, area, startPos, maxRange); @@ -977,9 +972,9 @@ void SearchSurroundingAreas(CNavArea *startArea, const Vector *startPos, Functor // check up ladders const NavLadderList *ladderList = area->GetLadderList(LADDER_UP); - if (ladderList != NULL) + if (ladderList) { - for (ladderIt = ladderList->begin(); ladderIt != ladderList->end(); ++ladderIt) + for (ladderIt = ladderList->begin(); ladderIt != ladderList->end(); ladderIt++) { const CNavLadder *ladder = *ladderIt; @@ -998,9 +993,9 @@ void SearchSurroundingAreas(CNavArea *startArea, const Vector *startPos, Functor // check down ladders ladderList = area->GetLadderList(LADDER_DOWN); - if (ladderList != NULL) + if (ladderList) { - for (ladderIt = ladderList->begin(); ladderIt != ladderList->end(); ++ladderIt) + for (ladderIt = ladderList->begin(); ladderIt != ladderList->end(); ladderIt++) { const CNavLadder *ladder = *ladderIt; AddAreaToOpenList(ladder->m_bottomArea, area, startPos, maxRange); @@ -1016,7 +1011,7 @@ template bool ForAllAreas(Functor &func) { NavAreaList::iterator iter; - for (iter = TheNavAreaList.begin(); iter != TheNavAreaList.end(); ++iter) + for (iter = TheNavAreaList.begin(); iter != TheNavAreaList.end(); iter++) { CNavArea *area = (*iter); if (func(area) == false) @@ -1073,7 +1068,7 @@ CNavArea *FindMinimumCostArea(CNavArea *startArea, CostFunctor &costFunc) int cheapAreaSetCount = 0; NavAreaList::iterator iter; - for (iter = TheNavAreaList.begin(); iter != TheNavAreaList.end(); ++iter) + for (iter = TheNavAreaList.begin(); iter != TheNavAreaList.end(); iter++) { CNavArea *area = (*iter); @@ -1083,7 +1078,7 @@ CNavArea *FindMinimumCostArea(CNavArea *startArea, CostFunctor &costFunc) continue; // compute cost of this area - float cost = costFunc(area, startArea, NULL); + float cost = costFunc(area, startArea, nullptr); if (cheapAreaSetCount < NUM_CHEAP_AREAS) { @@ -1094,7 +1089,7 @@ CNavArea *FindMinimumCostArea(CNavArea *startArea, CostFunctor &costFunc) { // replace most expensive cost if this is cheaper int expensive = 0; - for (int i = 1; i < NUM_CHEAP_AREAS; ++i) + for (int i = 1; i < NUM_CHEAP_AREAS; i++) { if (cheapAreaSet[i].cost > cheapAreaSet[expensive].cost) expensive = i; @@ -1119,7 +1114,7 @@ CNavArea *FindMinimumCostArea(CNavArea *startArea, CostFunctor &costFunc) int which = RANDOM_LONG(0, numAreas - 1); NavAreaList::iterator iter; - for (iter = TheNavAreaList.begin(); iter != TheNavAreaList.end(); ++iter) + for (iter = TheNavAreaList.begin(); iter != TheNavAreaList.end(); iter++) { if (which-- == 0) break; @@ -1133,8 +1128,8 @@ bool IsHidingSpotInCover(const Vector *spot); void ClassifySniperSpot(HidingSpot *spot); void DestroyHidingSpots(); void EditNavAreas(NavEditCmdType cmd); -bool GetGroundHeight(const Vector *pos, float *height, Vector *normal = NULL); -bool GetSimpleGroundHeight(const Vector *pos, float *height, Vector *normal = NULL); +bool GetGroundHeight(const Vector *pos, float *height, Vector *normal = nullptr); +bool GetSimpleGroundHeight(const Vector *pos, float *height, Vector *normal = nullptr); CNavArea *GetMarkedArea(); void EditNavAreasReset(); void DrawHidingSpots(const CNavArea *area); @@ -1145,7 +1140,7 @@ const Vector *FindNearbyHidingSpot(CBaseEntity *me, const Vector *pos, CNavArea const Vector *FindNearbyRetreatSpot(CBaseEntity *me, const Vector *start, CNavArea *startArea, float maxRange = 1000.0f, int avoidTeam = 0, bool useCrouchAreas = true); // return true if moving from "start" to "finish" will cross a player's line of fire -bool IsCrossingLineOfFire(const Vector &start, const Vector &finish, CBaseEntity *ignore = NULL, int ignoreTeam = 0); +bool IsCrossingLineOfFire(const Vector &start, const Vector &finish, CBaseEntity *ignore = nullptr, int ignoreTeam = 0); const Vector *FindRandomHidingSpot(CBaseEntity *me, Place place, bool isSniper = false); HidingSpot *GetHidingSpotByID(unsigned int id); void ApproachAreaAnalysisPrep(); @@ -1166,5 +1161,3 @@ int BuildArea(CNavNode *node, int width, int height); void BuildLadders(); void MarkJumpAreas(); void GenerateNavigationAreaMesh(); - -#endif // NAV_AREA_H diff --git a/regamedll/game_shared/bot/nav_file.cpp b/regamedll/game_shared/bot/nav_file.cpp index 730ba6f3..ed76acb9 100644 --- a/regamedll/game_shared/bot/nav_file.cpp +++ b/regamedll/game_shared/bot/nav_file.cpp @@ -64,7 +64,7 @@ void PlaceDirectory::AddPlace(Place place) Place PlaceDirectory::EntryToPlace(EntryType entry) const { - if (entry == 0) + if (entry == 0 || !m_directory.size()) return UNDEFINED_PLACE; unsigned int i = entry - 1; @@ -74,14 +74,14 @@ Place PlaceDirectory::EntryToPlace(EntryType entry) const return UNDEFINED_PLACE; } - return m_directory[ i ]; + return m_directory[i]; } void PlaceDirectory::Save(int fd) { // store number of entries in directory EntryType count = (EntryType)m_directory.size(); - Q_write(fd, &count, sizeof(EntryType)); + _write(fd, &count, sizeof(EntryType)); // store entries for (auto id : m_directory) @@ -90,8 +90,8 @@ void PlaceDirectory::Save(int fd) // store string length followed by string itself unsigned short len = (unsigned short)Q_strlen(placeName) + 1; - Q_write(fd, &len, sizeof(unsigned short)); - Q_write(fd, placeName, len); + _write(fd, &len, sizeof(unsigned short)); + _write(fd, placeName, len); } } @@ -106,7 +106,7 @@ void PlaceDirectory::Load(SteamFile *file) // read each entry char placeName[256]; unsigned short len; - for (int i = 0; i < count; ++i) + for (int i = 0; i < count; i++) { file->Read(&len, sizeof(unsigned short)); file->Read(placeName, len); @@ -124,45 +124,45 @@ char *GetBspFilename() void CNavArea::Save(FILE *fp) const { - Q_fprintf(fp, "v %f %f %f\n", m_extent.lo.x, m_extent.lo.y, m_extent.lo.z); - Q_fprintf(fp, "v %f %f %f\n", m_extent.hi.x, m_extent.lo.y, m_neZ); - Q_fprintf(fp, "v %f %f %f\n", m_extent.hi.x, m_extent.hi.y, m_extent.hi.z); - Q_fprintf(fp, "v %f %f %f\n", m_extent.lo.x, m_extent.hi.y, m_swZ); + fprintf(fp, "v %f %f %f\n", m_extent.lo.x, m_extent.lo.y, m_extent.lo.z); + fprintf(fp, "v %f %f %f\n", m_extent.hi.x, m_extent.lo.y, m_neZ); + fprintf(fp, "v %f %f %f\n", m_extent.hi.x, m_extent.hi.y, m_extent.hi.z); + fprintf(fp, "v %f %f %f\n", m_extent.lo.x, m_extent.hi.y, m_swZ); static int base = 1; - Q_fprintf(fp, "\n\ng %04dArea%s%s%s%s\n", m_id, + fprintf(fp, "\n\ng %04dArea%s%s%s%s\n", m_id, (GetAttributes() & NAV_CROUCH) ? "CROUCH" : "", (GetAttributes() & NAV_JUMP) ? "JUMP" : "", (GetAttributes() & NAV_PRECISE) ? "PRECISE" : "", (GetAttributes() & NAV_NO_JUMP) ? "NO_JUMP" : ""); - Q_fprintf(fp, "f %d %d %d %d\n\n", base, base + 1, base + 2, base + 3); + fprintf(fp, "f %d %d %d %d\n\n", base, base + 1, base + 2, base + 3); base += 4; } void CNavArea::Save(int fd, unsigned int version) { // save ID - Q_write(fd, &m_id, sizeof(unsigned int)); + _write(fd, &m_id, sizeof(unsigned int)); // save attribute flags - Q_write(fd, &m_attributeFlags, sizeof(unsigned char)); + _write(fd, &m_attributeFlags, sizeof(unsigned char)); // save extent of area - Q_write(fd, &m_extent, 6 * sizeof(float)); + _write(fd, &m_extent, 6 * sizeof(float)); // save heights of implicit corners - Q_write(fd, &m_neZ, sizeof(float)); - Q_write(fd, &m_swZ, sizeof(float)); + _write(fd, &m_neZ, sizeof(float)); + _write(fd, &m_swZ, sizeof(float)); // save connections to adjacent areas // in the enum order NORTH, EAST, SOUTH, WEST - for (int d = 0; d < NUM_DIRECTIONS; ++d) + for (int d = 0; d < NUM_DIRECTIONS; d++) { // save number of connections for this direction size_t count = m_connect[d].size(); - Q_write(fd, &count, sizeof(size_t)); + _write(fd, &count, sizeof(size_t)); for (auto connect : m_connect[d]) { - Q_write(fd, &connect.area->m_id, sizeof(unsigned int)); + _write(fd, &connect.area->m_id, sizeof(unsigned int)); } } @@ -178,7 +178,7 @@ void CNavArea::Save(int fd, unsigned int version) count = (unsigned char)m_hidingSpotList.size(); } - Q_write(fd, &count, sizeof(unsigned char)); + _write(fd, &count, sizeof(unsigned char)); // store HidingSpot objects unsigned int saveCount = 0; @@ -193,7 +193,7 @@ void CNavArea::Save(int fd, unsigned int version) // Save the approach areas for this area // save number of approach areas - Q_write(fd, &m_approachCount, sizeof(unsigned char)); + _write(fd, &m_approachCount, sizeof(unsigned char)); if (cv_bot_debug.value > 0.0f) { @@ -203,35 +203,35 @@ void CNavArea::Save(int fd, unsigned int version) // save approach area info unsigned char type; unsigned int zero = 0; - for (int a = 0; a < m_approachCount; ++a) + for (int a = 0; a < m_approachCount; a++) { if (m_approach[a].here.area) - Q_write(fd, &m_approach[a].here.area->m_id, sizeof(unsigned int)); + _write(fd, &m_approach[a].here.area->m_id, sizeof(unsigned int)); else - Q_write(fd, &zero, sizeof(unsigned int)); + _write(fd, &zero, sizeof(unsigned int)); if (m_approach[a].prev.area) - Q_write(fd, &m_approach[a].prev.area->m_id, sizeof(unsigned int)); + _write(fd, &m_approach[a].prev.area->m_id, sizeof(unsigned int)); else - Q_write(fd, &zero, sizeof(unsigned int)); + _write(fd, &zero, sizeof(unsigned int)); type = (unsigned char)m_approach[a].prevToHereHow; - Q_write(fd, &type, sizeof(unsigned char)); + _write(fd, &type, sizeof(unsigned char)); if (m_approach[a].next.area) - Q_write(fd, &m_approach[a].next.area->m_id, sizeof(unsigned int)); + _write(fd, &m_approach[a].next.area->m_id, sizeof(unsigned int)); else - Q_write(fd, &zero, sizeof(unsigned int)); + _write(fd, &zero, sizeof(unsigned int)); type = (unsigned char)m_approach[a].hereToNextHow; - Q_write(fd, &type, sizeof(unsigned char)); + _write(fd, &type, sizeof(unsigned char)); } // Save encounter spots for this area { // save number of encounter paths for this area unsigned int count = m_spotEncounterList.size(); - Q_write(fd, &count, sizeof(unsigned int)); + _write(fd, &count, sizeof(unsigned int)); if (cv_bot_debug.value > 0.0f) CONSOLE_ECHO(" m_spotEncounterList.size() = %d\n", count); @@ -239,20 +239,20 @@ void CNavArea::Save(int fd, unsigned int version) for (auto spote : m_spotEncounterList) { if (spote.from.area) - Q_write(fd, &spote.from.area->m_id, sizeof(unsigned int)); + _write(fd, &spote.from.area->m_id, sizeof(unsigned int)); else - Q_write(fd, &zero, sizeof(unsigned int)); + _write(fd, &zero, sizeof(unsigned int)); unsigned char dir = spote.fromDir; - Q_write(fd, &dir, sizeof(unsigned char)); + _write(fd, &dir, sizeof(unsigned char)); if (spote.to.area) - Q_write(fd, &spote.to.area->m_id, sizeof(unsigned int)); + _write(fd, &spote.to.area->m_id, sizeof(unsigned int)); else - Q_write(fd, &zero, sizeof(unsigned int)); + _write(fd, &zero, sizeof(unsigned int)); dir = spote.toDir; - Q_write(fd, &dir, sizeof(unsigned char)); + _write(fd, &dir, sizeof(unsigned char)); // write list of spots along this path unsigned char spotCount; @@ -265,17 +265,17 @@ void CNavArea::Save(int fd, unsigned int version) { spotCount = (unsigned char)spote.spotList.size(); } - Q_write(fd, &spotCount, sizeof(unsigned char)); + _write(fd, &spotCount, sizeof(unsigned char)); saveCount = 0; for (auto order : spote.spotList) { // order->spot may be NULL if we've loaded a nav mesh that has been edited but not re-analyzed unsigned int id = (order.spot) ? order.spot->GetID() : 0; - Q_write(fd, &id, sizeof(unsigned int)); + _write(fd, &id, sizeof(unsigned int)); unsigned char t = 255 * order.t; - Q_write(fd, &t, sizeof(unsigned char)); + _write(fd, &t, sizeof(unsigned char)); // overflow check if (++saveCount == spotCount) @@ -286,7 +286,7 @@ void CNavArea::Save(int fd, unsigned int version) // store place dictionary entry PlaceDirectory::EntryType entry = placeDirectory.GetEntry(GetPlace()); - Q_write(fd, &entry, sizeof(entry)); + _write(fd, &entry, sizeof(entry)); } void CNavArea::Load(SteamFile *file, unsigned int version) @@ -314,13 +314,13 @@ void CNavArea::Load(SteamFile *file, unsigned int version) // load connections (IDs) to adjacent areas // in the enum order NORTH, EAST, SOUTH, WEST - for (int d = 0; d < NUM_DIRECTIONS; ++d) + for (int d = 0; d < NUM_DIRECTIONS; d++) { // load number of connections for this direction unsigned int count; file->Read(&count, sizeof(unsigned int)); - for (unsigned int i = 0; i < count; ++i) + for (unsigned int i = 0; i < count; i++) { NavConnect connect; file->Read(&connect.id, sizeof(unsigned int)); @@ -338,7 +338,7 @@ void CNavArea::Load(SteamFile *file, unsigned int version) { // load simple vector array Vector pos; - for (int h = 0; h < hidingSpotCount; ++h) + for (int h = 0; h < hidingSpotCount; h++) { file->Read(&pos, 3 * sizeof(float)); @@ -351,7 +351,7 @@ void CNavArea::Load(SteamFile *file, unsigned int version) else { // load HidingSpot objects for this area - for (int h = 0; h < hidingSpotCount; ++h) + for (int h = 0; h < hidingSpotCount; h++) { // create new hiding spot and put on master list HidingSpot *spot = new HidingSpot; @@ -367,7 +367,7 @@ void CNavArea::Load(SteamFile *file, unsigned int version) // load approach area info (IDs) unsigned char type; - for (int a = 0; a < m_approachCount; ++a) + for (int a = 0; a < m_approachCount; a++) { file->Read(&m_approach[a].here.id, sizeof(unsigned int)); @@ -387,7 +387,7 @@ void CNavArea::Load(SteamFile *file, unsigned int version) if (version < 3) { // old data, read and discard - for (unsigned int e = 0; e < count; ++e) + for (unsigned int e = 0; e < count; e++) { SpotEncounter encounter; @@ -401,7 +401,7 @@ void CNavArea::Load(SteamFile *file, unsigned int version) unsigned char spotCount; file->Read(&spotCount, sizeof(unsigned char)); - for (int s = 0; s < spotCount; ++s) + for (int s = 0; s < spotCount; s++) { Vector pos; file->Read(&pos, 3 * sizeof(float)); @@ -412,7 +412,7 @@ void CNavArea::Load(SteamFile *file, unsigned int version) return; } - for (unsigned int e = 0; e < count; ++e) + for (unsigned int e = 0; e < count; e++) { SpotEncounter encounter; @@ -432,7 +432,7 @@ void CNavArea::Load(SteamFile *file, unsigned int version) file->Read(&spotCount, sizeof(unsigned char)); SpotOrder order; - for (int s = 0; s < spotCount; ++s) + for (int s = 0; s < spotCount; s++) { file->Read(&order.id, sizeof(unsigned int)); @@ -463,13 +463,13 @@ NavErrorType CNavArea::PostLoad() NavErrorType error = NAV_OK; // connect areas together - for (int d = 0; d < NUM_DIRECTIONS; ++d) + for (int d = 0; d < NUM_DIRECTIONS; d++) { for (auto& connect : m_connect[d]) { auto id = connect.id; connect.area = TheNavAreaGrid.GetNavAreaByID(id); - if (id && connect.area == NULL) + if (id && !connect.area) { CONSOLE_ECHO("ERROR: Corrupt navigation data. Cannot connect Navigation Areas.\n"); error = NAV_CORRUPT_DATA; @@ -478,24 +478,24 @@ NavErrorType CNavArea::PostLoad() } // resolve approach area IDs - for (int a = 0; a < m_approachCount; ++a) + for (int a = 0; a < m_approachCount; a++) { m_approach[a].here.area = TheNavAreaGrid.GetNavAreaByID(m_approach[a].here.id); - if (m_approach[a].here.id && m_approach[a].here.area == NULL) + if (m_approach[a].here.id && !m_approach[a].here.area) { CONSOLE_ECHO("ERROR: Corrupt navigation data. Missing Approach Area (here).\n"); error = NAV_CORRUPT_DATA; } m_approach[a].prev.area = TheNavAreaGrid.GetNavAreaByID(m_approach[a].prev.id); - if (m_approach[a].prev.id && m_approach[a].prev.area == NULL) + if (m_approach[a].prev.id && !m_approach[a].prev.area) { CONSOLE_ECHO("ERROR: Corrupt navigation data. Missing Approach Area (prev).\n"); error = NAV_CORRUPT_DATA; } m_approach[a].next.area = TheNavAreaGrid.GetNavAreaByID(m_approach[a].next.id); - if (m_approach[a].next.id && m_approach[a].next.area == NULL) + if (m_approach[a].next.id && !m_approach[a].next.area) { CONSOLE_ECHO("ERROR: Corrupt navigation data. Missing Approach Area (next).\n"); error = NAV_CORRUPT_DATA; @@ -506,14 +506,14 @@ NavErrorType CNavArea::PostLoad() for (auto& spote : m_spotEncounterList) { spote.from.area = TheNavAreaGrid.GetNavAreaByID(spote.from.id); - if (spote.from.area == NULL) + if (!spote.from.area) { CONSOLE_ECHO("ERROR: Corrupt navigation data. Missing \"from\" Navigation Area for Encounter Spot.\n"); error = NAV_CORRUPT_DATA; } spote.to.area = TheNavAreaGrid.GetNavAreaByID(spote.to.id); - if (spote.to.area == NULL) + if (!spote.to.area) { CONSOLE_ECHO("ERROR: Corrupt navigation data. Missing \"to\" Navigation Area for Encounter Spot.\n"); error = NAV_CORRUPT_DATA; @@ -535,7 +535,7 @@ NavErrorType CNavArea::PostLoad() for (auto& order : spote.spotList) { order.spot = GetHidingSpotByID(order.id); - if (order.spot == NULL) + if (!order.spot) { CONSOLE_ECHO("ERROR: Corrupt navigation data. Missing Hiding Spot\n"); error = NAV_CORRUPT_DATA; @@ -557,34 +557,14 @@ NavErrorType CNavArea::PostLoad() return error; } -// Changes all '/' characters into '\' characters, in place. -inline void COM_FixSlashes(char *pname) -{ -#ifdef _WIN32 - while (*pname) - { - if (*pname == '/') - *pname = '\\'; - pname++; - } -#else - while (*pname) - { - if (*pname == '\\') - *pname = '/'; - pname++; - } -#endif // _WIN32 -} - // Store AI navigation data to a file bool SaveNavigationMap(const char *filename) { - if (filename == NULL) + if (!filename) return false; // Store the NAV file - COM_FixSlashes(const_cast(filename)); + Q_FixSlashes(const_cast(filename)); #ifdef WIN32 int fd = _open(filename, _O_BINARY | _O_CREAT | _O_WRONLY, _S_IREAD | _S_IWRITE); @@ -597,22 +577,22 @@ bool SaveNavigationMap(const char *filename) // store "magic number" to help identify this kind of file unsigned int magic = NAV_MAGIC_NUMBER; - Q_write(fd, &magic, sizeof(unsigned int)); + _write(fd, &magic, sizeof(unsigned int)); // store version number of file unsigned int version = NAV_VERSION; - Q_write(fd, &version, sizeof(unsigned int)); + _write(fd, &version, sizeof(unsigned int)); // get size of source bsp file and store it in the nav file // so we can test if the bsp changed since the nav file was made char *bspFilename = GetBspFilename(); - if (bspFilename == NULL) + if (!bspFilename) return false; unsigned int bspSize = (unsigned int)GET_FILE_SIZE(bspFilename); CONSOLE_ECHO("Size of bsp file '%s' is %u bytes.\n", bspFilename, bspSize); - Q_write(fd, &bspSize, sizeof(unsigned int)); + _write(fd, &bspSize, sizeof(unsigned int)); // Build a directory of the Places in this map placeDirectory.Reset(); @@ -630,28 +610,14 @@ bool SaveNavigationMap(const char *filename) // Store navigation areas // store number of areas unsigned int count = TheNavAreaList.size(); - Q_write(fd, &count, sizeof(unsigned int)); + _write(fd, &count, sizeof(unsigned int)); // store each area for (auto area : TheNavAreaList) { area->Save(fd, version); } - Q_close(fd); - -/*#if defined(_WIN32) && !defined(REGAMEDLL_FIXES) - // output a simple Wavefront file to visualize the generated areas in 3DSMax - FILE *fp = Q_fopen("c:\\tmp\\nav.obj", "w"); - if (fp) - { - for (auto area : TheNavAreaList) { - area->Save(fd); - } - - Q_fclose(fp); - } -#endif // _WIN32 && !REGAMEDLL_FIXES*/ - + _close(fd); return true; } @@ -676,32 +642,32 @@ void LoadLocationFile(const char *filename) CONSOLE_ECHO("Loading legacy 'location file' '%s'\n", locFilename); // read directory - locData = MP_COM_Parse(locData); - int dirSize = Q_atoi(MP_COM_GetToken()); + locData = SharedParse(locData); + int dirSize = Q_atoi(SharedGetToken()); if (dirSize) { std::vector directory; directory.reserve(dirSize); - for (int i = 0; i < dirSize; ++i) + for (int i = 0; i < dirSize; i++) { - locData = MP_COM_Parse(locData); - directory.push_back(TheBotPhrases->NameToID(MP_COM_GetToken())); + locData = SharedParse(locData); + directory.push_back(TheBotPhrases->NameToID(SharedGetToken())); } // read places for each nav area unsigned int areaID, locDirIndex; while (true) { - locData = MP_COM_Parse(locData); - if (locData == NULL) + locData = SharedParse(locData); + if (!locData) break; - areaID = Q_atoi(MP_COM_GetToken()); + areaID = Q_atoi(SharedGetToken()); - locData = MP_COM_Parse(locData); - locDirIndex = Q_atoi(MP_COM_GetToken()); + locData = SharedParse(locData); + locDirIndex = Q_atoi(SharedGetToken()); CNavArea *area = TheNavAreaGrid.GetNavAreaByID(areaID); unsigned int place = (locDirIndex > 0) ? directory[locDirIndex - 1] : UNDEFINED_PLACE; @@ -767,7 +733,7 @@ void SanityCheckNavigationMap(const char *mapName) navFile.Read(&saveBspSize, sizeof(unsigned int)); // verify size - if (bspFilename == NULL) + if (!bspFilename) { CONSOLE_ECHO("ERROR: No map corresponds to navigation file %s.\n", navFilename); return; @@ -834,7 +800,7 @@ NavErrorType LoadNavigationMap() // verify size char *bspFilename = GetBspFilename(); - if (bspFilename == NULL) + if (!bspFilename) return NAV_INVALID_FILE; unsigned int bspSize = (unsigned int)GET_FILE_SIZE(bspFilename); @@ -866,7 +832,7 @@ NavErrorType LoadNavigationMap() extent.hi.y = -9999999999.9f; // load the areas and compute total extent - for (unsigned int i = 0; i < count; ++i) + for (unsigned int i = 0; i < count; i++) { CNavArea *area = new CNavArea; area->Load(&navFile, version); diff --git a/regamedll/game_shared/bot/nav_file.h b/regamedll/game_shared/bot/nav_file.h index 489c4dc5..a6c44c83 100644 --- a/regamedll/game_shared/bot/nav_file.h +++ b/regamedll/game_shared/bot/nav_file.h @@ -26,11 +26,7 @@ * */ -#ifndef NAV_FILE_H -#define NAV_FILE_H -#ifdef _WIN32 #pragma once -#endif // The 'place directory' is used to save and load places from // nav files in a size-efficient manner that also allows for the @@ -47,23 +43,18 @@ public: typedef unsigned short EntryType; void Reset(); - bool IsKnown(Place place) const; // return true if this place is already in the directory + bool IsKnown(Place place) const; // return true if this place is already in the directory EntryType GetEntry(Place place) const; // return the directory entry corresponding to this Place (0 = no entry) - void AddPlace(Place place); // add the place to the directory if not already known + void AddPlace(Place place); // add the place to the directory if not already known Place EntryToPlace(EntryType entry) const; // given an entry, return the Place - void Save(int fd); // store the directory - void Load(SteamFile *file); // load the directory + void Save(int fd); // store the directory + void Load(SteamFile *file); // load the directory private: std::vector m_directory; }; -extern char *MP_COM_GetToken(); -extern char *MP_COM_Parse(char *data); - bool SaveNavigationMap(const char *filename); void LoadLocationFile(const char *filename); void SanityCheckNavigationMap(const char *mapName); // Performs a lightweight sanity-check of the specified map's nav mesh NavErrorType LoadNavigationMap(); - -#endif // NAV_FILE_H diff --git a/regamedll/game_shared/bot/nav_node.cpp b/regamedll/game_shared/bot/nav_node.cpp index accb75af..81eaf6dd 100644 --- a/regamedll/game_shared/bot/nav_node.cpp +++ b/regamedll/game_shared/bot/nav_node.cpp @@ -5,9 +5,9 @@ */ #ifndef HOOK_GAMEDLL -NavDirType Opposite[ NUM_DIRECTIONS ] = { SOUTH, WEST, NORTH, EAST }; +NavDirType Opposite[NUM_DIRECTIONS] = { SOUTH, WEST, NORTH, EAST }; -CNavNode *CNavNode::m_list = NULL; +CNavNode *CNavNode::m_list = nullptr; unsigned int CNavNode::m_listLength = 0; #endif @@ -22,8 +22,8 @@ CNavNode::CNavNode(const Vector *pos, const Vector *normal, CNavNode *parent) static unsigned int nextID = 1; m_id = nextID++; - for (int i = 0; i < NUM_DIRECTIONS; ++i) - m_to[i] = NULL; + for (int i = 0; i < NUM_DIRECTIONS; i++) + m_to[i] = nullptr; m_visited = 0; m_parent = parent; @@ -33,7 +33,7 @@ CNavNode::CNavNode(const Vector *pos, const Vector *normal, CNavNode *parent) IMPL(m_listLength)++; m_isCovered = FALSE; - m_area = NULL; + m_area = nullptr; m_attributeFlags = 0; } @@ -41,7 +41,7 @@ CNavNode::CNavNode(const Vector *pos, const Vector *normal, CNavNode *parent) // Create a connection FROM this node TO the given node, in the given direction void CNavNode::ConnectTo(CNavNode *node, NavDirType dir) { - m_to[ dir ] = node; + m_to[dir] = node; } // Return node at given position @@ -50,7 +50,7 @@ const CNavNode *CNavNode::GetNode(const Vector *pos) { const float tolerance = 0.45f * GenerationStepSize; - for (const CNavNode *node = IMPL(m_list); node != NULL; node = node->m_next) + for (const CNavNode *node = IMPL(m_list); node; node = node->m_next) { float dx = ABS(node->m_pos.x - pos->x); float dy = ABS(node->m_pos.y - pos->y); @@ -60,14 +60,14 @@ const CNavNode *CNavNode::GetNode(const Vector *pos) return node; } - return NULL; + return nullptr; } // Return true if this node is bidirectionally linked to // another node in the given direction BOOL CNavNode::IsBiLinked(NavDirType dir) const { - if (m_to[ dir ] && m_to[ dir ]->m_to[ Opposite[dir] ] == this) + if (m_to[dir] && m_to[dir]->m_to[Opposite[dir]] == this) return true; return false; @@ -77,8 +77,8 @@ BOOL CNavNode::IsBiLinked(NavDirType dir) const // that are all bidirectionally linked BOOL CNavNode::IsClosedCell() const { - if (IsBiLinked( SOUTH ) && IsBiLinked( EAST ) && m_to[ EAST ]->IsBiLinked( SOUTH ) && m_to[ SOUTH ]->IsBiLinked( EAST ) - && m_to[ EAST ]->m_to[ SOUTH ] == m_to[ SOUTH ]->m_to[ EAST ]) + if (IsBiLinked(SOUTH) && IsBiLinked(EAST) && m_to[EAST]->IsBiLinked(SOUTH) && m_to[SOUTH]->IsBiLinked(EAST) + && m_to[EAST]->m_to[SOUTH] == m_to[SOUTH]->m_to[EAST]) return true; return false; diff --git a/regamedll/game_shared/bot/nav_node.h b/regamedll/game_shared/bot/nav_node.h index 79cbed79..36f8c1a5 100644 --- a/regamedll/game_shared/bot/nav_node.h +++ b/regamedll/game_shared/bot/nav_node.h @@ -26,16 +26,12 @@ * */ -#ifndef NAV_NODE_H -#define NAV_NODE_H -#ifdef _WIN32 #pragma once -#endif class CNavNode { public: - CNavNode(const Vector *pos, const Vector *normal, CNavNode *parent = NULL); + CNavNode(const Vector *pos, const Vector *normal, CNavNode *parent = nullptr); // return navigation node at the position, or NULL if none exists static const CNavNode *GetNode(const Vector *pos); @@ -128,5 +124,3 @@ inline CNavArea *CNavNode::GetArea() const { return m_area; } - -#endif // NAV_NODE_H diff --git a/regamedll/game_shared/bot/nav_path.cpp b/regamedll/game_shared/bot/nav_path.cpp index 2dc02560..041b7db0 100644 --- a/regamedll/game_shared/bot/nav_path.cpp +++ b/regamedll/game_shared/bot/nav_path.cpp @@ -8,18 +8,18 @@ bool CNavPath::ComputePathPositions() // start in first area's center m_path[0].pos = *m_path[0].area->GetCenter(); - m_path[0].ladder = NULL; + m_path[0].ladder = nullptr; m_path[0].how = NUM_TRAVERSE_TYPES; - for (int i = 1; i < m_segmentCount; ++i) + for (int i = 1; i < m_segmentCount; i++) { const PathSegment *from = &m_path[i - 1]; - PathSegment *to = &m_path[ i ]; + PathSegment *to = &m_path[i]; // walk along the floor to the next area if (to->how <= GO_WEST) { - to->ladder = NULL; + to->ladder = nullptr; // compute next point, keeping path as straight as possible from->area->ComputeClosestPointInPortal(to->area, (NavDirType)to->how, &from->pos, &to->pos); @@ -49,14 +49,14 @@ bool CNavPath::ComputePathPositions() if (m_segmentCount < MAX_PATH_SEGMENTS - 1) { // copy nodes down - for (int j = m_segmentCount; j > i; --j) + for (int j = m_segmentCount; j > i; j--) m_path[j] = m_path[j - 1]; // path is one node longer - ++m_segmentCount; + m_segmentCount++; // move index ahead into the new node we just duplicated - ++i; + i++; m_path[i].pos.x = to->pos.x + pushDist * dir.x; m_path[i].pos.y = to->pos.y + pushDist * dir.y; @@ -72,7 +72,7 @@ bool CNavPath::ComputePathPositions() // find our ladder const NavLadderList *list = from->area->GetLadderList(LADDER_UP); NavLadderList::const_iterator iter; - for (iter = list->begin(); iter != list->end(); ++iter) + for (iter = list->begin(); iter != list->end(); iter++) { CNavLadder *ladder = (*iter); @@ -98,7 +98,7 @@ bool CNavPath::ComputePathPositions() // find our ladder const NavLadderList *list = from->area->GetLadderList(LADDER_DOWN); NavLadderList::const_iterator iter; - for (iter = list->begin(); iter != list->end(); ++iter) + for (iter = list->begin(); iter != list->end(); iter++) { CNavLadder *ladder = (*iter); @@ -135,7 +135,7 @@ bool CNavPath::IsAtEnd(const Vector &pos) const float CNavPath::GetLength() const { float length = 0.0f; - for (int i = 1; i < GetSegmentCount(); ++i) + for (int i = 1; i < GetSegmentCount(); i++) { length += (m_path[i].pos - m_path[i - 1].pos).Length(); } @@ -147,7 +147,7 @@ float CNavPath::GetLength() const // TODO: Be careful of returning "positions" along one-way drops, ladders, etc. NOXREF bool CNavPath::GetPointAlongPath(float distAlong, Vector *pointOnPath) const { - if (!IsValid() || pointOnPath == NULL) + if (!IsValid() || !pointOnPath) return false; if (distAlong <= 0.0f) @@ -159,7 +159,7 @@ NOXREF bool CNavPath::GetPointAlongPath(float distAlong, Vector *pointOnPath) co float lengthSoFar = 0.0f; float segmentLength; Vector dir; - for (int i = 1; i < GetSegmentCount(); ++i) + for (int i = 1; i < GetSegmentCount(); i++) { dir = m_path[i].pos - m_path[i - 1].pos; segmentLength = dir.Length(); @@ -178,7 +178,7 @@ NOXREF bool CNavPath::GetPointAlongPath(float distAlong, Vector *pointOnPath) co lengthSoFar += segmentLength; } - *pointOnPath = m_path[ GetSegmentCount() - 1 ].pos; + *pointOnPath = m_path[GetSegmentCount() - 1].pos; return true; } @@ -195,7 +195,7 @@ int CNavPath::GetSegmentIndexAlongPath(float distAlong) const float lengthSoFar = 0.0f; Vector dir; - for (int i = 1; i < GetSegmentCount(); ++i) + for (int i = 1; i < GetSegmentCount(); i++) { lengthSoFar += (m_path[i].pos - m_path[i - 1].pos).Length(); @@ -212,7 +212,7 @@ int CNavPath::GetSegmentIndexAlongPath(float distAlong) const // NOTE: This does not do line-of-sight tests, so closest point may be thru the floor, etc NOXREF bool CNavPath::FindClosestPointOnPath(const Vector *worldPos, int startIndex, int endIndex, Vector *close) const { - if (!IsValid() || close == NULL) + if (!IsValid() || !close) return false; Vector along, toWorldPos; @@ -223,7 +223,7 @@ NOXREF bool CNavPath::FindClosestPointOnPath(const Vector *worldPos, int startIn float closeDistSq = 9999999999.9; float distSq; - for (int i = startIndex; i <= endIndex; ++i) + for (int i = startIndex; i <= endIndex; i++) { from = &m_path[i - 1].pos; to = &m_path[i].pos; @@ -267,11 +267,11 @@ bool CNavPath::BuildTrivialPath(const Vector *start, const Vector *goal) m_segmentCount = 0; CNavArea *startArea = TheNavAreaGrid.GetNearestNavArea(start); - if (startArea == NULL) + if (!startArea) return false; CNavArea *goalArea = TheNavAreaGrid.GetNearestNavArea(goal); - if (goalArea == NULL) + if (!goalArea) return false; m_segmentCount = 2; @@ -280,14 +280,14 @@ bool CNavPath::BuildTrivialPath(const Vector *start, const Vector *goal) m_path[0].pos.x = start->x; m_path[0].pos.y = start->y; m_path[0].pos.z = startArea->GetZ(start); - m_path[0].ladder = NULL; + m_path[0].ladder = nullptr; m_path[0].how = NUM_TRAVERSE_TYPES; m_path[1].area = goalArea; m_path[1].pos.x = goal->x; m_path[1].pos.y = goal->y; m_path[1].pos.z = goalArea->GetZ(goal); - m_path[1].ladder = NULL; + m_path[1].ladder = nullptr; m_path[1].how = NUM_TRAVERSE_TYPES; return true; @@ -299,7 +299,7 @@ void CNavPath::Draw() if (!IsValid()) return; - for (int i = 1; i < m_segmentCount; ++i) + for (int i = 1; i < m_segmentCount; i++) { UTIL_DrawBeamPoints(m_path[i - 1].pos + Vector(0, 0, HalfHumanHeight), m_path[i].pos + Vector(0, 0, HalfHumanHeight), 2, 255, 75, 0); } @@ -310,28 +310,28 @@ void CNavPath::Draw() int CNavPath::FindNextOccludedNode(int anchor_) { int lastVisible = anchor_; - for (int i = anchor_ + 1; i < m_segmentCount; ++i) + for (int i = anchor_ + 1; i < m_segmentCount; i++) { // don't remove ladder nodes if (m_path[i].ladder) return i; - if (!IsWalkableTraceLineClear(m_path[ anchor_ ].pos, m_path[ i ].pos)) + if (!IsWalkableTraceLineClear(m_path[anchor_].pos, m_path[i].pos)) { // cant see this node from anchor node return i; } - Vector anchorPlusHalf = m_path[ anchor_ ].pos + Vector(0, 0, HalfHumanHeight); - Vector iPlusHalf = m_path[ i ].pos + Vector(0, 0, HalfHumanHeight); + Vector anchorPlusHalf = m_path[anchor_].pos + Vector(0, 0, HalfHumanHeight); + Vector iPlusHalf = m_path[i].pos + Vector(0, 0, HalfHumanHeight); if (!IsWalkableTraceLineClear(anchorPlusHalf, iPlusHalf)) { // cant see this node from anchor node return i; } - Vector anchorPlusFull = m_path[ anchor_ ].pos + Vector(0, 0, HumanHeight); - Vector iPlusFull = m_path[ i ].pos + Vector(0, 0, HumanHeight); + Vector anchorPlusFull = m_path[anchor_].pos + Vector(0, 0, HumanHeight); + Vector iPlusFull = m_path[i].pos + Vector(0, 0, HumanHeight); if (!IsWalkableTraceLineClear(anchorPlusFull, iPlusFull)) { // cant see this node from anchor node @@ -362,7 +362,7 @@ void CNavPath::Optimize() int removeCount = nextAnchor - anchor_ - 1; if (removeCount > 0) { - for (int i = nextAnchor; i < m_segmentCount; ++i) + for (int i = nextAnchor; i < m_segmentCount; i++) { m_path[i - removeCount] = m_path[i]; } @@ -370,15 +370,15 @@ void CNavPath::Optimize() } } - ++anchor_; + anchor_++; } #endif } CNavPathFollower::CNavPathFollower() { - m_improv = NULL; - m_path = NULL; + m_improv = nullptr; + m_path = nullptr; m_segmentIndex = 0; m_isLadderStarted = false; @@ -397,12 +397,12 @@ void CNavPathFollower::Reset() // Move improv along path void CNavPathFollower::Update(float deltaT, bool avoidObstacles) { - if (m_path == NULL || m_path->IsValid() == false) + if (!m_path || m_path->IsValid() == false) return; const CNavPath::PathSegment *node = (*m_path)[m_segmentIndex]; - if (node == NULL) + if (!node) { m_improv->OnMoveToFailure(m_path->GetEndpoint(), IImprovEvent::FAIL_INVALID_PATH); m_path->Invalidate(); @@ -412,8 +412,8 @@ void CNavPathFollower::Update(float deltaT, bool avoidObstacles) // handle ladders if (node->ladder) { - const Vector *approachPos = NULL; - const Vector *departPos = NULL; + const Vector *approachPos = nullptr; + const Vector *departPos = nullptr; if (m_segmentIndex) approachPos = &(*m_path)[m_segmentIndex - 1]->pos; @@ -432,7 +432,7 @@ void CNavPathFollower::Update(float deltaT, bool avoidObstacles) if (m_improv->TraverseLadder(node->ladder, node->how, approachPos, departPos, deltaT)) { // completed ladder - ++m_segmentIndex; + m_segmentIndex++; } return; @@ -445,7 +445,7 @@ void CNavPathFollower::Update(float deltaT, bool avoidObstacles) const float closeRange = 20.0f; if ((m_improv->GetFeet() - node->pos).IsLengthLessThan(closeRange)) { - ++m_segmentIndex; + m_segmentIndex++; if (m_segmentIndex >= m_path->GetSegmentCount()) { @@ -469,7 +469,7 @@ void CNavPathFollower::Update(float deltaT, bool avoidObstacles) { // because hostage crouching is not really supported by the engine, // if we are standing in a crouch area, we must crouch to avoid collisions - if (m_improv->GetLastKnownArea() != NULL && (m_improv->GetLastKnownArea()->GetAttributes() & NAV_CROUCH) && !(m_improv->GetLastKnownArea()->GetAttributes() & NAV_JUMP)) + if (m_improv->GetLastKnownArea() && (m_improv->GetLastKnownArea()->GetAttributes() & NAV_CROUCH) && !(m_improv->GetLastKnownArea()->GetAttributes() & NAV_JUMP)) { m_improv->Crouch(); } @@ -478,7 +478,7 @@ void CNavPathFollower::Update(float deltaT, bool avoidObstacles) // if there are no crouch areas coming up, stand const float crouchRange = 50.0f; bool didCrouch = false; - for (int i = m_segmentIndex; i < m_path->GetSegmentCount(); ++i) + for (int i = m_segmentIndex; i < m_path->GetSegmentCount(); i++) { const CNavArea *to = (*m_path)[i]->area; @@ -616,7 +616,7 @@ int CNavPathFollower::FindOurPositionOnPath(Vector *close, bool local) const end = m_path->GetSegmentCount(); } - for (int i = start; i < end; ++i) + for (int i = start; i < end; i++) { from = &(*m_path)[i - 1]->pos; to = &(*m_path)[i]->pos; @@ -702,7 +702,7 @@ int CNavPathFollower::FindPathPoint(float aheadRange, Vector *point, int *prevIn const float closeEpsilon = 20.0f; while ((*point - close).Make2D().IsLengthLessThan(closeEpsilon)) { - ++index; + index++; if (index >= m_path->GetSegmentCount()) { @@ -725,7 +725,7 @@ int CNavPathFollower::FindPathPoint(float aheadRange, Vector *point, int *prevIn const float closeEpsilon = 20.0f; if ((pos - close).Make2D().IsLengthLessThan(closeEpsilon)) { - ++startIndex; + startIndex++; } else { @@ -767,7 +767,7 @@ int CNavPathFollower::FindPathPoint(float aheadRange, Vector *point, int *prevIn // step along the path until we pass aheadRange bool isCorner = false; int i; - for (i = startIndex; i < m_path->GetSegmentCount(); ++i) + for (i = startIndex; i < m_path->GetSegmentCount(); i++) { Vector pos = (*m_path)[i]->pos; Vector to = pos - (*m_path)[i - 1]->pos; @@ -776,7 +776,7 @@ int CNavPathFollower::FindPathPoint(float aheadRange, Vector *point, int *prevIn // don't allow path to double-back from our starting direction (going upstairs, down curved passages, etc) if (DotProduct(dir, initDir) < 0.0f) // -0.25f { - --i; + i--; break; } @@ -784,7 +784,7 @@ int CNavPathFollower::FindPathPoint(float aheadRange, Vector *point, int *prevIn if (DotProduct(dir, prevDir) < 0.5f) { isCorner = true; - --i; + i--; break; } prevDir = dir; @@ -806,7 +806,7 @@ int CNavPathFollower::FindPathPoint(float aheadRange, Vector *point, int *prevIn // Test for un-jumpable height change, or unrecoverable fall //if (!IsStraightLinePathWalkable(&pos)) //{ - // --i; + // i--; // break; //} @@ -879,7 +879,7 @@ int CNavPathFollower::FindPathPoint(float aheadRange, Vector *point, int *prevIn if (DotProduct(toPoint, initDir.Make2D()) < 0.0f || toPoint.IsLengthLessThan(epsilon)) { int i; - for (i = startIndex; i < m_path->GetSegmentCount(); ++i) + for (i = startIndex; i < m_path->GetSegmentCount(); i++) { toPoint.x = (*m_path)[i]->pos.x - centroid.x; toPoint.y = (*m_path)[i]->pos.y - centroid.y; @@ -1067,14 +1067,13 @@ void CStuckMonitor::Update(CImprov *improv) if (m_avgVelCount < MAX_VEL_SAMPLES) { - ++m_avgVelCount; + m_avgVelCount++; } else { // we have enough samples to know if we're stuck - float avgVel = 0.0f; - for (int t = 0; t < m_avgVelCount; ++t) + for (int t = 0; t < m_avgVelCount; t++) avgVel += m_avgVel[t]; avgVel /= m_avgVelCount; diff --git a/regamedll/game_shared/bot/nav_path.h b/regamedll/game_shared/bot/nav_path.h index b21ba2f1..6c34accf 100644 --- a/regamedll/game_shared/bot/nav_path.h +++ b/regamedll/game_shared/bot/nav_path.h @@ -26,11 +26,7 @@ * */ -#ifndef NAV_PATH_H -#define NAV_PATH_H -#ifdef _WIN32 #pragma once -#endif // STL uses exceptions, but we are not compiling with them - ignore warning #pragma warning(disable : 4530) @@ -48,9 +44,9 @@ public: const CNavLadder *ladder; // if "how" refers to a ladder, this is it }; - const PathSegment *operator[](int i) { return (i >= 0 && i < m_segmentCount) ? &m_path[i] : NULL; } + const PathSegment *operator[](int i) { return (i >= 0 && i < m_segmentCount) ? &m_path[i] : nullptr; } int GetSegmentCount() const { return m_segmentCount; } - const Vector &GetEndpoint() const { return m_path[ m_segmentCount - 1 ].pos; } + const Vector &GetEndpoint() const { return m_path[m_segmentCount - 1].pos; } bool IsAtEnd(const Vector &pos) const; // return true if position is at the end of the path float GetLength() const; // return length of path from start to finish @@ -76,11 +72,11 @@ public: { Invalidate(); - if (start == NULL || goal == NULL) + if (!start || !goal) return false; CNavArea *startArea = TheNavAreaGrid.GetNearestNavArea(start); - if (startArea == NULL) + if (!startArea) return false; CNavArea *goalArea = TheNavAreaGrid.GetNavArea(goal); @@ -110,7 +106,7 @@ public: int count = 0; CNavArea *area; for (area = effectiveGoalArea; area; area = area->GetParent()) - ++count; + count++; // save room for endpoint if (count > MAX_PATH_SEGMENTS - 1) @@ -128,9 +124,9 @@ public: m_segmentCount = count; for (area = effectiveGoalArea; count && area; area = area->GetParent()) { - --count; - m_path[ count ].area = area; - m_path[ count ].how = area->GetParentHow(); + count--; + m_path[count].area = area; + m_path[count].how = area->GetParentHow(); } // compute path positions @@ -141,18 +137,18 @@ public: } // append path end position - m_path[ m_segmentCount ].area = effectiveGoalArea; - m_path[ m_segmentCount ].pos = pathEndPosition; - m_path[ m_segmentCount ].ladder = NULL; - m_path[ m_segmentCount ].how = NUM_TRAVERSE_TYPES; - ++m_segmentCount; + m_path[m_segmentCount].area = effectiveGoalArea; + m_path[m_segmentCount].pos = pathEndPosition; + m_path[m_segmentCount].ladder = nullptr; + m_path[m_segmentCount].how = NUM_TRAVERSE_TYPES; + m_segmentCount++; return true; } private: enum { MAX_PATH_SEGMENTS = 256 }; - PathSegment m_path[ MAX_PATH_SEGMENTS ]; + PathSegment m_path[MAX_PATH_SEGMENTS]; int m_segmentCount; bool ComputePathPositions(); // determine actual path positions @@ -169,7 +165,7 @@ public: void Reset(); void Update(CImprov *improv); - bool IsStuck() const { return m_isStuck; } + bool IsStuck() const { return m_isStuck; } float GetDuration() const { return m_isStuck ? m_stuckTimer.GetElapsedTime() : 0.0f; } private: @@ -179,7 +175,7 @@ private: enum { MAX_VEL_SAMPLES = 5 }; - float m_avgVel[ MAX_VEL_SAMPLES ]; + float m_avgVel[MAX_VEL_SAMPLES]; int m_avgVelIndex; int m_avgVelCount; Vector m_lastCentroid; @@ -206,7 +202,7 @@ public: void FeelerReflexAdjustment(Vector *goalPosition, float height = -1.0f); // adjust goal position if "feelers" are touched private: - int FindOurPositionOnPath(Vector *close, bool local) const; // return the closest point to our current position on current path + int FindOurPositionOnPath(Vector *close, bool local) const; // return the closest point to our current position on current path int FindPathPoint(float aheadRange, Vector *point, int *prevIndex); // compute a point a fixed distance ahead along our path. CImprov *m_improv; // who is doing the path following @@ -218,5 +214,3 @@ private: bool m_isDebug; CStuckMonitor m_stuckMonitor; }; - -#endif // NAV_PATH_H diff --git a/regamedll/game_shared/bot/simple_state_machine.h b/regamedll/game_shared/bot/simple_state_machine.h index 7f6a1be0..866a78f6 100644 --- a/regamedll/game_shared/bot/simple_state_machine.h +++ b/regamedll/game_shared/bot/simple_state_machine.h @@ -26,23 +26,19 @@ * */ -#ifndef SIMPLE_STATE_MACHINE_H -#define SIMPLE_STATE_MACHINE_H -#ifdef _WIN32 #pragma once -#endif // Encapsulation of a finite-state-machine state template class SimpleState { public: - SimpleState() { m_parent = NULL; } + SimpleState() { m_parent = nullptr; } virtual ~SimpleState() {}; virtual void OnEnter(T userData) {}; // when state is entered virtual void OnUpdate(T userData) {}; // state behavior - virtual void OnExit(T userData) {}; // when state exited + virtual void OnExit(T userData) {}; // when state exited virtual const char *GetName() const = 0; // return state name void SetParent(SimpleState *parent) @@ -66,12 +62,12 @@ class SimpleStateMachine public: SimpleStateMachine() { - m_state = NULL; + m_state = nullptr; } void Reset(T userData) { m_userData = userData; - m_state = NULL; + m_state = nullptr; } // change behavior state - WARNING: not re-entrant. Do not SetState() from within OnEnter() or OnExit() void SetState(S *newState) @@ -102,9 +98,7 @@ public: } protected: - S *m_state; // current behavior state + S *m_state; // current behavior state IntervalTimer m_stateTimer; // how long have we been in the current state T m_userData; }; - -#endif // SIMPLE_STATE_MACHINE_H diff --git a/regamedll/game_shared/shared_util.cpp b/regamedll/game_shared/shared_util.cpp index 922359e6..4fa28b00 100644 --- a/regamedll/game_shared/shared_util.cpp +++ b/regamedll/game_shared/shared_util.cpp @@ -5,7 +5,7 @@ */ #ifndef HOOK_GAMEDLL -char s_shared_token[ 1500 ]; +char s_shared_token[1500]; char s_shared_quote = '\"'; #endif @@ -58,13 +58,13 @@ char *BufPrintf(char *buf, int &len, const char *fmt, ...) return buf + Q_strlen(buf); } - return NULL; + return nullptr; } wchar_t *BufWPrintf(wchar_t *buf, int &len, const wchar_t *fmt, ...) { if (len <= 0) - return NULL; + return nullptr; va_list argptr; @@ -100,7 +100,7 @@ const char *NumAsString(int val) int len = 16; - curstring = (curstring + 1) % 4; + curstring = (curstring + 1) % NumBuffers; BufPrintf(string[curstring], len, "%d", val); return string[curstring]; @@ -119,7 +119,7 @@ NOXREF void SharedSetQuoteChar(char c) } // Parse a token out of a string -const char *SharedParse(const char *data) +char *SharedParse(char *data) { int c; int len; @@ -128,7 +128,7 @@ const char *SharedParse(const char *data) s_shared_token[0] = '\0'; if (!data) - return NULL; + return nullptr; // skip whitespace skipwhite: @@ -137,28 +137,31 @@ skipwhite: if (c == 0) { // end of file; - return NULL; + return nullptr; } data++; } - // skip // comments + // skip // comments till the next line if (c == '/' && data[1] == '/') { while (*data && *data != '\n') data++; + // start over new line goto skipwhite; } - // handle quoted strings specially + // handle quoted strings specially: copy till the end or another quote if (c == s_shared_quote) { + // skip starting quote data++; while (true) { + // get char and advance c = *data++; if (c == s_shared_quote || !c) { @@ -166,16 +169,14 @@ skipwhite: return data; } - s_shared_token[len] = c; - len++; + s_shared_token[len++] = c; } } // parse single characters if (c == '{' || c == '}'|| c == ')'|| c == '(' || c == '\'' || c == ',') { - s_shared_token[len] = c; - len++; + s_shared_token[len++] = c; s_shared_token[len] = '\0'; return data + 1; } @@ -199,14 +200,14 @@ skipwhite: } // Returns true if additional data is waiting to be processed on this line -NOXREF bool SharedTokenWaiting(const char *buffer) +bool SharedTokenWaiting(const char *buffer) { const char *p; p = buffer; - while (*p && *p!='\n') + while (*p && *p != '\n') { - if (!Q_isspace(*p) || Q_isalnum(*p)) + if (!isspace(*p) || isalnum(*p)) return true; p++; diff --git a/regamedll/game_shared/shared_util.h b/regamedll/game_shared/shared_util.h index 458c2abe..250a671a 100644 --- a/regamedll/game_shared/shared_util.h +++ b/regamedll/game_shared/shared_util.h @@ -41,7 +41,7 @@ const wchar_t *NumAsWString(int val); const char *NumAsString(int val); char *SharedGetToken(); void SharedSetQuoteChar(char c); -const char *SharedParse(const char *data); +char *SharedParse(char *data); bool SharedTokenWaiting(const char *buffer); // Simple utility function to allocate memory and duplicate a string diff --git a/regamedll/game_shared/steam_util.h b/regamedll/game_shared/steam_util.h index fc3cf720..7426ab2c 100644 --- a/regamedll/game_shared/steam_util.h +++ b/regamedll/game_shared/steam_util.h @@ -26,11 +26,7 @@ * */ -#ifndef STEAM_UTIL_H -#define STEAM_UTIL_H -#ifdef _WIN32 #pragma once -#endif class SteamFile { @@ -61,23 +57,21 @@ inline SteamFile::~SteamFile() if (m_fileData) { FREE_FILE(m_fileData); - m_fileData = NULL; + m_fileData = nullptr; } } inline bool SteamFile::Read(void *data, int length) { - if (length > m_bytesLeft || m_cursor == NULL || m_bytesLeft <= 0) + if (length > m_bytesLeft || !m_cursor || m_bytesLeft <= 0) return false; byte *readCursor = static_cast(data); - for (int i = 0; i < length; ++i) + for (int i = 0; i < length; i++) { *readCursor++ = *m_cursor++; - --m_bytesLeft; + m_bytesLeft--; } return true; } - -#endif // STEAM_UTIL_H diff --git a/regamedll/game_shared/voice_common.h b/regamedll/game_shared/voice_common.h index 57591c67..bd72b60b 100644 --- a/regamedll/game_shared/voice_common.h +++ b/regamedll/game_shared/voice_common.h @@ -26,18 +26,12 @@ * */ -#ifndef VOICE_COMMON_H -#define VOICE_COMMON_H -#ifdef _WIN32 #pragma once -#endif #include "bitvec.h" // TODO: this should just be set to MAX_CLIENTS -#define VOICE_MAX_PLAYERS 32 -#define VOICE_MAX_PLAYERS_DW ((VOICE_MAX_PLAYERS / 32) + !!(VOICE_MAX_PLAYERS & 31)) +#define VOICE_MAX_PLAYERS 32 +#define VOICE_MAX_PLAYERS_DW ((VOICE_MAX_PLAYERS / 32) + !!(VOICE_MAX_PLAYERS & 31)) -typedef CBitVec< VOICE_MAX_PLAYERS > CPlayerBitVec; - -#endif // VOICE_COMMON_H +typedef CBitVec CPlayerBitVec; diff --git a/regamedll/game_shared/voice_gamemgr.cpp b/regamedll/game_shared/voice_gamemgr.cpp index f06a766f..e51a26a1 100644 --- a/regamedll/game_shared/voice_gamemgr.cpp +++ b/regamedll/game_shared/voice_gamemgr.cpp @@ -5,23 +5,23 @@ */ #ifndef HOOK_GAMEDLL -cvar_t voice_serverdebug = { "voice_serverdebug", "0", 0, 0.0f, NULL }; +cvar_t voice_serverdebug = { "voice_serverdebug", "0", 0, 0.0f, nullptr }; // Set game rules to allow all clients to talk to each other. // Muted players still can't talk to each other. -cvar_t sv_alltalk = { "sv_alltalk", "0", FCVAR_SERVER, 0.0f, NULL }; +cvar_t sv_alltalk = { "sv_alltalk", "0", FCVAR_SERVER, 0.0f, nullptr }; #endif // These are stored off as CVoiceGameMgr is created and deleted. -CPlayerBitVec g_PlayerModEnable; // Set to 1 for each player if the player wants to use voice in this mod. - // (If it's zero, then the server reports that the game rules are saying the player can't hear anyone). +CPlayerBitVec g_PlayerModEnable; // Set to 1 for each player if the player wants to use voice in this mod. + // (If it's zero, then the server reports that the game rules are saying the player can't hear anyone). -CBitVec< VOICE_MAX_PLAYERS > g_BanMasks[VOICE_MAX_PLAYERS]; // Tells which players don't want to hear each other. - // These are indexed as clients and each bit represents a client (so player entity is bit + 1). +CBitVec g_BanMasks[VOICE_MAX_PLAYERS]; // Tells which players don't want to hear each other. + // These are indexed as clients and each bit represents a client (so player entity is bit + 1). -CBitVec< VOICE_MAX_PLAYERS > g_SentGameRulesMasks[VOICE_MAX_PLAYERS]; // These store the masks we last sent to each client so we can determine if -CBitVec< VOICE_MAX_PLAYERS > g_SentBanMasks[VOICE_MAX_PLAYERS]; // we need to resend them. +CBitVec g_SentGameRulesMasks[VOICE_MAX_PLAYERS]; // These store the masks we last sent to each client so we can determine if +CBitVec g_SentBanMasks[VOICE_MAX_PLAYERS]; // we need to resend them. CPlayerBitVec g_bWantModEnable; @@ -125,10 +125,10 @@ bool CVoiceGameMgr::ClientCommand(CBasePlayer *pPlayer, const char *cmd) bool bBan = Q_stricmp(cmd, "vban") == 0; if (bBan && CMD_ARGC() >= 2) { - for (int i = 1; i < CMD_ARGC(); ++i) + for (int i = 1; i < CMD_ARGC(); i++) { uint32 mask = 0; - Q_sscanf(CMD_ARGV(i), "%x", &mask); + sscanf(CMD_ARGV(i), "%x", &mask); if (i <= VOICE_MAX_PLAYERS_DW) { @@ -162,7 +162,7 @@ void CVoiceGameMgr::UpdateMasks() bool bAllTalk = !!(sv_alltalk.value); - for (int iClient = 0; iClient < m_nMaxPlayers; ++iClient) + for (int iClient = 0; iClient < m_nMaxPlayers; iClient++) { CBaseEntity *pEnt = UTIL_PlayerByIndex(iClient + 1); @@ -179,17 +179,16 @@ void CVoiceGameMgr::UpdateMasks() // Request the state of their "VModEnable" cvar. if (g_bWantModEnable[ iClient ]) { - MESSAGE_BEGIN(MSG_ONE, m_msgRequestState, NULL, pEnt->pev); + MESSAGE_BEGIN(MSG_ONE, m_msgRequestState, nullptr, pEnt->pev); MESSAGE_END(); } if (g_PlayerModEnable[ iClient ]) { // Build a mask of who they can hear based on the game rules. - for (int iOtherClient = 0; iOtherClient < m_nMaxPlayers; ++iOtherClient) + for (int iOtherClient = 0; iOtherClient < m_nMaxPlayers; iOtherClient++) { CBaseEntity *pEnt = UTIL_PlayerByIndex(iOtherClient + 1); - if (pEnt && (bAllTalk || m_pHelper->CanPlayerHearPlayer(pPlayer, (CBasePlayer *)pEnt))) { gameRulesMask[ iOtherClient ] = true; @@ -203,8 +202,8 @@ void CVoiceGameMgr::UpdateMasks() g_SentGameRulesMasks[ iClient ] = gameRulesMask; g_SentBanMasks[ iClient ] = g_BanMasks[ iClient ]; - MESSAGE_BEGIN(MSG_ONE, m_msgPlayerVoiceMask, NULL, pPlayer->pev); - for (int dw = 0; dw < VOICE_MAX_PLAYERS_DW; ++dw) + MESSAGE_BEGIN(MSG_ONE, m_msgPlayerVoiceMask, nullptr, pPlayer->pev); + for (int dw = 0; dw < VOICE_MAX_PLAYERS_DW; dw++) { WRITE_LONG(gameRulesMask.GetDWord(dw)); WRITE_LONG(g_BanMasks[ iClient ].GetDWord(dw)); @@ -215,7 +214,7 @@ void CVoiceGameMgr::UpdateMasks() } // Tell the engine. - for (int iOtherClient = 0; iOtherClient < m_nMaxPlayers; ++iOtherClient) + for (int iOtherClient = 0; iOtherClient < m_nMaxPlayers; iOtherClient++) { bool bCanHear = gameRulesMask[ iOtherClient ] && !g_BanMasks[ iClient ][ iOtherClient ]; SET_CLIENT_LISTENING(iClient + 1, iOtherClient + 1, bCanHear); diff --git a/regamedll/game_shared/voice_gamemgr.h b/regamedll/game_shared/voice_gamemgr.h index cdcc9ff3..d81d3ac2 100644 --- a/regamedll/game_shared/voice_gamemgr.h +++ b/regamedll/game_shared/voice_gamemgr.h @@ -26,13 +26,9 @@ * */ -#ifndef VOICE_GAMEMGR_H -#define VOICE_GAMEMGR_H -#ifdef _WIN32 #pragma once -#endif -#define UPDATE_INTERVAL 0.3 +#define UPDATE_INTERVAL 0.3 #include "voice_common.h" @@ -85,9 +81,7 @@ private: int m_msgRequestState; IVoiceGameMgrHelper *m_pHelper; int m_nMaxPlayers; - double m_UpdateInterval; // How long since the last update. + double m_UpdateInterval; // How long since the last update. }; void VoiceServerDebug(const char *pFmt, ...); - -#endif // VOICE_GAMEMGR_H diff --git a/regamedll/hookers/hooker.cpp b/regamedll/hookers/hooker.cpp index 73c2d031..7e2c8d37 100644 --- a/regamedll/hookers/hooker.cpp +++ b/regamedll/hookers/hooker.cpp @@ -104,7 +104,7 @@ void *GetOriginalFuncAddrOrDie(const char *funcName) return (void*) cfh->originalAddress; } - regamedll_syserror("%s: Could not find function '%s'", __FUNCTION__, funcName); + Sys_Error("%s: Could not find function '%s'", __func__, funcName); return NULL; } @@ -127,7 +127,7 @@ void *GetFuncRefAddrOrDie(const char *funcName) return (void*)cfh->originalAddress; } - regamedll_syserror("%s: Could not find function '%s'", __FUNCTION__, funcName); + Sys_Error("%s: Could not find function '%s'", __func__, funcName); return NULL; } @@ -159,7 +159,7 @@ int HookGameDLL(size_t gameAddr, size_t engAddr) { if (!GetAddress(&g_GameDLLModule, (Address *)refData, g_BaseOffset)) { - _logf("%s: symbol not found \"%s\", symbol index: %i", __FUNCTION__, refData->symbolName, refData->symbolIndex); + UTIL_Log("%s: symbol not found \"%s\", symbol index: %i", __func__, refData->symbolName, refData->symbolIndex); success = false; } refData++; @@ -170,7 +170,7 @@ int HookGameDLL(size_t gameAddr, size_t engAddr) { if (!GetAddress(&g_GameDLLModule, (Address *)refFunc, g_BaseOffset)) { - _logf("%s: symbol not found \"%s\", symbol index: %i", __FUNCTION__, refFunc->symbolName, refFunc->symbolIndex); + UTIL_Log("%s: symbol not found \"%s\", symbol index: %i", __func__, refFunc->symbolName, refFunc->symbolIndex); success = false; } refFunc++; @@ -181,7 +181,7 @@ int HookGameDLL(size_t gameAddr, size_t engAddr) { if (!GetAddress(&g_GameDLLModule, (Address*)hookFunc, g_BaseOffset)) { - _logf("%s: symbol not found \"%s\", symbol index: %i", __FUNCTION__, hookFunc->symbolName, hookFunc->symbolIndex); + UTIL_Log("%s: symbol not found \"%s\", symbol index: %i", __func__, hookFunc->symbolName, hookFunc->symbolIndex); success = false; } hookFunc++; @@ -192,7 +192,7 @@ int HookGameDLL(size_t gameAddr, size_t engAddr) { if (!GetAddress(&g_GameDLLModule, (Address *)refVtbl, g_BaseOffset)) { - _logf("%s: symbol not found \"%s\"", __FUNCTION__, refVtbl->symbolName); + UTIL_Log("%s: symbol not found \"%s\"", __func__, refVtbl->symbolName); success = false; } refVtbl++; @@ -200,7 +200,7 @@ int HookGameDLL(size_t gameAddr, size_t engAddr) if (!success) { - _logf("%s: failed to hook gamedll!", __FUNCTION__); + UTIL_Log("%s: failed to hook gamedll!", __func__); return FALSE; } diff --git a/regamedll/hookers/hooker_impl.cpp b/regamedll/hookers/hooker_impl.cpp index b2a8b2d6..c463a714 100644 --- a/regamedll/hookers/hooker_impl.cpp +++ b/regamedll/hookers/hooker_impl.cpp @@ -85,7 +85,7 @@ TYPEDESCRIPTION gGlobalEntitySaveData[3]; // globals gamerules CGameRules *g_pGameRules; -char mp_com_token[ 1500 ]; +//char mp_com_token[1500]; cvar_t *sv_clienttrace; // globals player.cpp @@ -144,7 +144,7 @@ const int gSizes[18]; // globals bots CBotManager *TheBots; BotPhraseManager *TheBotPhrases; -CBaseEntity *g_pSelectedZombieSpawn; +//CBaseEntity *g_pSelectedZombieSpawn; CountdownTimer IMPL_CLASS(BotChatterInterface, m_encourageTimer); IntervalTimer IMPL_CLASS(BotChatterInterface, m_radioSilenceInterval)[ 2 ]; @@ -237,12 +237,12 @@ entity_field_alias_t custom_entity_field_alias[9]; int g_serveractive; // globals debug.cpp -DebugOutputLevel outputLevel[ NUM_LEVELS ]; +DebugOutputLevel outputLevel[6]; unsigned int theDebugOutputTypes; -char theDebugBuffer[ DebugBufferSize ]; +char theDebugBuffer[MAX_DEBUG_BUFF_SIZE]; // globals tutors -char *const g_TutorStateStrings[20]; +const char *g_TutorStateStrings[20]; const char *TutorIdentifierList[150]; bool s_tutorDisabledThisGame; diff --git a/regamedll/hookers/hooker_impl.h b/regamedll/hookers/hooker_impl.h index 4930314f..7af1034c 100644 --- a/regamedll/hookers/hooker_impl.h +++ b/regamedll/hookers/hooker_impl.h @@ -122,9 +122,9 @@ extern void (*pCCSBot__UpdateLookAngles)(); #define g_pLastTerroristSpawn (*pg_pLastTerroristSpawn) #define gInitHUD (*pgInitHUD) #define sv_aim (*psv_aim) -#define zombieSpawnCount (*pzombieSpawnCount) -#define zombieSpawn (*pzombieSpawn) -#define g_pSelectedZombieSpawn (*pg_pSelectedZombieSpawn) +//#define zombieSpawnCount (*pzombieSpawnCount) +//#define zombieSpawn (*pzombieSpawn) +//#define g_pSelectedZombieSpawn (*pg_pSelectedZombieSpawn) #define giPrecacheGrunt (*pgiPrecacheGrunt) #define gmsgWeapPickup (*pgmsgWeapPickup) #define gmsgHudText (*pgmsgHudText) @@ -358,7 +358,7 @@ extern void (*pCCSBot__UpdateLookAngles)(); #define g_GameMgrHelper (*pg_GameMgrHelper) #define sv_clienttrace (*psv_clienttrace) #define g_pMPGameRules (*pg_pMPGameRules) -#define mp_com_token (*pmp_com_token) +//#define mp_com_token (*pmp_com_token) // globals soundent #define pSoundEnt (*ppSoundEnt) @@ -401,8 +401,8 @@ extern void (*pCCSBot__UpdateLookAngles)(); #define g_vecZero (*pg_vecZero) #define g_Language (*pg_Language) -#define g_ulFrameCount (*pg_ulFrameCount) -#define g_ulModelIndexEyes (*pg_ulModelIndexEyes) +//#define g_ulFrameCount (*pg_ulFrameCount) +//#define g_ulModelIndexEyes (*pg_ulModelIndexEyes) #define g_vecAttackDir (*pg_vecAttackDir) #define g_iSkillLevel (*pg_iSkillLevel) @@ -464,7 +464,6 @@ extern void (*pCCSBot__UpdateLookAngles)(); #define primaryWeaponBuyInfoT (*pprimaryWeaponBuyInfoT) #define secondaryWeaponBuyInfoT (*psecondaryWeaponBuyInfoT) #define TheBotPhrases (*pTheBotPhrases) -#define g_pSelectedZombieSpawn (*pg_pSelectedZombieSpawn) #define TheBots (*pTheBots) // bot_util @@ -526,7 +525,7 @@ extern void (*pCCSBot__UpdateLookAngles)(); #define BotDifficultyName (*pBotDifficultyName) // utlsymbol -#define g_LessCtx (*pg_LessCtx) +//#define g_LessCtx (*pg_LessCtx) // bot_profile #define TheBotProfiles (*pTheBotProfiles) @@ -778,7 +777,7 @@ extern unsigned int glSeed; extern const int gSizes[18]; extern bool s_tutorDisabledThisGame; extern float s_nextCvarCheckTime; -extern char *const g_TutorStateStrings[20]; +extern const char *g_TutorStateStrings[20]; extern const char *TutorIdentifierList[150]; extern struct sv_blending_interface_s svBlending; extern struct server_studio_api_s IEngineStudio; @@ -816,13 +815,13 @@ extern Vector gTankSpread[5]; extern class CCStrikeGameMgrHelper g_GameMgrHelper; extern cvar_t *sv_clienttrace; extern class CHalfLifeMultiplay *g_pMPGameRules; -extern char mp_com_token[1500]; +//extern char mp_com_token[1500]; extern int giAmmoIndex; extern char *m_szPoses[4]; extern struct WeaponStruct g_weaponStruct[32]; -extern int zombieSpawnCount; -extern struct ZombieSpawn zombieSpawn[256]; -extern CBaseEntity *g_pSelectedZombieSpawn; +//extern int zombieSpawnCount; +//extern struct ZombieSpawn zombieSpawn[256]; +//extern CBaseEntity *g_pSelectedZombieSpawn; extern char st_szNextMap[32]; extern char st_szNextSpot[32]; extern char s_shared_token[1500]; @@ -830,11 +829,11 @@ extern char s_shared_quote; extern cvar_t voice_serverdebug; extern cvar_t sv_alltalk; extern CPlayerBitVec g_PlayerModEnable; -extern CBitVec< VOICE_MAX_PLAYERS > g_BanMasks[ VOICE_MAX_PLAYERS ]; -extern CBitVec< VOICE_MAX_PLAYERS > g_SentGameRulesMasks[ VOICE_MAX_PLAYERS ]; -extern CBitVec< VOICE_MAX_PLAYERS > g_SentBanMasks[ VOICE_MAX_PLAYERS ]; +extern CBitVec g_BanMasks[VOICE_MAX_PLAYERS]; +extern CBitVec g_SentGameRulesMasks[VOICE_MAX_PLAYERS]; +extern CBitVec g_SentBanMasks[VOICE_MAX_PLAYERS]; extern CPlayerBitVec g_bWantModEnable; -extern struct LessCtx_t g_LessCtx; +//extern struct LessCtx_t g_LessCtx; extern short s_iBeamSprite; extern float cosTable[256]; extern float lastDrawTimestamp; @@ -873,7 +872,7 @@ float_precision NavAreaTravelDistance__PathCost__wrapper(CNavArea *startArea, CN // PM void PM_SwapTextures(int i, int j); -int PM_IsThereGrassTexture(); +qboolean PM_IsThereGrassTexture(); void PM_SortTextures(); void PM_InitTextureTypes(); void PM_PlayStepSound(int step, float fvol); @@ -894,7 +893,7 @@ void PM_WaterMove(); void PM_AirMove(int playerIndex = 0); qboolean PM_InWater(); qboolean PM_CheckWater(); -void PM_CatagorizePosition(); +void PM_CategorizePosition(); int PM_GetRandomStuckOffsets(int nIndex, int server, vec_t *offset); void PM_ResetStuckOffsets(int nIndex, int server); qboolean PM_CheckStuck(); @@ -917,7 +916,7 @@ void PM_CheckFalling(); void PM_PlayWaterSounds(); float PM_CalcRoll(vec_t *angles, vec_t *velocity, float rollangle, float rollspeed); void PM_DropPunchAngle(vec_t *punchangle); -void PM_CheckParamters(); +void PM_CheckParameters(); void PM_ReduceTimers(); qboolean PM_ShouldDoSpectMode(); void PM_PlayerMove(qboolean server); diff --git a/regamedll/hookers/hooklist.cpp b/regamedll/hookers/hooklist.cpp index 8d65ad7e..222f6aff 100644 --- a/regamedll/hookers/hooklist.cpp +++ b/regamedll/hookers/hooklist.cpp @@ -156,7 +156,7 @@ FunctionHook g_FunctionHooks[] = HOOK_DEF(0x01DB30C0, PM_AirMove_internal), //HOOK_DEF(0x01DB3200, PM_InWater), // NOXREF HOOK_DEF(0x01DB3220, PM_CheckWater), - HOOK_DEF(0x01DB33E0, PM_CatagorizePosition), + HOOK_DEF(0x01DB33E0, PM_CategorizePosition), //HOOK_DEF(0x01DB3590, PM_GetRandomStuckOffsets), // NOXREF //HOOK_DEF(0x01DB35E0, PM_ResetStuckOffsets), // NOXREF HOOK_DEF(0x01DB3600, PM_CheckStuck), @@ -179,7 +179,7 @@ FunctionHook g_FunctionHooks[] = //HOOK_DEF(0x01DB5810, PM_PlayWaterSounds), // NOXREF //HOOK_DEF(0x01DB5810, PM_CalcRoll), // NOXREF //HOOK_DEF(0x01DB58A0, PM_DropPunchAngle), // NOXREF - HOOK_DEF(0x01DB58F0, PM_CheckParamters), + HOOK_DEF(0x01DB58F0, PM_CheckParameters), HOOK_DEF(0x01DB5BE0, PM_ReduceTimers), //HOOK_DEF(0x01DB5D20, PM_ShouldDoSpectMode), // NOXREF HOOK_DEF(0x01DB5D50, PM_PlayerMove), @@ -335,11 +335,11 @@ FunctionHook g_FunctionHooks[] = HOOK_SYMBOLDEF(0x01D61A70, "_Z20EmptyEntityHashTablev", EmptyEntityHashTable), HOOK_SYMBOLDEF(0x01D61AE0, "_Z18AddEntityHashValueP9entvars_sPKc12hash_types_e", AddEntityHashValue), HOOK_SYMBOLDEF(0x01D61CA0, "_Z21RemoveEntityHashValueP9entvars_sPKc12hash_types_e", RemoveEntityHashValue), - HOOK_SYMBOLDEF(0x01D61E20, "_Z13printEntitiesv", printEntities), + HOOK_SYMBOLDEF(0x01D61E20, "_Z13printEntitiesv", SV_PrintEntities_f), HOOK_SYMBOLDEF(0x01D61ED0, "_Z19CREATE_NAMED_ENTITYj", CREATE_NAMED_ENTITY), HOOK_SYMBOLDEF(0x01D61F10, "_Z13REMOVE_ENTITYP7edict_s", REMOVE_ENTITY), HOOK_SYMBOLDEF(0x01D62540, "_Z12CONSOLE_ECHOPcz", CONSOLE_ECHO), - HOOK_SYMBOLDEF(0x01D61F30, "_Z15loopPerformancev", loopPerformance), + HOOK_SYMBOLDEF(0x01D61F30, "_Z15loopPerformancev", SV_LoopPerformance_f), HOOK_DEF(0x01D62570, GetEntityAPI), //HOOK_SYMBOLDEF(0x01D62670, "_Z13GetEntityAPI2P13DLL_FUNCTIONSPi", GetEntityAPI2), // NOXREF HOOK_DEF(0x01D626B0, GetNewDLLFunctions), @@ -434,7 +434,7 @@ FunctionHook g_FunctionHooks[] = HOOK_SYMBOLDEF(0x01D72480, "_ZN11CBaseEntity12FireBullets3E6VectorS0_ffiiifP9entvars_sbi", CBaseEntity::FireBullets3), HOOK_SYMBOLDEF(0x01DBB190, "_ZN11CBaseEntity14SUB_UseTargetsEPS_8USE_TYPEf", CBaseEntity::SUB_UseTargets), HOOK_SYMBOLDEF(0x01DBB260, "_Z11FireTargetsPKcP11CBaseEntityS2_8USE_TYPEf", FireTargets), - HOOK_SYMBOLDEF(0x01D638C0, "_ZN11CBaseEntity10IntersectsEPS_", CBaseEntity::Intersects), + //HOOK_SYMBOLDEF(0x01D638C0, "_ZN11CBaseEntity10IntersectsEPS_", CBaseEntity::Intersects), //HOOK_SYMBOLDEF(0x01D63950, "_ZN11CBaseEntity11MakeDormantEv", CBaseEntity::MakeDormant), // NOXREF HOOK_SYMBOLDEF(0x01D639B0, "_ZN11CBaseEntity9IsDormantEv", CBaseEntity::IsDormant), //HOOK_SYMBOLDEF(0x0, "_ZN11CBaseEntity16IsLockedByMasterEv", CBaseEntity::IsLockedByMaster), // NOXREF @@ -1246,7 +1246,7 @@ FunctionHook g_FunctionHooks[] = HOOK_SYMBOLDEF(0x01D9A6E0, "_ZN10CGunTarget4WaitEv", CGunTarget::Wait), //HOOK_SYMBOLDEF(0x01D9A890, "_ZN10CGunTarget4StopEv", CGunTarget::Stop), // NOXREF //CPlane - //HOOK_SYMBOLDEF(0x01D952F0, "_ZN6CPlaneC2Ev", CPlane::CPlane), // NOXREF + //HOOK_SYMBOLDEF(0x01D952F0, "_ZN6CPlaneC2Ev", CPlane::CPlane), // NOXREF //HOOK_SYMBOLDEF(0x01D95300, "_ZN6CPlane15InitializePlaneERK6VectorS2_", CPlane::InitializePlane), // NOXREF //HOOK_SYMBOLDEF(0x01D95340, "_ZN6CPlane12PointInFrontERK6Vector", CPlane::PointInFront), // NOXREF //linked objects @@ -1328,7 +1328,7 @@ FunctionHook g_FunctionHooks[] = //HOOK_DEF(0x0, FixupAngles2), // NOXREF #ifdef _WIN32 - HOOK_DEF(0x01DCB7B0, Fix2), + //HOOK_DEF(0x01DCB7B0, Fix2), #endif // _WIN32 //linked objects @@ -2268,7 +2268,7 @@ FunctionHook g_FunctionHooks[] = //HOOK_SYMBOLDEF(0x01D8ABB0, "_ZN6CGraph17FSetGraphPointersEv", CGraph::FSetGraphPointers), // pure //HOOK_SYMBOLDEF(0x01D8ABC0, "_ZN6CGraph19ShowNodeConnectionsEi", CGraph::ShowNodeConnections), // pure //HOOK_SYMBOLDEF(0x0, "_ZN6CGraph15FindNearestNodeERK6VectorP11CBaseEntity", CGraph::FindNearestNode, int(const Vector &, CBaseEntity *)), // NOXREF - HOOK_SYMBOLDEF(0x01D8ABD0, "_ZN6CGraph15FindNearestNodeERK6Vectori", CGraph::FindNearestNode, int(const Vector &, int)), + //HOOK_SYMBOLDEF(0x01D8ABD0, "_ZN6CGraph15FindNearestNodeERK6Vectori", CGraph::FindNearestNode, int(const Vector &, int)), #endif // Graph_Region @@ -2389,8 +2389,8 @@ FunctionHook g_FunctionHooks[] = HOOK_SYMBOLDEF(0x01DC2D90, "_Z23UTIL_FindEntityInSphereP11CBaseEntityRK6Vectorf", UTIL_FindEntityInSphere), HOOK_SYMBOLDEF(0x01DC2DE0, "_Z27UTIL_FindEntityByString_OldP11CBaseEntityPKcS2_", UTIL_FindEntityByString_Old), HOOK_SYMBOLDEF(0x01DC2E30, "_Z23UTIL_FindEntityByStringP11CBaseEntityPKcS2_", UTIL_FindEntityByString), - HOOK_SYMBOLDEF(0x01DC2FB0, "_Z26UTIL_FindEntityByClassnameP11CBaseEntityPKc", UTIL_FindEntityByClassname), - HOOK_SYMBOLDEF(0x01DC2FD0, "_Z27UTIL_FindEntityByTargetnameP11CBaseEntityPKc", UTIL_FindEntityByTargetname), + //HOOK_SYMBOLDEF(0x01DC2FB0, "_Z26UTIL_FindEntityByClassnameP11CBaseEntityPKc", UTIL_FindEntityByClassname), + //HOOK_SYMBOLDEF(0x01DC2FD0, "_Z27UTIL_FindEntityByTargetnameP11CBaseEntityPKc", UTIL_FindEntityByTargetname), //HOOK_SYMBOLDEF(0x01DC2FF0, "_Z22UTIL_FindEntityGenericPKcR6Vectorf", UTIL_FindEntityGeneric), // NOXREF //HOOK_SYMBOLDEF(0x01DC30A0, "_Z18UTIL_PlayerByIndexi", UTIL_PlayerByIndex), HOOK_SYMBOLDEF(0x01DC30E0, "_Z16UTIL_MakeVectorsRK6Vector", UTIL_MakeVectors), @@ -2431,7 +2431,7 @@ FunctionHook g_FunctionHooks[] = HOOK_SYMBOLDEF(0x01DC4330, "_Z19UTIL_SplineFractionff", UTIL_SplineFraction), HOOK_SYMBOLDEF(0x01DC4350, "_Z12UTIL_VarArgsPcz", UTIL_VarArgs), //HOOK_SYMBOLDEF(0x01DC4370, "_Z17UTIL_GetAimVectorP7edict_sf", UTIL_GetAimVector), // NOXREF - HOOK_SYMBOLDEF(0x01DC43B0, "_Z22UTIL_IsMasterTriggeredjP11CBaseEntity", UTIL_IsMasterTriggered), + //HOOK_SYMBOLDEF(0x01DC43B0, "_Z22UTIL_IsMasterTriggeredjP11CBaseEntity", UTIL_IsMasterTriggered), //HOOK_SYMBOLDEF(0x01DC4430, "_Z20UTIL_ShouldShowBloodi", UTIL_ShouldShowBlood), // NOXREF HOOK_SYMBOLDEF(0x01DC4490, "_Z18UTIL_PointContentsRK6Vector", UTIL_PointContents), HOOK_SYMBOLDEF(0x01DC44A0, "_Z16UTIL_BloodStreamRK6VectorS1_ii", UTIL_BloodStream), @@ -2443,8 +2443,8 @@ FunctionHook g_FunctionHooks[] = //HOOK_SYMBOLDEF(0x01DC4940, "_Z22UTIL_GunshotDecalTraceP11TraceResultibP9entvars_s", UTIL_GunshotDecalTrace), // NOXREF HOOK_SYMBOLDEF(0x01DC4A40, "_Z11UTIL_SparksRK6Vector", UTIL_Sparks), HOOK_SYMBOLDEF(0x01DC4A90, "_Z13UTIL_RicochetRK6Vectorf", UTIL_Ricochet), - HOOK_SYMBOLDEF(0x01DC4AF0, "_Z15UTIL_TeamsMatchPKcS0_", UTIL_TeamsMatch), - HOOK_SYMBOLDEF(0x01DC4B30, "_Z19UTIL_StringToVectorPfPKc", UTIL_StringToVector), + //HOOK_SYMBOLDEF(0x01DC4AF0, "_Z15UTIL_TeamsMatchPKcS0_", UTIL_TeamsMatch), + //HOOK_SYMBOLDEF(0x01DC4B30, "_Z19UTIL_StringToVectorPfPKc", UTIL_StringToVector), HOOK_SYMBOLDEF(0x01DC4BB0, "_Z21UTIL_StringToIntArrayPiiPKc", UTIL_StringToIntArray), //HOOK_SYMBOLDEF(0x01DC4C40, "_Z21UTIL_ClampVectorToBoxRK6VectorS1_", UTIL_ClampVectorToBox), // NOXREF //HOOK_SYMBOLDEF(0x01DC4D80, "_Z15UTIL_WaterLevelRK6Vectorff", UTIL_WaterLevel), // NOXREF @@ -2455,7 +2455,7 @@ FunctionHook g_FunctionHooks[] = HOOK_SYMBOLDEF(0x01DC5300, "_Z18UTIL_PrecacheOtherPKc", UTIL_PrecacheOther), HOOK_SYMBOLDEF(0x01DC5380, "_Z14UTIL_LogPrintfPcz", UTIL_LogPrintf), //HOOK_SYMBOLDEF(0x01DC53B0, "_Z14UTIL_DotPointsRK6VectorS1_S1_", UTIL_DotPoints), // NOXREF - HOOK_SYMBOLDEF(0x01DC5430, "_Z15UTIL_StripTokenPKcPc", UTIL_StripToken), + //HOOK_SYMBOLDEF(0x01DC5430, "_Z15UTIL_StripTokenPKcPc", UTIL_StripToken), //HOOK_SYMBOLDEF(0x01DC5470, "_ZN18CSaveRestoreBufferC2Ev", (MethodThunk::Constructor), void()), // NOXREF //HOOK_SYMBOLDEF(0x01DC5480, "_ZN18CSaveRestoreBufferC2EP13saverestore_s", (MethodThunk::Constructor), void(SAVERESTOREDATA *)), // NOXREF //HOOK_SYMBOLDEF(0x01DC5490, "_ZN18CSaveRestoreBufferD2Ev", CSaveRestoreBuffer::~CSaveRestoreBuffer), // NOXREF @@ -2711,8 +2711,8 @@ FunctionHook g_FunctionHooks[] = //HOOK_SYMBOLDEF(0x01D8B7B0, "_Z15EndRoundMessagePKci", EndRoundMessage), //HOOK_SYMBOLDEF(0x01D8BD80, "_ZL18ReadMultiplayCvarsP18CHalfLifeMultiplay", ReadMultiplayCvars), //HOOK_SYMBOLDEF(0x01D92670, "_Z15DestroyMapCycleP10mapcycle_s", DestroyMapCycle), // NOXREF - HOOK_SYMBOLDEF(0x01D926B0, "_Z15MP_COM_GetTokenv", MP_COM_GetToken), - HOOK_SYMBOLDEF(0x01D926C0, "_Z12MP_COM_ParsePc", MP_COM_Parse), + //HOOK_SYMBOLDEF(0x01D926B0, "_Z15MP_COM_GetTokenv", MP_COM_GetToken), + //HOOK_SYMBOLDEF(0x01D926C0, "_Z12MP_COM_ParsePc", MP_COM_Parse), //HOOK_SYMBOLDEF(0x01D927A0, "_Z19MP_COM_TokenWaitingPc", MP_COM_TokenWaiting), // NOXREF HOOK_SYMBOLDEF(0x01D927F0, "_Z18ReloadMapCycleFilePcP10mapcycle_s", ReloadMapCycleFile), //HOOK_SYMBOLDEF(0x01D92AB0, "_Z12CountPlayersv", CountPlayers), // NOXREF @@ -4459,8 +4459,8 @@ FunctionHook g_FunctionHooks[] = #ifndef H_Region //AI - //HOOK_SYMBOLDEF(0x01D848B0, "_Z11FBoxVisibleP9entvars_sS0_R6Vectorf", FBoxVisible), // NOXREF - //HOOK_SYMBOLDEF(0x01D84A10, "_Z12VecCheckTossP9entvars_sRK6VectorS1_f", VecCheckToss), // NOXREF + //HOOK_SYMBOLDEF(0x01D848B0, "_Z11FBoxVisibleP9entvars_sS0_R6Vectorf", FBoxVisible), // NOXREF + //HOOK_SYMBOLDEF(0x01D84A10, "_Z12VecCheckTossP9entvars_sRK6VectorS1_f", VecCheckToss), // NOXREF //HOOK_SYMBOLDEF(0x01D84EB0, "_Z13VecCheckThrowP9entvars_sRK6VectorS1_ff", VecCheckThrow), // NOXREF //CRecharge // virtual func @@ -5727,11 +5727,11 @@ AddressRef g_DataRefs[] = GLOBALVAR_LINK(0x01E29480, "_ZL8cosTable", pcosTable), GLOBALVAR_LINK(0x01E23AA8, "TutorIdentifierList", pTutorIdentifierList), GLOBALVAR_LINK(0x01E23678, "_ZL19g_TutorStateStrings", pg_TutorStateStrings), - GLOBALVAR_LINK(0x01E61E4C, "WorldGraph", pWorldGraph), + //GLOBALVAR_LINK(0x01E61E4C, "WorldGraph", pWorldGraph), //GLOBALVAR_LINK(0x01E61E5C, "_ZN12CTalkMonster14g_talkWaitTimeE", CTalkMonster::pg_talkWaitTime), GLOBALVAR_LINK(0x01E61B98, "g_pGameRules", pg_pGameRules), GLOBALVAR_LINK(0x01E62560, "g_pMPGameRules", pg_pMPGameRules), - GLOBALVAR_LINK(0x01E61E70, "_ZL12mp_com_token", pmp_com_token), + //GLOBALVAR_LINK(0x01E61E70, "_ZL12mp_com_token", pmp_com_token), GLOBALVAR_LINK(0x01E636F0, "vec3_origin", pvec3_origin), GLOBALVAR_LINK(0x01E1F420, "nanmask", pnanmask), GLOBALVAR_LINK(0x01E0B0B0, "_ZL15weaponAliasInfo", pweaponAliasInfo), @@ -6146,7 +6146,7 @@ AddressRef g_DataRefs[] = GLOBALVAR_LINK(0x01E24950, "_ZL8taskInfo", ptaskInfo), GLOBALVAR_LINK(0x01E76594, "TheCareerTasks", pTheCareerTasks), GLOBALVAR_LINK(0x01E28C7C, "TheBotProfiles", pTheBotProfiles), - GLOBALVAR_LINK(0x01E287CC, "g_pSelectedZombieSpawn", pg_pSelectedZombieSpawn), + //GLOBALVAR_LINK(0x01E287CC, "g_pSelectedZombieSpawn", pg_pSelectedZombieSpawn), GLOBALVAR_LINK(0x01E287F0, "TheBotPhrases", pTheBotPhrases), GLOBALVAR_LINK(0x01E7657C, "TheTutor", pTheTutor), GLOBALVAR_LINK(0x01E2A25C, "g_pHostages", pg_pHostages), @@ -6154,13 +6154,13 @@ AddressRef g_DataRefs[] = GLOBALVAR_LINK(0x01E16EE0, "_ZL11outputLevel", poutputLevel), GLOBALVAR_LINK(0x01E61B40, "_ZL19theDebugOutputTypes", ptheDebugOutputTypes), GLOBALVAR_LINK(0x01E61740, "_ZL14theDebugBuffer", ptheDebugBuffer), - GLOBALVAR_LINK(0x01E75D04, "_ZL9g_LessCtx", pg_LessCtx), + //GLOBALVAR_LINK(0x01E75D04, "_ZL9g_LessCtx", pg_LessCtx), GLOBALVAR_LINK(0x01E62670, "g_pevLastInflictor", pg_pevLastInflictor), GLOBALVAR_LINK(0x01E62788, "g_pLastSpawn", pg_pLastSpawn), GLOBALVAR_LINK(0x01E63590, "g_pLastCTSpawn", pg_pLastCTSpawn), GLOBALVAR_LINK(0x01E63594, "g_pLastTerroristSpawn", pg_pLastTerroristSpawn), - GLOBALVAR_LINK(0x01E62990, "_ZL11zombieSpawn", pzombieSpawn), - GLOBALVAR_LINK(0x01E636E8, "_ZL16zombieSpawnCount", pzombieSpawnCount), + //GLOBALVAR_LINK(0x01E62990, "_ZL11zombieSpawn", pzombieSpawn), + //GLOBALVAR_LINK(0x01E636E8, "_ZL16zombieSpawnCount", pzombieSpawnCount), GLOBALVAR_LINK(0x01E13838, "svBlending", psvBlending), GLOBALVAR_LINK(0x01E312D0, "IEngineStudio", pIEngineStudio), GLOBALVAR_LINK(0x01E2DAA8, "g_pstudiohdr", pg_pstudiohdr), diff --git a/regamedll/hookers/hooklist.h b/regamedll/hookers/hooklist.h index adf983f8..928f9eec 100644 --- a/regamedll/hookers/hooklist.h +++ b/regamedll/hookers/hooklist.h @@ -6,12 +6,12 @@ #define _LOG_TRACE\ static int iNumPassed = 0;\ - printf2("%s:: iNumPassed - %d", __FUNCTION__, iNumPassed++); + UTIL_ServerPrint("%s:: iNumPassed - %d", __func__, iNumPassed++); #define _LOG_TRACE2\ static int iNumPassed2 = 0;\ - printf2("%s:: iNumPassed - %d", __FUNCTION__, iNumPassed2++);\ - _logf("%s:: iNumPassed - %d", __FUNCTION__, iNumPassed2++); + UTIL_ServerPrint("%s:: iNumPassed - %d", __func__, iNumPassed2++);\ + UTIL_Log("%s:: iNumPassed - %d", __func__, iNumPassed2++); #ifdef HOOK_GAMEDLL // STL containers Visual Studio 6.0 diff --git a/regamedll/hookers/memory.cpp b/regamedll/hookers/memory.cpp index f6d99748..474296f4 100644 --- a/regamedll/hookers/memory.cpp +++ b/regamedll/hookers/memory.cpp @@ -425,21 +425,19 @@ size_t HIDDEN FindSymbol(Module *module, const char* symbolName, int index) #endif // _WIN32 -extern void regamedll_syserror(const char* fmt, ...); - #ifdef _WIN32 void ProcessModuleData(Module *module) { int i = 0; PIMAGE_DOS_HEADER dosHeader = (PIMAGE_DOS_HEADER)module->base; if (dosHeader->e_magic != IMAGE_DOS_SIGNATURE) { - regamedll_syserror("%s: Invalid DOS header signature", __FUNCTION__); + Sys_Error("%s: Invalid DOS header signature", __func__); return; } PIMAGE_NT_HEADERS NTHeaders = (PIMAGE_NT_HEADERS)((size_t)module->base + dosHeader->e_lfanew); if (NTHeaders->Signature != 0x4550) { - regamedll_syserror("%s: Invalid NT header signature", __FUNCTION__); + Sys_Error("%s: Invalid NT header signature", __func__); return; } @@ -453,7 +451,7 @@ void ProcessModuleData(Module *module) } if (CodeSection == NULL) { - regamedll_syserror("%s: Code section not found", __FUNCTION__); + Sys_Error("%s: Code section not found", __func__); return; } @@ -865,13 +863,13 @@ void VirtualTableInit(void *ptr, const char *baseClass) VirtualTableRef *refsVtbl = GetVirtualTableRefAddr(baseClass); if (!refsVtbl) { - regamedll_syserror("%s: Missing vtable for \"%s\"", __FUNCTION__, baseClass); + Sys_Error("%s: Missing vtable for \"%s\"", __func__, baseClass); } /* int nCount = vtable_size(refsVtbl->originalAddress); if (nCount != refsVtbl->size) - regamedll_syserror("%s: Invalid size virtual table, expected [%d], got [%d]", __FUNCTION__, nCount, refsVtbl->size); + Sys_Error("%s: Invalid size virtual table, expected [%d], got [%d]", __func__, nCount, refsVtbl->size); */ int **ivtable = *(int ***)ptr; @@ -901,7 +899,7 @@ void HIDDEN GetAddressVtableByClassname(const char *szClassName, const int iOffs if (addr == NULL) { //can't create object. - printf2("%s: Not found export function of binaries. Presumably looks '__declspec(dllexport) void %s(entvars_t *pev)'", __FUNCTION__, szClassName); + UTIL_ServerPrint("%s: Not found export function of binaries. Presumably looks '__declspec(dllexport) void %s(entvars_t *pev)'", __func__, szClassName); REMOVE_ENTITY(pObject); return; } @@ -917,8 +915,8 @@ void HIDDEN GetAddressVtableByClassname(const char *szClassName, const int iOffs vtable = (void *)refsVtbl->originalAddress; } - printf2("%s: ADDRESS VTABLE: %p | ADDRESS VIRTUAL FUNC: %p", - __FUNCTION__, + UTIL_ServerPrint("%s: ADDRESS VTABLE: %p | ADDRESS VIRTUAL FUNC: %p", + __func__, OffsetToRebase((size_t)vtable), OffsetToRebase(*(((size_t **)&vtable)[ iOffset ]))); } diff --git a/regamedll/msvc/PreBuild.bat b/regamedll/msvc/PreBuild.bat index 7d6501cd..ce5388d6 100644 --- a/regamedll/msvc/PreBuild.bat +++ b/regamedll/msvc/PreBuild.bat @@ -26,6 +26,14 @@ set "hour=%dt:~8,2%" set "min=%dt:~10,2%" set "sec=%dt:~12,2%" +:: +:: Remove leading zero from MM (e.g 09 > 9) +for /f "tokens=* delims=0" %%I in ("%MM%") do set MM=%%I +:: + +:: +:: Index into array to get month name +:: for /f "tokens=%MM%" %%I in ("Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec") do set "month=%%I" :: diff --git a/regamedll/msvc/ReGameDLL.vcxproj b/regamedll/msvc/ReGameDLL.vcxproj index 0085199d..45ee9ba4 100644 --- a/regamedll/msvc/ReGameDLL.vcxproj +++ b/regamedll/msvc/ReGameDLL.vcxproj @@ -43,6 +43,7 @@ + false @@ -345,6 +346,7 @@ + @@ -355,6 +357,7 @@ + @@ -422,7 +425,6 @@ false false - @@ -431,11 +433,9 @@ - - @@ -838,7 +838,6 @@ - Create precompiled.h @@ -867,7 +866,6 @@ true - @@ -970,10 +968,12 @@ + + @@ -982,6 +982,7 @@ + @@ -989,7 +990,6 @@ - @@ -1002,9 +1002,9 @@ - + @@ -1030,7 +1030,6 @@ - @@ -1082,32 +1081,9 @@ - - - - - - - - - - - - - - - - - - - - - - - @@ -1117,12 +1093,10 @@ - - @@ -1346,7 +1320,7 @@ Level3 Disabled true - HOOK_GAMEDLL;REGAMEDLL_API;REGAMEDLL_SELF;REGAMEDLL_FIXES;REGAMEDLL_CHECKS;CLIENT_WEAPONS;USE_BREAKPAD_HANDLER;DEDICATED;_CRT_SECURE_NO_WARNINGS;_DEBUG;_ITERATOR_DEBUG_LEVEL=0;NOMINMAX;%(PreprocessorDefinitions) + HOOK_GAMEDLL;REGAMEDLL_API;REGAMEDLL_SELF;REGAMEDLL_FIXES;REGAMEDLL_CHECKS;CLIENT_WEAPONS;USE_BREAKPAD_HANDLER;USE_QSTRING;DEDICATED;_CRT_SECURE_NO_WARNINGS;_DEBUG;_ITERATOR_DEBUG_LEVEL=0;NOMINMAX;%(PreprocessorDefinitions) Precise /arch:IA32 %(AdditionalOptions) MultiThreadedDebug @@ -1383,7 +1357,7 @@ Level3 Disabled true - PLAY_GAMEDLL;HOOK_GAMEDLL;REGAMEDLL_SELF;REGAMEDLL_CHECKS;CLIENT_WEAPONS;USE_BREAKPAD_HANDLER;DEDICATED;_CRT_SECURE_NO_WARNINGS;_DEBUG;_ITERATOR_DEBUG_LEVEL=0;%(PreprocessorDefinitions) + PLAY_GAMEDLL;HOOK_GAMEDLL;REGAMEDLL_SELF;REGAMEDLL_CHECKS;CLIENT_WEAPONS;USE_BREAKPAD_HANDLER;USE_QSTRING;DEDICATED;_CRT_SECURE_NO_WARNINGS;_DEBUG;_ITERATOR_DEBUG_LEVEL=0;%(PreprocessorDefinitions) Precise /arch:IA32 %(AdditionalOptions) MultiThreadedDebug @@ -1419,7 +1393,7 @@ Level3 Disabled true - REGAMEDLL_ADD;REGAMEDLL_API;REGAMEDLL_FIXES;REGAMEDLL_SELF;REGAMEDLL_CHECKS;CLIENT_WEAPONS;USE_BREAKPAD_HANDLER;DEDICATED;_CRT_SECURE_NO_WARNINGS;_DEBUG;_ITERATOR_DEBUG_LEVEL=0;%(PreprocessorDefinitions) + REGAMEDLL_ADD;REGAMEDLL_API;REGAMEDLL_FIXES;REGAMEDLL_SELF;REGAMEDLL_CHECKS;CLIENT_WEAPONS;USE_BREAKPAD_HANDLER;USE_QSTRING;DEDICATED;_CRT_SECURE_NO_WARNINGS;_DEBUG;_ITERATOR_DEBUG_LEVEL=0;%(PreprocessorDefinitions) Precise /arch:IA32 %(AdditionalOptions) MultiThreadedDebug @@ -1455,8 +1429,8 @@ Level3 Full true - REGAMEDLL_ADD;REGAMEDLL_FIXES;REGAMEDLL_SELF;REGAMEDLL_CHECKS;REGAMEDLL_API;CLIENT_WEAPONS;USE_BREAKPAD_HANDLER;DEDICATED;_CRT_SECURE_NO_WARNINGS;NDEBUG;_ITERATOR_DEBUG_LEVEL=0;%(PreprocessorDefinitions) - Precise + REGAMEDLL_ADD;REGAMEDLL_FIXES;REGAMEDLL_SELF;REGAMEDLL_CHECKS;REGAMEDLL_API;CLIENT_WEAPONS;USE_BREAKPAD_HANDLER;USE_QSTRING;DEDICATED;_CRT_SECURE_NO_WARNINGS;NDEBUG;_ITERATOR_DEBUG_LEVEL=0;%(PreprocessorDefinitions) + Fast /arch:IA32 %(AdditionalOptions) MultiThreaded Use @@ -1500,7 +1474,7 @@ Level3 Full true - REGAMEDLL_SELF;PLAY_GAMEDLL;REGAMEDLL_API;REGAMEDLL_CHECKS;CLIENT_WEAPONS;USE_BREAKPAD_HANDLER;DEDICATED;_CRT_SECURE_NO_WARNINGS;NDEBUG;_ITERATOR_DEBUG_LEVEL=0;%(PreprocessorDefinitions) + REGAMEDLL_SELF;PLAY_GAMEDLL;REGAMEDLL_API;REGAMEDLL_CHECKS;CLIENT_WEAPONS;USE_BREAKPAD_HANDLER;USE_QSTRING;DEDICATED;_CRT_SECURE_NO_WARNINGS;NDEBUG;_ITERATOR_DEBUG_LEVEL=0;%(PreprocessorDefinitions) Precise /arch:IA32 %(AdditionalOptions) MultiThreaded @@ -1545,7 +1519,7 @@ Level3 Disabled true - REGAMEDLL_SELF;PLAY_GAMEDLL;REGAMEDLL_CHECKS;REGAMEDLL_API;CLIENT_WEAPONS;USE_BREAKPAD_HANDLER;DEDICATED;_CRT_SECURE_NO_WARNINGS;_DEBUG;_ITERATOR_DEBUG_LEVEL=0;%(PreprocessorDefinitions) + REGAMEDLL_SELF;PLAY_GAMEDLL;REGAMEDLL_CHECKS;REGAMEDLL_API;CLIENT_WEAPONS;USE_BREAKPAD_HANDLER;USE_QSTRING;DEDICATED;_CRT_SECURE_NO_WARNINGS;_DEBUG;_ITERATOR_DEBUG_LEVEL=0;%(PreprocessorDefinitions) Precise /arch:IA32 %(AdditionalOptions) MultiThreadedDebug @@ -1581,7 +1555,7 @@ Level3 Disabled true - REGAMEDLL_SELF;REGAMEDLL_FIXES;DEDICATED;REGAMEDLL_SELF;HOOK_GAMEDLL;_BUILD_FROM_IDE;USE_BREAKPAD_HANDLER;DEDICATED;_CRT_SECURE_NO_WARNINGS;_ITERATOR_DEBUG_LEVEL=0;_DEBUG;%(PreprocessorDefinitions) + REGAMEDLL_SELF;REGAMEDLL_FIXES;DEDICATED;REGAMEDLL_SELF;HOOK_GAMEDLL;_BUILD_FROM_IDE;USE_BREAKPAD_HANDLER;USE_QSTRING;DEDICATED;_CRT_SECURE_NO_WARNINGS;_ITERATOR_DEBUG_LEVEL=0;_DEBUG;%(PreprocessorDefinitions) MultiThreadedDebug Use precompiled.h @@ -1620,7 +1594,7 @@ true true true - HOOK_GAMEDLL;REGAMEDLL_SELF;REGAMEDLL_FIXES;REGAMEDLL_CHECKS;CLIENT_WEAPONS;USE_BREAKPAD_HANDLER;DEDICATED;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + HOOK_GAMEDLL;REGAMEDLL_SELF;REGAMEDLL_FIXES;REGAMEDLL_CHECKS;CLIENT_WEAPONS;USE_BREAKPAD_HANDLER;USE_QSTRING;DEDICATED;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) MultiThreaded /arch:IA32 %(AdditionalOptions) Use @@ -1659,7 +1633,7 @@ true true true - REGAMEDLL_SELF;PLAY_GAMEDLL;HOOK_GAMEDLL;REGAMEDLL_CHECKS;CLIENT_WEAPONS;USE_BREAKPAD_HANDLER;DEDICATED;_CRT_SECURE_NO_WARNINGS;NOMINMAX;%(PreprocessorDefinitions) + REGAMEDLL_SELF;PLAY_GAMEDLL;HOOK_GAMEDLL;REGAMEDLL_CHECKS;CLIENT_WEAPONS;USE_BREAKPAD_HANDLER;USE_QSTRING;DEDICATED;_CRT_SECURE_NO_WARNINGS;NOMINMAX;%(PreprocessorDefinitions) MultiThreaded /arch:IA32 %(AdditionalOptions) Use diff --git a/regamedll/msvc/ReGameDLL.vcxproj.filters b/regamedll/msvc/ReGameDLL.vcxproj.filters index ef8c4afd..87e61d81 100644 --- a/regamedll/msvc/ReGameDLL.vcxproj.filters +++ b/regamedll/msvc/ReGameDLL.vcxproj.filters @@ -48,9 +48,6 @@ {b9e4d175-16d0-4f51-8520-896826a345dc} - - {d07d80e2-b454-42b8-ba76-160e7b054875} - {58f96e92-9d4b-4a0d-91e4-10f9cdc18ce1} @@ -248,9 +245,6 @@ game_shared - - dlls - dlls\bot @@ -317,9 +311,6 @@ dlls - - dlls - engine @@ -485,9 +476,6 @@ dlls - - dlls - dlls @@ -542,12 +530,6 @@ hookers - - regamedll - - - regamedll - regamedll @@ -560,6 +542,15 @@ hookers + + dlls + + + dlls + + + dlls + @@ -583,9 +574,6 @@ public - - public - public @@ -733,72 +721,6 @@ pm_shared - - public\steam - - - public\steam - - - public\steam - - - public\steam - - - public\steam - - - public\steam - - - public\steam - - - public\steam - - - public\steam - - - public\steam - - - public\steam - - - public\steam - - - public\steam - - - public\steam - - - public\steam - - - public\steam - - - public\steam - - - public\steam - - - public\steam - - - public\steam - - - public\steam - - - public\steam - engine\client @@ -952,9 +874,6 @@ dlls - - dlls - game_shared @@ -1036,9 +955,6 @@ dlls - - dlls - engine @@ -1060,9 +976,6 @@ dlls - - dlls - hookers\stl @@ -1096,15 +1009,9 @@ hookers - - regamedll - regamedll - - regamedll - regamedll @@ -1132,6 +1039,18 @@ dlls + + dlls + + + dlls + + + dlls + + + dlls + diff --git a/regamedll/pm_shared/pm_defs.h b/regamedll/pm_shared/pm_defs.h index 73a1e0e3..67b82e61 100644 --- a/regamedll/pm_shared/pm_defs.h +++ b/regamedll/pm_shared/pm_defs.h @@ -26,11 +26,7 @@ * */ -#ifndef PM_DEFS_H -#define PM_DEFS_H -#ifdef _WIN32 #pragma once -#endif #include "pm_info.h" #include "pmtrace.h" @@ -45,7 +41,7 @@ #define MAX_MOVEENTS 64 #define MAX_CLIP_PLANES 5 -#define PM_NORMAL 0x00000000 +#define PM_NORMAL 0x00000000 #define PM_STUDIO_IGNORE 0x00000001 // Skip studio models #define PM_STUDIO_BOX 0x00000002 // Use boxes for non-complex studio models (even in traceline) #define PM_GLASS_IGNORE 0x00000004 // Ignore entities with non-normal rendermode @@ -59,14 +55,14 @@ typedef struct physent_s char name[32]; // Name of model, or "player" or "world". int player; vec3_t origin; // Model's origin in world coordinates. - struct model_s *model; // only for bsp models - struct model_s *studiomodel; // SOLID_BBOX, but studio clip intersections. + struct model_s *model; // only for bsp models + struct model_s *studiomodel; // SOLID_BBOX, but studio clip intersections. vec3_t mins, maxs; // only for non-bsp models - int info; // For client or server to use to identify (index into edicts or cl_entities) + int info; // For client or server to use to identify (index into edicts or cl_entities) vec3_t angles; // rotated entities need this info for hull testing to work. - int solid; // Triggers and func_door type WATER brushes are SOLID_NOT - int skin; // BSP Contents for such things like fun_door water brushes. + int solid; // Triggers and func_door type WATER brushes are SOLID_NOT + int skin; // BSP Contents for such things like fun_door water brushes. int rendermode; // So we can ignore glass float frame; @@ -99,34 +95,34 @@ typedef struct playermove_s { int player_index; // So we don't try to run the PM_CheckStuck nudging too quickly. qboolean server; // For debugging, are we running physics code on server side? - qboolean multiplayer; // 1 == multiplayer server - float time; // realtime on host, for reckoning duck timing + qboolean multiplayer; // 1 == multiplayer server + float time; // realtime on host, for reckoning duck timing float frametime; // Duration of this frame - vec3_t forward, right, up; // Vectors for angles + vec3_t forward, right, up; // Vectors for angles vec3_t origin; // Movement origin. vec3_t angles; // Movement view angles. vec3_t oldangles; // Angles before movement view angles were looked at. vec3_t velocity; // Current movement direction. vec3_t movedir; // For waterjumping, a forced forward velocity so we can fly over lip of ledge. - vec3_t basevelocity; // Velocity of the conveyor we are standing, e.g. + vec3_t basevelocity; // Velocity of the conveyor we are standing, e.g. vec3_t view_ofs; // For ducking/dead - // Our eye position. + // Our eye position. float flDuckTime; // Time we started duck qboolean bInDuck; // In process of ducking or ducked already? - int flTimeStepSound; // For walking/falling - // Next time we can play a step sound + int flTimeStepSound; // For walking/falling + // Next time we can play a step sound int iStepLeft; float flFallVelocity; vec3_t punchangle; float flSwimTime; float flNextPrimaryAttack; int effects; // MUZZLE FLASH, e.g. - int flags; // FL_ONGROUND, FL_DUCKING, etc. + int flags; // FL_ONGROUND, FL_DUCKING, etc. int usehull; // 0 = regular player hull, 1 = ducked player hull, 2 = point hull float gravity; // Our current gravity and friction. float friction; int oldbuttons; // Buttons last usercmd - float waterjumptime; // Amount of time left in jumping out of water cycle. + float waterjumptime; // Amount of time left in jumping out of water cycle. qboolean dead; // Are we a dead player? int deadflag; int spectator; // Should we use spectator physics model? @@ -151,17 +147,17 @@ typedef struct playermove_s vec3_t vuser2; vec3_t vuser3; vec3_t vuser4; - int numphysent; // world state - // Number of entities to clip against. + int numphysent; // world state + // Number of entities to clip against. physent_t physents[MAX_PHYSENTS]; - int nummoveent; // Number of momvement entities (ladders) - physent_t moveents[MAX_MOVEENTS]; // just a list of ladders - int numvisent; // All things being rendered, for tracing against things you don't actually collide with + int nummoveent; // Number of momvement entities (ladders) + physent_t moveents[MAX_MOVEENTS]; // just a list of ladders + int numvisent; // All things being rendered, for tracing against things you don't actually collide with physent_t visents[MAX_PHYSENTS]; - usercmd_t cmd; // input to run through physics. - int numtouch; // Trace results for objects we collided with. + usercmd_t cmd; // input to run through physics. + int numtouch; // Trace results for objects we collided with. pmtrace_t touchindex[MAX_PHYSENTS]; - char physinfo[MAX_PHYSINFO_STRING]; // Physics info string + char physinfo[MAX_PHYSINFO_STRING]; // Physics info string struct movevars_s *movevars; vec_t _player_mins[4][3]; vec_t _player_maxs[4][3]; @@ -194,6 +190,8 @@ typedef struct playermove_s const char *(*PM_TraceTexture)(int ground, float *vstart, float *vend); void (*PM_PlaybackEventFull)(int flags, int clientindex, unsigned short eventindex, float delay, float *origin, float *angles, float fparam1, float fparam2, int iparam1, int iparam2, int bparam1, int bparam2); -} playermove_t; + pmtrace_t (*PM_PlayerTraceEx)(float *start, float *end, int traceFlags, int (*pfnIgnore)(physent_t *pe)); + int (*PM_TestPlayerPositionEx)(float *pos, pmtrace_t *ptrace, int (*pfnIgnore)(physent_t *pe)); + struct pmtrace_s *(*PM_TraceLineEx)(float *start, float *end, int flags, int usehulll, int (*pfnIgnore)(physent_t *pe)); -#endif // PM_DEFS_H +} playermove_t; diff --git a/regamedll/pm_shared/pm_shared.cpp b/regamedll/pm_shared/pm_shared.cpp index 32fea661..1f1dbd29 100644 --- a/regamedll/pm_shared/pm_shared.cpp +++ b/regamedll/pm_shared/pm_shared.cpp @@ -40,15 +40,15 @@ void PM_SwapTextures(int i, int j) pm_grgchTextureType[j] = chTemp; } -NOXREF int PM_IsThereGrassTexture() +NOXREF qboolean PM_IsThereGrassTexture() { - for (int i = 0; i < pm_gcTextures; ++i) + for (int i = 0; i < pm_gcTextures; i++) { if (pm_grgchTextureType[i] == CHAR_TEX_GRASS) - return 1; + return TRUE; } - return 0; + return FALSE; } void PM_SortTextures() @@ -95,29 +95,29 @@ void PM_InitTextureTypes() { // skip whitespace i = 0; - while (buffer[i] && Q_isspace(buffer[i])) - ++i; + while (buffer[i] && isspace(buffer[i])) + i++; if (!buffer[i]) continue; // skip comment lines - if (buffer[i] == '/' || !Q_isalpha(buffer[i])) + if (buffer[i] == '/' || !isalpha(buffer[i])) continue; // get texture type - pm_grgchTextureType[pm_gcTextures] = Q_toupper(buffer[i++]); + pm_grgchTextureType[pm_gcTextures] = toupper(buffer[i++]); // skip whitespace - while (buffer[i] && Q_isspace(buffer[i])) - ++i; + while (buffer[i] && isspace(buffer[i])) + i++; if (!buffer[i]) continue; // get sentence name j = i; - while (buffer[j] && !Q_isspace(buffer[j])) + while (buffer[j] && !isspace(buffer[j])) j++; if (!buffer[j]) @@ -329,13 +329,13 @@ int PM_MapTextureTypeStepType(char chTextureType) { default: case CHAR_TEX_CONCRETE: return STEP_CONCRETE; - case CHAR_TEX_METAL: return STEP_METAL; - case CHAR_TEX_DIRT: return STEP_DIRT; - case CHAR_TEX_VENT: return STEP_VENT; - case CHAR_TEX_GRATE: return STEP_GRATE; - case CHAR_TEX_TILE: return STEP_TILE; - case CHAR_TEX_SLOSH: return STEP_SLOSH; - case CHAR_TEX_SNOW: return STEP_SNOW; + case CHAR_TEX_METAL: return STEP_METAL; + case CHAR_TEX_DIRT: return STEP_DIRT; + case CHAR_TEX_VENT: return STEP_VENT; + case CHAR_TEX_GRATE: return STEP_GRATE; + case CHAR_TEX_TILE: return STEP_TILE; + case CHAR_TEX_SLOSH: return STEP_SLOSH; + case CHAR_TEX_SNOW: return STEP_SNOW; } } @@ -453,32 +453,26 @@ void EXT_FUNC __API_HOOK(PM_UpdateStepSound)() fvol = 0.5; pmove->flTimeStepSound = 300; break; - case CHAR_TEX_METAL: fvol = 0.5; pmove->flTimeStepSound = 300; break; - case CHAR_TEX_DIRT: fvol = 0.55; pmove->flTimeStepSound = 300; break; - case CHAR_TEX_VENT: fvol = 0.7; pmove->flTimeStepSound = 300; break; - case CHAR_TEX_GRATE: fvol = 0.5; pmove->flTimeStepSound = 300; break; - case CHAR_TEX_TILE: fvol = 0.5; pmove->flTimeStepSound = 300; break; - case CHAR_TEX_SLOSH: fvol = 0.5; pmove->flTimeStepSound = 300; @@ -507,7 +501,7 @@ void EXT_FUNC __API_HOOK(PM_UpdateStepSound)() qboolean PM_AddToTouched(pmtrace_t tr, vec_t *impactvelocity) { int i; - for (i = 0; i < pmove->numtouch; ++i) + for (i = 0; i < pmove->numtouch; i++) { if (pmove->touchindex[i].ent == tr.ent) break; @@ -516,7 +510,7 @@ qboolean PM_AddToTouched(pmtrace_t tr, vec_t *impactvelocity) // Already in list. if (i != pmove->numtouch) { - return false; + return FALSE; } VectorCopy(impactvelocity, tr.deltavelocity); @@ -527,7 +521,7 @@ qboolean PM_AddToTouched(pmtrace_t tr, vec_t *impactvelocity) } pmove->touchindex[pmove->numtouch++] = tr; - return true; + return TRUE; } void PM_CheckVelocity() @@ -668,7 +662,7 @@ int PM_FlyMove() numbumps = 4; // Bump up to four times blocked = 0x00; // Assume not blocked - numplanes = 0; // and not sliding along any planes + numplanes = 0; // and not sliding along any planes VectorCopy(pmove->velocity, original_velocity); // Store original velocity VectorCopy(pmove->velocity, primal_velocity); @@ -767,7 +761,7 @@ int PM_FlyMove() // relfect player velocity if (numplanes == 1 && pmove->movetype == MOVETYPE_WALK && (pmove->onground == -1 || pmove->friction != 1)) { - for (i = 0; i < numplanes; ++i) + for (i = 0; i < numplanes; i++) { if (planes[i][2] > 0.7f) { @@ -863,13 +857,13 @@ void PM_Accelerate(vec_t *wishdir, float_precision wishspeed, float accel) accelspeed = addspeed; // Adjust velocity. - for (i = 0; i < 3; ++i) + for (i = 0; i < 3; i++) { pmove->velocity[i] += accelspeed * wishdir[i]; } } -// Only used by players. Moves along the ground when player is a MOVETYPE_WALK. +// Only used by players. Moves along the ground when player is a MOVETYPE_WALK. void PM_WalkMove() { int clip; @@ -1425,7 +1419,7 @@ qboolean PM_CheckWater() return (pmove->waterlevel > 1) ? TRUE : FALSE; } -void PM_CatagorizePosition() +void PM_CategorizePosition() { vec3_t point; pmtrace_t tr; @@ -1450,43 +1444,42 @@ void PM_CatagorizePosition() if (pmove->velocity[2] > 180) { pmove->onground = -1; + return; + } + + // Try and move down. + tr = pmove->PM_PlayerTrace(pmove->origin, point, PM_NORMAL, -1); + + // If we hit a steep plane, we are not on ground + if (tr.plane.normal[2] < 0.7f) + { + // too steep + pmove->onground = -1; } else { - // Try and move down. - tr = pmove->PM_PlayerTrace(pmove->origin, point, PM_NORMAL, -1); + // Otherwise, point to index of ent under us. + pmove->onground = tr.ent; + } - // If we hit a steep plane, we are not on ground - if (tr.plane.normal[2] < 0.7f) - { - // too steep - pmove->onground = -1; - } - else - { - // Otherwise, point to index of ent under us. - pmove->onground = tr.ent; - } + // If we are on something... + if (pmove->onground != -1) + { + // Then we are not in water jump sequence + pmove->waterjumptime = 0; - // If we are on something... - if (pmove->onground != -1) + // If we could make the move, drop us down that 1 pixel + if (pmove->waterlevel < 2 && !tr.startsolid && !tr.allsolid) { - // Then we are not in water jump sequence - pmove->waterjumptime = 0; - - // If we could make the move, drop us down that 1 pixel - if (pmove->waterlevel < 2 && !tr.startsolid && !tr.allsolid) - { - VectorCopy(tr.endpos, pmove->origin); - } + VectorCopy(tr.endpos, pmove->origin); } + } - // Standing on an entity other than the world - // So signal that we are touching something. - if (tr.ent > 0) - { - PM_AddToTouched(tr, pmove->velocity); - } + // Standing on an entity other than the world + // So signal that we are touching something. + if (tr.ent > 0) + { + PM_AddToTouched(tr, pmove->velocity); } } @@ -1796,7 +1789,7 @@ void PM_FixPlayerCrouchStuck(int direction) VectorCopy(pmove->origin, test); - for (i = 0; i < 36; ++i) + for (i = 0; i < 36; i++) { pmove->origin[2] += direction; hitent = pmove->PM_TestPlayerPosition(pmove->origin, NULL); @@ -1811,12 +1804,65 @@ void PM_FixPlayerCrouchStuck(int direction) VectorCopy(test, pmove->origin); } +void PM_UnDuck() +{ + pmtrace_t trace; + vec3_t newOrigin; + + VectorCopy(pmove->origin, newOrigin); + + if (pmove->onground != -1) + { +#ifdef REGAMEDLL_FIXES + vec3_t offset; + VectorSubtract(pmove->_player_mins[1], pmove->_player_mins[0], offset); + VectorAdd(newOrigin, offset, newOrigin); +#else + newOrigin[2] += 18.0; +#endif + } + + trace = pmove->PM_PlayerTrace(newOrigin, newOrigin, PM_NORMAL, -1); + if (!trace.startsolid) + { + pmove->usehull = 0; + + // Oh, no, changing hulls stuck us into something, try unsticking downward first. + trace = pmove->PM_PlayerTrace(newOrigin, newOrigin, PM_NORMAL, -1); + + if (trace.startsolid) + { + // See if we are stuck? If so, stay ducked with the duck hull until we have a clear spot + // Con_Printf("unstick got stuck\n"); + pmove->usehull = 1; + return; + } + + pmove->flags &= ~FL_DUCKING; + pmove->bInDuck = FALSE; + pmove->view_ofs[2] = PM_VEC_VIEW; + pmove->flDuckTime = 0; + + pmove->flTimeStepSound -= 100; + + if (pmove->flTimeStepSound < 0) + { + pmove->flTimeStepSound = 0; + } + + VectorCopy(newOrigin, pmove->origin); + + // Recatagorize position since ducking can change origin + PM_CategorizePosition(); + } +} + void PM_Duck() { float_precision duckFraction; int buttonsChanged = (pmove->oldbuttons ^ pmove->cmd.buttons); // These buttons have changed this frame - int nButtonPressed = buttonsChanged & pmove->cmd.buttons; // The changed ones still down are "pressed" + int nButtonPressed = buttonsChanged & pmove->cmd.buttons; // The changed ones still down are "pressed" int duckchange = buttonsChanged & IN_DUCK ? 1 : 0; int duckpressed = nButtonPressed & IN_DUCK ? 1 : 0; @@ -1830,8 +1876,14 @@ void PM_Duck() pmove->oldbuttons &= ~IN_DUCK; } - if (pmove->dead || (!(pmove->cmd.buttons & IN_DUCK) && !pmove->bInDuck && !(pmove->flags & FL_DUCKING))) + if (pmove->dead || !(pmove->cmd.buttons & IN_DUCK) && !pmove->bInDuck && !(pmove->flags & FL_DUCKING)) { +#ifdef REGAMEDLL_FIXES + if (pmove->flags & FL_DUCKING) + { + PM_UnDuck(); + } +#endif return; } @@ -1863,72 +1915,38 @@ void PM_Duck() // HACKHACK - Fudge for collision bug - no time to fix this properly if (pmove->onground != -1) { +#ifdef REGAMEDLL_FIXES + vec3_t newOrigin; + VectorSubtract(pmove->_player_mins[1], pmove->_player_mins[0], newOrigin); + VectorSubtract(pmove->origin, newOrigin, pmove->origin); +#else pmove->origin[2] = pmove->origin[2] - 18.0; +#endif // See if we are stuck? PM_FixPlayerCrouchStuck(STUCK_MOVEUP); // Recatagorize position since ducking can change origin - PM_CatagorizePosition(); + PM_CategorizePosition(); } } else { +#ifdef REGAMEDLL_FIXES + float fMore = (pmove->_player_mins[1] - pmove->_player_mins[0]); +#else float fMore = (PM_VEC_DUCK_HULL_MIN - PM_VEC_HULL_MIN); - +#endif // Calc parametric time duckFraction = PM_SplineFraction(time, (1.0 / TIME_TO_DUCK)); pmove->view_ofs[2] = ((PM_VEC_DUCK_VIEW - fMore) * duckFraction) + (PM_VEC_VIEW * (1 - duckFraction)); } } - } - else // Try to unduck + // Try to unduck + else { - pmtrace_t trace; - vec3_t newOrigin; - - VectorCopy(pmove->origin, newOrigin); - - if (pmove->onground != -1) - { - newOrigin[2] += 18.0; - } - - trace = pmove->PM_PlayerTrace(newOrigin, newOrigin, PM_NORMAL, -1); - - if (!trace.startsolid) - { - pmove->usehull = 0; - - // Oh, no, changing hulls stuck us into something, try unsticking downward first. - trace = pmove->PM_PlayerTrace(newOrigin, newOrigin, PM_NORMAL, -1); - - if (trace.startsolid) - { - // See if we are stuck? If so, stay ducked with the duck hull until we have a clear spot - // Con_Printf("unstick got stuck\n"); - pmove->usehull = 1; - return; - } - - pmove->flags &= ~FL_DUCKING; - pmove->bInDuck = FALSE; - pmove->view_ofs[2] = PM_VEC_VIEW; - pmove->flDuckTime = 0; - - pmove->flTimeStepSound -= 100; - - if (pmove->flTimeStepSound < 0) - { - pmove->flTimeStepSound = 0; - } - - VectorCopy(newOrigin, pmove->origin); - - // Recatagorize position since ducking can change origin - PM_CatagorizePosition(); - } + PM_UnDuck(); } } @@ -2057,7 +2075,7 @@ physent_t *PM_Ladder() int num; vec3_t test; - for (i = 0; i < pmove->nummoveent; ++i) + for (i = 0; i < pmove->nummoveent; i++) { pe = &pmove->moveents[i]; @@ -2638,7 +2656,7 @@ void PM_DropPunchAngle(vec_t *punchangle) VectorScale(punchangle, len, punchangle); } -void PM_CheckParamters() +void PM_CheckParameters() { float spd; float_precision maxspeed; @@ -2690,6 +2708,14 @@ void PM_CheckParamters() // Set dead player view_offset if (pmove->dead) { +#ifdef REGAMEDLL_FIXES + if (pmove->bInDuck) + { + PM_UnDuck(); + pmove->bInDuck = FALSE; + } +#endif + pmove->view_ofs[2] = PM_DEAD_VIEWHEIGHT; } @@ -2759,7 +2785,7 @@ void PM_PlayerMove(qboolean server) pmove->server = server; // Adjust speeds etc. - PM_CheckParamters(); + PM_CheckParameters(); // Assume we don't touch anything pmove->numtouch = 0; @@ -2780,7 +2806,7 @@ void PM_PlayerMove(qboolean server) if ((pmove->spectator || pmove->iuser1 > 0) && PM_ShouldDoSpectMode()) { PM_SpectatorMove(); - PM_CatagorizePosition(); + PM_CategorizePosition(); return; } @@ -2795,7 +2821,7 @@ void PM_PlayerMove(qboolean server) } // Now that we are "unstuck", see where we are (waterlevel and type, pmove->onground). - PM_CatagorizePosition(); + PM_CategorizePosition(); // Store off the starting water level pmove->oldwaterlevel = pmove->waterlevel; @@ -2813,7 +2839,7 @@ void PM_PlayerMove(qboolean server) { pLadder = PM_Ladder(); - if (pLadder != NULL) + if (pLadder) { g_onladder = 1; } @@ -2825,7 +2851,7 @@ void PM_PlayerMove(qboolean server) // Don't run ladder code if dead or on a train if (!pmove->dead && !(pmove->flags & FL_ONTRAIN)) { - if (pLadder != NULL) + if (pLadder) { PM_LadderMove(pLadder); } @@ -2928,7 +2954,7 @@ void PM_PlayerMove(qboolean server) VectorSubtract(pmove->velocity, pmove->basevelocity, pmove->velocity); // Get a final position - PM_CatagorizePosition(); + PM_CategorizePosition(); } // Not underwater else @@ -2969,7 +2995,7 @@ void PM_PlayerMove(qboolean server) } // Set final flags. - PM_CatagorizePosition(); + PM_CategorizePosition(); // Now pull the base velocity back out. // Base velocity is set if you are on a moving object, like @@ -2991,8 +3017,7 @@ void PM_PlayerMove(qboolean server) pmove->velocity[2] = 0; } - // See if we landed on the ground with enough force to play - // a landing sound. + // See if we landed on the ground with enough force to play a landing sound. PM_CheckFalling(); } diff --git a/regamedll/public/FileSystem.h b/regamedll/public/FileSystem.h index 4a3c6216..8e202baa 100644 --- a/regamedll/public/FileSystem.h +++ b/regamedll/public/FileSystem.h @@ -1,32 +1,54 @@ -//========= Copyright � 1996-2001, Valve LLC, All rights reserved. ============ -// -// Purpose: -// -// $NoKeywords: $ -//============================================================================= +/* +* +* This program is free software; you can redistribute it and/or modify it +* under the terms of the GNU General Public License as published by the +* Free Software Foundation; either version 2 of the License, or (at +* your option) any later version. +* +* This program 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 +* General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software Foundation, +* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +* +* In addition, as a special exception, the author gives permission to +* link the code of this program with the Half-Life Game Engine ("HL +* Engine") and Modified Game Libraries ("MODs") developed by Valve, +* L.L.C ("Valve"). You must obey the GNU General Public License in all +* respects for all of the code used other than the HL Engine and MODs +* from Valve. If you modify this file, you may extend this exception +* to your version of the file, but you are not obligated to do so. If +* you do not wish to do so, delete this exception statement from your +* version. +* +*/ -#ifndef FILESYSTEM_H -#define FILESYSTEM_H -#ifdef _WIN32 #pragma once -#endif #include "interface.h" #include #include +// There is only one instance of the IFileSystem interface, +// located in the filesystem_stdio library (filesystem_steam is obsolete). +#ifdef _WIN32 + #define STDIO_FILESYSTEM_LIB "filesystem_stdio.dll" + #define STEAM_FILESYSTEM_LIB "filesystem_steam.dll" +#else + #define STDIO_FILESYSTEM_LIB "filesystem_stdio.so" + #define STEAM_FILESYSTEM_LIB "filesystem_steam.so" +#endif // _WIN32 -//----------------------------------------------------------------------------- // Forward declarations -//----------------------------------------------------------------------------- -typedef FILE * FileHandle_t; +typedef FILE *FileHandle_t; typedef int FileFindHandle_t; typedef int WaitForResourcesHandle_t; +typedef void (*WarningFunc_t)(const char *fmt, ...); - -//----------------------------------------------------------------------------- // Enums used by the interface -//----------------------------------------------------------------------------- #ifndef FILESYSTEM_INTERNAL_H typedef enum { @@ -42,148 +64,138 @@ enum typedef enum { - // Don't print anything - FILESYSTEM_WARNING_QUIET = 0, - - // On shutdown, report names of files left unclosed - FILESYSTEM_WARNING_REPORTUNCLOSED, - - // Report number of times a file was opened, closed - FILESYSTEM_WARNING_REPORTUSAGE, - - // Report all open/close events to console ( !slow! ) - FILESYSTEM_WARNING_REPORTALLACCESSES + FILESYSTEM_WARNING_QUIET = 0, // Don't print anything + FILESYSTEM_WARNING_REPORTUNCLOSED, // On shutdown, report names of files left unclosed + FILESYSTEM_WARNING_REPORTUSAGE, // Report number of times a file was opened, closed + FILESYSTEM_WARNING_REPORTALLACCESSES // Report all open/close events to console (!slow!) } FileWarningLevel_t; -#define FILESYSTEM_INVALID_HANDLE ( FileHandle_t )0 -#endif +#define FILESYSTEM_INVALID_HANDLE (FileHandle_t)0 +#endif // FILESYSTEM_INTERNAL_H // turn off any windows defines #undef GetCurrentDirectory -//----------------------------------------------------------------------------- // Purpose: Main file system interface -//----------------------------------------------------------------------------- class IFileSystem : public IBaseInterface { public: // Mount and unmount the filesystem - virtual void Mount( void ) = 0; - virtual void Unmount( void ) = 0; + virtual void Mount() = 0; + virtual void Unmount() = 0; // Remove all search paths (including write path?) - virtual void RemoveAllSearchPaths( void ) = 0; + virtual void RemoveAllSearchPaths() = 0; // Add paths in priority order (mod dir, game dir, ....) // If one or more .pak files are in the specified directory, then they are // added after the file system path - // If the path is the relative path to a .bsp file, then any previous .bsp file + // If the path is the relative path to a .bsp file, then any previous .bsp file // override is cleared and the current .bsp is searched for an embedded PAK file - // and this file becomes the highest priority search path ( i.e., it's looked at first - // even before the mod's file system path ). - virtual void AddSearchPath( const char *pPath, const char *pathID ) = 0; - virtual bool RemoveSearchPath( const char *pPath ) = 0; + // and this file becomes the highest priority search path (i.e., it's looked at first + // even before the mod's file system path). + virtual void AddSearchPath(const char *pPath, const char *pathID) = 0; + virtual bool RemoveSearchPath(const char *pPath) = 0; // Deletes a file - virtual void RemoveFile( const char *pRelativePath, const char *pathID ) = 0; + virtual void RemoveFile(const char *pRelativePath, const char *pathID) = 0; // this isn't implementable on STEAM as is. - virtual void CreateDirHierarchy( const char *path, const char *pathID ) = 0; + virtual void CreateDirHierarchy(const char *path, const char *pathID) = 0; // File I/O and info - virtual bool FileExists( const char *pFileName ) = 0; - virtual bool IsDirectory( const char *pFileName ) = 0; + virtual bool FileExists(const char *pFileName) = 0; + virtual bool IsDirectory(const char *pFileName) = 0; // opens a file // if pathID is NULL, all paths will be searched for the file - virtual FileHandle_t Open( const char *pFileName, const char *pOptions, const char *pathID = 0L ) = 0; + virtual FileHandle_t Open(const char *pFileName, const char *pOptions, const char *pathID = 0L) = 0; - virtual void Close( FileHandle_t file ) = 0; + virtual void Close(FileHandle_t file) = 0; - virtual void Seek( FileHandle_t file, int pos, FileSystemSeek_t seekType ) = 0; - virtual unsigned int Tell( FileHandle_t file ) = 0; + virtual void Seek(FileHandle_t file, int pos, FileSystemSeek_t seekType) = 0; + virtual unsigned int Tell(FileHandle_t file) = 0; - virtual unsigned int Size( FileHandle_t file ) = 0; - virtual unsigned int Size( const char *pFileName ) = 0; + virtual unsigned int Size(FileHandle_t file) = 0; + virtual unsigned int Size(const char *pFileName) = 0; - virtual long GetFileTime( const char *pFileName ) = 0; - virtual void FileTimeToString( char* pStrip, int maxCharsIncludingTerminator, long fileTime ) = 0; + virtual long GetFileTime(const char *pFileName) = 0; + virtual void FileTimeToString(char *pStrip, int maxCharsIncludingTerminator, long fileTime) = 0; - virtual bool IsOk( FileHandle_t file ) = 0; + virtual bool IsOk(FileHandle_t file) = 0; - virtual void Flush( FileHandle_t file ) = 0; - virtual bool EndOfFile( FileHandle_t file ) = 0; + virtual void Flush(FileHandle_t file) = 0; + virtual bool EndOfFile(FileHandle_t file) = 0; - virtual int Read( void* pOutput, int size, FileHandle_t file ) = 0; - virtual int Write( void const* pInput, int size, FileHandle_t file ) = 0; - virtual char *ReadLine( char *pOutput, int maxChars, FileHandle_t file ) = 0; - virtual int FPrintf( FileHandle_t file, char *pFormat, ... ) = 0; + virtual int Read(void *pOutput, int size, FileHandle_t file) = 0; + virtual int Write(void const *pInput, int size, FileHandle_t file) = 0; + virtual char *ReadLine(char *pOutput, int maxChars, FileHandle_t file) = 0; + virtual int FPrintf(FileHandle_t file, char *pFormat, ...) = 0; // direct filesystem buffer access // returns a handle to a buffer containing the file data - // this is the optimal way to access the complete data for a file, + // this is the optimal way to access the complete data for a file, // since the file preloader has probably already got it in memory - virtual void *GetReadBuffer( FileHandle_t file, int *outBufferSize, bool failIfNotInCache ) = 0; - virtual void ReleaseReadBuffer( FileHandle_t file, void *readBuffer ) = 0; + virtual void *GetReadBuffer(FileHandle_t file, int *outBufferSize, bool failIfNotInCache) = 0; + virtual void ReleaseReadBuffer(FileHandle_t file, void *readBuffer) = 0; // FindFirst/FindNext - virtual const char *FindFirst( const char *pWildCard, FileFindHandle_t *pHandle, const char *pathID = 0L ) = 0; - virtual const char *FindNext( FileFindHandle_t handle ) = 0; - virtual bool FindIsDirectory( FileFindHandle_t handle ) = 0; - virtual void FindClose( FileFindHandle_t handle ) = 0; + virtual const char *FindFirst(const char *pWildCard, FileFindHandle_t *pHandle, const char *pathID = 0L) = 0; + virtual const char *FindNext(FileFindHandle_t handle) = 0; + virtual bool FindIsDirectory(FileFindHandle_t handle) = 0; + virtual void FindClose(FileFindHandle_t handle) = 0; - virtual void GetLocalCopy( const char *pFileName ) = 0; + virtual void GetLocalCopy(const char *pFileName) = 0; - virtual const char *GetLocalPath( const char *pFileName, char *pLocalPath, int localPathBufferSize ) = 0; + virtual const char *GetLocalPath(const char *pFileName, char *pLocalPath, int localPathBufferSize) = 0; // Note: This is sort of a secondary feature; but it's really useful to have it here - virtual char *ParseFile( char* pFileBytes, char* pToken, bool* pWasQuoted ) = 0; + virtual char *ParseFile(char *pFileBytes, char *pToken, bool *pWasQuoted) = 0; - // Returns true on success ( based on current list of search paths, otherwise false if it can't be resolved ) - virtual bool FullPathToRelativePath( const char *pFullpath, char *pRelative ) = 0; + // Returns true on success (based on current list of search paths, otherwise false if it can't be resolved) + virtual bool FullPathToRelativePath(const char *pFullpath, char *pRelative) = 0; // Gets the current working directory - virtual bool GetCurrentDirectory( char* pDirectory, int maxlen ) = 0; + virtual bool GetCurrentDirectory(char *pDirectory, int maxlen) = 0; // Dump to printf/OutputDebugString the list of files that have not been closed - virtual void PrintOpenedFiles( void ) = 0; + virtual void PrintOpenedFiles() = 0; - virtual void SetWarningFunc( void (*pfnWarning)( const char *fmt, ... ) ) = 0; - virtual void SetWarningLevel( FileWarningLevel_t level ) = 0; + virtual void SetWarningFunc(WarningFunc_t pfnWarning) = 0; + virtual void SetWarningLevel(FileWarningLevel_t level) = 0; - virtual void LogLevelLoadStarted( const char *name ) = 0; - virtual void LogLevelLoadFinished( const char *name ) = 0; - virtual int HintResourceNeed( const char *hintlist, int forgetEverything ) = 0; - virtual int PauseResourcePreloading( void ) = 0; - virtual int ResumeResourcePreloading( void ) = 0; - virtual int SetVBuf( FileHandle_t stream, char *buffer, int mode, long size ) = 0; - virtual void GetInterfaceVersion( char *p, int maxlen ) = 0; + virtual void LogLevelLoadStarted(const char *name) = 0; + virtual void LogLevelLoadFinished(const char *name) = 0; + virtual int HintResourceNeed(const char *hintlist, int forgetEverything) = 0; + virtual int PauseResourcePreloading() = 0; + virtual int ResumeResourcePreloading() = 0; + virtual int SetVBuf(FileHandle_t stream, char *buffer, int mode, long size) = 0; + virtual void GetInterfaceVersion(char *p, int maxlen) = 0; virtual bool IsFileImmediatelyAvailable(const char *pFileName) = 0; // starts waiting for resources to be available // returns FILESYSTEM_INVALID_HANDLE if there is nothing to wait on - virtual WaitForResourcesHandle_t WaitForResources( const char *resourcelist ) = 0; + virtual WaitForResourcesHandle_t WaitForResources(const char *resourcelist) = 0; + // get progress on waiting for resources; progress is a float [0, 1], complete is true on the waiting being done // returns false if no progress is available // any calls after complete is true or on an invalid handle will return false, 0.0f, true - virtual bool GetWaitForResourcesProgress( WaitForResourcesHandle_t handle, float *progress /* out */ , bool *complete /* out */ ) = 0; + virtual bool GetWaitForResourcesProgress(WaitForResourcesHandle_t handle, float *progress /* out */ , bool *complete /* out */) = 0; + // cancels a progress call - virtual void CancelWaitForResources( WaitForResourcesHandle_t handle ) = 0; + virtual void CancelWaitForResources(WaitForResourcesHandle_t handle) = 0; // returns true if the appID has all its caches fully preloaded - virtual bool IsAppReadyForOfflinePlay( int appID ) = 0; + virtual bool IsAppReadyForOfflinePlay(int appID) = 0; // interface for custom pack files > 4Gb - virtual bool AddPackFile( const char *fullpath, const char *pathID ) = 0; - - // open a file but force the data to come from the steam cache, NOT from disk - virtual FileHandle_t OpenFromCacheForRead( const char *pFileName, const char *pOptions, const char *pathID = 0L ) = 0; + virtual bool AddPackFile(const char *fullpath, const char *pathID) = 0; - virtual void AddSearchPathNoWrite( const char *pPath, const char *pathID ) = 0; + // open a file but force the data to come from the steam cache, NOT from disk + virtual FileHandle_t OpenFromCacheForRead(const char *pFileName, const char *pOptions, const char *pathID = 0L) = 0; + virtual void AddSearchPathNoWrite(const char *pPath, const char *pathID) = 0; }; // Steam3/Src compat #define IBaseFileSystem IFileSystem #define FILESYSTEM_INTERFACE_VERSION "VFileSystem009" - -#endif // FILESYSTEM_H diff --git a/regamedll/public/MemPool.cpp b/regamedll/public/MemPool.cpp index f7aedfcd..760635fe 100644 --- a/regamedll/public/MemPool.cpp +++ b/regamedll/public/MemPool.cpp @@ -1,3 +1,31 @@ +/* +* +* This program is free software; you can redistribute it and/or modify it +* under the terms of the GNU General Public License as published by the +* Free Software Foundation; either version 2 of the License, or (at +* your option) any later version. +* +* This program 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 +* General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software Foundation, +* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +* +* In addition, as a special exception, the author gives permission to +* link the code of this program with the Half-Life Game Engine ("HL +* Engine") and Modified Game Libraries ("MODs") developed by Valve, +* L.L.C ("Valve"). You must obey the GNU General Public License in all +* respects for all of the code used other than the HL Engine and MODs +* from Valve. If you modify this file, you may extend this exception +* to your version of the file, but you are not obligated to do so. If +* you do not wish to do so, delete this exception statement from your +* version. +* +*/ + #include "precompiled.h" CMemoryPool::CMemoryPool(int blockSize, int numElements) diff --git a/regamedll/public/MemPool.h b/regamedll/public/MemPool.h index 4e8c3b49..f5054bbb 100644 --- a/regamedll/public/MemPool.h +++ b/regamedll/public/MemPool.h @@ -26,11 +26,7 @@ * */ -#ifndef MEMPOOL_H -#define MEMPOOL_H -#ifdef _WIN32 #pragma once -#endif class CMemoryPool { @@ -55,5 +51,3 @@ public: int _peakAlloc; int _blocksAllocated; }; - -#endif // MEMPOOL_H diff --git a/regamedll/public/basetypes.h b/regamedll/public/basetypes.h index 52d81f91..b56ef3f4 100644 --- a/regamedll/public/basetypes.h +++ b/regamedll/public/basetypes.h @@ -1,9 +1,30 @@ -//========= Copyright 1996-2001, Valve LLC, All rights reserved. ============ -// -// Purpose: -// -// $NoKeywords: $ -//============================================================================= +/* +* +* This program is free software; you can redistribute it and/or modify it +* under the terms of the GNU General Public License as published by the +* Free Software Foundation; either version 2 of the License, or (at +* your option) any later version. +* +* This program 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 +* General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software Foundation, +* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +* +* In addition, as a special exception, the author gives permission to +* link the code of this program with the Half-Life Game Engine ("HL +* Engine") and Modified Game Libraries ("MODs") developed by Valve, +* L.L.C ("Valve"). You must obey the GNU General Public License in all +* respects for all of the code used other than the HL Engine and MODs +* from Valve. If you modify this file, you may extend this exception +* to your version of the file, but you are not obligated to do so. If +* you do not wish to do so, delete this exception statement from your +* version. +* +*/ #ifndef BASETYPES_H #define BASETYPES_H @@ -12,7 +33,6 @@ #endif #include "osconfig.h" -#include "protected_things.h" #include "commonmacros.h" #include "mathlib.h" @@ -25,32 +45,16 @@ #define NULL 0 #endif - -#define ExecuteNTimes( nTimes, x ) \ - { \ - static int __executeCount=0;\ - if ( __executeCount < nTimes )\ - { \ - x; \ - ++__executeCount; \ - } \ - } - - -#define ExecuteOnce( x ) ExecuteNTimes( 1, x ) - - // Pad a number so it lies on an N byte boundary. // So PAD_NUMBER(0,4) is 0 and PAD_NUMBER(1,4) is 4 #define PAD_NUMBER(number, boundary) \ - ( ((number) + ((boundary)-1)) / (boundary) ) * (boundary) + (((number) + ((boundary) - 1)) / (boundary)) * (boundary) #ifndef FALSE #define FALSE 0 #define TRUE (!FALSE) #endif - typedef int BOOL; typedef int qboolean; typedef unsigned long ULONG; @@ -60,216 +64,14 @@ typedef unsigned short word; typedef float vec_t; - -// FIXME: this should move -#ifndef __cplusplus -#define true TRUE -#define false FALSE -#endif - -//----------------------------------------------------------------------------- -// look for NANs, infinities, and underflows. -// This assumes the ANSI/IEEE 754-1985 standard -//----------------------------------------------------------------------------- - -#ifdef __cplusplus - -inline unsigned long& FloatBits(vec_t& f) -{ - return *reinterpret_cast(&f); -} - -inline unsigned long const& FloatBits(vec_t const& f) -{ - return *reinterpret_cast(&f); -} - -inline vec_t BitsToFloat(unsigned long i) -{ - return *reinterpret_cast(&i); -} - -inline bool IsFinite(vec_t f) -{ - return ((FloatBits(f) & 0x7F800000) != 0x7F800000); -} - -inline unsigned long FloatAbsBits(vec_t f) -{ - return FloatBits(f) & 0x7FFFFFFF; -} - -inline float FloatMakeNegative(vec_t f) -{ - return BitsToFloat(FloatBits(f) | 0x80000000); -} - -#if defined( WIN32 ) - -//#include -// Just use prototype from math.h -#ifdef __cplusplus -extern "C" -{ -#endif - double __cdecl fabs(double); -#ifdef __cplusplus -} -#endif - -// In win32 try to use the intrinsic fabs so the optimizer can do it's thing inline in the code -#pragma intrinsic( fabs ) -// Also, alias float make positive to use fabs, too -// NOTE: Is there a perf issue with double<->float conversion? -inline float FloatMakePositive(vec_t f) -{ - return fabs(f); -} -#else -inline float FloatMakePositive(vec_t f) -{ - return BitsToFloat(FloatBits(f) & 0x7FFFFFFF); -} -#endif - -inline float FloatNegate(vec_t f) -{ - return BitsToFloat(FloatBits(f) ^ 0x80000000); -} - - -#define FLOAT32_NAN_BITS (unsigned long)0x7FC00000 // not a number! -#define FLOAT32_NAN BitsToFloat( FLOAT32_NAN_BITS ) - -#define VEC_T_NAN FLOAT32_NAN - -#endif - -// FIXME: why are these here? Hardly anyone actually needs them. -struct valve_color24 -{ - byte r, g, b; -}; - -typedef struct valve_color32_s -{ - bool operator!=(const struct valve_color32_s &other) const; - - byte r, g, b, a; -} valve_color32; - -inline bool valve_color32::operator!=(const valve_color32 &other) const -{ - return r != other.r || g != other.g || b != other.b || a != other.a; -} - -struct valve_colorRGBExp32 -{ - byte r, g, b; - signed char exponent; -}; - -struct valve_colorVec -{ - unsigned r, g, b, a; -}; - - #ifndef UNUSED #define UNUSED(x) (x = x) // for pesky compiler / lint warnings #endif -#ifdef __cplusplus - struct vrect_t { - int x, y, width, height; - vrect_t *pnext; + int x, y, width, height; + vrect_t *pnext; }; -#endif - - -//----------------------------------------------------------------------------- -// MaterialRect_t struct - used for DrawDebugText -//----------------------------------------------------------------------------- -struct Rect_t -{ - int x, y; - int width, height; -}; - - -//----------------------------------------------------------------------------- -// Declares a type-safe handle type; you can't assign one handle to the next -//----------------------------------------------------------------------------- - -// 32-bit pointer handles. - -// Typesafe 8-bit and 16-bit handles. -template< class HandleType > -class CBaseIntHandle -{ -public: - - inline bool operator==(const CBaseIntHandle &other) { return m_Handle == other.m_Handle; } - inline bool operator!=(const CBaseIntHandle &other) { return m_Handle != other.m_Handle; } - - // Only the code that doles out these handles should use these functions. - // Everyone else should treat them as a transparent type. - inline HandleType GetHandleValue() { return m_Handle; } - inline void SetHandleValue(HandleType val) { m_Handle = val; } - - typedef HandleType HANDLE_TYPE; - -protected: - - HandleType m_Handle; -}; - -template< class DummyType > -class CIntHandle16 : public CBaseIntHandle < unsigned short > -{ -public: - inline CIntHandle16() {} - - static inline CIntHandle16 MakeHandle(HANDLE_TYPE val) - { - return CIntHandle16(val); - } - -protected: - inline CIntHandle16(HANDLE_TYPE val) - { - m_Handle = val; - } -}; - - -template< class DummyType > -class CIntHandle32 : public CBaseIntHandle < unsigned long > -{ -public: - inline CIntHandle32() {} - - static inline CIntHandle32 MakeHandle(HANDLE_TYPE val) - { - return CIntHandle32(val); - } - -protected: - inline CIntHandle32(HANDLE_TYPE val) - { - m_Handle = val; - } -}; - - -// NOTE: This macro is the same as windows uses; so don't change the guts of it -#define DECLARE_HANDLE_16BIT(name) typedef CIntHandle16< struct name##__handle * > name; -#define DECLARE_HANDLE_32BIT(name) typedef CIntHandle32< struct name##__handle * > name; - -#define DECLARE_POINTER_HANDLE(name) struct name##__ { int unused; }; typedef struct name##__ *name -#define FORWARD_DECLARE_HANDLE(name) typedef struct name##__ *name - #endif // BASETYPES_H diff --git a/regamedll/public/commonmacros.h b/regamedll/public/commonmacros.h index d6a6aec9..4a847e55 100644 --- a/regamedll/public/commonmacros.h +++ b/regamedll/public/commonmacros.h @@ -1,30 +1,49 @@ -#ifndef COMMONMACROS_H -#define COMMONMACROS_H +/* +* +* This program is free software; you can redistribute it and/or modify it +* under the terms of the GNU General Public License as published by the +* Free Software Foundation; either version 2 of the License, or (at +* your option) any later version. +* +* This program 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 +* General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software Foundation, +* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +* +* In addition, as a special exception, the author gives permission to +* link the code of this program with the Half-Life Game Engine ("HL +* Engine") and Modified Game Libraries ("MODs") developed by Valve, +* L.L.C ("Valve"). You must obey the GNU General Public License in all +* respects for all of the code used other than the HL Engine and MODs +* from Valve. If you modify this file, you may extend this exception +* to your version of the file, but you are not obligated to do so. If +* you do not wish to do so, delete this exception statement from your +* version. +* +*/ + #pragma once - -// ------------------------------------------------------- -// -// commonmacros.h -// -// This should contain ONLY general purpose macros that are -// appropriate for use in engine/launcher/all tools -// -// ------------------------------------------------------- - #include "osconfig.h" + +template +char(&ArraySizeHelper(T(&array)[N]))[N]; + +#undef ARRAYSIZE +#define ARRAYSIZE(array) (sizeof(ArraySizeHelper(array))) + // Makes a 4-byte "packed ID" int out of 4 characters -#define MAKEID(d,c,b,a) ( ((int)(a) << 24) | ((int)(b) << 16) | ((int)(c) << 8) | ((int)(d)) ) +#define MAKEID(d, c, b, a) (((int)(a)<<24) | ((int)(b)<<16) | ((int)(c)<<8) | ((int)(d))) // Compares a string with a 4-byte packed ID constant -#define STRING_MATCHES_ID( p, id ) ( (*((int *)(p)) == (id) ) ? true : false ) -#define ID_TO_STRING( id, p ) ( (p)[3] = (((id)>>24) & 0xFF), (p)[2] = (((id)>>16) & 0xFF), (p)[1] = (((id)>>8) & 0xFF), (p)[0] = (((id)>>0) & 0xFF) ) - -#define ARRAYSIZE(p) (sizeof(p)/sizeof(p[0])) +#define STRING_MATCHES_ID(p, id) ((*((int *)(p)) == (id)) ? true : false) +#define ID_TO_STRING(id, p) ((p)[3] = (((id)>>24) & 0xFF), (p)[2] = (((id)>>16) & 0xFF), (p)[1] = (((id)>>8) & 0xFF), (p)[0] = (((id)>>0) & 0xFF)) // Keeps clutter down a bit, when using a float as a bit-vector -#define SETBITS(flBitVector, bits) ((flBitVector) = (int)(flBitVector) | (bits)) -#define CLEARBITS(flBitVector, bits) ((flBitVector) = (int)(flBitVector) & ~(bits)) -#define FBitSet(flBitVector, bit) ((flBitVector) & (bit)) - -#endif // COMMONMACROS_H +#define SetBits (flBitVector, bits) ((flBitVector) = (int)(flBitVector) | (bits)) +#define ClearBits(flBitVector, bits) ((flBitVector) = (int)(flBitVector) & ~(bits)) +#define FBitSet (flBitVector, bit) ((int)(flBitVector) & (bit)) diff --git a/regamedll/public/interface.cpp b/regamedll/public/interface.cpp index bb7a19eb..bf58103b 100644 --- a/regamedll/public/interface.cpp +++ b/regamedll/public/interface.cpp @@ -1,26 +1,98 @@ +/* +* +* This program is free software; you can redistribute it and/or modify it +* under the terms of the GNU General Public License as published by the +* Free Software Foundation; either version 2 of the License, or (at +* your option) any later version. +* +* This program 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 +* General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software Foundation, +* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +* +* In addition, as a special exception, the author gives permission to +* link the code of this program with the Half-Life Game Engine ("HL +* Engine") and Modified Game Libraries ("MODs") developed by Valve, +* L.L.C ("Valve"). You must obey the GNU General Public License in all +* respects for all of the code used other than the HL Engine and MODs +* from Valve. If you modify this file, you may extend this exception +* to your version of the file, but you are not obligated to do so. If +* you do not wish to do so, delete this exception statement from your +* version. +* +*/ + #include "precompiled.h" +#ifdef _WIN32 + #define WIN32_LEAN_AND_MEAN + #include "windows.h" +#endif // _WIN32 -#if !defined ( _WIN32 ) +// InterfaceReg +InterfaceReg *InterfaceReg::s_pInterfaceRegs = nullptr; + +InterfaceReg::InterfaceReg(InstantiateInterfaceFn fn, const char *pName) : m_pName(pName) +{ + m_CreateFn = fn; + m_pNext = s_pInterfaceRegs; + s_pInterfaceRegs = this; +} + +// This is the primary exported function by a dll, referenced by name via dynamic binding +// that exposes an opqaue function pointer to the interface. +// +// We have the Internal variant so Sys_GetFactoryThis() returns the correct internal +// symbol under GCC/Linux/Mac as CreateInterface is DLL_EXPORT so its global so the loaders +// on those OS's pick exactly 1 of the CreateInterface symbols to be the one that is process wide and +// all Sys_GetFactoryThis() calls find that one, which doesn't work. Using the internal walkthrough here +// makes sure Sys_GetFactoryThis() has the dll specific symbol and GetProcAddress() returns the module specific +// function for CreateInterface again getting the dll specific symbol we need. +EXPORT_FUNCTION IBaseInterface *CreateInterface(const char *pName, int *pReturnCode) +{ + InterfaceReg *pCur; + for (pCur = InterfaceReg::s_pInterfaceRegs; pCur; pCur = pCur->m_pNext) + { + if (strcmp(pCur->m_pName, pName) == 0) + { + if (pReturnCode) + { + *pReturnCode = IFACE_OK; + } + + return pCur->m_CreateFn(); + } + } + + if (pReturnCode) + { + *pReturnCode = IFACE_FAILED; + } + + return nullptr; +} + +#ifndef _WIN32 // Linux doesn't have this function so this emulates its functionality -// -// void *GetModuleHandle(const char *name) { void *handle; - - if (name == NULL) + if (name == nullptr) { // hmm, how can this be handled under linux.... // is it even needed? - return NULL; + return nullptr; } - if ((handle=dlopen(name, RTLD_NOW)) == NULL) + if ((handle = dlopen(name, RTLD_NOW)) == nullptr) { //printf("Error:%s\n",dlerror()); // couldn't open this file - return NULL; + return nullptr; } // read "man dlopen" for details @@ -29,151 +101,67 @@ void *GetModuleHandle(const char *name) dlclose(handle); return handle; } -#endif +#endif // _WIN32 -// ------------------------------------------------------------------------------------ // -// InterfaceReg. -// ------------------------------------------------------------------------------------ // -InterfaceReg *InterfaceReg::s_pInterfaceRegs = NULL; - - -InterfaceReg::InterfaceReg( InstantiateInterfaceFn fn, const char *pName ) : m_pName(pName) -{ - m_CreateFn = fn; - m_pNext = s_pInterfaceRegs; - s_pInterfaceRegs = this; -} - - - -// ------------------------------------------------------------------------------------ // -// CreateInterface. -// ------------------------------------------------------------------------------------ // -EXPORT_FUNCTION IBaseInterface *CreateInterface( const char *pName, int *pReturnCode ) -{ - InterfaceReg *pCur; - - for(pCur=InterfaceReg::s_pInterfaceRegs; pCur; pCur=pCur->m_pNext) - { - if(strcmp(pCur->m_pName, pName) == 0) - { - if ( pReturnCode ) - { - *pReturnCode = IFACE_OK; - } - return pCur->m_CreateFn(); - } - } - - if ( pReturnCode ) - { - *pReturnCode = IFACE_FAILED; - } - return NULL; -} - -#ifdef LINUX -static IBaseInterface *CreateInterfaceLocal( const char *pName, int *pReturnCode ) -{ - InterfaceReg *pCur; - - for(pCur=InterfaceReg::s_pInterfaceRegs; pCur; pCur=pCur->m_pNext) - { - if(strcmp(pCur->m_pName, pName) == 0) - { - if ( pReturnCode ) - { - *pReturnCode = IFACE_OK; - } - return pCur->m_CreateFn(); - } - } - - if ( pReturnCode ) - { - *pReturnCode = IFACE_FAILED; - } - return NULL; -} -#endif - -#ifdef _WIN32 -#define WIN32_LEAN_AND_MEAN -#include "windows.h" -#endif - -//----------------------------------------------------------------------------- // Purpose: returns a pointer to a function, given a module // Input : pModuleName - module name // *pName - proc name -//----------------------------------------------------------------------------- -//static hlds_run wants to use this function -void *Sys_GetProcAddress( const char *pModuleName, const char *pName ) +//static hlds_run wants to use this function +void *Sys_GetProcAddress(const char *pModuleName, const char *pName) { - return GetProcAddress( GetModuleHandle(pModuleName), pName ); + return GetProcAddress(GetModuleHandle(pModuleName), pName); } -//----------------------------------------------------------------------------- // Purpose: returns a pointer to a function, given a module // Input : pModuleName - module name // *pName - proc name -//----------------------------------------------------------------------------- -// hlds_run wants to use this function -void *Sys_GetProcAddress( void *pModuleHandle, const char *pName ) +// hlds_run wants to use this function +void *Sys_GetProcAddress(void *pModuleHandle, const char *pName) { -#if defined ( _WIN32 ) - return GetProcAddress( (HINSTANCE)pModuleHandle, pName ); -#else - return GetProcAddress( pModuleHandle, pName ); -#endif + return GetProcAddress((HMODULE)pModuleHandle, pName); } -//----------------------------------------------------------------------------- // Purpose: Loads a DLL/component from disk and returns a handle to it // Input : *pModuleName - filename of the component // Output : opaque handle to the module (hides system dependency) -//----------------------------------------------------------------------------- -CSysModule *Sys_LoadModule( const char *pModuleName ) +CSysModule *Sys_LoadModule(const char *pModuleName) { -#if defined ( _WIN32 ) - HMODULE hDLL = LoadLibrary( pModuleName ); +#ifdef _WIN32 + HMODULE hDLL = LoadLibrary(pModuleName); #else - HMODULE hDLL = NULL; + HMODULE hDLL = nullptr; char szAbsoluteModuleName[1024]; - szAbsoluteModuleName[0] = 0; - if ( pModuleName[0] != '/' ) + if (pModuleName[0] != '/') { char szCwd[1024]; - char szAbsoluteModuleName[1024]; + getcwd(szCwd, sizeof(szCwd)); + if (szCwd[strlen(szCwd) - 1] == '/') + szCwd[strlen(szCwd) - 1] = '\0'; - getcwd( szCwd, sizeof( szCwd ) ); - if ( szCwd[ strlen( szCwd ) - 1 ] == '/' ) - szCwd[ strlen( szCwd ) - 1 ] = 0; - - _snprintf( szAbsoluteModuleName, sizeof(szAbsoluteModuleName), "%s/%s", szCwd, pModuleName ); - - hDLL = dlopen( szAbsoluteModuleName, RTLD_NOW ); + _snprintf(szAbsoluteModuleName, sizeof(szAbsoluteModuleName), "%s/%s", szCwd, pModuleName); + hDLL = dlopen(szAbsoluteModuleName, RTLD_NOW); } else { - _snprintf( szAbsoluteModuleName, sizeof(szAbsoluteModuleName), "%s", pModuleName ); - hDLL = dlopen( pModuleName, RTLD_NOW ); + _snprintf(szAbsoluteModuleName, sizeof(szAbsoluteModuleName), "%s", pModuleName); + hDLL = dlopen(pModuleName, RTLD_NOW); } -#endif +#endif // _WIN32 - if( !hDLL ) + if (!hDLL) { char str[512]; -#if defined ( _WIN32 ) - _snprintf( str, sizeof(str), "%s.dll", pModuleName ); - hDLL = LoadLibrary( str ); + +#if defined(_WIN32) + _snprintf(str, sizeof(str), "%s.dll", pModuleName); + hDLL = LoadLibrary(str); #elif defined(OSX) - printf("Error:%s\n",dlerror()); - _snprintf( str, sizeof(str), "%s.dylib", szAbsoluteModuleName ); - hDLL = dlopen(str, RTLD_NOW); + printf("Error: %s\n", dlerror()); + _snprintf(str, sizeof(str), "%s.dylib", szAbsoluteModuleName); + hDLL = dlopen(str, RTLD_NOW); #else - printf("Error:%s\n",dlerror()); - _snprintf( str, sizeof(str), "%s.so", szAbsoluteModuleName ); + printf("Error: %s\n", dlerror()); + _snprintf(str, sizeof(str), "%s.so", szAbsoluteModuleName); hDLL = dlopen(str, RTLD_NOW); #endif } @@ -181,83 +169,68 @@ CSysModule *Sys_LoadModule( const char *pModuleName ) return reinterpret_cast(hDLL); } -//----------------------------------------------------------------------------- // Purpose: Unloads a DLL/component from // Input : *pModuleName - filename of the component // Output : opaque handle to the module (hides system dependency) -//----------------------------------------------------------------------------- -void Sys_UnloadModule( CSysModule *pModule ) +void Sys_UnloadModule(CSysModule *pModule) { - if ( !pModule ) + if (!pModule) return; HMODULE hDLL = reinterpret_cast(pModule); -#if defined ( _WIN32 ) - FreeLibrary( hDLL ); -#else - dlclose((void *)hDLL); -#endif +#ifdef _WIN32 + FreeLibrary(hDLL); +#else + dlclose(hDLL); +#endif // _WIN32 } -//----------------------------------------------------------------------------- // Purpose: returns a pointer to a function, given a module -// Input : module - windows HMODULE from Sys_LoadModule() +// Input : module - windows HMODULE from Sys_LoadModule() // *pName - proc name // Output : factory for this module -//----------------------------------------------------------------------------- -CreateInterfaceFn Sys_GetFactory( CSysModule *pModule ) +CreateInterfaceFn Sys_GetFactory(CSysModule *pModule) { - if ( !pModule ) - return NULL; + if (!pModule) + return nullptr; - HMODULE hDLL = reinterpret_cast(pModule); -#if defined ( _WIN32 ) - return reinterpret_cast(GetProcAddress( hDLL, CREATEINTERFACE_PROCNAME )); -#else -// Linux gives this error: -//../public/interface.cpp: In function `IBaseInterface *(*Sys_GetFactory -//(CSysModule *)) (const char *, int *)': -//../public/interface.cpp:154: ISO C++ forbids casting between -//pointer-to-function and pointer-to-object -// -// so lets get around it :) - return (CreateInterfaceFn)(GetProcAddress( hDLL, CREATEINTERFACE_PROCNAME )); -#endif + return reinterpret_cast(Sys_GetProcAddress(pModule, CREATEINTERFACE_PROCNAME)); } - - -//----------------------------------------------------------------------------- // Purpose: returns the instance of this module -// Output : interface_instance_t -//----------------------------------------------------------------------------- -CreateInterfaceFn Sys_GetFactoryThis( void ) +// Output : CreateInterfaceFn +CreateInterfaceFn Sys_GetFactoryThis() { -#ifdef LINUX - return CreateInterfaceLocal; -#else return CreateInterface; -#endif } -//----------------------------------------------------------------------------- // Purpose: returns the instance of the named module // Input : *pModuleName - name of the module -// Output : interface_instance_t - instance of that module -//----------------------------------------------------------------------------- -CreateInterfaceFn Sys_GetFactory( const char *pModuleName ) +// Output : CreateInterfaceFn - instance of that module +CreateInterfaceFn Sys_GetFactory(const char *pModuleName) { -#if defined ( _WIN32 ) - return static_cast( Sys_GetProcAddress( pModuleName, CREATEINTERFACE_PROCNAME ) ); -#else -// Linux gives this error: -//../public/interface.cpp: In function `IBaseInterface *(*Sys_GetFactory -//(const char *)) (const char *, int *)': -//../public/interface.cpp:186: invalid static_cast from type `void *' to -//type `IBaseInterface *(*) (const char *, int *)' -// -// so lets use the old style cast. - return (CreateInterfaceFn)( Sys_GetProcAddress( pModuleName, CREATEINTERFACE_PROCNAME ) ); -#endif + return reinterpret_cast(Sys_GetProcAddress(pModuleName, CREATEINTERFACE_PROCNAME)); +} + +// Purpose: finds a particular interface in the factory set +void *InitializeInterface(char const *interfaceName, CreateInterfaceFn *factoryList, int numFactories) +{ + void *retval; + + for (int i = 0; i < numFactories; i++) + { + CreateInterfaceFn factory = factoryList[ i ]; + if (!factory) + continue; + + retval = factory(interfaceName, nullptr); + if (retval) + return retval; + } + + // No provider for requested interface!!! + // assert(!"No provider for requested interface!!!"); + + return nullptr; } diff --git a/regamedll/public/interface.h b/regamedll/public/interface.h index 980a5afd..bba69f70 100644 --- a/regamedll/public/interface.h +++ b/regamedll/public/interface.h @@ -1,4 +1,3 @@ - // This header defines the interface convention used in the valve engine. // To make an interface and expose it: // 1. Derive from IBaseInterface. @@ -8,22 +7,17 @@ // Versioning // There are two versioning cases that are handled by this: -// 1. You add functions to the end of an interface, so it is binary compatible with the previous interface. In this case, +// 1. You add functions to the end of an interface, so it is binary compatible with the previous interface. In this case, // you need two EXPOSE_INTERFACEs: one to expose your class as the old interface and one to expose it as the new interface. -// 2. You update an interface so it's not compatible anymore (but you still want to be able to expose the old interface -// for legacy code). In this case, you need to make a new version name for your new interface, and make a wrapper interface and +// 2. You update an interface so it's not compatible anymore (but you still want to be able to expose the old interface +// for legacy code). In this case, you need to make a new version name for your new interface, and make a wrapper interface and // expose it for the old interface. -//#if _MSC_VER >= 1300 // VC7 -//#include "tier1/interface.h" -//#else +#pragma once -#ifndef INTERFACE_H -#define INTERFACE_H +#ifndef _WIN32 -#if !defined ( _WIN32 ) - -#include // dlopen,dlclose, et al +#include // dlopen, dlclose, et al #include #define HMODULE void * @@ -31,7 +25,7 @@ #define _snprintf snprintf -#endif +#endif // _WIN32 void *Sys_GetProcAddress(const char *pModuleName, const char *pName); void *Sys_GetProcAddress(void *pModuleHandle, const char *pName); @@ -40,17 +34,13 @@ void *Sys_GetProcAddress(void *pModuleHandle, const char *pName); class IBaseInterface { public: - - virtual ~IBaseInterface() {} + virtual ~IBaseInterface() {} }; +#define CREATEINTERFACE_PROCNAME "CreateInterface" -#define CREATEINTERFACE_PROCNAME "CreateInterface" -typedef IBaseInterface* (*CreateInterfaceFn)(const char *pName, int *pReturnCode); - - -typedef IBaseInterface* (*InstantiateInterfaceFn)(); - +typedef IBaseInterface *(*CreateInterfaceFn)(const char *pName, int *pReturnCode); +typedef IBaseInterface *(*InstantiateInterfaceFn)(); // Used internally to register classes. class InterfaceReg @@ -60,19 +50,18 @@ public: public: - InstantiateInterfaceFn m_CreateFn; - const char *m_pName; + InstantiateInterfaceFn m_CreateFn; + const char *m_pName; - InterfaceReg *m_pNext; // For the global list. - static InterfaceReg *s_pInterfaceRegs; + InterfaceReg *m_pNext; // For the global list. + static InterfaceReg *s_pInterfaceRegs; }; - // Use this to expose an interface that can have multiple instances. // e.g.: -// EXPOSE_INTERFACE( CInterfaceImp, IInterface, "MyInterface001" ) +// EXPOSE_INTERFACE(CInterfaceImp, IInterface, "MyInterface001") // This will expose a class called CInterfaceImp that implements IInterface (a pure class) -// clients can receive a pointer to this class by calling CreateInterface( "MyInterface001" ) +// clients can receive a pointer to this class by calling CreateInterface("MyInterface001") // // In practice, the shared header file defines the interface (IInterface) and version name ("MyInterface001") // so that each component can use these names/vtables to communicate @@ -80,71 +69,55 @@ public: // A single class can support multiple interfaces through multiple inheritance // // Use this if you want to write the factory function. -#define EXPOSE_INTERFACE_FN(functionName, interfaceName, versionName) \ +#define EXPOSE_INTERFACE_FN(functionName, interfaceName, versionName)\ static InterfaceReg __g_Create##className##_reg(functionName, versionName); -#define EXPOSE_INTERFACE(className, interfaceName, versionName) \ - static IBaseInterface* __Create##className##_interface() {return (interfaceName *)new className;}\ - static InterfaceReg __g_Create##className##_reg(__Create##className##_interface, versionName ); +#define EXPOSE_INTERFACE(className, interfaceName, versionName)\ + static IBaseInterface *__Create##className##_interface() {return (interfaceName *)new className;}\ + static InterfaceReg __g_Create##className##_reg(__Create##className##_interface, versionName); // Use this to expose a singleton interface with a global variable you've created. -#define EXPOSE_SINGLE_INTERFACE_GLOBALVAR(className, interfaceName, versionName, globalVarName) \ - static IBaseInterface* __Create##className##interfaceName##_interface() {return (IBaseInterface *)&globalVarName;}\ +#define EXPOSE_SINGLE_INTERFACE_GLOBALVAR(className, interfaceName, versionName, globalVarName)\ + static IBaseInterface *__Create##className##interfaceName##_interface() {return (IBaseInterface *)&globalVarName;}\ static InterfaceReg __g_Create##className##interfaceName##_reg(__Create##className##interfaceName##_interface, versionName); // Use this to expose a singleton interface. This creates the global variable for you automatically. -#define EXPOSE_SINGLE_INTERFACE(className, interfaceName, versionName) \ +#define EXPOSE_SINGLE_INTERFACE(className, interfaceName, versionName)\ static className __g_##className##_singleton;\ EXPOSE_SINGLE_INTERFACE_GLOBALVAR(className, interfaceName, versionName, __g_##className##_singleton) - #ifdef _WIN32 - #define EXPORT_FUNCTION __declspec(dllexport) + #define EXPORT_FUNCTION __declspec(dllexport) EXT_FUNC #else - #define EXPORT_FUNCTION __attribute__ ((visibility("default"))) -#endif - + #define EXPORT_FUNCTION __attribute__((visibility("default"))) EXT_FUNC +#endif // _WIN32 // This function is automatically exported and allows you to access any interfaces exposed with the above macros. // if pReturnCode is set, it will return one of the following values // extend this for other error conditions/code -enum +enum { IFACE_OK = 0, IFACE_FAILED }; - extern "C" { - EXPORT_FUNCTION IBaseInterface* CreateInterface(const char *pName, int *pReturnCode); + EXPORT_FUNCTION IBaseInterface *CreateInterface(const char *pName, int *pReturnCode); }; +extern CreateInterfaceFn Sys_GetFactoryThis(); -extern CreateInterfaceFn Sys_GetFactoryThis( void ); - - -//----------------------------------------------------------------------------- // UNDONE: This is obsolete, use the module load/unload/get instead!!! -//----------------------------------------------------------------------------- -extern CreateInterfaceFn Sys_GetFactory( const char *pModuleName ); - +extern CreateInterfaceFn Sys_GetFactory(const char *pModuleName); // load/unload components class CSysModule; -//----------------------------------------------------------------------------- // Load & Unload should be called in exactly one place for each module // The factory for that module should be passed on to dependent components for // proper versioning. -//----------------------------------------------------------------------------- -extern CSysModule *Sys_LoadModule( const char *pModuleName ); -extern void Sys_UnloadModule( CSysModule *pModule ); - -extern CreateInterfaceFn Sys_GetFactory( CSysModule *pModule ); - - -#endif -//#endif // MSVC 6.0 - - +extern CSysModule *Sys_LoadModule(const char *pModuleName); +extern void Sys_UnloadModule(CSysModule *pModule); +extern CreateInterfaceFn Sys_GetFactory(CSysModule *pModule); +extern void *InitializeInterface(char const *interfaceName, CreateInterfaceFn *factoryList, int numFactories); diff --git a/regamedll/public/protected_things.h b/regamedll/public/protected_things.h deleted file mode 100644 index ab10bbb5..00000000 --- a/regamedll/public/protected_things.h +++ /dev/null @@ -1,187 +0,0 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ -// -// Purpose: -// -// $NoKeywords: $ -//============================================================================= - -#ifndef PROTECTED_THINGS_H -#define PROTECTED_THINGS_H -#ifdef _WIN32 -#pragma once -#endif - - -// This header tries to prevent people from using potentially dangerous functions -// (like the notorious non-null-terminating strncpy) and functions that will break -// VCR mode (like time, input, registry, etc). -// -// This header should be included by ALL of our source code. - -// Eventually, ALL of these should be protected, but one man can only accomplish so much in -// one day AND work on features too! -#if defined( PROTECT_STRING_FUNCTIONS ) -#if defined( strncpy ) -#undef strncpy -#endif -#define strncpy strncpy__HEY_YOU__USE_VSTDLIB - - -#if defined( _snprintf ) -#undef _snprintf -#endif -#define _snprintf snprintf__HEY_YOU__USE_VSTDLIB - - -#if defined( sprintf ) -#undef sprintf -#endif -#define sprintf sprintf__HEY_YOU__USE_VSTDLIB - - -#if defined( _vsnprintf ) -#undef _vsnprintf -#endif -#define _vsnprintf vsnprintf__HEY_YOU__USE_VSTDLIB - - -#if defined( strcat ) -#undef strcat -#endif -#define strcat strcat__HEY_YOU__USE_VSTDLIB -#endif - - -#if defined( PROTECT_FILEIO_FUNCTIONS ) -#if defined( fopen ) -#undef fopen -#endif -#define fopen fopen_USE_FILESYSTEM_INSTEAD -#endif - - -#if defined( PROTECTED_THINGS_ENABLE ) - -#if defined( GetTickCount ) -#undef GetTickCount -#endif -#define GetTickCount GetTickCount__HEY_YOU__USE_PLATFORM_LIB - - -#if defined( timeGetTime ) -#undef timeGetTime -#endif -#define timeGetTime timeGetTime__HEY_YOU__USE_PLATFORM_LIB - - -#if defined( clock ) -#undef clock -#endif -#define time time__HEY_YOU__USE_PLATFORM_LIB - - -#if defined( recvfrom ) -#undef recvfrom -#endif -#define recvfrom recvfrom__HEY_YOU__USE_PLATFORM_LIB - - -#if defined( GetCursorPos ) -#undef GetCursorPos -#endif -#define GetCursorPos GetCursorPos__HEY_YOU__USE_PLATFORM_LIB - - -#if defined( ScreenToClient ) -#undef ScreenToClient -#endif -#define ScreenToClient ScreenToClient__HEY_YOU__USE_PLATFORM_LIB - - -#if defined( GetCommandLine ) -#undef GetCommandLine -#endif -#define GetCommandLine GetCommandLine__HEY_YOU__USE_PLATFORM_LIB - - -#if defined( RegOpenKeyEx ) -#undef RegOpenKeyEx -#endif -#define RegOpenKeyEx RegOpenKeyEx__HEY_YOU__USE_PLATFORM_LIB - - -#if defined( RegOpenKey ) -#undef RegOpenKey -#endif -#define RegOpenKey RegOpenKey__HEY_YOU__USE_PLATFORM_LIB - - -#if defined( RegSetValueEx ) -#undef RegSetValueEx -#endif -#define RegSetValueEx RegSetValueEx__HEY_YOU__USE_PLATFORM_LIB - - -#if defined( RegSetValue ) -#undef RegSetValue -#endif -#define RegSetValue RegSetValue__HEY_YOU__USE_PLATFORM_LIB - - -#if defined( RegQueryValueEx ) -#undef RegQueryValueEx -#endif -#define RegQueryValueEx RegQueryValueEx__HEY_YOU__USE_PLATFORM_LIB - - -#if defined( RegQueryValue ) -#undef RegQueryValue -#endif -#define RegQueryValue RegQueryValue__HEY_YOU__USE_PLATFORM_LIB - - -#if defined( RegCreateKeyEx ) -#undef RegCreateKeyEx -#endif -#define RegCreateKeyEx RegCreateKeyEx__HEY_YOU__USE_PLATFORM_LIB - - -#if defined( RegCreateKey ) -#undef RegCreateKey -#endif -#define RegCreateKey RegCreateKey__HEY_YOU__USE_PLATFORM_LIB - - -#if defined( RegCloseKey ) -#undef RegCloseKey -#endif -#define RegCloseKey RegCloseKey__HEY_YOU__USE_PLATFORM_LIB - - -#if defined( GetNumberOfConsoleInputEvents ) -#undef GetNumberOfConsoleInputEvents -#endif -#define GetNumberOfConsoleInputEvents GetNumberOfConsoleInputEvents__HEY_YOU__USE_PLATFORM_LIB - - -#if defined( ReadConsoleInput ) -#undef ReadConsoleInput -#endif -#define ReadConsoleInput ReadConsoleInput__HEY_YOU__USE_PLATFORM_LIB - - -#if defined( GetAsyncKeyState ) -#undef GetAsyncKeyState -#endif -#define GetAsyncKeyState GetAsyncKeyState__HEY_YOU__USE_PLATFORM_LIB - - -#if defined( GetKeyState ) -#undef GetKeyState -#endif -#define GetKeyState GetKeyState__HEY_YOU__USE_PLATFORM_LIB - -#endif - - -#endif // PROTECTED_THINGS_H diff --git a/regamedll/public/regamedll/csbot_dll.h b/regamedll/public/regamedll/csbot_dll.h index 4620d053..4e01f703 100644 --- a/regamedll/public/regamedll/csbot_dll.h +++ b/regamedll/public/regamedll/csbot_dll.h @@ -25,6 +25,7 @@ * version. * */ + #pragma once #include "../game_shared/GameEvent.h" diff --git a/regamedll/public/regamedll/hookchains.h b/regamedll/public/regamedll/hookchains.h index 2554a4af..869d5b1b 100644 --- a/regamedll/public/regamedll/hookchains.h +++ b/regamedll/public/regamedll/hookchains.h @@ -25,6 +25,7 @@ * version. * */ + #pragma once template diff --git a/regamedll/public/regamedll/regamedll_api.h b/regamedll/public/regamedll/regamedll_api.h index 6424b6ca..700b94c8 100644 --- a/regamedll/public/regamedll/regamedll_api.h +++ b/regamedll/public/regamedll/regamedll_api.h @@ -25,7 +25,9 @@ * version. * */ + #pragma once + #include "archtypes.h" #include "regamedll_interfaces.h" #include "hookchains.h" @@ -33,7 +35,6 @@ #include "player.h" #include "gamerules.h" #include "client.h" -#include "items.h" #define REGAMEDLL_API_VERSION_MAJOR 5 #define REGAMEDLL_API_VERSION_MINOR 3 @@ -163,12 +164,12 @@ typedef IHookChainClass IReGameHo typedef IHookChainRegistryClass IReGameHookRegistry_CBasePlayer_HasRestrictItem; // CBasePlayer::DropPlayerItem hook -typedef IHookChainClass IReGameHook_CBasePlayer_DropPlayerItem; -typedef IHookChainRegistryClass IReGameHookRegistry_CBasePlayer_DropPlayerItem; +typedef IHookChainClass IReGameHook_CBasePlayer_DropPlayerItem; +typedef IHookChainRegistryClass IReGameHookRegistry_CBasePlayer_DropPlayerItem; // CBasePlayer::DropShield hook -typedef IHookChainClass IReGameHook_CBasePlayer_DropShield; -typedef IHookChainRegistryClass IReGameHookRegistry_CBasePlayer_DropShield; +typedef IHookChainClass IReGameHook_CBasePlayer_DropShield; +typedef IHookChainRegistryClass IReGameHookRegistry_CBasePlayer_DropShield; // CBasePlayer::OnSpawnEquip hook typedef IHookChainClass IReGameHook_CBasePlayer_OnSpawnEquip; @@ -367,91 +368,91 @@ public: virtual ~IReGameHookchains() {} // CBasePlayer virtual - virtual IReGameHookRegistry_CBasePlayer_Spawn* CBasePlayer_Spawn() = 0; - virtual IReGameHookRegistry_CBasePlayer_Precache* CBasePlayer_Precache() = 0; - virtual IReGameHookRegistry_CBasePlayer_ObjectCaps* CBasePlayer_ObjectCaps() = 0; - virtual IReGameHookRegistry_CBasePlayer_Classify* CBasePlayer_Classify() = 0; - virtual IReGameHookRegistry_CBasePlayer_TraceAttack* CBasePlayer_TraceAttack() = 0; - virtual IReGameHookRegistry_CBasePlayer_TakeDamage* CBasePlayer_TakeDamage() = 0; - virtual IReGameHookRegistry_CBasePlayer_TakeHealth* CBasePlayer_TakeHealth() = 0; - virtual IReGameHookRegistry_CBasePlayer_Killed* CBasePlayer_Killed() = 0; - virtual IReGameHookRegistry_CBasePlayer_AddPoints* CBasePlayer_AddPoints() = 0; - virtual IReGameHookRegistry_CBasePlayer_AddPointsToTeam* CBasePlayer_AddPointsToTeam() = 0; - virtual IReGameHookRegistry_CBasePlayer_AddPlayerItem* CBasePlayer_AddPlayerItem() = 0; - virtual IReGameHookRegistry_CBasePlayer_RemovePlayerItem* CBasePlayer_RemovePlayerItem() = 0; - virtual IReGameHookRegistry_CBasePlayer_GiveAmmo* CBasePlayer_GiveAmmo() = 0; - virtual IReGameHookRegistry_CBasePlayer_ResetMaxSpeed* CBasePlayer_ResetMaxSpeed() = 0; - virtual IReGameHookRegistry_CBasePlayer_Jump* CBasePlayer_Jump() = 0; - virtual IReGameHookRegistry_CBasePlayer_Duck* CBasePlayer_Duck() = 0; - virtual IReGameHookRegistry_CBasePlayer_PreThink* CBasePlayer_PreThink() = 0; - virtual IReGameHookRegistry_CBasePlayer_PostThink* CBasePlayer_PostThink() = 0; - virtual IReGameHookRegistry_CBasePlayer_UpdateClientData* CBasePlayer_UpdateClientData() = 0; - virtual IReGameHookRegistry_CBasePlayer_ImpulseCommands* CBasePlayer_ImpulseCommands() = 0; - virtual IReGameHookRegistry_CBasePlayer_RoundRespawn* CBasePlayer_RoundRespawn() = 0; - virtual IReGameHookRegistry_CBasePlayer_Blind* CBasePlayer_Blind() = 0; + virtual IReGameHookRegistry_CBasePlayer_Spawn *CBasePlayer_Spawn() = 0; + virtual IReGameHookRegistry_CBasePlayer_Precache *CBasePlayer_Precache() = 0; + virtual IReGameHookRegistry_CBasePlayer_ObjectCaps *CBasePlayer_ObjectCaps() = 0; + virtual IReGameHookRegistry_CBasePlayer_Classify *CBasePlayer_Classify() = 0; + virtual IReGameHookRegistry_CBasePlayer_TraceAttack *CBasePlayer_TraceAttack() = 0; + virtual IReGameHookRegistry_CBasePlayer_TakeDamage *CBasePlayer_TakeDamage() = 0; + virtual IReGameHookRegistry_CBasePlayer_TakeHealth *CBasePlayer_TakeHealth() = 0; + virtual IReGameHookRegistry_CBasePlayer_Killed *CBasePlayer_Killed() = 0; + virtual IReGameHookRegistry_CBasePlayer_AddPoints *CBasePlayer_AddPoints() = 0; + virtual IReGameHookRegistry_CBasePlayer_AddPointsToTeam *CBasePlayer_AddPointsToTeam() = 0; + virtual IReGameHookRegistry_CBasePlayer_AddPlayerItem *CBasePlayer_AddPlayerItem() = 0; + virtual IReGameHookRegistry_CBasePlayer_RemovePlayerItem *CBasePlayer_RemovePlayerItem() = 0; + virtual IReGameHookRegistry_CBasePlayer_GiveAmmo *CBasePlayer_GiveAmmo() = 0; + virtual IReGameHookRegistry_CBasePlayer_ResetMaxSpeed *CBasePlayer_ResetMaxSpeed() = 0; + virtual IReGameHookRegistry_CBasePlayer_Jump *CBasePlayer_Jump() = 0; + virtual IReGameHookRegistry_CBasePlayer_Duck *CBasePlayer_Duck() = 0; + virtual IReGameHookRegistry_CBasePlayer_PreThink *CBasePlayer_PreThink() = 0; + virtual IReGameHookRegistry_CBasePlayer_PostThink *CBasePlayer_PostThink() = 0; + virtual IReGameHookRegistry_CBasePlayer_UpdateClientData *CBasePlayer_UpdateClientData() = 0; + virtual IReGameHookRegistry_CBasePlayer_ImpulseCommands *CBasePlayer_ImpulseCommands() = 0; + virtual IReGameHookRegistry_CBasePlayer_RoundRespawn *CBasePlayer_RoundRespawn() = 0; + virtual IReGameHookRegistry_CBasePlayer_Blind *CBasePlayer_Blind() = 0; - virtual IReGameHookRegistry_CBasePlayer_Observer_IsValidTarget* CBasePlayer_Observer_IsValidTarget() = 0; - virtual IReGameHookRegistry_CBasePlayer_SetAnimation* CBasePlayer_SetAnimation() = 0; - virtual IReGameHookRegistry_CBasePlayer_GiveDefaultItems* CBasePlayer_GiveDefaultItems() = 0; - virtual IReGameHookRegistry_CBasePlayer_GiveNamedItem* CBasePlayer_GiveNamedItem() = 0; - virtual IReGameHookRegistry_CBasePlayer_AddAccount* CBasePlayer_AddAccount() = 0; - virtual IReGameHookRegistry_CBasePlayer_GiveShield* CBasePlayer_GiveShield() = 0; - virtual IReGameHookRegistry_CBasePlayer_SetClientUserInfoModel* CBasePlayer_SetClientUserInfoModel() = 0; - virtual IReGameHookRegistry_CBasePlayer_SetClientUserInfoName* CBasePlayer_SetClientUserInfoName() = 0; - virtual IReGameHookRegistry_CBasePlayer_HasRestrictItem* CBasePlayer_HasRestrictItem() = 0; - virtual IReGameHookRegistry_CBasePlayer_DropPlayerItem* CBasePlayer_DropPlayerItem() = 0; - virtual IReGameHookRegistry_CBasePlayer_DropShield* CBasePlayer_DropShield() = 0; - virtual IReGameHookRegistry_CBasePlayer_OnSpawnEquip* CBasePlayer_OnSpawnEquip() = 0; - virtual IReGameHookRegistry_CBasePlayer_Radio* CBasePlayer_Radio() = 0; - virtual IReGameHookRegistry_CBasePlayer_Disappear* CBasePlayer_Disappear() = 0; - virtual IReGameHookRegistry_CBasePlayer_MakeVIP* CBasePlayer_MakeVIP() = 0; - virtual IReGameHookRegistry_CBasePlayer_MakeBomber* CBasePlayer_MakeBomber() = 0; - virtual IReGameHookRegistry_CBasePlayer_StartObserver* CBasePlayer_StartObserver() = 0; - virtual IReGameHookRegistry_CBasePlayer_GetIntoGame* CBasePlayer_GetIntoGame() = 0; + virtual IReGameHookRegistry_CBasePlayer_Observer_IsValidTarget *CBasePlayer_Observer_IsValidTarget() = 0; + virtual IReGameHookRegistry_CBasePlayer_SetAnimation *CBasePlayer_SetAnimation() = 0; + virtual IReGameHookRegistry_CBasePlayer_GiveDefaultItems *CBasePlayer_GiveDefaultItems() = 0; + virtual IReGameHookRegistry_CBasePlayer_GiveNamedItem *CBasePlayer_GiveNamedItem() = 0; + virtual IReGameHookRegistry_CBasePlayer_AddAccount *CBasePlayer_AddAccount() = 0; + virtual IReGameHookRegistry_CBasePlayer_GiveShield *CBasePlayer_GiveShield() = 0; + virtual IReGameHookRegistry_CBasePlayer_SetClientUserInfoModel *CBasePlayer_SetClientUserInfoModel() = 0; + virtual IReGameHookRegistry_CBasePlayer_SetClientUserInfoName *CBasePlayer_SetClientUserInfoName() = 0; + virtual IReGameHookRegistry_CBasePlayer_HasRestrictItem *CBasePlayer_HasRestrictItem() = 0; + virtual IReGameHookRegistry_CBasePlayer_DropPlayerItem *CBasePlayer_DropPlayerItem() = 0; + virtual IReGameHookRegistry_CBasePlayer_DropShield *CBasePlayer_DropShield() = 0; + virtual IReGameHookRegistry_CBasePlayer_OnSpawnEquip *CBasePlayer_OnSpawnEquip() = 0; + virtual IReGameHookRegistry_CBasePlayer_Radio *CBasePlayer_Radio() = 0; + virtual IReGameHookRegistry_CBasePlayer_Disappear *CBasePlayer_Disappear() = 0; + virtual IReGameHookRegistry_CBasePlayer_MakeVIP *CBasePlayer_MakeVIP() = 0; + virtual IReGameHookRegistry_CBasePlayer_MakeBomber *CBasePlayer_MakeBomber() = 0; + virtual IReGameHookRegistry_CBasePlayer_StartObserver *CBasePlayer_StartObserver() = 0; + virtual IReGameHookRegistry_CBasePlayer_GetIntoGame *CBasePlayer_GetIntoGame() = 0; - virtual IReGameHookRegistry_CBaseAnimating_ResetSequenceInfo* CBaseAnimating_ResetSequenceInfo() = 0; + virtual IReGameHookRegistry_CBaseAnimating_ResetSequenceInfo *CBaseAnimating_ResetSequenceInfo() = 0; - virtual IReGameHookRegistry_GetForceCamera* GetForceCamera() = 0; - virtual IReGameHookRegistry_PlayerBlind* PlayerBlind() = 0; - virtual IReGameHookRegistry_RadiusFlash_TraceLine* RadiusFlash_TraceLine() = 0; - virtual IReGameHookRegistry_RoundEnd* RoundEnd() = 0; - virtual IReGameHookRegistry_InstallGameRules* InstallGameRules() = 0; - virtual IReGameHookRegistry_PM_Init* PM_Init() = 0; - virtual IReGameHookRegistry_PM_Move* PM_Move() = 0; - virtual IReGameHookRegistry_PM_AirMove* PM_AirMove() = 0; - virtual IReGameHookRegistry_HandleMenu_ChooseAppearance* HandleMenu_ChooseAppearance() = 0; - virtual IReGameHookRegistry_HandleMenu_ChooseTeam* HandleMenu_ChooseTeam() = 0; - virtual IReGameHookRegistry_ShowMenu* ShowMenu() = 0; - virtual IReGameHookRegistry_ShowVGUIMenu* ShowVGUIMenu() = 0; - virtual IReGameHookRegistry_BuyGunAmmo* BuyGunAmmo() = 0; - virtual IReGameHookRegistry_BuyWeaponByWeaponID* BuyWeaponByWeaponID() = 0; - virtual IReGameHookRegistry_InternalCommand* InternalCommand() = 0; + virtual IReGameHookRegistry_GetForceCamera *GetForceCamera() = 0; + virtual IReGameHookRegistry_PlayerBlind *PlayerBlind() = 0; + virtual IReGameHookRegistry_RadiusFlash_TraceLine *RadiusFlash_TraceLine() = 0; + virtual IReGameHookRegistry_RoundEnd *RoundEnd() = 0; + virtual IReGameHookRegistry_InstallGameRules *InstallGameRules() = 0; + virtual IReGameHookRegistry_PM_Init *PM_Init() = 0; + virtual IReGameHookRegistry_PM_Move *PM_Move() = 0; + virtual IReGameHookRegistry_PM_AirMove *PM_AirMove() = 0; + virtual IReGameHookRegistry_HandleMenu_ChooseAppearance *HandleMenu_ChooseAppearance() = 0; + virtual IReGameHookRegistry_HandleMenu_ChooseTeam *HandleMenu_ChooseTeam() = 0; + virtual IReGameHookRegistry_ShowMenu *ShowMenu() = 0; + virtual IReGameHookRegistry_ShowVGUIMenu *ShowVGUIMenu() = 0; + virtual IReGameHookRegistry_BuyGunAmmo *BuyGunAmmo() = 0; + virtual IReGameHookRegistry_BuyWeaponByWeaponID *BuyWeaponByWeaponID() = 0; + virtual IReGameHookRegistry_InternalCommand *InternalCommand() = 0; - virtual IReGameHookRegistry_CSGameRules_FShouldSwitchWeapon* CSGameRules_FShouldSwitchWeapon() = 0; - virtual IReGameHookRegistry_CSGameRules_GetNextBestWeapon* CSGameRules_GetNextBestWeapon() = 0; - virtual IReGameHookRegistry_CSGameRules_FlPlayerFallDamage* CSGameRules_FlPlayerFallDamage() = 0; - virtual IReGameHookRegistry_CSGameRules_FPlayerCanTakeDamage* CSGameRules_FPlayerCanTakeDamage() = 0; - virtual IReGameHookRegistry_CSGameRules_PlayerSpawn* CSGameRules_PlayerSpawn() = 0; - virtual IReGameHookRegistry_CSGameRules_FPlayerCanRespawn* CSGameRules_FPlayerCanRespawn() = 0; - virtual IReGameHookRegistry_CSGameRules_GetPlayerSpawnSpot* CSGameRules_GetPlayerSpawnSpot() = 0; - virtual IReGameHookRegistry_CSGameRules_ClientUserInfoChanged* CSGameRules_ClientUserInfoChanged() = 0; - virtual IReGameHookRegistry_CSGameRules_PlayerKilled* CSGameRules_PlayerKilled() = 0; - virtual IReGameHookRegistry_CSGameRules_DeathNotice* CSGameRules_DeathNotice() = 0; - virtual IReGameHookRegistry_CSGameRules_CanHavePlayerItem* CSGameRules_CanHavePlayerItem() = 0; - virtual IReGameHookRegistry_CSGameRules_DeadPlayerWeapons* CSGameRules_DeadPlayerWeapons() = 0; - virtual IReGameHookRegistry_CSGameRules_ServerDeactivate* CSGameRules_ServerDeactivate() = 0; - virtual IReGameHookRegistry_CSGameRules_CheckMapConditions* CSGameRules_CheckMapConditions() = 0; - virtual IReGameHookRegistry_CSGameRules_CleanUpMap* CSGameRules_CleanUpMap() = 0; - virtual IReGameHookRegistry_CSGameRules_RestartRound* CSGameRules_RestartRound() = 0; - virtual IReGameHookRegistry_CSGameRules_CheckWinConditions* CSGameRules_CheckWinConditions() = 0; - virtual IReGameHookRegistry_CSGameRules_RemoveGuns* CSGameRules_RemoveGuns() = 0; - virtual IReGameHookRegistry_CSGameRules_GiveC4* CSGameRules_GiveC4() = 0; - virtual IReGameHookRegistry_CSGameRules_ChangeLevel* CSGameRules_ChangeLevel() = 0; - virtual IReGameHookRegistry_CSGameRules_GoToIntermission* CSGameRules_GoToIntermission() = 0; - virtual IReGameHookRegistry_CSGameRules_BalanceTeams* CSGameRules_BalanceTeams() = 0; - virtual IReGameHookRegistry_CSGameRules_OnRoundFreezeEnd* CSGameRules_OnRoundFreezeEnd() = 0; - virtual IReGameHookRegistry_PM_UpdateStepSound* PM_UpdateStepSound() = 0; - virtual IReGameHookRegistry_CBasePlayer_StartDeathCam* CBasePlayer_StartDeathCam() = 0; + virtual IReGameHookRegistry_CSGameRules_FShouldSwitchWeapon *CSGameRules_FShouldSwitchWeapon() = 0; + virtual IReGameHookRegistry_CSGameRules_GetNextBestWeapon *CSGameRules_GetNextBestWeapon() = 0; + virtual IReGameHookRegistry_CSGameRules_FlPlayerFallDamage *CSGameRules_FlPlayerFallDamage() = 0; + virtual IReGameHookRegistry_CSGameRules_FPlayerCanTakeDamage *CSGameRules_FPlayerCanTakeDamage() = 0; + virtual IReGameHookRegistry_CSGameRules_PlayerSpawn *CSGameRules_PlayerSpawn() = 0; + virtual IReGameHookRegistry_CSGameRules_FPlayerCanRespawn *CSGameRules_FPlayerCanRespawn() = 0; + virtual IReGameHookRegistry_CSGameRules_GetPlayerSpawnSpot *CSGameRules_GetPlayerSpawnSpot() = 0; + virtual IReGameHookRegistry_CSGameRules_ClientUserInfoChanged *CSGameRules_ClientUserInfoChanged() = 0; + virtual IReGameHookRegistry_CSGameRules_PlayerKilled *CSGameRules_PlayerKilled() = 0; + virtual IReGameHookRegistry_CSGameRules_DeathNotice *CSGameRules_DeathNotice() = 0; + virtual IReGameHookRegistry_CSGameRules_CanHavePlayerItem *CSGameRules_CanHavePlayerItem() = 0; + virtual IReGameHookRegistry_CSGameRules_DeadPlayerWeapons *CSGameRules_DeadPlayerWeapons() = 0; + virtual IReGameHookRegistry_CSGameRules_ServerDeactivate *CSGameRules_ServerDeactivate() = 0; + virtual IReGameHookRegistry_CSGameRules_CheckMapConditions *CSGameRules_CheckMapConditions() = 0; + virtual IReGameHookRegistry_CSGameRules_CleanUpMap *CSGameRules_CleanUpMap() = 0; + virtual IReGameHookRegistry_CSGameRules_RestartRound *CSGameRules_RestartRound() = 0; + virtual IReGameHookRegistry_CSGameRules_CheckWinConditions *CSGameRules_CheckWinConditions() = 0; + virtual IReGameHookRegistry_CSGameRules_RemoveGuns *CSGameRules_RemoveGuns() = 0; + virtual IReGameHookRegistry_CSGameRules_GiveC4 *CSGameRules_GiveC4() = 0; + virtual IReGameHookRegistry_CSGameRules_ChangeLevel *CSGameRules_ChangeLevel() = 0; + virtual IReGameHookRegistry_CSGameRules_GoToIntermission *CSGameRules_GoToIntermission() = 0; + virtual IReGameHookRegistry_CSGameRules_BalanceTeams *CSGameRules_BalanceTeams() = 0; + virtual IReGameHookRegistry_CSGameRules_OnRoundFreezeEnd *CSGameRules_OnRoundFreezeEnd() = 0; + virtual IReGameHookRegistry_PM_UpdateStepSound *PM_UpdateStepSound() = 0; + virtual IReGameHookRegistry_CBasePlayer_StartDeathCam *CBasePlayer_StartDeathCam() = 0; }; struct ReGameFuncs_t { @@ -474,17 +475,17 @@ public: virtual int GetMajorVersion() = 0; virtual int GetMinorVersion() = 0; - virtual const ReGameFuncs_t* GetFuncs() = 0; - virtual IReGameHookchains* GetHookchains() = 0; + virtual const ReGameFuncs_t *GetFuncs() = 0; + virtual IReGameHookchains *GetHookchains() = 0; - virtual class CGameRules* GetGameRules() = 0; - virtual struct WeaponInfoStruct* GetWeaponInfo(int weaponID) = 0; - virtual struct WeaponInfoStruct* GetWeaponInfo(const char* weaponName) = 0; - virtual struct playermove_s* GetPlayerMove() = 0; - virtual struct WeaponSlotInfo* GetWeaponSlot(WeaponIdType weaponID) = 0; - virtual struct WeaponSlotInfo* GetWeaponSlot(const char* weaponName) = 0; - virtual struct ItemInfo* GetItemInfo(WeaponIdType weaponID) = 0; - virtual struct AmmoInfo* GetAmmoInfo(AmmoType ammoID) = 0; + virtual class CGameRules *GetGameRules() = 0; + virtual struct WeaponInfoStruct *GetWeaponInfo(int weaponID) = 0; + virtual struct WeaponInfoStruct *GetWeaponInfo(const char *weaponName) = 0; + virtual struct playermove_s *GetPlayerMove() = 0; + virtual struct WeaponSlotInfo *GetWeaponSlot(WeaponIdType weaponID) = 0; + virtual struct WeaponSlotInfo *GetWeaponSlot(const char *weaponName) = 0; + virtual struct ItemInfo *GetItemInfo(WeaponIdType weaponID) = 0; + virtual struct AmmoInfo *GetAmmoInfo(AmmoType ammoID) = 0; }; #define VRE_GAMEDLL_API_VERSION "VRE_GAMEDLL_API_VERSION001" diff --git a/regamedll/public/regamedll/regamedll_common.h b/regamedll/public/regamedll/regamedll_common.h deleted file mode 100644 index 04ad3383..00000000 --- a/regamedll/public/regamedll/regamedll_common.h +++ /dev/null @@ -1,142 +0,0 @@ -/* -* -* This program is free software; you can redistribute it and/or modify it -* under the terms of the GNU General Public License as published by the -* Free Software Foundation; either version 2 of the License, or (at -* your option) any later version. -* -* This program 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 -* General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* -*/ - -#pragma once - -#ifndef _WIN32 -#define _strlwr(p) for (int i = 0; p[i] != 0; i++) p[i] = tolower(p[i]); -#endif - -#define Q_isspace isspace -#define Q_isalnum isalnum -#define Q_isalpha isalpha - -#define Q_malloc malloc -#define Q_calloc calloc -#define Q_alloca alloca -#define Q_free free - -#ifdef REGAMEDLL_FIXES -#define Q_sqrt M_sqrt -#define Q_min M_min -#define Q_max M_max -#define Q_clamp M_clamp -#define Q_access _access -#define Q_close _close -#define Q_write _write -#define Q_memset A_memset -#define Q_memcpy A_memcpy -#define Q_memcmp A_memcmp -#define Q_memmove A_memmove -#define Q_strlen A_strlen -#define Q_strcpy A_strcpy -#define Q_strncpy strncpy -#define Q_strrchr A_strrchr -#define Q_strcat A_strcat -#define Q_strncat strncat -#define Q_strcmp A_strcmp -#define Q_strncmp strncmp -#define Q_sscanf sscanf -#define Q_strdup _strdup -#define Q_stricmp _stricmp -#define Q_strnicmp _strnicmp -#define Q_strstr A_strstr -#define Q_strchr strchr -#define Q_strrchr A_strrchr -#define Q_strlwr A_strtolower -#define Q_sprintf sprintf -#define Q_snprintf _snprintf -#define Q_atoi atoi -#define Q_atof atof -#define Q_toupper toupper -#define Q_vsnprintf _vsnprintf -#define Q_vsnwprintf _vsnwprintf -#define Q_abs abs -#define Q_fabs fabs -#define Q_tan tan -#define Q_atan atan -#define Q_atan2 atan2 -#define Q_acos acos -#define Q_cos cos -#define Q_sin sin -#define Q_pow pow -#define Q_fmod fmod -#define Q_fopen fopen -#define Q_fwrite fwrite -#define Q_fprintf fprintf -#define Q_fclose fclose -#else -#define Q_sqrt sqrt -#define Q_min min -#define Q_max max -#define Q_clamp clamp -#define Q_access _access -#define Q_close _close -#define Q_write _write -#define Q_memset memset -#define Q_memcpy memcpy -#define Q_memcmp memcmp -#define Q_memmove memmove -#define Q_strlen strlen -#define Q_strcpy strcpy -#define Q_strncpy strncpy -#define Q_strrchr strrchr -#define Q_strcat strcat -#define Q_strncat strncat -#define Q_strcmp strcmp -#define Q_strncmp strncmp -#define Q_sscanf sscanf -#define Q_strdup _strdup -#define Q_stricmp _stricmp -#define Q_strnicmp _strnicmp -#define Q_strstr strstr -#define Q_strchr strchr -#define Q_strrchr strrchr -#define Q_strlwr _strlwr -#define Q_sprintf sprintf -#define Q_snprintf _snprintf -#define Q_atoi atoi -#define Q_atof atof -#define Q_toupper toupper -#define Q_vsnprintf _vsnprintf -#define Q_vsnwprintf _vsnwprintf -#define Q_abs abs -#define Q_fabs fabs -#define Q_tan tan -#define Q_atan atan -#define Q_atan2 atan2 -#define Q_acos acos -#define Q_cos cos -#define Q_sin sin -#define Q_pow pow -#define Q_fmod fmod -#define Q_fopen fopen -#define Q_fwrite fwrite -#define Q_fprintf fprintf -#define Q_fclose fclose -#endif diff --git a/regamedll/public/regamedll/regamedll_const.h b/regamedll/public/regamedll/regamedll_const.h index 36d038b9..ddbe62af 100644 --- a/regamedll/public/regamedll/regamedll_const.h +++ b/regamedll/public/regamedll/regamedll_const.h @@ -25,80 +25,84 @@ * version. * */ + #pragma once // These are caps bits to indicate what an object's capabilities (currently used for save/restore and level transitions) -#define FCAP_CUSTOMSAVE 0x00000001 -#define FCAP_ACROSS_TRANSITION 0x00000002 // should transfer between transitions -#define FCAP_MUST_SPAWN 0x00000004 // Spawn after restore -#define FCAP_DONT_SAVE 0x80000000 // Don't save this -#define FCAP_IMPULSE_USE 0x00000008 // can be used by the player -#define FCAP_CONTINUOUS_USE 0x00000010 // can be used by the player -#define FCAP_ONOFF_USE 0x00000020 // can be used by the player -#define FCAP_DIRECTIONAL_USE 0x00000040 // Player sends +/- 1 when using (currently only tracktrains) -#define FCAP_MASTER 0x00000080 // Can be used to "master" other entities (like multisource) +#define FCAP_CUSTOMSAVE 0x00000001 +#define FCAP_ACROSS_TRANSITION 0x00000002 // Should transfer between transitions +#define FCAP_MUST_SPAWN 0x00000004 // Spawn after restore +#define FCAP_DONT_SAVE 0x80000000 // Don't save this +#define FCAP_IMPULSE_USE 0x00000008 // Can be used by the player +#define FCAP_CONTINUOUS_USE 0x00000010 // Can be used by the player +#define FCAP_ONOFF_USE 0x00000020 // Can be used by the player +#define FCAP_DIRECTIONAL_USE 0x00000040 // Player sends +/- 1 when using (currently only tracktrains) +#define FCAP_MASTER 0x00000080 // Can be used to "master" other entities (like multisource) +#define FCAP_MUST_RESET 0x00000100 // Should reset on the new round +#define FCAP_MUST_RELEASE 0x00000200 // Should release on the new round // UNDONE: This will ignore transition volumes (trigger_transition), but not the PVS!!! -#define FCAP_FORCE_TRANSITION 0x00000080 // ALWAYS goes across transitions +#define FCAP_FORCE_TRANSITION 0x00000080 // ALWAYS goes across transitions // for Classify -#define CLASS_NONE 0 -#define CLASS_MACHINE 1 -#define CLASS_PLAYER 2 -#define CLASS_HUMAN_PASSIVE 3 -#define CLASS_HUMAN_MILITARY 4 -#define CLASS_ALIEN_MILITARY 5 -#define CLASS_ALIEN_PASSIVE 6 -#define CLASS_ALIEN_MONSTER 7 -#define CLASS_ALIEN_PREY 8 -#define CLASS_ALIEN_PREDATOR 9 -#define CLASS_INSECT 10 -#define CLASS_PLAYER_ALLY 11 -#define CLASS_PLAYER_BIOWEAPON 12 // hornets and snarks.launched by players -#define CLASS_ALIEN_BIOWEAPON 13 // hornets and snarks.launched by the alien menace -#define CLASS_VEHICLE 14 -#define CLASS_BARNACLE 99 // special because no one pays attention to it, and it eats a wide cross-section of creatures. +#define CLASS_NONE 0 +#define CLASS_MACHINE 1 +#define CLASS_PLAYER 2 +#define CLASS_HUMAN_PASSIVE 3 +#define CLASS_HUMAN_MILITARY 4 +#define CLASS_ALIEN_MILITARY 5 +#define CLASS_ALIEN_PASSIVE 6 +#define CLASS_ALIEN_MONSTER 7 +#define CLASS_ALIEN_PREY 8 +#define CLASS_ALIEN_PREDATOR 9 +#define CLASS_INSECT 10 +#define CLASS_PLAYER_ALLY 11 +#define CLASS_PLAYER_BIOWEAPON 12 // hornets and snarks.launched by players +#define CLASS_ALIEN_BIOWEAPON 13 // hornets and snarks.launched by the alien menace +#define CLASS_VEHICLE 14 +#define CLASS_BARNACLE 99 // special because no one pays attention to it, and it eats a wide cross-section of creatures. -#define SF_NORESPAWN (1 << 30) // set this bit on guns and stuff that should never respawn. +#define SF_NORESPAWN (1<<30) // set this bit on guns and stuff that should never respawn. -#define DMG_GENERIC 0 // generic damage was done -#define DMG_CRUSH (1<<0) // crushed by falling or moving object -#define DMG_BULLET (1<<1) // shot -#define DMG_SLASH (1<<2) // cut, clawed, stabbed -#define DMG_BURN (1<<3) // heat burned -#define DMG_FREEZE (1<<4) // frozen -#define DMG_FALL (1<<5) // fell too far -#define DMG_BLAST (1<<6) // explosive blast damage -#define DMG_CLUB (1<<7) // crowbar, punch, headbutt -#define DMG_SHOCK (1<<8) // electric shock -#define DMG_SONIC (1<<9) // sound pulse shockwave -#define DMG_ENERGYBEAM (1<<10) // laser or other high energy beam -#define DMG_NEVERGIB (1<<12) // with this bit OR'd in, no damage type will be able to gib victims upon death -#define DMG_ALWAYSGIB (1<<13) // with this bit OR'd in, any damage type can be made to gib victims upon death -#define DMG_DROWN (1<<14) // Drowning +#define DMG_GENERIC 0 // generic damage was done +#define DMG_CRUSH (1<<0) // crushed by falling or moving object +#define DMG_BULLET (1<<1) // shot +#define DMG_SLASH (1<<2) // cut, clawed, stabbed +#define DMG_BURN (1<<3) // heat burned +#define DMG_FREEZE (1<<4) // frozen +#define DMG_FALL (1<<5) // fell too far +#define DMG_BLAST (1<<6) // explosive blast damage +#define DMG_CLUB (1<<7) // crowbar, punch, headbutt +#define DMG_SHOCK (1<<8) // electric shock +#define DMG_SONIC (1<<9) // sound pulse shockwave +#define DMG_ENERGYBEAM (1<<10) // laser or other high energy beam +#define DMG_NEVERGIB (1<<12) // with this bit OR'd in, no damage type will be able to gib victims upon death +#define DMG_ALWAYSGIB (1<<13) // with this bit OR'd in, any damage type can be made to gib victims upon death +#define DMG_DROWN (1<<14) // Drowning // time-based damage -#define DMG_TIMEBASED (~(0x3FFF)) // mask for time-based damage +#define DMG_TIMEBASED (~(0x3FFF)) // mask for time-based damage -#define DMG_PARALYZE (1<<15) // slows affected creature down -#define DMG_NERVEGAS (1<<16) // nerve toxins, very bad -#define DMG_POISON (1<<17) // blood poisioning -#define DMG_RADIATION (1<<18) // radiation exposure -#define DMG_DROWNRECOVER (1<<19) // drowning recovery -#define DMG_ACID (1<<20) // toxic chemicals or acid burns -#define DMG_SLOWBURN (1<<21) // in an oven -#define DMG_SLOWFREEZE (1<<22) // in a subzero freezer -#define DMG_MORTAR (1<<23) // Hit by air raid (done to distinguish grenade from mortar) -#define DMG_EXPLOSION (1<<24) +#define DMG_PARALYZE (1<<15) // slows affected creature down +#define DMG_NERVEGAS (1<<16) // nerve toxins, very bad +#define DMG_POISON (1<<17) // blood poisioning +#define DMG_RADIATION (1<<18) // radiation exposure +#define DMG_DROWNRECOVER (1<<19) // drowning recovery +#define DMG_ACID (1<<20) // toxic chemicals or acid burns +#define DMG_SLOWBURN (1<<21) // in an oven +#define DMG_SLOWFREEZE (1<<22) // in a subzero freezer +#define DMG_MORTAR (1<<23) // Hit by air raid (done to distinguish grenade from mortar) +#define DMG_EXPLOSION (1<<24) -// these are the damage types that are allowed to gib corpses -#define DMG_GIB_CORPSE (DMG_CRUSH | DMG_FALL | DMG_BLAST | DMG_SONIC | DMG_CLUB) +// These are the damage types that are allowed to gib corpses +#define DMG_GIB_CORPSE (DMG_CRUSH | DMG_FALL | DMG_BLAST | DMG_SONIC | DMG_CLUB) -// these are the damage types that have client hud art -#define DMG_SHOWNHUD (DMG_POISON | DMG_ACID | DMG_FREEZE | DMG_SLOWFREEZE | DMG_DROWN | DMG_BURN | DMG_SLOWBURN | DMG_NERVEGAS | DMG_RADIATION | DMG_SHOCK) +// These are the damage types that have client hud art +#define DMG_SHOWNHUD (DMG_POISON | DMG_ACID | DMG_FREEZE | DMG_SLOWFREEZE | DMG_DROWN | DMG_BURN | DMG_SLOWBURN | DMG_NERVEGAS | DMG_RADIATION | DMG_SHOCK) -// when calling KILLED(), a value that governs gib behavior is expected to be +// When calling KILLED(), a value that governs gib behavior is expected to be // one of these three values -#define GIB_NORMAL 0 // gib if entity was overkilled -#define GIB_NEVER 1 // never gib, no matter how much death damage is done ( freezing, etc ) -#define GIB_ALWAYS 2 // always gib ( Houndeye Shock, Barnacle Bite ) +#define GIB_NORMAL 0 // Gib if entity was overkilled +#define GIB_NEVER 1 // Never gib, no matter how much death damage is done ( freezing, etc ) +#define GIB_ALWAYS 2 // Always gib ( Houndeye Shock, Barnacle Bite ) +#define GIB_HEALTH_VALUE -30 diff --git a/regamedll/public/strtools.h b/regamedll/public/strtools.h new file mode 100644 index 00000000..8b414bf3 --- /dev/null +++ b/regamedll/public/strtools.h @@ -0,0 +1,211 @@ +/* +* +* This program is free software; you can redistribute it and/or modify it +* under the terms of the GNU General Public License as published by the +* Free Software Foundation; either version 2 of the License, or (at +* your option) any later version. +* +* This program 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 +* General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software Foundation, +* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +* +* In addition, as a special exception, the author gives permission to +* link the code of this program with the Half-Life Game Engine ("HL +* Engine") and Modified Game Libraries ("MODs") developed by Valve, +* L.L.C ("Valve"). You must obey the GNU General Public License in all +* respects for all of the code used other than the HL Engine and MODs +* from Valve. If you modify this file, you may extend this exception +* to your version of the file, but you are not obligated to do so. If +* you do not wish to do so, delete this exception statement from your +* version. +* +*/ + +#pragma once + +#ifdef _WIN32 +const char CORRECT_PATH_SEPARATOR = '\\'; +const char INCORRECT_PATH_SEPARATOR = '/'; +#else +const char CORRECT_PATH_SEPARATOR = '/'; +const char INCORRECT_PATH_SEPARATOR = '\\'; +#endif + +#if !defined(_WIN32) +inline char *_strupr(char *start) +{ + char *str = start; + while (str && *str) + { + *str = (char)toupper(*str); + str++; + } + + return start; +} + +inline char *_strlwr(char *start) +{ + char *str = start; + while (str && *str) + { + *str = (char)tolower(*str); + str++; + } + + return start; +} +#endif + +#if defined(ASMLIB_H) && defined(HAVE_OPT_STRTOOLS) + #define Q_memset A_memset + #define Q_memcpy A_memcpy + #define Q_memcmp A_memcmp + #define Q_memmove A_memmove + #define Q_strlen A_strlen + #define Q_strcpy A_strcpy + #define Q_strncpy strncpy + #define Q_strcat A_strcat + #define Q_strncat strncat + #define Q_strcmp A_strcmp + #define Q_strncmp strncmp + #define Q_strdup _strdup + #define Q_stricmp A_stricmp + #define Q_strnicmp _strnicmp + #define Q_strstr A_strstr + #define Q_strchr strchr + #define Q_strrchr strrchr + #define Q_strlwr A_strtolower + #define Q_strupr A_strtoupper + #define Q_sprintf sprintf + #define Q_snprintf _snprintf + #define Q_vsnprintf _vsnprintf + #define Q_vsnwprintf _vsnwprintf + #define Q_atoi atoi + #define Q_atof atof + #define Q_sqrt M_sqrt + #define Q_min M_min + #define Q_max M_max + #define Q_clamp M_clamp + #define Q_abs abs + #define Q_fabs fabs + #define Q_tan tan + #define Q_atan atan + #define Q_atan2 atan2 + #define Q_acos acos + #define Q_cos cos + #define Q_sin sin + #define Q_pow pow + #define Q_fmod fmod +#else + #define Q_memset memset + #define Q_memcpy memcpy + #define Q_memcmp memcmp + #define Q_memmove memmove + #define Q_strlen strlen + #define Q_strcpy strcpy + #define Q_strncpy strncpy + #define Q_strcat strcat + #define Q_strncat strncat + #define Q_strcmp strcmp + #define Q_strncmp strncmp + #define Q_strdup _strdup + #define Q_stricmp _stricmp + #define Q_strnicmp _strnicmp + #define Q_strstr strstr + #define Q_strchr strchr + #define Q_strrchr strrchr + #define Q_strlwr _strlwr + #define Q_strupr _strupr + #define Q_sprintf sprintf + #define Q_snprintf _snprintf + #define Q_vsnprintf _vsnprintf + #define Q_vsnwprintf _vsnwprintf + #define Q_atoi atoi + #define Q_atof atof + #define Q_sqrt sqrt + #define Q_min min + #define Q_max max + #define Q_clamp clamp + #define Q_abs abs + #define Q_fabs fabs + #define Q_tan tan + #define Q_atan atan + #define Q_atan2 atan2 + #define Q_acos acos + #define Q_cos cos + #define Q_sin sin + #define Q_pow pow + #define Q_fmod fmod +#endif // #if defined(ASMLIB_H) && defined(HAVE_OPT_STRTOOLS) + +// a safe variant of strcpy that truncates the result to fit in the destination buffer +template +char *Q_strlcpy(char (&dest)[size], const char *src) { + Q_strncpy(dest, src, size - 1); + dest[size - 1] = '\0'; + return dest; +} + +inline char *Q_strnlcpy(char *dest, const char *src, size_t n) { + Q_strncpy(dest, src, n - 1); + dest[n - 1] = '\0'; + return dest; +} + +// safely concatenate two strings. +// a variant of strcat that truncates the result to fit in the destination buffer +template +size_t Q_strlcat(char (&dest)[size], const char *src) +{ + size_t srclen; // Length of source string + size_t dstlen; // Length of destination string + + // Figure out how much room is left + dstlen = Q_strlen(dest); + size_t length = size - dstlen + 1; + + if (!length) { + // No room, return immediately + return dstlen; + } + + // Figure out how much room is needed + srclen = Q_strlen(src); + + // Copy the appropriate amount + if (srclen > length) { + srclen = length; + } + + Q_memcpy(dest + dstlen, src, srclen); + dest[dstlen + srclen] = '\0'; + + return dstlen + srclen; +} + +// Force slashes of either type to be = separator character +inline void Q_FixSlashes(char *pname, char separator = CORRECT_PATH_SEPARATOR) +{ + while (*pname) + { + if (*pname == INCORRECT_PATH_SEPARATOR || *pname == CORRECT_PATH_SEPARATOR) + { + *pname = separator; + } + + pname++; + } +} + +// strcpy that works correctly with overlapping src and dst buffers +inline char *Q_strcpy_s(char *dst, char *src) { + int len = Q_strlen(src); + Q_memmove(dst, src, len + 1); + return dst; +} diff --git a/regamedll/public/tier0/dbg.cpp b/regamedll/public/tier0/dbg.cpp index b730ec3f..f93e56d4 100644 --- a/regamedll/public/tier0/dbg.cpp +++ b/regamedll/public/tier0/dbg.cpp @@ -1,37 +1,38 @@ -//=========== (C) Copyright 1999 Valve, L.L.C. All rights reserved. =========== -// -// The copyright to the contents herein is the property of Valve, L.L.C. -// The contents may be used and/or copied only with the written permission of -// Valve, L.L.C., or in accordance with the terms and conditions stipulated in -// the agreement/contract under which the contents have been supplied. -// -// $Header: $ -// $NoKeywords: $ -// -// The main debug library implementation -//============================================================================= +/* +* +* This program is free software; you can redistribute it and/or modify it +* under the terms of the GNU General Public License as published by the +* Free Software Foundation; either version 2 of the License, or (at +* your option) any later version. +* +* This program 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 +* General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software Foundation, +* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +* +* In addition, as a special exception, the author gives permission to +* link the code of this program with the Half-Life Game Engine ("HL +* Engine") and Modified Game Libraries ("MODs") developed by Valve, +* L.L.C ("Valve"). You must obey the GNU General Public License in all +* respects for all of the code used other than the HL Engine and MODs +* from Valve. If you modify this file, you may extend this exception +* to your version of the file, but you are not obligated to do so. If +* you do not wish to do so, delete this exception statement from your +* version. +* +*/ #include "precompiled.h" -#include -#include -#include -#include -#include -#include -#include "tier0/dbg.h" -#include - - -//----------------------------------------------------------------------------- -// internal structures -//----------------------------------------------------------------------------- - -#define MAX_GROUP_NAME_LENGTH 48 -//enum -//{ -// MAX_GROUP_NAME_LENGTH = 48 -//}; +// Internal structures +enum +{ + MAX_GROUP_NAME_LENGTH = 48 +}; struct SpewGroup_t { @@ -40,10 +41,8 @@ struct SpewGroup_t }; -//----------------------------------------------------------------------------- // Templates to assist in validating pointers: - -void _AssertValidReadPtr(void* ptr, int count/* = 1*/) +void _AssertValidReadPtr(void *ptr, int count) { #ifdef _WIN32 Assert(!IsBadReadPtr(ptr, count)); @@ -53,7 +52,7 @@ void _AssertValidReadPtr(void* ptr, int count/* = 1*/) } -void _AssertValidWritePtr(void* ptr, int count/* = 1*/) +void _AssertValidWritePtr(void *ptr, int count) { #ifdef _WIN32 Assert(!IsBadWritePtr(ptr, count)); @@ -62,7 +61,7 @@ void _AssertValidWritePtr(void* ptr, int count/* = 1*/) #endif } -void _AssertValidReadWritePtr(void* ptr, int count/* = 1*/) +void _AssertValidReadWritePtr(void *ptr, int count) { #ifdef _WIN32 Assert(!(IsBadWritePtr(ptr, count) || IsBadReadPtr(ptr, count))); @@ -71,7 +70,7 @@ void _AssertValidReadWritePtr(void* ptr, int count/* = 1*/) #endif } -void AssertValidStringPtr(const char* ptr, int maxchar/* = 0xFFFFFF */) +void AssertValidStringPtr(const char *ptr, int maxchar) { #ifdef _WIN32 Assert(!IsBadStringPtr(ptr, maxchar)); @@ -80,12 +79,8 @@ void AssertValidStringPtr(const char* ptr, int maxchar/* = 0xFFFFFF */) #endif } - -//----------------------------------------------------------------------------- -// globals -//----------------------------------------------------------------------------- - -SpewRetval_t DefaultSpewFunc(SpewType_t type, char const *pMsg) +// Globals +SpewRetval_t DefaultSpewFunc(SpewType_t type, const char *pMsg) { printf("%s", pMsg); if (type == SPEW_ASSERT) @@ -96,28 +91,23 @@ SpewRetval_t DefaultSpewFunc(SpewType_t type, char const *pMsg) return SPEW_CONTINUE; } -static SpewOutputFunc_t s_SpewOutputFunc = DefaultSpewFunc; +static SpewOutputFunc_t s_SpewOutputFunc = DefaultSpewFunc; -static char const* s_pFileName; -static int s_Line; -static SpewType_t s_SpewType; +static const char *s_pFileName; +static int s_Line; +static SpewType_t s_SpewType; -static SpewGroup_t* s_pSpewGroups = 0; -static int s_GroupCount = 0; -static int s_DefaultLevel = 0; +static SpewGroup_t *s_pSpewGroups = 0; +static int s_GroupCount = 0; +static int s_DefaultLevel = 0; - - -//----------------------------------------------------------------------------- // Spew output management. -//----------------------------------------------------------------------------- - -void SpewOutputFunc(SpewOutputFunc_t func) +void SpewOutputFunc(SpewOutputFunc_t func) { s_SpewOutputFunc = func ? func : DefaultSpewFunc; } -SpewOutputFunc_t GetSpewOutputFunc(void) +SpewOutputFunc_t GetSpewOutputFunc() { if (s_SpewOutputFunc) { @@ -129,15 +119,12 @@ SpewOutputFunc_t GetSpewOutputFunc(void) } } -//----------------------------------------------------------------------------- // Spew functions -//----------------------------------------------------------------------------- - -void _SpewInfo(SpewType_t type, char const* pFile, int line) +void _SpewInfo(SpewType_t type, const char *pFile, int line) { // Only grab the file name. Ignore the path. - char const* pSlash = strrchr(pFile, '\\'); - char const* pSlash2 = strrchr(pFile, '/'); + const char *pSlash = strrchr(pFile, '\\'); + const char *pSlash2 = strrchr(pFile, '/'); if (pSlash < pSlash2) pSlash = pSlash2; s_pFileName = pSlash ? pSlash + 1 : pFile; @@ -145,18 +132,18 @@ void _SpewInfo(SpewType_t type, char const* pFile, int line) s_SpewType = type; } -SpewRetval_t _SpewMessage(SpewType_t spewType, char const* pMsgFormat, va_list args) +SpewRetval_t _SpewMessage(SpewType_t spewType, const char *pMsgFormat, va_list args) { char pTempBuffer[1024]; - /* Printf the file and line for warning + assert only... */ + // Printf the file and line for warning + assert only... int len = 0; if ((spewType == SPEW_ASSERT)) { len = sprintf(pTempBuffer, "%s (%d) : ", s_pFileName, s_Line); } - /* Create the message.... */ + // Create the message.... len += vsprintf(&pTempBuffer[len], pMsgFormat, args); // Add \n for warning and assert @@ -165,27 +152,29 @@ SpewRetval_t _SpewMessage(SpewType_t spewType, char const* pMsgFormat, va_list len += sprintf(&pTempBuffer[len], "\n"); } - assert(len < 1024); /* use normal assert here; to avoid recursion. */ + assert(len < 1024); // use normal assert here; to avoid recursion. assert(s_SpewOutputFunc); - /* direct it to the appropriate target(s) */ + // direct it to the appropriate target(s) SpewRetval_t ret = s_SpewOutputFunc(spewType, pTempBuffer); switch (ret) { - // Put the break into the macro so it would occur in the right place - // case SPEW_DEBUGGER: - // DebuggerBreak(); - // break; + // Put the break into the macro so it would occur in the right place + //case SPEW_DEBUGGER: + // DebuggerBreak(); + // break; case SPEW_ABORT: - // MessageBox(NULL,"Error in _SpewMessage","Error",MB_OK); + // MessageBox(NULL,"Error in _SpewMessage","Error",MB_OK); exit(0); + default: + break; } return ret; } -SpewRetval_t _SpewMessage(char const* pMsgFormat, ...) +SpewRetval_t _SpewMessage(const char *pMsgFormat, ...) { va_list args; va_start(args, pMsgFormat); @@ -194,7 +183,7 @@ SpewRetval_t _SpewMessage(char const* pMsgFormat, ...) return ret; } -SpewRetval_t _DSpewMessage(char const *pGroupName, int level, char const* pMsgFormat, ...) +SpewRetval_t _DSpewMessage(const char *pGroupName, int level, const char *pMsgFormat, ...) { if (!IsSpewActive(pGroupName, level)) return SPEW_CONTINUE; @@ -206,7 +195,7 @@ SpewRetval_t _DSpewMessage(char const *pGroupName, int level, char const* pMsgFo return ret; } -void Msg(char const* pMsgFormat, ...) +void Msg(const char *pMsgFormat, ...) { va_list args; va_start(args, pMsgFormat); @@ -214,7 +203,7 @@ void Msg(char const* pMsgFormat, ...) va_end(args); } -void DMsg(char const *pGroupName, int level, char const *pMsgFormat, ...) +void DMsg(const char *pGroupName, int level, const char *pMsgFormat, ...) { if (!IsSpewActive(pGroupName, level)) return; @@ -225,7 +214,7 @@ void DMsg(char const *pGroupName, int level, char const *pMsgFormat, ...) va_end(args); } -void Warning(char const *pMsgFormat, ...) +void Warning(const char *pMsgFormat, ...) { va_list args; va_start(args, pMsgFormat); @@ -233,7 +222,7 @@ void Warning(char const *pMsgFormat, ...) va_end(args); } -void DWarning(char const *pGroupName, int level, char const *pMsgFormat, ...) +void DWarning(const char *pGroupName, int level, const char *pMsgFormat, ...) { if (!IsSpewActive(pGroupName, level)) return; @@ -244,7 +233,7 @@ void DWarning(char const *pGroupName, int level, char const *pMsgFormat, ...) va_end(args); } -void Log(char const *pMsgFormat, ...) +void Log(const char *pMsgFormat, ...) { va_list args; va_start(args, pMsgFormat); @@ -252,7 +241,7 @@ void Log(char const *pMsgFormat, ...) va_end(args); } -void DLog(char const *pGroupName, int level, char const *pMsgFormat, ...) +void DLog(const char *pGroupName, int level, const char *pMsgFormat, ...) { if (!IsSpewActive(pGroupName, level)) return; @@ -263,7 +252,7 @@ void DLog(char const *pGroupName, int level, char const *pMsgFormat, ...) va_end(args); } -void Error(char const *pMsgFormat, ...) +void Error(const char *pMsgFormat, ...) { va_list args; va_start(args, pMsgFormat); @@ -271,13 +260,9 @@ void Error(char const *pMsgFormat, ...) va_end(args); } - -//----------------------------------------------------------------------------- // A couple of super-common dynamic spew messages, here for convenience // These looked at the "developer" group, print if it's level 1 or higher -//----------------------------------------------------------------------------- - -void DevMsg(int level, char const* pMsgFormat, ...) +void DevMsg(int level, char const *pMsgFormat, ...) { if (!IsSpewActive("developer", level)) return; @@ -288,7 +273,7 @@ void DevMsg(int level, char const* pMsgFormat, ...) va_end(args); } -void DevWarning(int level, char const *pMsgFormat, ...) +void DevWarning(int level, const char *pMsgFormat, ...) { if (!IsSpewActive("developer", level)) return; @@ -299,7 +284,7 @@ void DevWarning(int level, char const *pMsgFormat, ...) va_end(args); } -void DevLog(int level, char const *pMsgFormat, ...) +void DevLog(int level, const char *pMsgFormat, ...) { if (!IsSpewActive("developer", level)) return; @@ -310,7 +295,7 @@ void DevLog(int level, char const *pMsgFormat, ...) va_end(args); } -void DevMsg(char const *pMsgFormat, ...) +void DevMsg(const char *pMsgFormat, ...) { if (!IsSpewActive("developer", 1)) return; @@ -321,7 +306,7 @@ void DevMsg(char const *pMsgFormat, ...) va_end(args); } -void DevWarning(char const *pMsgFormat, ...) +void DevWarning(const char *pMsgFormat, ...) { va_list args; va_start(args, pMsgFormat); @@ -329,7 +314,7 @@ void DevWarning(char const *pMsgFormat, ...) va_end(args); } -void DevLog(char const *pMsgFormat, ...) +void DevLog(const char *pMsgFormat, ...) { va_list args; va_start(args, pMsgFormat); @@ -337,13 +322,10 @@ void DevLog(char const *pMsgFormat, ...) va_end(args); } -//----------------------------------------------------------------------------- // Find a group, return true if found, false if not. Return in ind the // index of the found group, or the index of the group right before where the // group should be inserted into the list to maintain sorted order. -//----------------------------------------------------------------------------- - -bool FindSpewGroup(char const* pGroupName, int* pInd) +bool FindSpewGroup(const char *pGroupName, int *pInd) { int s = 0; if (s_GroupCount) @@ -358,22 +340,20 @@ bool FindSpewGroup(char const* pGroupName, int* pInd) *pInd = m; return true; } + if (cmp < 0) e = m - 1; else s = m + 1; } } + *pInd = s; return false; } - -//----------------------------------------------------------------------------- // Sets the priority level for a spew group -//----------------------------------------------------------------------------- - -void SpewActivate(char const* pGroupName, int level) +void SpewActivate(const char *pGroupName, int level) { Assert(pGroupName); @@ -391,19 +371,17 @@ void SpewActivate(char const* pGroupName, int level) if (!FindSpewGroup(pGroupName, &ind)) { // not defined yet, insert an entry. - ++s_GroupCount; + s_GroupCount++; if (s_pSpewGroups) { - s_pSpewGroups = (SpewGroup_t*)realloc(s_pSpewGroups, - s_GroupCount * sizeof(SpewGroup_t)); + s_pSpewGroups = (SpewGroup_t *)realloc(s_pSpewGroups, s_GroupCount * sizeof(SpewGroup_t)); // shift elements down to preserve order int numToMove = s_GroupCount - ind - 1; - memmove(&s_pSpewGroups[ind + 1], &s_pSpewGroups[ind], - numToMove * sizeof(SpewGroup_t)); + memmove(&s_pSpewGroups[ind + 1], &s_pSpewGroups[ind], numToMove * sizeof(SpewGroup_t)); } else - s_pSpewGroups = (SpewGroup_t*)malloc(s_GroupCount * sizeof(SpewGroup_t)); + s_pSpewGroups = (SpewGroup_t *)malloc(s_GroupCount * sizeof(SpewGroup_t)); Assert(strlen(pGroupName) < MAX_GROUP_NAME_LENGTH); strcpy(s_pSpewGroups[ind].m_GroupName, pGroupName); @@ -411,12 +389,8 @@ void SpewActivate(char const* pGroupName, int level) s_pSpewGroups[ind].m_Level = level; } - -//----------------------------------------------------------------------------- // Tests to see if a particular spew is active -//----------------------------------------------------------------------------- - -bool IsSpewActive(char const* pGroupName, int level) +bool IsSpewActive(const char *pGroupName, int level) { // If we don't find the spew group, use the default level. int ind; @@ -425,20 +399,3 @@ bool IsSpewActive(char const* pGroupName, int level) else return s_DefaultLevel >= level; } - - -// If we don't have a function from math.h, then it doesn't link certain floating-point -// functions in and printfs with %f cause runtime errors in the C libraries. -float CrackSmokingCompiler(float a) -{ - return fabs(a); -} - -void* Plat_SimpleLog(const char* file, int line) -{ - FILE* f = fopen("simple.log", "at+"); - fprintf(f, "%s:%i\n", file, line); - fclose(f); - - return NULL; -} \ No newline at end of file diff --git a/regamedll/public/tier0/dbg.h b/regamedll/public/tier0/dbg.h index 0532eac1..11154f4f 100644 --- a/regamedll/public/tier0/dbg.h +++ b/regamedll/public/tier0/dbg.h @@ -1,56 +1,59 @@ -//=========== (C) Copyright 1999 Valve, L.L.C. All rights reserved. =========== -// -// The copyright to the contents herein is the property of Valve, L.L.C. -// The contents may be used and/or copied only with the written permission of -// Valve, L.L.C., or in accordance with the terms and conditions stipulated in -// the agreement/contract under which the contents have been supplied. -// -// $Header: $ -// $NoKeywords: $ -// -// The main debug library interfaces -//============================================================================= +/* +* +* This program is free software; you can redistribute it and/or modify it +* under the terms of the GNU General Public License as published by the +* Free Software Foundation; either version 2 of the License, or (at +* your option) any later version. +* +* This program 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 +* General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software Foundation, +* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +* +* In addition, as a special exception, the author gives permission to +* link the code of this program with the Half-Life Game Engine ("HL +* Engine") and Modified Game Libraries ("MODs") developed by Valve, +* L.L.C ("Valve"). You must obey the GNU General Public License in all +* respects for all of the code used other than the HL Engine and MODs +* from Valve. If you modify this file, you may extend this exception +* to your version of the file, but you are not obligated to do so. If +* you do not wish to do so, delete this exception statement from your +* version. +* +*/ - -#ifndef DBG_H -#define DBG_H - -#ifdef _WIN32 #pragma once -#endif -#include "osconfig.h" #include "basetypes.h" -#include "tier0/platform.h" + #include #include #include -//----------------------------------------------------------------------------- // dll export stuff -//----------------------------------------------------------------------------- - #ifdef TIER0_DLL_EXPORT -#define DBG_INTERFACE DLL_EXPORT -#define DBG_OVERLOAD DLL_GLOBAL_EXPORT -#define DBG_CLASS DLL_CLASS_EXPORT +#define DBG_INTERFACE DLL_EXPORT +#define DBG_OVERLOAD DLL_GLOBAL_EXPORT +#define DBG_CLASS DLL_CLASS_EXPORT #else -#define DBG_INTERFACE DLL_IMPORT -#define DBG_OVERLOAD DLL_GLOBAL_IMPORT -#define DBG_CLASS DLL_CLASS_IMPORT +#define DBG_INTERFACE DLL_IMPORT +#define DBG_OVERLOAD DLL_GLOBAL_IMPORT +#define DBG_CLASS DLL_CLASS_IMPORT #endif - -//----------------------------------------------------------------------------- // Usage model for the Dbg library // // 1. Spew. -// +// // Spew can be used in a static and a dynamic mode. The static // mode allows us to display assertions and other messages either only // in debug builds, or in non-release builds. The dynamic mode allows us to // turn on and off certain spew messages while the application is running. -// +// // Static Spew messages: // // Assertions are used to detect and warn about invalid states @@ -58,21 +61,21 @@ // // To use an assertion, use // -// Assert( (f == 5) ); -// AssertMsg( (f == 5), ("F needs to be %d here!\n", 5) ); -// AssertFunc( (f == 5), BadFunc() ); -// AssertEquals( f, 5 ); -// AssertFloatEquals( f, 5.0f, 1e-3 ); +// Assert((f == 5)); +// AssertMsg((f == 5), ("F needs to be %d here!\n", 5)); +// AssertFunc((f == 5), BadFunc()); +// AssertEquals(f, 5); +// AssertFloatEquals(f, 5.0f, 1e-3); // // The first will simply report that an assertion failed on a particular -// code file and line. The second version will display a print-f formatted message +// code file and line. The second version will display a print-f formatted message // along with the file and line, the third will display a generic message and // will also cause the function BadFunc to be executed, and the last two // will report an error if f is not equal to 5 (the last one asserts within // a particular tolerance). // // To use a warning, use -// +// // Warning("Oh I feel so %s all over\n", "yummy"); // // Warning will do its magic in only Debug builds. To perform spew in *all* @@ -81,40 +84,40 @@ // Three other spew types, Msg, Log, and Error, are compiled into all builds. // These error types do *not* need two sets of parenthesis. // -// Msg( "Isn't this exciting %d?", 5 ); -// Error( "I'm just thrilled" ); +// Msg("Isn't this exciting %d?", 5); +// Error("I'm just thrilled"); // // Dynamic Spew messages // -// It is possible to dynamically turn spew on and off. Dynamic spew is -// identified by a spew group and priority level. To turn spew on for a -// particular spew group, use SpewActivate( "group", level ). This will -// cause all spew in that particular group with priority levels <= the -// level specified in the SpewActivate function to be printed. Use DSpew +// It is possible to dynamically turn spew on and off. Dynamic spew is +// identified by a spew group and priority level. To turn spew on for a +// particular spew group, use SpewActivate("group", level). This will +// cause all spew in that particular group with priority levels <= the +// level specified in the SpewActivate function to be printed. Use DSpew // to perform the spew: // -// DWarning( "group", level, "Oh I feel even yummier!\n" ); +// DWarning("group", level, "Oh I feel even yummier!\n"); // // Priority level 0 means that the spew will *always* be printed, and group -// '*' is the default spew group. If a DWarning is encountered using a group -// whose priority has not been set, it will use the priority of the default -// group. The priority of the default group is initially set to 0. +// '*' is the default spew group. If a DWarning is encountered using a group +// whose priority has not been set, it will use the priority of the default +// group. The priority of the default group is initially set to 0. // // Spew output -// +// // The output of the spew system can be redirected to an externally-supplied -// function which is responsible for outputting the spew. By default, the +// function which is responsible for outputting the spew. By default, the // spew is simply printed using printf. // // To redirect spew output, call SpewOutput. // -// SpewOutputFunc( OutputFunc ); +// SpewOutputFunc(OutputFunc); // // This will cause OutputFunc to be called every time a spew message is // generated. OutputFunc will be passed a spew type and a message to print. // It must return a value indicating whether the debugger should be invoked, -// whether the program should continue running, or whether the program -// should abort. +// whether the program should continue running, or whether the program +// should abort. // // 2. Code activation // @@ -126,13 +129,13 @@ // int x = 5; // ++x; // } -// ); +// ); // // Code can be activated based on the dynamic spew groups also. Use -// -// DBG_DCODE( "group", level, +// +// DBG_DCODE("group", level, // { int x = 5; ++x; } -// ); +// ); // // 3. Breaking into the debugger. // @@ -143,9 +146,8 @@ // You can force a break in any build (release or debug) using // // DebuggerBreak(); -//----------------------------------------------------------------------------- -/* Various types of spew messages */ +// Various types of spew messages // I'm sure you're asking yourself why SPEW_ instead of DBG_ ? // It's because DBG_ is used all over the place in windows.h // For example, DBG_CONTINUE is defined. Feh. @@ -167,221 +169,207 @@ enum SpewRetval_t SPEW_ABORT }; -/* type of externally defined function used to display debug spew */ -typedef SpewRetval_t(*SpewOutputFunc_t)(SpewType_t spewType, char const *pMsg); +// Type of externally defined function used to display debug spew +typedef SpewRetval_t (*SpewOutputFunc_t)(SpewType_t spewType, const char *pMsg); -/* Used to redirect spew output */ -void SpewOutputFunc(SpewOutputFunc_t func); +// Used to redirect spew output +void SpewOutputFunc(SpewOutputFunc_t func); -/* Used ot get the current spew output function */ -SpewOutputFunc_t GetSpewOutputFunc(void); +// Used ot get the current spew output function +SpewOutputFunc_t GetSpewOutputFunc(); -/* Used to manage spew groups and subgroups */ -void SpewActivate(char const* pGroupName, int level); -bool IsSpewActive(char const* pGroupName, int level); +// Used to manage spew groups and subgroups +void SpewActivate(const char *pGroupName, int level); +bool IsSpewActive(const char *pGroupName, int level); -/* Used to display messages, should never be called directly. */ -void _SpewInfo(SpewType_t type, char const* pFile, int line); -SpewRetval_t _SpewMessage(char const* pMsg, ...); -SpewRetval_t _DSpewMessage(char const *pGroupName, int level, char const* pMsg, ...); +// Used to display messages, should never be called directly. +void _SpewInfo(SpewType_t type, const char *pFile, int line); +SpewRetval_t _SpewMessage(const char *pMsg, ...); +SpewRetval_t _DSpewMessage(const char *pGroupName, int level, const char *pMsg, ...); -/* Used to define macros, never use these directly. */ -#define _Assert( _exp ) do { \ - if (!(_exp)) \ - { \ - _SpewInfo( SPEW_ASSERT, __FILE__, __LINE__ ); \ - if (_SpewMessage("Assertion Failed: " #_exp) == SPEW_DEBUGGER) \ - { \ - DebuggerBreak(); \ - } \ - } \ - } while (0) +// Used to define macros, never use these directly. +#define _Assert(_exp) \ + do { \ + if (!(_exp)) \ + { \ + _SpewInfo(SPEW_ASSERT, __FILE__, __LINE__); \ + if (_SpewMessage("Assertion Failed: " #_exp) == SPEW_DEBUGGER) \ + { \ + DebuggerBreak(); \ + } \ + } \ + } while (0) -#define _AssertMsg( _exp, _msg ) do { \ - if (!(_exp)) \ - { \ - _SpewInfo( SPEW_ASSERT, __FILE__, __LINE__ ); \ - if (_SpewMessage(_msg) == SPEW_DEBUGGER) \ - { \ - DebuggerBreak(); \ - } \ - } \ - } while (0) +#define _AssertMsg(_exp, _msg) \ + do { \ + if (!(_exp)) \ + { \ + _SpewInfo(SPEW_ASSERT, __FILE__, __LINE__); \ + if (_SpewMessage(_msg) == SPEW_DEBUGGER) \ + { \ + DebuggerBreak(); \ + } \ + } \ + } while (0) -#define _AssertFunc( _exp, _f ) do { \ - if (!(_exp)) \ - { \ - _SpewInfo( SPEW_ASSERT, __FILE__, __LINE__ ); \ - SpewRetval_t ret = _SpewMessage("Assertion Failed!" #_exp); \ - _f; \ - if (ret == SPEW_DEBUGGER) \ - { \ - DebuggerBreak(); \ - } \ - } \ - } while (0) +#define _AssertFunc(_exp, _f) \ + do { \ + if (!(_exp)) \ + { \ + _SpewInfo(SPEW_ASSERT, __FILE__, __LINE__); \ + SpewRetval_t ret = _SpewMessage("Assertion Failed!" #_exp); \ + _f; \ + if (ret == SPEW_DEBUGGER) \ + { \ + DebuggerBreak(); \ + } \ + } \ + } while (0) -#define _AssertEquals( _exp, _expectedValue ) \ - do { \ - if ((_exp) != (_expectedValue)) \ - { \ - _SpewInfo( SPEW_ASSERT, __FILE__, __LINE__ ); \ - SpewRetval_t ret = _SpewMessage("Expected %d but got %d!", (_expectedValue), (_exp)); \ - if (ret == SPEW_DEBUGGER) \ - { \ - DebuggerBreak(); \ - } \ - } \ - } while (0) +#define _AssertEquals(_exp, _expectedValue) \ + do { \ + if ((_exp) != (_expectedValue)) \ + { \ + _SpewInfo(SPEW_ASSERT, __FILE__, __LINE__); \ + SpewRetval_t ret = _SpewMessage("Expected %d but got %d!", (_expectedValue), (_exp)); \ + if (ret == SPEW_DEBUGGER) \ + { \ + DebuggerBreak(); \ + } \ + } \ + } while (0) -#define _AssertFloatEquals( _exp, _expectedValue, _tol ) \ - do { \ - if (fabs((_exp) - (_expectedValue)) > (_tol)) \ - { \ - _SpewInfo( SPEW_ASSERT, __FILE__, __LINE__ ); \ - SpewRetval_t ret = _SpewMessage("Expected %f but got %f!", (_expectedValue), (_exp)); \ - if (ret == SPEW_DEBUGGER) \ - { \ - DebuggerBreak(); \ - } \ - } \ - } while (0) - -/* Spew macros... */ +#define _AssertFloatEquals(_exp, _expectedValue, _tol) \ + do { \ + if (fabs((_exp) - (_expectedValue)) > (_tol)) \ + { \ + _SpewInfo(SPEW_ASSERT, __FILE__, __LINE__); \ + SpewRetval_t ret = _SpewMessage("Expected %f but got %f!", (_expectedValue), (_exp)); \ + if (ret == SPEW_DEBUGGER) \ + { \ + DebuggerBreak(); \ + } \ + } \ + } while (0) +// Spew macros... #ifdef _DEBUG -#define Assert( _exp ) _Assert( _exp ) -#define AssertMsg( _exp, _msg ) _AssertMsg( _exp, _msg ) -#define AssertFunc( _exp, _f ) _AssertFunc( _exp, _f ) -#define AssertEquals( _exp, _expectedValue ) _AssertEquals( _exp, _expectedValue ) -#define AssertFloatEquals( _exp, _expectedValue, _tol ) _AssertFloatEquals( _exp, _expectedValue, _tol ) -#define Verify( _exp ) _Assert( _exp ) +#define Assert(_exp) _Assert(_exp) +#define AssertMsg(_exp, _msg) _AssertMsg(_exp, _msg) +#define AssertFunc(_exp, _f) _AssertFunc(_exp, _f) +#define AssertEquals(_exp, _expectedValue) _AssertEquals(_exp, _expectedValue) +#define AssertFloatEquals(_exp, _expectedValue, _tol) _AssertFloatEquals(_exp, _expectedValue, _tol) +#define Verify(_exp) _Assert(_exp) -#define AssertMsg1( _exp, _msg, a1 ) _AssertMsg( _exp, CDbgFmtMsg( _msg, a1 ) ) -#define AssertMsg2( _exp, _msg, a1, a2 ) _AssertMsg( _exp, CDbgFmtMsg( _msg, a1, a2 ) ) -#define AssertMsg3( _exp, _msg, a1, a2, a3 ) _AssertMsg( _exp, CDbgFmtMsg( _msg, a1, a2, a3 ) ) -#define AssertMsg4( _exp, _msg, a1, a2, a3, a4 ) _AssertMsg( _exp, CDbgFmtMsg( _msg, a1, a2, a3, a4 ) ) -#define AssertMsg5( _exp, _msg, a1, a2, a3, a4, a5 ) _AssertMsg( _exp, CDbgFmtMsg( _msg, a1, a2, a3, a4, a5 ) ) -#define AssertMsg6( _exp, _msg, a1, a2, a3, a4, a5, a6 ) _AssertMsg( _exp, CDbgFmtMsg( _msg, a1, a2, a3, a4, a5, a6 ) ) -#define AssertMsg6( _exp, _msg, a1, a2, a3, a4, a5, a6 ) _AssertMsg( _exp, CDbgFmtMsg( _msg, a1, a2, a3, a4, a5, a6 ) ) -#define AssertMsg7( _exp, _msg, a1, a2, a3, a4, a5, a6, a7 ) _AssertMsg( _exp, CDbgFmtMsg( _msg, a1, a2, a3, a4, a5, a6, a7 ) ) -#define AssertMsg8( _exp, _msg, a1, a2, a3, a4, a5, a6, a7, a8 ) _AssertMsg( _exp, CDbgFmtMsg( _msg, a1, a2, a3, a4, a5, a6, a7, a8 ) ) -#define AssertMsg9( _exp, _msg, a1, a2, a3, a4, a5, a6, a7, a8, a9 ) _AssertMsg( _exp, CDbgFmtMsg( _msg, a1, a2, a3, a4, a5, a6, a7, a8, a9 ) ) +#define AssertMsg1(_exp, _msg, a1) _AssertMsg(_exp, CDbgFmtMsg(_msg, a1)) +#define AssertMsg2(_exp, _msg, a1, a2) _AssertMsg(_exp, CDbgFmtMsg(_msg, a1, a2)) +#define AssertMsg3(_exp, _msg, a1, a2, a3) _AssertMsg(_exp, CDbgFmtMsg(_msg, a1, a2, a3)) +#define AssertMsg4(_exp, _msg, a1, a2, a3, a4) _AssertMsg(_exp, CDbgFmtMsg(_msg, a1, a2, a3, a4)) +#define AssertMsg5(_exp, _msg, a1, a2, a3, a4, a5) _AssertMsg(_exp, CDbgFmtMsg(_msg, a1, a2, a3, a4, a5)) +#define AssertMsg6(_exp, _msg, a1, a2, a3, a4, a5, a6) _AssertMsg(_exp, CDbgFmtMsg(_msg, a1, a2, a3, a4, a5, a6)) +#define AssertMsg6(_exp, _msg, a1, a2, a3, a4, a5, a6) _AssertMsg(_exp, CDbgFmtMsg(_msg, a1, a2, a3, a4, a5, a6)) +#define AssertMsg7(_exp, _msg, a1, a2, a3, a4, a5, a6, a7) _AssertMsg(_exp, CDbgFmtMsg(_msg, a1, a2, a3, a4, a5, a6, a7)) +#define AssertMsg8(_exp, _msg, a1, a2, a3, a4, a5, a6, a7, a8) _AssertMsg(_exp, CDbgFmtMsg(_msg, a1, a2, a3, a4, a5, a6, a7, a8)) +#define AssertMsg9(_exp, _msg, a1, a2, a3, a4, a5, a6, a7, a8, a9) _AssertMsg(_exp, CDbgFmtMsg(_msg, a1, a2, a3, a4, a5, a6, a7, a8, a9)) +#else // _DEBUG -#else /* Not _DEBUG */ +#define Assert(_exp) ((void)0) +#define AssertMsg(_exp, _msg) ((void)0) +#define AssertFunc(_exp, _f) ((void)0) +#define AssertEquals(_exp, _expectedValue) ((void)0) +#define AssertFloatEquals(_exp, _expectedValue, _tol) ((void)0) +#define Verify(_exp) (_exp) -#define Assert( _exp ) ((void)0) -#define AssertMsg( _exp, _msg ) ((void)0) -#define AssertFunc( _exp, _f ) ((void)0) -#define AssertEquals( _exp, _expectedValue ) ((void)0) -#define AssertFloatEquals( _exp, _expectedValue, _tol ) ((void)0) -#define Verify( _exp ) (_exp) +#define AssertMsg1(_exp, _msg, a1) ((void)0) +#define AssertMsg2(_exp, _msg, a1, a2) ((void)0) +#define AssertMsg3(_exp, _msg, a1, a2, a3) ((void)0) +#define AssertMsg4(_exp, _msg, a1, a2, a3, a4) ((void)0) +#define AssertMsg5(_exp, _msg, a1, a2, a3, a4, a5) ((void)0) +#define AssertMsg6(_exp, _msg, a1, a2, a3, a4, a5, a6) ((void)0) +#define AssertMsg6(_exp, _msg, a1, a2, a3, a4, a5, a6) ((void)0) +#define AssertMsg7(_exp, _msg, a1, a2, a3, a4, a5, a6, a7) ((void)0) +#define AssertMsg8(_exp, _msg, a1, a2, a3, a4, a5, a6, a7, a8) ((void)0) +#define AssertMsg9(_exp, _msg, a1, a2, a3, a4, a5, a6, a7, a8, a9) ((void)0) -#define AssertMsg1( _exp, _msg, a1 ) ((void)0) -#define AssertMsg2( _exp, _msg, a1, a2 ) ((void)0) -#define AssertMsg3( _exp, _msg, a1, a2, a3 ) ((void)0) -#define AssertMsg4( _exp, _msg, a1, a2, a3, a4 ) ((void)0) -#define AssertMsg5( _exp, _msg, a1, a2, a3, a4, a5 ) ((void)0) -#define AssertMsg6( _exp, _msg, a1, a2, a3, a4, a5, a6 ) ((void)0) -#define AssertMsg6( _exp, _msg, a1, a2, a3, a4, a5, a6 ) ((void)0) -#define AssertMsg7( _exp, _msg, a1, a2, a3, a4, a5, a6, a7 ) ((void)0) -#define AssertMsg8( _exp, _msg, a1, a2, a3, a4, a5, a6, a7, a8 ) ((void)0) -#define AssertMsg9( _exp, _msg, a1, a2, a3, a4, a5, a6, a7, a8, a9 ) ((void)0) +#endif // _DEBUG -#endif /* _DEBUG */ +// These are always compiled in +void Msg(const char *pMsg, ...); +void DMsg(const char *pGroupName, int level, const char *pMsg, ...); +void Warning(const char *pMsg, ...); +void DWarning(const char *pGroupName, int level, const char *pMsg, ...); +void Log(const char *pMsg, ...); +void DLog(const char *pGroupName, int level, const char *pMsg, ...); -/* These are always compiled in */ -void Msg(char const* pMsg, ...); -void DMsg(char const *pGroupName, int level, char const *pMsg, ...); - -void Warning(char const *pMsg, ...); -void DWarning(char const *pGroupName, int level, char const *pMsg, ...); - -void Log(char const *pMsg, ...); -void DLog(char const *pGroupName, int level, char const *pMsg, ...); - -void Error(char const *pMsg, ...); +void Error(const char *pMsg, ...); // You can use this macro like a runtime assert macro. // If the condition fails, then Error is called with the message. This macro is called // like AssertMsg, where msg must be enclosed in parenthesis: // -// ErrorIfNot( bCondition, ("a b c %d %d %d", 1, 2, 3) ); -#define ErrorIfNot( condition, msg ) \ - if ( (condition) ) \ - ; \ - else \ - { \ - Error msg; \ +// ErrorIfNot(bCondition, ("a b c %d %d %d", 1, 2, 3)); +#define ErrorIfNot(condition, msg) \ + if ((condition)) \ + ; \ + else \ + { \ + Error msg; \ } -/* A couple of super-common dynamic spew messages, here for convenience */ -/* These looked at the "developer" group */ +// A couple of super-common dynamic spew messages, here for convenience +// These looked at the "developer" group void DevMsg(int level, char const* pMsg, ...); -void DevWarning(int level, char const *pMsg, ...); -void DevLog(int level, char const *pMsg, ...); +void DevWarning(int level, const char *pMsg, ...); +void DevLog(int level, const char *pMsg, ...); -/* default level versions (level 1) */ +// default level versions (level 1) void DevMsg(char const* pMsg, ...); -void DevWarning(char const *pMsg, ...); -void DevLog(char const *pMsg, ...); - -/* Code macros, debugger interface */ +void DevWarning(const char *pMsg, ...); +void DevLog(const char *pMsg, ...); +// Code macros, debugger interface #ifdef _DEBUG +#define DBG_CODE(_code) if (0) ; else { _code } +#define DBG_DCODE(_g, _l, _code) if (IsSpewActive(_g, _l)) { _code } else {} +#define DBG_BREAK() DebuggerBreak() +#else // _DEBUG +#define DBG_CODE(_code) ((void)0) +#define DBG_DCODE(_g, _l, _code) ((void)0) +#define DBG_BREAK() ((void)0) +#endif // _DEBUG -#define DBG_CODE( _code ) if (0) ; else { _code } -#define DBG_DCODE( _g, _l, _code ) if (IsSpewActive( _g, _l )) { _code } else {} -#define DBG_BREAK() DebuggerBreak() /* defined in platform.h */ - -#else /* not _DEBUG */ - -#define DBG_CODE( _code ) ((void)0) -#define DBG_DCODE( _g, _l, _code ) ((void)0) -#define DBG_BREAK() ((void)0) - -#endif /* _DEBUG */ - -//----------------------------------------------------------------------------- // Macro to assist in asserting constant invariants during compilation - #define UID_PREFIX generated_id_ -#define UID_CAT1(a,c) a ## c -#define UID_CAT2(a,c) UID_CAT1(a,c) -#define UNIQUE_ID UID_CAT2(UID_PREFIX,__LINE__) - +#define UID_CAT1(a, c) a ## c +#define UID_CAT2(a, c) UID_CAT1(a,c) +#define UNIQUE_ID UID_CAT2(UID_PREFIX, __LINE__) #ifdef _DEBUG -#define COMPILE_TIME_ASSERT( pred ) switch(0){case 0:case pred:;} -#define ASSERT_INVARIANT( pred ) static void UNIQUE_ID() { COMPILE_TIME_ASSERT( pred ) } +#define COMPILE_TIME_ASSERT(pred) switch(0){case 0:case pred:;} +#define ASSERT_INVARIANT(pred) static void UNIQUE_ID() { COMPILE_TIME_ASSERT(pred) } #else -#define COMPILE_TIME_ASSERT( pred ) -#define ASSERT_INVARIANT( pred ) +#define COMPILE_TIME_ASSERT(pred) +#define ASSERT_INVARIANT(pred) #endif - -//----------------------------------------------------------------------------- // Templates to assist in validating pointers: - // Have to use these stubs so we don't have to include windows.h here. -void _AssertValidReadPtr(void* ptr, int count = 1); -void _AssertValidWritePtr(void* ptr, int count = 1); -void _AssertValidReadWritePtr(void* ptr, int count = 1); +void _AssertValidReadPtr(void *ptr, int count = 1); +void _AssertValidWritePtr(void *ptr, int count = 1); +void _AssertValidReadWritePtr(void *ptr, int count = 1); - void AssertValidStringPtr(const char* ptr, int maxchar = 0xFFFFFF); -template inline void AssertValidReadPtr(T* ptr, int count = 1) { _AssertValidReadPtr((void*)ptr, count); } -template inline void AssertValidWritePtr(T* ptr, int count = 1) { _AssertValidWritePtr((void*)ptr, count); } -template inline void AssertValidReadWritePtr(T* ptr, int count = 1) { _AssertValidReadWritePtr((void*)ptr, count); } + void AssertValidStringPtr(const char *ptr, int maxchar = 0xFFFFFF); +template inline void AssertValidReadPtr(T *ptr, int count = 1) { _AssertValidReadPtr((void *)ptr, count); } +template inline void AssertValidWritePtr(T *ptr, int count = 1) { _AssertValidWritePtr((void *)ptr, count); } +template inline void AssertValidReadWritePtr(T *ptr, int count = 1) { _AssertValidReadWritePtr((void *)ptr, count); } -#define AssertValidThis() AssertValidReadWritePtr(this,sizeof(*this)) +#define AssertValidThis() AssertValidReadWritePtr(this, sizeof(*this)) -//----------------------------------------------------------------------------- // Macro to protect functions that are not reentrant - #ifdef _DEBUG class CReentryGuard { @@ -391,7 +379,6 @@ public: { ++(*m_pSemaphore); } - ~CReentryGuard() { --(*m_pSemaphore); @@ -401,31 +388,25 @@ private: int *m_pSemaphore; }; -#define ASSERT_NO_REENTRY() \ +#define ASSERT_NO_REENTRY() \ static int fSemaphore##__LINE__; \ - Assert( !fSemaphore##__LINE__ ); \ - CReentryGuard ReentryGuard##__LINE__( &fSemaphore##__LINE__ ) -#else + Assert(!fSemaphore##__LINE__); \ + CReentryGuard ReentryGuard##__LINE__(&fSemaphore##__LINE__) +#else // _DEBUG #define ASSERT_NO_REENTRY() -#endif - -//----------------------------------------------------------------------------- -// -// Purpose: Inline string formatter -// +#endif // _DEBUG +// Inline string formatter class CDbgFmtMsg { public: CDbgFmtMsg(const char *pszFormat, ...) { va_list arg_ptr; - va_start(arg_ptr, pszFormat); _vsnprintf(m_szBuf, sizeof(m_szBuf) - 1, pszFormat, arg_ptr); va_end(arg_ptr); - - m_szBuf[sizeof(m_szBuf) - 1] = 0; + m_szBuf[sizeof(m_szBuf) - 1] = '\0'; } operator const char *() const @@ -437,15 +418,10 @@ private: char m_szBuf[256]; }; -//----------------------------------------------------------------------------- -// -// Purpose: Embed debug info in each file. -// +// Embed debug info in each file. //#ifdef _WIN32 //#ifdef _DEBUG //#pragma comment(compiler) //#pragma comment(exestr,"*** DEBUG file detected, Last Compile: " __DATE__ ", " __TIME__ " ***") //#endif //#endif - -#endif /* DBG_H */ \ No newline at end of file diff --git a/regamedll/public/tier0/platform.h b/regamedll/public/tier0/platform.h index defe6d18..a70d0d31 100644 --- a/regamedll/public/tier0/platform.h +++ b/regamedll/public/tier0/platform.h @@ -1,489 +1,125 @@ -//=========== (C) Copyright 1999 Valve, L.L.C. All rights reserved. =========== -// -// The copyright to the contents herein is the property of Valve, L.L.C. -// The contents may be used and/or copied only with the written permission of -// Valve, L.L.C., or in accordance with the terms and conditions stipulated in -// the agreement/contract under which the contents have been supplied. -// -// $Header: $ -// $NoKeywords: $ -// -// Extremely low-level platform-specific stuff -//============================================================================= +/* +* +* This program is free software; you can redistribute it and/or modify it +* under the terms of the GNU General Public License as published by the +* Free Software Foundation; either version 2 of the License, or (at +* your option) any later version. +* +* This program 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 +* General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software Foundation, +* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +* +* In addition, as a special exception, the author gives permission to +* link the code of this program with the Half-Life Game Engine ("HL +* Engine") and Modified Game Libraries ("MODs") developed by Valve, +* L.L.C ("Valve"). You must obey the GNU General Public License in all +* respects for all of the code used other than the HL Engine and MODs +* from Valve. If you modify this file, you may extend this exception +* to your version of the file, but you are not obligated to do so. If +* you do not wish to do so, delete this exception statement from your +* version. +* +*/ - -#ifndef PLATFORM_H -#define PLATFORM_H - -#ifdef _WIN32 #pragma once -#endif #include "osconfig.h" -// need this for _alloca -#include - -// need this for memset -#include +#include // need this for _alloca +#include // need this for memset #include "archtypes.h" -typedef float float32; -typedef double float64; - -// for when we don't care about how many bits we use -typedef unsigned int uint; - -// This can be used to ensure the size of pointers to members when declaring -// a pointer type for a class that has only been forward declared -#ifdef _MSC_VER -#define SINGLE_INHERITANCE __single_inheritance -#define MULTIPLE_INHERITANCE __multiple_inheritance -#else -#define SINGLE_INHERITANCE -#define MULTIPLE_INHERITANCE -#endif - -/* -FIXME: Enable this when we no longer fear change =) - -// need these for the limits -#include -#include - -// Maximum and minimum representable values -#define INT8_MAX SCHAR_MAX -#define INT16_MAX SHRT_MAX -#define INT32_MAX LONG_MAX -#define INT64_MAX (((int64)~0) >> 1) - -#define INT8_MIN SCHAR_MIN -#define INT16_MIN SHRT_MIN -#define INT32_MIN LONG_MIN -#define INT64_MIN (((int64)1) << 63) - -#define UINT8_MAX ((uint8)~0) -#define UINT16_MAX ((uint16)~0) -#define UINT32_MAX ((uint32)~0) -#define UINT64_MAX ((uint64)~0) - -#define UINT8_MIN 0 -#define UINT16_MIN 0 -#define UINT32_MIN 0 -#define UINT64_MIN 0 - -#ifndef UINT_MIN -#define UINT_MIN UINT32_MIN -#endif - -#define FLOAT32_MAX FLT_MAX -#define FLOAT64_MAX DBL_MAX - -#define FLOAT32_MIN FLT_MIN -#define FLOAT64_MIN DBL_MIN -*/ - -// portability / compiler settings -#if defined(_WIN32) && !defined(WINDED) - -#if defined(_M_IX86) -#define __i386__ 1 -#endif - -#elif __linux__ -typedef void * HINSTANCE; -#define _MAX_PATH PATH_MAX -#endif // defined(_WIN32) && !defined(WINDED) - - // Defines MAX_PATH #ifndef MAX_PATH -#define MAX_PATH 260 +#define MAX_PATH 260 #endif // Used to step into the debugger -#define DebuggerBreak() __asm { int 3 } +#define DebuggerBreak() __asm { int 3 } // C functions for external declarations that call the appropriate C++ methods #ifndef EXPORT #ifdef _WIN32 -#define EXPORT _declspec( dllexport ) -#else -#define EXPORT /* */ -#endif -#endif - -#if defined __i386__ && !defined __linux__ -#define id386 1 +#define EXPORT __declspec(dllexport) #else -#define id386 0 -#endif // __i386__ +#define EXPORT /**/ +#endif +#endif #ifdef _WIN32 // Used for dll exporting and importing -#define DLL_EXPORT extern "C" __declspec( dllexport ) -#define DLL_IMPORT extern "C" __declspec( dllimport ) +#define DLL_EXPORT extern "C" __declspec(dllexport) +#define DLL_IMPORT extern "C" __declspec(dllimport) // Can't use extern "C" when DLL exporting a class -#define DLL_CLASS_EXPORT __declspec( dllexport ) -#define DLL_CLASS_IMPORT __declspec( dllimport ) +#define DLL_CLASS_EXPORT __declspec(dllexport) +#define DLL_CLASS_IMPORT __declspec(dllimport) // Can't use extern "C" when DLL exporting a global -#define DLL_GLOBAL_EXPORT extern __declspec( dllexport ) -#define DLL_GLOBAL_IMPORT extern __declspec( dllimport ) +#define DLL_GLOBAL_EXPORT extern __declspec(dllexport) +#define DLL_GLOBAL_IMPORT extern __declspec(dllimport) #elif defined __linux__ // Used for dll exporting and importing -#define DLL_EXPORT extern "C" -#define DLL_IMPORT extern "C" +#define DLL_EXPORT extern "C" +#define DLL_IMPORT extern "C" // Can't use extern "C" when DLL exporting a class -#define DLL_CLASS_EXPORT -#define DLL_CLASS_IMPORT +#define DLL_CLASS_EXPORT +#define DLL_CLASS_IMPORT // Can't use extern "C" when DLL exporting a global -#define DLL_GLOBAL_EXPORT extern -#define DLL_GLOBAL_IMPORT extern +#define DLL_GLOBAL_EXPORT extern +#define DLL_GLOBAL_IMPORT extern #else #error "Unsupported Platform." #endif -// Used for standard calling conventions #ifdef _WIN32 -#define FASTCALL __fastcall -#define FORCEINLINE __forceinline -#else -#define FASTCALL -#define FORCEINLINE inline + // Remove warnings from warning level 4. + #pragma warning(disable:4514) // warning C4514: 'acosl' : unreferenced inline function has been removed + #pragma warning(disable:4100) // warning C4100: 'hwnd' : unreferenced formal parameter + #pragma warning(disable:4127) // warning C4127: conditional expression is constant + #pragma warning(disable:4512) // warning C4512: 'InFileRIFF' : assignment operator could not be generated + #pragma warning(disable:4611) // warning C4611: interaction between '_setjmp' and C++ object destruction is non-portable + #pragma warning(disable:4706) // warning C4706: assignment within conditional expression + #pragma warning(disable:4710) // warning C4710: function 'x' not inlined + #pragma warning(disable:4702) // warning C4702: unreachable code + #pragma warning(disable:4505) // unreferenced local function has been removed + #pragma warning(disable:4239) // nonstandard extension used : 'argument' ( conversion from class Vector to class Vector& ) + #pragma warning(disable:4097) // typedef-name 'BaseClass' used as synonym for class-name 'CFlexCycler::CBaseFlex' + #pragma warning(disable:4324) // Padding was added at the end of a structure + #pragma warning(disable:4244) // type conversion warning. + #pragma warning(disable:4305) // truncation from 'const double ' to 'float ' + #pragma warning(disable:4786) // Disable warnings about long symbol names + + #if _MSC_VER >= 1300 + #pragma warning(disable:4511) // Disable warnings about private copy constructors + #endif #endif -// Force a function call site -not- to inlined. (useful for profiling) -#define DONT_INLINE(a) (((int)(a)+1)?(a):(a)) - -// Pass hints to the compiler to prevent it from generating unnessecary / stupid code -// in certain situations. Several compilers other than MSVC also have an equivilent -// construct. -// -// Essentially the 'Hint' is that the condition specified is assumed to be true at -// that point in the compilation. If '0' is passed, then the compiler assumes that -// any subsequent code in the same 'basic block' is unreachable, and thus usually -// removed. -#ifdef _MSC_VER -#define HINT(THE_HINT) __assume((THE_HINT)) -#else -#define HINT(THE_HINT) 0 -#endif - -// Marks the codepath from here until the next branch entry point as unreachable, -// and asserts if any attempt is made to execute it. -#define UNREACHABLE() { Assert(0); HINT(0); } - -// In cases where no default is present or appropriate, this causes MSVC to generate -// as little code as possible, and throw an assertion in debug. -#define NO_DEFAULT default: UNREACHABLE(); - -#ifdef _WIN32 -// Alloca defined for this platform -#define stackalloc( _size ) _alloca( _size ) -#define stackfree( _p ) 0 -#elif __linux__ -// Alloca defined for this platform -#define stackalloc( _size ) alloca( _size ) -#define stackfree( _p ) 0 -#endif - -#ifdef _WIN32 -// Remove warnings from warning level 4. -#pragma warning(disable : 4514) // warning C4514: 'acosl' : unreferenced inline function has been removed -#pragma warning(disable : 4100) // warning C4100: 'hwnd' : unreferenced formal parameter -#pragma warning(disable : 4127) // warning C4127: conditional expression is constant -#pragma warning(disable : 4512) // warning C4512: 'InFileRIFF' : assignment operator could not be generated -#pragma warning(disable : 4611) // warning C4611: interaction between '_setjmp' and C++ object destruction is non-portable -#pragma warning(disable : 4706) // warning C4706: assignment within conditional expression -#pragma warning(disable : 4710) // warning C4710: function 'x' not inlined -#pragma warning(disable : 4702) // warning C4702: unreachable code -#pragma warning(disable : 4505) // unreferenced local function has been removed -#pragma warning(disable : 4239) // nonstandard extension used : 'argument' ( conversion from class Vector to class Vector& ) -#pragma warning(disable : 4097) // typedef-name 'BaseClass' used as synonym for class-name 'CFlexCycler::CBaseFlex' -#pragma warning(disable : 4324) // Padding was added at the end of a structure -#pragma warning(disable : 4244) // type conversion warning. -#pragma warning(disable : 4305) // truncation from 'const double ' to 'float ' -#pragma warning(disable : 4786) // Disable warnings about long symbol names - -#if _MSC_VER >= 1300 -#pragma warning(disable : 4511) // Disable warnings about private copy constructors -#endif -#endif -//----------------------------------------------------------------------------- -// Purpose: Standard functions for handling endian-ness -//----------------------------------------------------------------------------- - -//------------------------------------- -// Basic swaps -//------------------------------------- - -template -inline T WordSwapC(T w) -{ - uint16 temp; - - temp = ((*((uint16 *)&w) & 0xff00) >> 8); - temp |= ((*((uint16 *)&w) & 0x00ff) << 8); - - return *((T*)&temp); -} - -template -inline T DWordSwapC(T dw) -{ - uint32 temp; - - temp = *((uint32 *)&dw) >> 24; - temp |= ((*((uint32 *)&dw) & 0x00FF0000) >> 8); - temp |= ((*((uint32 *)&dw) & 0x0000FF00) << 8); - temp |= ((*((uint32 *)&dw) & 0x000000FF) << 24); - - return *((T*)&temp); -} - -//------------------------------------- -// Fast swaps -//------------------------------------- - -#ifdef _MSC_VER - -#define WordSwap WordSwapAsm -#define DWordSwap DWordSwapAsm - -#pragma warning(push) -#pragma warning (disable:4035) // no return value - -template -inline T WordSwapAsm(T w) -{ - __asm - { - mov ax, w - xchg al, ah - } -} - -template -inline T DWordSwapAsm(T dw) -{ - __asm - { - mov eax, dw - bswap eax - } -} - -#pragma warning(pop) - -// The assembly implementation is not compatible with floats -template <> -inline float DWordSwapAsm(float f) -{ - return DWordSwapC(f); -} - -#else - -#define WordSwap WordSwapC -#define DWordSwap DWordSwapC - -#endif - -//------------------------------------- -// The typically used methods. -//------------------------------------- - -#if defined(__i386__) -#define VALVE_LITTLE_ENDIAN 1 -#endif - -#ifdef _SGI_SOURCE -#define VALVE_BIG_ENDIAN 1 -#endif - -#if defined(VALVE_LITTLE_ENDIAN) - -#define Valve_BigShort( val ) WordSwap( val ) -#define Valve_BigWord( val ) WordSwap( val ) -#define Valve_BigLong( val ) DWordSwap( val ) -#define Valve_BigDWord( val ) DWordSwap( val ) -#define Valve_BigFloat( val ) DWordSwap( val ) -#define Valve_LittleShort( val ) ( val ) -#define Valve_LittleWord( val ) ( val ) -#define Valve_LittleLong( val ) ( val ) -#define Valve_LittleDWord( val ) ( val ) -#define Valve_LittleFloat( val ) ( val ) - -#elif defined(BIG_ENDIAN) - -#define Valve_BigShort( val ) ( val ) -#define Valve_BigWord( val ) ( val ) -#define Valve_BigLong( val ) ( val ) -#define Valve_BigDWord( val ) ( val ) -#define Valve_BigFloat( val ) ( val ) -#define Valve_LittleShort( val ) WordSwap( val ) -#define Valve_LittleWord( val ) WordSwap( val ) -#define Valve_LittleLong( val ) DWordSwap( val ) -#define Valve_LittleDWord( val ) DWordSwap( val ) -#define Valve_LittleFloat( val ) DWordSwap( val ) - -#else - -// @Note (toml 05-02-02): this technique expects the compiler to -// optimize the expression and eliminate the other path. On any new -// platform/compiler this should be tested. -inline short BigShort(short val) { int test = 1; return (*(char *)&test == 1) ? WordSwap(val) : val; } -inline uint16 BigWord(uint16 val) { int test = 1; return (*(char *)&test == 1) ? WordSwap(val) : val; } -inline long BigLong(long val) { int test = 1; return (*(char *)&test == 1) ? DWordSwap(val) : val; } -inline uint32 BigDWord(uint32 val) { int test = 1; return (*(char *)&test == 1) ? DWordSwap(val) : val; } -inline float BigFloat(float val) { int test = 1; return (*(char *)&test == 1) ? DWordSwap(val) : val; } -inline short LittleShort(short val) { int test = 1; return (*(char *)&test == 1) ? val : WordSwap(val); } -inline uint16 LittleWord(uint16 val) { int test = 1; return (*(char *)&test == 1) ? val : WordSwap(val); } -inline long LittleLong(long val) { int test = 1; return (*(char *)&test == 1) ? val : DWordSwap(val); } -inline uint32 LittleDWord(uint32 val) { int test = 1; return (*(char *)&test == 1) ? val : DWordSwap(val); } -inline float LittleFloat(float val) { int test = 1; return (*(char *)&test == 1) ? val : DWordSwap(val); } - -#endif - - - -#ifdef TIER0_DLL_EXPORT -#define PLATFORM_INTERFACE DLL_EXPORT -#define PLATFORM_OVERLOAD DLL_GLOBAL_EXPORT -#else -#define PLATFORM_INTERFACE DLL_IMPORT -#define PLATFORM_OVERLOAD DLL_GLOBAL_IMPORT -#endif - -/* -PLATFORM_INTERFACE double Plat_FloatTime(); // Returns time in seconds since the module was loaded. -PLATFORM_INTERFACE unsigned long Plat_MSTime(); // Time in milliseconds. - -// b/w compatibility -#define Sys_FloatTime Plat_FloatTime -*/ - -// Processor Information: -struct CPUInformation -{ - int m_Size; // Size of this structure, for forward compatability. - - bool m_bRDTSC : 1, // Is RDTSC supported? - m_bCMOV : 1, // Is CMOV supported? - m_bFCMOV : 1, // Is FCMOV supported? - m_bSSE : 1, // Is SSE supported? - m_bSSE2 : 1, // Is SSE2 Supported? - m_b3DNow : 1, // Is 3DNow! Supported? - m_bMMX : 1, // Is MMX supported? - m_bHT : 1; // Is HyperThreading supported? - - unsigned char m_nLogicalProcessors, // Number op logical processors. - m_nPhysicalProcessors; // Number of physical processors - - int64 m_Speed; // In cycles per second. - - char* m_szProcessorID; // Processor vendor Identification. -}; - -PLATFORM_INTERFACE const CPUInformation& GetCPUInformation(); - - -//----------------------------------------------------------------------------- -// Thread related functions -//----------------------------------------------------------------------------- -// Registers the current thread with Tier0's thread management system. -// This should be called on every thread created in the game. -PLATFORM_INTERFACE unsigned long Plat_RegisterThread(const char *pName = "Source Thread"); - -// Registers the current thread as the primary thread. -PLATFORM_INTERFACE unsigned long Plat_RegisterPrimaryThread(); - -// VC-specific. Sets the thread's name so it has a friendly name in the debugger. -// This should generally only be handled by Plat_RegisterThread and Plat_RegisterPrimaryThread -PLATFORM_INTERFACE void Plat_SetThreadName(unsigned long dwThreadID, const char *pName); - -// These would be private if it were possible to export private variables from a .DLL. -// They need to be variables because they are checked by inline functions at performance -// critical places. -PLATFORM_INTERFACE unsigned long Plat_PrimaryThreadID; - -// Returns the ID of the currently executing thread. -PLATFORM_INTERFACE unsigned long Plat_GetCurrentThreadID(); - -// Returns the ID of the primary thread. -inline unsigned long Plat_GetPrimaryThreadID() -{ - return Plat_PrimaryThreadID; -} - -// Returns true if the current thread is the primary thread. -inline bool Plat_IsPrimaryThread() -{ - //return true; - return (Plat_GetPrimaryThreadID() == Plat_GetCurrentThreadID()); -} - -//----------------------------------------------------------------------------- -// Security related functions -//----------------------------------------------------------------------------- -// Ensure that the hardware key's drivers have been installed. -PLATFORM_INTERFACE bool Plat_VerifyHardwareKeyDriver(); - -// Ok, so this isn't a very secure way to verify the hardware key for now. It -// is primarially depending on the fact that all the binaries have been wrapped -// with the secure wrapper provided by the hardware keys vendor. -PLATFORM_INTERFACE bool Plat_VerifyHardwareKey(); - -// The same as above, but notifies user with a message box when the key isn't in -// and gives him an opportunity to correct the situation. -PLATFORM_INTERFACE bool Plat_VerifyHardwareKeyPrompt(); - -// Can be called in real time, doesn't perform the verify every frame. Mainly just -// here to allow the game to drop out quickly when the key is removed, rather than -// allowing the wrapper to pop up it's own blocking dialog, which the engine doesn't -// like much. -PLATFORM_INTERFACE bool Plat_FastVerifyHardwareKey(); - - - -//----------------------------------------------------------------------------- -// Include additional dependant header components. -//----------------------------------------------------------------------------- -//#include "tier0/fasttimer.h" - - -//----------------------------------------------------------------------------- -// Just logs file and line to simple.log -//----------------------------------------------------------------------------- -void* Plat_SimpleLog(const char* file, int line); - -//#define Plat_dynamic_cast Plat_SimpleLog(__FILE__,__LINE__),dynamic_cast - -//----------------------------------------------------------------------------- // Methods to invoke the constructor, copy constructor, and destructor -//----------------------------------------------------------------------------- - template -inline void Construct(T* pMemory) +inline void Construct(T *pMemory) { - new(pMemory)T; + new(pMemory) T; } template -inline void CopyConstruct(T* pMemory, T const& src) +inline void CopyConstruct(T *pMemory, T const &src) { - new(pMemory)T(src); + new(pMemory) T(src); } template -inline void Destruct(T* pMemory) +inline void Destruct(T *pMemory) { pMemory->~T(); @@ -491,140 +127,3 @@ inline void Destruct(T* pMemory) memset(pMemory, 0xDD, sizeof(T)); #endif } - - -// -// GET_OUTER() -// -// A platform-independent way for a contained class to get a pointer to its -// owner. If you know a class is exclusively used in the context of some -// "outer" class, this is a much more space efficient way to get at the outer -// class than having the inner class store a pointer to it. -// -// class COuter -// { -// class CInner // Note: this does not need to be a nested class to work -// { -// void PrintAddressOfOuter() -// { -// printf( "Outer is at 0x%x\n", GET_OUTER( COuter, m_Inner ) ); -// } -// }; -// -// CInner m_Inner; -// friend class CInner; -// }; - -#define GET_OUTER( OuterType, OuterMember ) \ - ( ( OuterType * ) ( (char *)this - offsetof( OuterType, OuterMember ) ) ) - - -/* TEMPLATE_FUNCTION_TABLE() - -(Note added to platform.h so platforms that correctly support templated -functions can handle portions as templated functions rather than wrapped -functions) - -Helps automate the process of creating an array of function -templates that are all specialized by a single integer. -This sort of thing is often useful in optimization work. - -For example, using TEMPLATE_FUNCTION_TABLE, this: - -TEMPLATE_FUNCTION_TABLE(int, Function, ( int blah, int blah ), 10) -{ -return argument * argument; -} - -is equivilent to the following: - -(NOTE: the function has to be wrapped in a class due to code -generation bugs involved with directly specializing a function -based on a constant.) - -template -class FunctionWrapper -{ -public: -int Function( int blah, int blah ) -{ -return argument*argument; -} -} - -typedef int (*FunctionType)( int blah, int blah ); - -class FunctionName -{ -public: -enum { count = 10 }; -FunctionType functions[10]; -}; - -FunctionType FunctionName::functions[] = -{ -FunctionWrapper<0>::Function, -FunctionWrapper<1>::Function, -FunctionWrapper<2>::Function, -FunctionWrapper<3>::Function, -FunctionWrapper<4>::Function, -FunctionWrapper<5>::Function, -FunctionWrapper<6>::Function, -FunctionWrapper<7>::Function, -FunctionWrapper<8>::Function, -FunctionWrapper<9>::Function -}; -*/ - -bool vtune(bool resume); - - -#define TEMPLATE_FUNCTION_TABLE(RETURN_TYPE, NAME, ARGS, COUNT) \ - \ -typedef RETURN_TYPE (FASTCALL *__Type_##NAME) ARGS; \ - \ -template \ -struct __Function_##NAME \ -{ \ - static RETURN_TYPE FASTCALL Run ARGS; \ -}; \ - \ -template \ -struct __MetaLooper_##NAME : __MetaLooper_##NAME \ -{ \ - __Type_##NAME func; \ - inline __MetaLooper_##NAME() { func = __Function_##NAME::Run; } \ -}; \ - \ -template<> \ -struct __MetaLooper_##NAME<0> \ -{ \ - __Type_##NAME func; \ - inline __MetaLooper_##NAME() { func = __Function_##NAME<0>::Run; } \ -}; \ - \ -class NAME \ -{ \ -private: \ - static const __MetaLooper_##NAME m; \ -public: \ - enum { count = COUNT }; \ - static const __Type_##NAME* functions; \ -}; \ -const __MetaLooper_##NAME NAME::m; \ -const __Type_##NAME* NAME::functions = (__Type_##NAME*)&m; \ -template \ -RETURN_TYPE FASTCALL __Function_##NAME::Run ARGS - - -#define LOOP_INTERCHANGE(BOOLEAN, CODE)\ - if( (BOOLEAN) )\ - {\ - CODE;\ - } else\ - {\ - CODE;\ - } - - -#endif /* PLATFORM_H */ \ No newline at end of file diff --git a/regamedll/public/utlbuffer.cpp b/regamedll/public/utlbuffer.cpp index 7dabbd9d..1ab0159c 100644 --- a/regamedll/public/utlbuffer.cpp +++ b/regamedll/public/utlbuffer.cpp @@ -1,15 +1,30 @@ -//========= Copyright 1996-2001, Valve LLC, All rights reserved. ============ -// -// The copyright to the contents herein is the property of Valve, L.L.C. -// The contents may be used and/or copied only with the written permission of -// Valve, L.L.C., or in accordance with the terms and conditions stipulated in -// the agreement/contract under which the contents have been supplied. -// -// $Header: $ -// $NoKeywords: $ -// -// Serialization buffer -//============================================================================= +/* +* +* This program is free software; you can redistribute it and/or modify it +* under the terms of the GNU General Public License as published by the +* Free Software Foundation; either version 2 of the License, or (at +* your option) any later version. +* +* This program 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 +* General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software Foundation, +* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +* +* In addition, as a special exception, the author gives permission to +* link the code of this program with the Half-Life Game Engine ("HL +* Engine") and Modified Game Libraries ("MODs") developed by Valve, +* L.L.C ("Valve"). You must obey the GNU General Public License in all +* respects for all of the code used other than the HL Engine and MODs +* from Valve. If you modify this file, you may extend this exception +* to your version of the file, but you are not obligated to do so. If +* you do not wish to do so, delete this exception statement from your +* version. +* +*/ #include "precompiled.h" @@ -19,11 +34,10 @@ #include #include -//----------------------------------------------------------------------------- -// constructors -//----------------------------------------------------------------------------- +// Constructors CUtlBuffer::CUtlBuffer(int growSize, int initSize, bool text) : -m_Memory(growSize, initSize), m_Error(0) + m_Memory(growSize, initSize), + m_Error(0) { m_Get = 0; m_Put = 0; @@ -34,56 +48,51 @@ m_Memory(growSize, initSize), m_Error(0) } } -CUtlBuffer::CUtlBuffer(void const* pBuffer, int size, bool text) : -m_Memory((unsigned char*)pBuffer, size), m_Error(0) +CUtlBuffer::CUtlBuffer(void const *pBuffer, int size, bool text) : + m_Memory((unsigned char *)pBuffer, size), + m_Error(0) { m_Get = 0; m_Put = 0; m_Flags = 0; + if (text) + { m_Flags |= TEXT_BUFFER; + } } - -//----------------------------------------------------------------------------- // Attaches the buffer to external memory.... -//----------------------------------------------------------------------------- -void CUtlBuffer::SetExternalBuffer(void* pMemory, int numElements, bool text) +void CUtlBuffer::SetExternalBuffer(void *pMemory, int numElements, bool text) { - m_Memory.SetExternalBuffer((unsigned char*)pMemory, numElements); + m_Memory.SetExternalBuffer((unsigned char *)pMemory, numElements); // Reset all indices; we just changed memory m_Get = 0; m_Put = 0; m_Flags = 0; + if (text) + { m_Flags |= TEXT_BUFFER; + } } - -//----------------------------------------------------------------------------- // Makes sure we've got at least this much memory -//----------------------------------------------------------------------------- void CUtlBuffer::EnsureCapacity(int num) { m_Memory.EnsureCapacity(num); } - -//----------------------------------------------------------------------------- // Base get method from which all others derive -//----------------------------------------------------------------------------- -void CUtlBuffer::Get(void* pMem, int size) +void CUtlBuffer::Get(void *pMem, int size) { Assert(m_Get + size <= m_Memory.NumAllocated()); memcpy(pMem, &m_Memory[m_Get], size); m_Get += size; } - -//----------------------------------------------------------------------------- // Eats whitespace -//----------------------------------------------------------------------------- void CUtlBuffer::EatWhiteSpace() { if (IsText() && IsValid()) @@ -91,22 +100,20 @@ void CUtlBuffer::EatWhiteSpace() int lastpos = Size(); while (m_Get < lastpos) { - if (!isspace(*(char*)&m_Memory[m_Get])) + if (!isspace(*(char *)&m_Memory[m_Get])) break; + m_Get += sizeof(char); } } } - -//----------------------------------------------------------------------------- // Reads a null-terminated string -//----------------------------------------------------------------------------- -void CUtlBuffer::GetString(char* pString, int nMaxLen) +void CUtlBuffer::GetString(char *pString, int nMaxLen) { if (!IsValid()) { - *pString = 0; + *pString = '\0'; return; } @@ -117,7 +124,7 @@ void CUtlBuffer::GetString(char* pString, int nMaxLen) if (!IsText()) { - int len = strlen((char*)&m_Memory[m_Get]) + 1; + int len = strlen((char *)&m_Memory[m_Get]) + 1; if (len <= nMaxLen) { Get(pString, len); @@ -125,7 +132,7 @@ void CUtlBuffer::GetString(char* pString, int nMaxLen) else { Get(pString, nMaxLen); - pString[nMaxLen - 1] = 0; + pString[nMaxLen - 1] = '\0'; SeekGet(SEEK_CURRENT, len - nMaxLen); } } @@ -139,7 +146,7 @@ void CUtlBuffer::GetString(char* pString, int nMaxLen) int nLastPos = Size(); while (m_Get < nLastPos) { - char c = *(char*)&m_Memory[m_Get]; + char c = *(char *)&m_Memory[m_Get]; if (isspace(c) || (!c)) break; @@ -147,19 +154,17 @@ void CUtlBuffer::GetString(char* pString, int nMaxLen) { *pString++ = c; } - ++nCount; - ++m_Get; + + nCount++; + m_Get++; } // Terminate - *pString = 0; + *pString = '\0'; } } - -//----------------------------------------------------------------------------- // Checks if a get is ok -//----------------------------------------------------------------------------- bool CUtlBuffer::CheckGet(int size) { if (m_Error) @@ -172,10 +177,7 @@ bool CUtlBuffer::CheckGet(int size) return false; } - -//----------------------------------------------------------------------------- // Change where I'm reading -//----------------------------------------------------------------------------- void CUtlBuffer::SeekGet(SeekType_t type, int offset) { switch (type) @@ -194,14 +196,10 @@ void CUtlBuffer::SeekGet(SeekType_t type, int offset) } } - -//----------------------------------------------------------------------------- // Parse... -//----------------------------------------------------------------------------- +#pragma warning(disable:4706) -#pragma warning ( disable : 4706 ) - -int CUtlBuffer::VaScanf(char const* pFmt, va_list list) +int CUtlBuffer::VaScanf(char const *pFmt, va_list list) { Assert(pFmt); if (m_Error || !IsText()) @@ -210,7 +208,7 @@ int CUtlBuffer::VaScanf(char const* pFmt, va_list list) int numScanned = 0; char c; - char* pEnd; + char *pEnd; while (c = *pFmt++) { // Stop if we hit the end of the buffer @@ -238,17 +236,17 @@ int CUtlBuffer::VaScanf(char const* pFmt, va_list list) { case 'c': { - char* ch = va_arg(list, char *); + char *ch = va_arg(list, char *); *ch = (char)m_Memory[m_Get]; - ++m_Get; + m_Get++; } break; case 'i': case 'd': { - int* i = va_arg(list, int *); - *i = strtol((char*)PeekGet(), &pEnd, 10); + int *i = va_arg(list, int *); + *i = strtol((char *)PeekGet(), &pEnd, 10); if (pEnd == PeekGet()) return numScanned; m_Get = (int)pEnd - (int)Base(); @@ -257,8 +255,8 @@ int CUtlBuffer::VaScanf(char const* pFmt, va_list list) case 'x': { - int* i = va_arg(list, int *); - *i = strtol((char*)PeekGet(), &pEnd, 16); + int *i = va_arg(list, int *); + *i = strtol((char *)PeekGet(), &pEnd, 16); if (pEnd == PeekGet()) return numScanned; m_Get = (int)pEnd - (int)Base(); @@ -267,8 +265,8 @@ int CUtlBuffer::VaScanf(char const* pFmt, va_list list) case 'u': { - unsigned int* u = va_arg(list, unsigned int *); - *u = strtoul((char*)PeekGet(), &pEnd, 10); + unsigned int *u = va_arg(list, unsigned int *); + *u = strtoul((char *)PeekGet(), &pEnd, 10); if (pEnd == PeekGet()) return numScanned; m_Get = (int)pEnd - (int)Base(); @@ -277,8 +275,8 @@ int CUtlBuffer::VaScanf(char const* pFmt, va_list list) case 'f': { - float* f = va_arg(list, float *); - *f = (float)strtod((char*)PeekGet(), &pEnd); + float *f = va_arg(list, float *); + *f = (float)strtod((char *)PeekGet(), &pEnd); if (pEnd == PeekGet()) return numScanned; m_Get = (int)pEnd - (int)Base(); @@ -287,7 +285,7 @@ int CUtlBuffer::VaScanf(char const* pFmt, va_list list) case 's': { - char* s = va_arg(list, char *); + char *s = va_arg(list, char *); GetString(s); } break; @@ -301,7 +299,7 @@ int CUtlBuffer::VaScanf(char const* pFmt, va_list list) break; } - ++numScanned; + numScanned++; } break; @@ -311,16 +309,17 @@ int CUtlBuffer::VaScanf(char const* pFmt, va_list list) // against what's in the buffer or we're done. if (c != m_Memory[m_Get]) return numScanned; - ++m_Get; + m_Get++; } } } + return numScanned; } -#pragma warning ( default : 4706 ) +#pragma warning(default:4706) -int CUtlBuffer::Scanf(char const* pFmt, ...) +int CUtlBuffer::Scanf(char const *pFmt, ...) { va_list args; @@ -331,12 +330,8 @@ int CUtlBuffer::Scanf(char const* pFmt, ...) return count; } - -//----------------------------------------------------------------------------- // Serialization -//----------------------------------------------------------------------------- - -void CUtlBuffer::Put(void const* pMem, int size) +void CUtlBuffer::Put(void const *pMem, int size) { if (CheckPut(size)) { @@ -345,23 +340,19 @@ void CUtlBuffer::Put(void const* pMem, int size) } } - -//----------------------------------------------------------------------------- // Writes a null-terminated string -//----------------------------------------------------------------------------- - -void CUtlBuffer::PutString(char const* pString) +void CUtlBuffer::PutString(char const *pString) { int len = strlen(pString); // Not text? append a null at the end. if (!IsText()) - ++len; + len++; Put(pString, len); } -void CUtlBuffer::VaPrintf(char const* pFmt, va_list list) +void CUtlBuffer::VaPrintf(char const *pFmt, va_list list) { char temp[2048]; int len = vsprintf(temp, pFmt, list); @@ -369,12 +360,12 @@ void CUtlBuffer::VaPrintf(char const* pFmt, va_list list) // Not text? append a null at the end. if (!IsText()) - ++len; + len++; Put(temp, len); } -void CUtlBuffer::Printf(char const* pFmt, ...) +void CUtlBuffer::Printf(char const *pFmt, ...) { va_list args; @@ -383,11 +374,7 @@ void CUtlBuffer::Printf(char const* pFmt, ...) va_end(args); } - -//----------------------------------------------------------------------------- // Checks if a put is ok -//----------------------------------------------------------------------------- - bool CUtlBuffer::CheckPut(int size) { if (m_Error) @@ -403,6 +390,7 @@ bool CUtlBuffer::CheckPut(int size) m_Memory.Grow(); } + return true; } diff --git a/regamedll/public/utllinkedlist.h b/regamedll/public/utllinkedlist.h index ce49b60e..51e232c9 100644 --- a/regamedll/public/utllinkedlist.h +++ b/regamedll/public/utllinkedlist.h @@ -1,42 +1,47 @@ -//======== (C) Copyright 1999, 2000 Valve, L.L.C. All rights reserved. ======== -// -// The copyright to the contents herein is the property of Valve, L.L.C. -// The contents may be used and/or copied only with the written permission of -// Valve, L.L.C., or in accordance with the terms and conditions stipulated in -// the agreement/contract under which the contents have been supplied. -// -// Purpose: Linked list container class -// -// $Revision: $ -// $NoKeywords: $ -//============================================================================= +/* +* +* This program is free software; you can redistribute it and/or modify it +* under the terms of the GNU General Public License as published by the +* Free Software Foundation; either version 2 of the License, or (at +* your option) any later version. +* +* This program 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 +* General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software Foundation, +* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +* +* In addition, as a special exception, the author gives permission to +* link the code of this program with the Half-Life Game Engine ("HL +* Engine") and Modified Game Libraries ("MODs") developed by Valve, +* L.L.C ("Valve"). You must obey the GNU General Public License in all +* respects for all of the code used other than the HL Engine and MODs +* from Valve. If you modify this file, you may extend this exception +* to your version of the file, but you are not obligated to do so. If +* you do not wish to do so, delete this exception statement from your +* version. +* +*/ -#ifndef UTLLINKEDLIST_H -#define UTLLINKEDLIST_H - -#ifdef _WIN32 #pragma once -#endif #include "osconfig.h" #include "basetypes.h" #include "utlmemory.h" -//#include "tier0/dbg.h" - // This is a useful macro to iterate from head to tail in a linked list. -#define FOR_EACH_LL( listName, iteratorName ) \ - for( int iteratorName=listName.Head(); iteratorName != listName.InvalidIndex(); iteratorName = listName.Next( iteratorName ) ) +#define FOR_EACH_LL(listName, iteratorName)\ + for (int iteratorName = listName.Head(); iteratorName != listName.InvalidIndex(); iteratorName = listName.Next(iteratorName)) #define INVALID_LLIST_IDX ((I)~0) -//----------------------------------------------------------------------------- // class CUtlLinkedList: // description: // A lovely index-based linked list! T is the class type, I is the index // type, which usually should be an unsigned short or smaller. -//----------------------------------------------------------------------------- - template class CUtlLinkedList { @@ -50,10 +55,10 @@ public: ~CUtlLinkedList(); // gets particular elements - T& Element(I i); - T const& Element(I i) const; - T& operator[](I i); - T const& operator[](I i) const; + T& Element(I i); + T const& Element(I i) const; + T& operator[](I i); + T const& operator[](I i) const; // Make sure we have a particular amount of memory void EnsureCapacity(int num); @@ -65,64 +70,64 @@ public: void PurgeAndDeleteElements(); // Insertion methods.... - I InsertBefore(I before); - I InsertAfter(I after); - I AddToHead(); - I AddToTail(); + I InsertBefore(I before); + I InsertAfter(I after); + I AddToHead(); + I AddToTail(); - I InsertBefore(I before, T const& src); - I InsertAfter(I after, T const& src); - I AddToHead(T const& src); - I AddToTail(T const& src); + I InsertBefore(I before, T const& src); + I InsertAfter(I after, T const& src); + I AddToHead(T const& src); + I AddToTail(T const& src); // Find an element and return its index or InvalidIndex() if it couldn't be found. - I Find(const T &src) const; + I Find(const T &src) const; // Look for the element. If it exists, remove it and return true. Otherwise, return false. - bool FindAndRemove(const T &src); + bool FindAndRemove(const T &src); // Removal methods - void Remove(I elem); - void RemoveAll(); + void Remove(I elem); + void RemoveAll(); // Allocation/deallocation methods // If multilist == true, then list list may contain many // non-connected lists, and IsInList and Head + Tail are meaningless... - I Alloc(bool multilist = false); - void Free(I elem); + I Alloc(bool multilist = false); + void Free(I elem); // list modification - void LinkBefore(I before, I elem); - void LinkAfter(I after, I elem); - void Unlink(I elem); - void LinkToHead(I elem); - void LinkToTail(I elem); + void LinkBefore(I before, I elem); + void LinkAfter(I after, I elem); + void Unlink(I elem); + void LinkToHead(I elem); + void LinkToTail(I elem); // invalid index - inline static I InvalidIndex() { return INVALID_LLIST_IDX; } + inline static I InvalidIndex() { return INVALID_LLIST_IDX; } inline static size_t ElementSize() { return sizeof(ListElem_t); } // list statistics - int Count() const; - I MaxElementIndex() const; + int Count() const; + I MaxElementIndex() const; // Traversing the list - I Head() const; - I Tail() const; - I Previous(I i) const; - I Next(I i) const; + I Head() const; + I Tail() const; + I Previous(I i) const; + I Next(I i) const; // Are nodes in the list or valid? - bool IsValidIndex(I i) const; - bool IsInList(I i) const; + bool IsValidIndex(I i) const; + bool IsInList(I i) const; protected: // What the linked list element looks like struct ListElem_t { - T m_Element; - I m_Previous; - I m_Next; + T m_Element; + I m_Previous; + I m_Next; private: // No copy constructor for these... @@ -130,7 +135,7 @@ protected: }; // constructs the class - I AllocInternal(bool multilist = false); + I AllocInternal(bool multilist = false); void ConstructList(); // Gets at the list element.... @@ -146,22 +151,18 @@ protected: CUtlLinkedList(CUtlLinkedList const& list) { Assert(0); } CUtlMemory m_Memory; - I m_Head; - I m_Tail; - I m_FirstFree; - I m_ElementCount; // The number actually in the list - I m_TotalElements; // The number allocated + I m_Head; + I m_Tail; + I m_FirstFree; + I m_ElementCount; // The number actually in the list + I m_TotalElements; // The number allocated - // For debugging purposes; + // For debugging purposes; // it's in release builds so this can be used in libraries correctly - ListElem_t *m_pElements; + ListElem_t *m_pElements; }; - -//----------------------------------------------------------------------------- -// constructor, destructor -//----------------------------------------------------------------------------- - +// Constructor, Destructor template CUtlLinkedList::CUtlLinkedList(int growSize, int initSize) : m_Memory(growSize, initSize) @@ -171,7 +172,7 @@ m_Memory(growSize, initSize) } template -CUtlLinkedList::CUtlLinkedList(void* pMemory, int memsize) : +CUtlLinkedList::CUtlLinkedList(void *pMemory, int memsize) : m_Memory((ListElem_t *)pMemory, memsize / sizeof(ListElem_t)) { ConstructList(); @@ -193,11 +194,7 @@ void CUtlLinkedList::ConstructList() m_ElementCount = m_TotalElements = 0; } - -//----------------------------------------------------------------------------- -// gets particular elements -//----------------------------------------------------------------------------- - +// Gets particular elements template inline T& CUtlLinkedList::Element(I i) { @@ -222,10 +219,7 @@ inline T const& CUtlLinkedList::operator[](I i) const return m_Memory[i].m_Element; } -//----------------------------------------------------------------------------- -// list statistics -//----------------------------------------------------------------------------- - +// List statistics template inline int CUtlLinkedList::Count() const { @@ -238,42 +232,34 @@ inline I CUtlLinkedList::MaxElementIndex() const return m_Memory.NumAllocated(); } - -//----------------------------------------------------------------------------- // Traversing the list -//----------------------------------------------------------------------------- - template -inline I CUtlLinkedList::Head() const +inline I CUtlLinkedList::Head() const { return m_Head; } template -inline I CUtlLinkedList::Tail() const +inline I CUtlLinkedList::Tail() const { return m_Tail; } template -inline I CUtlLinkedList::Previous(I i) const +inline I CUtlLinkedList::Previous(I i) const { Assert(IsValidIndex(i)); return InternalElement(i).m_Previous; } template -inline I CUtlLinkedList::Next(I i) const +inline I CUtlLinkedList::Next(I i) const { Assert(IsValidIndex(i)); return InternalElement(i).m_Next; } - -//----------------------------------------------------------------------------- // Are nodes in the list or valid? -//----------------------------------------------------------------------------- - template inline bool CUtlLinkedList::IsValidIndex(I i) const { @@ -287,10 +273,7 @@ inline bool CUtlLinkedList::IsInList(I i) const return (i < m_TotalElements) && (i >= 0) && (Previous(i) != i); } -//----------------------------------------------------------------------------- // Makes sure we have enough memory allocated to store a requested # of elements -//----------------------------------------------------------------------------- - template< class T, class I > void CUtlLinkedList::EnsureCapacity(int num) { @@ -298,13 +281,9 @@ void CUtlLinkedList::EnsureCapacity(int num) ResetDbgInfo(); } - -//----------------------------------------------------------------------------- // Deallocate memory -//----------------------------------------------------------------------------- - template -void CUtlLinkedList::Purge() +void CUtlLinkedList::Purge() { RemoveAll(); m_Memory.Purge(); @@ -314,7 +293,6 @@ void CUtlLinkedList::Purge() } - template void CUtlLinkedList::PurgeAndDeleteElements() { @@ -328,10 +306,7 @@ void CUtlLinkedList::PurgeAndDeleteElements() Purge(); } - -//----------------------------------------------------------------------------- // Node allocation/deallocation -//----------------------------------------------------------------------------- template I CUtlLinkedList::AllocInternal(bool multilist) { @@ -347,7 +322,7 @@ I CUtlLinkedList::AllocInternal(bool multilist) Assert(m_TotalElements != InvalidIndex()); elem = (I)m_TotalElements; - ++m_TotalElements; + m_TotalElements++; if (elem == InvalidIndex()) { @@ -366,7 +341,6 @@ I CUtlLinkedList::AllocInternal(bool multilist) InternalElement(elem).m_Next = InternalElement(elem).m_Previous = InvalidIndex(); ResetDbgInfo(); - return elem; } @@ -380,7 +354,7 @@ I CUtlLinkedList::Alloc(bool multilist) } template -void CUtlLinkedList::Free(I elem) +void CUtlLinkedList::Free(I elem) { Assert(IsValidIndex(elem)); Unlink(elem); @@ -391,15 +365,12 @@ void CUtlLinkedList::Free(I elem) m_FirstFree = elem; } -//----------------------------------------------------------------------------- // Insertion methods; allocates and links (uses default constructor) -//----------------------------------------------------------------------------- - template I CUtlLinkedList::InsertBefore(I before) { // Make a new node - I newNode = AllocInternal(); + I newNode = AllocInternal(); // Link it in LinkBefore(before, newNode); @@ -414,7 +385,7 @@ template I CUtlLinkedList::InsertAfter(I after) { // Make a new node - I newNode = AllocInternal(); + I newNode = AllocInternal(); // Link it in LinkAfter(after, newNode); @@ -437,16 +408,12 @@ inline I CUtlLinkedList::AddToTail() return InsertBefore(InvalidIndex()); } - -//----------------------------------------------------------------------------- // Insertion methods; allocates and links (uses copy constructor) -//----------------------------------------------------------------------------- - template I CUtlLinkedList::InsertBefore(I before, T const& src) { // Make a new node - I newNode = AllocInternal(); + I newNode = AllocInternal(); // Link it in LinkBefore(before, newNode); @@ -461,7 +428,7 @@ template I CUtlLinkedList::InsertAfter(I after, T const& src) { // Make a new node - I newNode = AllocInternal(); + I newNode = AllocInternal(); // Link it in LinkAfter(after, newNode); @@ -484,11 +451,7 @@ inline I CUtlLinkedList::AddToTail(T const& src) return InsertBefore(InvalidIndex(), src); } - -//----------------------------------------------------------------------------- // Removal methods -//----------------------------------------------------------------------------- - template I CUtlLinkedList::Find(const T &src) const { @@ -497,10 +460,10 @@ I CUtlLinkedList::Find(const T &src) const if (Element(i) == src) return i; } + return InvalidIndex(); } - template bool CUtlLinkedList::FindAndRemove(const T &src) { @@ -516,15 +479,14 @@ bool CUtlLinkedList::FindAndRemove(const T &src) } } - template -void CUtlLinkedList::Remove(I elem) +void CUtlLinkedList::Remove(I elem) { Free(elem); } template -void CUtlLinkedList::RemoveAll() +void CUtlLinkedList::RemoveAll() { if (m_TotalElements == 0) return; @@ -554,13 +516,9 @@ void CUtlLinkedList::RemoveAll() m_ElementCount = 0; } - -//----------------------------------------------------------------------------- // list modification -//----------------------------------------------------------------------------- - template -void CUtlLinkedList::LinkBefore(I before, I elem) +void CUtlLinkedList::LinkBefore(I before, I elem) { Assert(IsValidIndex(elem)); @@ -595,11 +553,11 @@ void CUtlLinkedList::LinkBefore(I before, I elem) InternalElement(newElem.m_Previous).m_Next = elem; // one more element baby - ++m_ElementCount; + m_ElementCount++; } template -void CUtlLinkedList::LinkAfter(I after, I elem) +void CUtlLinkedList::LinkAfter(I after, I elem) { Assert(IsValidIndex(elem)); @@ -634,11 +592,11 @@ void CUtlLinkedList::LinkAfter(I after, I elem) InternalElement(newElem.m_Next).m_Previous = elem; // one more element baby - ++m_ElementCount; + m_ElementCount++; } template -void CUtlLinkedList::Unlink(I elem) +void CUtlLinkedList::Unlink(I elem) { Assert(IsValidIndex(elem)); if (IsInList(elem)) @@ -668,12 +626,12 @@ void CUtlLinkedList::Unlink(I elem) m_Tail = pOldElem->m_Previous; } - // This marks this node as not in the list, + // This marks this node as not in the list, // but not in the free list either pOldElem->m_Previous = pOldElem->m_Next = elem; // One less puppy - --m_ElementCount; + m_ElementCount--; } } @@ -688,6 +646,3 @@ inline void CUtlLinkedList::LinkToTail(I elem) { LinkBefore(InvalidIndex(), elem); } - - -#endif // UTLLINKEDLIST_H diff --git a/regamedll/public/utlmap.h b/regamedll/public/utlmap.h index 4433f263..f414604a 100644 --- a/regamedll/public/utlmap.h +++ b/regamedll/public/utlmap.h @@ -38,7 +38,7 @@ // faster iteration, but in an unspecified order #define FOR_EACH_MAP_FAST(mapName, iteratorName)\ - for (int iteratorName = 0; (mapName).IsUtlMap && iteratorName < (mapName).MaxElement(); ++iteratorName) if (!(mapName).IsValidIndex(iteratorName)) continue; else + for (int iteratorName = 0; (mapName).IsUtlMap && iteratorName < (mapName).MaxElement(); iteratorName++) if (!(mapName).IsValidIndex(iteratorName)) continue; else struct base_utlmap_t { @@ -89,28 +89,27 @@ public: void EnsureCapacity(int num) { m_Tree.EnsureCapacity(num); } // gets particular elements - ElemType_t & Element(IndexType_t i) { return m_Tree.Element(i).elem; } - const ElemType_t & Element(IndexType_t i) const { return m_Tree.Element(i).elem; } - ElemType_t & operator[](IndexType_t i) { return m_Tree.Element(i).elem; } - const ElemType_t & operator[](IndexType_t i) const { return m_Tree.Element(i).elem; } - KeyType_t & Key(IndexType_t i) { return m_Tree.Element(i).key; } - const KeyType_t & Key(IndexType_t i) const { return m_Tree.Element(i).key; } - + ElemType_t& Element(IndexType_t i) { return m_Tree.Element(i).elem; } + const ElemType_t& Element(IndexType_t i) const { return m_Tree.Element(i).elem; } + ElemType_t& operator[](IndexType_t i) { return m_Tree.Element(i).elem; } + const ElemType_t& operator[](IndexType_t i) const { return m_Tree.Element(i).elem; } + KeyType_t& Key(IndexType_t i) { return m_Tree.Element(i).key; } + const KeyType_t& Key(IndexType_t i) const { return m_Tree.Element(i).key; } // Num elements - unsigned int Count() const { return m_Tree.Count(); } + unsigned int Count() const { return m_Tree.Count(); } // Max "size" of the vector - IndexType_t MaxElement() const { return m_Tree.MaxElement(); } + IndexType_t MaxElement() const { return m_Tree.MaxElement(); } // Checks if a node is valid and in the map - bool IsValidIndex(IndexType_t i) const { return m_Tree.IsValidIndex(i); } + bool IsValidIndex(IndexType_t i) const { return m_Tree.IsValidIndex(i); } // Checks if the map as a whole is valid - bool IsValid() const { return m_Tree.IsValid(); } + bool IsValid() const { return m_Tree.IsValid(); } // Invalid index - static IndexType_t InvalidIndex() { return CTree::InvalidIndex(); } + static IndexType_t InvalidIndex() { return CTree::InvalidIndex(); } // Sets the less func void SetLessFunc(LessFunc_t func) @@ -143,7 +142,7 @@ public: } // Remove methods - void RemoveAt(IndexType_t i) { m_Tree.RemoveAt(i); } + void RemoveAt(IndexType_t i) { m_Tree.RemoveAt(i); } bool Remove(const KeyType_t &key) { Node_t dummyNode; @@ -151,17 +150,17 @@ public: return m_Tree.Remove(dummyNode); } - void RemoveAll() { m_Tree.RemoveAll(); } - void Purge() { m_Tree.Purge(); } + void RemoveAll() { m_Tree.RemoveAll(); } + void Purge() { m_Tree.Purge(); } // Purges the list and calls delete on each element in it. void PurgeAndDeleteElements(); // Iteration - IndexType_t FirstInorder() const { return m_Tree.FirstInorder(); } - IndexType_t NextInorder(IndexType_t i) const { return m_Tree.NextInorder(i); } - IndexType_t PrevInorder(IndexType_t i) const { return m_Tree.PrevInorder(i); } - IndexType_t LastInorder() const { return m_Tree.LastInorder(); } + IndexType_t FirstInorder() const { return m_Tree.FirstInorder(); } + IndexType_t NextInorder(IndexType_t i) const { return m_Tree.NextInorder(i); } + IndexType_t PrevInorder(IndexType_t i) const { return m_Tree.PrevInorder(i); } + IndexType_t LastInorder() const { return m_Tree.LastInorder(); } // If you change the search key, this can be used to reinsert the // element into the map. @@ -234,7 +233,7 @@ protected: template inline void CUtlMap::PurgeAndDeleteElements() { - for (I i = 0; i < MaxElement(); ++i) + for (I i = 0; i < MaxElement(); i++) { if (!IsValidIndex(i)) continue; diff --git a/regamedll/public/utlmemory.h b/regamedll/public/utlmemory.h index 5f76e302..4f2fc0fb 100644 --- a/regamedll/public/utlmemory.h +++ b/regamedll/public/utlmemory.h @@ -59,18 +59,18 @@ public: bool operator!=(const Iterator_t it) const { return m_index != it.m_index; } }; - Iterator_t First() const { return Iterator_t(IsIdxValid(0) ? 0 : InvalidIndex()); } - Iterator_t Next(const Iterator_t &it) const { return Iterator_t(IsIdxValid(it.index + 1) ? it.index + 1 : InvalidIndex()); } - I GetIndex(const Iterator_t &it) const { return it.index; } - bool IsIdxAfter(I i, const Iterator_t &it) const { return i > it.index; } - bool IsValidIterator(const Iterator_t &it) const { return IsIdxValid(it.index); } - Iterator_t InvalidIterator() const { return Iterator_t(InvalidIndex()); } + Iterator_t First() const { return Iterator_t(IsIdxValid(0) ? 0 : InvalidIndex()); } + Iterator_t Next(const Iterator_t &it) const { return Iterator_t(IsIdxValid(it.index + 1) ? it.index + 1 : InvalidIndex()); } + I GetIndex(const Iterator_t &it) const { return it.index; } + bool IsIdxAfter(I i, const Iterator_t &it) const { return i > it.index; } + bool IsValidIterator(const Iterator_t &it) const { return IsIdxValid(it.index); } + Iterator_t InvalidIterator() const { return Iterator_t(InvalidIndex()); } // element access - T& Element(I i); - T const& Element(I i) const; - T& operator[](I i); - T const& operator[](I i) const; + T& Element(I i); + T const& Element(I i) const; + T& operator[](I i); + T const& operator[](I i) const; // Can we use this index? bool IsIdxValid(I i) const; @@ -116,7 +116,7 @@ private: int m_nGrowSize; }; -// constructor, destructor +// Constructor, Destructor template CUtlMemory::CUtlMemory(int nGrowSize, int nInitSize) : m_pMemory(0), m_nAllocationCount(nInitSize), m_nGrowSize(nGrowSize) @@ -170,7 +170,7 @@ void CUtlMemory::SetExternalBuffer(T *pMemory, int numElements) m_nGrowSize = EXTERNAL_BUFFER_MARKER; } -// element access +// Element access template inline T& CUtlMemory::operator[](I i) { @@ -199,7 +199,7 @@ inline T const& CUtlMemory::Element(I i) const return m_pMemory[i]; } -// is the memory externally allocated? +// Is the memory externally allocated? template bool CUtlMemory::IsExternallyAllocated() const { @@ -329,6 +329,7 @@ void CUtlMemory::Purge() free((void *)m_pMemory); m_pMemory = 0; } + m_nAllocationCount = 0; } } diff --git a/regamedll/public/utlrbtree.h b/regamedll/public/utlrbtree.h index 4982cee0..ea2b9e9a 100644 --- a/regamedll/public/utlrbtree.h +++ b/regamedll/public/utlrbtree.h @@ -41,12 +41,12 @@ public: #define DefLessFunc(type) CDefOps::LessFunc -inline bool StringLessThan(const char * const &lhs, const char * const &rhs) { return (strcmp(lhs, rhs) < 0); } -inline bool CaselessStringLessThan(const char * const &lhs, const char * const &rhs) { return (_stricmp(lhs, rhs) < 0); } +inline bool StringLessThan(const char * const &lhs, const char * const &rhs) { return (strcmp(lhs, rhs) < 0); } +inline bool CaselessStringLessThan(const char * const &lhs, const char * const &rhs) { return (_stricmp(lhs, rhs) < 0); } // inline these two templates to stop multiple definitions of the same code -template <> inline bool CDefOps::LessFunc(const char * const &lhs, const char * const &rhs) { return StringLessThan(lhs, rhs); } -template <> inline bool CDefOps::LessFunc(char * const &lhs, char * const &rhs) { return StringLessThan(lhs, rhs); } +template <> inline bool CDefOps::LessFunc(const char * const &lhs, const char * const &rhs) { return StringLessThan(lhs, rhs); } +template <> inline bool CDefOps::LessFunc(char * const &lhs, char * const &rhs) { return StringLessThan(lhs, rhs); } template void SetDefLessFunc(RBTREE_T &RBTree) @@ -91,10 +91,10 @@ public: ~CUtlRBTree(); // gets particular elements - T& Element(I i); - T const& Element(I i) const; - T& operator[](I i); - T const& operator[](I i) const; + T& Element(I i); + T const& Element(I i) const; + T& operator[](I i); + T const& operator[](I i) const; // Gets the root I Root() const; @@ -191,8 +191,8 @@ protected: void LinkToParent(I i, I parent, bool isLeft); // Gets at the links - Links_t const& Links(I i) const; - Links_t& Links(I i); + Links_t const& Links(I i) const; + Links_t& Links(I i); // Checks if a link is red or black bool IsRed(I i) const; @@ -231,7 +231,7 @@ protected: I m_TotalElements; }; -// constructor, destructor +// Constructor, Destructor template CUtlRBTree::CUtlRBTree(int growSize, int initSize, LessFunc_t lessfunc) : m_Elements(growSize, initSize), @@ -247,7 +247,7 @@ CUtlRBTree::~CUtlRBTree() { } -// gets particular elements +// Gets particular elements template inline T &CUtlRBTree::Element(I i) { @@ -595,7 +595,7 @@ I CUtlRBTree::InsertAt(I parent, bool leftchild) { I i = NewNode(); LinkToParent(i, parent, leftchild); - ++m_NumElements; + m_NumElements++; return i; } @@ -808,7 +808,7 @@ void CUtlRBTree::RemoveAt(I elem) Unlink(elem); FreeNode(elem); - --m_NumElements; + m_NumElements--; } } @@ -848,7 +848,7 @@ void CUtlRBTree::RemoveAll() m_NumElements = 0; } -// iteration +// Iteration template I CUtlRBTree::FirstInorder() const { @@ -942,7 +942,7 @@ I CUtlRBTree::NextPreorder(I i) const template I CUtlRBTree::PrevPreorder(I i) const { - Assert(0); // not implemented yet + Assert(0); // Not implemented yet return InvalidIndex(); } @@ -1008,7 +1008,7 @@ void CUtlRBTree::Reinsert(I elem) Link(elem); } -// returns the tree depth (not a very fast operation) +// Returns the tree depth (not a very fast operation) template int CUtlRBTree::Depth(I node) const { @@ -1038,7 +1038,7 @@ bool CUtlRBTree::IsValid() const int curr = m_FirstFree; while (curr != InvalidIndex()) { - ++numFree; + numFree++; curr = RightChild(curr); if ((curr > MaxElement()) && (curr != InvalidIndex())) goto InvalidTree; @@ -1046,13 +1046,13 @@ bool CUtlRBTree::IsValid() const if (MaxElement() - numFree != Count()) goto InvalidTree; - // iterate over all elements, looking for validity + // Iterate over all elements, looking for validity // based on the self pointers int numFree2 = 0; - for (curr = 0; curr < MaxElement(); ++curr) + for (curr = 0; curr < MaxElement(); curr++) { if (!IsValidIndex(curr)) - ++numFree2; + numFree2++; else { int right = RightChild(curr); @@ -1100,7 +1100,7 @@ void CUtlRBTree::SetLessFunc(typename CUtlRBTree::LessFu m_LessFunc = func; else { - // need to re-sort the tree here.... + // Need to re-sort the tree here.... Assert(0); } } @@ -1111,7 +1111,7 @@ void CUtlRBTree::FindInsertionPosition(T const &insert, I &parent, b { Assert(m_LessFunc); - // find where node belongs + // Find where node belongs I current = m_Root; parent = InvalidIndex(); leftchild = false; @@ -1134,7 +1134,7 @@ void CUtlRBTree::FindInsertionPosition(T const &insert, I &parent, b template I CUtlRBTree::Insert(T const &insert) { - // use copy constructor to copy it in + // Use copy constructor to copy it in I parent; bool leftchild; FindInsertionPosition(insert, parent, leftchild); @@ -1152,7 +1152,7 @@ void CUtlRBTree::Insert(const T *pArray, int nItems) } } -// finds a node in the tree +// Finds a node in the tree template I CUtlRBTree::Find(T const &search) const { diff --git a/regamedll/public/utlsymbol.cpp b/regamedll/public/utlsymbol.cpp index 4a9b35f6..8e1f35d3 100644 --- a/regamedll/public/utlsymbol.cpp +++ b/regamedll/public/utlsymbol.cpp @@ -1,19 +1,39 @@ +/* +* +* This program is free software; you can redistribute it and/or modify it +* under the terms of the GNU General Public License as published by the +* Free Software Foundation; either version 2 of the License, or (at +* your option) any later version. +* +* This program 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 +* General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software Foundation, +* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +* +* In addition, as a special exception, the author gives permission to +* link the code of this program with the Half-Life Game Engine ("HL +* Engine") and Modified Game Libraries ("MODs") developed by Valve, +* L.L.C ("Valve"). You must obey the GNU General Public License in all +* respects for all of the code used other than the HL Engine and MODs +* from Valve. If you modify this file, you may extend this exception +* to your version of the file, but you are not obligated to do so. If +* you do not wish to do so, delete this exception statement from your +* version. +* +*/ + #include "precompiled.h" -/* -* Globals initialization -*/ -#ifndef HOOK_GAMEDLL - LessCtx_t g_LessCtx; - -#endif - -CUtlSymbolTable *CUtlSymbol::s_pSymbolTable = 0; +CUtlSymbolTable *CUtlSymbol::s_pSymbolTable = nullptr; void CUtlSymbol::Initialize() { - // necessary to allow us to create global symbols + // Necessary to allow us to create global symbols static bool symbolsInitialized = false; if (!symbolsInitialized) { @@ -84,7 +104,6 @@ CUtlSymbol CUtlSymbolTable::Find(const char *pString) const } // Finds and/or creates a symbol based on the string - CUtlSymbol CUtlSymbolTable::AddString(const char *pString) { if (!pString) @@ -104,7 +123,7 @@ CUtlSymbol CUtlSymbolTable::AddString(const char *pString) const char *CUtlSymbolTable::String(CUtlSymbol id) const { - if (!id.IsValid()) + if (!id.IsValid()) return ""; assert(m_Lookup.IsValidIndex((UtlSymId_t)id)); diff --git a/regamedll/public/utlsymbol.h b/regamedll/public/utlsymbol.h index 5a85abeb..44a72410 100644 --- a/regamedll/public/utlsymbol.h +++ b/regamedll/public/utlsymbol.h @@ -26,17 +26,13 @@ * */ -#ifndef UTL_SYMBOL_H -#define UTL_SYMBOL_H -#ifdef _WIN32 #pragma once -#endif class CUtlSymbolTable; typedef unsigned short UtlSymId_t; -#define UTL_INVAL_SYMBOL ((UtlSymId_t)~0) +#define UTL_INVAL_SYMBOL ((UtlSymId_t)~0) struct LessCtx_t { @@ -49,7 +45,7 @@ struct LessCtx_t class CUtlSymbol { public: - // constructor, destructor + // Constructor, Destructor CUtlSymbol() : m_Id(UTL_INVAL_SYMBOL) {} CUtlSymbol(UtlSymId_t id) : m_Id(id) {} CUtlSymbol(const char* pStr); @@ -59,7 +55,7 @@ public: CUtlSymbol &operator=(CUtlSymbol const &src) { m_Id = src.m_Id; - return *this; + return (*this); } // operator== @@ -69,12 +65,12 @@ public: // Is valid? bool IsValid() const { return m_Id != UTL_INVAL_SYMBOL; } - operator UtlSymId_t/* const*/() const { return m_Id; } // Gets at the symbol - const char *String() const; // Gets the string associated with the symbol + operator UtlSymId_t/* const*/() const { return m_Id; } // Gets at the symbol + const char *String() const; // Gets the string associated with the symbol protected: - static void Initialize(); // Initializes the symbol table - static CUtlSymbolTable *CurrTable(); // returns the current symbol table + static void Initialize(); // Initializes the symbol table + static CUtlSymbolTable *CurrTable(); // returns the current symbol table UtlSymId_t m_Id; static CUtlSymbolTable *s_pSymbolTable; @@ -83,23 +79,21 @@ protected: class CUtlSymbolTable { public: - // constructor, destructor + // Constructor, Destructor CUtlSymbolTable(int growSize = 0,int initSize = 32,bool caseInsensitive = false); ~CUtlSymbolTable(); - CUtlSymbol AddString(const char *pString); // Finds and/or creates a symbol based on the string - CUtlSymbol Find(const char *pString) const; // Finds the symbol for pString + CUtlSymbol AddString(const char *pString); // Finds and/or creates a symbol based on the string + CUtlSymbol Find(const char *pString) const; // Finds the symbol for pString - const char *String(CUtlSymbol id) const; // Look up the string associated with a particular symbol - void RemoveAll(); // Remove all symbols in the table + const char *String(CUtlSymbol id) const; // Look up the string associated with a particular symbol + void RemoveAll(); // Remove all symbols in the table public: static bool SymLess(const unsigned int &i1, const unsigned int &i2); static bool SymLessi(const unsigned int &i1, const unsigned int &i2); protected: - CUtlRBTree m_Lookup; + CUtlRBTree m_Lookup; CUtlVector m_Strings; }; - -#endif // UTL_SYMBOL_H diff --git a/regamedll/public/utlvector.h b/regamedll/public/utlvector.h index 5b8e0aec..a409f7f6 100644 --- a/regamedll/public/utlvector.h +++ b/regamedll/public/utlvector.h @@ -1,8 +1,32 @@ -#ifndef UTLVECTOR_H -#define UTLVECTOR_H -#ifdef _WIN32 +/* +* +* This program is free software; you can redistribute it and/or modify it +* under the terms of the GNU General Public License as published by the +* Free Software Foundation; either version 2 of the License, or (at +* your option) any later version. +* +* This program 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 +* General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software Foundation, +* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +* +* In addition, as a special exception, the author gives permission to +* link the code of this program with the Half-Life Game Engine ("HL +* Engine") and Modified Game Libraries ("MODs") developed by Valve, +* L.L.C ("Valve"). You must obey the GNU General Public License in all +* respects for all of the code used other than the HL Engine and MODs +* from Valve. If you modify this file, you may extend this exception +* to your version of the file, but you are not obligated to do so. If +* you do not wish to do so, delete this exception statement from your +* version. +* +*/ + #pragma once -#endif #include "utlmemory.h" @@ -14,21 +38,28 @@ public: // constructor, destructor CUtlVector(int growSize = 0, int initSize = 0); - CUtlVector(T* pMemory, int numElements); + CUtlVector(T *pMemory, int numElements); ~CUtlVector(); + // features C++11 ranged based for + T *begin() { return &m_Memory[0]; } + T *end() { return &m_Memory[m_Size - 1]; } + + T const *begin() const { return &m_Memory[0]; } + T const *end() const { return &m_Memory[m_Size - 1]; } + // Copy the array. - CUtlVector& operator=(const CUtlVector &other); + CUtlVector &operator=(const CUtlVector &other); // element access - T& operator[](int i); - T const& operator[](int i) const; - T& Element(int i); - T const& Element(int i) const; + T &operator[](int i); + T const &operator[](int i) const; + T &Element(int i); + T const &Element(int i) const; // Gets the base address (can change when adding elements!) - T* Base(); - T const* Base() const; + T *Base(); + T const *Base() const; // Returns the number of elements in the vector // SIZE IS DEPRECATED! @@ -46,15 +77,15 @@ public: int InsertAfter(int elem); // Adds an element, uses copy constructor - int AddToHead(T const& src); - int AddToTail(T const& src); - int InsertBefore(int elem, T const& src); - int InsertAfter(int elem, T const& src); + int AddToHead(T const &src); + int AddToTail(T const &src); + int InsertBefore(int elem, T const &src); + int InsertAfter(int elem, T const &src); // Adds multiple elements, uses default constructor int AddMultipleToHead(int num); - int AddMultipleToTail(int num, const T *pToCopy=NULL); - int InsertMultipleBefore(int elem, int num, const T *pToCopy=NULL); // If pToCopy is set, then it's an array of length 'num' and + int AddMultipleToTail(int num, const T *pToCopy = nullptr); + int InsertMultipleBefore(int elem, int num, const T *pToCopy = nullptr); // If pToCopy is set, then it's an array of length 'num' and int InsertMultipleAfter(int elem, int num); // Calls RemoveAll() then AddMultipleToTail. @@ -68,9 +99,9 @@ public: int AddVectorToTail(CUtlVector const &src); // Finds an element (element needs operator== defined) - int Find(T const& src) const; + int Find(T const &src) const; - bool HasElement(T const& src); + bool HasElement(T const &src); // Makes sure we have enough memory allocated to store a requested # of elements void EnsureCapacity(int num); @@ -79,11 +110,11 @@ public: void EnsureCount(int num); // Element removal - void FastRemove(int elem); // doesn't preserve order - void Remove(int elem); // preserves order, shifts elements - void FindAndRemove(T const& src); // removes first occurrence of src, preserves order, shifts elements + void FastRemove(int elem); // doesn't preserve order + void Remove(int elem); // preserves order, shifts elements + void FindAndRemove(T const &src); // removes first occurrence of src, preserves order, shifts elements void RemoveMultiple(int elem, int num); // preserves order, shifts elements - void RemoveAll(); // doesn't deallocate memory + void RemoveAll(); // doesn't deallocate memory // Memory deallocation void Purge(); @@ -96,7 +127,7 @@ public: protected: // Can't copy this unless we explicitly do it! - CUtlVector(CUtlVector const& vec) { assert(0); } + CUtlVector(CUtlVector const &vec) { assert(0); } // Grows the vector void GrowVector(int num = 1); @@ -116,134 +147,112 @@ protected: T *m_pElements; }; -//----------------------------------------------------------------------------- // For easier access to the elements through the debugger -//----------------------------------------------------------------------------- - -template< class T > +template inline void CUtlVector::ResetDbgInfo() { m_pElements = m_Memory.Base(); } -//----------------------------------------------------------------------------- // constructor, destructor -//----------------------------------------------------------------------------- - -template< class T > -inline CUtlVector::CUtlVector(int growSize, int initSize) : +template +inline CUtlVector::CUtlVector(int growSize, int initSize) : m_Memory(growSize, initSize), m_Size(0) { ResetDbgInfo(); } -template< class T > -inline CUtlVector::CUtlVector(T* pMemory, int numElements) : +template +inline CUtlVector::CUtlVector(T *pMemory, int numElements) : m_Memory(pMemory, numElements), m_Size(0) { ResetDbgInfo(); } -template< class T > +template inline CUtlVector::~CUtlVector() { Purge(); } -template -inline CUtlVector& CUtlVector::operator=(const CUtlVector &other) +template +inline CUtlVector &CUtlVector::operator=(const CUtlVector &other) { CopyArray(other.Base(), other.Count()); return *this; } -//----------------------------------------------------------------------------- // element access -//----------------------------------------------------------------------------- - -template< class T > -inline T& CUtlVector::operator[](int i) +template +inline T &CUtlVector::operator[](int i) { assert(IsValidIndex(i)); return m_Memory[i]; } -template< class T > -inline T const& CUtlVector::operator[](int i) const +template +inline T const &CUtlVector::operator[](int i) const { assert(IsValidIndex(i)); return m_Memory[i]; } -template< class T > -inline T& CUtlVector::Element(int i) +template +inline T &CUtlVector::Element(int i) { assert(IsValidIndex(i)); return m_Memory[i]; } -template< class T > -inline T const& CUtlVector::Element(int i) const +template +inline T const &CUtlVector::Element(int i) const { assert(IsValidIndex(i)); return m_Memory[i]; } -//----------------------------------------------------------------------------- // Gets the base address (can change when adding elements!) -//----------------------------------------------------------------------------- - -template< class T > -inline T* CUtlVector::Base() +template +inline T *CUtlVector::Base() { return m_Memory.Base(); } -template< class T > -inline T const* CUtlVector::Base() const +template +inline T const *CUtlVector::Base() const { return m_Memory.Base(); } -//----------------------------------------------------------------------------- // Count -//----------------------------------------------------------------------------- - -template< class T > +template inline int CUtlVector::Size() const { return m_Size; } -template< class T > +template inline int CUtlVector::Count() const { return m_Size; } -//----------------------------------------------------------------------------- // Is element index valid? -//----------------------------------------------------------------------------- - -template< class T > +template inline bool CUtlVector::IsValidIndex(int i) const { return (i >= 0) && (i < m_Size); } -//----------------------------------------------------------------------------- // Returns in invalid index -//----------------------------------------------------------------------------- -template< class T > +template inline int CUtlVector::InvalidIndex(void) { return -1; } -//----------------------------------------------------------------------------- // Grows the vector -//----------------------------------------------------------------------------- -template< class T > +template void CUtlVector::GrowVector(int num) { if (m_Size + num - 1 >= m_Memory.NumAllocated()) @@ -255,30 +264,24 @@ void CUtlVector::GrowVector(int num) ResetDbgInfo(); } -//----------------------------------------------------------------------------- // Makes sure we have enough memory allocated to store a requested # of elements -//----------------------------------------------------------------------------- -template< class T > +template void CUtlVector::EnsureCapacity(int num) { m_Memory.EnsureCapacity(num); ResetDbgInfo(); } -//----------------------------------------------------------------------------- // Makes sure we have at least this many elements -//----------------------------------------------------------------------------- -template< class T > +template void CUtlVector::EnsureCount(int num) { if (Count() < num) AddMultipleToTail(num - Count()); } -//----------------------------------------------------------------------------- // Shifts elements -//----------------------------------------------------------------------------- -template< class T > +template void CUtlVector::ShiftElementsRight(int elem, int num) { assert(IsValidIndex(elem) || (m_Size == 0) || (num == 0)); @@ -287,14 +290,14 @@ void CUtlVector::ShiftElementsRight(int elem, int num) memmove(&Element(elem+num), &Element(elem), numToMove * sizeof(T)); } -template< class T > +template void CUtlVector::ShiftElementsLeft(int elem, int num) { assert(IsValidIndex(elem) || (m_Size == 0) || (num == 0)); int numToMove = m_Size - elem - num; if ((numToMove > 0) && (num > 0)) { - memmove(&Element(elem), &Element(elem+num), numToMove * sizeof(T)); + memmove(&Element(elem), &Element(elem + num), numToMove * sizeof(T)); #ifdef _DEBUG memset(&Element(m_Size-num), 0xDD, num * sizeof(T)); @@ -302,29 +305,26 @@ void CUtlVector::ShiftElementsLeft(int elem, int num) } } -//----------------------------------------------------------------------------- // Adds an element, uses default constructor -//----------------------------------------------------------------------------- - -template< class T > +template inline int CUtlVector::AddToHead() { return InsertBefore(0); } -template< class T > +template inline int CUtlVector::AddToTail() { return InsertBefore(m_Size); } -template< class T > +template inline int CUtlVector::InsertAfter(int elem) { return InsertBefore(elem + 1); } -template< class T > +template int CUtlVector::InsertBefore(int elem) { // Can insert at the end @@ -336,30 +336,27 @@ int CUtlVector::InsertBefore(int elem) return elem; } -//----------------------------------------------------------------------------- // Adds an element, uses copy constructor -//----------------------------------------------------------------------------- - -template< class T > -inline int CUtlVector::AddToHead(T const& src) +template +inline int CUtlVector::AddToHead(T const &src) { return InsertBefore(0, src); } template< class T > -inline int CUtlVector::AddToTail(T const& src) +inline int CUtlVector::AddToTail(T const &src) { return InsertBefore(m_Size, src); } template< class T > -inline int CUtlVector::InsertAfter(int elem, T const& src) +inline int CUtlVector::InsertAfter(int elem, T const &src) { return InsertBefore(elem + 1, src); } template< class T > -int CUtlVector::InsertBefore(int elem, T const& src) +int CUtlVector::InsertBefore(int elem, T const &src) { // Can insert at the end assert((elem == Count()) || IsValidIndex(elem)); @@ -370,52 +367,49 @@ int CUtlVector::InsertBefore(int elem, T const& src) return elem; } - -//----------------------------------------------------------------------------- // Adds multiple elements, uses default constructor -//----------------------------------------------------------------------------- - -template< class T > +template inline int CUtlVector::AddMultipleToHead(int num) { return InsertMultipleBefore(0, num); } -template< class T > +template inline int CUtlVector::AddMultipleToTail(int num, const T *pToCopy) { return InsertMultipleBefore(m_Size, num, pToCopy); } -template< class T > +template int CUtlVector::InsertMultipleAfter(int elem, int num) { return InsertMultipleBefore(elem + 1, num); } - -template< class T > +template void CUtlVector::SetCount(int count) { RemoveAll(); AddMultipleToTail(count); } -template< class T > +template inline void CUtlVector::SetSize(int size) { SetCount(size); } -template< class T > +template void CUtlVector::CopyArray(T const *pArray, int size) { SetSize(size); - for(int i=0; i < size; i++) + for(int i = 0; i < size; i++) + { (*this)[i] = pArray[i]; + } } -template< class T > +template int CUtlVector::AddVectorToTail(CUtlVector const &src) { int base = Count(); @@ -424,13 +418,15 @@ int CUtlVector::AddVectorToTail(CUtlVector const &src) AddMultipleToTail(src.Count()); // Copy the elements. - for (int i=0; i < src.Count(); i++) + for (int i = 0; i < src.Count(); i++) + { (*this)[base + i] = src[i]; + } return base; } -template< class T > +template inline int CUtlVector::InsertMultipleBefore(int elem, int num, const T *pToInsert) { if(num == 0) @@ -444,12 +440,14 @@ inline int CUtlVector::InsertMultipleBefore(int elem, int num, const T *pToIn // Invoke default constructors for (int i = 0; i < num; ++i) + { Construct(&Element(elem+i)); + } // Copy stuff in? if (pToInsert) { - for (int i=0; i < num; i++) + for (int i = 0; i < num; i++) { Element(elem+i) = pToInsert[i]; } @@ -458,31 +456,27 @@ inline int CUtlVector::InsertMultipleBefore(int elem, int num, const T *pToIn return elem; } -//----------------------------------------------------------------------------- // Finds an element (element needs operator== defined) -//----------------------------------------------------------------------------- -template< class T > -int CUtlVector::Find(T const& src) const +template +int CUtlVector::Find(T const &src) const { - for (int i = 0; i < Count(); ++i) + for (int i = 0; i < Count(); i++) { if (Element(i) == src) return i; } - return -1; + + return InvalidIndex(); } -template< class T > -bool CUtlVector::HasElement(T const& src) +template +bool CUtlVector::HasElement(T const &src) { return (Find(src) >= 0); } -//----------------------------------------------------------------------------- // Element removal -//----------------------------------------------------------------------------- - -template< class T > +template void CUtlVector::FastRemove(int elem) { assert(IsValidIndex(elem)); @@ -490,30 +484,30 @@ void CUtlVector::FastRemove(int elem) Destruct(&Element(elem)); if (m_Size > 0) { - Q_memcpy(&Element(elem), &Element(m_Size-1), sizeof(T)); - --m_Size; + Q_memcpy(&Element(elem), &Element(m_Size - 1), sizeof(T)); + m_Size--; } } -template< class T > +template void CUtlVector::Remove(int elem) { Destruct(&Element(elem)); ShiftElementsLeft(elem); - --m_Size; + m_Size--; } -template< class T > -void CUtlVector::FindAndRemove(T const& src) +template +void CUtlVector::FindAndRemove(T const &src) { int elem = Find(src); - if (elem != -1) + if (elem != InvalidIndex()) { Remove(elem); } } -template< class T > +template void CUtlVector::RemoveMultiple(int elem, int num) { assert(IsValidIndex(elem)); @@ -526,7 +520,7 @@ void CUtlVector::RemoveMultiple(int elem, int num) m_Size -= num; } -template< class T > +template void CUtlVector::RemoveAll() { for (int i = m_Size; --i >= 0;) @@ -535,11 +529,8 @@ void CUtlVector::RemoveAll() m_Size = 0; } -//----------------------------------------------------------------------------- // Memory deallocation -//----------------------------------------------------------------------------- - -template< class T > +template void CUtlVector::Purge() { RemoveAll(); @@ -547,7 +538,7 @@ void CUtlVector::Purge() ResetDbgInfo(); } -template +template inline void CUtlVector::PurgeAndDeleteElements() { for (int i = 0; i < m_Size; i++) @@ -556,10 +547,8 @@ inline void CUtlVector::PurgeAndDeleteElements() Purge(); } -template< class T > +template void CUtlVector::SetGrowSize(int size) { m_Memory.SetGrowSize(size); } - -#endif // CCVECTOR_H diff --git a/regamedll/regamedll/RegameDLLRuntimeConfig.cpp b/regamedll/regamedll/RegameDLLRuntimeConfig.cpp index bfa2ab3d..9b2cca4b 100644 --- a/regamedll/regamedll/RegameDLLRuntimeConfig.cpp +++ b/regamedll/regamedll/RegameDLLRuntimeConfig.cpp @@ -1,3 +1,31 @@ +/* +* +* This program is free software; you can redistribute it and/or modify it +* under the terms of the GNU General Public License as published by the +* Free Software Foundation; either version 2 of the License, or (at +* your option) any later version. +* +* This program 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 +* General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software Foundation, +* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +* +* In addition, as a special exception, the author gives permission to +* link the code of this program with the Half-Life Game Engine ("HL +* Engine") and Modified Game Libraries ("MODs") developed by Valve, +* L.L.C ("Valve"). You must obey the GNU General Public License in all +* respects for all of the code used other than the HL Engine and MODs +* from Valve. If you modify this file, you may extend this exception +* to your version of the file, but you are not obligated to do so. If +* you do not wish to do so, delete this exception statement from your +* version. +* +*/ + #include "precompiled.h" CRegameDLLRuntimeConfig g_ReGameDLLRuntimeConfig; @@ -11,7 +39,9 @@ void CRegameDLLRuntimeConfig::parseFromCommandLine(const char *cmdLine) { char localBuf[2048]; if (strlen(cmdLine) >= sizeof(localBuf)) - regamedll_syserror("%s: too long cmdline", __FUNCTION__); + { + Sys_Error("%s: too long cmdline", __func__); + } strcpy(localBuf, cmdLine); char *cpos = localBuf; @@ -33,7 +63,7 @@ void CRegameDLLRuntimeConfig::parseFromCommandLine(const char *cmdLine) } } -const char *CRegameDLLRuntimeConfig::getNextToken(char* *pBuf) +const char *CRegameDLLRuntimeConfig::getNextToken(char **pBuf) { char *rpos = *pBuf; if (*rpos == 0) diff --git a/regamedll/regamedll/RegameDLLRuntimeConfig.h b/regamedll/regamedll/RegameDLLRuntimeConfig.h index ba4e1a16..6a6caeb5 100644 --- a/regamedll/regamedll/RegameDLLRuntimeConfig.h +++ b/regamedll/regamedll/RegameDLLRuntimeConfig.h @@ -1,3 +1,31 @@ +/* +* +* This program is free software; you can redistribute it and/or modify it +* under the terms of the GNU General Public License as published by the +* Free Software Foundation; either version 2 of the License, or (at +* your option) any later version. +* +* This program 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 +* General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software Foundation, +* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +* +* In addition, as a special exception, the author gives permission to +* link the code of this program with the Half-Life Game Engine ("HL +* Engine") and Modified Game Libraries ("MODs") developed by Valve, +* L.L.C ("Valve"). You must obey the GNU General Public License in all +* respects for all of the code used other than the HL Engine and MODs +* from Valve. If you modify this file, you may extend this exception +* to your version of the file, but you are not obligated to do so. If +* you do not wish to do so, delete this exception statement from your +* version. +* +*/ + #pragma once class CRegameDLLRuntimeConfig diff --git a/regamedll/regamedll/classes_dummy.cpp b/regamedll/regamedll/classes_dummy.cpp index 564860cb..9aafd5f9 100644 --- a/regamedll/regamedll/classes_dummy.cpp +++ b/regamedll/regamedll/classes_dummy.cpp @@ -1,3 +1,31 @@ +/* +* +* This program is free software; you can redistribute it and/or modify it +* under the terms of the GNU General Public License as published by the +* Free Software Foundation; either version 2 of the License, or (at +* your option) any later version. +* +* This program 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 +* General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software Foundation, +* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +* +* In addition, as a special exception, the author gives permission to +* link the code of this program with the Half-Life Game Engine ("HL +* Engine") and Modified Game Libraries ("MODs") developed by Valve, +* L.L.C ("Valve"). You must obey the GNU General Public License in all +* respects for all of the code used other than the HL Engine and MODs +* from Valve. If you modify this file, you may extend this exception +* to your version of the file, but you are not obligated to do so. If +* you do not wish to do so, delete this exception statement from your +* version. +* +*/ + #include "precompiled.h" class CDummyWeaponClass: diff --git a/regamedll/regamedll/dlls.h b/regamedll/regamedll/dlls.h index d9342ffe..5a403397 100644 --- a/regamedll/regamedll/dlls.h +++ b/regamedll/regamedll/dlls.h @@ -44,12 +44,9 @@ typedef Vector& VectorRef; typedef float& FloatRef; #endif // HOOK_GAMEDLL -#include "schedule.h" #include "archtypes.h" -#include "scriptevent.h" #include "enginecallback.h" #include "entity_state.h" -#include "nodes.h" #include "screenfade.h" #include "utlvector.h" @@ -65,9 +62,6 @@ typedef float& FloatRef; // GameInit #include "game.h" -// weapon shared -#include "wpn_shared.h" - //PM #include "pm_shared/pm_defs.h" #include "pm_shared/pm_materials.h" @@ -76,24 +70,19 @@ typedef float& FloatRef; #include "pm_shared/pm_shared.h" #include "pm_shared/pm_math.h" -#include "shake.h" -#include "util.h" #include "decals.h" #include "hltv.h" #include "cbase.h" -#include "world.h" #include "sound.h" #include "basemonster.h" #include "monsters.h" #include "unisignals.h" -#include "weapons.h" #include "maprules.h" #include "ammo.h" #include "mortar.h" #include "effects.h" #include "lights.h" -#include "items.h" #include "healthkit.h" #include "vehicle.h" #include "func_tank.h" @@ -102,8 +91,6 @@ typedef float& FloatRef; #include "bmodels.h" #include "debug.h" - -#include "player.h" #include "observer.h" #include "client.h" @@ -135,7 +122,6 @@ typedef float& FloatRef; #include "game_shared/bot/nav_path.h" #include "airtank.h" -#include "h_ai.h" #include "h_cycler.h" #include "h_battery.h" @@ -163,7 +149,6 @@ typedef float& FloatRef; #include "training_gamerules.h" #include "maprules.h" #include "monsterevent.h" -#include "plane.h" #include "skill.h" #include "soundent.h" #include "spectator.h" diff --git a/regamedll/regamedll/hookchains_impl.cpp b/regamedll/regamedll/hookchains_impl.cpp index 73035e7d..32ec882d 100644 --- a/regamedll/regamedll/hookchains_impl.cpp +++ b/regamedll/regamedll/hookchains_impl.cpp @@ -14,6 +14,16 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * +* In addition, as a special exception, the author gives permission to +* link the code of this program with the Half-Life Game Engine ("HL +* Engine") and Modified Game Libraries ("MODs") developed by Valve, +* L.L.C ("Valve"). You must obey the GNU General Public License in all +* respects for all of the code used other than the HL Engine and MODs +* from Valve. If you modify this file, you may extend this exception +* to your version of the file, but you are not obligated to do so. If +* you do not wish to do so, delete this exception statement from your +* version. +* */ #include "precompiled.h" @@ -39,11 +49,11 @@ bool AbstractHookChainRegistry::findHook(void* hookFunc) const void AbstractHookChainRegistry::addHook(void* hookFunc, int priority) { if (!hookFunc) { - Sys_Error("%s: Parameter hookFunc can't be a nullptr", __FUNCTION__); + Sys_Error("%s: Parameter hookFunc can't be a nullptr", __func__); } if (findHook(hookFunc)) { - Sys_Error("%s: The same handler can't be used twice on the hookchain.", __FUNCTION__); + Sys_Error("%s: The same handler can't be used twice on the hookchain.", __func__); } for (auto i = 0; i < MAX_HOOKS_IN_CHAIN; i++) @@ -62,7 +72,7 @@ void AbstractHookChainRegistry::addHook(void* hookFunc, int priority) } if (m_NumHooks >= MAX_HOOKS_IN_CHAIN) { - Sys_Error("%s: MAX_HOOKS_IN_CHAIN limit hit", __FUNCTION__); + Sys_Error("%s: MAX_HOOKS_IN_CHAIN limit hit", __func__); } m_NumHooks++; diff --git a/regamedll/regamedll/hookchains_impl.h b/regamedll/regamedll/hookchains_impl.h index ebbeea28..54fcbc58 100644 --- a/regamedll/regamedll/hookchains_impl.h +++ b/regamedll/regamedll/hookchains_impl.h @@ -25,7 +25,9 @@ * version. * */ + #pragma once + #include "hookchains.h" #define MAX_HOOKS_IN_CHAIN 30 @@ -52,7 +54,7 @@ public: IHookChainImpl(void** hooks, origfunc_t orig) : m_Hooks(hooks), m_OriginalFunc(orig) { if (orig == NULL && !is_void(orig)) - Sys_Error("%s: Non-void HookChain without original function.", __FUNCTION__); + Sys_Error("%s: Non-void HookChain without original function.", __func__); } virtual ~IHookChainImpl() {} @@ -88,7 +90,7 @@ public: IHookChainClassImpl(void** hooks, origfunc_t orig) : m_Hooks(hooks), m_OriginalFunc(orig) { if (orig == NULL && !is_void(orig)) - Sys_Error("%s: Non-void HookChain without original function.", __FUNCTION__); + Sys_Error("%s: Non-void HookChain without original function.", __func__); } virtual ~IHookChainClassImpl() {} @@ -124,7 +126,7 @@ public: IHookChainClassEmptyImpl(void** hooks, origfunc_t orig, t_class *object) : m_Hooks(hooks), m_OriginalFunc(orig), m_Object(object) { if (orig == NULL && !is_void(orig)) - Sys_Error("%s: Non-void HookChain without original function.", __FUNCTION__); + Sys_Error("%s: Non-void HookChain without original function.", __func__); } virtual ~IHookChainClassEmptyImpl() {} diff --git a/regamedll/regamedll/platform.cpp b/regamedll/regamedll/platform.cpp deleted file mode 100644 index 76c851d2..00000000 --- a/regamedll/regamedll/platform.cpp +++ /dev/null @@ -1,48 +0,0 @@ -#include "precompiled.h" - -void regamedll_log(const char *fmt, ...) -{ - va_list argptr; - static char data[8192]; - - va_start(argptr, fmt); - Q_vsnprintf(data, sizeof(data), fmt, argptr); - data[sizeof(data) - 1] = 0; - - strcat(data,"\n"); - -#ifdef _WIN32 - - int fd = _open("regamedll.log", _O_WRONLY | _O_APPEND | _O_CREAT, _S_IREAD | _S_IWRITE); - int len = Q_strlen(data); - _write(fd, data, len); - _close(fd); - -#else - - FILE *fd = fopen("regamedll.log", "at"); - fprintf(fd, "%s", data); - fclose(fd); - -#endif // _WIN32 -} - -void NORETURN regamedll_syserror(const char *error, ...) -{ - va_list argptr; - static char text[2048]; - - va_start(argptr, error); - vsnprintf(text, sizeof(text), error, argptr); - va_end(argptr); - - CONSOLE_ECHO("%s\n", text); - - FILE *fl = fopen("regamedll_error.txt", "w"); - fprintf(fl, "%s\n", text); - fclose(fl); - - //TerminateProcess(GetCurrentProcess(), 1); - *((int *)NULL) = 0; - while (true); -} diff --git a/regamedll/regamedll/platform.h b/regamedll/regamedll/platform.h deleted file mode 100644 index 1db8e907..00000000 --- a/regamedll/regamedll/platform.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef PLATFORM_GAMEDLL_H -#define PLATFORM_GAMEDLL_H -#ifdef _WIN32 -#pragma once -#endif - -#define _logf regamedll_log - -extern void regamedll_log(const char *fmt, ...); -extern void NORETURN regamedll_syserror(const char *error, ...); - -#endif // PLATFORM_GAMEDLL_H diff --git a/regamedll/regamedll/precompiled.cpp b/regamedll/regamedll/precompiled.cpp index 7ff8df54..a37dcb6c 100644 --- a/regamedll/regamedll/precompiled.cpp +++ b/regamedll/regamedll/precompiled.cpp @@ -1 +1,29 @@ +/* +* +* This program is free software; you can redistribute it and/or modify it +* under the terms of the GNU General Public License as published by the +* Free Software Foundation; either version 2 of the License, or (at +* your option) any later version. +* +* This program 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 +* General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software Foundation, +* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +* +* In addition, as a special exception, the author gives permission to +* link the code of this program with the Half-Life Game Engine ("HL +* Engine") and Modified Game Libraries ("MODs") developed by Valve, +* L.L.C ("Valve"). You must obey the GNU General Public License in all +* respects for all of the code used other than the HL Engine and MODs +* from Valve. If you modify this file, you may extend this exception +* to your version of the file, but you are not obligated to do so. If +* you do not wish to do so, delete this exception statement from your +* version. +* +*/ + #include "precompiled.h" diff --git a/regamedll/regamedll/precompiled.h b/regamedll/regamedll/precompiled.h index 1c9a6e0b..c551ad71 100644 --- a/regamedll/regamedll/precompiled.h +++ b/regamedll/regamedll/precompiled.h @@ -1,3 +1,31 @@ +/* +* +* This program is free software; you can redistribute it and/or modify it +* under the terms of the GNU General Public License as published by the +* Free Software Foundation; either version 2 of the License, or (at +* your option) any later version. +* +* This program 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 +* General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software Foundation, +* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +* +* In addition, as a special exception, the author gives permission to +* link the code of this program with the Half-Life Game Engine ("HL +* Engine") and Modified Game Libraries ("MODs") developed by Valve, +* L.L.C ("Valve"). You must obey the GNU General Public License in all +* respects for all of the code used other than the HL Engine and MODs +* from Valve. If you modify this file, you may extend this exception +* to your version of the file, but you are not obligated to do so. If +* you do not wish to do so, delete this exception statement from your +* version. +* +*/ + #pragma once #include "version/appversion.h" @@ -15,9 +43,7 @@ #include "hookers/hooklist.h" #include "engine.h" -#include "platform.h" #include "RegameDLLRuntimeConfig.h" -#include "regamedll_debug.h" // Valve libs stuff #include "tier0/platform.h" diff --git a/regamedll/regamedll/regamedll.cpp b/regamedll/regamedll/regamedll.cpp index 901b3504..897653b4 100644 --- a/regamedll/regamedll/regamedll.cpp +++ b/regamedll/regamedll/regamedll.cpp @@ -1,10 +1,38 @@ +/* +* +* This program is free software; you can redistribute it and/or modify it +* under the terms of the GNU General Public License as published by the +* Free Software Foundation; either version 2 of the License, or (at +* your option) any later version. +* +* This program 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 +* General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software Foundation, +* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +* +* In addition, as a special exception, the author gives permission to +* link the code of this program with the Half-Life Game Engine ("HL +* Engine") and Modified Game Libraries ("MODs") developed by Valve, +* L.L.C ("Valve"). You must obey the GNU General Public License in all +* respects for all of the code used other than the HL Engine and MODs +* from Valve. If you modify this file, you may extend this exception +* to your version of the file, but you are not obligated to do so. If +* you do not wish to do so, delete this exception statement from your +* version. +* +*/ + #include "precompiled.h" void Regamedll_Game_Init() { g_bIsCzeroGame = UTIL_IsGame("czero"); - g_bAllowedCSBot = UTIL_AreBotsAllowed(); // determine whether bots can be used or not - g_bHostageImprov = UTIL_AreHostagesImprov(); // determine whether hostage improv can be used or not + g_bAllowedCSBot = UTIL_AreBotsAllowed(); // determine whether bots can be used or not + g_bHostageImprov = UTIL_AreHostagesImprov(); // determine whether hostage improv can be used or not WeaponInfoReset(); } diff --git a/regamedll/regamedll/regamedll.h b/regamedll/regamedll/regamedll.h index b828eace..fedf81f8 100644 --- a/regamedll/regamedll/regamedll.h +++ b/regamedll/regamedll/regamedll.h @@ -1,6 +1,34 @@ +/* +* +* This program is free software; you can redistribute it and/or modify it +* under the terms of the GNU General Public License as published by the +* Free Software Foundation; either version 2 of the License, or (at +* your option) any later version. +* +* This program 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 +* General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software Foundation, +* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +* +* In addition, as a special exception, the author gives permission to +* link the code of this program with the Half-Life Game Engine ("HL +* Engine") and Modified Game Libraries ("MODs") developed by Valve, +* L.L.C ("Valve"). You must obey the GNU General Public License in all +* respects for all of the code used other than the HL Engine and MODs +* from Valve. If you modify this file, you may extend this exception +* to your version of the file, but you are not obligated to do so. If +* you do not wish to do so, delete this exception statement from your +* version. +* +*/ + #pragma once -extern void Regamedll_Game_Init(); +void Regamedll_Game_Init(); inline bool AreRunningCZero() { diff --git a/regamedll/regamedll/regamedll_api_impl.cpp b/regamedll/regamedll/regamedll_api_impl.cpp index 2616a1f4..2aee8532 100644 --- a/regamedll/regamedll/regamedll_api_impl.cpp +++ b/regamedll/regamedll/regamedll_api_impl.cpp @@ -25,6 +25,7 @@ * version. * */ + #include "precompiled.h" CReGameHookchains g_ReGameHookchains; @@ -154,31 +155,31 @@ const EXT_FUNC ReGameFuncs_t *CReGameApi::GetFuncs() { return &g_ReGameApiFuncs; } -IReGameHookchains* EXT_FUNC CReGameApi::GetHookchains() { +IReGameHookchains *EXT_FUNC CReGameApi::GetHookchains() { return &g_ReGameHookchains; } -CGameRules* EXT_FUNC CReGameApi::GetGameRules() { +CGameRules *EXT_FUNC CReGameApi::GetGameRules() { return g_pGameRules; } -WeaponInfoStruct* EXT_FUNC CReGameApi::GetWeaponInfo(int weaponID) { +WeaponInfoStruct *EXT_FUNC CReGameApi::GetWeaponInfo(int weaponID) { return ::GetWeaponInfo(weaponID); } -WeaponInfoStruct* EXT_FUNC CReGameApi::GetWeaponInfo(const char* weaponName) { +WeaponInfoStruct *EXT_FUNC CReGameApi::GetWeaponInfo(const char *weaponName) { return ::GetWeaponInfo(weaponName); } -playermove_t* EXT_FUNC CReGameApi::GetPlayerMove() { +playermove_t *EXT_FUNC CReGameApi::GetPlayerMove() { return pmove; } -WeaponSlotInfo* EXT_FUNC CReGameApi::GetWeaponSlot(WeaponIdType weaponID) { return ::GetWeaponSlot(weaponID); } -WeaponSlotInfo* EXT_FUNC CReGameApi::GetWeaponSlot(const char* weaponName) { return ::GetWeaponSlot(weaponName); } +WeaponSlotInfo *EXT_FUNC CReGameApi::GetWeaponSlot(WeaponIdType weaponID) { return ::GetWeaponSlot(weaponID); } +WeaponSlotInfo *EXT_FUNC CReGameApi::GetWeaponSlot(const char *weaponName) { return ::GetWeaponSlot(weaponName); } -ItemInfo* EXT_FUNC CReGameApi::GetItemInfo(WeaponIdType weaponID) { return &IMPL_CLASS(CBasePlayerItem, ItemInfoArray)[ weaponID ]; } -AmmoInfo* EXT_FUNC CReGameApi::GetAmmoInfo(AmmoType ammoID) { return &IMPL_CLASS(CBasePlayerItem, AmmoInfoArray)[ ammoID ]; } +ItemInfo *EXT_FUNC CReGameApi::GetItemInfo(WeaponIdType weaponID) { return &IMPL_CLASS(CBasePlayerItem, ItemInfoArray)[ weaponID ]; } +AmmoInfo *EXT_FUNC CReGameApi::GetAmmoInfo(AmmoType ammoID) { return &IMPL_CLASS(CBasePlayerItem, AmmoInfoArray)[ ammoID ]; } void EXT_FUNC Regamedll_ChangeString_api(char *&dest, const char *source) { diff --git a/regamedll/regamedll/regamedll_api_impl.h b/regamedll/regamedll/regamedll_api_impl.h index 283c543b..172e505a 100644 --- a/regamedll/regamedll/regamedll_api_impl.h +++ b/regamedll/regamedll/regamedll_api_impl.h @@ -25,6 +25,7 @@ * version. * */ + #pragma once #include "archtypes.h" @@ -32,7 +33,7 @@ #include "regamedll_interfaces_impl.h" #define GAMEHOOK_REGISTRY(func)\ - IReGameHookRegistry_##func* CReGameHookchains::func() { return &m_##func; } + IReGameHookRegistry_##func *CReGameHookchains::func() { return &m_##func; } // CBasePlayer::Spawn hook typedef IHookChainClassImpl CReGameHook_CBasePlayer_Spawn; @@ -159,12 +160,12 @@ typedef IHookChainClassImpl CReGameHook typedef IHookChainRegistryClassImpl CReGameHookRegistry_CBasePlayer_HasRestrictItem; // CBasePlayer::DropPlayerItem hook -typedef IHookChainClassImpl CReGameHook_CBasePlayer_DropPlayerItem; -typedef IHookChainRegistryClassImpl CReGameHookRegistry_CBasePlayer_DropPlayerItem; +typedef IHookChainClassImpl CReGameHook_CBasePlayer_DropPlayerItem; +typedef IHookChainRegistryClassImpl CReGameHookRegistry_CBasePlayer_DropPlayerItem; // CBasePlayer::DropShield hook -typedef IHookChainClassImpl CReGameHook_CBasePlayer_DropShield; -typedef IHookChainRegistryClassImpl CReGameHookRegistry_CBasePlayer_DropShield; +typedef IHookChainClassImpl CReGameHook_CBasePlayer_DropShield; +typedef IHookChainRegistryClassImpl CReGameHookRegistry_CBasePlayer_DropShield; // CBasePlayer::OnSpawnEquip hook typedef IHookChainClassImpl CReGameHook_CBasePlayer_OnSpawnEquip; @@ -448,91 +449,91 @@ public: CReGameHookRegistry_CBasePlayer_StartDeathCam m_CBasePlayer_StartDeathCam; public: - virtual IReGameHookRegistry_CBasePlayer_Spawn* CBasePlayer_Spawn(); - virtual IReGameHookRegistry_CBasePlayer_Precache* CBasePlayer_Precache(); - virtual IReGameHookRegistry_CBasePlayer_ObjectCaps* CBasePlayer_ObjectCaps(); - virtual IReGameHookRegistry_CBasePlayer_Classify* CBasePlayer_Classify(); - virtual IReGameHookRegistry_CBasePlayer_TraceAttack* CBasePlayer_TraceAttack(); - virtual IReGameHookRegistry_CBasePlayer_TakeDamage* CBasePlayer_TakeDamage(); - virtual IReGameHookRegistry_CBasePlayer_TakeHealth* CBasePlayer_TakeHealth(); - virtual IReGameHookRegistry_CBasePlayer_Killed* CBasePlayer_Killed(); - virtual IReGameHookRegistry_CBasePlayer_AddPoints* CBasePlayer_AddPoints(); - virtual IReGameHookRegistry_CBasePlayer_AddPointsToTeam* CBasePlayer_AddPointsToTeam(); - virtual IReGameHookRegistry_CBasePlayer_AddPlayerItem* CBasePlayer_AddPlayerItem(); - virtual IReGameHookRegistry_CBasePlayer_RemovePlayerItem* CBasePlayer_RemovePlayerItem(); - virtual IReGameHookRegistry_CBasePlayer_GiveAmmo* CBasePlayer_GiveAmmo(); - virtual IReGameHookRegistry_CBasePlayer_ResetMaxSpeed* CBasePlayer_ResetMaxSpeed(); - virtual IReGameHookRegistry_CBasePlayer_Jump* CBasePlayer_Jump(); - virtual IReGameHookRegistry_CBasePlayer_Duck* CBasePlayer_Duck(); - virtual IReGameHookRegistry_CBasePlayer_PreThink* CBasePlayer_PreThink(); - virtual IReGameHookRegistry_CBasePlayer_PostThink* CBasePlayer_PostThink(); - virtual IReGameHookRegistry_CBasePlayer_UpdateClientData* CBasePlayer_UpdateClientData(); - virtual IReGameHookRegistry_CBasePlayer_ImpulseCommands* CBasePlayer_ImpulseCommands(); - virtual IReGameHookRegistry_CBasePlayer_RoundRespawn* CBasePlayer_RoundRespawn(); - virtual IReGameHookRegistry_CBasePlayer_Blind* CBasePlayer_Blind(); + virtual IReGameHookRegistry_CBasePlayer_Spawn *CBasePlayer_Spawn(); + virtual IReGameHookRegistry_CBasePlayer_Precache *CBasePlayer_Precache(); + virtual IReGameHookRegistry_CBasePlayer_ObjectCaps *CBasePlayer_ObjectCaps(); + virtual IReGameHookRegistry_CBasePlayer_Classify *CBasePlayer_Classify(); + virtual IReGameHookRegistry_CBasePlayer_TraceAttack *CBasePlayer_TraceAttack(); + virtual IReGameHookRegistry_CBasePlayer_TakeDamage *CBasePlayer_TakeDamage(); + virtual IReGameHookRegistry_CBasePlayer_TakeHealth *CBasePlayer_TakeHealth(); + virtual IReGameHookRegistry_CBasePlayer_Killed *CBasePlayer_Killed(); + virtual IReGameHookRegistry_CBasePlayer_AddPoints *CBasePlayer_AddPoints(); + virtual IReGameHookRegistry_CBasePlayer_AddPointsToTeam *CBasePlayer_AddPointsToTeam(); + virtual IReGameHookRegistry_CBasePlayer_AddPlayerItem *CBasePlayer_AddPlayerItem(); + virtual IReGameHookRegistry_CBasePlayer_RemovePlayerItem *CBasePlayer_RemovePlayerItem(); + virtual IReGameHookRegistry_CBasePlayer_GiveAmmo *CBasePlayer_GiveAmmo(); + virtual IReGameHookRegistry_CBasePlayer_ResetMaxSpeed *CBasePlayer_ResetMaxSpeed(); + virtual IReGameHookRegistry_CBasePlayer_Jump *CBasePlayer_Jump(); + virtual IReGameHookRegistry_CBasePlayer_Duck *CBasePlayer_Duck(); + virtual IReGameHookRegistry_CBasePlayer_PreThink *CBasePlayer_PreThink(); + virtual IReGameHookRegistry_CBasePlayer_PostThink *CBasePlayer_PostThink(); + virtual IReGameHookRegistry_CBasePlayer_UpdateClientData *CBasePlayer_UpdateClientData(); + virtual IReGameHookRegistry_CBasePlayer_ImpulseCommands *CBasePlayer_ImpulseCommands(); + virtual IReGameHookRegistry_CBasePlayer_RoundRespawn *CBasePlayer_RoundRespawn(); + virtual IReGameHookRegistry_CBasePlayer_Blind *CBasePlayer_Blind(); - virtual IReGameHookRegistry_CBasePlayer_Observer_IsValidTarget* CBasePlayer_Observer_IsValidTarget(); - virtual IReGameHookRegistry_CBasePlayer_SetAnimation* CBasePlayer_SetAnimation(); - virtual IReGameHookRegistry_CBasePlayer_GiveDefaultItems* CBasePlayer_GiveDefaultItems(); - virtual IReGameHookRegistry_CBasePlayer_GiveNamedItem* CBasePlayer_GiveNamedItem(); - virtual IReGameHookRegistry_CBasePlayer_AddAccount* CBasePlayer_AddAccount(); - virtual IReGameHookRegistry_CBasePlayer_GiveShield* CBasePlayer_GiveShield(); - virtual IReGameHookRegistry_CBasePlayer_SetClientUserInfoModel* CBasePlayer_SetClientUserInfoModel(); - virtual IReGameHookRegistry_CBasePlayer_SetClientUserInfoName* CBasePlayer_SetClientUserInfoName(); - virtual IReGameHookRegistry_CBasePlayer_HasRestrictItem* CBasePlayer_HasRestrictItem(); - virtual IReGameHookRegistry_CBasePlayer_DropPlayerItem* CBasePlayer_DropPlayerItem(); - virtual IReGameHookRegistry_CBasePlayer_DropShield* CBasePlayer_DropShield(); - virtual IReGameHookRegistry_CBasePlayer_OnSpawnEquip* CBasePlayer_OnSpawnEquip(); - virtual IReGameHookRegistry_CBasePlayer_Radio* CBasePlayer_Radio(); - virtual IReGameHookRegistry_CBasePlayer_Disappear* CBasePlayer_Disappear(); - virtual IReGameHookRegistry_CBasePlayer_MakeVIP* CBasePlayer_MakeVIP(); - virtual IReGameHookRegistry_CBasePlayer_MakeBomber* CBasePlayer_MakeBomber(); - virtual IReGameHookRegistry_CBasePlayer_StartObserver* CBasePlayer_StartObserver(); - virtual IReGameHookRegistry_CBasePlayer_GetIntoGame* CBasePlayer_GetIntoGame(); + virtual IReGameHookRegistry_CBasePlayer_Observer_IsValidTarget *CBasePlayer_Observer_IsValidTarget(); + virtual IReGameHookRegistry_CBasePlayer_SetAnimation *CBasePlayer_SetAnimation(); + virtual IReGameHookRegistry_CBasePlayer_GiveDefaultItems *CBasePlayer_GiveDefaultItems(); + virtual IReGameHookRegistry_CBasePlayer_GiveNamedItem *CBasePlayer_GiveNamedItem(); + virtual IReGameHookRegistry_CBasePlayer_AddAccount *CBasePlayer_AddAccount(); + virtual IReGameHookRegistry_CBasePlayer_GiveShield *CBasePlayer_GiveShield(); + virtual IReGameHookRegistry_CBasePlayer_SetClientUserInfoModel *CBasePlayer_SetClientUserInfoModel(); + virtual IReGameHookRegistry_CBasePlayer_SetClientUserInfoName *CBasePlayer_SetClientUserInfoName(); + virtual IReGameHookRegistry_CBasePlayer_HasRestrictItem *CBasePlayer_HasRestrictItem(); + virtual IReGameHookRegistry_CBasePlayer_DropPlayerItem *CBasePlayer_DropPlayerItem(); + virtual IReGameHookRegistry_CBasePlayer_DropShield *CBasePlayer_DropShield(); + virtual IReGameHookRegistry_CBasePlayer_OnSpawnEquip *CBasePlayer_OnSpawnEquip(); + virtual IReGameHookRegistry_CBasePlayer_Radio *CBasePlayer_Radio(); + virtual IReGameHookRegistry_CBasePlayer_Disappear *CBasePlayer_Disappear(); + virtual IReGameHookRegistry_CBasePlayer_MakeVIP *CBasePlayer_MakeVIP(); + virtual IReGameHookRegistry_CBasePlayer_MakeBomber *CBasePlayer_MakeBomber(); + virtual IReGameHookRegistry_CBasePlayer_StartObserver *CBasePlayer_StartObserver(); + virtual IReGameHookRegistry_CBasePlayer_GetIntoGame *CBasePlayer_GetIntoGame(); - virtual IReGameHookRegistry_CBaseAnimating_ResetSequenceInfo* CBaseAnimating_ResetSequenceInfo(); + virtual IReGameHookRegistry_CBaseAnimating_ResetSequenceInfo *CBaseAnimating_ResetSequenceInfo(); - virtual IReGameHookRegistry_GetForceCamera* GetForceCamera(); - virtual IReGameHookRegistry_PlayerBlind* PlayerBlind(); - virtual IReGameHookRegistry_RadiusFlash_TraceLine* RadiusFlash_TraceLine(); - virtual IReGameHookRegistry_RoundEnd* RoundEnd(); - virtual IReGameHookRegistry_InstallGameRules* InstallGameRules(); - virtual IReGameHookRegistry_PM_Init* PM_Init(); - virtual IReGameHookRegistry_PM_Move* PM_Move(); - virtual IReGameHookRegistry_PM_AirMove* PM_AirMove(); - virtual IReGameHookRegistry_HandleMenu_ChooseAppearance* HandleMenu_ChooseAppearance(); - virtual IReGameHookRegistry_HandleMenu_ChooseTeam* HandleMenu_ChooseTeam(); - virtual IReGameHookRegistry_ShowMenu* ShowMenu(); - virtual IReGameHookRegistry_ShowVGUIMenu* ShowVGUIMenu(); - virtual IReGameHookRegistry_BuyGunAmmo* BuyGunAmmo(); - virtual IReGameHookRegistry_BuyWeaponByWeaponID* BuyWeaponByWeaponID(); - virtual IReGameHookRegistry_InternalCommand* InternalCommand(); + virtual IReGameHookRegistry_GetForceCamera *GetForceCamera(); + virtual IReGameHookRegistry_PlayerBlind *PlayerBlind(); + virtual IReGameHookRegistry_RadiusFlash_TraceLine *RadiusFlash_TraceLine(); + virtual IReGameHookRegistry_RoundEnd *RoundEnd(); + virtual IReGameHookRegistry_InstallGameRules *InstallGameRules(); + virtual IReGameHookRegistry_PM_Init *PM_Init(); + virtual IReGameHookRegistry_PM_Move *PM_Move(); + virtual IReGameHookRegistry_PM_AirMove *PM_AirMove(); + virtual IReGameHookRegistry_HandleMenu_ChooseAppearance *HandleMenu_ChooseAppearance(); + virtual IReGameHookRegistry_HandleMenu_ChooseTeam *HandleMenu_ChooseTeam(); + virtual IReGameHookRegistry_ShowMenu *ShowMenu(); + virtual IReGameHookRegistry_ShowVGUIMenu *ShowVGUIMenu(); + virtual IReGameHookRegistry_BuyGunAmmo *BuyGunAmmo(); + virtual IReGameHookRegistry_BuyWeaponByWeaponID *BuyWeaponByWeaponID(); + virtual IReGameHookRegistry_InternalCommand *InternalCommand(); - virtual IReGameHookRegistry_CSGameRules_FShouldSwitchWeapon* CSGameRules_FShouldSwitchWeapon(); - virtual IReGameHookRegistry_CSGameRules_GetNextBestWeapon* CSGameRules_GetNextBestWeapon(); - virtual IReGameHookRegistry_CSGameRules_FlPlayerFallDamage* CSGameRules_FlPlayerFallDamage(); - virtual IReGameHookRegistry_CSGameRules_FPlayerCanTakeDamage* CSGameRules_FPlayerCanTakeDamage(); - virtual IReGameHookRegistry_CSGameRules_PlayerSpawn* CSGameRules_PlayerSpawn(); - virtual IReGameHookRegistry_CSGameRules_FPlayerCanRespawn* CSGameRules_FPlayerCanRespawn(); - virtual IReGameHookRegistry_CSGameRules_GetPlayerSpawnSpot* CSGameRules_GetPlayerSpawnSpot(); - virtual IReGameHookRegistry_CSGameRules_ClientUserInfoChanged* CSGameRules_ClientUserInfoChanged(); - virtual IReGameHookRegistry_CSGameRules_PlayerKilled* CSGameRules_PlayerKilled(); - virtual IReGameHookRegistry_CSGameRules_DeathNotice* CSGameRules_DeathNotice(); - virtual IReGameHookRegistry_CSGameRules_CanHavePlayerItem* CSGameRules_CanHavePlayerItem(); - virtual IReGameHookRegistry_CSGameRules_DeadPlayerWeapons* CSGameRules_DeadPlayerWeapons(); - virtual IReGameHookRegistry_CSGameRules_ServerDeactivate* CSGameRules_ServerDeactivate(); - virtual IReGameHookRegistry_CSGameRules_CheckMapConditions* CSGameRules_CheckMapConditions(); - virtual IReGameHookRegistry_CSGameRules_CleanUpMap* CSGameRules_CleanUpMap(); - virtual IReGameHookRegistry_CSGameRules_RestartRound* CSGameRules_RestartRound(); - virtual IReGameHookRegistry_CSGameRules_CheckWinConditions* CSGameRules_CheckWinConditions(); - virtual IReGameHookRegistry_CSGameRules_RemoveGuns* CSGameRules_RemoveGuns(); - virtual IReGameHookRegistry_CSGameRules_GiveC4* CSGameRules_GiveC4(); - virtual IReGameHookRegistry_CSGameRules_ChangeLevel* CSGameRules_ChangeLevel(); - virtual IReGameHookRegistry_CSGameRules_GoToIntermission* CSGameRules_GoToIntermission(); - virtual IReGameHookRegistry_CSGameRules_BalanceTeams* CSGameRules_BalanceTeams(); - virtual IReGameHookRegistry_CSGameRules_OnRoundFreezeEnd* CSGameRules_OnRoundFreezeEnd(); - virtual IReGameHookRegistry_PM_UpdateStepSound* PM_UpdateStepSound(); - virtual IReGameHookRegistry_CBasePlayer_StartDeathCam* CBasePlayer_StartDeathCam(); + virtual IReGameHookRegistry_CSGameRules_FShouldSwitchWeapon *CSGameRules_FShouldSwitchWeapon(); + virtual IReGameHookRegistry_CSGameRules_GetNextBestWeapon *CSGameRules_GetNextBestWeapon(); + virtual IReGameHookRegistry_CSGameRules_FlPlayerFallDamage *CSGameRules_FlPlayerFallDamage(); + virtual IReGameHookRegistry_CSGameRules_FPlayerCanTakeDamage *CSGameRules_FPlayerCanTakeDamage(); + virtual IReGameHookRegistry_CSGameRules_PlayerSpawn *CSGameRules_PlayerSpawn(); + virtual IReGameHookRegistry_CSGameRules_FPlayerCanRespawn *CSGameRules_FPlayerCanRespawn(); + virtual IReGameHookRegistry_CSGameRules_GetPlayerSpawnSpot *CSGameRules_GetPlayerSpawnSpot(); + virtual IReGameHookRegistry_CSGameRules_ClientUserInfoChanged *CSGameRules_ClientUserInfoChanged(); + virtual IReGameHookRegistry_CSGameRules_PlayerKilled *CSGameRules_PlayerKilled(); + virtual IReGameHookRegistry_CSGameRules_DeathNotice *CSGameRules_DeathNotice(); + virtual IReGameHookRegistry_CSGameRules_CanHavePlayerItem *CSGameRules_CanHavePlayerItem(); + virtual IReGameHookRegistry_CSGameRules_DeadPlayerWeapons *CSGameRules_DeadPlayerWeapons(); + virtual IReGameHookRegistry_CSGameRules_ServerDeactivate *CSGameRules_ServerDeactivate(); + virtual IReGameHookRegistry_CSGameRules_CheckMapConditions *CSGameRules_CheckMapConditions(); + virtual IReGameHookRegistry_CSGameRules_CleanUpMap *CSGameRules_CleanUpMap(); + virtual IReGameHookRegistry_CSGameRules_RestartRound *CSGameRules_RestartRound(); + virtual IReGameHookRegistry_CSGameRules_CheckWinConditions *CSGameRules_CheckWinConditions(); + virtual IReGameHookRegistry_CSGameRules_RemoveGuns *CSGameRules_RemoveGuns(); + virtual IReGameHookRegistry_CSGameRules_GiveC4 *CSGameRules_GiveC4(); + virtual IReGameHookRegistry_CSGameRules_ChangeLevel *CSGameRules_ChangeLevel(); + virtual IReGameHookRegistry_CSGameRules_GoToIntermission *CSGameRules_GoToIntermission(); + virtual IReGameHookRegistry_CSGameRules_BalanceTeams *CSGameRules_BalanceTeams(); + virtual IReGameHookRegistry_CSGameRules_OnRoundFreezeEnd *CSGameRules_OnRoundFreezeEnd(); + virtual IReGameHookRegistry_PM_UpdateStepSound *PM_UpdateStepSound(); + virtual IReGameHookRegistry_CBasePlayer_StartDeathCam *CBasePlayer_StartDeathCam(); }; extern CReGameHookchains g_ReGameHookchains; @@ -546,14 +547,14 @@ public: virtual const ReGameFuncs_t *GetFuncs(); virtual IReGameHookchains *GetHookchains(); - virtual CGameRules* GetGameRules(); - virtual WeaponInfoStruct* GetWeaponInfo(int weaponID); - virtual WeaponInfoStruct* GetWeaponInfo(const char* weaponName); - virtual playermove_t* GetPlayerMove(); - virtual WeaponSlotInfo* GetWeaponSlot(WeaponIdType weaponID); - virtual WeaponSlotInfo* GetWeaponSlot(const char* weaponName); - virtual ItemInfo* GetItemInfo(WeaponIdType weaponID); - virtual AmmoInfo* GetAmmoInfo(AmmoType ammoID); + virtual CGameRules *GetGameRules(); + virtual WeaponInfoStruct *GetWeaponInfo(int weaponID); + virtual WeaponInfoStruct *GetWeaponInfo(const char *weaponName); + virtual playermove_t *GetPlayerMove(); + virtual WeaponSlotInfo *GetWeaponSlot(WeaponIdType weaponID); + virtual WeaponSlotInfo *GetWeaponSlot(const char *weaponName); + virtual ItemInfo *GetItemInfo(WeaponIdType weaponID); + virtual AmmoInfo *GetAmmoInfo(AmmoType ammoID); }; void Regamedll_ChangeString_api(char *&dest, const char *source); diff --git a/regamedll/regamedll/regamedll_debug.cpp b/regamedll/regamedll/regamedll_debug.cpp deleted file mode 100644 index 9d9c82bd..00000000 --- a/regamedll/regamedll/regamedll_debug.cpp +++ /dev/null @@ -1,57 +0,0 @@ -#include "precompiled.h" - -void _print_chat(class CBasePlayer *pPlayer, const char *fmt, ...) -{ - static char Dest[4096]; - - va_list ap; - va_start(ap, fmt); - vsnprintf(Dest, sizeof(Dest), fmt, ap); - va_end(ap); - - if (Q_strlen(Dest) < sizeof(Dest) - 2) - Q_strcat(Dest, "\n"); - - else Dest[Q_strlen(Dest) - 1] = '\n'; - - UTIL_SayText(Dest, (class CBaseEntity *)pPlayer); -} - -void _print_console(struct entvars_s *pev, const char *fmt, ...) -{ - static char Dest[4096]; - - va_list ap; - va_start(ap, fmt); - vsnprintf(Dest, sizeof(Dest), fmt, ap); - va_end(ap); - - if (Q_strlen(Dest) < sizeof(Dest) - 2) - Q_strcat(Dest, "\n"); - - else Dest[Q_strlen(Dest) - 1] = '\n'; - - ClientPrint(pev, HUD_PRINTCONSOLE, Dest); -} - -void _printf2(const char *fmt, ...) -{ - /* - * check is null, test the demo started before than searches pointer to refs - */ - if (&g_engfuncs == NULL || g_engfuncs.pfnServerPrint == NULL) - return; - - static char Dest[4096]; - va_list ap; - va_start(ap, fmt); - vsnprintf(Dest, sizeof(Dest), fmt, ap); - va_end(ap); - - if (Q_strlen(Dest) < sizeof(Dest) - 2) - Q_strcat(Dest, "\n"); - - else Dest[Q_strlen(Dest) - 1] = '\n'; - - SERVER_PRINT(Dest); -} diff --git a/regamedll/regamedll/regamedll_debug.h b/regamedll/regamedll/regamedll_debug.h deleted file mode 100644 index f6bae133..00000000 --- a/regamedll/regamedll/regamedll_debug.h +++ /dev/null @@ -1,9 +0,0 @@ -#pragma once - -#define _logf regamedll_log -#define printf2 _printf2 -#define chatf _print_chat - -extern void _printf2(const char *fmt, ...); -extern void _print_chat(class CBasePlayer *pPlayer, const char *fmt, ...); -extern void _print_console(struct entvars_s *pev, const char *fmt, ...); diff --git a/regamedll/regamedll/regamedll_interfaces_impl.cpp b/regamedll/regamedll/regamedll_interfaces_impl.cpp index 02ecc45c..c8c76fcf 100644 --- a/regamedll/regamedll/regamedll_interfaces_impl.cpp +++ b/regamedll/regamedll/regamedll_interfaces_impl.cpp @@ -140,7 +140,7 @@ bool EXT_FUNC CCSPlayer::JoinTeam(TeamName team) return true; } -bool EXT_FUNC CCSPlayer::RemovePlayerItem(const char* pszItemName) +bool EXT_FUNC CCSPlayer::RemovePlayerItem(const char *pszItemName) { if (!pszItemName) return false; @@ -316,7 +316,7 @@ void EXT_FUNC CCSPlayer::SetBombIcon(bool bFlash) { BasePlayer()->SetBombIcon(bF void EXT_FUNC CCSPlayer::SetScoreAttrib(CBasePlayer *dest) { BasePlayer()->SetScoreAttrib(dest); } void EXT_FUNC CCSPlayer::ReloadWeapons(CBasePlayerItem *pWeapon, bool bForceReload, bool bForceRefill) { BasePlayer()->ReloadWeapons(pWeapon, bForceReload, bForceRefill); } void EXT_FUNC CCSPlayer::Observer_SetMode(int iMode) { BasePlayer()->Observer_SetMode(iMode); } -bool EXT_FUNC CCSPlayer::SelectSpawnSpot(const char *pEntClassName, CBaseEntity* &pSpot) { return BasePlayer()->SelectSpawnSpot(pEntClassName, pSpot); } +bool EXT_FUNC CCSPlayer::SelectSpawnSpot(const char *pEntClassName, CBaseEntity *&pSpot) { return BasePlayer()->SelectSpawnSpot(pEntClassName, pSpot); } bool EXT_FUNC CCSPlayer::SwitchWeapon(CBasePlayerItem *pWeapon) { return BasePlayer()->SwitchWeapon(pWeapon) != FALSE; } void EXT_FUNC CCSPlayer::SwitchTeam() { BasePlayer()->SwitchTeam(); } void EXT_FUNC CCSPlayer::StartObserver(Vector& vecPosition, Vector& vecViewAngle) { BasePlayer()->StartObserver(vecPosition, vecViewAngle); } diff --git a/regamedll/regamedll/regamedll_interfaces_impl.h b/regamedll/regamedll/regamedll_interfaces_impl.h index 526e7e62..30ea361a 100644 --- a/regamedll/regamedll/regamedll_interfaces_impl.h +++ b/regamedll/regamedll/regamedll_interfaces_impl.h @@ -25,6 +25,7 @@ * version. * */ + #pragma once #include "maintypes.h"