summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Angus <tim@ngus.net>2002-09-09 23:32:27 +0000
committerTim Angus <tim@ngus.net>2002-09-09 23:32:27 +0000
commitc0e95997d9e9fcaa220704c8c67b50d6761d1b66 (patch)
tree307242d290de1715df0f4f28dd7e08ccb7006f5c
parent9af7c524043a8f296ea5f45ec7f73c16e29921b5 (diff)
* General tidy up and beautification of code
* Removal of most of the legacy Q3A stuff * Cursor no longer displayed on load screen * (Biggest commit EVAR?)
-rw-r--r--Makefile1
-rw-r--r--depend174
-rw-r--r--src/cgame/cg_animmapobj.c69
-rw-r--r--src/cgame/cg_buildable.c38
-rw-r--r--src/cgame/cg_consolecmds.c245
-rw-r--r--src/cgame/cg_draw.c149
-rw-r--r--src/cgame/cg_drawtools.c661
-rw-r--r--src/cgame/cg_ents.c426
-rw-r--r--src/cgame/cg_event.c1524
-rw-r--r--src/cgame/cg_local.h1
-rw-r--r--src/cgame/cg_main.c1240
-rw-r--r--src/cgame/cg_marks.c417
-rw-r--r--src/cgame/cg_players.c1225
-rw-r--r--src/cgame/cg_playerstate.c457
-rw-r--r--src/cgame/cg_predict.c384
-rw-r--r--src/cgame/cg_scanner.c4
-rw-r--r--src/cgame/cg_servercmds.c886
-rw-r--r--src/cgame/cg_snapshot.c522
-rw-r--r--src/cgame/cg_syscalls.asm196
-rw-r--r--src/cgame/cg_syscalls.c412
-rw-r--r--src/cgame/cg_trails.c1308
-rw-r--r--src/cgame/cg_view.c539
-rw-r--r--src/cgame/cg_weapons.c1493
-rw-r--r--src/cgame/tr_types.h273
-rw-r--r--src/game/bg_lib.c1692
-rw-r--r--src/game/bg_lib.h68
-rw-r--r--src/game/bg_local.h13
-rw-r--r--src/game/bg_misc.c360
-rw-r--r--src/game/bg_pmove.c1211
-rw-r--r--src/game/bg_public.h123
-rw-r--r--src/game/bg_slidemove.c380
-rw-r--r--src/game/g_active.c607
-rw-r--r--src/game/g_buildable.c194
-rw-r--r--src/game/g_client.c527
-rw-r--r--src/game/g_cmds.c383
-rw-r--r--src/game/g_combat.c304
-rw-r--r--src/game/g_local.h956
-rw-r--r--src/game/g_main.c844
-rw-r--r--src/game/g_mem.c35
-rw-r--r--src/game/g_misc.c121
-rw-r--r--src/game/g_missile.c114
-rw-r--r--src/game/g_mover.c914
-rw-r--r--src/game/g_session.c18
-rw-r--r--src/game/g_spawn.c350
-rw-r--r--src/game/g_svcmds.c364
-rw-r--r--src/game/g_syscalls.asm276
-rw-r--r--src/game/g_syscalls.c793
-rw-r--r--src/game/g_target.c211
-rw-r--r--src/game/g_team.c103
-rw-r--r--src/game/g_trigger.c232
-rw-r--r--src/game/g_utils.c739
-rw-r--r--src/game/g_weapon.c20
-rw-r--r--src/game/q_math.c207
-rw-r--r--src/game/q_shared.c308
-rw-r--r--src/ui/ui_main.c11
-rw-r--r--src/ui/ui_players.c4
-rw-r--r--src/ui/ui_shared.c96
57 files changed, 11193 insertions, 14029 deletions
diff --git a/Makefile b/Makefile
index 28a96b5c..fca2a36b 100644
--- a/Makefile
+++ b/Makefile
@@ -20,7 +20,6 @@ GOBJ = \
$(GDIRNAME)/q_math.o \
$(GDIRNAME)/q_shared.o \
$(GDIRNAME)/g_active.o \
- $(GDIRNAME)/g_arenas.o \
$(GDIRNAME)/g_client.o \
$(GDIRNAME)/g_cmds.o \
$(GDIRNAME)/g_combat.o \
diff --git a/depend b/depend
index 850d59c4..13777ca3 100644
--- a/depend
+++ b/depend
@@ -9,67 +9,56 @@ releasei386-glibc/game/bg_slidemove.o: ./src/game/bg_slidemove.c src/game/q_shar
src/game/surfaceflags.h src/game/bg_public.h src/game/bg_local.h
releasei386-glibc/game/g_active.o: ./src/game/g_active.c src/game/g_local.h \
src/game/q_shared.h src/game/surfaceflags.h src/game/bg_public.h \
- src/game/g_public.h src/game/g_team.h
-releasei386-glibc/game/g_arenas.o: ./src/game/g_arenas.c src/game/g_local.h \
- src/game/q_shared.h src/game/surfaceflags.h src/game/bg_public.h \
- src/game/g_public.h src/game/g_team.h
+ src/game/g_public.h
releasei386-glibc/game/g_buildable.o: ./src/game/g_buildable.c src/game/g_local.h \
src/game/q_shared.h src/game/surfaceflags.h src/game/bg_public.h \
- src/game/g_public.h src/game/g_team.h
+ src/game/g_public.h
releasei386-glibc/game/g_client.o: ./src/game/g_client.c src/game/g_local.h \
src/game/q_shared.h src/game/surfaceflags.h src/game/bg_public.h \
- src/game/g_public.h src/game/g_team.h
+ src/game/g_public.h
releasei386-glibc/game/g_cmds.o: ./src/game/g_cmds.c src/game/g_local.h src/game/q_shared.h \
- src/game/surfaceflags.h src/game/bg_public.h src/game/g_public.h \
- src/game/g_team.h
+ src/game/surfaceflags.h src/game/bg_public.h src/game/g_public.h
releasei386-glibc/game/g_combat.o: ./src/game/g_combat.c src/game/g_local.h \
src/game/q_shared.h src/game/surfaceflags.h src/game/bg_public.h \
- src/game/g_public.h src/game/g_team.h
+ src/game/g_public.h
releasei386-glibc/game/g_main.o: ./src/game/g_main.c src/game/g_local.h src/game/q_shared.h \
- src/game/surfaceflags.h src/game/bg_public.h src/game/g_public.h \
- src/game/g_team.h
+ src/game/surfaceflags.h src/game/bg_public.h src/game/g_public.h
releasei386-glibc/game/g_mem.o: ./src/game/g_mem.c src/game/g_local.h src/game/q_shared.h \
- src/game/surfaceflags.h src/game/bg_public.h src/game/g_public.h \
- src/game/g_team.h
+ src/game/surfaceflags.h src/game/bg_public.h src/game/g_public.h
releasei386-glibc/game/g_misc.o: ./src/game/g_misc.c src/game/g_local.h src/game/q_shared.h \
- src/game/surfaceflags.h src/game/bg_public.h src/game/g_public.h \
- src/game/g_team.h
+ src/game/surfaceflags.h src/game/bg_public.h src/game/g_public.h
releasei386-glibc/game/g_missile.o: ./src/game/g_missile.c src/game/g_local.h \
src/game/q_shared.h src/game/surfaceflags.h src/game/bg_public.h \
- src/game/g_public.h src/game/g_team.h
+ src/game/g_public.h
releasei386-glibc/game/g_mover.o: ./src/game/g_mover.c src/game/g_local.h src/game/q_shared.h \
- src/game/surfaceflags.h src/game/bg_public.h src/game/g_public.h \
- src/game/g_team.h
+ src/game/surfaceflags.h src/game/bg_public.h src/game/g_public.h
releasei386-glibc/game/g_physics.o: ./src/game/g_physics.c src/game/g_local.h \
src/game/q_shared.h src/game/surfaceflags.h src/game/bg_public.h \
- src/game/g_public.h src/game/g_team.h
+ src/game/g_public.h
releasei386-glibc/game/g_session.o: ./src/game/g_session.c src/game/g_local.h \
src/game/q_shared.h src/game/surfaceflags.h src/game/bg_public.h \
- src/game/g_public.h src/game/g_team.h
+ src/game/g_public.h
releasei386-glibc/game/g_spawn.o: ./src/game/g_spawn.c src/game/g_local.h src/game/q_shared.h \
- src/game/surfaceflags.h src/game/bg_public.h src/game/g_public.h \
- src/game/g_team.h
+ src/game/surfaceflags.h src/game/bg_public.h src/game/g_public.h
releasei386-glibc/game/g_svcmds.o: ./src/game/g_svcmds.c src/game/g_local.h \
src/game/q_shared.h src/game/surfaceflags.h src/game/bg_public.h \
- src/game/g_public.h src/game/g_team.h
+ src/game/g_public.h
releasei386-glibc/game/g_syscalls.o: ./src/game/g_syscalls.c src/game/g_local.h \
src/game/q_shared.h src/game/surfaceflags.h src/game/bg_public.h \
- src/game/g_public.h src/game/g_team.h
+ src/game/g_public.h
releasei386-glibc/game/g_target.o: ./src/game/g_target.c src/game/g_local.h \
src/game/q_shared.h src/game/surfaceflags.h src/game/bg_public.h \
- src/game/g_public.h src/game/g_team.h
+ src/game/g_public.h
releasei386-glibc/game/g_team.o: ./src/game/g_team.c src/game/g_local.h src/game/q_shared.h \
- src/game/surfaceflags.h src/game/bg_public.h src/game/g_public.h \
- src/game/g_team.h
+ src/game/surfaceflags.h src/game/bg_public.h src/game/g_public.h
releasei386-glibc/game/g_trigger.o: ./src/game/g_trigger.c src/game/g_local.h \
src/game/q_shared.h src/game/surfaceflags.h src/game/bg_public.h \
- src/game/g_public.h src/game/g_team.h
+ src/game/g_public.h
releasei386-glibc/game/g_utils.o: ./src/game/g_utils.c src/game/g_local.h src/game/q_shared.h \
- src/game/surfaceflags.h src/game/bg_public.h src/game/g_public.h \
- src/game/g_team.h
+ src/game/surfaceflags.h src/game/bg_public.h src/game/g_public.h
releasei386-glibc/game/g_weapon.o: ./src/game/g_weapon.c src/game/g_local.h \
src/game/q_shared.h src/game/surfaceflags.h src/game/bg_public.h \
- src/game/g_public.h src/game/g_team.h
+ src/game/g_public.h
releasei386-glibc/game/q_math.o: ./src/game/q_math.c src/game/q_shared.h \
src/game/surfaceflags.h
releasei386-glibc/game/q_shared.o: ./src/game/q_shared.c src/game/q_shared.h \
@@ -84,67 +73,56 @@ debugi386-glibc/game/bg_slidemove.o: ./src/game/bg_slidemove.c src/game/q_shared
src/game/surfaceflags.h src/game/bg_public.h src/game/bg_local.h
debugi386-glibc/game/g_active.o: ./src/game/g_active.c src/game/g_local.h \
src/game/q_shared.h src/game/surfaceflags.h src/game/bg_public.h \
- src/game/g_public.h src/game/g_team.h
-debugi386-glibc/game/g_arenas.o: ./src/game/g_arenas.c src/game/g_local.h \
- src/game/q_shared.h src/game/surfaceflags.h src/game/bg_public.h \
- src/game/g_public.h src/game/g_team.h
+ src/game/g_public.h
debugi386-glibc/game/g_buildable.o: ./src/game/g_buildable.c src/game/g_local.h \
src/game/q_shared.h src/game/surfaceflags.h src/game/bg_public.h \
- src/game/g_public.h src/game/g_team.h
+ src/game/g_public.h
debugi386-glibc/game/g_client.o: ./src/game/g_client.c src/game/g_local.h \
src/game/q_shared.h src/game/surfaceflags.h src/game/bg_public.h \
- src/game/g_public.h src/game/g_team.h
+ src/game/g_public.h
debugi386-glibc/game/g_cmds.o: ./src/game/g_cmds.c src/game/g_local.h src/game/q_shared.h \
- src/game/surfaceflags.h src/game/bg_public.h src/game/g_public.h \
- src/game/g_team.h
+ src/game/surfaceflags.h src/game/bg_public.h src/game/g_public.h
debugi386-glibc/game/g_combat.o: ./src/game/g_combat.c src/game/g_local.h \
src/game/q_shared.h src/game/surfaceflags.h src/game/bg_public.h \
- src/game/g_public.h src/game/g_team.h
+ src/game/g_public.h
debugi386-glibc/game/g_main.o: ./src/game/g_main.c src/game/g_local.h src/game/q_shared.h \
- src/game/surfaceflags.h src/game/bg_public.h src/game/g_public.h \
- src/game/g_team.h
+ src/game/surfaceflags.h src/game/bg_public.h src/game/g_public.h
debugi386-glibc/game/g_mem.o: ./src/game/g_mem.c src/game/g_local.h src/game/q_shared.h \
- src/game/surfaceflags.h src/game/bg_public.h src/game/g_public.h \
- src/game/g_team.h
+ src/game/surfaceflags.h src/game/bg_public.h src/game/g_public.h
debugi386-glibc/game/g_misc.o: ./src/game/g_misc.c src/game/g_local.h src/game/q_shared.h \
- src/game/surfaceflags.h src/game/bg_public.h src/game/g_public.h \
- src/game/g_team.h
+ src/game/surfaceflags.h src/game/bg_public.h src/game/g_public.h
debugi386-glibc/game/g_missile.o: ./src/game/g_missile.c src/game/g_local.h \
src/game/q_shared.h src/game/surfaceflags.h src/game/bg_public.h \
- src/game/g_public.h src/game/g_team.h
+ src/game/g_public.h
debugi386-glibc/game/g_mover.o: ./src/game/g_mover.c src/game/g_local.h src/game/q_shared.h \
- src/game/surfaceflags.h src/game/bg_public.h src/game/g_public.h \
- src/game/g_team.h
+ src/game/surfaceflags.h src/game/bg_public.h src/game/g_public.h
debugi386-glibc/game/g_physics.o: ./src/game/g_physics.c src/game/g_local.h \
src/game/q_shared.h src/game/surfaceflags.h src/game/bg_public.h \
- src/game/g_public.h src/game/g_team.h
+ src/game/g_public.h
debugi386-glibc/game/g_session.o: ./src/game/g_session.c src/game/g_local.h \
src/game/q_shared.h src/game/surfaceflags.h src/game/bg_public.h \
- src/game/g_public.h src/game/g_team.h
+ src/game/g_public.h
debugi386-glibc/game/g_spawn.o: ./src/game/g_spawn.c src/game/g_local.h src/game/q_shared.h \
- src/game/surfaceflags.h src/game/bg_public.h src/game/g_public.h \
- src/game/g_team.h
+ src/game/surfaceflags.h src/game/bg_public.h src/game/g_public.h
debugi386-glibc/game/g_svcmds.o: ./src/game/g_svcmds.c src/game/g_local.h \
src/game/q_shared.h src/game/surfaceflags.h src/game/bg_public.h \
- src/game/g_public.h src/game/g_team.h
+ src/game/g_public.h
debugi386-glibc/game/g_syscalls.o: ./src/game/g_syscalls.c src/game/g_local.h \
src/game/q_shared.h src/game/surfaceflags.h src/game/bg_public.h \
- src/game/g_public.h src/game/g_team.h
+ src/game/g_public.h
debugi386-glibc/game/g_target.o: ./src/game/g_target.c src/game/g_local.h \
src/game/q_shared.h src/game/surfaceflags.h src/game/bg_public.h \
- src/game/g_public.h src/game/g_team.h
+ src/game/g_public.h
debugi386-glibc/game/g_team.o: ./src/game/g_team.c src/game/g_local.h src/game/q_shared.h \
- src/game/surfaceflags.h src/game/bg_public.h src/game/g_public.h \
- src/game/g_team.h
+ src/game/surfaceflags.h src/game/bg_public.h src/game/g_public.h
debugi386-glibc/game/g_trigger.o: ./src/game/g_trigger.c src/game/g_local.h \
src/game/q_shared.h src/game/surfaceflags.h src/game/bg_public.h \
- src/game/g_public.h src/game/g_team.h
+ src/game/g_public.h
debugi386-glibc/game/g_utils.o: ./src/game/g_utils.c src/game/g_local.h src/game/q_shared.h \
- src/game/surfaceflags.h src/game/bg_public.h src/game/g_public.h \
- src/game/g_team.h
+ src/game/surfaceflags.h src/game/bg_public.h src/game/g_public.h
debugi386-glibc/game/g_weapon.o: ./src/game/g_weapon.c src/game/g_local.h \
src/game/q_shared.h src/game/surfaceflags.h src/game/bg_public.h \
- src/game/g_public.h src/game/g_team.h
+ src/game/g_public.h
debugi386-glibc/game/q_math.o: ./src/game/q_math.c src/game/q_shared.h \
src/game/surfaceflags.h
debugi386-glibc/game/q_shared.o: ./src/game/q_shared.c src/game/q_shared.h \
@@ -159,67 +137,56 @@ qvm/game/bg_slidemove.asm: ./src/game/bg_slidemove.c src/game/q_shared.h \
src/game/surfaceflags.h src/game/bg_public.h src/game/bg_local.h
qvm/game/g_active.asm: ./src/game/g_active.c src/game/g_local.h \
src/game/q_shared.h src/game/surfaceflags.h src/game/bg_public.h \
- src/game/g_public.h src/game/g_team.h
-qvm/game/g_arenas.asm: ./src/game/g_arenas.c src/game/g_local.h \
- src/game/q_shared.h src/game/surfaceflags.h src/game/bg_public.h \
- src/game/g_public.h src/game/g_team.h
+ src/game/g_public.h
qvm/game/g_buildable.asm: ./src/game/g_buildable.c src/game/g_local.h \
src/game/q_shared.h src/game/surfaceflags.h src/game/bg_public.h \
- src/game/g_public.h src/game/g_team.h
+ src/game/g_public.h
qvm/game/g_client.asm: ./src/game/g_client.c src/game/g_local.h \
src/game/q_shared.h src/game/surfaceflags.h src/game/bg_public.h \
- src/game/g_public.h src/game/g_team.h
+ src/game/g_public.h
qvm/game/g_cmds.asm: ./src/game/g_cmds.c src/game/g_local.h src/game/q_shared.h \
- src/game/surfaceflags.h src/game/bg_public.h src/game/g_public.h \
- src/game/g_team.h
+ src/game/surfaceflags.h src/game/bg_public.h src/game/g_public.h
qvm/game/g_combat.asm: ./src/game/g_combat.c src/game/g_local.h \
src/game/q_shared.h src/game/surfaceflags.h src/game/bg_public.h \
- src/game/g_public.h src/game/g_team.h
+ src/game/g_public.h
qvm/game/g_main.asm: ./src/game/g_main.c src/game/g_local.h src/game/q_shared.h \
- src/game/surfaceflags.h src/game/bg_public.h src/game/g_public.h \
- src/game/g_team.h
+ src/game/surfaceflags.h src/game/bg_public.h src/game/g_public.h
qvm/game/g_mem.asm: ./src/game/g_mem.c src/game/g_local.h src/game/q_shared.h \
- src/game/surfaceflags.h src/game/bg_public.h src/game/g_public.h \
- src/game/g_team.h
+ src/game/surfaceflags.h src/game/bg_public.h src/game/g_public.h
qvm/game/g_misc.asm: ./src/game/g_misc.c src/game/g_local.h src/game/q_shared.h \
- src/game/surfaceflags.h src/game/bg_public.h src/game/g_public.h \
- src/game/g_team.h
+ src/game/surfaceflags.h src/game/bg_public.h src/game/g_public.h
qvm/game/g_missile.asm: ./src/game/g_missile.c src/game/g_local.h \
src/game/q_shared.h src/game/surfaceflags.h src/game/bg_public.h \
- src/game/g_public.h src/game/g_team.h
+ src/game/g_public.h
qvm/game/g_mover.asm: ./src/game/g_mover.c src/game/g_local.h src/game/q_shared.h \
- src/game/surfaceflags.h src/game/bg_public.h src/game/g_public.h \
- src/game/g_team.h
+ src/game/surfaceflags.h src/game/bg_public.h src/game/g_public.h
qvm/game/g_physics.asm: ./src/game/g_physics.c src/game/g_local.h \
src/game/q_shared.h src/game/surfaceflags.h src/game/bg_public.h \
- src/game/g_public.h src/game/g_team.h
+ src/game/g_public.h
qvm/game/g_session.asm: ./src/game/g_session.c src/game/g_local.h \
src/game/q_shared.h src/game/surfaceflags.h src/game/bg_public.h \
- src/game/g_public.h src/game/g_team.h
+ src/game/g_public.h
qvm/game/g_spawn.asm: ./src/game/g_spawn.c src/game/g_local.h src/game/q_shared.h \
- src/game/surfaceflags.h src/game/bg_public.h src/game/g_public.h \
- src/game/g_team.h
+ src/game/surfaceflags.h src/game/bg_public.h src/game/g_public.h
qvm/game/g_svcmds.asm: ./src/game/g_svcmds.c src/game/g_local.h \
src/game/q_shared.h src/game/surfaceflags.h src/game/bg_public.h \
- src/game/g_public.h src/game/g_team.h
+ src/game/g_public.h
qvm/game/g_syscalls.asm: ./src/game/g_syscalls.c src/game/g_local.h \
src/game/q_shared.h src/game/surfaceflags.h src/game/bg_public.h \
- src/game/g_public.h src/game/g_team.h
+ src/game/g_public.h
qvm/game/g_target.asm: ./src/game/g_target.c src/game/g_local.h \
src/game/q_shared.h src/game/surfaceflags.h src/game/bg_public.h \
- src/game/g_public.h src/game/g_team.h
+ src/game/g_public.h
qvm/game/g_team.asm: ./src/game/g_team.c src/game/g_local.h src/game/q_shared.h \
- src/game/surfaceflags.h src/game/bg_public.h src/game/g_public.h \
- src/game/g_team.h
+ src/game/surfaceflags.h src/game/bg_public.h src/game/g_public.h
qvm/game/g_trigger.asm: ./src/game/g_trigger.c src/game/g_local.h \
src/game/q_shared.h src/game/surfaceflags.h src/game/bg_public.h \
- src/game/g_public.h src/game/g_team.h
+ src/game/g_public.h
qvm/game/g_utils.asm: ./src/game/g_utils.c src/game/g_local.h src/game/q_shared.h \
- src/game/surfaceflags.h src/game/bg_public.h src/game/g_public.h \
- src/game/g_team.h
+ src/game/surfaceflags.h src/game/bg_public.h src/game/g_public.h
qvm/game/g_weapon.asm: ./src/game/g_weapon.c src/game/g_local.h \
src/game/q_shared.h src/game/surfaceflags.h src/game/bg_public.h \
- src/game/g_public.h src/game/g_team.h
+ src/game/g_public.h
qvm/game/q_math.asm: ./src/game/q_math.c src/game/q_shared.h \
src/game/surfaceflags.h
qvm/game/q_shared.asm: ./src/game/q_shared.c src/game/q_shared.h \
@@ -350,13 +317,6 @@ releasei386-glibc/cgame/cg_scanner.o: ./src/cgame/cg_scanner.c src/cgame/cg_loca
src/cgame/../ui/../game/q_shared.h \
src/cgame/../ui/../cgame/tr_types.h src/cgame/../ui/keycodes.h \
src/cgame/../ui/../../ui/menudef.h
-releasei386-glibc/cgame/cg_scoreboard.o: ./src/cgame/cg_scoreboard.c src/cgame/cg_local.h \
- src/cgame/../game/q_shared.h src/cgame/../game/surfaceflags.h \
- src/cgame/tr_types.h src/cgame/../game/bg_public.h \
- src/cgame/cg_public.h src/cgame/../ui/ui_shared.h \
- src/cgame/../ui/../game/q_shared.h \
- src/cgame/../ui/../cgame/tr_types.h src/cgame/../ui/keycodes.h \
- src/cgame/../ui/../../ui/menudef.h
releasei386-glibc/cgame/cg_servercmds.o: ./src/cgame/cg_servercmds.c src/cgame/cg_local.h \
src/cgame/../game/q_shared.h src/cgame/../game/surfaceflags.h \
src/cgame/tr_types.h src/cgame/../game/bg_public.h \
@@ -532,13 +492,6 @@ debugi386-glibc/cgame/cg_scanner.o: ./src/cgame/cg_scanner.c src/cgame/cg_local.
src/cgame/../ui/../game/q_shared.h \
src/cgame/../ui/../cgame/tr_types.h src/cgame/../ui/keycodes.h \
src/cgame/../ui/../../ui/menudef.h
-debugi386-glibc/cgame/cg_scoreboard.o: ./src/cgame/cg_scoreboard.c src/cgame/cg_local.h \
- src/cgame/../game/q_shared.h src/cgame/../game/surfaceflags.h \
- src/cgame/tr_types.h src/cgame/../game/bg_public.h \
- src/cgame/cg_public.h src/cgame/../ui/ui_shared.h \
- src/cgame/../ui/../game/q_shared.h \
- src/cgame/../ui/../cgame/tr_types.h src/cgame/../ui/keycodes.h \
- src/cgame/../ui/../../ui/menudef.h
debugi386-glibc/cgame/cg_servercmds.o: ./src/cgame/cg_servercmds.c src/cgame/cg_local.h \
src/cgame/../game/q_shared.h src/cgame/../game/surfaceflags.h \
src/cgame/tr_types.h src/cgame/../game/bg_public.h \
@@ -714,13 +667,6 @@ qvm/cgame/cg_scanner.asm: ./src/cgame/cg_scanner.c src/cgame/cg_local.h \
src/cgame/../ui/../game/q_shared.h \
src/cgame/../ui/../cgame/tr_types.h src/cgame/../ui/keycodes.h \
src/cgame/../ui/../../ui/menudef.h
-qvm/cgame/cg_scoreboard.asm: ./src/cgame/cg_scoreboard.c src/cgame/cg_local.h \
- src/cgame/../game/q_shared.h src/cgame/../game/surfaceflags.h \
- src/cgame/tr_types.h src/cgame/../game/bg_public.h \
- src/cgame/cg_public.h src/cgame/../ui/ui_shared.h \
- src/cgame/../ui/../game/q_shared.h \
- src/cgame/../ui/../cgame/tr_types.h src/cgame/../ui/keycodes.h \
- src/cgame/../ui/../../ui/menudef.h
qvm/cgame/cg_servercmds.asm: ./src/cgame/cg_servercmds.c src/cgame/cg_local.h \
src/cgame/../game/q_shared.h src/cgame/../game/surfaceflags.h \
src/cgame/tr_types.h src/cgame/../game/bg_public.h \
diff --git a/src/cgame/cg_animmapobj.c b/src/cgame/cg_animmapobj.c
index d911604a..c7218b00 100644
--- a/src/cgame/cg_animmapobj.c
+++ b/src/cgame/cg_animmapobj.c
@@ -27,74 +27,77 @@ static void CG_RunAMOLerpFrame( lerpFrame_t *lf )
animation_t *anim;
// debugging tool to get no animations
- if ( cg_animSpeed.integer == 0 ) {
+ if( cg_animSpeed.integer == 0 )
+ {
lf->oldFrame = lf->frame = lf->backlerp = 0;
return;
}
// if we have passed the current frame, move it to
// oldFrame and calculate a new frame
- if ( cg.time >= lf->frameTime ) {
+ if( cg.time >= lf->frameTime )
+ {
lf->oldFrame = lf->frame;
lf->oldFrameTime = lf->frameTime;
// get the next frame based on the animation
anim = lf->animation;
- if ( !anim->frameLerp ) {
+ if( !anim->frameLerp )
return; // shouldn't happen
- }
- if ( cg.time < lf->animationTime ) {
+
+ if( cg.time < lf->animationTime )
lf->frameTime = lf->animationTime; // initial lerp
- } else {
+ else
lf->frameTime = lf->oldFrameTime + anim->frameLerp;
- }
+
f = ( lf->frameTime - lf->animationTime ) / anim->frameLerp;
numFrames = anim->numFrames;
- if (anim->flipflop) {
+ if( anim->flipflop )
numFrames *= 2;
- }
- if ( f >= numFrames ) {
+
+ if( f >= numFrames )
+ {
f -= numFrames;
- if ( anim->loopFrames ) {
+ if( anim->loopFrames )
+ {
f %= anim->loopFrames;
f += anim->numFrames - anim->loopFrames;
- } else {
+ }
+ else
+ {
f = numFrames - 1;
// the animation is stuck at the end, so it
// can immediately transition to another sequence
lf->frameTime = cg.time;
}
}
- if ( anim->reversed ) {
+
+ if( anim->reversed )
lf->frame = anim->firstFrame + anim->numFrames - 1 - f;
- }
- else if (anim->flipflop && f>=anim->numFrames) {
- lf->frame = anim->firstFrame + anim->numFrames - 1 - (f%anim->numFrames);
- }
- else {
+ else if( anim->flipflop && f>=anim->numFrames )
+ lf->frame = anim->firstFrame + anim->numFrames - 1 - ( f % anim->numFrames );
+ else
lf->frame = anim->firstFrame + f;
- }
- if ( cg.time > lf->frameTime ) {
+
+ if( cg.time > lf->frameTime )
+ {
lf->frameTime = cg.time;
- if ( cg_debugAnim.integer ) {
- CG_Printf( "Clamp lf->frameTime\n");
- }
+ if( cg_debugAnim.integer )
+ CG_Printf( "Clamp lf->frameTime\n" );
}
}
- if ( lf->frameTime > cg.time + 200 ) {
+ if( lf->frameTime > cg.time + 200 )
lf->frameTime = cg.time;
- }
- if ( lf->oldFrameTime > cg.time ) {
+ if( lf->oldFrameTime > cg.time )
lf->oldFrameTime = cg.time;
- }
+
// calculate current lerp value
- if ( lf->frameTime == lf->oldFrameTime ) {
+ if( lf->frameTime == lf->oldFrameTime )
lf->backlerp = 0;
- } else {
+ else
lf->backlerp = 1.0 - (float)( cg.time - lf->oldFrameTime ) / ( lf->frameTime - lf->oldFrameTime );
- }
}
@@ -160,9 +163,9 @@ void CG_animMapObj( centity_t *cent )
if( es->angles2[ 0 ] )
{
scale = es->angles2[ 0 ];
- VectorScale( ent.axis[0], scale, ent.axis[0] );
- VectorScale( ent.axis[1], scale, ent.axis[1] );
- VectorScale( ent.axis[2], scale, ent.axis[2] );
+ VectorScale( ent.axis[ 0 ], scale, ent.axis[ 0 ] );
+ VectorScale( ent.axis[ 1 ], scale, ent.axis[ 1 ] );
+ VectorScale( ent.axis[ 2 ], scale, ent.axis[ 2 ] );
ent.nonNormalizedAxes = qtrue;
}
diff --git a/src/cgame/cg_buildable.c b/src/cgame/cg_buildable.c
index 4c5e13ec..90cb2e76 100644
--- a/src/cgame/cg_buildable.c
+++ b/src/cgame/cg_buildable.c
@@ -44,14 +44,14 @@ models/buildables/hivemind/animation.cfg, etc
*/
static qboolean CG_ParseBuildableAnimationFile( const char *filename, buildable_t buildable )
{
- char *text_p, *prev;
- int len;
- int i;
- char *token;
- float fps;
- char text[ 20000 ];
+ char *text_p, *prev;
+ int len;
+ int i;
+ char *token;
+ float fps;
+ char text[ 20000 ];
fileHandle_t f;
- animation_t *animations;
+ animation_t *animations;
animations = cg_buildables[ buildable ].animations;
@@ -135,13 +135,13 @@ sound/buildables/hivemind/sound.cfg, etc
*/
static qboolean CG_ParseBuildableSoundFile( const char *filename, buildable_t buildable )
{
- char *text_p, *prev;
- int len;
- int i;
- char *token;
- char text[ 20000 ];
+ char *text_p, *prev;
+ int len;
+ int i;
+ char *token;
+ char text[ 20000 ];
fileHandle_t f;
- sound_t *sounds;
+ sound_t *sounds;
sounds = cg_buildables[ buildable ].sounds;
@@ -198,12 +198,12 @@ Initialises the animation db
*/
void CG_InitBuildables( )
{
- char filename[ MAX_QPATH ];
- char soundfile[ MAX_QPATH ];
- char *buildableName;
- char *modelFile;
- int i;
- int j;
+ char filename[ MAX_QPATH ];
+ char soundfile[ MAX_QPATH ];
+ char *buildableName;
+ char *modelFile;
+ int i;
+ int j;
fileHandle_t f;
memset( cg_buildables, 0, sizeof( cg_buildables ) );
diff --git a/src/cgame/cg_consolecmds.c b/src/cgame/cg_consolecmds.c
index c53ee166..43c78675 100644
--- a/src/cgame/cg_consolecmds.c
+++ b/src/cgame/cg_consolecmds.c
@@ -20,14 +20,14 @@
-void CG_TargetCommand_f( void ) {
+void CG_TargetCommand_f( void )
+{
int targetNum;
- char test[4];
+ char test[ 4 ];
- targetNum = CG_CrosshairPlayer();
- if (!targetNum ) {
+ targetNum = CG_CrosshairPlayer( );
+ if( !targetNum )
return;
- }
trap_Argv( 1, test, 4 );
trap_SendConsoleCommand( va( "gc %i %i", targetNum, atoi( test ) ) );
@@ -42,8 +42,9 @@ CG_SizeUp_f
Keybinding command
=================
*/
-static void CG_SizeUp_f (void) {
- trap_Cvar_Set("cg_viewsize", va("%i",(int)(cg_viewsize.integer+10)));
+static void CG_SizeUp_f( void )
+{
+ trap_Cvar_Set( "cg_viewsize", va( "%i", (int)( cg_viewsize.integer + 10 ) ) );
}
@@ -54,8 +55,9 @@ CG_SizeDown_f
Keybinding command
=================
*/
-static void CG_SizeDown_f (void) {
- trap_Cvar_Set("cg_viewsize", va("%i",(int)(cg_viewsize.integer-10)));
+static void CG_SizeDown_f( void )
+{
+ trap_Cvar_Set( "cg_viewsize", va( "%i", (int)( cg_viewsize.integer - 10 ) ) );
}
@@ -66,15 +68,18 @@ CG_Viewpos_f
Debugging command to print the current position
=============
*/
-static void CG_Viewpos_f (void) {
- CG_Printf ("(%i %i %i) : %i\n", (int)cg.refdef.vieworg[0],
- (int)cg.refdef.vieworg[1], (int)cg.refdef.vieworg[2],
- (int)cg.refdefViewAngles[YAW]);
+static void CG_Viewpos_f( void )
+{
+ CG_Printf( "(%i %i %i) : %i\n", (int)cg.refdef.vieworg[ 0 ],
+ (int)cg.refdef.vieworg[ 1 ], (int)cg.refdef.vieworg[ 2 ],
+ (int)cg.refdefViewAngles[ YAW ] );
}
-static void CG_ScoresDown_f( void ) {
- if ( cg.scoresRequestTime + 2000 < cg.time ) {
+static void CG_ScoresDown_f( void )
+{
+ if( cg.scoresRequestTime + 2000 < cg.time )
+ {
// the scores are more than two seconds out of data,
// so request new ones
cg.scoresRequestTime = cg.time;
@@ -82,108 +87,59 @@ static void CG_ScoresDown_f( void ) {
// leave the current scores up if they were already
// displayed, but if this is the first hit, clear them out
- if ( !cg.showScores ) {
+ if( !cg.showScores )
+ {
cg.showScores = qtrue;
cg.numScores = 0;
}
- } else {
+ }
+ else
+ {
// show the cached contents even if they just pressed if it
// is within two seconds
cg.showScores = qtrue;
}
}
-static void CG_ScoresUp_f( void ) {
- if ( cg.showScores ) {
+static void CG_ScoresUp_f( void )
+{
+ if( cg.showScores )
+ {
cg.showScores = qfalse;
cg.scoreFadeTime = cg.time;
}
}
-static void CG_TellTarget_f( void ) {
+static void CG_TellTarget_f( void )
+{
int clientNum;
- char command[128];
- char message[128];
+ char command[ 128 ];
+ char message[ 128 ];
- clientNum = CG_CrosshairPlayer();
- if ( clientNum == -1 ) {
+ clientNum = CG_CrosshairPlayer( );
+ if( clientNum == -1 )
return;
- }
trap_Args( message, 128 );
Com_sprintf( command, 128, "tell %i %s", clientNum, message );
trap_SendClientCommand( command );
}
-static void CG_TellAttacker_f( void ) {
+static void CG_TellAttacker_f( void )
+{
int clientNum;
- char command[128];
- char message[128];
+ char command[ 128 ];
+ char message[ 128 ];
- clientNum = CG_LastAttacker();
- if ( clientNum == -1 ) {
+ clientNum = CG_LastAttacker( );
+ if( clientNum == -1 )
return;
- }
trap_Args( message, 128 );
Com_sprintf( command, 128, "tell %i %s", clientNum, message );
trap_SendClientCommand( command );
}
-static void CG_VoiceTellTarget_f( void ) {
- int clientNum;
- char command[128];
- char message[128];
-
- clientNum = CG_CrosshairPlayer();
- if ( clientNum == -1 ) {
- return;
- }
-
- trap_Args( message, 128 );
- Com_sprintf( command, 128, "vtell %i %s", clientNum, message );
- trap_SendClientCommand( command );
-}
-
-static void CG_VoiceTellAttacker_f( void ) {
- int clientNum;
- char command[128];
- char message[128];
-
- clientNum = CG_LastAttacker();
- if ( clientNum == -1 ) {
- return;
- }
-
- trap_Args( message, 128 );
- Com_sprintf( command, 128, "vtell %i %s", clientNum, message );
- trap_SendClientCommand( command );
-}
-
-/*
-==================
-CG_StartOrbit_f
-==================
-*/
-
-static void CG_StartOrbit_f( void ) {
- char var[MAX_TOKEN_CHARS];
-
- trap_Cvar_VariableStringBuffer( "developer", var, sizeof( var ) );
- if ( !atoi(var) ) {
- return;
- }
- if (cg_cameraOrbit.value != 0) {
- trap_Cvar_Set("cg_cameraOrbit", "0");
- trap_Cvar_Set("cg_thirdPerson", "0");
- } else {
- trap_Cvar_Set("cg_cameraOrbit", "5");
- trap_Cvar_Set("cg_thirdPerson", "1");
- trap_Cvar_Set("cg_thirdPersonAngle", "0");
- trap_Cvar_Set("cg_thirdPersonRange", "100");
- }
-}
-
/*
==================
CG_DecodeMP3_f
@@ -194,7 +150,7 @@ void CG_DecodeMP3_f( void )
char mp3file[ MAX_QPATH ];
char wavfile[ MAX_QPATH ];
- if( trap_Argc() < 2 )
+ if( trap_Argc( ) < 2 )
{
CG_Printf( "usage: decodeMP3 <mp3file> <wavfile>\n" );
return;
@@ -206,12 +162,14 @@ void CG_DecodeMP3_f( void )
S_decodeMP3( mp3file, wavfile );
}
-typedef struct {
+typedef struct
+{
char *cmd;
- void (*function)(void);
+ void (*function)( void );
} consoleCommand_t;
-static consoleCommand_t commands[] = {
+static consoleCommand_t commands[ ] =
+{
{ "testgun", CG_TestGun_f },
{ "testmodel", CG_TestModel_f },
{ "nextframe", CG_TestModelNextFrame_f },
@@ -230,10 +188,7 @@ static consoleCommand_t commands[] = {
{ "weapon", CG_Weapon_f },
{ "tell_target", CG_TellTarget_f },
{ "tell_attacker", CG_TellAttacker_f },
- { "vtell_target", CG_VoiceTellTarget_f },
- { "vtell_attacker", CG_VoiceTellAttacker_f },
{ "tcmd", CG_TargetCommand_f },
- { "startOrbit", CG_StartOrbit_f },
{ "decodeMP3", CG_DecodeMP3_f },
{ "loaddeferred", CG_LoadDeferredPlayers }
};
@@ -247,12 +202,13 @@ The string has been tokenized and can be retrieved with
Cmd_Argc() / Cmd_Argv()
=================
*/
-qboolean CG_ConsoleCommand( void ) {
+qboolean CG_ConsoleCommand( void )
+{
const char *cmd;
const char *arg1;
- int i;
+ int i;
- cmd = CG_Argv(0);
+ cmd = CG_Argv( 0 );
//TA: ugly hacky special case
if( !Q_stricmp( cmd, "ui_menu" ) )
@@ -262,9 +218,11 @@ qboolean CG_ConsoleCommand( void ) {
return qtrue;
}
- for ( i = 0 ; i < sizeof( commands ) / sizeof( commands[0] ) ; i++ ) {
- if ( !Q_stricmp( cmd, commands[i].cmd ) ) {
- commands[i].function();
+ for( i = 0; i < sizeof( commands ) / sizeof( commands[ 0 ] ); i++ )
+ {
+ if( !Q_stricmp( cmd, commands[ i ].cmd ) )
+ {
+ commands[ i ].function( );
return qtrue;
}
}
@@ -281,57 +239,56 @@ Let the client system know about all of our commands
so it can perform tab completion
=================
*/
-void CG_InitConsoleCommands( void ) {
+void CG_InitConsoleCommands( void )
+{
int i;
- for ( i = 0 ; i < sizeof( commands ) / sizeof( commands[0] ) ; i++ ) {
- trap_AddCommand( commands[i].cmd );
- }
+ for( i = 0 ; i < sizeof( commands ) / sizeof( commands[ 0 ] ) ; i++ )
+ trap_AddCommand( commands[ i ].cmd );
//
// the game server will interpret these commands, which will be automatically
// forwarded to the server after they are not recognized locally
//
- trap_AddCommand ("kill");
- trap_AddCommand ("say");
- trap_AddCommand ("say_team");
- trap_AddCommand ("tell");
- trap_AddCommand ("vsay");
- trap_AddCommand ("vsay_team");
- trap_AddCommand ("vtell");
- trap_AddCommand ("vtaunt");
- trap_AddCommand ("vosay");
- trap_AddCommand ("vosay_team");
- trap_AddCommand ("votell");
- trap_AddCommand ("give");
- trap_AddCommand ("god");
- trap_AddCommand ("notarget");
- trap_AddCommand ("noclip");
- trap_AddCommand ("team");
- trap_AddCommand ("follow");
- trap_AddCommand ("levelshot");
- trap_AddCommand ("addbot");
- trap_AddCommand ("setviewpos");
- trap_AddCommand ("callvote");
- trap_AddCommand ("vote");
- trap_AddCommand ("callteamvote");
- trap_AddCommand ("teamvote");
- trap_AddCommand ("stats");
- trap_AddCommand ("teamtask");
- trap_AddCommand ("class");
- trap_AddCommand ("build");
- trap_AddCommand ("buy");
- trap_AddCommand ("sell");
- trap_AddCommand ("deposit");
- trap_AddCommand ("withdraw");
- trap_AddCommand ("spawnbody");
- trap_AddCommand ("itemact");
- trap_AddCommand ("itemdeact");
- trap_AddCommand ("itemtoggle");
- trap_AddCommand ("destroy");
- trap_AddCommand ("deconstruct");
- trap_AddCommand ("torch");
- trap_AddCommand ("menu");
- trap_AddCommand ("ui_menu");
- trap_AddCommand ("loaddefered"); // spelled wrong, but not changing for demo
+ trap_AddCommand( "kill" );
+ trap_AddCommand( "say" );
+ trap_AddCommand( "say_team" );
+ trap_AddCommand( "tell" );
+ trap_AddCommand( "vsay" );
+ trap_AddCommand( "vsay_team" );
+ trap_AddCommand( "vtell" );
+ trap_AddCommand( "vtaunt" );
+ trap_AddCommand( "vosay" );
+ trap_AddCommand( "vosay_team" );
+ trap_AddCommand( "votell" );
+ trap_AddCommand( "give" );
+ trap_AddCommand( "god" );
+ trap_AddCommand( "notarget" );
+ trap_AddCommand( "noclip" );
+ trap_AddCommand( "team" );
+ trap_AddCommand( "follow" );
+ trap_AddCommand( "levelshot" );
+ trap_AddCommand( "addbot" );
+ trap_AddCommand( "setviewpos" );
+ trap_AddCommand( "callvote" );
+ trap_AddCommand( "vote" );
+ trap_AddCommand( "callteamvote" );
+ trap_AddCommand( "teamvote" );
+ trap_AddCommand( "stats" );
+ trap_AddCommand( "teamtask" );
+ trap_AddCommand( "class" );
+ trap_AddCommand( "build" );
+ trap_AddCommand( "buy" );
+ trap_AddCommand( "sell" );
+ trap_AddCommand( "deposit" );
+ trap_AddCommand( "withdraw" );
+ trap_AddCommand( "spawnbody" );
+ trap_AddCommand( "itemact" );
+ trap_AddCommand( "itemdeact" );
+ trap_AddCommand( "itemtoggle" );
+ trap_AddCommand( "destroy" );
+ trap_AddCommand( "deconstruct" );
+ trap_AddCommand( "menu" );
+ trap_AddCommand( "ui_menu" );
+ trap_AddCommand( "loaddefered" ); // spelled wrong, but not changing for demo
}
diff --git a/src/cgame/cg_draw.c b/src/cgame/cg_draw.c
index 7b77489a..3938aa4a 100644
--- a/src/cgame/cg_draw.c
+++ b/src/cgame/cg_draw.c
@@ -27,9 +27,9 @@ int drawTeamOverlayModificationCount = -1;
int sortedTeamPlayers[TEAM_MAXOVERLAY];
int numSortedTeamPlayers;
-char systemChat[256];
-char teamChat1[256];
-char teamChat2[256];
+char systemChat[ 256 ];
+char teamChat1[ 256 ];
+char teamChat2[ 256 ];
//TA UI
int CG_Text_Width( const char *text, float scale, int limit )
@@ -881,8 +881,8 @@ static void CG_DrawKiller( rectDef_t *rect, float scale, vec4_t color,
static void CG_Text_Paint_Limit( float *maxX, float x, float y, float scale,
vec4_t color, const char* text, float adjust, int limit )
{
- int len, count;
- vec4_t newColor;
+ int len, count;
+ vec4_t newColor;
glyphInfo_t *glyph;
if( text )
@@ -1219,11 +1219,11 @@ LAGOMETER
typedef struct
{
- int frameSamples[ LAG_SAMPLES ];
- int frameCount;
- int snapshotFlags[ LAG_SAMPLES ];
- int snapshotSamples[ LAG_SAMPLES ];
- int snapshotCount;
+ int frameSamples[ LAG_SAMPLES ];
+ int frameCount;
+ int snapshotFlags[ LAG_SAMPLES ];
+ int snapshotSamples[ LAG_SAMPLES ];
+ int snapshotCount;
} lagometer_t;
lagometer_t lagometer;
@@ -1319,11 +1319,12 @@ CG_DrawLagometer
*/
static void CG_DrawLagometer( rectDef_t *rect, qhandle_t shader )
{
- int a, x, y, i;
- float v;
- float ax, ay, aw, ah, mid, range;
- int color;
- float vscale;
+ int a, x, y, i;
+ float v;
+ float ax, ay, aw, ah, mid, range;
+ int color;
+ float vscale;
+ vec4_t white = { 1.0f, 1.0f, 1.0f, 1.0f };
if( !cg_lagometer.integer )
{
@@ -1437,9 +1438,9 @@ static void CG_DrawLagometer( rectDef_t *rect, qhandle_t shader )
trap_R_SetColor( NULL );
if( cg_nopredict.integer || cg_synchronousClients.integer )
- CG_DrawBigString( ax, ay, "snc", 1.0 );
+ CG_Text_Paint( ax, ay, 0.5, white, "snc", 0, 0, ITEM_TEXTSTYLE_NORMAL );
- CG_DrawDisconnect();
+ CG_DrawDisconnect( );
}
/*
@@ -1678,7 +1679,7 @@ CG_ShowTeamMenus
*/
void CG_ShowTeamMenu( )
{
- Menus_OpenByName("teamMenu");
+ Menus_OpenByName( "teamMenu" );
}
/*
@@ -1695,24 +1696,14 @@ void CG_EventHandling( int type )
cgs.eventHandling = type;
if( type == CGAME_EVENT_NONE )
- {
CG_HideTeamMenu( );
- }
- else if( type == CGAME_EVENT_TEAMMENU )
- {
- //CG_ShowTeamMenu();
- }
- else if( type == CGAME_EVENT_SCOREBOARD )
- {
-
- }
}
void CG_KeyEvent( int key, qboolean down )
{
- if( !down)
+ if( !down )
return;
if( cg.predictedPlayerState.pm_type == PM_NORMAL ||
@@ -1727,9 +1718,7 @@ void CG_KeyEvent( int key, qboolean down )
Display_HandleKey( key, down, cgs.cursorX, cgs.cursorY );
if( cgs.capturedItem )
- {
cgs.capturedItem = NULL;
- }
else
{
if( key == K_MOUSE2 && down )
@@ -1763,11 +1752,11 @@ void CG_RunMenuScript( char **args )
}
-void CG_GetTeamColor(vec4_t *color)
+void CG_GetTeamColor( vec4_t *color )
{
- (*color)[0] = (*color)[2] = 0.0f;
- (*color)[1] = 0.17f;
- (*color)[3] = 0.25f;
+ (*color)[ 0 ] = (*color)[ 2 ] = 0.0f;
+ (*color)[ 1 ] = 0.17f;
+ (*color)[ 3 ] = 0.25f;
}
//END TA UI
@@ -1782,7 +1771,7 @@ static void CG_DrawLighting( void )
{
centity_t *cent;
- cent = &cg_entities[cg.snap->ps.clientNum];
+ cent = &cg_entities[ cg.snap->ps.clientNum ];
//fade to black if stamina is low
if( ( cg.snap->ps.stats[ STAT_STAMINA ] < -800 ) &&
@@ -1797,16 +1786,6 @@ static void CG_DrawLighting( void )
}
/*
-===========================================================================================
-
- LOWER RIGHT CORNER
-
-===========================================================================================
-*/
-
-
-
-/*
===============================================================================
CENTER PRINTING
@@ -2059,8 +2038,9 @@ CG_DrawVote
*/
static void CG_DrawVote( void )
{
- char *s;
- int sec;
+ char *s;
+ int sec;
+ vec4_t white = { 1.0f, 1.0f, 1.0f, 1.0f };
if( !cgs.voteTime )
return;
@@ -2078,9 +2058,9 @@ static void CG_DrawVote( void )
sec = 0;
s = va( "VOTE(%i):%s yes:%i no:%i", sec, cgs.voteString, cgs.voteYes, cgs.voteNo );
- CG_DrawSmallString( 0, 58, s, 1.0F );
+ CG_Text_Paint( 0, 58, 0.3f, white, s, 0, 0, ITEM_TEXTSTYLE_NORMAL );
s = "or press ESC then click Vote";
- CG_DrawSmallString( 0, 58 + SMALLCHAR_HEIGHT + 2, s, 1.0F );
+ CG_Text_Paint( 0, 78, 0.3f, white, s, 0, 0, ITEM_TEXTSTYLE_NORMAL );
}
/*
@@ -2090,8 +2070,9 @@ CG_DrawTeamVote
*/
static void CG_DrawTeamVote( void )
{
- char *s;
- int sec, cs_offset;
+ char *s;
+ int sec, cs_offset;
+ vec4_t white = { 1.0f, 1.0f, 1.0f, 1.0f };
if( cg.predictedPlayerState.stats[ STAT_PTEAM ] == PTE_HUMANS )
cs_offset = 0;
@@ -2118,7 +2099,7 @@ static void CG_DrawTeamVote( void )
s = va( "TEAMVOTE(%i):%s yes:%i no:%i", sec, cgs.teamVoteString[ cs_offset ],
cgs.teamVoteYes[cs_offset], cgs.teamVoteNo[ cs_offset ] );
- CG_DrawSmallString( 0, 90, s, 1.0F );
+ CG_Text_Paint( 0, 90, 0.3f, white, s, 0, 0, ITEM_TEXTSTYLE_NORMAL );
}
@@ -2180,67 +2161,6 @@ static void CG_DrawIntermission( void )
cg.scoreBoardShowing = CG_DrawScoreboard( );
}
-/*
-=================
-CG_DrawFollow
-=================
-*/
-static qboolean CG_DrawFollow( void )
-{
- float x;
- vec4_t color;
- const char *name;
-
- if( !( cg.snap->ps.pm_flags & PMF_FOLLOW ) )
- return qfalse;
-
- color[ 0 ] = 1;
- color[ 1 ] = 1;
- color[ 2 ] = 1;
- color[ 3 ] = 1;
-
-
- CG_DrawBigString( 320 - 9 * 8, 24, "following", 1.0F );
-
- name = cgs.clientinfo[ cg.snap->ps.clientNum ].name;
-
- x = 0.5 * ( 640 - GIANT_WIDTH * CG_DrawStrlen( name ) );
-
- CG_DrawStringExt( x, 40, name, color, qtrue, qtrue, GIANT_WIDTH, GIANT_HEIGHT, 0 );
-
- return qtrue;
-}
-
-
-
-/*
-=================
-CG_DrawAmmoWarning
-=================
-*/
-static void CG_DrawAmmoWarning( void )
-{
- const char *s;
- int w;
-
- if( cg.snap->ps.weapon == WP_NONE )
- return;
-
- if ( cg_drawAmmoWarning.integer == 0 )
- return;
-
- if ( !cg.lowAmmoWarning )
- return;
-
- if ( cg.lowAmmoWarning == 2 )
- s = "OUT OF AMMO";
- else
- s = "LOW AMMO WARNING";
-
- w = CG_DrawStrlen( s ) * BIGCHAR_WIDTH;
- CG_DrawBigString( 320 - w / 2, 64, s, 1.0F );
-}
-
//==================================================================================
#define SPECTATOR_STRING "SPECTATOR"
@@ -2291,7 +2211,6 @@ static void CG_Draw2D( void )
if( cg_drawStatus.integer )
Menu_Paint( menu, qtrue );
- CG_DrawAmmoWarning( );
CG_DrawCrosshair( );
if( BG_gotItem( UP_HELMET, cg.snap->ps.stats ) )
diff --git a/src/cgame/cg_drawtools.c b/src/cgame/cg_drawtools.c
index 6cc0b74f..31f7f2e3 100644
--- a/src/cgame/cg_drawtools.c
+++ b/src/cgame/cg_drawtools.c
@@ -75,7 +75,8 @@ CG_AdjustFrom640
Adjusted for resolution and screen aspect ratio
================
*/
-void CG_AdjustFrom640( float *x, float *y, float *w, float *h ) {
+void CG_AdjustFrom640( float *x, float *y, float *w, float *h )
+{
#if 0
// adjust for wide screens
if ( cgs.glconfig.vidWidth * 480 > cgs.glconfig.vidHeight * 640 ) {
@@ -96,7 +97,8 @@ CG_FillRect
Coordinates are 640*480 virtual values
=================
*/
-void CG_FillRect( float x, float y, float width, float height, const float *color ) {
+void CG_FillRect( float x, float y, float width, float height, const float *color )
+{
trap_R_SetColor( color );
CG_AdjustFrom640( &x, &y, &width, &height );
@@ -113,14 +115,16 @@ CG_DrawSides
Coords are virtual 640x480
================
*/
-void CG_DrawSides(float x, float y, float w, float h, float size) {
+void CG_DrawSides( float x, float y, float w, float h, float size )
+{
CG_AdjustFrom640( &x, &y, &w, &h );
size *= cgs.screenXScale;
trap_R_DrawStretchPic( x, y, size, h, 0, 0, 0, 0, cgs.media.whiteShader );
trap_R_DrawStretchPic( x + w - size, y, size, h, 0, 0, 0, 0, cgs.media.whiteShader );
}
-void CG_DrawTopBottom(float x, float y, float w, float h, float size) {
+void CG_DrawTopBottom( float x, float y, float w, float h, float size )
+{
CG_AdjustFrom640( &x, &y, &w, &h );
size *= cgs.screenYScale;
trap_R_DrawStretchPic( x, y, w, size, 0, 0, 0, 0, cgs.media.whiteShader );
@@ -135,11 +139,12 @@ CG_DrawRect
Coordinates are 640*480 virtual values
=================
*/
-void CG_DrawRect( float x, float y, float width, float height, float size, const float *color ) {
+void CG_DrawRect( float x, float y, float width, float height, float size, const float *color )
+{
trap_R_SetColor( color );
- CG_DrawTopBottom(x, y, width, height, size);
- CG_DrawSides(x, y, width, height, size);
+ CG_DrawTopBottom( x, y, width, height, size );
+ CG_DrawSides( x, y, width, height, size );
trap_R_SetColor( NULL );
}
@@ -152,7 +157,8 @@ CG_DrawPic
Coordinates are 640*480 virtual values
=================
*/
-void CG_DrawPic( float x, float y, float width, float height, qhandle_t hShader ) {
+void CG_DrawPic( float x, float y, float width, float height, qhandle_t hShader )
+{
CG_AdjustFrom640( &x, &y, &width, &height );
trap_R_DrawStretchPic( x, y, width, height, 0, 0, 1, 1, hShader );
}
@@ -166,7 +172,8 @@ CG_DrawFadePic
Coordinates are 640*480 virtual values
=================
*/
-void CG_DrawFadePic( float x, float y, float width, float height, vec4_t fcolor, vec4_t tcolor, float amount, qhandle_t hShader )
+void CG_DrawFadePic( float x, float y, float width, float height, vec4_t fcolor,
+ vec4_t tcolor, float amount, qhandle_t hShader )
{
vec4_t finalcolor;
float inverse;
@@ -175,143 +182,16 @@ void CG_DrawFadePic( float x, float y, float width, float height, vec4_t fcolor,
CG_AdjustFrom640( &x, &y, &width, &height );
- finalcolor[0] = ( ( inverse * fcolor[0] ) + ( amount * tcolor[0] ) ) / 100;
- finalcolor[1] = ( ( inverse * fcolor[1] ) + ( amount * tcolor[1] ) ) / 100;
- finalcolor[2] = ( ( inverse * fcolor[2] ) + ( amount * tcolor[2] ) ) / 100;
- finalcolor[3] = ( ( inverse * fcolor[3] ) + ( amount * tcolor[3] ) ) / 100;
+ finalcolor[ 0 ] = ( ( inverse * fcolor[ 0 ] ) + ( amount * tcolor[ 0 ] ) ) / 100;
+ finalcolor[ 1 ] = ( ( inverse * fcolor[ 1 ] ) + ( amount * tcolor[ 1 ] ) ) / 100;
+ finalcolor[ 2 ] = ( ( inverse * fcolor[ 2 ] ) + ( amount * tcolor[ 2 ] ) ) / 100;
+ finalcolor[ 3 ] = ( ( inverse * fcolor[ 3 ] ) + ( amount * tcolor[ 3 ] ) ) / 100;
trap_R_SetColor( finalcolor );
trap_R_DrawStretchPic( x, y, width, height, 0, 0, 1, 1, hShader );
trap_R_SetColor( NULL );
}
-
-/*
-===============
-CG_DrawChar
-
-Coordinates and size in 640*480 virtual screen size
-===============
-*/
-void CG_DrawChar( int x, int y, int width, int height, int ch ) {
- int row, col;
- float frow, fcol;
- float size;
- float ax, ay, aw, ah;
-
- ch &= 255;
-
- if ( ch == ' ' ) {
- return;
- }
-
- ax = x;
- ay = y;
- aw = width;
- ah = height;
- CG_AdjustFrom640( &ax, &ay, &aw, &ah );
-
- row = ch>>4;
- col = ch&15;
-
- frow = row*0.0625;
- fcol = col*0.0625;
- size = 0.0625;
-
- trap_R_DrawStretchPic( ax, ay, aw, ah,
- fcol, frow,
- fcol + size, frow + size,
- cgs.media.charsetShader );
-}
-
-
-/*
-==================
-CG_DrawStringExt
-
-Draws a multi-colored string with a drop shadow, optionally forcing
-to a fixed color.
-
-Coordinates are at 640 by 480 virtual resolution
-==================
-*/
-void CG_DrawStringExt( int x, int y, const char *string, const float *setColor,
- qboolean forceColor, qboolean shadow, int charWidth, int charHeight, int maxChars ) {
- vec4_t color;
- const char *s;
- int xx;
- int cnt;
-
- if (maxChars <= 0)
- maxChars = 32767; // do them all!
-
- // draw the drop shadow
- if (shadow) {
- color[0] = color[1] = color[2] = 0;
- color[3] = setColor[3];
- trap_R_SetColor( color );
- s = string;
- xx = x;
- cnt = 0;
- while ( *s && cnt < maxChars) {
- if ( Q_IsColorString( s ) ) {
- s += 2;
- continue;
- }
- CG_DrawChar( xx + 2, y + 2, charWidth, charHeight, *s );
- cnt++;
- xx += charWidth;
- s++;
- }
- }
-
- // draw the colored text
- s = string;
- xx = x;
- cnt = 0;
- trap_R_SetColor( setColor );
- while ( *s && cnt < maxChars) {
- if ( Q_IsColorString( s ) ) {
- if ( !forceColor ) {
- memcpy( color, g_color_table[ColorIndex(*(s+1))], sizeof( color ) );
- color[3] = setColor[3];
- trap_R_SetColor( color );
- }
- s += 2;
- continue;
- }
- CG_DrawChar( xx, y, charWidth, charHeight, *s );
- xx += charWidth;
- cnt++;
- s++;
- }
- trap_R_SetColor( NULL );
-}
-
-void CG_DrawBigString( int x, int y, const char *s, float alpha ) {
- float color[4];
-
- color[0] = color[1] = color[2] = 1.0;
- color[3] = alpha;
- CG_DrawStringExt( x, y, s, color, qfalse, qtrue, BIGCHAR_WIDTH, BIGCHAR_HEIGHT, 0 );
-}
-
-void CG_DrawBigStringColor( int x, int y, const char *s, vec4_t color ) {
- CG_DrawStringExt( x, y, s, color, qtrue, qtrue, BIGCHAR_WIDTH, BIGCHAR_HEIGHT, 0 );
-}
-
-void CG_DrawSmallString( int x, int y, const char *s, float alpha ) {
- float color[4];
-
- color[0] = color[1] = color[2] = 1.0;
- color[3] = alpha;
- CG_DrawStringExt( x, y, s, color, qfalse, qfalse, SMALLCHAR_WIDTH, SMALLCHAR_HEIGHT, 0 );
-}
-
-void CG_DrawSmallStringColor( int x, int y, const char *s, vec4_t color ) {
- CG_DrawStringExt( x, y, s, color, qtrue, qfalse, SMALLCHAR_WIDTH, SMALLCHAR_HEIGHT, 0 );
-}
-
/*
=================
CG_DrawStrlen
@@ -319,14 +199,17 @@ CG_DrawStrlen
Returns character count, skiping color escape codes
=================
*/
-int CG_DrawStrlen( const char *str ) {
- const char *s = str;
- int count = 0;
+int CG_DrawStrlen( const char *str )
+{
+ const char *s = str;
+ int count = 0;
- while ( *s ) {
- if ( Q_IsColorString( s ) ) {
+ while( *s )
+ {
+ if( Q_IsColorString( s ) )
s += 2;
- } else {
+ else
+ {
count++;
s++;
}
@@ -343,13 +226,14 @@ This repeats a 64*64 tile graphic to fill the screen around a sized down
refresh window.
=============
*/
-static void CG_TileClearBox( int x, int y, int w, int h, qhandle_t hShader ) {
+static void CG_TileClearBox( int x, int y, int w, int h, qhandle_t hShader )
+{
float s1, t1, s2, t2;
- s1 = x/64.0;
- t1 = y/64.0;
- s2 = (x+w)/64.0;
- t2 = (y+h)/64.0;
+ s1 = x / 64.0;
+ t1 = y / 64.0;
+ s2 = ( x + w ) / 64.0;
+ t2 = ( y + h ) / 64.0;
trap_R_DrawStretchPic( x, y, w, h, s1, t1, s2, t2, hShader );
}
@@ -362,22 +246,22 @@ CG_TileClear
Clear around a sized down screen
==============
*/
-void CG_TileClear( void ) {
+void CG_TileClear( void )
+{
int top, bottom, left, right;
int w, h;
w = cgs.glconfig.vidWidth;
h = cgs.glconfig.vidHeight;
- if ( cg.refdef.x == 0 && cg.refdef.y == 0 &&
- cg.refdef.width == w && cg.refdef.height == h ) {
+ if( cg.refdef.x == 0 && cg.refdef.y == 0 &&
+ cg.refdef.width == w && cg.refdef.height == h )
return; // full screen rendering
- }
top = cg.refdef.y;
- bottom = top + cg.refdef.height-1;
+ bottom = top + cg.refdef.height - 1;
left = cg.refdef.x;
- right = left + cg.refdef.width-1;
+ right = left + cg.refdef.width - 1;
// clear above view screen
CG_TileClearBox( 0, 0, w, top, cgs.media.backTileShader );
@@ -399,27 +283,26 @@ void CG_TileClear( void ) {
CG_FadeColor
================
*/
-float *CG_FadeColor( int startMsec, int totalMsec ) {
+float *CG_FadeColor( int startMsec, int totalMsec )
+{
static vec4_t color;
int t;
- if ( startMsec == 0 ) {
+ if( startMsec == 0 )
return NULL;
- }
t = cg.time - startMsec;
- if ( t >= totalMsec ) {
+ if( t >= totalMsec )
return NULL;
- }
// fade out
- if ( totalMsec - t < FADE_TIME ) {
- color[3] = ( totalMsec - t ) * 1.0/FADE_TIME;
- } else {
- color[3] = 1.0;
- }
- color[0] = color[1] = color[2] = 1;
+ if( totalMsec - t < FADE_TIME )
+ color[ 3 ] = ( totalMsec - t ) * 1.0 / FADE_TIME;
+ else
+ color[ 3 ] = 1.0;
+
+ color[ 0 ] = color[ 1 ] = color[ 2 ] = 1;
return color;
}
@@ -430,42 +313,45 @@ float *CG_FadeColor( int startMsec, int totalMsec ) {
CG_GetColorForHealth
=================
*/
-void CG_GetColorForHealth( int health, int armor, vec4_t hcolor ) {
+void CG_GetColorForHealth( int health, int armor, vec4_t hcolor )
+{
int count;
int max;
// calculate the total points of damage that can
// be sustained at the current health / armor level
- if ( health <= 0 ) {
+ if( health <= 0 )
+ {
VectorClear( hcolor ); // black
- hcolor[3] = 1;
+ hcolor[ 3 ] = 1;
return;
}
+
count = armor;
max = health * ARMOR_PROTECTION / ( 1.0 - ARMOR_PROTECTION );
- if ( max < count ) {
+
+ if( max < count )
count = max;
- }
+
health += count;
// set the color based on health
- hcolor[0] = 1.0;
- hcolor[3] = 1.0;
- if ( health >= 100 ) {
- hcolor[2] = 1.0;
- } else if ( health < 66 ) {
- hcolor[2] = 0;
- } else {
- hcolor[2] = ( health - 66 ) / 33.0;
- }
-
- if ( health > 60 ) {
- hcolor[1] = 1.0;
- } else if ( health < 30 ) {
- hcolor[1] = 0;
- } else {
- hcolor[1] = ( health - 30 ) / 30.0;
- }
+ hcolor[ 0 ] = 1.0;
+ hcolor[ 3 ] = 1.0;
+
+ if( health >= 100 )
+ hcolor[ 2 ] = 1.0;
+ else if( health < 66 )
+ hcolor[ 2 ] = 0;
+ else
+ hcolor[ 2 ] = ( health - 66 ) / 33.0;
+
+ if( health > 60 )
+ hcolor[ 1 ] = 1.0;
+ else if( health < 30 )
+ hcolor[ 1 ] = 0;
+ else
+ hcolor[ 1 ] = ( health - 30 ) / 30.0;
}
/*
@@ -473,398 +359,7 @@ void CG_GetColorForHealth( int health, int armor, vec4_t hcolor ) {
CG_ColorForHealth
=================
*/
-void CG_ColorForHealth( vec4_t hcolor ) {
-
- CG_GetColorForHealth( cg.snap->ps.stats[STAT_HEALTH],
- 0, hcolor );
-}
-
-// bk001205 - code below duplicated in q3_ui/ui-atoms.c
-// bk001205 - FIXME: does this belong in ui_shared.c?
-// bk001205 - FIXME: HARD_LINKED flags not visible here
-#ifndef Q3_STATIC // bk001205 - q_shared defines not visible here
-/*
-=================
-UI_DrawProportionalString2
-=================
-*/
-static int propMap[128][3] = {
-{0, 0, -1}, {0, 0, -1}, {0, 0, -1}, {0, 0, -1}, {0, 0, -1}, {0, 0, -1}, {0, 0, -1}, {0, 0, -1},
-{0, 0, -1}, {0, 0, -1}, {0, 0, -1}, {0, 0, -1}, {0, 0, -1}, {0, 0, -1}, {0, 0, -1}, {0, 0, -1},
-
-{0, 0, -1}, {0, 0, -1}, {0, 0, -1}, {0, 0, -1}, {0, 0, -1}, {0, 0, -1}, {0, 0, -1}, {0, 0, -1},
-{0, 0, -1}, {0, 0, -1}, {0, 0, -1}, {0, 0, -1}, {0, 0, -1}, {0, 0, -1}, {0, 0, -1}, {0, 0, -1},
-
-{0, 0, PROP_SPACE_WIDTH}, // SPACE
-{11, 122, 7}, // !
-{154, 181, 14}, // "
-{55, 122, 17}, // #
-{79, 122, 18}, // $
-{101, 122, 23}, // %
-{153, 122, 18}, // &
-{9, 93, 7}, // '
-{207, 122, 8}, // (
-{230, 122, 9}, // )
-{177, 122, 18}, // *
-{30, 152, 18}, // +
-{85, 181, 7}, // ,
-{34, 93, 11}, // -
-{110, 181, 6}, // .
-{130, 152, 14}, // /
-
-{22, 64, 17}, // 0
-{41, 64, 12}, // 1
-{58, 64, 17}, // 2
-{78, 64, 18}, // 3
-{98, 64, 19}, // 4
-{120, 64, 18}, // 5
-{141, 64, 18}, // 6
-{204, 64, 16}, // 7
-{162, 64, 17}, // 8
-{182, 64, 18}, // 9
-{59, 181, 7}, // :
-{35,181, 7}, // ;
-{203, 152, 14}, // <
-{56, 93, 14}, // =
-{228, 152, 14}, // >
-{177, 181, 18}, // ?
-
-{28, 122, 22}, // @
-{5, 4, 18}, // A
-{27, 4, 18}, // B
-{48, 4, 18}, // C
-{69, 4, 17}, // D
-{90, 4, 13}, // E
-{106, 4, 13}, // F
-{121, 4, 18}, // G
-{143, 4, 17}, // H
-{164, 4, 8}, // I
-{175, 4, 16}, // J
-{195, 4, 18}, // K
-{216, 4, 12}, // L
-{230, 4, 23}, // M
-{6, 34, 18}, // N
-{27, 34, 18}, // O
-
-{48, 34, 18}, // P
-{68, 34, 18}, // Q
-{90, 34, 17}, // R
-{110, 34, 18}, // S
-{130, 34, 14}, // T
-{146, 34, 18}, // U
-{166, 34, 19}, // V
-{185, 34, 29}, // W
-{215, 34, 18}, // X
-{234, 34, 18}, // Y
-{5, 64, 14}, // Z
-{60, 152, 7}, // [
-{106, 151, 13}, // '\'
-{83, 152, 7}, // ]
-{128, 122, 17}, // ^
-{4, 152, 21}, // _
-
-{134, 181, 5}, // '
-{5, 4, 18}, // A
-{27, 4, 18}, // B
-{48, 4, 18}, // C
-{69, 4, 17}, // D
-{90, 4, 13}, // E
-{106, 4, 13}, // F
-{121, 4, 18}, // G
-{143, 4, 17}, // H
-{164, 4, 8}, // I
-{175, 4, 16}, // J
-{195, 4, 18}, // K
-{216, 4, 12}, // L
-{230, 4, 23}, // M
-{6, 34, 18}, // N
-{27, 34, 18}, // O
-
-{48, 34, 18}, // P
-{68, 34, 18}, // Q
-{90, 34, 17}, // R
-{110, 34, 18}, // S
-{130, 34, 14}, // T
-{146, 34, 18}, // U
-{166, 34, 19}, // V
-{185, 34, 29}, // W
-{215, 34, 18}, // X
-{234, 34, 18}, // Y
-{5, 64, 14}, // Z
-{153, 152, 13}, // {
-{11, 181, 5}, // |
-{180, 152, 13}, // }
-{79, 93, 17}, // ~
-{0, 0, -1} // DEL
-};
-
-static int propMapB[26][3] = {
-{11, 12, 33},
-{49, 12, 31},
-{85, 12, 31},
-{120, 12, 30},
-{156, 12, 21},
-{183, 12, 21},
-{207, 12, 32},
-
-{13, 55, 30},
-{49, 55, 13},
-{66, 55, 29},
-{101, 55, 31},
-{135, 55, 21},
-{158, 55, 40},
-{204, 55, 32},
-
-{12, 97, 31},
-{48, 97, 31},
-{82, 97, 30},
-{118, 97, 30},
-{153, 97, 30},
-{185, 97, 25},
-{213, 97, 30},
-
-{11, 139, 32},
-{42, 139, 51},
-{93, 139, 32},
-{126, 139, 31},
-{158, 139, 25},
-};
-
-#define PROPB_GAP_WIDTH 4
-#define PROPB_SPACE_WIDTH 12
-#define PROPB_HEIGHT 36
-
-/*
-=================
-UI_DrawBannerString
-=================
-*/
-static void UI_DrawBannerString2( int x, int y, const char* str, vec4_t color )
+void CG_ColorForHealth( vec4_t hcolor )
{
- const char* s;
- unsigned char ch;
- float ax;
- float ay;
- float aw;
- float ah;
- float frow;
- float fcol;
- float fwidth;
- float fheight;
-
- // draw the colored text
- trap_R_SetColor( color );
-
- ax = x * cgs.screenXScale + cgs.screenXBias;
- ay = y * cgs.screenXScale;
-
- s = str;
- while ( *s )
- {
- ch = *s & 127;
- if ( ch == ' ' ) {
- ax += ((float)PROPB_SPACE_WIDTH + (float)PROPB_GAP_WIDTH)* cgs.screenXScale;
- }
- else if ( ch >= 'A' && ch <= 'Z' ) {
- ch -= 'A';
- fcol = (float)propMapB[ch][0] / 256.0f;
- frow = (float)propMapB[ch][1] / 256.0f;
- fwidth = (float)propMapB[ch][2] / 256.0f;
- fheight = (float)PROPB_HEIGHT / 256.0f;
- aw = (float)propMapB[ch][2] * cgs.screenXScale;
- ah = (float)PROPB_HEIGHT * cgs.screenXScale;
- trap_R_DrawStretchPic( ax, ay, aw, ah, fcol, frow, fcol+fwidth, frow+fheight, cgs.media.charsetPropB );
- ax += (aw + (float)PROPB_GAP_WIDTH * cgs.screenXScale);
- }
- s++;
- }
-
- trap_R_SetColor( NULL );
-}
-
-void UI_DrawBannerString( int x, int y, const char* str, int style, vec4_t color ) {
- const char * s;
- int ch;
- int width;
- vec4_t drawcolor;
-
- // find the width of the drawn text
- s = str;
- width = 0;
- while ( *s ) {
- ch = *s;
- if ( ch == ' ' ) {
- width += PROPB_SPACE_WIDTH;
- }
- else if ( ch >= 'A' && ch <= 'Z' ) {
- width += propMapB[ch - 'A'][2] + PROPB_GAP_WIDTH;
- }
- s++;
- }
- width -= PROPB_GAP_WIDTH;
-
- switch( style & UI_FORMATMASK ) {
- case UI_CENTER:
- x -= width / 2;
- break;
-
- case UI_RIGHT:
- x -= width;
- break;
-
- case UI_LEFT:
- default:
- break;
- }
-
- if ( style & UI_DROPSHADOW ) {
- drawcolor[0] = drawcolor[1] = drawcolor[2] = 0;
- drawcolor[3] = color[3];
- UI_DrawBannerString2( x+2, y+2, str, drawcolor );
- }
-
- UI_DrawBannerString2( x, y, str, color );
-}
-
-
-int UI_ProportionalStringWidth( const char* str ) {
- const char * s;
- int ch;
- int charWidth;
- int width;
-
- s = str;
- width = 0;
- while ( *s ) {
- ch = *s & 127;
- charWidth = propMap[ch][2];
- if ( charWidth != -1 ) {
- width += charWidth;
- width += PROP_GAP_WIDTH;
- }
- s++;
- }
-
- width -= PROP_GAP_WIDTH;
- return width;
-}
-
-static void UI_DrawProportionalString2( int x, int y, const char* str, vec4_t color, float sizeScale, qhandle_t charset )
-{
- const char* s;
- unsigned char ch;
- float ax;
- float ay;
- float aw;
- float ah;
- float frow;
- float fcol;
- float fwidth;
- float fheight;
-
- // draw the colored text
- trap_R_SetColor( color );
-
- ax = x * cgs.screenXScale + cgs.screenXBias;
- ay = y * cgs.screenXScale;
-
- s = str;
- while ( *s )
- {
- ch = *s & 127;
- if ( ch == ' ' ) {
- aw = (float)PROP_SPACE_WIDTH * cgs.screenXScale * sizeScale;
- } else if ( propMap[ch][2] != -1 ) {
- fcol = (float)propMap[ch][0] / 256.0f;
- frow = (float)propMap[ch][1] / 256.0f;
- fwidth = (float)propMap[ch][2] / 256.0f;
- fheight = (float)PROP_HEIGHT / 256.0f;
- aw = (float)propMap[ch][2] * cgs.screenXScale * sizeScale;
- ah = (float)PROP_HEIGHT * cgs.screenXScale * sizeScale;
- trap_R_DrawStretchPic( ax, ay, aw, ah, fcol, frow, fcol+fwidth, frow+fheight, charset );
- } else {
- aw = 0;
- }
-
- ax += (aw + (float)PROP_GAP_WIDTH * cgs.screenXScale * sizeScale);
- s++;
- }
-
- trap_R_SetColor( NULL );
-}
-
-/*
-=================
-UI_ProportionalSizeScale
-=================
-*/
-float UI_ProportionalSizeScale( int style ) {
- if( style & UI_SMALLFONT ) {
- return 0.75;
- }
-
- return 1.00;
-}
-
-
-/*
-=================
-UI_DrawProportionalString
-=================
-*/
-void UI_DrawProportionalString( int x, int y, const char* str, int style, vec4_t color ) {
- vec4_t drawcolor;
- int width;
- float sizeScale;
-
- sizeScale = UI_ProportionalSizeScale( style );
-
- switch( style & UI_FORMATMASK ) {
- case UI_CENTER:
- width = UI_ProportionalStringWidth( str ) * sizeScale;
- x -= width / 2;
- break;
-
- case UI_RIGHT:
- width = UI_ProportionalStringWidth( str ) * sizeScale;
- x -= width;
- break;
-
- case UI_LEFT:
- default:
- break;
- }
-
- if ( style & UI_DROPSHADOW ) {
- drawcolor[0] = drawcolor[1] = drawcolor[2] = 0;
- drawcolor[3] = color[3];
- UI_DrawProportionalString2( x+2, y+2, str, drawcolor, sizeScale, cgs.media.charsetProp );
- }
-
- if ( style & UI_INVERSE ) {
- drawcolor[0] = color[0] * 0.8;
- drawcolor[1] = color[1] * 0.8;
- drawcolor[2] = color[2] * 0.8;
- drawcolor[3] = color[3];
- UI_DrawProportionalString2( x, y, str, drawcolor, sizeScale, cgs.media.charsetProp );
- return;
- }
-
- if ( style & UI_PULSE ) {
- drawcolor[0] = color[0] * 0.8;
- drawcolor[1] = color[1] * 0.8;
- drawcolor[2] = color[2] * 0.8;
- drawcolor[3] = color[3];
- UI_DrawProportionalString2( x, y, str, color, sizeScale, cgs.media.charsetProp );
-
- drawcolor[0] = color[0];
- drawcolor[1] = color[1];
- drawcolor[2] = color[2];
- drawcolor[3] = 0.5 + 0.5 * sin( cg.time / PULSE_DIVISOR );
- UI_DrawProportionalString2( x, y, str, drawcolor, sizeScale, cgs.media.charsetPropGlow );
- return;
- }
-
- UI_DrawProportionalString2( x, y, str, color, sizeScale, cgs.media.charsetProp );
+ CG_GetColorForHealth( cg.snap->ps.stats[ STAT_HEALTH ], 0, hcolor );
}
-#endif // Q3STATIC
diff --git a/src/cgame/cg_ents.c b/src/cgame/cg_ents.c
index f0e10574..c4b287aa 100644
--- a/src/cgame/cg_ents.c
+++ b/src/cgame/cg_ents.c
@@ -27,22 +27,22 @@ tag location
======================
*/
void CG_PositionEntityOnTag( refEntity_t *entity, const refEntity_t *parent,
- qhandle_t parentModel, char *tagName ) {
- int i;
+ qhandle_t parentModel, char *tagName )
+{
+ int i;
orientation_t lerped;
// lerp the tag
trap_R_LerpTag( &lerped, parentModel, parent->oldframe, parent->frame,
- 1.0 - parent->backlerp, tagName );
+ 1.0 - parent->backlerp, tagName );
// FIXME: allow origin offsets along tag?
VectorCopy( parent->origin, entity->origin );
- for ( i = 0 ; i < 3 ; i++ ) {
- VectorMA( entity->origin, lerped.origin[i], parent->axis[i], entity->origin );
- }
+ for( i = 0; i < 3; i++ )
+ VectorMA( entity->origin, lerped.origin[ i ], parent->axis[ i ], entity->origin );
// had to cast away the const to avoid compiler problems...
- MatrixMultiply( lerped.axis, ((refEntity_t *)parent)->axis, entity->axis );
+ MatrixMultiply( lerped.axis, ( (refEntity_t *)parent )->axis, entity->axis );
entity->backlerp = parent->backlerp;
}
@@ -56,25 +56,25 @@ tag location
======================
*/
void CG_PositionRotatedEntityOnTag( refEntity_t *entity, const refEntity_t *parent,
- qhandle_t parentModel, char *tagName ) {
- int i;
+ qhandle_t parentModel, char *tagName )
+{
+ int i;
orientation_t lerped;
- vec3_t tempAxis[3];
+ vec3_t tempAxis[ 3 ];
//AxisClear( entity->axis );
// lerp the tag
trap_R_LerpTag( &lerped, parentModel, parent->oldframe, parent->frame,
- 1.0 - parent->backlerp, tagName );
+ 1.0 - parent->backlerp, tagName );
// FIXME: allow origin offsets along tag?
VectorCopy( parent->origin, entity->origin );
- for ( i = 0 ; i < 3 ; i++ ) {
- VectorMA( entity->origin, lerped.origin[i], parent->axis[i], entity->origin );
- }
+ for( i = 0; i < 3; i++ )
+ VectorMA( entity->origin, lerped.origin[ i ], parent->axis[ i ], entity->origin );
// had to cast away the const to avoid compiler problems...
MatrixMultiply( entity->axis, lerped.axis, tempAxis );
- MatrixMultiply( tempAxis, ((refEntity_t *)parent)->axis, entity->axis );
+ MatrixMultiply( tempAxis, ( (refEntity_t *)parent )->axis, entity->axis );
}
@@ -94,17 +94,19 @@ CG_SetEntitySoundPosition
Also called by event processing code
======================
*/
-void CG_SetEntitySoundPosition( centity_t *cent ) {
- if ( cent->currentState.solid == SOLID_BMODEL ) {
+void CG_SetEntitySoundPosition( centity_t *cent )
+{
+ if( cent->currentState.solid == SOLID_BMODEL )
+ {
vec3_t origin;
- float *v;
+ float *v;
v = cgs.inlineModelMidpoints[ cent->currentState.modelindex ];
VectorAdd( cent->lerpOrigin, v, origin );
trap_S_UpdateEntityPosition( cent->currentState.number, origin );
- } else {
- trap_S_UpdateEntityPosition( cent->currentState.number, cent->lerpOrigin );
}
+ else
+ trap_S_UpdateEntityPosition( cent->currentState.number, cent->lerpOrigin );
}
/*
@@ -114,19 +116,23 @@ CG_EntityEffects
Add continuous entity effects, like local entity emission and lighting
==================
*/
-static void CG_EntityEffects( centity_t *cent ) {
-
+static void CG_EntityEffects( centity_t *cent )
+{
// update sound origins
CG_SetEntitySoundPosition( cent );
// add loop sound
- if ( cent->currentState.loopSound ) {
- if (cent->currentState.eType != ET_SPEAKER) {
+ if( cent->currentState.loopSound )
+ {
+ if( cent->currentState.eType != ET_SPEAKER )
+ {
trap_S_AddLoopingSound( cent->currentState.number, cent->lerpOrigin, vec3_origin,
- cgs.gameSounds[ cent->currentState.loopSound ] );
- } else {
+ cgs.gameSounds[ cent->currentState.loopSound ] );
+ }
+ else
+ {
trap_S_AddRealLoopingSound( cent->currentState.number, cent->lerpOrigin, vec3_origin,
- cgs.gameSounds[ cent->currentState.loopSound ] );
+ cgs.gameSounds[ cent->currentState.loopSound ] );
}
}
@@ -153,18 +159,18 @@ static void CG_EntityEffects( centity_t *cent ) {
CG_General
==================
*/
-static void CG_General( centity_t *cent ) {
+static void CG_General( centity_t *cent )
+{
refEntity_t ent;
entityState_t *s1;
s1 = &cent->currentState;
// if set to invisible, skip
- if (!s1->modelindex) {
+ if( !s1->modelindex )
return;
- }
- memset (&ent, 0, sizeof(ent));
+ memset( &ent, 0, sizeof( ent ) );
// set frame
@@ -175,18 +181,17 @@ static void CG_General( centity_t *cent ) {
VectorCopy( cent->lerpOrigin, ent.origin);
VectorCopy( cent->lerpOrigin, ent.oldorigin);
- ent.hModel = cgs.gameModels[s1->modelindex];
+ ent.hModel = cgs.gameModels[ s1->modelindex ];
// player model
- if (s1->number == cg.snap->ps.clientNum) {
+ if( s1->number == cg.snap->ps.clientNum )
ent.renderfx |= RF_THIRD_PERSON; // only draw from mirrors
- }
// convert angles to axis
AnglesToAxis( cent->lerpAngles, ent.axis );
// add to refresh list
- trap_R_AddRefEntityToScene (&ent);
+ trap_R_AddRefEntityToScene( &ent );
}
/*
@@ -196,20 +201,21 @@ CG_Speaker
Speaker entities can automatically play sounds
==================
*/
-static void CG_Speaker( centity_t *cent ) {
- if ( ! cent->currentState.clientNum ) { // FIXME: use something other than clientNum...
+static void CG_Speaker( centity_t *cent )
+{
+ if( ! cent->currentState.clientNum )
+ { // FIXME: use something other than clientNum...
return; // not auto triggering
}
- if ( cg.time < cent->miscTime ) {
+ if( cg.time < cent->miscTime )
return;
- }
- trap_S_StartSound (NULL, cent->currentState.number, CHAN_ITEM, cgs.gameSounds[cent->currentState.eventParm] );
+ trap_S_StartSound( NULL, cent->currentState.number, CHAN_ITEM, cgs.gameSounds[ cent->currentState.eventParm ] );
// ent->s.frame = ent->wait * 10;
// ent->s.clientNum = ent->random * 10;
- cent->miscTime = cg.time + cent->currentState.frame * 100 + cent->currentState.clientNum * 100 * crandom();
+ cent->miscTime = cg.time + cent->currentState.frame * 100 + cent->currentState.clientNum * 100 * crandom( );
}
@@ -230,55 +236,42 @@ static void CG_Missile( centity_t *cent )
int index;
s1 = &cent->currentState;
- if ( s1->weapon > WP_NUM_WEAPONS ) {
+ if( s1->weapon > WP_NUM_WEAPONS )
s1->weapon = 0;
- }
- weapon = &cg_weapons[s1->weapon];
+
+ weapon = &cg_weapons[ s1->weapon ];
// calculate the axis
- VectorCopy( s1->angles, cent->lerpAngles);
+ VectorCopy( s1->angles, cent->lerpAngles );
// add trails
- if ( weapon->missileTrailFunc )
- {
+ if( weapon->missileTrailFunc )
weapon->missileTrailFunc( cent, weapon );
- }
// add dynamic light
- if ( weapon->missileDlight ) {
- trap_R_AddLightToScene(cent->lerpOrigin, weapon->missileDlight,
- weapon->missileDlightColor[0], weapon->missileDlightColor[1], weapon->missileDlightColor[2] );
+ if( weapon->missileDlight )
+ {
+ trap_R_AddLightToScene( cent->lerpOrigin, weapon->missileDlight,
+ weapon->missileDlightColor[ 0 ], weapon->missileDlightColor[ 1 ], weapon->missileDlightColor[ 2 ] );
}
// add missile sound
- if ( weapon->missileSound ) {
+ if( weapon->missileSound )
+ {
vec3_t velocity;
BG_EvaluateTrajectoryDelta( &cent->currentState.pos, cg.time, velocity );
- //TA: FIXME: hack until i figure out why trap_S_ALS has a problem with velocity`
- if( s1->weapon == WP_PLASMAGUN )
- VectorClear( velocity );
-
trap_S_AddLoopingSound( cent->currentState.number, cent->lerpOrigin, velocity, weapon->missileSound );
}
// create the render entity
- memset (&ent, 0, sizeof(ent));
- VectorCopy( cent->lerpOrigin, ent.origin);
- VectorCopy( cent->lerpOrigin, ent.oldorigin);
+ memset( &ent, 0, sizeof( ent ) );
+ VectorCopy( cent->lerpOrigin, ent.origin );
+ VectorCopy( cent->lerpOrigin, ent.oldorigin );
switch( cent->currentState.weapon )
{
- case WP_PLASMAGUN:
- ent.reType = RT_SPRITE;
- ent.radius = 16;
- ent.rotation = 0;
- ent.customShader = cgs.media.plasmaBallShader;
- trap_R_AddRefEntityToScene( &ent );
- return;
- break;
-
case WP_PULSE_RIFLE:
ent.reType = RT_SPRITE;
ent.radius = 4;
@@ -335,66 +328,18 @@ static void CG_Missile( centity_t *cent )
/*
===============
-CG_Grapple
-
-This is called when the grapple is sitting up against the wall
-===============
-*/
-static void CG_Grapple( centity_t *cent ) {
- refEntity_t ent;
- entityState_t *s1;
- const weaponInfo_t *weapon;
-
- s1 = &cent->currentState;
- if ( s1->weapon > WP_NUM_WEAPONS ) {
- s1->weapon = 0;
- }
- weapon = &cg_weapons[s1->weapon];
-
- // calculate the axis
- VectorCopy( s1->angles, cent->lerpAngles);
-
-#if 0 // FIXME add grapple pull sound here..?
- // add missile sound
- if ( weapon->missileSound ) {
- trap_S_AddLoopingSound( cent->currentState.number, cent->lerpOrigin, vec3_origin, weapon->missileSound );
- }
-#endif
-
- // Will draw cable if needed
- CG_GrappleTrail ( cent, weapon );
-
- // create the render entity
- memset (&ent, 0, sizeof(ent));
- VectorCopy( cent->lerpOrigin, ent.origin);
- VectorCopy( cent->lerpOrigin, ent.oldorigin);
-
- // flicker between two skins
- ent.skinNum = cg.clientFrame & 1;
- ent.hModel = weapon->missileModel;
- ent.renderfx = weapon->missileRenderfx | RF_NOSHADOW;
-
- // convert direction of travel into axis
- if ( VectorNormalize2( s1->pos.trDelta, ent.axis[0] ) == 0 ) {
- ent.axis[0][2] = 1;
- }
-
- trap_R_AddRefEntityToScene( &ent );
-}
-
-/*
-===============
CG_Mover
===============
*/
-static void CG_Mover( centity_t *cent ) {
+static void CG_Mover( centity_t *cent )
+{
refEntity_t ent;
entityState_t *s1;
s1 = &cent->currentState;
// create the render entity
- memset (&ent, 0, sizeof(ent));
+ memset( &ent, 0, sizeof( ent ) );
VectorCopy( cent->lerpOrigin, ent.origin);
VectorCopy( cent->lerpOrigin, ent.oldorigin);
AnglesToAxis( cent->lerpAngles, ent.axis );
@@ -405,20 +350,20 @@ static void CG_Mover( centity_t *cent ) {
ent.skinNum = ( cg.time >> 6 ) & 1;
// get the model, either as a bmodel or a modelindex
- if ( s1->solid == SOLID_BMODEL ) {
- ent.hModel = cgs.inlineDrawModel[s1->modelindex];
- } else {
- ent.hModel = cgs.gameModels[s1->modelindex];
- }
+ if( s1->solid == SOLID_BMODEL )
+ ent.hModel = cgs.inlineDrawModel[ s1->modelindex ];
+ else
+ ent.hModel = cgs.gameModels[ s1->modelindex ];
// add to refresh list
- trap_R_AddRefEntityToScene(&ent);
+ trap_R_AddRefEntityToScene( &ent );
// add the secondary model
- if ( s1->modelindex2 ) {
+ if( s1->modelindex2 )
+ {
ent.skinNum = 0;
- ent.hModel = cgs.gameModels[s1->modelindex2];
- trap_R_AddRefEntityToScene(&ent);
+ ent.hModel = cgs.gameModels[ s1->modelindex2 ];
+ trap_R_AddRefEntityToScene( &ent );
}
}
@@ -430,14 +375,15 @@ CG_Beam
Also called as an event
===============
*/
-void CG_Beam( centity_t *cent ) {
+void CG_Beam( centity_t *cent )
+{
refEntity_t ent;
entityState_t *s1;
s1 = &cent->currentState;
// create the render entity
- memset (&ent, 0, sizeof(ent));
+ memset( &ent, 0, sizeof( ent ) );
VectorCopy( s1->pos.trBase, ent.origin );
VectorCopy( s1->origin2, ent.oldorigin );
AxisClear( ent.axis );
@@ -446,7 +392,7 @@ void CG_Beam( centity_t *cent ) {
ent.renderfx = RF_NOSHADOW;
// add to refresh list
- trap_R_AddRefEntityToScene(&ent);
+ trap_R_AddRefEntityToScene( &ent );
}
@@ -455,31 +401,32 @@ void CG_Beam( centity_t *cent ) {
CG_Portal
===============
*/
-static void CG_Portal( centity_t *cent ) {
+static void CG_Portal( centity_t *cent )
+{
refEntity_t ent;
entityState_t *s1;
s1 = &cent->currentState;
// create the render entity
- memset (&ent, 0, sizeof(ent));
+ memset( &ent, 0, sizeof( ent ) );
VectorCopy( cent->lerpOrigin, ent.origin );
VectorCopy( s1->origin2, ent.oldorigin );
- ByteToDir( s1->eventParm, ent.axis[0] );
- PerpendicularVector( ent.axis[1], ent.axis[0] );
+ ByteToDir( s1->eventParm, ent.axis[ 0 ] );
+ PerpendicularVector( ent.axis[ 1 ], ent.axis[ 0 ] );
// negating this tends to get the directions like they want
// we really should have a camera roll value
- VectorSubtract( vec3_origin, ent.axis[1], ent.axis[1] );
+ VectorSubtract( vec3_origin, ent.axis[ 1 ], ent.axis[ 1 ] );
- CrossProduct( ent.axis[0], ent.axis[1], ent.axis[2] );
+ CrossProduct( ent.axis[ 0 ], ent.axis[ 1 ], ent.axis[ 2 ] );
ent.reType = RT_PORTALSURFACE;
ent.oldframe = s1->powerups;
ent.frame = s1->frame; // rotation speed
- ent.skinNum = s1->clientNum/256.0 * 360; // roll offset
+ ent.skinNum = s1->clientNum / 256.0 * 360; // roll offset
// add to refresh list
- trap_R_AddRefEntityToScene(&ent);
+ trap_R_AddRefEntityToScene( &ent );
}
//============================================================================
@@ -548,18 +495,22 @@ CG_AdjustPositionForMover
Also called by client movement prediction code
=========================
*/
-void CG_AdjustPositionForMover( const vec3_t in, int moverNum, int fromTime, int toTime, vec3_t out ) {
+void CG_AdjustPositionForMover( const vec3_t in, int moverNum, int fromTime, int toTime, vec3_t out )
+{
centity_t *cent;
- vec3_t oldOrigin, origin, deltaOrigin;
- vec3_t oldAngles, angles, deltaAngles;
+ vec3_t oldOrigin, origin, deltaOrigin;
+ vec3_t oldAngles, angles, deltaAngles;
- if ( moverNum <= 0 || moverNum >= ENTITYNUM_MAX_NORMAL ) {
+ if( moverNum <= 0 || moverNum >= ENTITYNUM_MAX_NORMAL )
+ {
VectorCopy( in, out );
return;
}
cent = &cg_entities[ moverNum ];
- if ( cent->currentState.eType != ET_MOVER ) {
+
+ if( cent->currentState.eType != ET_MOVER )
+ {
VectorCopy( in, out );
return;
}
@@ -584,15 +535,15 @@ void CG_AdjustPositionForMover( const vec3_t in, int moverNum, int fromTime, int
CG_InterpolateEntityPosition
=============================
*/
-static void CG_InterpolateEntityPosition( centity_t *cent ) {
+static void CG_InterpolateEntityPosition( centity_t *cent )
+{
vec3_t current, next;
- float f;
+ float f;
// it would be an internal error to find an entity that interpolates without
// a snapshot ahead of the current one
- if ( cg.nextSnap == NULL ) {
+ if( cg.nextSnap == NULL )
CG_Error( "CG_InterpoateEntityPosition: cg.nextSnap == NULL" );
- }
f = cg.frameInterpolation;
@@ -601,16 +552,16 @@ static void CG_InterpolateEntityPosition( centity_t *cent ) {
BG_EvaluateTrajectory( &cent->currentState.pos, cg.snap->serverTime, current );
BG_EvaluateTrajectory( &cent->nextState.pos, cg.nextSnap->serverTime, next );
- cent->lerpOrigin[0] = current[0] + f * ( next[0] - current[0] );
- cent->lerpOrigin[1] = current[1] + f * ( next[1] - current[1] );
- cent->lerpOrigin[2] = current[2] + f * ( next[2] - current[2] );
+ cent->lerpOrigin[ 0 ] = current[ 0 ] + f * ( next[ 0 ] - current[ 0 ] );
+ cent->lerpOrigin[ 1 ] = current[ 1 ] + f * ( next[ 1 ] - current[ 1 ] );
+ cent->lerpOrigin[ 2 ] = current[ 2 ] + f * ( next[ 2 ] - current[ 2 ] );
BG_EvaluateTrajectory( &cent->currentState.apos, cg.snap->serverTime, current );
BG_EvaluateTrajectory( &cent->nextState.apos, cg.nextSnap->serverTime, next );
- cent->lerpAngles[0] = LerpAngle( current[0], next[0], f );
- cent->lerpAngles[1] = LerpAngle( current[1], next[1], f );
- cent->lerpAngles[2] = LerpAngle( current[2], next[2], f );
+ cent->lerpAngles[ 0 ] = LerpAngle( current[ 0 ], next[ 0 ], f );
+ cent->lerpAngles[ 1 ] = LerpAngle( current[ 1 ], next[ 1 ], f );
+ cent->lerpAngles[ 2 ] = LerpAngle( current[ 2 ], next[ 2 ], f );
}
@@ -620,25 +571,30 @@ CG_CalcEntityLerpPositions
===============
*/
-static void CG_CalcEntityLerpPositions( centity_t *cent ) {
+static void CG_CalcEntityLerpPositions( centity_t *cent )
+{
// if this player does not want to see extrapolated players
- if ( !cg_smoothClients.integer ) {
+ if( !cg_smoothClients.integer )
+ {
// make sure the clients use TR_INTERPOLATE
- if ( cent->currentState.number < MAX_CLIENTS ) {
+ if( cent->currentState.number < MAX_CLIENTS )
+ {
cent->currentState.pos.trType = TR_INTERPOLATE;
cent->nextState.pos.trType = TR_INTERPOLATE;
}
}
- if ( cent->interpolate && cent->currentState.pos.trType == TR_INTERPOLATE ) {
+ if( cent->interpolate && cent->currentState.pos.trType == TR_INTERPOLATE )
+ {
CG_InterpolateEntityPosition( cent );
return;
}
// first see if we can interpolate between two snaps for
// linear extrapolated clients
- if ( cent->interpolate && cent->currentState.pos.trType == TR_LINEAR_STOP &&
- cent->currentState.number < MAX_CLIENTS) {
+ if( cent->interpolate && cent->currentState.pos.trType == TR_LINEAR_STOP &&
+ cent->currentState.number < MAX_CLIENTS )
+ {
CG_InterpolateEntityPosition( cent );
return;
}
@@ -649,9 +605,10 @@ static void CG_CalcEntityLerpPositions( centity_t *cent ) {
// adjust for riding a mover if it wasn't rolled into the predicted
// player state
- if ( cent != &cg.predictedPlayerEntity ) {
+ if( cent != &cg.predictedPlayerEntity )
+ {
CG_AdjustPositionForMover( cent->lerpOrigin, cent->currentState.groundEntityNum,
- cg.snap->serverTime, cg.time, cent->lerpOrigin );
+ cg.snap->serverTime, cg.time, cent->lerpOrigin );
}
}
@@ -663,11 +620,11 @@ CG_AddCEntity
===============
*/
-static void CG_AddCEntity( centity_t *cent ) {
+static void CG_AddCEntity( centity_t *cent )
+{
// event-only entities will have been dealt with already
- if ( cent->currentState.eType >= ET_EVENTS ) {
+ if( cent->currentState.eType >= ET_EVENTS )
return;
- }
// calculate the current origin
CG_CalcEntityLerpPositions( cent );
@@ -675,53 +632,64 @@ static void CG_AddCEntity( centity_t *cent ) {
// add automatic effects
CG_EntityEffects( cent );
- switch ( cent->currentState.eType ) {
- default:
- CG_Error( "Bad entity type: %i\n", cent->currentState.eType );
- break;
- case ET_INVISIBLE:
- case ET_PUSH_TRIGGER:
- case ET_TELEPORT_TRIGGER:
- break;
- case ET_GENERAL:
- CG_General( cent );
- break;
- case ET_CORPSE:
- CG_Corpse( cent );
- break;
- case ET_PLAYER:
- CG_Player( cent );
- break;
- case ET_BUILDABLE:
- CG_Buildable( cent );
- break;
- case ET_MISSILE:
- CG_Missile( cent );
- break;
- case ET_MOVER:
- CG_Mover( cent );
- break;
- case ET_BEAM:
- CG_Beam( cent );
- break;
- case ET_PORTAL:
- CG_Portal( cent );
- break;
- case ET_SPEAKER:
- CG_Speaker( cent );
- break;
- case ET_GRAPPLE:
- CG_Grapple( cent );
- break;
- case ET_SPRITER:
- CG_Spriter( cent );
- break;
- case ET_ANIMMAPOBJ:
- CG_animMapObj( cent );
- break;
- case ET_LIGHTFLARE:
- CG_LightFlare( cent );
- break;
+ switch( cent->currentState.eType )
+ {
+ default:
+ CG_Error( "Bad entity type: %i\n", cent->currentState.eType );
+ break;
+
+ case ET_INVISIBLE:
+ case ET_PUSH_TRIGGER:
+ case ET_TELEPORT_TRIGGER:
+ break;
+
+ case ET_GENERAL:
+ CG_General( cent );
+ break;
+
+ case ET_CORPSE:
+ CG_Corpse( cent );
+ break;
+
+ case ET_PLAYER:
+ CG_Player( cent );
+ break;
+
+ case ET_BUILDABLE:
+ CG_Buildable( cent );
+ break;
+
+ case ET_MISSILE:
+ CG_Missile( cent );
+ break;
+
+ case ET_MOVER:
+ CG_Mover( cent );
+ break;
+
+ case ET_BEAM:
+ CG_Beam( cent );
+ break;
+
+ case ET_PORTAL:
+ CG_Portal( cent );
+ break;
+
+ case ET_SPEAKER:
+ CG_Speaker( cent );
+ break;
+
+ case ET_SPRITER:
+ CG_Spriter( cent );
+ break;
+
+ case ET_ANIMMAPOBJ:
+ CG_animMapObj( cent );
+ break;
+
+ case ET_LIGHTFLARE:
+ CG_LightFlare( cent );
+ break;
}
}
@@ -731,34 +699,38 @@ CG_AddPacketEntities
===============
*/
-void CG_AddPacketEntities( void ) {
- int num;
- centity_t *cent;
+void CG_AddPacketEntities( void )
+{
+ int num;
+ centity_t *cent;
playerState_t *ps;
// set cg.frameInterpolation
- if ( cg.nextSnap ) {
+ if( cg.nextSnap )
+ {
int delta;
- delta = (cg.nextSnap->serverTime - cg.snap->serverTime);
- if ( delta == 0 ) {
+ delta = ( cg.nextSnap->serverTime - cg.snap->serverTime );
+
+ if( delta == 0 )
cg.frameInterpolation = 0;
- } else {
+ else
cg.frameInterpolation = (float)( cg.time - cg.snap->serverTime ) / delta;
- }
- } else {
+ }
+ else
+ {
cg.frameInterpolation = 0; // actually, it should never be used, because
// no entities should be marked as interpolating
}
// the auto-rotating items will all have the same axis
- cg.autoAngles[0] = 0;
- cg.autoAngles[1] = ( cg.time & 2047 ) * 360 / 2048.0;
- cg.autoAngles[2] = 0;
+ cg.autoAngles[ 0 ] = 0;
+ cg.autoAngles[ 1 ] = ( cg.time & 2047 ) * 360 / 2048.0;
+ cg.autoAngles[ 2 ] = 0;
- cg.autoAnglesFast[0] = 0;
- cg.autoAnglesFast[1] = ( cg.time & 1023 ) * 360 / 1024.0f;
- cg.autoAnglesFast[2] = 0;
+ cg.autoAnglesFast[ 0 ] = 0;
+ cg.autoAnglesFast[ 1 ] = ( cg.time & 1023 ) * 360 / 1024.0f;
+ cg.autoAnglesFast[ 2 ] = 0;
AnglesToAxis( cg.autoAngles, cg.autoAxis );
AnglesToAxis( cg.autoAnglesFast, cg.autoAxisFast );
diff --git a/src/cgame/cg_event.c b/src/cgame/cg_event.c
index b8c5e44c..98337c45 100644
--- a/src/cgame/cg_event.c
+++ b/src/cgame/cg_event.c
@@ -17,271 +17,239 @@
#include "cg_local.h"
-// for the voice chats
-#include "../../ui/menudef.h"
-
-//==========================================================================
-
-/*
-===================
-CG_PlaceString
-
-Also called by scoreboard drawing
-===================
-*/
-const char *CG_PlaceString( int rank ) {
- static char str[64];
- char *s, *t;
-
- if ( rank & RANK_TIED_FLAG ) {
- rank &= ~RANK_TIED_FLAG;
- t = "Tied for ";
- } else {
- t = "";
- }
-
- if ( rank == 1 ) {
- s = S_COLOR_BLUE "1st" S_COLOR_WHITE; // draw in blue
- } else if ( rank == 2 ) {
- s = S_COLOR_RED "2nd" S_COLOR_WHITE; // draw in red
- } else if ( rank == 3 ) {
- s = S_COLOR_YELLOW "3rd" S_COLOR_WHITE; // draw in yellow
- } else if ( rank == 11 ) {
- s = "11th";
- } else if ( rank == 12 ) {
- s = "12th";
- } else if ( rank == 13 ) {
- s = "13th";
- } else if ( rank % 10 == 1 ) {
- s = va("%ist", rank);
- } else if ( rank % 10 == 2 ) {
- s = va("%ind", rank);
- } else if ( rank % 10 == 3 ) {
- s = va("%ird", rank);
- } else {
- s = va("%ith", rank);
- }
-
- Com_sprintf( str, sizeof( str ), "%s%s", t, s );
- return str;
-}
-
/*
=============
CG_Obituary
=============
*/
-static void CG_Obituary( entityState_t *ent ) {
- int mod;
- int target, attacker;
- char *message;
- char *message2;
- const char *targetInfo;
- const char *attackerInfo;
- char targetName[32];
- char attackerName[32];
- gender_t gender;
+static void CG_Obituary( entityState_t *ent )
+{
+ int mod;
+ int target, attacker;
+ char *message;
+ char *message2;
+ const char *targetInfo;
+ const char *attackerInfo;
+ char targetName[ 32 ];
+ char attackerName[ 32 ];
+ gender_t gender;
clientInfo_t *ci;
target = ent->otherEntityNum;
attacker = ent->otherEntityNum2;
mod = ent->eventParm;
- if ( target < 0 || target >= MAX_CLIENTS ) {
+ if( target < 0 || target >= MAX_CLIENTS )
CG_Error( "CG_Obituary: target out of range" );
- }
- ci = &cgs.clientinfo[target];
+
+ ci = &cgs.clientinfo[ target ];
- if ( attacker < 0 || attacker >= MAX_CLIENTS ) {
+ if( attacker < 0 || attacker >= MAX_CLIENTS )
+ {
attacker = ENTITYNUM_WORLD;
attackerInfo = NULL;
- } else {
- attackerInfo = CG_ConfigString( CS_PLAYERS + attacker );
}
+ else
+ attackerInfo = CG_ConfigString( CS_PLAYERS + attacker );
targetInfo = CG_ConfigString( CS_PLAYERS + target );
- if ( !targetInfo ) {
+
+ if( !targetInfo )
return;
- }
- Q_strncpyz( targetName, Info_ValueForKey( targetInfo, "n" ), sizeof(targetName) - 2);
+
+ Q_strncpyz( targetName, Info_ValueForKey( targetInfo, "n" ), sizeof( targetName ) - 2);
strcat( targetName, S_COLOR_WHITE );
message2 = "";
// check for single client messages
- switch( mod ) {
- case MOD_SUICIDE:
- message = "suicides";
- break;
- case MOD_FALLING:
- message = "cratered";
- break;
- case MOD_CRUSH:
- message = "was squished";
- break;
- case MOD_WATER:
- message = "sank like a rock";
- break;
- case MOD_SLIME:
- message = "melted";
- break;
- case MOD_LAVA:
- message = "does a back flip into the lava";
- break;
- case MOD_TARGET_LASER:
- message = "saw the light";
- break;
- case MOD_TRIGGER_HURT:
- message = "was in the wrong place";
- break;
- case MOD_HSPAWN:
- message = "should have run further";
- break;
- case MOD_ASPAWN:
- message = "was melted by the acid blood";
- break;
- default:
- message = NULL;
- break;
- }
-
- if (attacker == target) {
- gender = ci->gender;
- switch (mod) {
- case MOD_GRENADE_SPLASH:
- if ( gender == GENDER_FEMALE )
- message = "tripped on her own grenade";
- else if ( gender == GENDER_NEUTER )
- message = "tripped on its own grenade";
- else
- message = "tripped on his own grenade";
+ switch( mod )
+ {
+ case MOD_SUICIDE:
+ message = "suicides";
break;
- case MOD_ROCKET_SPLASH:
- if ( gender == GENDER_FEMALE )
- message = "blew herself up";
- else if ( gender == GENDER_NEUTER )
- message = "blew itself up";
- else
- message = "blew himself up";
+ case MOD_FALLING:
+ message = "cratered";
break;
- case MOD_FLAMER_SPLASH:
- if ( gender == GENDER_FEMALE )
- message = "toasted herself";
- else if ( gender == GENDER_NEUTER )
- message = "toasted itself";
- else
- message = "toasted himself";
+ case MOD_CRUSH:
+ message = "was squished";
+ break;
+ case MOD_WATER:
+ message = "sank like a rock";
+ break;
+ case MOD_SLIME:
+ message = "melted";
+ break;
+ case MOD_LAVA:
+ message = "does a back flip into the lava";
+ break;
+ case MOD_TARGET_LASER:
+ message = "saw the light";
+ break;
+ case MOD_TRIGGER_HURT:
+ message = "was in the wrong place";
break;
- case MOD_BFG_SPLASH:
- message = "should have used a smaller gun";
+ case MOD_HSPAWN:
+ message = "should have run further";
+ break;
+ case MOD_ASPAWN:
+ message = "was melted by the acid blood";
break;
default:
- if ( gender == GENDER_FEMALE )
- message = "killed herself";
- else if ( gender == GENDER_NEUTER )
- message = "killed itself";
- else
- message = "killed himself";
+ message = NULL;
break;
+ }
+
+ if( attacker == target )
+ {
+ gender = ci->gender;
+ switch( mod )
+ {
+ case MOD_GRENADE_SPLASH:
+ if( gender == GENDER_FEMALE )
+ message = "tripped on her own grenade";
+ else if( gender == GENDER_NEUTER )
+ message = "tripped on its own grenade";
+ else
+ message = "tripped on his own grenade";
+ break;
+
+ case MOD_ROCKET_SPLASH:
+ if( gender == GENDER_FEMALE )
+ message = "blew herself up";
+ else if( gender == GENDER_NEUTER )
+ message = "blew itself up";
+ else
+ message = "blew himself up";
+ break;
+
+ case MOD_FLAMER_SPLASH:
+ if( gender == GENDER_FEMALE )
+ message = "toasted herself";
+ else if( gender == GENDER_NEUTER )
+ message = "toasted itself";
+ else
+ message = "toasted himself";
+ break;
+
+ case MOD_BFG_SPLASH:
+ message = "should have used a smaller gun";
+ break;
+
+ default:
+ if( gender == GENDER_FEMALE )
+ message = "killed herself";
+ else if( gender == GENDER_NEUTER )
+ message = "killed itself";
+ else
+ message = "killed himself";
+ break;
}
}
- if (message) {
- CG_Printf( "%s %s.\n", targetName, message);
+ if( message )
+ {
+ CG_Printf( "%s %s.\n", targetName, message );
return;
}
// check for kill messages from the current clientNum
- if ( attacker == cg.snap->ps.clientNum ) {
+ if( attacker == cg.snap->ps.clientNum )
+ {
char *s;
- s = va("You fragged %s", targetName );
+ s = va( "You fragged %s", targetName );
CG_CenterPrint( s, SCREEN_HEIGHT * 0.30, BIGCHAR_WIDTH );
// print the text message as well
}
// check for double client messages
- if ( !attackerInfo ) {
+ if( !attackerInfo )
+ {
attacker = ENTITYNUM_WORLD;
strcpy( attackerName, "noname" );
- } else {
- Q_strncpyz( attackerName, Info_ValueForKey( attackerInfo, "n" ), sizeof(attackerName) - 2);
+ }
+ else
+ {
+ Q_strncpyz( attackerName, Info_ValueForKey( attackerInfo, "n" ), sizeof( attackerName ) - 2);
strcat( attackerName, S_COLOR_WHITE );
// check for kill messages about the current clientNum
- if ( target == cg.snap->ps.clientNum ) {
+ if( target == cg.snap->ps.clientNum )
Q_strncpyz( cg.killerName, attackerName, sizeof( cg.killerName ) );
- }
}
- if ( attacker != ENTITYNUM_WORLD ) {
- switch (mod) {
- case MOD_GRAPPLE:
- message = "was caught by";
- break;
- case MOD_GAUNTLET:
- message = "was pummeled by";
- break;
- case MOD_MACHINEGUN:
- message = "was machinegunned by";
- break;
- case MOD_CHAINGUN:
- message = "was chaingunned by";
- break;
- case MOD_SHOTGUN:
- message = "was gunned down by";
- break;
- case MOD_GRENADE:
- message = "ate";
- message2 = "'s grenade";
- break;
- case MOD_GRENADE_SPLASH:
- message = "was shredded by";
- message2 = "'s shrapnel";
- break;
- case MOD_ROCKET:
- message = "ate";
- message2 = "'s rocket";
- break;
- case MOD_ROCKET_SPLASH:
- message = "almost dodged";
- message2 = "'s rocket";
- break;
- case MOD_FLAMER:
- message = "was toasted by";
- message2 = "'s flamer";
- break;
- case MOD_FLAMER_SPLASH:
- message = "was toasted by";
- message2 = "'s flamer";
- break;
- case MOD_RAILGUN:
- message = "was railed by";
- break;
- case MOD_LIGHTNING:
- message = "was electrocuted by";
- break;
- case MOD_VENOM:
- message = "was biten by";
- break;
- case MOD_BFG:
- case MOD_BFG_SPLASH:
- message = "was blasted by";
- message2 = "'s BFG";
- break;
- case MOD_TELEFRAG:
- message = "tried to invade";
- message2 = "'s personal space";
- break;
- default:
- message = "was killed by";
- break;
+ if( attacker != ENTITYNUM_WORLD )
+ {
+ switch( mod )
+ {
+ case MOD_GRAPPLE:
+ message = "was caught by";
+ break;
+ case MOD_GAUNTLET:
+ message = "was pummeled by";
+ break;
+ case MOD_MACHINEGUN:
+ message = "was machinegunned by";
+ break;
+ case MOD_CHAINGUN:
+ message = "was chaingunned by";
+ break;
+ case MOD_SHOTGUN:
+ message = "was gunned down by";
+ break;
+ case MOD_GRENADE:
+ message = "ate";
+ message2 = "'s grenade";
+ break;
+ case MOD_GRENADE_SPLASH:
+ message = "was shredded by";
+ message2 = "'s shrapnel";
+ break;
+ case MOD_ROCKET:
+ message = "ate";
+ message2 = "'s rocket";
+ break;
+ case MOD_ROCKET_SPLASH:
+ message = "almost dodged";
+ message2 = "'s rocket";
+ break;
+ case MOD_FLAMER:
+ message = "was toasted by";
+ message2 = "'s flamer";
+ break;
+ case MOD_FLAMER_SPLASH:
+ message = "was toasted by";
+ message2 = "'s flamer";
+ break;
+ case MOD_RAILGUN:
+ message = "was railed by";
+ break;
+ case MOD_LIGHTNING:
+ message = "was electrocuted by";
+ break;
+ case MOD_VENOM:
+ message = "was biten by";
+ break;
+ case MOD_BFG:
+ case MOD_BFG_SPLASH:
+ message = "was blasted by";
+ message2 = "'s BFG";
+ break;
+ case MOD_TELEFRAG:
+ message = "tried to invade";
+ message2 = "'s personal space";
+ break;
+ default:
+ message = "was killed by";
+ break;
}
- if (message) {
+ if( message )
+ {
CG_Printf( "%s %s %s%s\n",
- targetName, message, attackerName, message2);
+ targetName, message, attackerName, message2 );
return;
}
}
@@ -293,94 +261,29 @@ static void CG_Obituary( entityState_t *ent ) {
//==========================================================================
/*
-===============
-CG_UseItem
-===============
-*/
-static void CG_UseItem( centity_t *cent ) {
- clientInfo_t *ci;
- int itemNum, clientNum;
- gitem_t *item;
- entityState_t *es;
-
- es = &cent->currentState;
-
- itemNum = (es->event & ~EV_EVENT_BITS) - EV_USE_ITEM0;
- if ( itemNum < 0 || itemNum > HI_NUM_HOLDABLE ) {
- itemNum = 0;
- }
-
- // print a message if the local player
- if ( es->number == cg.snap->ps.clientNum ) {
- if ( !itemNum ) {
- CG_CenterPrint( "No item to use", SCREEN_HEIGHT * 0.30, BIGCHAR_WIDTH );
- } else {
- /*item = BG_FindItemForHoldable( itemNum );*/
- CG_CenterPrint( va("Use %s", item->pickup_name), SCREEN_HEIGHT * 0.30, BIGCHAR_WIDTH );
- }
- }
-
- switch ( itemNum ) {
- default:
- case HI_NONE:
- trap_S_StartSound (NULL, es->number, CHAN_BODY, cgs.media.useNothingSound );
- break;
-
- case HI_TELEPORTER:
- break;
-
- case HI_MEDKIT:
- clientNum = cent->currentState.clientNum;
- if ( clientNum >= 0 && clientNum < MAX_CLIENTS ) {
- ci = &cgs.clientinfo[ clientNum ];
- ci->medkitUsageTime = cg.time;
- }
- trap_S_StartSound (NULL, es->number, CHAN_BODY, cgs.media.medkitSound );
- break;
- }
-
-}
-
-/*
-================
-CG_ItemPickup
-
-A new item was picked up this frame
-================
-*/
-static void CG_ItemPickup( int itemNum ) {
- cg.itemPickup = itemNum;
- cg.itemPickupTime = cg.time;
- cg.itemPickupBlendTime = cg.time;
- // see if it should be the grabbed weapon
-
-}
-
-
-/*
================
CG_PainEvent
Also called by playerstate transition
================
*/
-void CG_PainEvent( centity_t *cent, int health ) {
+void CG_PainEvent( centity_t *cent, int health )
+{
char *snd;
// don't do more than two pain sounds a second
- if ( cg.time - cent->pe.painTime < 500 ) {
+ if( cg.time - cent->pe.painTime < 500 )
return;
- }
- if ( health < 25 ) {
+ if( health < 25 )
snd = "*pain25_1.wav";
- } else if ( health < 50 ) {
+ else if( health < 50 )
snd = "*pain50_1.wav";
- } else if ( health < 75 ) {
+ else if( health < 75 )
snd = "*pain75_1.wav";
- } else {
+ else
snd = "*pain100_1.wav";
- }
+
trap_S_StartSound( NULL, cent->currentState.number, CHAN_VOICE,
CG_CustomSound( cent->currentState.number, snd ) );
@@ -584,597 +487,509 @@ void CG_EntityEvent( centity_t *cent, vec3_t position )
es = &cent->currentState;
event = es->event & ~EV_EVENT_BITS;
- if ( cg_debugEvents.integer ) {
+ if( cg_debugEvents.integer )
CG_Printf( "ent:%3i event:%3i ", es->number, event );
- }
- if ( !event ) {
+ if( !event )
+ {
DEBUGNAME("ZEROEVENT");
return;
}
clientNum = es->clientNum;
- if ( clientNum < 0 || clientNum >= MAX_CLIENTS ) {
+ if( clientNum < 0 || clientNum >= MAX_CLIENTS )
clientNum = 0;
- }
+
ci = &cgs.clientinfo[ clientNum ];
- switch ( event ) {
- //
- // movement generated events
- //
- case EV_FOOTSTEP:
- DEBUGNAME("EV_FOOTSTEP");
- if (cg_footsteps.integer) {
- trap_S_StartSound (NULL, es->number, CHAN_BODY,
- cgs.media.footsteps[ ci->footsteps ][rand()&3] );
- }
- break;
- case EV_FOOTSTEP_METAL:
- DEBUGNAME("EV_FOOTSTEP_METAL");
- if (cg_footsteps.integer) {
- trap_S_StartSound (NULL, es->number, CHAN_BODY,
- cgs.media.footsteps[ FOOTSTEP_METAL ][rand()&3] );
- }
- break;
- case EV_FOOTSTEP_SQUELCH:
- DEBUGNAME("EV_FOOTSTEP_SQUELCH");
- if (cg_footsteps.integer) {
- trap_S_StartSound (NULL, es->number, CHAN_BODY,
- cgs.media.footsteps[ FOOTSTEP_FLESH ][rand()&3] );
- }
- break;
- case EV_FOOTSPLASH:
- DEBUGNAME("EV_FOOTSPLASH");
- if (cg_footsteps.integer) {
- trap_S_StartSound (NULL, es->number, CHAN_BODY,
- cgs.media.footsteps[ FOOTSTEP_SPLASH ][rand()&3] );
- }
- break;
- case EV_FOOTWADE:
- DEBUGNAME("EV_FOOTWADE");
- if (cg_footsteps.integer) {
- trap_S_StartSound (NULL, es->number, CHAN_BODY,
- cgs.media.footsteps[ FOOTSTEP_SPLASH ][rand()&3] );
- }
- break;
- case EV_SWIM:
- DEBUGNAME("EV_SWIM");
- if (cg_footsteps.integer) {
- trap_S_StartSound (NULL, es->number, CHAN_BODY,
- cgs.media.footsteps[ FOOTSTEP_SPLASH ][rand()&3] );
- }
- break;
+ switch( event )
+ {
+ //
+ // movement generated events
+ //
+ case EV_FOOTSTEP:
+ DEBUGNAME( "EV_FOOTSTEP" );
+ if( cg_footsteps.integer )
+ {
+ trap_S_StartSound( NULL, es->number, CHAN_BODY,
+ cgs.media.footsteps[ ci->footsteps ][ rand( ) & 3 ] );
+ }
+ break;
+
+ case EV_FOOTSTEP_METAL:
+ DEBUGNAME( "EV_FOOTSTEP_METAL" );
+ if( cg_footsteps.integer )
+ {
+ trap_S_StartSound( NULL, es->number, CHAN_BODY,
+ cgs.media.footsteps[ FOOTSTEP_METAL ][ rand( ) & 3 ] );
+ }
+ break;
+
+ case EV_FOOTSTEP_SQUELCH:
+ DEBUGNAME( "EV_FOOTSTEP_SQUELCH" );
+ if( cg_footsteps.integer )
+ {
+ trap_S_StartSound( NULL, es->number, CHAN_BODY,
+ cgs.media.footsteps[ FOOTSTEP_FLESH ][ rand( ) & 3 ] );
+ }
+ break;
+
+ case EV_FOOTSPLASH:
+ DEBUGNAME( "EV_FOOTSPLASH" );
+ if( cg_footsteps.integer )
+ {
+ trap_S_StartSound( NULL, es->number, CHAN_BODY,
+ cgs.media.footsteps[ FOOTSTEP_SPLASH ][ rand( ) & 3 ] );
+ }
+ break;
+
+ case EV_FOOTWADE:
+ DEBUGNAME( "EV_FOOTWADE" );
+ if( cg_footsteps.integer )
+ {
+ trap_S_StartSound( NULL, es->number, CHAN_BODY,
+ cgs.media.footsteps[ FOOTSTEP_SPLASH ][ rand( ) & 3 ] );
+ }
+ break;
+
+ case EV_SWIM:
+ DEBUGNAME( "EV_SWIM" );
+ if( cg_footsteps.integer )
+ {
+ trap_S_StartSound( NULL, es->number, CHAN_BODY,
+ cgs.media.footsteps[ FOOTSTEP_SPLASH ][ rand( ) & 3 ] );
+ }
+ break;
- case EV_FALL_SHORT:
- DEBUGNAME("EV_FALL_SHORT");
- trap_S_StartSound (NULL, es->number, CHAN_AUTO, cgs.media.landSound );
- if ( clientNum == cg.predictedPlayerState.clientNum ) {
- // smooth landing z changes
- cg.landChange = -8;
- cg.landTime = cg.time;
- }
- break;
- case EV_FALL_MEDIUM:
- DEBUGNAME("EV_FALL_MEDIUM");
- // use normal pain sound
- trap_S_StartSound( NULL, es->number, CHAN_VOICE, CG_CustomSound( es->number, "*pain100_1.wav" ) );
- if ( clientNum == cg.predictedPlayerState.clientNum ) {
- // smooth landing z changes
- cg.landChange = -16;
- cg.landTime = cg.time;
- }
- break;
- case EV_FALL_FAR:
- DEBUGNAME("EV_FALL_FAR");
- trap_S_StartSound (NULL, es->number, CHAN_AUTO, CG_CustomSound( es->number, "*fall1.wav" ) );
- cent->pe.painTime = cg.time; // don't play a pain sound right after this
- if ( clientNum == cg.predictedPlayerState.clientNum ) {
- // smooth landing z changes
- cg.landChange = -24;
- cg.landTime = cg.time;
- }
- break;
-
- case EV_STEP_4:
- case EV_STEP_8:
- case EV_STEP_12:
- case EV_STEP_16: // smooth out step up transitions
- case EV_STEPDN_4:
- case EV_STEPDN_8:
- case EV_STEPDN_12:
- case EV_STEPDN_16: // smooth out step down transitions
- DEBUGNAME("EV_STEP");
- {
- float oldStep;
- int delta;
- int step;
-
- if( clientNum != cg.predictedPlayerState.clientNum )
- break;
-
- // if we are interpolating, we don't need to smooth steps
- if( cg.demoPlayback || ( cg.snap->ps.pm_flags & PMF_FOLLOW ) ||
- cg_nopredict.integer || cg_synchronousClients.integer )
- break;
-
- // check for stepping up before a previous step is completed
- delta = cg.time - cg.stepTime;
-
- if( delta < STEP_TIME )
- oldStep = cg.stepChange * ( STEP_TIME - delta ) / STEP_TIME;
- else
- oldStep = 0;
+ case EV_FALL_SHORT:
+ DEBUGNAME( "EV_FALL_SHORT" );
+ trap_S_StartSound( NULL, es->number, CHAN_AUTO, cgs.media.landSound );
+
+ if( clientNum == cg.predictedPlayerState.clientNum )
+ {
+ // smooth landing z changes
+ cg.landChange = -8;
+ cg.landTime = cg.time;
+ }
+ break;
+
+ case EV_FALL_MEDIUM:
+ DEBUGNAME( "EV_FALL_MEDIUM" );
+ // use normal pain sound
+ trap_S_StartSound( NULL, es->number, CHAN_VOICE, CG_CustomSound( es->number, "*pain100_1.wav" ) );
+
+ if( clientNum == cg.predictedPlayerState.clientNum )
+ {
+ // smooth landing z changes
+ cg.landChange = -16;
+ cg.landTime = cg.time;
+ }
+ break;
+
+ case EV_FALL_FAR:
+ DEBUGNAME( "EV_FALL_FAR" );
+ trap_S_StartSound (NULL, es->number, CHAN_AUTO, CG_CustomSound( es->number, "*fall1.wav" ) );
+ cent->pe.painTime = cg.time; // don't play a pain sound right after this
+
+ if( clientNum == cg.predictedPlayerState.clientNum )
+ {
+ // smooth landing z changes
+ cg.landChange = -24;
+ cg.landTime = cg.time;
+ }
+ break;
- // add this amount
- if( event >= EV_STEPDN_4 )
- {
- step = 4 * ( event - EV_STEPDN_4 + 1 );
- cg.stepChange = oldStep - step;
- }
- else
- {
- step = 4 * ( event - EV_STEP_4 + 1 );
- cg.stepChange = oldStep + step;
- }
+ case EV_STEP_4:
+ case EV_STEP_8:
+ case EV_STEP_12:
+ case EV_STEP_16: // smooth out step up transitions
+ case EV_STEPDN_4:
+ case EV_STEPDN_8:
+ case EV_STEPDN_12:
+ case EV_STEPDN_16: // smooth out step down transitions
+ DEBUGNAME( "EV_STEP" );
+ {
+ float oldStep;
+ int delta;
+ int step;
+
+ if( clientNum != cg.predictedPlayerState.clientNum )
+ break;
+
+ // if we are interpolating, we don't need to smooth steps
+ if( cg.demoPlayback || ( cg.snap->ps.pm_flags & PMF_FOLLOW ) ||
+ cg_nopredict.integer || cg_synchronousClients.integer )
+ break;
+
+ // check for stepping up before a previous step is completed
+ delta = cg.time - cg.stepTime;
+
+ if( delta < STEP_TIME )
+ oldStep = cg.stepChange * ( STEP_TIME - delta ) / STEP_TIME;
+ else
+ oldStep = 0;
+
+ // add this amount
+ if( event >= EV_STEPDN_4 )
+ {
+ step = 4 * ( event - EV_STEPDN_4 + 1 );
+ cg.stepChange = oldStep - step;
+ }
+ else
+ {
+ step = 4 * ( event - EV_STEP_4 + 1 );
+ cg.stepChange = oldStep + step;
+ }
+
+ if( cg.stepChange > MAX_STEP_CHANGE )
+ cg.stepChange = MAX_STEP_CHANGE;
+ else if( cg.stepChange < -MAX_STEP_CHANGE )
+ cg.stepChange = -MAX_STEP_CHANGE;
+
+ cg.stepTime = cg.time;
+ break;
+ }
+
+ case EV_JUMP_PAD:
+ DEBUGNAME( "EV_JUMP_PAD" );
+ // CG_Printf( "EV_JUMP_PAD w/effect #%i\n", es->eventParm );
+ {
+ localEntity_t *smoke;
+ vec3_t up = { 0, 0, 1 };
+
+
+ smoke = CG_SmokePuff( cent->lerpOrigin, up,
+ 32,
+ 1, 1, 1, 0.33f,
+ 1000,
+ cg.time, 0,
+ LEF_PUFF_DONT_SCALE,
+ cgs.media.smokePuffShader );
+ }
- if( cg.stepChange > MAX_STEP_CHANGE )
- cg.stepChange = MAX_STEP_CHANGE;
- else if( cg.stepChange < -MAX_STEP_CHANGE )
- cg.stepChange = -MAX_STEP_CHANGE;
-
- cg.stepTime = cg.time;
- break;
- }
-
- case EV_JUMP_PAD:
- DEBUGNAME("EV_JUMP_PAD");
-// CG_Printf( "EV_JUMP_PAD w/effect #%i\n", es->eventParm );
- {
- localEntity_t *smoke;
- vec3_t up = {0, 0, 1};
+ // boing sound at origin, jump sound on player
+ trap_S_StartSound( cent->lerpOrigin, -1, CHAN_VOICE, cgs.media.jumpPadSound );
+ trap_S_StartSound( NULL, es->number, CHAN_VOICE, CG_CustomSound( es->number, "*jump1.wav" ) );
+ break;
+ case EV_JUMP:
+ DEBUGNAME( "EV_JUMP" );
+ trap_S_StartSound( NULL, es->number, CHAN_VOICE, CG_CustomSound( es->number, "*jump1.wav" ) );
+ break;
+
+ case EV_TAUNT:
+ DEBUGNAME( "EV_TAUNT" );
+ trap_S_StartSound( NULL, es->number, CHAN_VOICE, CG_CustomSound( es->number, "*taunt.wav" ) );
+ break;
+
+ case EV_WATER_TOUCH:
+ DEBUGNAME( "EV_WATER_TOUCH" );
+ trap_S_StartSound( NULL, es->number, CHAN_AUTO, cgs.media.watrInSound );
+ break;
+
+ case EV_WATER_LEAVE:
+ DEBUGNAME( "EV_WATER_LEAVE" );
+ trap_S_StartSound( NULL, es->number, CHAN_AUTO, cgs.media.watrOutSound );
+ break;
+
+ case EV_WATER_UNDER:
+ DEBUGNAME( "EV_WATER_UNDER" );
+ trap_S_StartSound( NULL, es->number, CHAN_AUTO, cgs.media.watrUnSound );
+ break;
+
+ case EV_WATER_CLEAR:
+ DEBUGNAME( "EV_WATER_CLEAR" );
+ trap_S_StartSound( NULL, es->number, CHAN_AUTO, CG_CustomSound( es->number, "*gasp.wav" ) );
+ break;
- smoke = CG_SmokePuff( cent->lerpOrigin, up,
- 32,
- 1, 1, 1, 0.33f,
- 1000,
- cg.time, 0,
- LEF_PUFF_DONT_SCALE,
- cgs.media.smokePuffShader );
- }
- // boing sound at origin, jump sound on player
- trap_S_StartSound ( cent->lerpOrigin, -1, CHAN_VOICE, cgs.media.jumpPadSound );
- trap_S_StartSound (NULL, es->number, CHAN_VOICE, CG_CustomSound( es->number, "*jump1.wav" ) );
- break;
-
- case EV_JUMP:
- DEBUGNAME("EV_JUMP");
- trap_S_StartSound (NULL, es->number, CHAN_VOICE, CG_CustomSound( es->number, "*jump1.wav" ) );
- break;
- case EV_TAUNT:
- DEBUGNAME("EV_TAUNT");
- trap_S_StartSound (NULL, es->number, CHAN_VOICE, CG_CustomSound( es->number, "*taunt.wav" ) );
- break;
- case EV_WATER_TOUCH:
- DEBUGNAME("EV_WATER_TOUCH");
- trap_S_StartSound (NULL, es->number, CHAN_AUTO, cgs.media.watrInSound );
- break;
- case EV_WATER_LEAVE:
- DEBUGNAME("EV_WATER_LEAVE");
- trap_S_StartSound (NULL, es->number, CHAN_AUTO, cgs.media.watrOutSound );
- break;
- case EV_WATER_UNDER:
- DEBUGNAME("EV_WATER_UNDER");
- trap_S_StartSound (NULL, es->number, CHAN_AUTO, cgs.media.watrUnSound );
- break;
- case EV_WATER_CLEAR:
- DEBUGNAME("EV_WATER_CLEAR");
- trap_S_StartSound (NULL, es->number, CHAN_AUTO, CG_CustomSound( es->number, "*gasp.wav" ) );
- break;
-
- case EV_ITEM_PICKUP:
- DEBUGNAME("EV_ITEM_PICKUP");
- {
- }
- break;
+ case EV_ITEM_PICKUP:
+ DEBUGNAME( "EV_ITEM_PICKUP" );
+ {
+ }
+ break;
- case EV_GLOBAL_ITEM_PICKUP:
- DEBUGNAME("EV_GLOBAL_ITEM_PICKUP");
- {
- }
- break;
-
- //
- // weapon events
- //
- case EV_NOAMMO:
- DEBUGNAME("EV_NOAMMO");
-// trap_S_StartSound (NULL, es->number, CHAN_AUTO, cgs.media.noAmmoSound );
- if ( es->number == cg.snap->ps.clientNum ) {
- CG_OutOfAmmoChange();
- }
- break;
- case EV_CHANGE_WEAPON:
- DEBUGNAME("EV_CHANGE_WEAPON");
- trap_S_StartSound (NULL, es->number, CHAN_AUTO, cgs.media.selectSound );
- break;
- case EV_NEXT_WEAPON:
- DEBUGNAME("EV_NEXT_WEAPON");
- CG_NextWeapon_f( );
- break;
- case EV_FIRE_WEAPON:
- DEBUGNAME("EV_FIRE_WEAPON");
- CG_FireWeapon( cent, 0 );
- break;
- case EV_FIRE_WEAPON2:
- DEBUGNAME("EV_FIRE_WEAPON2");
- CG_FireWeapon( cent, 1 ); //FIXME:??
- break;
- case EV_FIRE_WEAPON3:
- DEBUGNAME("EV_FIRE_WEAPON3");
- CG_FireWeapon( cent, 2 ); //FIXME:??
- break;
- case EV_USE_ITEM0:
- DEBUGNAME("EV_USE_ITEM0");
- CG_UseItem( cent );
- break;
- case EV_USE_ITEM1:
- DEBUGNAME("EV_USE_ITEM1");
- CG_UseItem( cent );
- break;
- case EV_USE_ITEM2:
- DEBUGNAME("EV_USE_ITEM2");
- CG_UseItem( cent );
- break;
- case EV_USE_ITEM3:
- DEBUGNAME("EV_USE_ITEM3");
- CG_UseItem( cent );
- break;
- case EV_USE_ITEM4:
- DEBUGNAME("EV_USE_ITEM4");
- CG_UseItem( cent );
- break;
- case EV_USE_ITEM5:
- DEBUGNAME("EV_USE_ITEM5");
- CG_UseItem( cent );
- break;
- case EV_USE_ITEM6:
- DEBUGNAME("EV_USE_ITEM6");
- CG_UseItem( cent );
- break;
- case EV_USE_ITEM7:
- DEBUGNAME("EV_USE_ITEM7");
- CG_UseItem( cent );
- break;
- case EV_USE_ITEM8:
- DEBUGNAME("EV_USE_ITEM8");
- CG_UseItem( cent );
- break;
- case EV_USE_ITEM9:
- DEBUGNAME("EV_USE_ITEM9");
- CG_UseItem( cent );
- break;
- case EV_USE_ITEM10:
- DEBUGNAME("EV_USE_ITEM10");
- CG_UseItem( cent );
- break;
- case EV_USE_ITEM11:
- DEBUGNAME("EV_USE_ITEM11");
- CG_UseItem( cent );
- break;
- case EV_USE_ITEM12:
- DEBUGNAME("EV_USE_ITEM12");
- CG_UseItem( cent );
- break;
- case EV_USE_ITEM13:
- DEBUGNAME("EV_USE_ITEM13");
- CG_UseItem( cent );
- break;
- case EV_USE_ITEM14:
- DEBUGNAME("EV_USE_ITEM14");
- CG_UseItem( cent );
- break;
-
- //=================================================================
-
- //
- // other events
- //
- case EV_PLAYER_TELEPORT_IN:
- DEBUGNAME("EV_PLAYER_TELEPORT_IN");
- trap_S_StartSound (NULL, es->number, CHAN_AUTO, cgs.media.teleInSound );
- CG_SpawnEffect( position);
- break;
-
- case EV_PLAYER_TELEPORT_OUT:
- DEBUGNAME("EV_PLAYER_TELEPORT_OUT");
- trap_S_StartSound (NULL, es->number, CHAN_AUTO, cgs.media.teleOutSound );
- CG_SpawnEffect( position);
- break;
-
- case EV_ITEM_POP:
- DEBUGNAME("EV_ITEM_POP");
- trap_S_StartSound (NULL, es->number, CHAN_AUTO, cgs.media.respawnSound );
- break;
- case EV_ITEM_RESPAWN:
- DEBUGNAME("EV_ITEM_RESPAWN");
- cent->miscTime = cg.time; // scale up from this
- trap_S_StartSound (NULL, es->number, CHAN_AUTO, cgs.media.respawnSound );
- break;
-
- //TA: make alien items "grow"
- case EV_BUILD_CONSTRUCT:
- DEBUGNAME("EV_BUILD_CONSTRUCT");
- cent->miscTime = cg.time; // scale up from this
- //probably a better place for this, but for the time being it lives here
- memset( &cent->lerpFrame, 0, sizeof( lerpFrame_t ) );
- cent->buildableAnim = es->eventParm;
- break;
-
- //TA: make alien creep "recede"
- case EV_BUILD_DESTROY:
- DEBUGNAME("EV_BUILD_DESTROY");
- cent->miscTime = -cg.time; // scale down from this
- break;
-
- //TA: trigger an anim on a buildable item
- case EV_BUILD_ANIM:
- DEBUGNAME("EV_BUILD_ANIM");
- if( cent->buildableAnim == es->torsoAnim || es->eventParm & ANIM_TOGGLEBIT )
+ case EV_GLOBAL_ITEM_PICKUP:
+ DEBUGNAME( "EV_GLOBAL_ITEM_PICKUP" );
+ {
+ }
+ break;
+
+ //
+ // weapon events
+ //
+ case EV_NOAMMO:
+ DEBUGNAME( "EV_NOAMMO" );
+ // trap_S_StartSound (NULL, es->number, CHAN_AUTO, cgs.media.noAmmoSound );
+ {
+ }
+ break;
+
+ case EV_CHANGE_WEAPON:
+ DEBUGNAME( "EV_CHANGE_WEAPON" );
+ trap_S_StartSound( NULL, es->number, CHAN_AUTO, cgs.media.selectSound );
+ break;
+
+ case EV_NEXT_WEAPON:
+ DEBUGNAME( "EV_NEXT_WEAPON" );
+ CG_NextWeapon_f( );
+ break;
+
+ case EV_FIRE_WEAPON:
+ DEBUGNAME( "EV_FIRE_WEAPON" );
+ CG_FireWeapon( cent, 0 );
+ break;
+
+ case EV_FIRE_WEAPON2:
+ DEBUGNAME( "EV_FIRE_WEAPON2" );
+ CG_FireWeapon( cent, 1 ); //FIXME:??
+ break;
+
+ case EV_FIRE_WEAPON3:
+ DEBUGNAME( "EV_FIRE_WEAPON3" );
+ CG_FireWeapon( cent, 2 ); //FIXME:??
+ break;
+
+ //=================================================================
+
+ //
+ // other events
+ //
+ case EV_PLAYER_TELEPORT_IN:
+ DEBUGNAME( "EV_PLAYER_TELEPORT_IN" );
+ trap_S_StartSound( NULL, es->number, CHAN_AUTO, cgs.media.teleInSound );
+ CG_SpawnEffect( position );
+ break;
+
+ case EV_PLAYER_TELEPORT_OUT:
+ DEBUGNAME( "EV_PLAYER_TELEPORT_OUT" );
+ trap_S_StartSound( NULL, es->number, CHAN_AUTO, cgs.media.teleOutSound );
+ CG_SpawnEffect( position );
+ break;
+
+ case EV_BUILD_CONSTRUCT:
+ DEBUGNAME( "EV_BUILD_CONSTRUCT" );
+ cent->miscTime = cg.time; // scale up from this
+ //probably a better place for this, but for the time being it lives here
+ memset( &cent->lerpFrame, 0, sizeof( lerpFrame_t ) );
cent->buildableAnim = es->eventParm;
- break;
-
- case EV_GRENADE_BOUNCE:
- DEBUGNAME("EV_GRENADE_BOUNCE");
- if ( rand() & 1 ) {
- trap_S_StartSound (NULL, es->number, CHAN_AUTO, cgs.media.hgrenb1aSound );
- } else {
- trap_S_StartSound (NULL, es->number, CHAN_AUTO, cgs.media.hgrenb2aSound );
- }
- break;
-
- //
- // missile impacts
- //
- case EV_MISSILE_HIT:
- DEBUGNAME("EV_MISSILE_HIT");
- ByteToDir( es->eventParm, dir );
- CG_MissileHitPlayer( es->weapon, position, dir, es->otherEntityNum, es->generic1 );
- break;
-
- case EV_MISSILE_MISS:
- DEBUGNAME("EV_MISSILE_MISS");
- ByteToDir( es->eventParm, dir );
- CG_MissileHitWall( es->weapon, 0, position, dir, IMPACTSOUND_DEFAULT, es->generic1 );
- break;
-
- case EV_MISSILE_MISS_METAL:
- DEBUGNAME("EV_MISSILE_MISS_METAL");
- ByteToDir( es->eventParm, dir );
- CG_MissileHitWall( es->weapon, 0, position, dir, IMPACTSOUND_METAL, es->generic1 );
- break;
-
- case EV_ITEM_EXPLOSION:
- DEBUGNAME("EV_ITEM_EXPLOSION");
- ByteToDir( es->eventParm, dir );
- CG_Explosion( 0, position, dir );
- break;
-
- case EV_RAILTRAIL:
-/* DEBUGNAME("EV_RAILTRAIL");
- cent->currentState.weapon = WP_RAILGUN;
- // if the end was on a nomark surface, don't make an explosion
- CG_RailTrail( es->origin2, es->pos.trBase );
- if ( es->eventParm != 255 ) {
+ break;
+
+ case EV_BUILD_DESTROY:
+ DEBUGNAME( "EV_BUILD_DESTROY" );
+ cent->miscTime = -cg.time; // scale down from this
+ break;
+
+ //TA: trigger an anim on a buildable item
+ case EV_BUILD_ANIM:
+ DEBUGNAME( "EV_BUILD_ANIM" );
+ if( cent->buildableAnim == es->torsoAnim || es->eventParm & ANIM_TOGGLEBIT )
+ cent->buildableAnim = es->eventParm;
+ break;
+
+ case EV_GRENADE_BOUNCE:
+ DEBUGNAME( "EV_GRENADE_BOUNCE" );
+ if( rand( ) & 1 )
+ trap_S_StartSound( NULL, es->number, CHAN_AUTO, cgs.media.hgrenb1aSound );
+ else
+ trap_S_StartSound( NULL, es->number, CHAN_AUTO, cgs.media.hgrenb2aSound );
+ break;
+
+ //
+ // missile impacts
+ //
+ case EV_MISSILE_HIT:
+ DEBUGNAME( "EV_MISSILE_HIT" );
ByteToDir( es->eventParm, dir );
- CG_MissileHitWall( es->weapon, es->clientNum, position, dir, IMPACTSOUND_DEFAULT );
- }*/
- break;
-
- case EV_TESLATRAIL:
- DEBUGNAME("EV_TESLATRAIL");
- cent->currentState.weapon = WP_TESLAGEN;
- CG_TeslaTrail( es->origin2, es->pos.trBase, es->generic1, es->clientNum );
- break;
-
- case EV_ALIENZAP:
- DEBUGNAME("EV_ALIENZAP");
- CG_AlienZap( es->origin2, es->pos.trBase, es->generic1, es->clientNum );
- break;
-
- case EV_BULLET_HIT_WALL:
- DEBUGNAME("EV_BULLET_HIT_WALL");
- ByteToDir( es->eventParm, dir );
- CG_Bullet( es->pos.trBase, es->otherEntityNum, dir, qfalse, ENTITYNUM_WORLD );
- break;
-
- case EV_BULLET_HIT_FLESH:
- DEBUGNAME("EV_BULLET_HIT_FLESH");
- CG_Bullet( es->pos.trBase, es->otherEntityNum, dir, qtrue, es->eventParm );
- break;
-
- case EV_LAS_HIT_WALL:
- DEBUGNAME("EV_LAS_HIT_WALL");
- ByteToDir( es->eventParm, dir );
- CG_LasGunHit( es->pos.trBase, es->otherEntityNum, dir, qfalse, ENTITYNUM_WORLD );
- break;
-
- case EV_LAS_HIT_FLESH:
- DEBUGNAME("EV_LAS_HIT_FLESH");
- CG_LasGunHit( es->pos.trBase, es->otherEntityNum, dir, qtrue, es->eventParm );
- break;
-
+ CG_MissileHitPlayer( es->weapon, position, dir, es->otherEntityNum, es->generic1 );
+ break;
+
+ case EV_MISSILE_MISS:
+ DEBUGNAME( "EV_MISSILE_MISS" );
+ ByteToDir( es->eventParm, dir );
+ CG_MissileHitWall( es->weapon, 0, position, dir, IMPACTSOUND_DEFAULT, es->generic1 );
+ break;
+
+ case EV_MISSILE_MISS_METAL:
+ DEBUGNAME( "EV_MISSILE_MISS_METAL" );
+ ByteToDir( es->eventParm, dir );
+ CG_MissileHitWall( es->weapon, 0, position, dir, IMPACTSOUND_METAL, es->generic1 );
+ break;
+
+ case EV_BUILDABLE_EXPLOSION:
+ DEBUGNAME( "EV_BUILDABLE_EXPLOSION" );
+ ByteToDir( es->eventParm, dir );
+ CG_Explosion( 0, position, dir );
+ break;
+
+ case EV_TESLATRAIL:
+ DEBUGNAME( "EV_TESLATRAIL" );
+ cent->currentState.weapon = WP_TESLAGEN;
+ CG_TeslaTrail( es->origin2, es->pos.trBase, es->generic1, es->clientNum );
+ break;
+
+ case EV_ALIENZAP:
+ DEBUGNAME( "EV_ALIENZAP" );
+ CG_AlienZap( es->origin2, es->pos.trBase, es->generic1, es->clientNum );
+ break;
+
+ case EV_BULLET_HIT_WALL:
+ DEBUGNAME( "EV_BULLET_HIT_WALL" );
+ ByteToDir( es->eventParm, dir );
+ CG_Bullet( es->pos.trBase, es->otherEntityNum, dir, qfalse, ENTITYNUM_WORLD );
+ break;
+
+ case EV_BULLET_HIT_FLESH:
+ DEBUGNAME( "EV_BULLET_HIT_FLESH" );
+ CG_Bullet( es->pos.trBase, es->otherEntityNum, dir, qtrue, es->eventParm );
+ break;
+
+ case EV_LAS_HIT_WALL:
+ DEBUGNAME( "EV_LAS_HIT_WALL" );
+ ByteToDir( es->eventParm, dir );
+ CG_LasGunHit( es->pos.trBase, es->otherEntityNum, dir, qfalse, ENTITYNUM_WORLD );
+ break;
+
+ case EV_LAS_HIT_FLESH:
+ DEBUGNAME( "EV_LAS_HIT_FLESH" );
+ CG_LasGunHit( es->pos.trBase, es->otherEntityNum, dir, qtrue, es->eventParm );
+ break;
+
#define MASS_EJECTION_VEL 300
- case EV_MASS_DRIVER_HIT:
- DEBUGNAME("EV_MASS_DRIVER_HIT");
- for( i = 0; i <= 10; i++ )
- {
- qhandle_t spark;
- vec3_t velocity;
- vec3_t accel = { 0.0f, 0.0f, -DEFAULT_GRAVITY };
- vec3_t origin, normal;
+ case EV_MASS_DRIVER_HIT:
+ DEBUGNAME( "EV_MASS_DRIVER_HIT" );
+ for( i = 0; i <= 10; i++ )
+ {
+ qhandle_t spark;
+ vec3_t velocity;
+ vec3_t accel = { 0.0f, 0.0f, -DEFAULT_GRAVITY };
+ vec3_t origin, normal;
+
+ ByteToDir( es->eventParm, normal );
+
+ VectorMA( es->pos.trBase, 10.0f, normal, origin );
+
+ if( crandom( ) > 0.5f )
+ spark = cgs.media.gibSpark1;
+ else
+ spark = cgs.media.gibSpark2;
+
+ velocity[ 0 ] = ( 2 * random( ) - 1.0f ) * MASS_EJECTION_VEL;
+ velocity[ 1 ] = ( 2 * random( ) - 1.0f ) * MASS_EJECTION_VEL;
+ velocity[ 2 ] = ( 2 * random( ) - 1.0f ) * MASS_EJECTION_VEL;
+
+ CG_LaunchSprite( origin, velocity, accel, 0.0f, 0.5f, 4.0f, 2.0f, 255, 0, rand( ) % 360,
+ cg.time, cg.time, 5000 + ( crandom( ) * 3000 ),
+ spark, qfalse, qfalse );
+ }
- ByteToDir( es->eventParm, normal );
+ break;
- VectorMA( es->pos.trBase, 10.0f, normal, origin );
+ case EV_GENERAL_SOUND:
+ DEBUGNAME( "EV_GENERAL_SOUND" );
+ if( cgs.gameSounds[ es->eventParm ] )
+ trap_S_StartSound( NULL, es->number, CHAN_VOICE, cgs.gameSounds[ es->eventParm ] );
+ else
+ {
+ s = CG_ConfigString( CS_SOUNDS + es->eventParm );
+ trap_S_StartSound( NULL, es->number, CHAN_VOICE, CG_CustomSound( es->number, s ) );
+ }
+ break;
- if( crandom( ) > 0.5f )
- spark = cgs.media.gibSpark1;
+ case EV_GLOBAL_SOUND: // play from the player's head so it never diminishes
+ DEBUGNAME( "EV_GLOBAL_SOUND" );
+ if( cgs.gameSounds[ es->eventParm ] )
+ trap_S_StartSound( NULL, cg.snap->ps.clientNum, CHAN_AUTO, cgs.gameSounds[ es->eventParm ] );
else
- spark = cgs.media.gibSpark2;
+ {
+ s = CG_ConfigString( CS_SOUNDS + es->eventParm );
+ trap_S_StartSound( NULL, cg.snap->ps.clientNum, CHAN_AUTO, CG_CustomSound( es->number, s ) );
+ }
+ break;
- velocity[ 0 ] = ( 2 * random( ) - 1.0f ) * MASS_EJECTION_VEL;
- velocity[ 1 ] = ( 2 * random( ) - 1.0f ) * MASS_EJECTION_VEL;
- velocity[ 2 ] = ( 2 * random( ) - 1.0f ) * MASS_EJECTION_VEL;
-
- CG_LaunchSprite( origin, velocity, accel, 0.0f, 0.5f, 4.0f, 2.0f, 255, 0, rand( ) % 360,
- cg.time, cg.time, 5000 + ( crandom( ) * 3000 ),
- spark, qfalse, qfalse );
- }
+ case EV_PAIN:
+ // local player sounds are triggered in CG_CheckLocalSounds,
+ // so ignore events on the player
+ DEBUGNAME( "EV_PAIN" );
+ if( cent->currentState.number != cg.snap->ps.clientNum )
+ CG_PainEvent( cent, es->eventParm );
+ break;
- break;
+ case EV_DEATH1:
+ case EV_DEATH2:
+ case EV_DEATH3:
+ DEBUGNAME( "EV_DEATHx" );
+ trap_S_StartSound( NULL, es->number, CHAN_VOICE,
+ CG_CustomSound( es->number, va( "*death%i.wav", event - EV_DEATH1 + 1 ) ) );
+ break;
- case EV_SHOTGUN:
- DEBUGNAME("EV_SHOTGUN");
- CG_ShotgunFire( es );
- break;
+ case EV_OBITUARY:
+ DEBUGNAME( "EV_OBITUARY" );
+ CG_Obituary( es );
+ break;
- case EV_GENERAL_SOUND:
- DEBUGNAME("EV_GENERAL_SOUND");
- if ( cgs.gameSounds[ es->eventParm ] ) {
- trap_S_StartSound (NULL, es->number, CHAN_VOICE, cgs.gameSounds[ es->eventParm ] );
- } else {
- s = CG_ConfigString( CS_SOUNDS + es->eventParm );
- trap_S_StartSound (NULL, es->number, CHAN_VOICE, CG_CustomSound( es->number, s ) );
- }
- break;
-
- case EV_GLOBAL_SOUND: // play from the player's head so it never diminishes
- DEBUGNAME("EV_GLOBAL_SOUND");
- if ( cgs.gameSounds[ es->eventParm ] ) {
- trap_S_StartSound (NULL, cg.snap->ps.clientNum, CHAN_AUTO, cgs.gameSounds[ es->eventParm ] );
- } else {
- s = CG_ConfigString( CS_SOUNDS + es->eventParm );
- trap_S_StartSound (NULL, cg.snap->ps.clientNum, CHAN_AUTO, CG_CustomSound( es->number, s ) );
- }
- break;
-
- case EV_PAIN:
- // local player sounds are triggered in CG_CheckLocalSounds,
- // so ignore events on the player
- DEBUGNAME("EV_PAIN");
- if ( cent->currentState.number != cg.snap->ps.clientNum ) {
- CG_PainEvent( cent, es->eventParm );
- }
- break;
-
- case EV_DEATH1:
- case EV_DEATH2:
- case EV_DEATH3:
- DEBUGNAME("EV_DEATHx");
- trap_S_StartSound( NULL, es->number, CHAN_VOICE,
- CG_CustomSound( es->number, va("*death%i.wav", event - EV_DEATH1 + 1) ) );
- break;
-
-
- case EV_OBITUARY:
- DEBUGNAME("EV_OBITUARY");
- CG_Obituary( es );
- break;
-
- //
- // powerup events
- //
- case EV_POWERUP_QUAD:
- DEBUGNAME("EV_POWERUP_QUAD");
- if ( es->number == cg.snap->ps.clientNum ) {
- cg.powerupActive = PW_QUAD;
- cg.powerupTime = cg.time;
- }
- trap_S_StartSound (NULL, es->number, CHAN_ITEM, cgs.media.quadSound );
- break;
- case EV_POWERUP_BATTLESUIT:
- DEBUGNAME("EV_POWERUP_BATTLESUIT");
- if ( es->number == cg.snap->ps.clientNum ) {
- cg.powerupActive = PW_BATTLESUIT;
- cg.powerupTime = cg.time;
- }
- trap_S_StartSound (NULL, es->number, CHAN_ITEM, cgs.media.protectSound );
- break;
- case EV_POWERUP_REGEN:
- DEBUGNAME("EV_POWERUP_REGEN");
- if ( es->number == cg.snap->ps.clientNum ) {
- cg.powerupActive = PW_REGEN;
- cg.powerupTime = cg.time;
- }
- trap_S_StartSound (NULL, es->number, CHAN_ITEM, cgs.media.regenSound );
- break;
-
- case EV_GIB_PLAYER:
- DEBUGNAME("EV_GIB_PLAYER");
- trap_S_StartSound( NULL, es->number, CHAN_BODY, cgs.media.gibSound );
- CG_GibPlayer( cent->lerpOrigin );
- break;
-
- case EV_GIB_ALIEN:
- DEBUGNAME("EV_GIB_ALIEN");
- trap_S_StartSound( NULL, es->number, CHAN_BODY, cgs.media.gibSound );
- CG_GenericGib( cent->lerpOrigin );
- break;
-
- case EV_STOPLOOPINGSOUND:
- DEBUGNAME("EV_STOPLOOPINGSOUND");
- trap_S_StopLoopingSound( es->number );
- es->loopSound = 0;
- break;
-
- case EV_DEBUG_LINE:
- DEBUGNAME("EV_DEBUG_LINE");
- CG_Beam( cent );
- break;
-
- case EV_MENU:
- DEBUGNAME("EV_MENU");
- if( es->number == cg.clientNum )
- CG_Menu( es->eventParm );
- break;
-
- case EV_BUILD_DELAY:
- DEBUGNAME("EV_BUILD_DELAY");
- //FIXME: change to "negative" sound
- trap_S_StartLocalSound( cgs.media.hitSound, CHAN_LOCAL_SOUND );
- cg.lastBuildAttempt = cg.time;
- break;
-
- case EV_POISONCLOUD:
- DEBUGNAME("EV_POISONCLOUD");
- cg.firstPoisonedTime = cg.time;
- break;
-
- case EV_KNOCKOVER:
- DEBUGNAME("EV_KNOCKOVER");
- cg.firstKnockedTime = cg.time;
- break;
-
- case EV_GETUP:
- DEBUGNAME("EV_GETUP");
- cg.firstGetUpTime = cg.time;
- break;
-
- case EV_PLAYER_RESPAWN:
- DEBUGNAME("EV_PLAYER_RESPAWN");
- if( es->number == cg.clientNum )
- cg.spawnTime = cg.time;
- break;
-
- default:
- DEBUGNAME("UNKNOWN");
- CG_Error( "Unknown event: %i", event );
- break;
- }
+ case EV_GIB_PLAYER:
+ DEBUGNAME( "EV_GIB_PLAYER" );
+ trap_S_StartSound( NULL, es->number, CHAN_BODY, cgs.media.gibSound );
+ CG_GibPlayer( cent->lerpOrigin );
+ break;
+
+ case EV_GIB_ALIEN:
+ DEBUGNAME( "EV_GIB_ALIEN" );
+ trap_S_StartSound( NULL, es->number, CHAN_BODY, cgs.media.gibSound );
+ CG_GenericGib( cent->lerpOrigin );
+ break;
+
+ case EV_STOPLOOPINGSOUND:
+ DEBUGNAME( "EV_STOPLOOPINGSOUND" );
+ trap_S_StopLoopingSound( es->number );
+ es->loopSound = 0;
+ break;
+
+ case EV_DEBUG_LINE:
+ DEBUGNAME( "EV_DEBUG_LINE" );
+ CG_Beam( cent );
+ break;
+
+ case EV_MENU:
+ DEBUGNAME( "EV_MENU" );
+ if( es->number == cg.clientNum )
+ CG_Menu( es->eventParm );
+ break;
+
+ case EV_BUILD_DELAY:
+ DEBUGNAME( "EV_BUILD_DELAY" );
+ //FIXME: change to "negative" sound
+ trap_S_StartLocalSound( cgs.media.hitSound, CHAN_LOCAL_SOUND );
+ cg.lastBuildAttempt = cg.time;
+ break;
+
+ case EV_POISONCLOUD:
+ DEBUGNAME( "EV_POISONCLOUD" );
+ cg.firstPoisonedTime = cg.time;
+ break;
+
+ case EV_KNOCKOVER:
+ DEBUGNAME( "EV_KNOCKOVER" );
+ cg.firstKnockedTime = cg.time;
+ break;
+ case EV_GETUP:
+ DEBUGNAME( "EV_GETUP" );
+ cg.firstGetUpTime = cg.time;
+ break;
+
+ case EV_PLAYER_RESPAWN:
+ DEBUGNAME( "EV_PLAYER_RESPAWN" );
+ if( es->number == cg.clientNum )
+ cg.spawnTime = cg.time;
+ break;
+
+ default:
+ DEBUGNAME( "UNKNOWN" );
+ CG_Error( "Unknown event: %i", event );
+ break;
+ }
}
@@ -1184,24 +999,27 @@ CG_CheckEvents
==============
*/
-void CG_CheckEvents( centity_t *cent ) {
+void CG_CheckEvents( centity_t *cent )
+{
// check for event-only entities
- if ( cent->currentState.eType > ET_EVENTS ) {
- if ( cent->previousEvent ) {
+ if( cent->currentState.eType > ET_EVENTS )
+ {
+ if( cent->previousEvent )
return; // already fired
- }
+
cent->previousEvent = 1;
cent->currentState.event = cent->currentState.eType - ET_EVENTS;
- } else {
+ }
+ else
+ {
// check for events riding with another entity
- if ( cent->currentState.event == cent->previousEvent ) {
+ if( cent->currentState.event == cent->previousEvent )
return;
- }
+
cent->previousEvent = cent->currentState.event;
- if ( ( cent->currentState.event & ~EV_EVENT_BITS ) == 0 ) {
+ if( ( cent->currentState.event & ~EV_EVENT_BITS ) == 0 )
return;
- }
}
// calculate the position at exactly the frame time
diff --git a/src/cgame/cg_local.h b/src/cgame/cg_local.h
index e6855a35..15be6a51 100644
--- a/src/cgame/cg_local.h
+++ b/src/cgame/cg_local.h
@@ -1295,6 +1295,7 @@ extern vmCvar_t ui_currentClass;
extern vmCvar_t ui_carriage;
extern vmCvar_t ui_stages;
extern vmCvar_t ui_dialog;
+extern vmCvar_t ui_loading;
//
// cg_main.c
diff --git a/src/cgame/cg_main.c b/src/cgame/cg_main.c
index 8d233476..cf99e93e 100644
--- a/src/cgame/cg_main.c
+++ b/src/cgame/cg_main.c
@@ -34,52 +34,65 @@ This is the only way control passes into the module.
This must be the very first function compiled into the .q3vm file
================
*/
-int vmMain( int command, int arg0, int arg1, int arg2, int arg3, int arg4, int arg5, int arg6, int arg7, int arg8, int arg9, int arg10, int arg11 ) {
- switch ( command ) {
- case CG_INIT:
- CG_Init( arg0, arg1, arg2 );
- return 0;
- case CG_SHUTDOWN:
- CG_Shutdown();
- return 0;
- case CG_CONSOLE_COMMAND:
- return CG_ConsoleCommand();
- case CG_DRAW_ACTIVE_FRAME:
- CG_DrawActiveFrame( arg0, arg1, arg2 );
- return 0;
- case CG_CROSSHAIR_PLAYER:
- return CG_CrosshairPlayer();
- case CG_LAST_ATTACKER:
- return CG_LastAttacker();
- case CG_KEY_EVENT:
- CG_KeyEvent(arg0, arg1);
- return 0;
- case CG_MOUSE_EVENT:
- cgDC.cursorx = cgs.cursorX;
- cgDC.cursory = cgs.cursorY;
- CG_MouseEvent(arg0, arg1);
- return 0;
- case CG_EVENT_HANDLING:
- CG_EventHandling(arg0);
- return 0;
- default:
- CG_Error( "vmMain: unknown command %i", command );
- break;
+int vmMain( int command, int arg0, int arg1, int arg2, int arg3,
+ int arg4, int arg5, int arg6, int arg7,
+ int arg8, int arg9, int arg10, int arg11 )
+{
+ switch( command )
+ {
+ case CG_INIT:
+ CG_Init( arg0, arg1, arg2 );
+ return 0;
+
+ case CG_SHUTDOWN:
+ CG_Shutdown( );
+ return 0;
+
+ case CG_CONSOLE_COMMAND:
+ return CG_ConsoleCommand( );
+
+ case CG_DRAW_ACTIVE_FRAME:
+ CG_DrawActiveFrame( arg0, arg1, arg2 );
+ return 0;
+
+ case CG_CROSSHAIR_PLAYER:
+ return CG_CrosshairPlayer( );
+
+ case CG_LAST_ATTACKER:
+ return CG_LastAttacker( );
+
+ case CG_KEY_EVENT:
+ CG_KeyEvent( arg0, arg1 );
+ return 0;
+
+ case CG_MOUSE_EVENT:
+ cgDC.cursorx = cgs.cursorX;
+ cgDC.cursory = cgs.cursorY;
+ CG_MouseEvent( arg0, arg1 );
+ return 0;
+
+ case CG_EVENT_HANDLING:
+ CG_EventHandling( arg0 );
+ return 0;
+
+ default:
+ CG_Error( "vmMain: unknown command %i", command );
+ break;
}
+
return -1;
}
cg_t cg;
cgs_t cgs;
-centity_t cg_entities[MAX_GENTITIES];
+centity_t cg_entities[ MAX_GENTITIES ];
//TA: weapons limit expanded:
//weaponInfo_t cg_weapons[MAX_WEAPONS];
-weaponInfo_t cg_weapons[32];
-upgradeInfo_t cg_upgrades[32];
+weaponInfo_t cg_weapons[ 32 ];
+upgradeInfo_t cg_upgrades[ 32 ];
-itemInfo_t cg_items[MAX_ITEMS];
buildableInfo_t cg_buildables[ BA_NUM_BUILDABLES ];
vmCvar_t cg_teslaTrailTime;
@@ -190,16 +203,19 @@ vmCvar_t ui_currentClass;
vmCvar_t ui_carriage;
vmCvar_t ui_stages;
vmCvar_t ui_dialog;
+vmCvar_t ui_loading;
-typedef struct {
+typedef struct
+{
vmCvar_t *vmCvar;
- char *cvarName;
- char *defaultString;
- int cvarFlags;
+ char *cvarName;
+ char *defaultString;
+ int cvarFlags;
} cvarTable_t;
-static cvarTable_t cvarTable[] = {
+static cvarTable_t cvarTable[ ] =
+{
{ &cg_ignore, "cg_ignore", "0", 0 }, // used for debugging
{ &cg_autoswitch, "cg_autoswitch", "1", CVAR_ARCHIVE },
{ &cg_drawGun, "cg_drawGun", "1", CVAR_ARCHIVE },
@@ -281,6 +297,7 @@ static cvarTable_t cvarTable[] = {
{ &ui_carriage, "ui_carriage", "", 0 },
{ &ui_stages, "ui_stages", "0 0", 0 },
{ &ui_dialog, "ui_dialog", "Text not set", 0 },
+ { &ui_loading, "ui_loading", "0", 0 },
// the following variables are created in other parts of the system,
// but we also reference them here
@@ -318,25 +335,30 @@ static int cvarTableSize = sizeof( cvarTable ) / sizeof( cvarTable[0] );
CG_RegisterCvars
=================
*/
-void CG_RegisterCvars( void ) {
- int i;
+void CG_RegisterCvars( void )
+{
+ int i;
cvarTable_t *cv;
- char var[MAX_TOKEN_CHARS];
+ char var[ MAX_TOKEN_CHARS ];
- for ( i = 0, cv = cvarTable ; i < cvarTableSize ; i++, cv++ ) {
+ for( i = 0, cv = cvarTable; i < cvarTableSize; i++, cv++ )
+ {
trap_Cvar_Register( cv->vmCvar, cv->cvarName,
cv->defaultString, cv->cvarFlags );
}
+ //repress standard Q3 console
+ trap_Cvar_Set( "con_notifytime", "-2" );
+
// see if we are also running the server on this machine
trap_Cvar_VariableStringBuffer( "sv_running", var, sizeof( var ) );
cgs.localServer = atoi( var );
forceModelModificationCount = cg_forceModel.modificationCount;
- trap_Cvar_Register(NULL, "model", DEFAULT_MODEL, CVAR_USERINFO | CVAR_ARCHIVE );
- trap_Cvar_Register(NULL, "headmodel", DEFAULT_MODEL, CVAR_USERINFO | CVAR_ARCHIVE );
- trap_Cvar_Register(NULL, "team_model", DEFAULT_TEAM_MODEL, CVAR_USERINFO | CVAR_ARCHIVE );
- trap_Cvar_Register(NULL, "team_headmodel", DEFAULT_TEAM_HEAD, CVAR_USERINFO | CVAR_ARCHIVE );
+ trap_Cvar_Register( NULL, "model", DEFAULT_MODEL, CVAR_USERINFO | CVAR_ARCHIVE );
+ trap_Cvar_Register( NULL, "headmodel", DEFAULT_MODEL, CVAR_USERINFO | CVAR_ARCHIVE );
+ trap_Cvar_Register( NULL, "team_model", DEFAULT_TEAM_MODEL, CVAR_USERINFO | CVAR_ARCHIVE );
+ trap_Cvar_Register( NULL, "team_headmodel", DEFAULT_TEAM_HEAD, CVAR_USERINFO | CVAR_ARCHIVE );
}
@@ -345,16 +367,19 @@ void CG_RegisterCvars( void ) {
CG_ForceModelChange
===================
*/
-static void CG_ForceModelChange( void ) {
+static void CG_ForceModelChange( void )
+{
int i;
- for (i=0 ; i<MAX_CLIENTS ; i++) {
+ for( i = 0; i < MAX_CLIENTS; i++ )
+ {
const char *clientInfo;
- clientInfo = CG_ConfigString( CS_PLAYERS+i );
- if ( !clientInfo[0] ) {
+ clientInfo = CG_ConfigString( CS_PLAYERS + i );
+
+ if( !clientInfo[ 0 ] )
continue;
- }
+
CG_NewClientInfo( i );
}
}
@@ -365,51 +390,52 @@ static void CG_ForceModelChange( void ) {
CG_UpdateCvars
=================
*/
-void CG_UpdateCvars( void ) {
- int i;
+void CG_UpdateCvars( void )
+{
+ int i;
cvarTable_t *cv;
- for ( i = 0, cv = cvarTable ; i < cvarTableSize ; i++, cv++ ) {
+ for( i = 0, cv = cvarTable; i < cvarTableSize; i++, cv++ )
trap_Cvar_Update( cv->vmCvar );
- }
// check for modications here
// If team overlay is on, ask for updates from the server. If its off,
// let the server know so we don't receive it
- if ( drawTeamOverlayModificationCount != cg_drawTeamOverlay.modificationCount ) {
+ if( drawTeamOverlayModificationCount != cg_drawTeamOverlay.modificationCount )
+ {
drawTeamOverlayModificationCount = cg_drawTeamOverlay.modificationCount;
- if ( cg_drawTeamOverlay.integer > 0 ) {
+ if( cg_drawTeamOverlay.integer > 0 )
trap_Cvar_Set( "teamoverlay", "1" );
- } else {
+ else
trap_Cvar_Set( "teamoverlay", "0" );
- }
- // FIXME E3 HACK
- trap_Cvar_Set( "teamoverlay", "1" );
}
// if force model changed
- if ( forceModelModificationCount != cg_forceModel.modificationCount ) {
+ if( forceModelModificationCount != cg_forceModel.modificationCount )
+ {
forceModelModificationCount = cg_forceModel.modificationCount;
- CG_ForceModelChange();
+ CG_ForceModelChange( );
}
}
-int CG_CrosshairPlayer( void ) {
- if ( cg.time > ( cg.crosshairClientTime + 1000 ) ) {
+int CG_CrosshairPlayer( void )
+{
+ if( cg.time > ( cg.crosshairClientTime + 1000 ) )
return -1;
- }
+
return cg.crosshairClientNum;
}
-int CG_LastAttacker( void ) {
- if ( !cg.attackerTime ) {
+int CG_LastAttacker( void )
+{
+ if( !cg.attackerTime )
return -1;
- }
- return cg.snap->ps.persistant[PERS_ATTACKER];
+
+ return cg.snap->ps.persistant[ PERS_ATTACKER ];
}
void CG_RemoveConsoleLine( void )
@@ -433,13 +459,14 @@ void CG_RemoveConsoleLine( void )
cg.numConsoleLines--;
}
-void QDECL CG_Printf( const char *msg, ... ) {
- va_list argptr;
- char text[1024];
+void QDECL CG_Printf( const char *msg, ... )
+{
+ va_list argptr;
+ char text[ 1024 ];
- va_start (argptr, msg);
- vsprintf (text, msg, argptr);
- va_end (argptr);
+ va_start( argptr, msg );
+ vsprintf( text, msg, argptr );
+ va_end( argptr );
//TA: team arena UI based console
if( cg.numConsoleLines == MAX_CONSOLE_LINES )
@@ -456,13 +483,14 @@ void QDECL CG_Printf( const char *msg, ... ) {
trap_Print( text );
}
-void QDECL CG_Error( const char *msg, ... ) {
- va_list argptr;
- char text[1024];
+void QDECL CG_Error( const char *msg, ... )
+{
+ va_list argptr;
+ char text[ 1024 ];
- va_start (argptr, msg);
- vsprintf (text, msg, argptr);
- va_end (argptr);
+ va_start( argptr, msg );
+ vsprintf( text, msg, argptr );
+ va_end( argptr );
trap_Error( text );
}
@@ -470,15 +498,16 @@ void QDECL CG_Error( const char *msg, ... ) {
#ifndef CGAME_HARD_LINKED
// this is only here so the functions in q_shared.c and bg_*.c can link (FIXME)
-void QDECL Com_Error( int level, const char *error, ... ) {
- va_list argptr;
+void QDECL Com_Error( int level, const char *error, ... )
+{
+ va_list argptr;
char text[1024];
- va_start (argptr, error);
- vsprintf (text, error, argptr);
- va_end (argptr);
+ va_start( argptr, error );
+ vsprintf( text, error, argptr );
+ va_end( argptr );
- CG_Error( "%s", text);
+ CG_Error( "%s", text );
}
void QDECL Com_Printf( const char *msg, ... ) {
@@ -513,8 +542,9 @@ void QDECL Com_Printf( const char *msg, ... ) {
CG_Argv
================
*/
-const char *CG_Argv( int arg ) {
- static char buffer[MAX_STRING_CHARS];
+const char *CG_Argv( int arg )
+{
+ static char buffer[ MAX_STRING_CHARS ];
trap_Argv( arg, buffer, sizeof( buffer ) );
@@ -531,7 +561,8 @@ CG_RegisterItemSounds
The server says this item is used on this level
=================
*/
-static void CG_RegisterItemSounds( int itemNum ) {
+static void CG_RegisterItemSounds( int itemNum )
+{
}
@@ -542,125 +573,98 @@ CG_RegisterSounds
called during a precache command
=================
*/
-static void CG_RegisterSounds( void ) {
- int i;
- char items[MAX_ITEMS+1];
- char name[MAX_QPATH];
+static void CG_RegisterSounds( void )
+{
+ int i;
+ char items[ MAX_ITEMS + 1 ];
+ char name[ MAX_QPATH ];
const char *soundName;
// voice commands
- cgs.media.oneMinuteSound = trap_S_RegisterSound( "sound/feedback/1_minute.wav", qtrue );
- cgs.media.fiveMinuteSound = trap_S_RegisterSound( "sound/feedback/5_minute.wav", qtrue );
- cgs.media.suddenDeathSound = trap_S_RegisterSound( "sound/feedback/sudden_death.wav", qtrue );
- cgs.media.oneFragSound = trap_S_RegisterSound( "sound/feedback/1_frag.wav", qtrue );
- cgs.media.twoFragSound = trap_S_RegisterSound( "sound/feedback/2_frags.wav", qtrue );
- cgs.media.threeFragSound = trap_S_RegisterSound( "sound/feedback/3_frags.wav", qtrue );
- cgs.media.count3Sound = trap_S_RegisterSound( "sound/feedback/three.wav", qtrue );
- cgs.media.count2Sound = trap_S_RegisterSound( "sound/feedback/two.wav", qtrue );
- cgs.media.count1Sound = trap_S_RegisterSound( "sound/feedback/one.wav", qtrue );
- cgs.media.countFightSound = trap_S_RegisterSound( "sound/feedback/fight.wav", qtrue );
- cgs.media.countPrepareSound = trap_S_RegisterSound( "sound/feedback/prepare.wav", qtrue );
-
- cgs.media.alienStageTransition = trap_S_RegisterSound( "sound/announcements/overmindevolved.wav", qtrue );
- cgs.media.humanStageTransition = trap_S_RegisterSound( "sound/announcements/reinforcement.wav", qtrue );
+ cgs.media.alienStageTransition = trap_S_RegisterSound( "sound/announcements/overmindevolved.wav", qtrue );
+ cgs.media.humanStageTransition = trap_S_RegisterSound( "sound/announcements/reinforcement.wav", qtrue );
- cgs.media.tracerSound = trap_S_RegisterSound( "sound/weapons/machinegun/buletby1.wav", qfalse );
- cgs.media.selectSound = trap_S_RegisterSound( "sound/weapons/change.wav", qfalse );
- cgs.media.wearOffSound = trap_S_RegisterSound( "sound/items/wearoff.wav", qfalse );
- cgs.media.useNothingSound = trap_S_RegisterSound( "sound/items/use_nothing.wav", qfalse );
- cgs.media.gibSound = trap_S_RegisterSound( "sound/player/gibsplt1.wav", qfalse );
- cgs.media.gibBounce1Sound = trap_S_RegisterSound( "sound/player/gibimp1.wav", qfalse );
- cgs.media.gibBounce2Sound = trap_S_RegisterSound( "sound/player/gibimp2.wav", qfalse );
- cgs.media.gibBounce3Sound = trap_S_RegisterSound( "sound/player/gibimp3.wav", qfalse );
+ cgs.media.tracerSound = trap_S_RegisterSound( "sound/weapons/machinegun/buletby1.wav", qfalse );
+ cgs.media.selectSound = trap_S_RegisterSound( "sound/weapons/change.wav", qfalse );
+ cgs.media.wearOffSound = trap_S_RegisterSound( "sound/items/wearoff.wav", qfalse );
+ cgs.media.useNothingSound = trap_S_RegisterSound( "sound/items/use_nothing.wav", qfalse );
+ cgs.media.gibSound = trap_S_RegisterSound( "sound/player/gibsplt1.wav", qfalse );
+ cgs.media.gibBounce1Sound = trap_S_RegisterSound( "sound/player/gibimp1.wav", qfalse );
+ cgs.media.gibBounce2Sound = trap_S_RegisterSound( "sound/player/gibimp2.wav", qfalse );
+ cgs.media.gibBounce3Sound = trap_S_RegisterSound( "sound/player/gibimp3.wav", qfalse );
- cgs.media.teleInSound = trap_S_RegisterSound( "sound/world/telein.wav", qfalse );
- cgs.media.teleOutSound = trap_S_RegisterSound( "sound/world/teleout.wav", qfalse );
- cgs.media.respawnSound = trap_S_RegisterSound( "sound/items/respawn1.wav", qfalse );
+ cgs.media.teleInSound = trap_S_RegisterSound( "sound/world/telein.wav", qfalse );
+ cgs.media.teleOutSound = trap_S_RegisterSound( "sound/world/teleout.wav", qfalse );
+ cgs.media.respawnSound = trap_S_RegisterSound( "sound/items/respawn1.wav", qfalse );
- cgs.media.noAmmoSound = trap_S_RegisterSound( "sound/weapons/noammo.wav", qfalse );
+ cgs.media.noAmmoSound = trap_S_RegisterSound( "sound/weapons/noammo.wav", qfalse );
- cgs.media.talkSound = trap_S_RegisterSound( "sound/player/talk.wav", qfalse );
- cgs.media.landSound = trap_S_RegisterSound( "sound/player/land1.wav", qfalse);
+ cgs.media.talkSound = trap_S_RegisterSound( "sound/player/talk.wav", qfalse );
+ cgs.media.landSound = trap_S_RegisterSound( "sound/player/land1.wav", qfalse );
- cgs.media.hitSound = trap_S_RegisterSound( "sound/feedback/hit.wav", qfalse );
+ cgs.media.hitSound = trap_S_RegisterSound( "sound/feedback/hit.wav", qfalse );
- cgs.media.impressiveSound = trap_S_RegisterSound( "sound/feedback/impressive.wav", qtrue );
- cgs.media.excellentSound = trap_S_RegisterSound( "sound/feedback/excellent.wav", qtrue );
- cgs.media.deniedSound = trap_S_RegisterSound( "sound/feedback/denied.wav", qtrue );
- cgs.media.humiliationSound = trap_S_RegisterSound( "sound/feedback/humiliation.wav", qtrue );
- cgs.media.assistSound = trap_S_RegisterSound( "sound/feedback/assist.wav", qtrue );
- cgs.media.defendSound = trap_S_RegisterSound( "sound/feedback/defense.wav", qtrue );
+ cgs.media.watrInSound = trap_S_RegisterSound( "sound/player/watr_in.wav", qfalse );
+ cgs.media.watrOutSound = trap_S_RegisterSound( "sound/player/watr_out.wav", qfalse );
+ cgs.media.watrUnSound = trap_S_RegisterSound( "sound/player/watr_un.wav", qfalse );
- cgs.media.takenLeadSound = trap_S_RegisterSound( "sound/feedback/takenlead.wav", qtrue);
- cgs.media.tiedLeadSound = trap_S_RegisterSound( "sound/feedback/tiedlead.wav", qtrue);
- cgs.media.lostLeadSound = trap_S_RegisterSound( "sound/feedback/lostlead.wav", qtrue);
+ cgs.media.jumpPadSound = trap_S_RegisterSound( "sound/world/jumppad.wav", qfalse );
- cgs.media.watrInSound = trap_S_RegisterSound( "sound/player/watr_in.wav", qfalse);
- cgs.media.watrOutSound = trap_S_RegisterSound( "sound/player/watr_out.wav", qfalse);
- cgs.media.watrUnSound = trap_S_RegisterSound( "sound/player/watr_un.wav", qfalse);
-
- cgs.media.jumpPadSound = trap_S_RegisterSound ("sound/world/jumppad.wav", qfalse );
-
- for (i=0 ; i<4 ; i++) {
- Com_sprintf (name, sizeof(name), "sound/player/footsteps/step%i.wav", i+1);
- cgs.media.footsteps[FOOTSTEP_NORMAL][i] = trap_S_RegisterSound (name, qfalse);
+ for( i = 0; i < 4; i++ )
+ {
+ Com_sprintf( name, sizeof( name ), "sound/player/footsteps/step%i.wav", i + 1 );
+ cgs.media.footsteps[ FOOTSTEP_NORMAL ][ i ] = trap_S_RegisterSound( name, qfalse );
- Com_sprintf (name, sizeof(name), "sound/player/footsteps/boot%i.wav", i+1);
- cgs.media.footsteps[FOOTSTEP_BOOT][i] = trap_S_RegisterSound (name, qfalse);
+ Com_sprintf( name, sizeof( name ), "sound/player/footsteps/boot%i.wav", i + 1 );
+ cgs.media.footsteps[ FOOTSTEP_BOOT ][ i ] = trap_S_RegisterSound( name, qfalse );
- Com_sprintf (name, sizeof(name), "sound/player/footsteps/flesh%i.wav", i+1);
- cgs.media.footsteps[FOOTSTEP_FLESH][i] = trap_S_RegisterSound (name, qfalse);
+ Com_sprintf( name, sizeof( name ), "sound/player/footsteps/flesh%i.wav", i + 1 );
+ cgs.media.footsteps[ FOOTSTEP_FLESH ][ i ] = trap_S_RegisterSound( name, qfalse );
- Com_sprintf (name, sizeof(name), "sound/player/footsteps/mech%i.wav", i+1);
- cgs.media.footsteps[FOOTSTEP_MECH][i] = trap_S_RegisterSound (name, qfalse);
+ Com_sprintf( name, sizeof( name ), "sound/player/footsteps/mech%i.wav", i + 1 );
+ cgs.media.footsteps[ FOOTSTEP_MECH ][ i ] = trap_S_RegisterSound( name, qfalse );
- Com_sprintf (name, sizeof(name), "sound/player/footsteps/energy%i.wav", i+1);
- cgs.media.footsteps[FOOTSTEP_ENERGY][i] = trap_S_RegisterSound (name, qfalse);
+ Com_sprintf( name, sizeof( name ), "sound/player/footsteps/energy%i.wav", i + 1 );
+ cgs.media.footsteps[ FOOTSTEP_ENERGY ][ i ] = trap_S_RegisterSound( name, qfalse );
- Com_sprintf (name, sizeof(name), "sound/player/footsteps/splash%i.wav", i+1);
- cgs.media.footsteps[FOOTSTEP_SPLASH][i] = trap_S_RegisterSound (name, qfalse);
+ Com_sprintf( name, sizeof( name ), "sound/player/footsteps/splash%i.wav", i + 1 );
+ cgs.media.footsteps[ FOOTSTEP_SPLASH ][ i ] = trap_S_RegisterSound( name, qfalse );
- Com_sprintf (name, sizeof(name), "sound/player/footsteps/clank%i.wav", i+1);
- cgs.media.footsteps[FOOTSTEP_METAL][i] = trap_S_RegisterSound (name, qfalse);
+ Com_sprintf( name, sizeof( name ), "sound/player/footsteps/clank%i.wav", i + 1 );
+ cgs.media.footsteps[ FOOTSTEP_METAL ][ i ] = trap_S_RegisterSound( name, qfalse );
}
// only register the items that the server says we need
strcpy( items, CG_ConfigString( CS_ITEMS ) );
- for ( i = 1 ; i < MAX_SOUNDS ; i++ ) {
- soundName = CG_ConfigString( CS_SOUNDS+i );
- if ( !soundName[0] ) {
+ for( i = 1 ; i < MAX_SOUNDS ; i++ )
+ {
+ soundName = CG_ConfigString( CS_SOUNDS + i );
+
+ if( !soundName[ 0 ] )
break;
- }
- if ( soundName[0] == '*' ) {
+
+ if( soundName[ 0 ] == '*' )
continue; // custom sound
- }
- cgs.gameSounds[i] = trap_S_RegisterSound( soundName, qfalse );
+
+ cgs.gameSounds[ i ] = trap_S_RegisterSound( soundName, qfalse );
}
//TA:
cgs.media.jetpackDescendSound = trap_S_RegisterSound( "sound/upgrades/jetpack/low.wav", qfalse );
- cgs.media.jetpackIdleSound = trap_S_RegisterSound( "sound/upgrades/jetpack/idle.wav", qfalse );
- cgs.media.jetpackAscendSound = trap_S_RegisterSound( "sound/upgrades/jetpack/hi.wav", qfalse );
+ cgs.media.jetpackIdleSound = trap_S_RegisterSound( "sound/upgrades/jetpack/idle.wav", qfalse );
+ cgs.media.jetpackAscendSound = trap_S_RegisterSound( "sound/upgrades/jetpack/hi.wav", qfalse );
// FIXME: only needed with item
- cgs.media.flightSound = trap_S_RegisterSound( "sound/items/flight.wav", qfalse );
- cgs.media.medkitSound = trap_S_RegisterSound ("sound/items/use_medkit.wav", qfalse);
- cgs.media.quadSound = trap_S_RegisterSound("sound/items/damage3.wav", qfalse);
- cgs.media.sfx_ric1 = trap_S_RegisterSound ("sound/weapons/machinegun/ric1.wav", qfalse);
- cgs.media.sfx_ric2 = trap_S_RegisterSound ("sound/weapons/machinegun/ric2.wav", qfalse);
- cgs.media.sfx_ric3 = trap_S_RegisterSound ("sound/weapons/machinegun/ric3.wav", qfalse);
- cgs.media.sfx_railg = trap_S_RegisterSound ("sound/weapons/railgun/railgf1a.wav", qfalse);
- cgs.media.sfx_rockexp = trap_S_RegisterSound ("sound/weapons/rocket/rocklx1a.wav", qfalse);
- cgs.media.sfx_plasmaexp = trap_S_RegisterSound ("sound/weapons/plasma/plasmx1a.wav", qfalse);
- cgs.media.sfx_flamerexp = trap_S_RegisterSound ("sound/weapons/flamer/fireimpc.wav", qfalse);
-
- cgs.media.regenSound = trap_S_RegisterSound("sound/items/regen.wav", qfalse);
- cgs.media.protectSound = trap_S_RegisterSound("sound/items/protect3.wav", qfalse);
- cgs.media.n_healthSound = trap_S_RegisterSound("sound/items/n_health.wav", qfalse );
- cgs.media.hgrenb1aSound = trap_S_RegisterSound("sound/weapons/grenade/hgrenb1a.wav", qfalse);
- cgs.media.hgrenb2aSound = trap_S_RegisterSound("sound/weapons/grenade/hgrenb2a.wav", qfalse);
+ cgs.media.sfx_ric1 = trap_S_RegisterSound( "sound/weapons/machinegun/ric1.wav", qfalse );
+ cgs.media.sfx_ric2 = trap_S_RegisterSound( "sound/weapons/machinegun/ric2.wav", qfalse );
+ cgs.media.sfx_ric3 = trap_S_RegisterSound( "sound/weapons/machinegun/ric3.wav", qfalse );
+ cgs.media.sfx_plasmaexp = trap_S_RegisterSound( "sound/weapons/plasma/plasmx1a.wav", qfalse );
+ cgs.media.sfx_flamerexp = trap_S_RegisterSound( "sound/weapons/flamer/fireimpc.wav", qfalse );
+
+ cgs.media.hgrenb1aSound = trap_S_RegisterSound( "sound/weapons/grenade/hgrenb1a.wav", qfalse );
+ cgs.media.hgrenb2aSound = trap_S_RegisterSound( "sound/weapons/grenade/hgrenb2a.wav", qfalse );
}
@@ -674,10 +678,12 @@ CG_RegisterGraphics
This function may execute for a couple of minutes with a slow disk.
=================
*/
-static void CG_RegisterGraphics( void ) {
- int i;
- char items[MAX_ITEMS+1];
- static char *sb_nums[11] = {
+static void CG_RegisterGraphics( void )
+{
+ int i;
+ char items[ MAX_ITEMS + 1 ];
+ static char *sb_nums[ 11 ] =
+ {
"gfx/2d/numbers/zero_32b",
"gfx/2d/numbers/one_32b",
"gfx/2d/numbers/two_32b",
@@ -693,144 +699,98 @@ static void CG_RegisterGraphics( void ) {
// clear any references to old media
memset( &cg.refdef, 0, sizeof( cg.refdef ) );
- trap_R_ClearScene();
+ trap_R_ClearScene( );
trap_R_LoadWorldMap( cgs.mapname );
CG_UpdateMediaFraction( 0.66f );
- for ( i=0 ; i<11 ; i++) {
- cgs.media.numberShaders[i] = trap_R_RegisterShader( sb_nums[i] );
- }
-
- cgs.media.botSkillShaders[0] = trap_R_RegisterShader( "menu/art/skill1.tga" );
- cgs.media.botSkillShaders[1] = trap_R_RegisterShader( "menu/art/skill2.tga" );
- cgs.media.botSkillShaders[2] = trap_R_RegisterShader( "menu/art/skill3.tga" );
- cgs.media.botSkillShaders[3] = trap_R_RegisterShader( "menu/art/skill4.tga" );
- cgs.media.botSkillShaders[4] = trap_R_RegisterShader( "menu/art/skill5.tga" );
+ for( i = 0; i < 11; i++ )
+ cgs.media.numberShaders[ i ] = trap_R_RegisterShader( sb_nums[ i ] );
- cgs.media.viewBloodShader = trap_R_RegisterShader( "viewBloodBlend" );
+ cgs.media.viewBloodShader = trap_R_RegisterShader( "viewBloodBlend" );
- cgs.media.deferShader = trap_R_RegisterShaderNoMip( "gfx/2d/defer.tga" );
+ cgs.media.deferShader = trap_R_RegisterShaderNoMip( "gfx/2d/defer.tga" );
- cgs.media.scoreboardName = trap_R_RegisterShaderNoMip( "menu/tab/name.tga" );
- cgs.media.scoreboardPing = trap_R_RegisterShaderNoMip( "menu/tab/ping.tga" );
- cgs.media.scoreboardScore = trap_R_RegisterShaderNoMip( "menu/tab/score.tga" );
- cgs.media.scoreboardTime = trap_R_RegisterShaderNoMip( "menu/tab/time.tga" );
-
- cgs.media.smokePuffShader = trap_R_RegisterShader( "smokePuff" );
- cgs.media.smokePuffRageProShader = trap_R_RegisterShader( "smokePuffRagePro" );
- cgs.media.shotgunSmokePuffShader = trap_R_RegisterShader( "shotgunSmokePuff" );
- cgs.media.plasmaBallShader = trap_R_RegisterShader( "sprites/plasma1" );
- cgs.media.bloodTrailShader = trap_R_RegisterShader( "bloodTrail" );
- cgs.media.lagometerShader = trap_R_RegisterShader("lagometer" );
- cgs.media.connectionShader = trap_R_RegisterShader( "disconnected" );
+ cgs.media.smokePuffShader = trap_R_RegisterShader( "smokePuff" );
+ cgs.media.smokePuffRageProShader = trap_R_RegisterShader( "smokePuffRagePro" );
+ cgs.media.shotgunSmokePuffShader = trap_R_RegisterShader( "shotgunSmokePuff" );
+ cgs.media.plasmaBallShader = trap_R_RegisterShader( "sprites/plasma1" );
+ cgs.media.bloodTrailShader = trap_R_RegisterShader( "bloodTrail" );
+ cgs.media.connectionShader = trap_R_RegisterShader( "disconnected" );
//TA: extra stuff
- cgs.media.explosionShader = trap_R_RegisterShader( "grenadeExplosion" );
- cgs.media.greenBloodTrailShader = trap_R_RegisterShader( "greenBloodTrail" );
+ cgs.media.explosionShader = trap_R_RegisterShader( "grenadeExplosion" );
+ cgs.media.greenBloodTrailShader = trap_R_RegisterShader( "greenBloodTrail" );
cgs.media.greenBloodExplosionShader = trap_R_RegisterShader( "greenBloodExplosion" );
- cgs.media.greenBloodMarkShader = trap_R_RegisterShader( "greenBloodMark" );
- cgs.media.explosionTrailShader = trap_R_RegisterShader( "explosionTrail" );
- cgs.media.poisonCloudShader = trap_R_RegisterShader( "poisonCloud" );
+ cgs.media.greenBloodMarkShader = trap_R_RegisterShader( "greenBloodMark" );
+ cgs.media.explosionTrailShader = trap_R_RegisterShader( "explosionTrail" );
+ cgs.media.poisonCloudShader = trap_R_RegisterShader( "poisonCloud" );
for( i = 0; i < 32; i++ )
cgs.media.flameShader[ i ] = trap_R_RegisterShader( va( "fireball%d", i + 1 ) );
- /*cgs.media.creepShader = trap_R_RegisterShader( "creep" );*/
-
- cgs.media.scannerBlipShader = trap_R_RegisterShader( "gfx/2d/droidhealth" );
- cgs.media.scannerLineShader = trap_R_RegisterShader( "white" );
+ cgs.media.scannerBlipShader = trap_R_RegisterShader( "gfx/2d/blip" );
+ cgs.media.scannerLineShader = trap_R_RegisterShader( "white" );
/*cgs.media.scannerShader = trap_R_RegisterShader( "gfx/2d/scanner" );*/
- cgs.media.waterBubbleShader = trap_R_RegisterShader( "waterBubble" );
+ cgs.media.waterBubbleShader = trap_R_RegisterShader( "waterBubble" );
- cgs.media.tracerShader = trap_R_RegisterShader( "gfx/misc/tracer" );
- cgs.media.selectShader = trap_R_RegisterShader( "gfx/2d/select" );
+ cgs.media.tracerShader = trap_R_RegisterShader( "gfx/misc/tracer" );
+ cgs.media.selectShader = trap_R_RegisterShader( "gfx/2d/select" );
- for ( i = 0 ; i < NUM_CROSSHAIRS ; i++ ) {
- cgs.media.crosshairShader[i] = trap_R_RegisterShader( va("gfx/2d/crosshair%c", 'a'+i) );
- }
+ for( i = 0 ; i < NUM_CROSSHAIRS ; i++ )
+ cgs.media.crosshairShader[ i ] = trap_R_RegisterShader( va( "gfx/2d/crosshair%c", 'a' + i ) );
- cgs.media.backTileShader = trap_R_RegisterShader( "gfx/2d/backtile" );
- cgs.media.noammoShader = trap_R_RegisterShader( "icons/noammo" );
+ cgs.media.backTileShader = trap_R_RegisterShader( "gfx/2d/backtile" );
+ cgs.media.noammoShader = trap_R_RegisterShader( "icons/noammo" );
+ cgs.media.friendShader = trap_R_RegisterShader( "sprites/foe" );
+
//TA: building shaders
- cgs.media.greenBuildShader = trap_R_RegisterShader("gfx/2d/greenbuild" );
- cgs.media.redBuildShader = trap_R_RegisterShader("gfx/2d/redbuild" );
- cgs.media.noPowerShader = trap_R_RegisterShader("gfx/2d/nopower" );
-
- // powerup shaders
- cgs.media.quadShader = trap_R_RegisterShader("powerups/quad" );
- cgs.media.quadWeaponShader = trap_R_RegisterShader("powerups/quadWeapon" );
- cgs.media.battleSuitShader = trap_R_RegisterShader("powerups/battleSuit" );
- cgs.media.battleWeaponShader = trap_R_RegisterShader("powerups/battleWeapon" );
- cgs.media.invisShader = trap_R_RegisterShader("powerups/invisibility" );
- cgs.media.regenShader = trap_R_RegisterShader("powerups/regen" );
- cgs.media.hastePuffShader = trap_R_RegisterShader("hasteSmokePuff" );
-
- //TA: screenfades
- cgs.media.humanNV = trap_R_RegisterShader( "humanNV" );
- cgs.media.humanTorch8 = trap_R_RegisterShader( "humanTorch8" );
- cgs.media.humanTorch7 = trap_R_RegisterShader( "humanTorch7" );
- cgs.media.humanTorch6 = trap_R_RegisterShader( "humanTorch6" );
- cgs.media.humanTorch5 = trap_R_RegisterShader( "humanTorch5" );
- cgs.media.humanTorch4 = trap_R_RegisterShader( "humanTorch4" );
- cgs.media.humanTorch3 = trap_R_RegisterShader( "humanTorch3" );
- cgs.media.humanTorch2 = trap_R_RegisterShader( "humanTorch2" );
- cgs.media.humanTorch1 = trap_R_RegisterShader( "humanTorch1" );
- cgs.media.alienHealth = trap_R_RegisterShader( "gfx/2d/droidhealth.tga" );
-
- cgs.media.armorModel = trap_R_RegisterModel( "models/powerups/armor/armor_yel.md3" );
- cgs.media.armorIcon = trap_R_RegisterShaderNoMip( "icons/iconr_yellow" );
-
- cgs.media.machinegunBrassModel = trap_R_RegisterModel( "models/weapons2/shells/m_shell.md3" );
- cgs.media.shotgunBrassModel = trap_R_RegisterModel( "models/weapons2/shells/s_shell.md3" );
-
- cgs.media.gibAbdomen = trap_R_RegisterModel( "models/gibs/abdomen.md3" );
- cgs.media.gibArm = trap_R_RegisterModel( "models/gibs/arm.md3" );
- cgs.media.gibChest = trap_R_RegisterModel( "models/gibs/chest.md3" );
- cgs.media.gibFist = trap_R_RegisterModel( "models/gibs/fist.md3" );
- cgs.media.gibFoot = trap_R_RegisterModel( "models/gibs/foot.md3" );
- cgs.media.gibForearm = trap_R_RegisterModel( "models/gibs/forearm.md3" );
- cgs.media.gibIntestine = trap_R_RegisterModel( "models/gibs/intestine.md3" );
- cgs.media.gibLeg = trap_R_RegisterModel( "models/gibs/leg.md3" );
- cgs.media.gibSkull = trap_R_RegisterModel( "models/gibs/skull.md3" );
- cgs.media.gibBrain = trap_R_RegisterModel( "models/gibs/brain.md3" );
-
- cgs.media.metalGib1 = trap_R_RegisterModel( "models/fx/metal_gibs/m_gib1.md3" );
- cgs.media.metalGib2 = trap_R_RegisterModel( "models/fx/metal_gibs/m_gib2.md3" );
- cgs.media.metalGib3 = trap_R_RegisterModel( "models/fx/metal_gibs/m_gib3.md3" );
- cgs.media.metalGib4 = trap_R_RegisterModel( "models/fx/metal_gibs/m_gib4.md3" );
- cgs.media.metalGib5 = trap_R_RegisterModel( "models/fx/metal_gibs/m_gib5.md3" );
- cgs.media.metalGib6 = trap_R_RegisterModel( "models/fx/metal_gibs/m_gib6.md3" );
- cgs.media.metalGib7 = trap_R_RegisterModel( "models/fx/metal_gibs/m_gib7.md3" );
- cgs.media.metalGib8 = trap_R_RegisterModel( "models/fx/metal_gibs/m_gib8.md3" );
+ cgs.media.greenBuildShader = trap_R_RegisterShader("gfx/2d/greenbuild" );
+ cgs.media.redBuildShader = trap_R_RegisterShader("gfx/2d/redbuild" );
+ cgs.media.noPowerShader = trap_R_RegisterShader("gfx/2d/nopower" );
+
+ cgs.media.machinegunBrassModel = trap_R_RegisterModel( "models/weapons2/shells/m_shell.md3" );
+ cgs.media.shotgunBrassModel = trap_R_RegisterModel( "models/weapons2/shells/s_shell.md3" );
+
+ cgs.media.gibAbdomen = trap_R_RegisterModel( "models/gibs/abdomen.md3" );
+ cgs.media.gibArm = trap_R_RegisterModel( "models/gibs/arm.md3" );
+ cgs.media.gibChest = trap_R_RegisterModel( "models/gibs/chest.md3" );
+ cgs.media.gibFist = trap_R_RegisterModel( "models/gibs/fist.md3" );
+ cgs.media.gibFoot = trap_R_RegisterModel( "models/gibs/foot.md3" );
+ cgs.media.gibForearm = trap_R_RegisterModel( "models/gibs/forearm.md3" );
+ cgs.media.gibIntestine = trap_R_RegisterModel( "models/gibs/intestine.md3" );
+ cgs.media.gibLeg = trap_R_RegisterModel( "models/gibs/leg.md3" );
+ cgs.media.gibSkull = trap_R_RegisterModel( "models/gibs/skull.md3" );
+ cgs.media.gibBrain = trap_R_RegisterModel( "models/gibs/brain.md3" );
+
+ cgs.media.metalGib1 = trap_R_RegisterModel( "models/fx/metal_gibs/m_gib1.md3" );
+ cgs.media.metalGib2 = trap_R_RegisterModel( "models/fx/metal_gibs/m_gib2.md3" );
+ cgs.media.metalGib3 = trap_R_RegisterModel( "models/fx/metal_gibs/m_gib3.md3" );
+ cgs.media.metalGib4 = trap_R_RegisterModel( "models/fx/metal_gibs/m_gib4.md3" );
+ cgs.media.metalGib5 = trap_R_RegisterModel( "models/fx/metal_gibs/m_gib5.md3" );
+ cgs.media.metalGib6 = trap_R_RegisterModel( "models/fx/metal_gibs/m_gib6.md3" );
+ cgs.media.metalGib7 = trap_R_RegisterModel( "models/fx/metal_gibs/m_gib7.md3" );
+ cgs.media.metalGib8 = trap_R_RegisterModel( "models/fx/metal_gibs/m_gib8.md3" );
- cgs.media.gibSpark1 = trap_R_RegisterShader( "models/fx/metal_gibs/spark.jpg" );
- cgs.media.gibSpark2 = trap_R_RegisterShader( "models/fx/metal_gibs/spark2.jpg" );
+ cgs.media.gibSpark1 = trap_R_RegisterShader( "models/fx/metal_gibs/spark.jpg" );
+ cgs.media.gibSpark2 = trap_R_RegisterShader( "models/fx/metal_gibs/spark2.jpg" );
- cgs.media.smoke2 = trap_R_RegisterModel( "models/weapons2/shells/s_shell.md3" );
-
- cgs.media.balloonShader = trap_R_RegisterShader( "sprites/balloon3" );
+ cgs.media.smoke2 = trap_R_RegisterModel( "models/weapons2/shells/s_shell.md3" );
- cgs.media.bloodExplosionShader = trap_R_RegisterShader( "bloodExplosion" );
+ cgs.media.balloonShader = trap_R_RegisterShader( "sprites/balloon3" );
- cgs.media.bulletFlashModel = trap_R_RegisterModel("models/weaphits/bullet.md3");
- cgs.media.ringFlashModel = trap_R_RegisterModel("models/weaphits/ring02.md3");
- cgs.media.dishFlashModel = trap_R_RegisterModel("models/weaphits/boom01.md3");
- cgs.media.teleportEffectModel = trap_R_RegisterModel( "models/misc/telep.md3" );
- cgs.media.teleportEffectShader = trap_R_RegisterShader( "teleportEffect" );
+ cgs.media.bloodExplosionShader = trap_R_RegisterShader( "bloodExplosion" );
- cgs.media.medalImpressive = trap_R_RegisterShaderNoMip( "medal_impressive" );
- cgs.media.medalExcellent = trap_R_RegisterShaderNoMip( "medal_excellent" );
- cgs.media.medalGauntlet = trap_R_RegisterShaderNoMip( "medal_gauntlet" );
- cgs.media.medalDefend = trap_R_RegisterShaderNoMip( "medal_defend" );
- cgs.media.medalAssist = trap_R_RegisterShaderNoMip( "medal_assist" );
- cgs.media.medalCapture = trap_R_RegisterShaderNoMip( "medal_capture" );
+ cgs.media.bulletFlashModel = trap_R_RegisterModel( "models/weaphits/bullet.md3" );
+ cgs.media.ringFlashModel = trap_R_RegisterModel( "models/weaphits/ring02.md3" );
+ cgs.media.dishFlashModel = trap_R_RegisterModel( "models/weaphits/boom01.md3" );
+ cgs.media.teleportEffectModel = trap_R_RegisterModel( "models/misc/telep.md3" );
+ cgs.media.teleportEffectShader = trap_R_RegisterShader( "teleportEffect" );
CG_UpdateMediaFraction( 0.7f );
- memset( cg_items, 0, sizeof( cg_items ) );
memset( cg_weapons, 0, sizeof( cg_weapons ) );
memset( cg_upgrades, 0, sizeof( cg_upgrades ) );
@@ -838,51 +798,58 @@ static void CG_RegisterGraphics( void ) {
strcpy( items, CG_ConfigString( CS_ITEMS) );
// wall marks
- cgs.media.bulletMarkShader = trap_R_RegisterShader( "gfx/damage/bullet_mrk" );
- cgs.media.burnMarkShader = trap_R_RegisterShader( "gfx/damage/burn_med_mrk" );
- cgs.media.holeMarkShader = trap_R_RegisterShader( "gfx/damage/hole_lg_mrk" );
- cgs.media.energyMarkShader = trap_R_RegisterShader( "gfx/damage/plasma_mrk" );
- cgs.media.shadowMarkShader = trap_R_RegisterShader( "markShadow" );
- cgs.media.wakeMarkShader = trap_R_RegisterShader( "wake" );
- cgs.media.bloodMarkShader = trap_R_RegisterShader( "bloodMark" );
+ cgs.media.bulletMarkShader = trap_R_RegisterShader( "gfx/damage/bullet_mrk" );
+ cgs.media.burnMarkShader = trap_R_RegisterShader( "gfx/damage/burn_med_mrk" );
+ cgs.media.holeMarkShader = trap_R_RegisterShader( "gfx/damage/hole_lg_mrk" );
+ cgs.media.energyMarkShader = trap_R_RegisterShader( "gfx/damage/plasma_mrk" );
+ cgs.media.shadowMarkShader = trap_R_RegisterShader( "markShadow" );
+ cgs.media.wakeMarkShader = trap_R_RegisterShader( "wake" );
+ cgs.media.bloodMarkShader = trap_R_RegisterShader( "bloodMark" );
// register the inline models
- cgs.numInlineModels = trap_CM_NumInlineModels();
- for ( i = 1 ; i < cgs.numInlineModels ; i++ ) {
- char name[10];
- vec3_t mins, maxs;
- int j;
-
- Com_sprintf( name, sizeof(name), "*%i", i );
- cgs.inlineDrawModel[i] = trap_R_RegisterModel( name );
- trap_R_ModelBounds( cgs.inlineDrawModel[i], mins, maxs );
- for ( j = 0 ; j < 3 ; j++ ) {
- cgs.inlineModelMidpoints[i][j] = mins[j] + 0.5 * ( maxs[j] - mins[j] );
- }
+ cgs.numInlineModels = trap_CM_NumInlineModels( );
+
+ for( i = 1; i < cgs.numInlineModels; i++ )
+ {
+ char name[ 10 ];
+ vec3_t mins, maxs;
+ int j;
+
+ Com_sprintf( name, sizeof( name ), "*%i", i );
+
+ cgs.inlineDrawModel[ i ] = trap_R_RegisterModel( name );
+ trap_R_ModelBounds( cgs.inlineDrawModel[ i ], mins, maxs );
+
+ for( j = 0 ; j < 3 ; j++ )
+ cgs.inlineModelMidpoints[ i ][ j ] = mins[ j ] + 0.5 * ( maxs[ j ] - mins[ j ] );
}
// register all the server specified models
- for (i=1 ; i<MAX_MODELS ; i++) {
- const char *modelName;
+ for( i = 1; i < MAX_MODELS; i++ )
+ {
+ const char *modelName;
modelName = CG_ConfigString( CS_MODELS+i );
- if ( !modelName[0] ) {
+
+ if( !modelName[ 0 ] )
break;
- }
- cgs.gameModels[i] = trap_R_RegisterModel( modelName );
+
+ cgs.gameModels[ i ] = trap_R_RegisterModel( modelName );
}
CG_UpdateMediaFraction( 0.8f );
// register all the server specified shaders
- for (i=1 ; i<MAX_SHADERS ; i++) {
- const char *shaderName;
+ for( i = 1; i < MAX_SHADERS; i++ )
+ {
+ const char *shaderName;
shaderName = CG_ConfigString( CS_SHADERS+i );
- if ( !shaderName[0] ) {
+
+ if( !shaderName[ 0 ] )
break;
- }
- cgs.gameShaders[i] = trap_R_RegisterShader( shaderName );
+
+ cgs.gameShaders[ i ] = trap_R_RegisterShader( shaderName );
}
}
@@ -893,16 +860,22 @@ CG_BuildSpectatorString
=======================
*/
-void CG_BuildSpectatorString() {
+void CG_BuildSpectatorString( void )
+{
int i;
- cg.spectatorList[0] = 0;
- for (i = 0; i < MAX_CLIENTS; i++) {
- if (cgs.clientinfo[i].infoValid && cgs.clientinfo[i].team == PTE_NONE ) {
- Q_strcat(cg.spectatorList, sizeof(cg.spectatorList), va("%s ", cgs.clientinfo[i].name));
- }
+
+ cg.spectatorList[ 0 ] = 0;
+
+ for( i = 0; i < MAX_CLIENTS; i++ )
+ {
+ if( cgs.clientinfo[ i ].infoValid && cgs.clientinfo[ i ].team == PTE_NONE )
+ Q_strcat( cg.spectatorList, sizeof( cg.spectatorList ), va( "%s ", cgs.clientinfo[ i ].name ) );
}
- i = strlen(cg.spectatorList);
- if (i != cg.spectatorLen) {
+
+ i = strlen( cg.spectatorList );
+
+ if( i != cg.spectatorLen )
+ {
cg.spectatorLen = i;
cg.spectatorWidth = -1;
}
@@ -928,7 +901,7 @@ static void CG_RegisterClients( void )
const char *clientInfo;
clientInfo = CG_ConfigString( CS_PRECACHES + i );
- if ( !clientInfo[0] )
+ if( !clientInfo[0] )
continue;
CG_PrecacheClientInfo( i );
@@ -949,7 +922,7 @@ static void CG_RegisterClients( void )
CG_NewClientInfo( i );
}
- CG_BuildSpectatorString();
+ CG_BuildSpectatorString( );
}
//===========================================================================
@@ -959,10 +932,11 @@ static void CG_RegisterClients( void )
CG_ConfigString
=================
*/
-const char *CG_ConfigString( int index ) {
- if ( index < 0 || index >= MAX_CONFIGSTRINGS ) {
+const char *CG_ConfigString( int index )
+{
+ if( index < 0 || index >= MAX_CONFIGSTRINGS )
CG_Error( "CG_ConfigString: bad index: %i", index );
- }
+
return cgs.gameState.stringData + cgs.gameState.stringOffsets[ index ];
}
@@ -974,9 +948,10 @@ CG_StartMusic
======================
*/
-void CG_StartMusic( void ) {
+void CG_StartMusic( void )
+{
char *s;
- char parm1[MAX_QPATH], parm2[MAX_QPATH];
+ char parm1[ MAX_QPATH ], parm2[ MAX_QPATH ];
// start the background music
s = (char *)CG_ConfigString( CS_MUSIC );
@@ -992,18 +967,24 @@ void CG_StartMusic( void ) {
// new hud stuff ( mission pack )
// ==============================
//
-char *CG_GetMenuBuffer(const char *filename) {
- int len;
+char *CG_GetMenuBuffer( const char *filename )
+{
+ int len;
fileHandle_t f;
- static char buf[MAX_MENUFILE];
+ static char buf[ MAX_MENUFILE ];
len = trap_FS_FOpenFile( filename, &f, FS_READ );
- if ( !f ) {
+
+ if( !f )
+ {
trap_Print( va( S_COLOR_RED "menu file not found: %s, using default\n", filename ) );
return NULL;
}
- if ( len >= MAX_MENUFILE ) {
- trap_Print( va( S_COLOR_RED "menu file too large: %s is %i, max allowed is %i", filename, len, MAX_MENUFILE ) );
+
+ if( len >= MAX_MENUFILE )
+ {
+ trap_Print( va( S_COLOR_RED "menu file too large: %s is %i, max allowed is %i",
+ filename, len, MAX_MENUFILE ) );
trap_FS_FCloseFile( f );
return NULL;
}
@@ -1015,167 +996,190 @@ char *CG_GetMenuBuffer(const char *filename) {
return buf;
}
-qboolean CG_Asset_Parse(int handle) {
+qboolean CG_Asset_Parse( int handle )
+{
pc_token_t token;
const char *tempStr;
- if (!trap_PC_ReadToken(handle, &token))
+ if( !trap_PC_ReadToken( handle, &token ) )
return qfalse;
- if (Q_stricmp(token.string, "{") != 0) {
+
+ if( Q_stricmp( token.string, "{" ) != 0 )
return qfalse;
- }
- while ( 1 ) {
- if (!trap_PC_ReadToken(handle, &token))
+ while( 1 )
+ {
+ if( !trap_PC_ReadToken( handle, &token ) )
return qfalse;
- if (Q_stricmp(token.string, "}") == 0) {
+ if( Q_stricmp( token.string, "}" ) == 0 )
return qtrue;
- }
// font
- if (Q_stricmp(token.string, "font") == 0) {
+ if( Q_stricmp( token.string, "font" ) == 0 )
+ {
int pointSize;
- if (!PC_String_Parse(handle, &tempStr) || !PC_Int_Parse(handle, &pointSize)) {
+
+ if( !PC_String_Parse( handle, &tempStr ) || !PC_Int_Parse( handle, &pointSize ) )
return qfalse;
- }
- cgDC.registerFont(tempStr, pointSize, &cgDC.Assets.textFont);
+
+ cgDC.registerFont( tempStr, pointSize, &cgDC.Assets.textFont );
continue;
}
// smallFont
- if (Q_stricmp(token.string, "smallFont") == 0) {
+ if( Q_stricmp( token.string, "smallFont" ) == 0 )
+ {
int pointSize;
- if (!PC_String_Parse(handle, &tempStr) || !PC_Int_Parse(handle, &pointSize)) {
+
+ if( !PC_String_Parse( handle, &tempStr ) || !PC_Int_Parse( handle, &pointSize ) )
return qfalse;
- }
- cgDC.registerFont(tempStr, pointSize, &cgDC.Assets.smallFont);
+
+ cgDC.registerFont( tempStr, pointSize, &cgDC.Assets.smallFont );
continue;
}
// font
- if (Q_stricmp(token.string, "bigfont") == 0) {
+ if( Q_stricmp( token.string, "bigfont" ) == 0 )
+ {
int pointSize;
- if (!PC_String_Parse(handle, &tempStr) || !PC_Int_Parse(handle, &pointSize)) {
+
+ if( !PC_String_Parse( handle, &tempStr ) || !PC_Int_Parse( handle, &pointSize ) )
return qfalse;
- }
- cgDC.registerFont(tempStr, pointSize, &cgDC.Assets.bigFont);
+
+ cgDC.registerFont( tempStr, pointSize, &cgDC.Assets.bigFont );
continue;
}
// gradientbar
- if (Q_stricmp(token.string, "gradientbar") == 0) {
- if (!PC_String_Parse(handle, &tempStr)) {
+ if( Q_stricmp( token.string, "gradientbar" ) == 0 )
+ {
+ if( !PC_String_Parse( handle, &tempStr ) )
return qfalse;
- }
- cgDC.Assets.gradientBar = trap_R_RegisterShaderNoMip(tempStr);
+
+ cgDC.Assets.gradientBar = trap_R_RegisterShaderNoMip( tempStr );
continue;
}
// enterMenuSound
- if (Q_stricmp(token.string, "menuEnterSound") == 0) {
- if (!PC_String_Parse(handle, &tempStr)) {
+ if( Q_stricmp( token.string, "menuEnterSound" ) == 0 )
+ {
+ if( !PC_String_Parse( handle, &tempStr ) )
return qfalse;
- }
+
cgDC.Assets.menuEnterSound = trap_S_RegisterSound( tempStr, qfalse );
continue;
}
// exitMenuSound
- if (Q_stricmp(token.string, "menuExitSound") == 0) {
- if (!PC_String_Parse(handle, &tempStr)) {
+ if( Q_stricmp( token.string, "menuExitSound" ) == 0 )
+ {
+ if( !PC_String_Parse( handle, &tempStr ) )
return qfalse;
- }
+
cgDC.Assets.menuExitSound = trap_S_RegisterSound( tempStr, qfalse );
continue;
}
// itemFocusSound
- if (Q_stricmp(token.string, "itemFocusSound") == 0) {
- if (!PC_String_Parse(handle, &tempStr)) {
+ if( Q_stricmp( token.string, "itemFocusSound" ) == 0 )
+ {
+ if( !PC_String_Parse( handle, &tempStr ) )
return qfalse;
- }
+
cgDC.Assets.itemFocusSound = trap_S_RegisterSound( tempStr, qfalse );
continue;
}
// menuBuzzSound
- if (Q_stricmp(token.string, "menuBuzzSound") == 0) {
- if (!PC_String_Parse(handle, &tempStr)) {
+ if( Q_stricmp( token.string, "menuBuzzSound" ) == 0 )
+ {
+ if( !PC_String_Parse( handle, &tempStr ) )
return qfalse;
- }
+
cgDC.Assets.menuBuzzSound = trap_S_RegisterSound( tempStr, qfalse );
continue;
}
- if (Q_stricmp(token.string, "cursor") == 0) {
- if (!PC_String_Parse(handle, &cgDC.Assets.cursorStr)) {
+ if( Q_stricmp( token.string, "cursor" ) == 0 )
+ {
+ if( !PC_String_Parse( handle, &cgDC.Assets.cursorStr ) )
return qfalse;
- }
- cgDC.Assets.cursor = trap_R_RegisterShaderNoMip( cgDC.Assets.cursorStr);
+
+ cgDC.Assets.cursor = trap_R_RegisterShaderNoMip( cgDC.Assets.cursorStr );
continue;
}
- if (Q_stricmp(token.string, "fadeClamp") == 0) {
- if (!PC_Float_Parse(handle, &cgDC.Assets.fadeClamp)) {
+ if( Q_stricmp( token.string, "fadeClamp" ) == 0 )
+ {
+ if( !PC_Float_Parse( handle, &cgDC.Assets.fadeClamp ) )
return qfalse;
- }
+
continue;
}
- if (Q_stricmp(token.string, "fadeCycle") == 0) {
- if (!PC_Int_Parse(handle, &cgDC.Assets.fadeCycle)) {
+ if( Q_stricmp( token.string, "fadeCycle" ) == 0 )
+ {
+ if( !PC_Int_Parse( handle, &cgDC.Assets.fadeCycle ) )
return qfalse;
- }
+
continue;
}
- if (Q_stricmp(token.string, "fadeAmount") == 0) {
- if (!PC_Float_Parse(handle, &cgDC.Assets.fadeAmount)) {
+ if( Q_stricmp( token.string, "fadeAmount" ) == 0 )
+ {
+ if( !PC_Float_Parse( handle, &cgDC.Assets.fadeAmount ) )
return qfalse;
- }
+
continue;
}
- if (Q_stricmp(token.string, "shadowX") == 0) {
- if (!PC_Float_Parse(handle, &cgDC.Assets.shadowX)) {
+ if( Q_stricmp( token.string, "shadowX" ) == 0 )
+ {
+ if( !PC_Float_Parse( handle, &cgDC.Assets.shadowX ) )
return qfalse;
- }
+
continue;
}
- if (Q_stricmp(token.string, "shadowY") == 0) {
- if (!PC_Float_Parse(handle, &cgDC.Assets.shadowY)) {
+ if( Q_stricmp( token.string, "shadowY" ) == 0 )
+ {
+ if( !PC_Float_Parse( handle, &cgDC.Assets.shadowY ) )
return qfalse;
- }
+
continue;
}
- if (Q_stricmp(token.string, "shadowColor") == 0) {
- if (!PC_Color_Parse(handle, &cgDC.Assets.shadowColor)) {
+ if( Q_stricmp( token.string, "shadowColor" ) == 0 )
+ {
+ if( !PC_Color_Parse( handle, &cgDC.Assets.shadowColor ) )
return qfalse;
- }
- cgDC.Assets.shadowFadeClamp = cgDC.Assets.shadowColor[3];
+
+ cgDC.Assets.shadowFadeClamp = cgDC.Assets.shadowColor[ 3 ];
continue;
}
}
+
return qfalse; // bk001204 - why not?
}
-void CG_ParseMenu(const char *menuFile) {
- pc_token_t token;
- int handle;
+void CG_ParseMenu( const char *menuFile )
+{
+ pc_token_t token;
+ int handle;
- handle = trap_PC_LoadSource(menuFile);
- if (!handle)
- handle = trap_PC_LoadSource("ui/testhud.menu");
- if (!handle)
+ handle = trap_PC_LoadSource( menuFile );
+
+ if( !handle )
+ handle = trap_PC_LoadSource( "ui/testhud.menu" );
+
+ if( !handle )
return;
- while ( 1 ) {
- if (!trap_PC_ReadToken( handle, &token )) {
+ while( 1 )
+ {
+ if( !trap_PC_ReadToken( handle, &token ) )
break;
- }
//if ( Q_stricmp( token, "{" ) ) {
// Com_Printf( "Missing { in menu file\n" );
@@ -1187,125 +1191,119 @@ void CG_ParseMenu(const char *menuFile) {
// break;
//}
- if ( token.string[0] == '}' ) {
+ if( token.string[ 0 ] == '}' )
break;
- }
- if (Q_stricmp(token.string, "assetGlobalDef") == 0) {
- if (CG_Asset_Parse(handle)) {
+ if( Q_stricmp( token.string, "assetGlobalDef" ) == 0 )
+ {
+ if( CG_Asset_Parse( handle ) )
continue;
- } else {
- break;
- }
+ else
+ break;
}
- if (Q_stricmp(token.string, "menudef") == 0) {
+ if( Q_stricmp( token.string, "menudef" ) == 0 )
+ {
// start a new menu
- Menu_New(handle);
+ Menu_New( handle );
}
}
- trap_PC_FreeSource(handle);
+
+ trap_PC_FreeSource( handle );
}
-qboolean CG_Load_Menu(char **p) {
+qboolean CG_Load_Menu( char **p )
+{
char *token;
- token = COM_ParseExt(p, qtrue);
+ token = COM_ParseExt( p, qtrue );
- if (token[0] != '{') {
+ if( token[ 0 ] != '{' )
return qfalse;
- }
-
- while ( 1 ) {
- token = COM_ParseExt(p, qtrue);
+ while( 1 )
+ {
+ token = COM_ParseExt( p, qtrue );
- if (Q_stricmp(token, "}") == 0) {
+ if( Q_stricmp( token, "}" ) == 0 )
return qtrue;
- }
- if ( !token || token[0] == 0 ) {
+ if( !token || token[ 0 ] == 0 )
return qfalse;
- }
- CG_ParseMenu(token);
+ CG_ParseMenu( token );
}
return qfalse;
}
-void CG_LoadMenus(const char *menuFile) {
- char *token;
- char *p;
- int len, start;
+void CG_LoadMenus( const char *menuFile )
+{
+ char *token;
+ char *p;
+ int len, start;
fileHandle_t f;
- static char buf[MAX_MENUDEFFILE];
+ static char buf[ MAX_MENUDEFFILE ];
- start = trap_Milliseconds();
+ start = trap_Milliseconds( );
len = trap_FS_FOpenFile( menuFile, &f, FS_READ );
- if ( !f ) {
+
+ if( !f )
+ {
trap_Error( va( S_COLOR_YELLOW "menu file not found: %s, using default\n", menuFile ) );
len = trap_FS_FOpenFile( "ui/hud.txt", &f, FS_READ );
- if (!f) {
+
+ if( !f )
trap_Error( va( S_COLOR_RED "default menu file not found: ui/hud.txt, unable to continue!\n", menuFile ) );
- }
}
- if ( len >= MAX_MENUDEFFILE ) {
- trap_Error( va( S_COLOR_RED "menu file too large: %s is %i, max allowed is %i", menuFile, len, MAX_MENUDEFFILE ) );
+ if( len >= MAX_MENUDEFFILE )
+ {
+ trap_Error( va( S_COLOR_RED "menu file too large: %s is %i, max allowed is %i",
+ menuFile, len, MAX_MENUDEFFILE ) );
trap_FS_FCloseFile( f );
return;
}
trap_FS_Read( buf, len, f );
- buf[len] = 0;
+ buf[ len ] = 0;
trap_FS_FCloseFile( f );
- COM_Compress(buf);
+ COM_Compress( buf );
- Menu_Reset();
+ Menu_Reset( );
p = buf;
- while ( 1 ) {
+ while( 1 )
+ {
token = COM_ParseExt( &p, qtrue );
- if( !token || token[0] == 0 || token[0] == '}') {
+
+ if( !token || token[ 0 ] == 0 || token[ 0 ] == '}' )
break;
- }
-
- //if ( Q_stricmp( token, "{" ) ) {
- // Com_Printf( "Missing { in menu file\n" );
- // break;
- //}
-
- //if ( menuCount == MAX_MENUS ) {
- // Com_Printf( "Too many menus!\n" );
- // break;
- //}
- if ( Q_stricmp( token, "}" ) == 0 ) {
+ if( Q_stricmp( token, "}" ) == 0 )
break;
- }
- if (Q_stricmp(token, "loadmenu") == 0) {
- if (CG_Load_Menu(&p)) {
+ if( Q_stricmp( token, "loadmenu" ) == 0 )
+ {
+ if( CG_Load_Menu( &p ) )
continue;
- } else {
+ else
break;
- }
}
}
- Com_Printf("UI menu load time = %d milli seconds\n", trap_Milliseconds() - start);
-
+ Com_Printf( "UI menu load time = %d milli seconds\n", trap_Milliseconds( ) - start );
}
-static qboolean CG_OwnerDrawHandleKey(int ownerDraw, int flags, float *special, int key) {
+static qboolean CG_OwnerDrawHandleKey( int ownerDraw, int flags, float *special, int key )
+{
return qfalse;
}
@@ -1445,7 +1443,8 @@ static const char *CG_FeederItemText( float feederID, int index, int column, qha
return "";
}
-static qhandle_t CG_FeederItemImage(float feederID, int index) {
+static qhandle_t CG_FeederItemImage( float feederID, int index )
+{
return 0;
}
@@ -1467,152 +1466,146 @@ static void CG_FeederSelection( float feederID, int index )
}
}
-static float CG_Cvar_Get(const char *cvar) {
- char buff[128];
- memset(buff, 0, sizeof(buff));
- trap_Cvar_VariableStringBuffer(cvar, buff, sizeof(buff));
- return atof(buff);
+static float CG_Cvar_Get( const char *cvar )
+{
+ char buff[ 128 ];
+
+ memset( buff, 0, sizeof( buff ) );
+ trap_Cvar_VariableStringBuffer( cvar, buff, sizeof( buff ) );
+ return atof( buff );
}
-void CG_Text_PaintWithCursor(float x, float y, float scale, vec4_t color, const char *text, int cursorPos, char cursor, int limit, int style) {
- CG_Text_Paint(x, y, scale, color, text, 0, limit, style);
+void CG_Text_PaintWithCursor( float x, float y, float scale, vec4_t color, const char *text,
+ int cursorPos, char cursor, int limit, int style )
+{
+ CG_Text_Paint( x, y, scale, color, text, 0, limit, style );
}
-static int CG_OwnerDrawWidth(int ownerDraw, float scale) {
- switch (ownerDraw) {
-/* case CG_GAME_TYPE:
- return CG_Text_Width(CG_GameTypeString(), scale, 0);*/
-/* case CG_GAME_STATUS:
- return CG_Text_Width(CG_GetGameStatusText(), scale, 0);
- break;*/
+static int CG_OwnerDrawWidth( int ownerDraw, float scale )
+{
+ switch( ownerDraw )
+ {
case CG_KILLER:
- return CG_Text_Width(CG_GetKillerText(), scale, 0);
- break;
-/* case CG_RED_NAME:
- return CG_Text_Width(cg_redTeamName.string, scale, 0);
+ return CG_Text_Width( CG_GetKillerText( ), scale, 0 );
break;
- case CG_BLUE_NAME:
- return CG_Text_Width(cg_blueTeamName.string, scale, 0);
- break;*/
-
-
}
+
return 0;
}
-static int CG_PlayCinematic(const char *name, float x, float y, float w, float h) {
- return trap_CIN_PlayCinematic(name, x, y, w, h, CIN_loop);
+static int CG_PlayCinematic( const char *name, float x, float y, float w, float h )
+{
+ return trap_CIN_PlayCinematic( name, x, y, w, h, CIN_loop );
}
-static void CG_StopCinematic(int handle) {
- trap_CIN_StopCinematic(handle);
+static void CG_StopCinematic( int handle )
+{
+ trap_CIN_StopCinematic( handle );
}
-static void CG_DrawCinematic(int handle, float x, float y, float w, float h) {
- trap_CIN_SetExtents(handle, x, y, w, h);
- trap_CIN_DrawCinematic(handle);
+static void CG_DrawCinematic( int handle, float x, float y, float w, float h )
+{
+ trap_CIN_SetExtents( handle, x, y, w, h );
+ trap_CIN_DrawCinematic( handle );
}
-static void CG_RunCinematicFrame(int handle) {
- trap_CIN_RunCinematic(handle);
+static void CG_RunCinematicFrame( int handle )
+{
+ trap_CIN_RunCinematic( handle );
}
/*
=================
-CG_LoadHudMenu();
-
+CG_LoadHudMenu
=================
*/
-void CG_LoadHudMenu() {
- char buff[1024];
- const char *hudSet;
-
- cgDC.registerShaderNoMip = &trap_R_RegisterShaderNoMip;
- cgDC.setColor = &trap_R_SetColor;
- cgDC.drawHandlePic = &CG_DrawPic;
- cgDC.drawStretchPic = &trap_R_DrawStretchPic;
- cgDC.drawText = &CG_Text_Paint;
- cgDC.textWidth = &CG_Text_Width;
- cgDC.textHeight = &CG_Text_Height;
- cgDC.registerModel = &trap_R_RegisterModel;
- cgDC.modelBounds = &trap_R_ModelBounds;
- cgDC.fillRect = &CG_FillRect;
- cgDC.drawRect = &CG_DrawRect;
- cgDC.drawSides = &CG_DrawSides;
- cgDC.drawTopBottom = &CG_DrawTopBottom;
- cgDC.clearScene = &trap_R_ClearScene;
- cgDC.addRefEntityToScene = &trap_R_AddRefEntityToScene;
- cgDC.renderScene = &trap_R_RenderScene;
- cgDC.registerFont = &trap_R_RegisterFont;
- cgDC.ownerDrawItem = &CG_OwnerDraw;
- cgDC.getValue = &CG_GetValue;
- cgDC.ownerDrawVisible = NULL; //&CG_OwnerDrawVisible;
- cgDC.runScript = &CG_RunMenuScript;
- cgDC.getTeamColor = &CG_GetTeamColor;
- cgDC.setCVar = trap_Cvar_Set;
- cgDC.getCVarString = trap_Cvar_VariableStringBuffer;
- cgDC.getCVarValue = CG_Cvar_Get;
- cgDC.drawTextWithCursor = &CG_Text_PaintWithCursor;
- //cgDC.setOverstrikeMode = &trap_Key_SetOverstrikeMode;
- //cgDC.getOverstrikeMode = &trap_Key_GetOverstrikeMode;
- cgDC.startLocalSound = &trap_S_StartLocalSound;
- cgDC.ownerDrawHandleKey = &CG_OwnerDrawHandleKey;
- cgDC.feederCount = &CG_FeederCount;
- cgDC.feederItemImage = &CG_FeederItemImage;
- cgDC.feederItemText = &CG_FeederItemText;
- cgDC.feederSelection = &CG_FeederSelection;
- //cgDC.setBinding = &trap_Key_SetBinding;
- //cgDC.getBindingBuf = &trap_Key_GetBindingBuf;
- //cgDC.keynumToStringBuf = &trap_Key_KeynumToStringBuf;
- //cgDC.executeText = &trap_Cmd_ExecuteText;
- cgDC.Error = &Com_Error;
- cgDC.Print = &Com_Printf;
- cgDC.ownerDrawWidth = &CG_OwnerDrawWidth;
- //cgDC.Pause = &CG_Pause;
- cgDC.registerSound = &trap_S_RegisterSound;
+void CG_LoadHudMenu( )
+{
+ char buff[ 1024 ];
+ const char *hudSet;
+
+ cgDC.registerShaderNoMip = &trap_R_RegisterShaderNoMip;
+ cgDC.setColor = &trap_R_SetColor;
+ cgDC.drawHandlePic = &CG_DrawPic;
+ cgDC.drawStretchPic = &trap_R_DrawStretchPic;
+ cgDC.drawText = &CG_Text_Paint;
+ cgDC.textWidth = &CG_Text_Width;
+ cgDC.textHeight = &CG_Text_Height;
+ cgDC.registerModel = &trap_R_RegisterModel;
+ cgDC.modelBounds = &trap_R_ModelBounds;
+ cgDC.fillRect = &CG_FillRect;
+ cgDC.drawRect = &CG_DrawRect;
+ cgDC.drawSides = &CG_DrawSides;
+ cgDC.drawTopBottom = &CG_DrawTopBottom;
+ cgDC.clearScene = &trap_R_ClearScene;
+ cgDC.addRefEntityToScene = &trap_R_AddRefEntityToScene;
+ cgDC.renderScene = &trap_R_RenderScene;
+ cgDC.registerFont = &trap_R_RegisterFont;
+ cgDC.ownerDrawItem = &CG_OwnerDraw;
+ cgDC.getValue = &CG_GetValue;
+ cgDC.ownerDrawVisible = NULL; //&CG_OwnerDrawVisible;
+ cgDC.runScript = &CG_RunMenuScript;
+ cgDC.getTeamColor = &CG_GetTeamColor;
+ cgDC.setCVar = trap_Cvar_Set;
+ cgDC.getCVarString = trap_Cvar_VariableStringBuffer;
+ cgDC.getCVarValue = CG_Cvar_Get;
+ cgDC.drawTextWithCursor = &CG_Text_PaintWithCursor;
+ //cgDC.setOverstrikeMode = &trap_Key_SetOverstrikeMode;
+ //cgDC.getOverstrikeMode = &trap_Key_GetOverstrikeMode;
+ cgDC.startLocalSound = &trap_S_StartLocalSound;
+ cgDC.ownerDrawHandleKey = &CG_OwnerDrawHandleKey;
+ cgDC.feederCount = &CG_FeederCount;
+ cgDC.feederItemImage = &CG_FeederItemImage;
+ cgDC.feederItemText = &CG_FeederItemText;
+ cgDC.feederSelection = &CG_FeederSelection;
+ //cgDC.setBinding = &trap_Key_SetBinding;
+ //cgDC.getBindingBuf = &trap_Key_GetBindingBuf;
+ //cgDC.keynumToStringBuf = &trap_Key_KeynumToStringBuf;
+ //cgDC.executeText = &trap_Cmd_ExecuteText;
+ cgDC.Error = &Com_Error;
+ cgDC.Print = &Com_Printf;
+ cgDC.ownerDrawWidth = &CG_OwnerDrawWidth;
+ //cgDC.Pause = &CG_Pause;
+ cgDC.registerSound = &trap_S_RegisterSound;
cgDC.startBackgroundTrack = &trap_S_StartBackgroundTrack;
- cgDC.stopBackgroundTrack = &trap_S_StopBackgroundTrack;
- cgDC.playCinematic = &CG_PlayCinematic;
- cgDC.stopCinematic = &CG_StopCinematic;
- cgDC.drawCinematic = &CG_DrawCinematic;
- cgDC.runCinematicFrame = &CG_RunCinematicFrame;
+ cgDC.stopBackgroundTrack = &trap_S_StopBackgroundTrack;
+ cgDC.playCinematic = &CG_PlayCinematic;
+ cgDC.stopCinematic = &CG_StopCinematic;
+ cgDC.drawCinematic = &CG_DrawCinematic;
+ cgDC.runCinematicFrame = &CG_RunCinematicFrame;
- Init_Display(&cgDC);
+ Init_Display( &cgDC );
- Menu_Reset();
+ Menu_Reset( );
- trap_Cvar_VariableStringBuffer("cg_hudFiles", buff, sizeof(buff));
+ trap_Cvar_VariableStringBuffer( "cg_hudFiles", buff, sizeof( buff ) );
hudSet = buff;
- if (hudSet[0] == '\0') {
+
+ if( hudSet[ 0 ] == '\0' )
hudSet = "ui/hud.txt";
- }
- CG_LoadMenus(hudSet);
+ CG_LoadMenus( hudSet );
}
-void CG_AssetCache() {
- //if (Assets.textFont == NULL) {
- // trap_R_RegisterFont("fonts/arial.ttf", 72, &Assets.textFont);
- //}
- //Assets.background = trap_R_RegisterShaderNoMip( ASSET_BACKGROUND );
- //Com_Printf("Menu Size: %i bytes\n", sizeof(Menus));
- cgDC.Assets.gradientBar = trap_R_RegisterShaderNoMip( ASSET_GRADIENTBAR );
- cgDC.Assets.fxBasePic = trap_R_RegisterShaderNoMip( ART_FX_BASE );
- cgDC.Assets.fxPic[0] = trap_R_RegisterShaderNoMip( ART_FX_RED );
- cgDC.Assets.fxPic[1] = trap_R_RegisterShaderNoMip( ART_FX_YELLOW );
- cgDC.Assets.fxPic[2] = trap_R_RegisterShaderNoMip( ART_FX_GREEN );
- cgDC.Assets.fxPic[3] = trap_R_RegisterShaderNoMip( ART_FX_TEAL );
- cgDC.Assets.fxPic[4] = trap_R_RegisterShaderNoMip( ART_FX_BLUE );
- cgDC.Assets.fxPic[5] = trap_R_RegisterShaderNoMip( ART_FX_CYAN );
- cgDC.Assets.fxPic[6] = trap_R_RegisterShaderNoMip( ART_FX_WHITE );
- cgDC.Assets.scrollBar = trap_R_RegisterShaderNoMip( ASSET_SCROLLBAR );
- cgDC.Assets.scrollBarArrowDown = trap_R_RegisterShaderNoMip( ASSET_SCROLLBAR_ARROWDOWN );
- cgDC.Assets.scrollBarArrowUp = trap_R_RegisterShaderNoMip( ASSET_SCROLLBAR_ARROWUP );
- cgDC.Assets.scrollBarArrowLeft = trap_R_RegisterShaderNoMip( ASSET_SCROLLBAR_ARROWLEFT );
+void CG_AssetCache( void )
+{
+ cgDC.Assets.gradientBar = trap_R_RegisterShaderNoMip( ASSET_GRADIENTBAR );
+ cgDC.Assets.fxBasePic = trap_R_RegisterShaderNoMip( ART_FX_BASE );
+ cgDC.Assets.fxPic[ 0 ] = trap_R_RegisterShaderNoMip( ART_FX_RED );
+ cgDC.Assets.fxPic[ 1 ] = trap_R_RegisterShaderNoMip( ART_FX_YELLOW );
+ cgDC.Assets.fxPic[ 2 ] = trap_R_RegisterShaderNoMip( ART_FX_GREEN );
+ cgDC.Assets.fxPic[ 3 ] = trap_R_RegisterShaderNoMip( ART_FX_TEAL );
+ cgDC.Assets.fxPic[ 4 ] = trap_R_RegisterShaderNoMip( ART_FX_BLUE );
+ cgDC.Assets.fxPic[ 5 ] = trap_R_RegisterShaderNoMip( ART_FX_CYAN );
+ cgDC.Assets.fxPic[ 6 ] = trap_R_RegisterShaderNoMip( ART_FX_WHITE );
+ cgDC.Assets.scrollBar = trap_R_RegisterShaderNoMip( ASSET_SCROLLBAR );
+ cgDC.Assets.scrollBarArrowDown = trap_R_RegisterShaderNoMip( ASSET_SCROLLBAR_ARROWDOWN );
+ cgDC.Assets.scrollBarArrowUp = trap_R_RegisterShaderNoMip( ASSET_SCROLLBAR_ARROWUP );
+ cgDC.Assets.scrollBarArrowLeft = trap_R_RegisterShaderNoMip( ASSET_SCROLLBAR_ARROWLEFT );
cgDC.Assets.scrollBarArrowRight = trap_R_RegisterShaderNoMip( ASSET_SCROLLBAR_ARROWRIGHT );
- cgDC.Assets.scrollBarThumb = trap_R_RegisterShaderNoMip( ASSET_SCROLL_THUMB );
- cgDC.Assets.sliderBar = trap_R_RegisterShaderNoMip( ASSET_SLIDER_BAR );
- cgDC.Assets.sliderThumb = trap_R_RegisterShaderNoMip( ASSET_SLIDER_THUMB );
+ cgDC.Assets.scrollBarThumb = trap_R_RegisterShaderNoMip( ASSET_SCROLL_THUMB );
+ cgDC.Assets.sliderBar = trap_R_RegisterShaderNoMip( ASSET_SLIDER_BAR );
+ cgDC.Assets.sliderThumb = trap_R_RegisterShaderNoMip( ASSET_SLIDER_THUMB );
}
//TA: FIXME: preliminary integration of CG TA UI stuff
@@ -1624,14 +1617,14 @@ Called after every level change or subsystem restart
Will perform callbacks to make the loading info screen update.
=================
*/
-void CG_Init( int serverMessageNum, int serverCommandSequence, int clientNum ) {
+void CG_Init( int serverMessageNum, int serverCommandSequence, int clientNum )
+{
const char *s;
// clear everything
memset( &cgs, 0, sizeof( cgs ) );
memset( &cg, 0, sizeof( cg ) );
- memset( cg_entities, 0, sizeof(cg_entities) );
- memset( cg_items, 0, sizeof(cg_items) );
+ memset( cg_entities, 0, sizeof( cg_entities ) );
cg.clientNum = clientNum;
@@ -1639,31 +1632,26 @@ void CG_Init( int serverMessageNum, int serverCommandSequence, int clientNum ) {
cgs.serverCommandSequence = serverCommandSequence;
// load a few needed things before we do any screen updates
+ cgs.media.whiteShader = trap_R_RegisterShader( "white" );
cgs.media.charsetShader = trap_R_RegisterShader( "gfx/2d/bigchars" );
- cgs.media.whiteShader = trap_R_RegisterShader( "white" );
- cgs.media.charsetProp = trap_R_RegisterShaderNoMip( "menu/art/font1_prop.tga" );
- cgs.media.charsetPropGlow = trap_R_RegisterShaderNoMip( "menu/art/font1_prop_glo.tga" );
- cgs.media.charsetPropB = trap_R_RegisterShaderNoMip( "menu/art/font2_prop.tga" );
+ //inform UI to repress cursor whilst loading
+ trap_Cvar_Set( "ui_loading", "1" );
+
//TA: dyn memory
CG_InitMemory( );
- CG_RegisterCvars();
+ CG_RegisterCvars( );
- CG_InitConsoleCommands();
+ CG_InitConsoleCommands( );
- //repress standard Q3 console
- trap_Cvar_Set( "con_notifytime", "-2" );
-
//TA: moved up for LoadHudMenu
- String_Init();
+ String_Init( );
//TA: FIXME: TA UI
- CG_AssetCache();
- CG_LoadHudMenu(); // load new hud stuff
+ CG_AssetCache( );
+ CG_LoadHudMenu( ); // load new hud stuff
- //cg.weaponSelect = WP_MACHINEGUN;
- //TA: if it does weird things, this is why:
cg.weaponSelect = WP_NONE;
cgs.redflag = cgs.blueflag = -1; // For compatibily, default to unset for
@@ -1680,14 +1668,14 @@ void CG_Init( int serverMessageNum, int serverCommandSequence, int clientNum ) {
// check version
s = CG_ConfigString( CS_GAME_VERSION );
- if ( strcmp( s, GAME_VERSION ) ) {
+
+ if( strcmp( s, GAME_VERSION ) )
CG_Error( "Client/Server game mismatch: %s/%s", GAME_VERSION, s );
- }
s = CG_ConfigString( CS_LEVEL_START_TIME );
cgs.levelStartTime = atoi( s );
- CG_ParseServerinfo();
+ CG_ParseServerinfo( );
// load the new map
trap_CM_LoadMap( cgs.mapname );
@@ -1707,27 +1695,29 @@ void CG_Init( int serverMessageNum, int serverCommandSequence, int clientNum ) {
//TA:
CG_InitBuildables( );
- CG_RegisterClients(); // if low on memory, some clients will be deferred
+ CG_RegisterClients( ); // if low on memory, some clients will be deferred
cg.loading = qfalse; // future players will be deferred
- CG_InitLocalEntities();
+ CG_InitLocalEntities( );
- CG_InitMarkPolys();
+ CG_InitMarkPolys( );
// remove the last loading update
- cg.infoScreenText[0] = 0;
+ cg.infoScreenText[ 0 ] = 0;
// Make sure we have update values (scores)
- CG_SetConfigValues();
+ CG_SetConfigValues( );
- CG_StartMusic();
+ CG_StartMusic( );
- CG_ShaderStateChanged();
+ CG_ShaderStateChanged( );
trap_S_ClearLoopingSounds( qtrue );
cg.consoleValid = qtrue;
+
+ trap_Cvar_Set( "ui_loading", "0" );
}
/*
@@ -1737,28 +1727,8 @@ CG_Shutdown
Called before every level change or subsystem restart
=================
*/
-void CG_Shutdown( void ) {
+void CG_Shutdown( void )
+{
// some mods may need to do cleanup work here,
// like closing files or archiving session data
}
-
-/*
-==================
-CG_EventHandling
-==================
- type 0 - no event handling
- 1 - team menu
- 2 - hud editor
-
-*/
-/*void CG_EventHandling(int type) {
-}
-
-
-
-void CG_KeyEvent(int key, qboolean down) {
-}
-
-void CG_MouseEvent(int x, int y) {
-}
-*/
diff --git a/src/cgame/cg_marks.c b/src/cgame/cg_marks.c
index 7dbb7c1f..deb31c4d 100644
--- a/src/cgame/cg_marks.c
+++ b/src/cgame/cg_marks.c
@@ -26,10 +26,10 @@ MARK POLYS
*/
-markPoly_t cg_activeMarkPolys; // double linked list
-markPoly_t *cg_freeMarkPolys; // single linked list
-markPoly_t cg_markPolys[MAX_MARK_POLYS];
-static int markTotal;
+markPoly_t cg_activeMarkPolys; // double linked list
+markPoly_t *cg_freeMarkPolys; // single linked list
+markPoly_t cg_markPolys[ MAX_MARK_POLYS ];
+static int markTotal;
/*
===================
@@ -38,17 +38,18 @@ CG_InitMarkPolys
This is called at startup and for tournement restarts
===================
*/
-void CG_InitMarkPolys( void ) {
- int i;
-
- memset( cg_markPolys, 0, sizeof(cg_markPolys) );
-
- cg_activeMarkPolys.nextMark = &cg_activeMarkPolys;
- cg_activeMarkPolys.prevMark = &cg_activeMarkPolys;
- cg_freeMarkPolys = cg_markPolys;
- for ( i = 0 ; i < MAX_MARK_POLYS - 1 ; i++ ) {
- cg_markPolys[i].nextMark = &cg_markPolys[i+1];
- }
+void CG_InitMarkPolys( void )
+{
+ int i;
+
+ memset( cg_markPolys, 0, sizeof( cg_markPolys ) );
+
+ cg_activeMarkPolys.nextMark = &cg_activeMarkPolys;
+ cg_activeMarkPolys.prevMark = &cg_activeMarkPolys;
+ cg_freeMarkPolys = cg_markPolys;
+
+ for( i = 0; i < MAX_MARK_POLYS - 1; i++ )
+ cg_markPolys[ i ].nextMark = &cg_markPolys[ i + 1 ];
}
@@ -57,18 +58,18 @@ void CG_InitMarkPolys( void ) {
CG_FreeMarkPoly
==================
*/
-void CG_FreeMarkPoly( markPoly_t *le ) {
- if ( !le->prevMark ) {
- CG_Error( "CG_FreeLocalEntity: not active" );
- }
-
- // remove from the doubly linked active list
- le->prevMark->nextMark = le->nextMark;
- le->nextMark->prevMark = le->prevMark;
-
- // the free list is only singly linked
- le->nextMark = cg_freeMarkPolys;
- cg_freeMarkPolys = le;
+void CG_FreeMarkPoly( markPoly_t *le )
+{
+ if( !le->prevMark )
+ CG_Error( "CG_FreeLocalEntity: not active" );
+
+ // remove from the doubly linked active list
+ le->prevMark->nextMark = le->nextMark;
+ le->nextMark->prevMark = le->prevMark;
+
+ // the free list is only singly linked
+ le->nextMark = cg_freeMarkPolys;
+ cg_freeMarkPolys = le;
}
/*
@@ -78,30 +79,32 @@ CG_AllocMark
Will allways succeed, even if it requires freeing an old active mark
===================
*/
-markPoly_t *CG_AllocMark( void ) {
- markPoly_t *le;
- int time;
-
- if ( !cg_freeMarkPolys ) {
- // no free entities, so free the one at the end of the chain
- // remove the oldest active entity
- time = cg_activeMarkPolys.prevMark->time;
- while (cg_activeMarkPolys.prevMark && time == cg_activeMarkPolys.prevMark->time) {
- CG_FreeMarkPoly( cg_activeMarkPolys.prevMark );
- }
- }
-
- le = cg_freeMarkPolys;
- cg_freeMarkPolys = cg_freeMarkPolys->nextMark;
-
- memset( le, 0, sizeof( *le ) );
-
- // link into the active list
- le->nextMark = cg_activeMarkPolys.nextMark;
- le->prevMark = &cg_activeMarkPolys;
- cg_activeMarkPolys.nextMark->prevMark = le;
- cg_activeMarkPolys.nextMark = le;
- return le;
+markPoly_t *CG_AllocMark( void )
+{
+ markPoly_t *le;
+ int time;
+
+ if( !cg_freeMarkPolys )
+ {
+ // no free entities, so free the one at the end of the chain
+ // remove the oldest active entity
+ time = cg_activeMarkPolys.prevMark->time;
+
+ while( cg_activeMarkPolys.prevMark && time == cg_activeMarkPolys.prevMark->time )
+ CG_FreeMarkPoly( cg_activeMarkPolys.prevMark );
+ }
+
+ le = cg_freeMarkPolys;
+ cg_freeMarkPolys = cg_freeMarkPolys->nextMark;
+
+ memset( le, 0, sizeof( *le ) );
+
+ // link into the active list
+ le->nextMark = cg_activeMarkPolys.nextMark;
+ le->prevMark = &cg_activeMarkPolys;
+ cg_activeMarkPolys.nextMark->prevMark = le;
+ cg_activeMarkPolys.nextMark = le;
+ return le;
}
@@ -117,101 +120,104 @@ temporary marks will not be stored or randomly oriented, but immediately
passed to the renderer.
=================
*/
-#define MAX_MARK_FRAGMENTS 128
-#define MAX_MARK_POINTS 384
+#define MAX_MARK_FRAGMENTS 128
+#define MAX_MARK_POINTS 384
void CG_ImpactMark( qhandle_t markShader, const vec3_t origin, const vec3_t dir,
- float orientation, float red, float green, float blue, float alpha,
- qboolean alphaFade, float radius, qboolean temporary ) {
- vec3_t axis[3];
- float texCoordScale;
- vec3_t originalPoints[4];
- byte colors[4];
- int i, j;
- int numFragments;
- markFragment_t markFragments[MAX_MARK_FRAGMENTS], *mf;
- vec3_t markPoints[MAX_MARK_POINTS];
- vec3_t projection;
-
- if ( !cg_addMarks.integer ) {
- return;
- }
-
- if ( radius <= 0 ) {
- CG_Error( "CG_ImpactMark called with <= 0 radius" );
- }
+ float orientation, float red, float green, float blue, float alpha,
+ qboolean alphaFade, float radius, qboolean temporary )
+{
+ vec3_t axis[ 3 ];
+ float texCoordScale;
+ vec3_t originalPoints[ 4 ];
+ byte colors[ 4 ];
+ int i, j;
+ int numFragments;
+ markFragment_t markFragments[ MAX_MARK_FRAGMENTS ], *mf;
+ vec3_t markPoints[ MAX_MARK_POINTS ];
+ vec3_t projection;
+
+ if( !cg_addMarks.integer )
+ return;
+
+ if( radius <= 0 )
+ CG_Error( "CG_ImpactMark called with <= 0 radius" );
//if ( markTotal >= MAX_MARK_POLYS ) {
// return;
//}
- // create the texture axis
- VectorNormalize2( dir, axis[0] );
- PerpendicularVector( axis[1], axis[0] );
- RotatePointAroundVector( axis[2], axis[0], axis[1], orientation );
- CrossProduct( axis[0], axis[2], axis[1] );
-
- texCoordScale = 0.5 * 1.0 / radius;
-
- // create the full polygon
- for ( i = 0 ; i < 3 ; i++ ) {
- originalPoints[0][i] = origin[i] - radius * axis[1][i] - radius * axis[2][i];
- originalPoints[1][i] = origin[i] + radius * axis[1][i] - radius * axis[2][i];
- originalPoints[2][i] = origin[i] + radius * axis[1][i] + radius * axis[2][i];
- originalPoints[3][i] = origin[i] - radius * axis[1][i] + radius * axis[2][i];
- }
-
- // get the fragments
- VectorScale( dir, -20, projection );
- numFragments = trap_CM_MarkFragments( 4, (void *)originalPoints,
- projection, MAX_MARK_POINTS, markPoints[0],
- MAX_MARK_FRAGMENTS, markFragments );
-
- colors[0] = red * 255;
- colors[1] = green * 255;
- colors[2] = blue * 255;
- colors[3] = alpha * 255;
-
- for ( i = 0, mf = markFragments ; i < numFragments ; i++, mf++ ) {
- polyVert_t *v;
- polyVert_t verts[MAX_VERTS_ON_POLY];
- markPoly_t *mark;
-
- // we have an upper limit on the complexity of polygons
- // that we store persistantly
- if ( mf->numPoints > MAX_VERTS_ON_POLY ) {
- mf->numPoints = MAX_VERTS_ON_POLY;
- }
- for ( j = 0, v = verts ; j < mf->numPoints ; j++, v++ ) {
- vec3_t delta;
-
- VectorCopy( markPoints[mf->firstPoint + j], v->xyz );
-
- VectorSubtract( v->xyz, origin, delta );
- v->st[0] = 0.5 + DotProduct( delta, axis[1] ) * texCoordScale;
- v->st[1] = 0.5 + DotProduct( delta, axis[2] ) * texCoordScale;
- *(int *)v->modulate = *(int *)colors;
- }
-
- // if it is a temporary (shadow) mark, add it immediately and forget about it
- if ( temporary ) {
- trap_R_AddPolyToScene( markShader, mf->numPoints, verts );
- continue;
- }
-
- // otherwise save it persistantly
- mark = CG_AllocMark();
- mark->time = cg.time;
- mark->alphaFade = alphaFade;
- mark->markShader = markShader;
- mark->poly.numVerts = mf->numPoints;
- mark->color[0] = red;
- mark->color[1] = green;
- mark->color[2] = blue;
- mark->color[3] = alpha;
- memcpy( mark->verts, verts, mf->numPoints * sizeof( verts[0] ) );
+ // create the texture axis
+ VectorNormalize2( dir, axis[ 0 ] );
+ PerpendicularVector( axis[ 1 ], axis[ 0 ] );
+ RotatePointAroundVector( axis[ 2 ], axis[ 0 ], axis[ 1 ], orientation );
+ CrossProduct( axis[ 0 ], axis[ 2 ], axis[ 1 ] );
+
+ texCoordScale = 0.5 * 1.0 / radius;
+
+ // create the full polygon
+ for( i = 0; i < 3; i++ )
+ {
+ originalPoints[ 0 ][ i ] = origin[ i ] - radius * axis[ 1 ][ i ] - radius * axis[ 2 ][ i ];
+ originalPoints[ 1 ][ i ] = origin[ i ] + radius * axis[ 1 ][ i ] - radius * axis[ 2 ][ i ];
+ originalPoints[ 2 ][ i ] = origin[ i ] + radius * axis[ 1 ][ i ] + radius * axis[ 2 ][ i ];
+ originalPoints[ 3 ][ i ] = origin[ i ] - radius * axis[ 1 ][ i ] + radius * axis[ 2 ][ i ];
+ }
+
+ // get the fragments
+ VectorScale( dir, -20, projection );
+ numFragments = trap_CM_MarkFragments( 4, (void *)originalPoints,
+ projection, MAX_MARK_POINTS, markPoints[ 0 ],
+ MAX_MARK_FRAGMENTS, markFragments );
+
+ colors[ 0 ] = red * 255;
+ colors[ 1 ] = green * 255;
+ colors[ 2 ] = blue * 255;
+ colors[ 3 ] = alpha * 255;
+
+ for( i = 0, mf = markFragments; i < numFragments; i++, mf++ )
+ {
+ polyVert_t *v;
+ polyVert_t verts[ MAX_VERTS_ON_POLY ];
+ markPoly_t *mark;
+
+ // we have an upper limit on the complexity of polygons
+ // that we store persistantly
+ if( mf->numPoints > MAX_VERTS_ON_POLY )
+ mf->numPoints = MAX_VERTS_ON_POLY;
+
+ for( j = 0, v = verts; j < mf->numPoints; j++, v++ )
+ {
+ vec3_t delta;
+
+ VectorCopy( markPoints[ mf->firstPoint + j ], v->xyz );
+
+ VectorSubtract( v->xyz, origin, delta );
+ v->st[ 0 ] = 0.5 + DotProduct( delta, axis[ 1 ] ) * texCoordScale;
+ v->st[ 1 ] = 0.5 + DotProduct( delta, axis[ 2 ] ) * texCoordScale;
+ *(int *)v->modulate = *(int *)colors;
+ }
+
+ // if it is a temporary (shadow) mark, add it immediately and forget about it
+ if( temporary )
+ {
+ trap_R_AddPolyToScene( markShader, mf->numPoints, verts );
+ continue;
+ }
+
+ // otherwise save it persistantly
+ mark = CG_AllocMark( );
+ mark->time = cg.time;
+ mark->alphaFade = alphaFade;
+ mark->markShader = markShader;
+ mark->poly.numVerts = mf->numPoints;
+ mark->color[ 0 ] = red;
+ mark->color[ 1 ] = green;
+ mark->color[ 2 ] = blue;
+ mark->color[ 3 ] = alpha;
+ memcpy( mark->verts, verts, mf->numPoints * sizeof( verts[ 0 ] ) );
markTotal++;
- }
+ }
}
@@ -220,68 +226,77 @@ void CG_ImpactMark( qhandle_t markShader, const vec3_t origin, const vec3_t dir,
CG_AddMarks
===============
*/
-#define MARK_TOTAL_TIME 10000
-#define MARK_FADE_TIME 1000
-
-void CG_AddMarks( void ) {
- int j;
- markPoly_t *mp, *next;
- int t;
- int fade;
-
- if ( !cg_addMarks.integer ) {
- return;
- }
-
- mp = cg_activeMarkPolys.nextMark;
- for ( ; mp != &cg_activeMarkPolys ; mp = next ) {
- // grab next now, so if the local entity is freed we
- // still have it
- next = mp->nextMark;
-
- // see if it is time to completely remove it
- if ( cg.time > mp->time + MARK_TOTAL_TIME ) {
- CG_FreeMarkPoly( mp );
- continue;
- }
-
- // fade out the energy bursts
- if ( mp->markShader == cgs.media.energyMarkShader ) {
-
- fade = 450 - 450 * ( (cg.time - mp->time ) / 3000.0 );
- if ( fade < 255 ) {
- if ( fade < 0 ) {
- fade = 0;
- }
- if ( mp->verts[0].modulate[0] != 0 ) {
- for ( j = 0 ; j < mp->poly.numVerts ; j++ ) {
- mp->verts[j].modulate[0] = mp->color[0] * fade;
- mp->verts[j].modulate[1] = mp->color[1] * fade;
- mp->verts[j].modulate[2] = mp->color[2] * fade;
- }
- }
- }
- }
-
- // fade all marks out with time
- t = mp->time + MARK_TOTAL_TIME - cg.time;
- if ( t < MARK_FADE_TIME ) {
- fade = 255 * t / MARK_FADE_TIME;
- if ( mp->alphaFade ) {
- for ( j = 0 ; j < mp->poly.numVerts ; j++ ) {
- mp->verts[j].modulate[3] = fade;
- }
- } else {
- for ( j = 0 ; j < mp->poly.numVerts ; j++ ) {
- mp->verts[j].modulate[0] = mp->color[0] * fade;
- mp->verts[j].modulate[1] = mp->color[1] * fade;
- mp->verts[j].modulate[2] = mp->color[2] * fade;
- }
- }
- }
-
-
- trap_R_AddPolyToScene( mp->markShader, mp->poly.numVerts, mp->verts );
- }
+#define MARK_TOTAL_TIME 10000
+#define MARK_FADE_TIME 1000
+
+void CG_AddMarks( void )
+{
+ int j;
+ markPoly_t *mp, *next;
+ int t;
+ int fade;
+
+ if( !cg_addMarks.integer )
+ return;
+
+ mp = cg_activeMarkPolys.nextMark;
+ for ( ; mp != &cg_activeMarkPolys; mp = next )
+ {
+ // grab next now, so if the local entity is freed we
+ // still have it
+ next = mp->nextMark;
+
+ // see if it is time to completely remove it
+ if( cg.time > mp->time + MARK_TOTAL_TIME )
+ {
+ CG_FreeMarkPoly( mp );
+ continue;
+ }
+
+ // fade out the energy bursts
+ if( mp->markShader == cgs.media.energyMarkShader )
+ {
+
+ fade = 450 - 450 * ( (cg.time - mp->time ) / 3000.0 );
+ if( fade < 255 )
+ {
+ if( fade < 0 )
+ fade = 0;
+
+ if( mp->verts[ 0 ].modulate[ 0 ] != 0 )
+ {
+ for( j = 0; j < mp->poly.numVerts; j++ )
+ {
+ mp->verts[ j ].modulate[ 0 ] = mp->color[ 0 ] * fade;
+ mp->verts[ j ].modulate[ 1 ] = mp->color[ 1 ] * fade;
+ mp->verts[ j ].modulate[ 2 ] = mp->color[ 2 ] * fade;
+ }
+ }
+ }
+ }
+
+ // fade all marks out with time
+ t = mp->time + MARK_TOTAL_TIME - cg.time;
+ if( t < MARK_FADE_TIME )
+ {
+ fade = 255 * t / MARK_FADE_TIME;
+ if( mp->alphaFade )
+ {
+ for( j = 0; j < mp->poly.numVerts; j++ )
+ mp->verts[ j ].modulate[ 3 ] = fade;
+ }
+ else
+ {
+ for( j = 0; j < mp->poly.numVerts; j++ )
+ {
+ mp->verts[ j ].modulate[ 0 ] = mp->color[ 0 ] * fade;
+ mp->verts[ j ].modulate[ 1 ] = mp->color[ 1 ] * fade;
+ mp->verts[ j ].modulate[ 2 ] = mp->color[ 2 ] * fade;
+ }
+ }
+ }
+
+ trap_R_AddPolyToScene( mp->markShader, mp->poly.numVerts, mp->verts );
+ }
}
diff --git a/src/cgame/cg_players.c b/src/cgame/cg_players.c
index 09098e31..b553fbc2 100644
--- a/src/cgame/cg_players.c
+++ b/src/cgame/cg_players.c
@@ -17,7 +17,8 @@
#include "cg_local.h"
-char *cg_customSoundNames[MAX_CUSTOM_SOUNDS] = {
+char *cg_customSoundNames[ MAX_CUSTOM_SOUNDS ] =
+{
"*death1.wav",
"*death2.wav",
"*death3.wav",
@@ -40,23 +41,23 @@ CG_CustomSound
================
*/
-sfxHandle_t CG_CustomSound( int clientNum, const char *soundName ) {
- clientInfo_t *ci;
- int i;
+sfxHandle_t CG_CustomSound( int clientNum, const char *soundName )
+{
+ clientInfo_t *ci;
+ int i;
- if ( soundName[0] != '*' ) {
+ if( soundName[ 0 ] != '*' )
return trap_S_RegisterSound( soundName, qfalse );
- }
- if ( clientNum < 0 || clientNum >= MAX_CLIENTS ) {
+ if( clientNum < 0 || clientNum >= MAX_CLIENTS )
clientNum = 0;
- }
+
ci = &cgs.clientinfo[ clientNum ];
- for ( i = 0 ; i < MAX_CUSTOM_SOUNDS && cg_customSoundNames[i] ; i++ ) {
- if ( !strcmp( soundName, cg_customSoundNames[i] ) ) {
- return ci->sounds[i];
- }
+ for( i = 0; i < MAX_CUSTOM_SOUNDS && cg_customSoundNames[ i ]; i++ )
+ {
+ if( !strcmp( soundName, cg_customSoundNames[ i ] ) )
+ return ci->sounds[ i ];
}
CG_Error( "Unknown custom sound: %s", soundName );
@@ -81,30 +82,33 @@ Read a configuration file containing animation coutns and rates
models/players/visor/animation.cfg, etc
======================
*/
-static qboolean CG_ParseAnimationFile( const char *filename, clientInfo_t *ci ) {
- char *text_p, *prev;
- int len;
- int i;
- char *token;
- float fps;
- int skip;
- char text[20000];
+static qboolean CG_ParseAnimationFile( const char *filename, clientInfo_t *ci )
+{
+ char *text_p, *prev;
+ int len;
+ int i;
+ char *token;
+ float fps;
+ int skip;
+ char text[ 20000 ];
fileHandle_t f;
- animation_t *animations;
+ animation_t *animations;
animations = ci->animations;
// load the file
len = trap_FS_FOpenFile( filename, &f, FS_READ );
- if ( len <= 0 ) {
+ if( len <= 0 )
return qfalse;
- }
- if ( len >= sizeof( text ) - 1 ) {
+
+ if( len >= sizeof( text ) - 1 )
+ {
CG_Printf( "File %s too long\n", filename );
return qfalse;
}
+
trap_FS_Read( text, len, f );
- text[len] = 0;
+ text[ len ] = 0;
trap_FS_FCloseFile( f );
// parse the text
@@ -118,166 +122,184 @@ static qboolean CG_ParseAnimationFile( const char *filename, clientInfo_t *ci )
ci->fixedtorso = qfalse;
// read optional parameters
- while ( 1 ) {
+ while( 1 )
+ {
prev = text_p; // so we can unget
token = COM_Parse( &text_p );
- if ( !token ) {
+
+ if( !token )
break;
- }
- if ( !Q_stricmp( token, "footsteps" ) ) {
+
+ if( !Q_stricmp( token, "footsteps" ) )
+ {
token = COM_Parse( &text_p );
- if ( !token ) {
+ if( !token )
break;
- }
- if ( !Q_stricmp( token, "default" ) || !Q_stricmp( token, "normal" ) ) {
+
+ if( !Q_stricmp( token, "default" ) || !Q_stricmp( token, "normal" ) )
ci->footsteps = FOOTSTEP_NORMAL;
- } else if ( !Q_stricmp( token, "boot" ) ) {
+ else if( !Q_stricmp( token, "boot" ) )
ci->footsteps = FOOTSTEP_BOOT;
- } else if ( !Q_stricmp( token, "flesh" ) ) {
+ else if( !Q_stricmp( token, "flesh" ) )
ci->footsteps = FOOTSTEP_FLESH;
- } else if ( !Q_stricmp( token, "mech" ) ) {
+ else if( !Q_stricmp( token, "mech" ) )
ci->footsteps = FOOTSTEP_MECH;
- } else if ( !Q_stricmp( token, "energy" ) ) {
+ else if( !Q_stricmp( token, "energy" ) )
ci->footsteps = FOOTSTEP_ENERGY;
- } else {
+ else
CG_Printf( "Bad footsteps parm in %s: %s\n", filename, token );
- }
+
continue;
- } else if ( !Q_stricmp( token, "headoffset" ) ) {
- for ( i = 0 ; i < 3 ; i++ ) {
+ }
+ else if( !Q_stricmp( token, "headoffset" ) )
+ {
+ for( i = 0 ; i < 3 ; i++ )
+ {
token = COM_Parse( &text_p );
- if ( !token ) {
+ if( !token )
break;
- }
- ci->headOffset[i] = atof( token );
+
+ ci->headOffset[ i ] = atof( token );
}
+
continue;
- } else if ( !Q_stricmp( token, "sex" ) ) {
+ }
+ else if( !Q_stricmp( token, "sex" ) )
+ {
token = COM_Parse( &text_p );
- if ( !token ) {
+
+ if( !token )
break;
- }
- if ( token[0] == 'f' || token[0] == 'F' ) {
+
+ if( token[ 0 ] == 'f' || token[ 0 ] == 'F' )
ci->gender = GENDER_FEMALE;
- } else if ( token[0] == 'n' || token[0] == 'N' ) {
+ else if( token[ 0 ] == 'n' || token[ 0 ] == 'N' )
ci->gender = GENDER_NEUTER;
- } else {
+ else
ci->gender = GENDER_MALE;
- }
+
continue;
- } else if ( !Q_stricmp( token, "fixedlegs" ) ) {
+ }
+ else if( !Q_stricmp( token, "fixedlegs" ) )
+ {
ci->fixedlegs = qtrue;
continue;
- } else if ( !Q_stricmp( token, "fixedtorso" ) ) {
+ }
+ else if( !Q_stricmp( token, "fixedtorso" ) )
+ {
ci->fixedtorso = qtrue;
continue;
}
// if it is a number, start parsing animations
- if ( token[0] >= '0' && token[0] <= '9' ) {
+ if( token[ 0 ] >= '0' && token[ 0 ] <= '9' )
+ {
text_p = prev; // unget the token
break;
}
+
Com_Printf( "unknown token '%s' is %s\n", token, filename );
}
// read information for each frame
- for ( i = 0 ; i < MAX_PLAYER_ANIMATIONS ; i++ ) {
-
+ for( i = 0; i < MAX_PLAYER_ANIMATIONS; i++ )
+ {
token = COM_Parse( &text_p );
- if ( !*token ) {
- if( i >= TORSO_GETFLAG && i <= TORSO_NEGATIVE ) {
- animations[i].firstFrame = animations[TORSO_GESTURE].firstFrame;
- animations[i].frameLerp = animations[TORSO_GESTURE].frameLerp;
- animations[i].initialLerp = animations[TORSO_GESTURE].initialLerp;
- animations[i].loopFrames = animations[TORSO_GESTURE].loopFrames;
- animations[i].numFrames = animations[TORSO_GESTURE].numFrames;
- animations[i].reversed = qfalse;
- animations[i].flipflop = qfalse;
+
+ if( !*token )
+ {
+ if( i >= TORSO_GETFLAG && i <= TORSO_NEGATIVE )
+ {
+ animations[ i ].firstFrame = animations[ TORSO_GESTURE ].firstFrame;
+ animations[ i ].frameLerp = animations[ TORSO_GESTURE ].frameLerp;
+ animations[ i ].initialLerp = animations[ TORSO_GESTURE ].initialLerp;
+ animations[ i ].loopFrames = animations[ TORSO_GESTURE ].loopFrames;
+ animations[ i ].numFrames = animations[ TORSO_GESTURE ].numFrames;
+ animations[ i ].reversed = qfalse;
+ animations[ i ].flipflop = qfalse;
continue;
}
+
break;
}
- animations[i].firstFrame = atoi( token );
+
+ animations[ i ].firstFrame = atoi( token );
+
// leg only frames are adjusted to not count the upper body only frames
- if ( i == LEGS_WALKCR ) {
- skip = animations[LEGS_WALKCR].firstFrame - animations[TORSO_GESTURE].firstFrame;
- }
- if ( i >= LEGS_WALKCR && i<TORSO_GETFLAG ) {
- animations[i].firstFrame -= skip;
- }
+ if( i == LEGS_WALKCR )
+ skip = animations[ LEGS_WALKCR ].firstFrame - animations[ TORSO_GESTURE ].firstFrame;
+
+ if( i >= LEGS_WALKCR && i<TORSO_GETFLAG )
+ animations[ i ].firstFrame -= skip;
token = COM_Parse( &text_p );
- if ( !*token ) {
+ if( !*token )
break;
- }
- animations[i].numFrames = atoi( token );
- animations[i].reversed = qfalse;
- animations[i].flipflop = qfalse;
+
+ animations[ i ].numFrames = atoi( token );
+ animations[ i ].reversed = qfalse;
+ animations[ i ].flipflop = qfalse;
+
// if numFrames is negative the animation is reversed
- if (animations[i].numFrames < 0) {
- animations[i].numFrames = -animations[i].numFrames;
- animations[i].reversed = qtrue;
+ if( animations[ i ].numFrames < 0 )
+ {
+ animations[ i ].numFrames = -animations[ i ].numFrames;
+ animations[ i ].reversed = qtrue;
}
token = COM_Parse( &text_p );
- if ( !*token ) {
+
+ if( !*token )
break;
- }
- animations[i].loopFrames = atoi( token );
+
+ animations[ i ].loopFrames = atoi( token );
token = COM_Parse( &text_p );
- if ( !*token ) {
+
+ if( !*token )
break;
- }
+
fps = atof( token );
- if ( fps == 0 ) {
+ if( fps == 0 )
fps = 1;
- }
- animations[i].frameLerp = 1000 / fps;
- animations[i].initialLerp = 1000 / fps;
+
+ animations[ i ].frameLerp = 1000 / fps;
+ animations[ i ].initialLerp = 1000 / fps;
}
- if ( i != MAX_PLAYER_ANIMATIONS ) {
+ if( i != MAX_PLAYER_ANIMATIONS )
+ {
CG_Printf( "Error parsing animation file: %s", filename );
return qfalse;
}
// crouch backward animation
- memcpy(&animations[LEGS_BACKCR], &animations[LEGS_WALKCR], sizeof(animation_t));
- animations[LEGS_BACKCR].reversed = qtrue;
+ memcpy( &animations[ LEGS_BACKCR ], &animations[ LEGS_WALKCR ], sizeof( animation_t ) );
+ animations[ LEGS_BACKCR ].reversed = qtrue;
// walk backward animation
- memcpy(&animations[LEGS_BACKWALK], &animations[LEGS_WALK], sizeof(animation_t));
- animations[LEGS_BACKWALK].reversed = qtrue;
+ memcpy( &animations[ LEGS_BACKWALK ], &animations[ LEGS_WALK ], sizeof( animation_t ) );
+ animations[ LEGS_BACKWALK ].reversed = qtrue;
// flag moving fast
- animations[FLAG_RUN].firstFrame = 0;
- animations[FLAG_RUN].numFrames = 16;
- animations[FLAG_RUN].loopFrames = 16;
- animations[FLAG_RUN].frameLerp = 1000 / 15;
- animations[FLAG_RUN].initialLerp = 1000 / 15;
- animations[FLAG_RUN].reversed = qfalse;
+ animations[ FLAG_RUN ].firstFrame = 0;
+ animations[ FLAG_RUN ].numFrames = 16;
+ animations[ FLAG_RUN ].loopFrames = 16;
+ animations[ FLAG_RUN ].frameLerp = 1000 / 15;
+ animations[ FLAG_RUN ].initialLerp = 1000 / 15;
+ animations[ FLAG_RUN ].reversed = qfalse;
// flag not moving or moving slowly
- animations[FLAG_STAND].firstFrame = 16;
- animations[FLAG_STAND].numFrames = 5;
- animations[FLAG_STAND].loopFrames = 0;
- animations[FLAG_STAND].frameLerp = 1000 / 20;
- animations[FLAG_STAND].initialLerp = 1000 / 20;
- animations[FLAG_STAND].reversed = qfalse;
+ animations[ FLAG_STAND ].firstFrame = 16;
+ animations[ FLAG_STAND ].numFrames = 5;
+ animations[ FLAG_STAND ].loopFrames = 0;
+ animations[ FLAG_STAND ].frameLerp = 1000 / 20;
+ animations[ FLAG_STAND ].initialLerp = 1000 / 20;
+ animations[ FLAG_STAND ].reversed = qfalse;
// flag speeding up
- animations[FLAG_STAND2RUN].firstFrame = 16;
- animations[FLAG_STAND2RUN].numFrames = 5;
- animations[FLAG_STAND2RUN].loopFrames = 1;
- animations[FLAG_STAND2RUN].frameLerp = 1000 / 15;
- animations[FLAG_STAND2RUN].initialLerp = 1000 / 15;
- animations[FLAG_STAND2RUN].reversed = qtrue;
- //
- // new anims changes
- //
-// animations[TORSO_GETFLAG].flipflop = qtrue;
-// animations[TORSO_GUARDBASE].flipflop = qtrue;
-// animations[TORSO_PATROL].flipflop = qtrue;
-// animations[TORSO_AFFIRMATIVE].flipflop = qtrue;
-// animations[TORSO_NEGATIVE].flipflop = qtrue;
- //
+ animations[ FLAG_STAND2RUN ].firstFrame = 16;
+ animations[ FLAG_STAND2RUN ].numFrames = 5;
+ animations[ FLAG_STAND2RUN ].loopFrames = 1;
+ animations[ FLAG_STAND2RUN ].frameLerp = 1000 / 15;
+ animations[ FLAG_STAND2RUN ].initialLerp = 1000 / 15;
+ animations[ FLAG_STAND2RUN ].reversed = qtrue;
+
return qtrue;
}
@@ -286,30 +308,27 @@ static qboolean CG_ParseAnimationFile( const char *filename, clientInfo_t *ci )
CG_RegisterClientSkin
==========================
*/
-static qboolean CG_RegisterClientSkin( clientInfo_t *ci, const char *modelName, const char *skinName ) {
- char filename[MAX_QPATH];
+static qboolean CG_RegisterClientSkin( clientInfo_t *ci, const char *modelName, const char *skinName )
+{
+ char filename[ MAX_QPATH ];
Com_sprintf( filename, sizeof( filename ), "models/players/%s/lower_%s.skin", modelName, skinName );
ci->legsSkin = trap_R_RegisterSkin( filename );
- if (!ci->legsSkin) {
+ if( !ci->legsSkin )
Com_Printf( "Leg skin load failure: %s\n", filename );
- }
Com_sprintf( filename, sizeof( filename ), "models/players/%s/upper_%s.skin", modelName, skinName );
ci->torsoSkin = trap_R_RegisterSkin( filename );
- if (!ci->torsoSkin) {
+ if( !ci->torsoSkin )
Com_Printf( "Torso skin load failure: %s\n", filename );
- }
Com_sprintf( filename, sizeof( filename ), "models/players/%s/head_%s.skin", modelName, skinName );
ci->headSkin = trap_R_RegisterSkin( filename );
- if (!ci->headSkin) {
+ if( !ci->headSkin )
Com_Printf( "Head skin load failure: %s\n", filename );
- }
- if ( !ci->legsSkin || !ci->torsoSkin || !ci->headSkin ) {
+ if( !ci->legsSkin || !ci->torsoSkin || !ci->headSkin )
return qfalse;
- }
return qtrue;
}
@@ -319,48 +338,55 @@ static qboolean CG_RegisterClientSkin( clientInfo_t *ci, const char *modelName,
CG_RegisterClientModelname
==========================
*/
-static qboolean CG_RegisterClientModelname( clientInfo_t *ci, const char *modelName, const char *skinName ) {
- char filename[MAX_QPATH*2];
+static qboolean CG_RegisterClientModelname( clientInfo_t *ci, const char *modelName, const char *skinName )
+{
+ char filename[ MAX_QPATH * 2 ];
// load cmodels before models so filecache works
Com_sprintf( filename, sizeof( filename ), "models/players/%s/lower.md3", modelName );
ci->legsModel = trap_R_RegisterModel( filename );
- if ( !ci->legsModel ) {
+ if( !ci->legsModel )
+ {
Com_Printf( "Failed to load model file %s\n", filename );
return qfalse;
}
Com_sprintf( filename, sizeof( filename ), "models/players/%s/upper.md3", modelName );
ci->torsoModel = trap_R_RegisterModel( filename );
- if ( !ci->torsoModel ) {
+ if( !ci->torsoModel )
+ {
Com_Printf( "Failed to load model file %s\n", filename );
return qfalse;
}
Com_sprintf( filename, sizeof( filename ), "models/players/%s/head.md3", modelName );
ci->headModel = trap_R_RegisterModel( filename );
- if ( !ci->headModel ) {
+ if( !ci->headModel )
+ {
Com_Printf( "Failed to load model file %s\n", filename );
return qfalse;
}
// if any skins failed to load, return failure
- if ( !CG_RegisterClientSkin( ci, modelName, skinName ) ) {
+ if( !CG_RegisterClientSkin( ci, modelName, skinName ) )
+ {
Com_Printf( "Failed to load skin file: %s : %s\n", modelName, skinName );
return qfalse;
}
// load the animations
Com_sprintf( filename, sizeof( filename ), "models/players/%s/animation.cfg", modelName );
- if ( !CG_ParseAnimationFile( filename, ci ) ) {
+ if( !CG_ParseAnimationFile( filename, ci ) )
+ {
Com_Printf( "Failed to load animation file %s\n", filename );
return qfalse;
}
Com_sprintf( filename, sizeof( filename ), "models/players/%s/icon_%s.tga", modelName, skinName );
ci->modelIcon = trap_R_RegisterShaderNoMip( filename );
- if ( !ci->modelIcon ) {
+ if( !ci->modelIcon )
+ {
Com_Printf( "Failed to load icon file: %s\n", filename );
return qfalse;
}
@@ -373,27 +399,28 @@ static qboolean CG_RegisterClientModelname( clientInfo_t *ci, const char *modelN
CG_ColorFromString
====================
*/
-static void CG_ColorFromString( const char *v, vec3_t color ) {
+static void CG_ColorFromString( const char *v, vec3_t color )
+{
int val;
VectorClear( color );
val = atoi( v );
- if ( val < 1 || val > 7 ) {
+ if( val < 1 || val > 7 )
+ {
VectorSet( color, 1, 1, 1 );
return;
}
- if ( val & 1 ) {
- color[2] = 1.0f;
- }
- if ( val & 2 ) {
- color[1] = 1.0f;
- }
- if ( val & 4 ) {
- color[0] = 1.0f;
- }
+ if( val & 1 )
+ color[ 2 ] = 1.0f;
+
+ if( val & 2 )
+ color[ 1 ] = 1.0f;
+
+ if( val & 4 )
+ color[ 0 ] = 1.0f;
}
@@ -405,16 +432,17 @@ Load it now, taking the disk hits.
This will usually be deferred to a safe time
===================
*/
-static void CG_LoadClientInfo( clientInfo_t *ci ) {
+static void CG_LoadClientInfo( clientInfo_t *ci )
+{
const char *dir, *fallback;
- int i;
+ int i;
const char *s;
- int clientNum;
+ int clientNum;
- if ( !CG_RegisterClientModelname( ci, ci->modelName, ci->skinName ) ) {
- if ( cg_buildScript.integer ) {
+ if( !CG_RegisterClientModelname( ci, ci->modelName, ci->skinName ) )
+ {
+ if( cg_buildScript.integer )
CG_Error( "CG_RegisterClientModelname( %s, %s ) failed", ci->modelName, ci->skinName );
- }
// fall back
if( !CG_RegisterClientModelname( ci, DEFAULT_MODEL, "default" ) )
@@ -425,15 +453,16 @@ static void CG_LoadClientInfo( clientInfo_t *ci ) {
dir = ci->modelName;
fallback = DEFAULT_MODEL;
- for ( i = 0 ; i < MAX_CUSTOM_SOUNDS ; i++ ) {
- s = cg_customSoundNames[i];
- if ( !s ) {
+ for( i = 0 ; i < MAX_CUSTOM_SOUNDS ; i++ )
+ {
+ s = cg_customSoundNames[ i ];
+
+ if( !s )
break;
- }
- ci->sounds[i] = trap_S_RegisterSound( va("sound/player/%s/%s", dir, s + 1), qfalse );
- if ( !ci->sounds[i] ) {
- ci->sounds[i] = trap_S_RegisterSound( va("sound/player/%s/%s", fallback, s + 1), qfalse );
- }
+
+ ci->sounds[ i ] = trap_S_RegisterSound( va( "sound/player/%s/%s", dir, s + 1 ), qfalse );
+ if( !ci->sounds[ i ] )
+ ci->sounds[ i ] = trap_S_RegisterSound( va( "sound/player/%s/%s", fallback, s + 1 ), qfalse );
}
ci->deferred = qfalse;
@@ -443,11 +472,11 @@ static void CG_LoadClientInfo( clientInfo_t *ci ) {
if( clientNum <= MAX_CLIENTS )
{
clientNum = ci - cgs.clientinfo;
- for ( i = 0 ; i < MAX_GENTITIES ; i++ ) {
- if ( cg_entities[i].currentState.clientNum == clientNum
- && cg_entities[i].currentState.eType == ET_PLAYER ) {
- CG_ResetPlayerEntity( &cg_entities[i] );
- }
+ for( i = 0; i < MAX_GENTITIES; i++ )
+ {
+ if( cg_entities[ i ].currentState.clientNum == clientNum &&
+ cg_entities[ i ].currentState.eType == ET_PLAYER )
+ CG_ResetPlayerEntity( &cg_entities[ i ] );
}
}
}
@@ -457,7 +486,8 @@ static void CG_LoadClientInfo( clientInfo_t *ci ) {
CG_CopyClientInfoModel
======================
*/
-static void CG_CopyClientInfoModel( clientInfo_t *from, clientInfo_t *to ) {
+static void CG_CopyClientInfoModel( clientInfo_t *from, clientInfo_t *to )
+{
VectorCopy( from->headOffset, to->headOffset );
to->footsteps = from->footsteps;
to->gender = from->gender;
@@ -480,24 +510,27 @@ static void CG_CopyClientInfoModel( clientInfo_t *from, clientInfo_t *to ) {
CG_GetCorpseNum
======================
*/
-static int CG_GetCorpseNum( int pclass ) {
+static int CG_GetCorpseNum( int pclass )
+{
int i;
clientInfo_t *match;
char *modelName;
modelName = BG_FindModelNameForClass( pclass );
- for ( i = PCL_NONE + 1 ; i < PCL_NUM_CLASSES; i++ )
+ for( i = PCL_NONE + 1; i < PCL_NUM_CLASSES; i++ )
{
match = &cgs.corpseinfo[ i ];
- if ( !match->infoValid )
+
+ if( !match->infoValid )
continue;
- if ( match->deferred )
+ if( match->deferred )
continue;
- if ( !Q_stricmp( modelName, match->modelName )
- /*&& !Q_stricmp( modelName, match->skinName )*/ ) {
+ if( !Q_stricmp( modelName, match->modelName )
+ /*&& !Q_stricmp( modelName, match->skinName )*/ )
+ {
// this clientinfo is identical, so use it's handles
return i;
}
@@ -513,22 +546,24 @@ static int CG_GetCorpseNum( int pclass ) {
CG_ScanForExistingClientInfo
======================
*/
-static qboolean CG_ScanForExistingClientInfo( clientInfo_t *ci ) {
+static qboolean CG_ScanForExistingClientInfo( clientInfo_t *ci )
+{
int i;
clientInfo_t *match;
- for ( i = 0 ; i < cgs.maxclients ; i++ ) {
+ for( i = 0 ; i < cgs.maxclients ; i++ )
+ {
match = &cgs.clientinfo[ i ];
- if ( !match->infoValid ) {
+ if( !match->infoValid )
continue;
- }
- if ( match->deferred ) {
+
+ if( match->deferred )
continue;
- }
- if ( !Q_stricmp( ci->modelName, match->modelName )
- && !Q_stricmp( ci->skinName, match->skinName ) ) {
- // this clientinfo is identical, so use it's handles
+ if( !Q_stricmp( ci->modelName, match->modelName ) &&
+ !Q_stricmp( ci->skinName, match->skinName ) )
+ {
+ // this clientinfo is identical, so use it's handles
ci->deferred = qfalse;
CG_CopyClientInfoModel( match, ci );
@@ -549,16 +584,17 @@ We aren't going to load it now, so grab some other
client's info to use until we have some spare time.
======================
*/
-static void CG_SetDeferredClientInfo( clientInfo_t *ci ) {
- int i;
+static void CG_SetDeferredClientInfo( clientInfo_t *ci )
+{
+ int i;
clientInfo_t *match;
// find the first valid clientinfo and grab its stuff
- for ( i = 0 ; i < cgs.maxclients ; i++ ) {
+ for( i = 0; i < cgs.maxclients; i++ )
+ {
match = &cgs.clientinfo[ i ];
- if ( !match->infoValid ) {
+ if( !match->infoValid )
continue;
- }
ci->deferred = qtrue;
CG_CopyClientInfoModel( match, ci );
@@ -577,28 +613,28 @@ static void CG_SetDeferredClientInfo( clientInfo_t *ci ) {
CG_PrecacheClientInfo
======================
*/
-void CG_PrecacheClientInfo( int clientNum ) {
- clientInfo_t *ci;
- clientInfo_t newInfo;
- const char *configstring;
- const char *v;
- char *slash;
+void CG_PrecacheClientInfo( int clientNum )
+{
+ clientInfo_t *ci;
+ clientInfo_t newInfo;
+ const char *configstring;
+ const char *v;
+ char *slash;
ci = &cgs.corpseinfo[ clientNum ];
//CG_Printf( "%d %d\n", clientNum, (clientNum - MAX_CLIENTS ) );
configstring = CG_ConfigString( clientNum + CS_PRECACHES );
- if ( !configstring[0] ) {
+ if( !configstring[ 0 ] )
return; // player just left
- }
// build into a temp buffer so the defer checks can use
// the old value
memset( &newInfo, 0, sizeof( newInfo ) );
// isolate the player's name
- v = Info_ValueForKey(configstring, "n");
+ v = Info_ValueForKey( configstring, "n" );
Q_strncpyz( newInfo.name, v, sizeof( newInfo.name ) );
// colors
@@ -630,27 +666,30 @@ void CG_PrecacheClientInfo( int clientNum ) {
// team task
v = Info_ValueForKey( configstring, "tt" );
- newInfo.teamTask = atoi(v);
+ newInfo.teamTask = atoi( v );
// team leader
v = Info_ValueForKey( configstring, "tl" );
- newInfo.teamLeader = atoi(v);
+ newInfo.teamLeader = atoi( v );
v = Info_ValueForKey( configstring, "g_redteam" );
- Q_strncpyz(newInfo.redTeam, v, MAX_TEAMNAME);
+ Q_strncpyz( newInfo.redTeam, v, MAX_TEAMNAME );
v = Info_ValueForKey( configstring, "g_blueteam" );
- Q_strncpyz(newInfo.blueTeam, v, MAX_TEAMNAME);
+ Q_strncpyz( newInfo.blueTeam, v, MAX_TEAMNAME );
// model
v = Info_ValueForKey( configstring, "model" );
Q_strncpyz( newInfo.modelName, v, sizeof( newInfo.modelName ) );
slash = strchr( newInfo.modelName, '/' );
- if ( !slash ) {
+ if( !slash )
+ {
// modelName didn not include a skin name
Q_strncpyz( newInfo.skinName, "default", sizeof( newInfo.skinName ) );
- } else {
+ }
+ else
+ {
Q_strncpyz( newInfo.skinName, slash + 1, sizeof( newInfo.skinName ) );
// truncate modelName
*slash = 0;
@@ -663,10 +702,14 @@ void CG_PrecacheClientInfo( int clientNum ) {
Q_strncpyz( newInfo.headModelName, v, sizeof( newInfo.headModelName ) );
slash = strchr( newInfo.headModelName, '/' );
- if ( !slash ) {
+
+ if( !slash )
+ {
// modelName didn not include a skin name
Q_strncpyz( newInfo.headSkinName, "default", sizeof( newInfo.headSkinName ) );
- } else {
+ }
+ else
+ {
Q_strncpyz( newInfo.headSkinName, slash + 1, sizeof( newInfo.headSkinName ) );
// truncate modelName
*slash = 0;
@@ -684,17 +727,19 @@ void CG_PrecacheClientInfo( int clientNum ) {
CG_NewClientInfo
======================
*/
-void CG_NewClientInfo( int clientNum ) {
- clientInfo_t *ci;
- clientInfo_t newInfo;
- const char *configstring;
- const char *v;
- char *slash;
+void CG_NewClientInfo( int clientNum )
+{
+ clientInfo_t *ci;
+ clientInfo_t newInfo;
+ const char *configstring;
+ const char *v;
+ char *slash;
- ci = &cgs.clientinfo[clientNum];
+ ci = &cgs.clientinfo[ clientNum ];
configstring = CG_ConfigString( clientNum + CS_PLAYERS );
- if ( !configstring[0] ) {
+ if( !configstring[0] )
+ {
memset( ci, 0, sizeof( *ci ) );
return; // player just left
}
@@ -704,7 +749,7 @@ void CG_NewClientInfo( int clientNum ) {
memset( &newInfo, 0, sizeof( newInfo ) );
// isolate the player's name
- v = Info_ValueForKey(configstring, "n");
+ v = Info_ValueForKey( configstring, "n" );
Q_strncpyz( newInfo.name, v, sizeof( newInfo.name ) );
// colors
@@ -736,27 +781,31 @@ void CG_NewClientInfo( int clientNum ) {
// team task
v = Info_ValueForKey( configstring, "tt" );
- newInfo.teamTask = atoi(v);
+ newInfo.teamTask = atoi( v );
// team leader
v = Info_ValueForKey( configstring, "tl" );
- newInfo.teamLeader = atoi(v);
+ newInfo.teamLeader = atoi( v );
v = Info_ValueForKey( configstring, "g_redteam" );
- Q_strncpyz(newInfo.redTeam, v, MAX_TEAMNAME);
+ Q_strncpyz( newInfo.redTeam, v, MAX_TEAMNAME );
v = Info_ValueForKey( configstring, "g_blueteam" );
- Q_strncpyz(newInfo.blueTeam, v, MAX_TEAMNAME);
+ Q_strncpyz( newInfo.blueTeam, v, MAX_TEAMNAME );
// model
v = Info_ValueForKey( configstring, "model" );
Q_strncpyz( newInfo.modelName, v, sizeof( newInfo.modelName ) );
slash = strchr( newInfo.modelName, '/' );
- if ( !slash ) {
+
+ if( !slash )
+ {
// modelName didn not include a skin name
Q_strncpyz( newInfo.skinName, "default", sizeof( newInfo.skinName ) );
- } else {
+ }
+ else
+ {
Q_strncpyz( newInfo.skinName, slash + 1, sizeof( newInfo.skinName ) );
// truncate modelName
*slash = 0;
@@ -769,10 +818,14 @@ void CG_NewClientInfo( int clientNum ) {
Q_strncpyz( newInfo.headModelName, v, sizeof( newInfo.headModelName ) );
slash = strchr( newInfo.headModelName, '/' );
- if ( !slash ) {
+
+ if( !slash )
+ {
// modelName didn not include a skin name
Q_strncpyz( newInfo.headSkinName, "default", sizeof( newInfo.headSkinName ) );
- } else {
+ }
+ else
+ {
Q_strncpyz( newInfo.headSkinName, slash + 1, sizeof( newInfo.headSkinName ) );
// truncate modelName
*slash = 0;
@@ -780,18 +833,18 @@ void CG_NewClientInfo( int clientNum ) {
// scan for an existing clientinfo that matches this modelname
// so we can avoid loading checks if possible
- if ( !CG_ScanForExistingClientInfo( &newInfo ) ) {
+ if( !CG_ScanForExistingClientInfo( &newInfo ) )
+ {
qboolean forceDefer;
- forceDefer = trap_MemoryRemaining() < 4000000;
+ forceDefer = trap_MemoryRemaining( ) < 4000000;
// if we are defering loads, just have it pick the first valid
//TA: we should only defer models when ABSOLUTELY TOTALLY necessary since models are precached
- if ( forceDefer ) //|| ( cg_deferPlayers.integer && !cg_buildScript.integer && !cg.loading ) )
+ if( forceDefer )
{
// keep whatever they had if it won't violate team skins
- if ( ci->infoValid &&
- ( !Q_stricmp( newInfo.skinName, ci->skinName ) ) )
+ if ( ci->infoValid && ( !Q_stricmp( newInfo.skinName, ci->skinName ) ) )
{
CG_CopyClientInfoModel( ci, &newInfo );
newInfo.deferred = qtrue;
@@ -803,16 +856,14 @@ void CG_NewClientInfo( int clientNum ) {
}
// if we are low on memory, leave them with this model
- if ( forceDefer )
+ if( forceDefer )
{
CG_Printf( "Memory is low. Using deferred model.\n" );
newInfo.deferred = qfalse;
}
}
else
- {
CG_LoadClientInfo( &newInfo );
- }
}
// replace whatever was there with the new one
@@ -831,21 +882,25 @@ and the scoreboard is up
so deferred players can be loaded
======================
*/
-void CG_LoadDeferredPlayers( void ) {
- int i;
+void CG_LoadDeferredPlayers( void )
+{
+ int i;
clientInfo_t *ci;
// scan for a deferred player to load
- for ( i = 0, ci = cgs.clientinfo ; i < cgs.maxclients ; i++, ci++ ) {
- if ( ci->infoValid && ci->deferred ) {
+ for( i = 0, ci = cgs.clientinfo; i < cgs.maxclients; i++, ci++ )
+ {
+ if( ci->infoValid && ci->deferred )
+ {
// if we are low on memory, leave it deferred
- if ( trap_MemoryRemaining() < 4000000 ) {
+ if( trap_MemoryRemaining( ) < 4000000 )
+ {
CG_Printf( "Memory is low. Using deferred model.\n" );
ci->deferred = qfalse;
continue;
}
+
CG_LoadClientInfo( ci );
-// break;
}
}
}
@@ -866,24 +921,23 @@ CG_SetLerpFrameAnimation
may include ANIM_TOGGLEBIT
===============
*/
-static void CG_SetLerpFrameAnimation( clientInfo_t *ci, lerpFrame_t *lf, int newAnimation ) {
+static void CG_SetLerpFrameAnimation( clientInfo_t *ci, lerpFrame_t *lf, int newAnimation )
+{
animation_t *anim;
lf->animationNumber = newAnimation;
newAnimation &= ~ANIM_TOGGLEBIT;
- if ( newAnimation < 0 || newAnimation >= MAX_PLAYER_TOTALANIMATIONS ) {
+ if( newAnimation < 0 || newAnimation >= MAX_PLAYER_TOTALANIMATIONS )
CG_Error( "Bad animation number: %i", newAnimation );
- }
anim = &ci->animations[ newAnimation ];
lf->animation = anim;
lf->animationTime = lf->frameTime + anim->initialLerp;
- if ( cg_debugAnim.integer ) {
+ if( cg_debugAnim.integer )
CG_Printf( "Anim: %i\n", newAnimation );
- }
}
/*
@@ -894,85 +948,92 @@ Sets cg.snap, cg.oldFrame, and cg.backlerp
cg.time should be between oldFrameTime and frameTime after exit
===============
*/
-static void CG_RunLerpFrame( clientInfo_t *ci, lerpFrame_t *lf, int newAnimation, float speedScale ) {
- int f, numFrames;
+static void CG_RunLerpFrame( clientInfo_t *ci, lerpFrame_t *lf, int newAnimation, float speedScale )
+{
+ int f, numFrames;
animation_t *anim;
// debugging tool to get no animations
- if ( cg_animSpeed.integer == 0 ) {
+ if( cg_animSpeed.integer == 0 )
+ {
lf->oldFrame = lf->frame = lf->backlerp = 0;
return;
}
// see if the animation sequence is switching
- if ( newAnimation != lf->animationNumber || !lf->animation ) {
+ if( newAnimation != lf->animationNumber || !lf->animation )
+ {
CG_SetLerpFrameAnimation( ci, lf, newAnimation );
}
// if we have passed the current frame, move it to
// oldFrame and calculate a new frame
- if ( cg.time >= lf->frameTime ) {
+ if( cg.time >= lf->frameTime )
+ {
lf->oldFrame = lf->frame;
lf->oldFrameTime = lf->frameTime;
// get the next frame based on the animation
anim = lf->animation;
- if ( !anim->frameLerp ) {
+ if( !anim->frameLerp )
return; // shouldn't happen
- }
- if ( cg.time < lf->animationTime ) {
+
+ if( cg.time < lf->animationTime )
lf->frameTime = lf->animationTime; // initial lerp
- } else {
+ else
lf->frameTime = lf->oldFrameTime + anim->frameLerp;
- }
+
f = ( lf->frameTime - lf->animationTime ) / anim->frameLerp;
f *= speedScale; // adjust for haste, etc
numFrames = anim->numFrames;
- if (anim->flipflop) {
+
+ if( anim->flipflop )
numFrames *= 2;
- }
- if ( f >= numFrames ) {
+
+ if( f >= numFrames )
+ {
f -= numFrames;
- if ( anim->loopFrames ) {
+ if( anim->loopFrames )
+ {
f %= anim->loopFrames;
f += anim->numFrames - anim->loopFrames;
- } else {
+ }
+ else
+ {
f = numFrames - 1;
// the animation is stuck at the end, so it
// can immediately transition to another sequence
lf->frameTime = cg.time;
}
}
- if ( anim->reversed ) {
+
+ if( anim->reversed )
lf->frame = anim->firstFrame + anim->numFrames - 1 - f;
- }
- else if (anim->flipflop && f>=anim->numFrames) {
- lf->frame = anim->firstFrame + anim->numFrames - 1 - (f%anim->numFrames);
- }
- else {
+ else if( anim->flipflop && f>=anim->numFrames )
+ lf->frame = anim->firstFrame + anim->numFrames - 1 - ( f % anim->numFrames );
+ else
lf->frame = anim->firstFrame + f;
- }
- if ( cg.time > lf->frameTime ) {
+
+ if( cg.time > lf->frameTime )
+ {
lf->frameTime = cg.time;
- if ( cg_debugAnim.integer ) {
- CG_Printf( "Clamp lf->frameTime\n");
- }
+
+ if( cg_debugAnim.integer )
+ CG_Printf( "Clamp lf->frameTime\n" );
}
}
- if ( lf->frameTime > cg.time + 200 ) {
+ if( lf->frameTime > cg.time + 200 )
lf->frameTime = cg.time;
- }
- if ( lf->oldFrameTime > cg.time ) {
+ if( lf->oldFrameTime > cg.time )
lf->oldFrameTime = cg.time;
- }
+
// calculate current lerp value
- if ( lf->frameTime == lf->oldFrameTime ) {
+ if( lf->frameTime == lf->oldFrameTime )
lf->backlerp = 0;
- } else {
+ else
lf->backlerp = 1.0 - (float)( cg.time - lf->oldFrameTime ) / ( lf->frameTime - lf->oldFrameTime );
- }
}
@@ -981,7 +1042,8 @@ static void CG_RunLerpFrame( clientInfo_t *ci, lerpFrame_t *lf, int newAnimation
CG_ClearLerpFrame
===============
*/
-static void CG_ClearLerpFrame( clientInfo_t *ci, lerpFrame_t *lf, int animationNumber ) {
+static void CG_ClearLerpFrame( clientInfo_t *ci, lerpFrame_t *lf, int animationNumber )
+{
lf->frameTime = lf->oldFrameTime = cg.time;
CG_SetLerpFrameAnimation( ci, lf, animationNumber );
lf->oldFrame = lf->frame = lf->animation->firstFrame;
@@ -994,32 +1056,27 @@ CG_PlayerAnimation
===============
*/
static void CG_PlayerAnimation( centity_t *cent, int *legsOld, int *legs, float *legsBackLerp,
- int *torsoOld, int *torso, float *torsoBackLerp ) {
+ int *torsoOld, int *torso, float *torsoBackLerp )
+{
clientInfo_t *ci;
- int clientNum;
- float speedScale;
+ int clientNum;
+ float speedScale = 1.0f;
clientNum = cent->currentState.clientNum;
- if ( cg_noPlayerAnims.integer ) {
+ if( cg_noPlayerAnims.integer )
+ {
*legsOld = *legs = *torsoOld = *torso = 0;
return;
}
- /*if ( cent->currentState.powerups & ( 1 << PW_HASTE ) ) {
- speedScale = 1.5;
- } else*/ {
- speedScale = 1;
- }
-
ci = &cgs.clientinfo[ clientNum ];
// do the shuffle turn frames locally
- if ( cent->pe.legs.yawing && ( cent->currentState.legsAnim & ~ANIM_TOGGLEBIT ) == LEGS_IDLE ) {
+ if( cent->pe.legs.yawing && ( cent->currentState.legsAnim & ~ANIM_TOGGLEBIT ) == LEGS_IDLE )
CG_RunLerpFrame( ci, &cent->pe.legs, LEGS_TURN, speedScale );
- } else {
+ else
CG_RunLerpFrame( ci, &cent->pe.legs, cent->currentState.legsAnim, speedScale );
- }
*legsOld = cent->pe.legs.oldFrame;
*legs = cent->pe.legs.frame;
@@ -1046,46 +1103,54 @@ CG_SwingAngles
==================
*/
static void CG_SwingAngles( float destination, float swingTolerance, float clampTolerance,
- float speed, float *angle, qboolean *swinging ) {
+ float speed, float *angle, qboolean *swinging )
+{
float swing;
float move;
float scale;
- if ( !*swinging ) {
+ if( !*swinging )
+ {
// see if a swing should be started
swing = AngleSubtract( *angle, destination );
- if ( swing > swingTolerance || swing < -swingTolerance ) {
+
+ if( swing > swingTolerance || swing < -swingTolerance )
*swinging = qtrue;
- }
}
- if ( !*swinging ) {
+ if( !*swinging )
return;
- }
// modify the speed depending on the delta
// so it doesn't seem so linear
swing = AngleSubtract( destination, *angle );
scale = fabs( swing );
- if ( scale < swingTolerance * 0.5 ) {
+
+ if( scale < swingTolerance * 0.5 )
scale = 0.5;
- } else if ( scale < swingTolerance ) {
+ else if( scale < swingTolerance )
scale = 1.0;
- } else {
+ else
scale = 2.0;
- }
// swing towards the destination angle
- if ( swing >= 0 ) {
+ if( swing >= 0 )
+ {
move = cg.frametime * scale * speed;
- if ( move >= swing ) {
+
+ if( move >= swing )
+ {
move = swing;
*swinging = qfalse;
}
*angle = AngleMod( *angle + move );
- } else if ( swing < 0 ) {
+ }
+ else if( swing < 0 )
+ {
move = cg.frametime * scale * -speed;
- if ( move <= swing ) {
+
+ if( move <= swing )
+ {
move = swing;
*swinging = qfalse;
}
@@ -1094,11 +1159,10 @@ static void CG_SwingAngles( float destination, float swingTolerance, float clamp
// clamp to no more than tolerance
swing = AngleSubtract( destination, *angle );
- if ( swing > clampTolerance ) {
- *angle = AngleMod( destination - (clampTolerance - 1) );
- } else if ( swing < -clampTolerance ) {
- *angle = AngleMod( destination + (clampTolerance - 1) );
- }
+ if( swing > clampTolerance )
+ *angle = AngleMod( destination - ( clampTolerance - 1 ) );
+ else if( swing < -clampTolerance )
+ *angle = AngleMod( destination + ( clampTolerance - 1 ) );
}
/*
@@ -1106,22 +1170,22 @@ static void CG_SwingAngles( float destination, float swingTolerance, float clamp
CG_AddPainTwitch
=================
*/
-static void CG_AddPainTwitch( centity_t *cent, vec3_t torsoAngles ) {
+static void CG_AddPainTwitch( centity_t *cent, vec3_t torsoAngles )
+{
int t;
float f;
t = cg.time - cent->pe.painTime;
- if ( t >= PAIN_TWITCH_TIME ) {
+
+ if( t >= PAIN_TWITCH_TIME )
return;
- }
f = 1.0 - (float)t / PAIN_TWITCH_TIME;
- if ( cent->pe.painDirection ) {
- torsoAngles[ROLL] += 20 * f;
- } else {
- torsoAngles[ROLL] -= 20 * f;
- }
+ if( cent->pe.painDirection )
+ torsoAngles[ ROLL ] += 20 * f;
+ else
+ torsoAngles[ ROLL ] -= 20 * f;
}
@@ -1139,26 +1203,28 @@ Handles seperate torso motion
if < 45 degrees, also show in torso
===============
*/
-static void CG_PlayerAngles( centity_t *cent, vec3_t srcAngles, vec3_t legs[3], vec3_t torso[3], vec3_t head[3] )
+static void CG_PlayerAngles( centity_t *cent, vec3_t srcAngles,
+ vec3_t legs[ 3 ], vec3_t torso[ 3 ], vec3_t head[ 3 ] )
{
- vec3_t legsAngles, torsoAngles, headAngles;
- float dest;
- static int movementOffsets[8] = { 0, 22, 45, -22, 0, 22, -45, -22 };
- vec3_t velocity;
- float speed;
- int dir, clientNum;
+ vec3_t legsAngles, torsoAngles, headAngles;
+ float dest;
+ static int movementOffsets[ 8 ] = { 0, 22, 45, -22, 0, 22, -45, -22 };
+ vec3_t velocity;
+ float speed;
+ int dir, clientNum;
clientInfo_t *ci;
VectorCopy( srcAngles, headAngles );
- headAngles[YAW] = AngleMod( headAngles[YAW] );
+ headAngles[ YAW ] = AngleMod( headAngles[ YAW ] );
VectorClear( legsAngles );
VectorClear( torsoAngles );
// --------- yaw -------------
// allow yaw to drift a bit
- if ( ( cent->currentState.legsAnim & ~ANIM_TOGGLEBIT ) != LEGS_IDLE
- || ( cent->currentState.torsoAnim & ~ANIM_TOGGLEBIT ) != TORSO_STAND ) {
+ if( ( cent->currentState.legsAnim & ~ANIM_TOGGLEBIT ) != LEGS_IDLE ||
+ ( cent->currentState.torsoAnim & ~ANIM_TOGGLEBIT ) != TORSO_STAND )
+ {
// if not standing still, always point all in the same direction
cent->pe.torso.yawing = qtrue; // always center
cent->pe.torso.pitching = qtrue; // always center
@@ -1166,56 +1232,60 @@ static void CG_PlayerAngles( centity_t *cent, vec3_t srcAngles, vec3_t legs[3],
}
// adjust legs for movement dir
- if ( cent->currentState.eFlags & EF_DEAD ) {
+ if( cent->currentState.eFlags & EF_DEAD )
+ {
// don't let dead bodies twitch
dir = 0;
- } else {
+ }
+ else
+ {
//TA: did use angles2.. now uses time2.. looks a bit funny but time2 isn't used othwise
dir = cent->currentState.time2;
- if ( dir < 0 || dir > 7 ) {
+ if( dir < 0 || dir > 7 )
CG_Error( "Bad player movement angle" );
- }
}
- legsAngles[YAW] = headAngles[YAW] + movementOffsets[ dir ];
- torsoAngles[YAW] = headAngles[YAW] + 0.25 * movementOffsets[ dir ];
+
+ legsAngles[ YAW ] = headAngles[ YAW ] + movementOffsets[ dir ];
+ torsoAngles[ YAW ] = headAngles[ YAW ] + 0.25 * movementOffsets[ dir ];
// torso
if( cent->currentState.eFlags & EF_DEAD )
{
- CG_SwingAngles( torsoAngles[YAW], 0, 0, cg_swingSpeed.value,
+ CG_SwingAngles( torsoAngles[ YAW ], 0, 0, cg_swingSpeed.value,
&cent->pe.torso.yawAngle, &cent->pe.torso.yawing );
- CG_SwingAngles( legsAngles[YAW], 0, 0, cg_swingSpeed.value,
+ CG_SwingAngles( legsAngles[ YAW ], 0, 0, cg_swingSpeed.value,
&cent->pe.legs.yawAngle, &cent->pe.legs.yawing );
}
else
{
- CG_SwingAngles( torsoAngles[YAW], 25, 90, cg_swingSpeed.value,
+ CG_SwingAngles( torsoAngles[ YAW ], 25, 90, cg_swingSpeed.value,
&cent->pe.torso.yawAngle, &cent->pe.torso.yawing );
- CG_SwingAngles( legsAngles[YAW], 40, 90, cg_swingSpeed.value,
+ CG_SwingAngles( legsAngles[ YAW ], 40, 90, cg_swingSpeed.value,
&cent->pe.legs.yawAngle, &cent->pe.legs.yawing );
}
- torsoAngles[YAW] = cent->pe.torso.yawAngle;
- legsAngles[YAW] = cent->pe.legs.yawAngle;
+ torsoAngles[ YAW ] = cent->pe.torso.yawAngle;
+ legsAngles[ YAW ] = cent->pe.legs.yawAngle;
// --------- pitch -------------
// only show a fraction of the pitch angle in the torso
- if ( headAngles[PITCH] > 180 ) {
- dest = (-360 + headAngles[PITCH]) * 0.75f;
- } else {
- dest = headAngles[PITCH] * 0.75f;
- }
+ if( headAngles[ PITCH ] > 180 )
+ dest = ( -360 + headAngles[ PITCH ] ) * 0.75f;
+ else
+ dest = headAngles[ PITCH ] * 0.75f;
+
CG_SwingAngles( dest, 15, 30, 0.1f, &cent->pe.torso.pitchAngle, &cent->pe.torso.pitching );
- torsoAngles[PITCH] = cent->pe.torso.pitchAngle;
+ torsoAngles[ PITCH ] = cent->pe.torso.pitchAngle;
//
clientNum = cent->currentState.clientNum;
- if ( clientNum >= 0 && clientNum < MAX_CLIENTS ) {
+
+ if( clientNum >= 0 && clientNum < MAX_CLIENTS )
+ {
ci = &cgs.clientinfo[ clientNum ];
- if ( ci->fixedtorso ) {
- torsoAngles[PITCH] = 0.0f;
- }
+ if( ci->fixedtorso )
+ torsoAngles[ PITCH ] = 0.0f;
}
// --------- roll -------------
@@ -1224,28 +1294,34 @@ static void CG_PlayerAngles( centity_t *cent, vec3_t srcAngles, vec3_t legs[3],
// lean towards the direction of travel
VectorCopy( cent->currentState.pos.trDelta, velocity );
speed = VectorNormalize( velocity );
- if ( speed ) {
- vec3_t axis[3];
- float side;
+
+ if( speed )
+ {
+ vec3_t axis[ 3 ];
+ float side;
speed *= 0.05f;
AnglesToAxis( legsAngles, axis );
- side = speed * DotProduct( velocity, axis[1] );
- legsAngles[ROLL] -= side;
+ side = speed * DotProduct( velocity, axis[ 1 ] );
+ legsAngles[ ROLL ] -= side;
- side = speed * DotProduct( velocity, axis[0] );
- legsAngles[PITCH] += side;
+ side = speed * DotProduct( velocity, axis[ 0 ] );
+ legsAngles[ PITCH ] += side;
}
//
clientNum = cent->currentState.clientNum;
- if ( clientNum >= 0 && clientNum < MAX_CLIENTS ) {
+
+ if( clientNum >= 0 && clientNum < MAX_CLIENTS )
+ {
ci = &cgs.clientinfo[ clientNum ];
- if ( ci->fixedlegs ) {
- legsAngles[YAW] = torsoAngles[YAW];
- legsAngles[PITCH] = 0.0f;
- legsAngles[ROLL] = 0.0f;
+
+ if( ci->fixedlegs )
+ {
+ legsAngles[ YAW ] = torsoAngles[ YAW ];
+ legsAngles[ PITCH ] = 0.0f;
+ legsAngles[ ROLL ] = 0.0f;
}
}
@@ -1263,70 +1339,6 @@ static void CG_PlayerAngles( centity_t *cent, vec3_t srcAngles, vec3_t legs[3],
//==========================================================================
-/*
-===============
-CG_HasteTrail
-===============
-*/
-static void CG_HasteTrail( centity_t *cent ) {
- localEntity_t *smoke;
- vec3_t origin;
- int anim;
-
- if ( cent->trailTime > cg.time ) {
- return;
- }
- anim = cent->pe.legs.animationNumber & ~ANIM_TOGGLEBIT;
- if ( anim != LEGS_RUN && anim != LEGS_BACK ) {
- return;
- }
-
- cent->trailTime += 100;
- if ( cent->trailTime < cg.time ) {
- cent->trailTime = cg.time;
- }
-
- VectorCopy( cent->lerpOrigin, origin );
- origin[2] -= 16;
-
- smoke = CG_SmokePuff( origin, vec3_origin,
- 8,
- 1, 1, 1, 1,
- 500,
- cg.time,
- 0,
- 0,
- cgs.media.hastePuffShader );
-
- // use the optimized local entity add
- smoke->leType = LE_SCALE_FADE;
-}
-
-/*
-===============
-CG_TrailItem
-===============
-*/
-static void CG_TrailItem( centity_t *cent, qhandle_t hModel ) {
- refEntity_t ent;
- vec3_t angles;
- vec3_t axis[3];
-
- VectorCopy( cent->lerpAngles, angles );
- angles[PITCH] = 0;
- angles[ROLL] = 0;
- AnglesToAxis( angles, axis );
-
- memset( &ent, 0, sizeof( ent ) );
- VectorMA( cent->lerpOrigin, -16, axis[0], ent.origin );
- ent.origin[2] += 16;
- angles[YAW] += 90;
- AnglesToAxis( angles, ent.axis );
-
- ent.hModel = hModel;
- trap_R_AddRefEntityToScene( &ent );
-}
-
#define JET_SPREAD 30.0f
#define JET_LIFETIME 1500
@@ -1404,37 +1416,6 @@ static void CG_PlayerUpgrades( centity_t *cent, refEntity_t *torso )
}
}
}
- /*powerups = cent->currentState.powerups;
- if ( !powerups ) {
- return;
- }
-
- // quad gives a dlight
- if ( powerups & ( 1 << PW_QUAD ) ) {
- trap_R_AddLightToScene( cent->lerpOrigin, 200 + (rand()&31), 0.2, 0.2, 1 );
- }
-
- // flight plays a looped sound
- if ( powerups & ( 1 << PW_FLIGHT ) ) {
- trap_S_AddLoopingSound( cent->currentState.number, cent->lerpOrigin, vec3_origin, cgs.media.flightSound );
- }
-
- // redflag
- if ( powerups & ( 1 << PW_REDFLAG ) ) {
- CG_TrailItem( cent, cgs.media.redFlagModel );
- trap_R_AddLightToScene( cent->lerpOrigin, 200 + (rand()&31), 1, 0.2, 0.2 );
- }
-
- // blueflag
- if ( powerups & ( 1 << PW_BLUEFLAG ) ) {
- CG_TrailItem( cent, cgs.media.blueFlagModel );
- trap_R_AddLightToScene( cent->lerpOrigin, 200 + (rand()&31), 0.2, 0.2, 1 );
- }
-
- // haste leaves smoke trails
- if ( powerups & ( 1 << PW_HASTE ) ) {
- CG_HasteTrail( cent );
- }*/
}
@@ -1445,27 +1426,27 @@ CG_PlayerFloatSprite
Float a sprite over the player's head
===============
*/
-static void CG_PlayerFloatSprite( centity_t *cent, qhandle_t shader ) {
- int rf;
+static void CG_PlayerFloatSprite( centity_t *cent, qhandle_t shader )
+{
+ int rf;
refEntity_t ent;
- if ( cent->currentState.number == cg.snap->ps.clientNum && !cg.renderingThirdPerson ) {
+ if( cent->currentState.number == cg.snap->ps.clientNum && !cg.renderingThirdPerson )
rf = RF_THIRD_PERSON; // only show in mirrors
- } else {
+ else
rf = 0;
- }
memset( &ent, 0, sizeof( ent ) );
VectorCopy( cent->lerpOrigin, ent.origin );
- ent.origin[2] += 48;
+ ent.origin[ 2 ] += 48;
ent.reType = RT_SPRITE;
ent.customShader = shader;
ent.radius = 10;
ent.renderfx = rf;
- ent.shaderRGBA[0] = 255;
- ent.shaderRGBA[1] = 255;
- ent.shaderRGBA[2] = 255;
- ent.shaderRGBA[3] = 255;
+ ent.shaderRGBA[ 0 ] = 255;
+ ent.shaderRGBA[ 1 ] = 255;
+ ent.shaderRGBA[ 2 ] = 255;
+ ent.shaderRGBA[ 3 ] = 255;
trap_R_AddRefEntityToScene( &ent );
}
@@ -1503,38 +1484,31 @@ Returns the Z component of the surface being shadowed
===============
*/
#define SHADOW_DISTANCE 128
-static qboolean CG_PlayerShadow( centity_t *cent, float *shadowPlane ) {
- vec3_t end, mins = {-15, -15, 0}, maxs = {15, 15, 2};
+static qboolean CG_PlayerShadow( centity_t *cent, float *shadowPlane )
+{
+ vec3_t end, mins = { -15, -15, 0 }, maxs = { 15, 15, 2 };
trace_t trace;
- float alpha;
+ float alpha;
*shadowPlane = 0;
- if ( cg_shadows.integer == 0 ) {
- return qfalse;
- }
-
- // no shadows when invisible
- /*if ( cent->currentState.powerups & ( 1 << PW_INVIS ) ) {
+ if( cg_shadows.integer == 0 )
return qfalse;
- }*/
// send a trace down from the player to the ground
VectorCopy( cent->lerpOrigin, end );
- end[2] -= SHADOW_DISTANCE;
+ end[ 2 ] -= SHADOW_DISTANCE;
trap_CM_BoxTrace( &trace, cent->lerpOrigin, end, mins, maxs, 0, MASK_PLAYERSOLID );
// no shadow if too high
- if ( trace.fraction == 1.0 || trace.startsolid || trace.allsolid ) {
+ if( trace.fraction == 1.0 || trace.startsolid || trace.allsolid )
return qfalse;
- }
- *shadowPlane = trace.endpos[2] + 1;
+ *shadowPlane = trace.endpos[ 2 ] + 1;
- if ( cg_shadows.integer != 1 ) { // no mark for stencil or projection shadows
+ if( cg_shadows.integer != 1 ) // no mark for stencil or projection shadows
return qtrue;
- }
// fade the shadow out with height
alpha = 1.0 - trace.fraction;
@@ -1542,7 +1516,7 @@ static qboolean CG_PlayerShadow( centity_t *cent, float *shadowPlane ) {
// add the mark as a temporary, so it goes directly to the renderer
// without taking a spot in the cg_marks array
CG_ImpactMark( cgs.media.shadowMarkShader, trace.endpos, trace.plane.normal,
- cent->pe.legs.yawAngle, alpha,alpha,alpha,1, qfalse, 24, qtrue );
+ cent->pe.legs.yawAngle, alpha,alpha,alpha,1, qfalse, 24, qtrue );
return qtrue;
}
@@ -1555,82 +1529,81 @@ CG_PlayerSplash
Draw a mark at the water surface
===============
*/
-static void CG_PlayerSplash( centity_t *cent ) {
- vec3_t start, end;
- trace_t trace;
- int contents;
- polyVert_t verts[4];
+static void CG_PlayerSplash( centity_t *cent )
+{
+ vec3_t start, end;
+ trace_t trace;
+ int contents;
+ polyVert_t verts[ 4 ];
- if ( !cg_shadows.integer ) {
+ if( !cg_shadows.integer )
return;
- }
VectorCopy( cent->lerpOrigin, end );
- end[2] -= 24;
+ end[ 2 ] -= 24;
// if the feet aren't in liquid, don't make a mark
// this won't handle moving water brushes, but they wouldn't draw right anyway...
contents = trap_CM_PointContents( end, 0 );
- if ( !( contents & ( CONTENTS_WATER | CONTENTS_SLIME | CONTENTS_LAVA ) ) ) {
+
+ if( !( contents & ( CONTENTS_WATER | CONTENTS_SLIME | CONTENTS_LAVA ) ) )
return;
- }
VectorCopy( cent->lerpOrigin, start );
- start[2] += 32;
+ start[ 2 ] += 32;
// if the head isn't out of liquid, don't make a mark
contents = trap_CM_PointContents( start, 0 );
- if ( contents & ( CONTENTS_SOLID | CONTENTS_WATER | CONTENTS_SLIME | CONTENTS_LAVA ) ) {
+
+ if( contents & ( CONTENTS_SOLID | CONTENTS_WATER | CONTENTS_SLIME | CONTENTS_LAVA ) )
return;
- }
// trace down to find the surface
trap_CM_BoxTrace( &trace, start, end, NULL, NULL, 0, ( CONTENTS_WATER | CONTENTS_SLIME | CONTENTS_LAVA ) );
- if ( trace.fraction == 1.0 ) {
+ if( trace.fraction == 1.0 )
return;
- }
// create a mark polygon
- VectorCopy( trace.endpos, verts[0].xyz );
- verts[0].xyz[0] -= 32;
- verts[0].xyz[1] -= 32;
- verts[0].st[0] = 0;
- verts[0].st[1] = 0;
- verts[0].modulate[0] = 255;
- verts[0].modulate[1] = 255;
- verts[0].modulate[2] = 255;
- verts[0].modulate[3] = 255;
-
- VectorCopy( trace.endpos, verts[1].xyz );
- verts[1].xyz[0] -= 32;
- verts[1].xyz[1] += 32;
- verts[1].st[0] = 0;
- verts[1].st[1] = 1;
- verts[1].modulate[0] = 255;
- verts[1].modulate[1] = 255;
- verts[1].modulate[2] = 255;
- verts[1].modulate[3] = 255;
-
- VectorCopy( trace.endpos, verts[2].xyz );
- verts[2].xyz[0] += 32;
- verts[2].xyz[1] += 32;
- verts[2].st[0] = 1;
- verts[2].st[1] = 1;
- verts[2].modulate[0] = 255;
- verts[2].modulate[1] = 255;
- verts[2].modulate[2] = 255;
- verts[2].modulate[3] = 255;
-
- VectorCopy( trace.endpos, verts[3].xyz );
- verts[3].xyz[0] += 32;
- verts[3].xyz[1] -= 32;
- verts[3].st[0] = 1;
- verts[3].st[1] = 0;
- verts[3].modulate[0] = 255;
- verts[3].modulate[1] = 255;
- verts[3].modulate[2] = 255;
- verts[3].modulate[3] = 255;
+ VectorCopy( trace.endpos, verts[ 0 ].xyz );
+ verts[ 0 ].xyz[ 0 ] -= 32;
+ verts[ 0 ].xyz[ 1 ] -= 32;
+ verts[ 0 ].st[ 0 ] = 0;
+ verts[ 0 ].st[ 1 ] = 0;
+ verts[ 0 ].modulate[ 0 ] = 255;
+ verts[ 0 ].modulate[ 1 ] = 255;
+ verts[ 0 ].modulate[ 2 ] = 255;
+ verts[ 0 ].modulate[ 3 ] = 255;
+
+ VectorCopy( trace.endpos, verts[ 1 ].xyz );
+ verts[ 1 ].xyz[ 0 ] -= 32;
+ verts[ 1 ].xyz[ 1 ] += 32;
+ verts[ 1 ].st[ 0 ] = 0;
+ verts[ 1 ].st[ 1 ] = 1;
+ verts[ 1 ].modulate[ 0 ] = 255;
+ verts[ 1 ].modulate[ 1 ] = 255;
+ verts[ 1 ].modulate[ 2 ] = 255;
+ verts[ 1 ].modulate[ 3 ] = 255;
+
+ VectorCopy( trace.endpos, verts[ 2 ].xyz );
+ verts[ 2 ].xyz[ 0 ] += 32;
+ verts[ 2 ].xyz[ 1 ] += 32;
+ verts[ 2 ].st[ 0 ] = 1;
+ verts[ 2 ].st[ 1 ] = 1;
+ verts[ 2 ].modulate[ 0 ] = 255;
+ verts[ 2 ].modulate[ 1 ] = 255;
+ verts[ 2 ].modulate[ 2 ] = 255;
+ verts[ 2 ].modulate[ 3 ] = 255;
+
+ VectorCopy( trace.endpos, verts[ 3 ].xyz );
+ verts[ 3 ].xyz[ 0 ] += 32;
+ verts[ 3 ].xyz[ 1 ] -= 32;
+ verts[ 3 ].st[ 0 ] = 1;
+ verts[ 3 ].st[ 1 ] = 0;
+ verts[ 3 ].modulate[ 0 ] = 255;
+ verts[ 3 ].modulate[ 1 ] = 255;
+ verts[ 3 ].modulate[ 2 ] = 255;
+ verts[ 3 ].modulate[ 3 ] = 255;
trap_R_AddPolyToScene( cgs.media.wakeMarkShader, 4, verts );
}
@@ -1645,33 +1618,9 @@ Adds a piece with modifications or duplications for powerups
Also called by CG_Missile for quad rockets, but nobody can tell...
===============
*/
-void CG_AddRefEntityWithPowerups( refEntity_t *ent, int powerups, int team ) {
-
- /*if ( powerups & ( 1 << PW_INVIS ) ) {
- ent->customShader = cgs.media.invisShader;
- trap_R_AddRefEntityToScene( ent );
- } else {*/
- trap_R_AddRefEntityToScene( ent );
-
- /*if ( powerups & ( 1 << PW_QUAD ) )
- {
- if (team == TEAM_HUMANS)
- ent->customShader = cgs.media.redQuadShader;
- else
- ent->customShader = cgs.media.quadShader;
- trap_R_AddRefEntityToScene( ent );
- }
- if ( powerups & ( 1 << PW_REGEN ) ) {
- if ( ( ( cg.time / 100 ) % 10 ) == 1 ) {
- ent->customShader = cgs.media.regenShader;
- trap_R_AddRefEntityToScene( ent );
- }
- }
- if ( powerups & ( 1 << PW_BATTLESUIT ) ) {
- ent->customShader = cgs.media.battleSuitShader;
- trap_R_AddRefEntityToScene( ent );
- }
- }*/
+void CG_AddRefEntityWithPowerups( refEntity_t *ent, int powerups, int team )
+{
+ trap_R_AddRefEntityToScene( ent );
}
@@ -1688,36 +1637,43 @@ int CG_LightVerts( vec3_t normal, int numVerts, polyVert_t *verts )
vec3_t lightDir;
vec3_t directedLight;
- trap_R_LightForPoint( verts[0].xyz, ambientLight, directedLight, lightDir );
+ trap_R_LightForPoint( verts[ 0 ].xyz, ambientLight, directedLight, lightDir );
- for (i = 0; i < numVerts; i++) {
- incoming = DotProduct (normal, lightDir);
- if ( incoming <= 0 ) {
- verts[i].modulate[0] = ambientLight[0];
- verts[i].modulate[1] = ambientLight[1];
- verts[i].modulate[2] = ambientLight[2];
- verts[i].modulate[3] = 255;
+ for( i = 0; i < numVerts; i++ )
+ {
+ incoming = DotProduct( normal, lightDir );
+
+ if( incoming <= 0 )
+ {
+ verts[ i ].modulate[ 0 ] = ambientLight[ 0 ];
+ verts[ i ].modulate[ 1 ] = ambientLight[ 1 ];
+ verts[ i ].modulate[ 2 ] = ambientLight[ 2 ];
+ verts[ i ].modulate[ 3 ] = 255;
continue;
}
- j = ( ambientLight[0] + incoming * directedLight[0] );
- if ( j > 255 ) {
+
+ j = ( ambientLight[ 0 ] + incoming * directedLight[ 0 ] );
+
+ if( j > 255 )
j = 255;
- }
- verts[i].modulate[0] = j;
+
+ verts[ i ].modulate[ 0 ] = j;
- j = ( ambientLight[1] + incoming * directedLight[1] );
- if ( j > 255 ) {
+ j = ( ambientLight[ 1 ] + incoming * directedLight[ 1 ] );
+
+ if( j > 255 )
j = 255;
- }
- verts[i].modulate[1] = j;
- j = ( ambientLight[2] + incoming * directedLight[2] );
- if ( j > 255 ) {
+ verts[ i ].modulate[ 1 ] = j;
+
+ j = ( ambientLight[ 2 ] + incoming * directedLight[ 2 ] );
+
+ if( j > 255 )
j = 255;
- }
- verts[i].modulate[2] = j;
- verts[i].modulate[3] = 255;
+ verts[ i ].modulate[ 2 ] = j;
+
+ verts[ i ].modulate[ 3 ] = 255;
}
return qtrue;
}
@@ -1739,33 +1695,38 @@ int CG_LightFromDirection( vec3_t point, vec3_t direction )
trap_R_LightForPoint( point, ambientLight, directedLight, lightDir );
- incoming = DotProduct (direction, lightDir);
- if ( incoming <= 0 ) {
- result[0] = ambientLight[0];
- result[1] = ambientLight[1];
- result[2] = ambientLight[2];
- return (int)((float)( result[0] + result[1] + result[2] ) / 3.0f );
+ incoming = DotProduct( direction, lightDir );
+
+ if( incoming <= 0 )
+ {
+ result[ 0 ] = ambientLight[ 0 ];
+ result[ 1 ] = ambientLight[ 1 ];
+ result[ 2 ] = ambientLight[ 2 ];
+ return (int)( (float)( result[ 0 ] + result[ 1 ] + result[ 2 ] ) / 3.0f );
}
- j = ( ambientLight[0] + incoming * directedLight[0] );
- if ( j > 255 ) {
+ j = ( ambientLight[ 0 ] + incoming * directedLight[ 0 ] );
+
+ if( j > 255 )
j = 255;
- }
- result[0] = j;
- j = ( ambientLight[1] + incoming * directedLight[1] );
- if ( j > 255 ) {
+ result[ 0 ] = j;
+
+ j = ( ambientLight[ 1 ] + incoming * directedLight[ 1 ] );
+
+ if( j > 255 )
j = 255;
- }
- result[1] = j;
- j = ( ambientLight[2] + incoming * directedLight[2] );
- if ( j > 255 ) {
+ result[ 1 ] = j;
+
+ j = ( ambientLight[ 2 ] + incoming * directedLight[ 2 ] );
+
+ if( j > 255 )
j = 255;
- }
- result[2] = j;
- return (int)((float)( result[0] + result[1] + result[2] ) / 3.0f );
+ result[ 2 ] = j;
+
+ return (int)((float)( result[ 0 ] + result[ 1 ] + result[ 2 ] ) / 3.0f );
}
@@ -1783,10 +1744,10 @@ int CG_AmbientLight( vec3_t point )
trap_R_LightForPoint( point, ambientLight, directedLight, lightDir );
- result[0] = ambientLight[0];
- result[1] = ambientLight[1];
- result[2] = ambientLight[2];
- return (int)((float)( result[0] + result[1] + result[2] ) / 3.0f );
+ result[ 0 ] = ambientLight[ 0 ];
+ result[ 1 ] = ambientLight[ 1 ];
+ result[ 2 ] = ambientLight[ 2 ];
+ return (int)((float)( result[ 0 ] + result[ 1 ] + result[ 2 ] ) / 3.0f );
}
#define TRACE_DEPTH 128.0f
@@ -1864,7 +1825,7 @@ void CG_Player( centity_t *cent )
// get the animation state (after rotation, to allow feet shuffle)
CG_PlayerAnimation( cent, &legs.oldframe, &legs.frame, &legs.backlerp,
- &torso.oldframe, &torso.frame, &torso.backlerp );
+ &torso.oldframe, &torso.frame, &torso.backlerp );
// add the talk baloon or disconnect icon
CG_PlayerSprites( cent );
@@ -1990,14 +1951,15 @@ void CG_Corpse( centity_t *cent )
refEntity_t legs;
refEntity_t torso;
refEntity_t head;
- int corpseNum;
- int renderfx;
- qboolean shadow;
- float shadowPlane;
- vec3_t origin, liveZ, deadZ;
+ int corpseNum;
+ int renderfx;
+ qboolean shadow;
+ float shadowPlane;
+ vec3_t origin, liveZ, deadZ;
corpseNum = CG_GetCorpseNum( cent->currentState.clientNum );
- if ( corpseNum < 0 || corpseNum >= MAX_CLIENTS )
+
+ if( corpseNum < 0 || corpseNum >= MAX_CLIENTS )
CG_Error( "Bad corpseNum on corpse entity: %d", corpseNum );
ci = &cgs.corpseinfo[ corpseNum ];
@@ -2007,9 +1969,9 @@ void CG_Corpse( centity_t *cent )
if( !ci->infoValid )
return;
- memset( &legs, 0, sizeof(legs) );
- memset( &torso, 0, sizeof(torso) );
- memset( &head, 0, sizeof(head) );
+ memset( &legs, 0, sizeof( legs ) );
+ memset( &torso, 0, sizeof( torso ) );
+ memset( &head, 0, sizeof( head ) );
VectorCopy( cent->lerpOrigin, origin );
BG_FindBBoxForClass( cent->currentState.clientNum, liveZ, NULL, NULL, deadZ, NULL );
@@ -2020,7 +1982,7 @@ void CG_Corpse( centity_t *cent )
CG_PlayerAngles( cent, cent->lerpAngles, legs.axis, torso.axis, head.axis );
//set the correct frame (should always be dead)
- if ( cg_noPlayerAnims.integer )
+ if( cg_noPlayerAnims.integer )
legs.oldframe = legs.frame = torso.oldframe = torso.frame = 0;
else
{
@@ -2041,6 +2003,7 @@ void CG_Corpse( centity_t *cent )
// get the player model information
renderfx = 0;
+
if( cg_shadows.integer == 3 && shadow )
renderfx |= RF_SHADOW_PLANE;
@@ -2057,7 +2020,7 @@ void CG_Corpse( centity_t *cent )
VectorCopy( origin, legs.lightingOrigin );
legs.shadowPlane = shadowPlane;
legs.renderfx = renderfx;
- VectorCopy (legs.origin, legs.oldorigin); // don't positionally lerp at all
+ VectorCopy( legs.origin, legs.oldorigin ); // don't positionally lerp at all
//CG_AddRefEntityWithPowerups( &legs, cent->currentState.powerups, ci->team );
trap_R_AddRefEntityToScene( &legs );
@@ -2077,7 +2040,7 @@ void CG_Corpse( centity_t *cent )
VectorCopy( origin, torso.lightingOrigin );
- CG_PositionRotatedEntityOnTag( &torso, &legs, ci->legsModel, "tag_torso");
+ CG_PositionRotatedEntityOnTag( &torso, &legs, ci->legsModel, "tag_torso" );
torso.shadowPlane = shadowPlane;
torso.renderfx = renderfx;
@@ -2110,7 +2073,7 @@ void CG_Corpse( centity_t *cent )
cent->currentState.powerups == 65535 ) //65535 = 16bit signed -1
{
//draw indicator
- CG_PlayerFloatSprite( cent, cgs.media.medalImpressive );
+ CG_PlayerFloatSprite( cent, cgs.media.friendShader );
}
}
}
@@ -2125,12 +2088,15 @@ CG_ResetPlayerEntity
A player just came into view or teleported, so reset all animation info
===============
*/
-void CG_ResetPlayerEntity( centity_t *cent ) {
+void CG_ResetPlayerEntity( centity_t *cent )
+{
cent->errorTime = -99999; // guarantee no error decay added
cent->extrapolated = qfalse;
- CG_ClearLerpFrame( &cgs.clientinfo[ cent->currentState.clientNum ], &cent->pe.legs, cent->currentState.legsAnim );
- CG_ClearLerpFrame( &cgs.clientinfo[ cent->currentState.clientNum ], &cent->pe.torso, cent->currentState.torsoAnim );
+ CG_ClearLerpFrame( &cgs.clientinfo[ cent->currentState.clientNum ],
+ &cent->pe.legs, cent->currentState.legsAnim );
+ CG_ClearLerpFrame( &cgs.clientinfo[ cent->currentState.clientNum ],
+ &cent->pe.torso, cent->currentState.torsoAnim );
BG_EvaluateTrajectory( &cent->currentState.pos, cg.time, cent->lerpOrigin );
BG_EvaluateTrajectory( &cent->currentState.apos, cg.time, cent->lerpAngles );
@@ -2139,19 +2105,18 @@ void CG_ResetPlayerEntity( centity_t *cent ) {
VectorCopy( cent->lerpAngles, cent->rawAngles );
memset( &cent->pe.legs, 0, sizeof( cent->pe.legs ) );
- cent->pe.legs.yawAngle = cent->rawAngles[YAW];
+ cent->pe.legs.yawAngle = cent->rawAngles[ YAW ];
cent->pe.legs.yawing = qfalse;
cent->pe.legs.pitchAngle = 0;
cent->pe.legs.pitching = qfalse;
memset( &cent->pe.torso, 0, sizeof( cent->pe.legs ) );
- cent->pe.torso.yawAngle = cent->rawAngles[YAW];
+ cent->pe.torso.yawAngle = cent->rawAngles[ YAW ];
cent->pe.torso.yawing = qfalse;
- cent->pe.torso.pitchAngle = cent->rawAngles[PITCH];
+ cent->pe.torso.pitchAngle = cent->rawAngles[ PITCH ];
cent->pe.torso.pitching = qfalse;
- if ( cg_debugPosition.integer ) {
- CG_Printf("%i ResetPlayerEntity yaw=%i\n", cent->currentState.number, cent->pe.torso.yawAngle );
- }
+ if( cg_debugPosition.integer )
+ CG_Printf( "%i ResetPlayerEntity yaw=%i\n", cent->currentState.number, cent->pe.torso.yawAngle );
}
diff --git a/src/cgame/cg_playerstate.c b/src/cgame/cg_playerstate.c
index 4a307481..1e39ad70 100644
--- a/src/cgame/cg_playerstate.c
+++ b/src/cgame/cg_playerstate.c
@@ -22,156 +22,103 @@
/*
==============
-CG_CheckAmmo
-
-If the ammo has gone low enough to generate the warning, play a sound
+CG_DamageFeedback
==============
*/
-void CG_CheckAmmo( void ) {
- int i;
- int total;
- int previous;
- int ammo, clips, maxclips;
-
- // see about how many seconds of ammo we have remaining
- total = 0;
- for ( i = WP_MACHINEGUN ; i < WP_NUM_WEAPONS ; i++ ) {
- if ( !BG_gotWeapon( i, cg.snap->ps.stats ) ) {
- continue;
- }
-
- BG_unpackAmmoArray( i, cg.snap->ps.ammo, cg.snap->ps.powerups, &ammo, &clips, &maxclips );
+void CG_DamageFeedback( int yawByte, int pitchByte, int damage )
+{
+ float left, front, up;
+ float kick;
+ int health;
+ float scale;
+ vec3_t dir;
+ vec3_t angles;
+ float dist;
+ float yaw, pitch;
+
+ // show the attacking player's head and name in corner
+ cg.attackerTime = cg.time;
+
+ // the lower on health you are, the greater the view kick will be
+ health = cg.snap->ps.stats[STAT_HEALTH];
+
+ if( health < 40 )
+ scale = 1;
+ else
+ scale = 40.0 / health;
+
+ kick = damage * scale;
+
+ if( kick < 5 )
+ kick = 5;
+
+ if( kick > 10 )
+ kick = 10;
+
+ // if yaw and pitch are both 255, make the damage always centered (falling, etc)
+ if( yawByte == 255 && pitchByte == 255 )
+ {
+ cg.damageX = 0;
+ cg.damageY = 0;
+ cg.v_dmg_roll = 0;
+ cg.v_dmg_pitch = -kick;
+ }
+ else
+ {
+ // positional
+ pitch = pitchByte / 255.0 * 360;
+ yaw = yawByte / 255.0 * 360;
+
+ angles[ PITCH ] = pitch;
+ angles[ YAW ] = yaw;
+ angles[ ROLL ] = 0;
+
+ AngleVectors( angles, dir, NULL, NULL );
+ VectorSubtract( vec3_origin, dir, dir );
+
+ front = DotProduct( dir, cg.refdef.viewaxis[ 0 ] );
+ left = DotProduct( dir, cg.refdef.viewaxis[ 1 ] );
+ up = DotProduct( dir, cg.refdef.viewaxis[ 2 ] );
+
+ dir[ 0 ] = front;
+ dir[ 1 ] = left;
+ dir[ 2 ] = 0;
+ dist = VectorLength( dir );
- switch ( i ) {
- /*case WP_ROCKET_LAUNCHER:*/
- case WP_LOCKBLOB_LAUNCHER:
- /*case WP_GRENADE_LAUNCHER:*/
- /*case WP_RAILGUN:*/
- /*case WP_SHOTGUN:*/
- total += ammo * 1000;
- break;
- default:
- if( clips )
- total += 5000;
- total += ammo * 200;
- break;
- }
- if ( total >= 5000 || BG_FindInfinteAmmoForWeapon( i ) )
- {
- cg.lowAmmoWarning = 0;
- return;
- }
- }
-
- previous = cg.lowAmmoWarning;
-
- if ( total == 0 ) {
- cg.lowAmmoWarning = 2;
- } else {
- cg.lowAmmoWarning = 1;
- }
-
- // play a sound on transitions
- if ( cg.lowAmmoWarning != previous ) {
- trap_S_StartLocalSound( cgs.media.noAmmoSound, CHAN_LOCAL_SOUND );
- }
-}
+ if( dist < 0.1f )
+ dist = 0.1f;
-/*
-==============
-CG_DamageFeedback
-==============
-*/
-void CG_DamageFeedback( int yawByte, int pitchByte, int damage ) {
- float left, front, up;
- float kick;
- int health;
- float scale;
- vec3_t dir;
- vec3_t angles;
- float dist;
- float yaw, pitch;
-
- // show the attacking player's head and name in corner
- cg.attackerTime = cg.time;
-
- // the lower on health you are, the greater the view kick will be
- health = cg.snap->ps.stats[STAT_HEALTH];
- if ( health < 40 ) {
- scale = 1;
- } else {
- scale = 40.0 / health;
- }
- kick = damage * scale;
-
- if (kick < 5)
- kick = 5;
- if (kick > 10)
- kick = 10;
-
- // if yaw and pitch are both 255, make the damage always centered (falling, etc)
- if ( yawByte == 255 && pitchByte == 255 ) {
- cg.damageX = 0;
- cg.damageY = 0;
- cg.v_dmg_roll = 0;
- cg.v_dmg_pitch = -kick;
- } else {
- // positional
- pitch = pitchByte / 255.0 * 360;
- yaw = yawByte / 255.0 * 360;
-
- angles[PITCH] = pitch;
- angles[YAW] = yaw;
- angles[ROLL] = 0;
-
- AngleVectors( angles, dir, NULL, NULL );
- VectorSubtract( vec3_origin, dir, dir );
-
- front = DotProduct (dir, cg.refdef.viewaxis[0] );
- left = DotProduct (dir, cg.refdef.viewaxis[1] );
- up = DotProduct (dir, cg.refdef.viewaxis[2] );
-
- dir[0] = front;
- dir[1] = left;
- dir[2] = 0;
- dist = VectorLength( dir );
- if ( dist < 0.1 ) {
- dist = 0.1f;
- }
-
- cg.v_dmg_roll = kick * left;
-
- cg.v_dmg_pitch = -kick * front;
-
- if ( front <= 0.1 ) {
- front = 0.1f;
- }
- cg.damageX = -left / front;
- cg.damageY = up / dist;
- }
-
- // clamp the position
- if ( cg.damageX > 1.0 ) {
- cg.damageX = 1.0;
- }
- if ( cg.damageX < - 1.0 ) {
- cg.damageX = -1.0;
- }
-
- if ( cg.damageY > 1.0 ) {
- cg.damageY = 1.0;
- }
- if ( cg.damageY < - 1.0 ) {
- cg.damageY = -1.0;
- }
-
- // don't let the screen flashes vary as much
- if ( kick > 10 ) {
- kick = 10;
- }
- cg.damageValue = kick;
- cg.v_dmg_time = cg.time + DAMAGE_TIME;
- cg.damageTime = cg.snap->serverTime;
+ cg.v_dmg_roll = kick * left;
+
+ cg.v_dmg_pitch = -kick * front;
+
+ if( front <= 0.1 )
+ front = 0.1f;
+
+ cg.damageX = -left / front;
+ cg.damageY = up / dist;
+ }
+
+ // clamp the position
+ if( cg.damageX > 1.0 )
+ cg.damageX = 1.0;
+
+ if( cg.damageX < - 1.0 )
+ cg.damageX = -1.0;
+
+ if( cg.damageY > 1.0 )
+ cg.damageY = 1.0;
+
+ if( cg.damageY < - 1.0 )
+ cg.damageY = -1.0;
+
+ // don't let the screen flashes vary as much
+ if( kick > 10 )
+ kick = 10;
+
+ cg.damageValue = kick;
+ cg.v_dmg_time = cg.time + DAMAGE_TIME;
+ cg.damageTime = cg.snap->serverTime;
}
@@ -184,57 +131,60 @@ CG_Respawn
A respawn happened this snapshot
================
*/
-void CG_Respawn( void ) {
- // no error decay on player movement
- cg.thisFrameTeleport = qtrue;
+void CG_Respawn( void )
+{
+ // no error decay on player movement
+ cg.thisFrameTeleport = qtrue;
- // display weapons available
- cg.weaponSelectTime = cg.time;
+ // display weapons available
+ cg.weaponSelectTime = cg.time;
- // select the weapon the server says we are using
- cg.weaponSelect = cg.snap->ps.weapon;
+ // select the weapon the server says we are using
+ cg.weaponSelect = cg.snap->ps.weapon;
}
-extern char *eventnames[];
-
/*
==============
CG_CheckPlayerstateEvents
==============
*/
-void CG_CheckPlayerstateEvents( playerState_t *ps, playerState_t *ops ) {
- int i;
- int event;
- centity_t *cent;
+void CG_CheckPlayerstateEvents( playerState_t *ps, playerState_t *ops )
+{
+ int i;
+ int event;
+ centity_t *cent;
- if ( ps->externalEvent && ps->externalEvent != ops->externalEvent ) {
- cent = &cg_entities[ ps->clientNum ];
- cent->currentState.event = ps->externalEvent;
- cent->currentState.eventParm = ps->externalEventParm;
- CG_EntityEvent( cent, cent->lerpOrigin );
- }
+ if( ps->externalEvent && ps->externalEvent != ops->externalEvent )
+ {
+ cent = &cg_entities[ ps->clientNum ];
+ cent->currentState.event = ps->externalEvent;
+ cent->currentState.eventParm = ps->externalEventParm;
+ CG_EntityEvent( cent, cent->lerpOrigin );
+ }
- cent = &cg.predictedPlayerEntity; // cg_entities[ ps->clientNum ];
+ cent = &cg.predictedPlayerEntity; // cg_entities[ ps->clientNum ];
// go through the predictable events buffer
- for ( i = ps->eventSequence - MAX_PS_EVENTS ; i < ps->eventSequence ; i++ ) {
+ for( i = ps->eventSequence - MAX_PS_EVENTS; i < ps->eventSequence; i++ )
+ {
// if we have a new predictable event
- if ( i >= ops->eventSequence
+ if( i >= ops->eventSequence ||
// or the server told us to play another event instead of a predicted event we already issued
// or something the server told us changed our prediction causing a different event
- || (i > ops->eventSequence - MAX_PS_EVENTS && ps->events[i & (MAX_PS_EVENTS-1)] != ops->events[i & (MAX_PS_EVENTS-1)]) ) {
-
- event = ps->events[ i & (MAX_PS_EVENTS-1) ];
+ ( i > ops->eventSequence - MAX_PS_EVENTS && ps->events[ i & ( MAX_PS_EVENTS - 1 ) ] !=
+ ops->events[ i & ( MAX_PS_EVENTS - 1 ) ] ) )
+ {
+ event = ps->events[ i & ( MAX_PS_EVENTS - 1 ) ];
- cent->currentState.event = event;
- cent->currentState.eventParm = ps->eventParms[ i & (MAX_PS_EVENTS-1) ];
- CG_EntityEvent( cent, cent->lerpOrigin );
- cg.predictableEvents[ i & (MAX_PREDICTED_EVENTS-1) ] = event;
+ cent->currentState.event = event;
+ cent->currentState.eventParm = ps->eventParms[ i & ( MAX_PS_EVENTS - 1 ) ];
+ CG_EntityEvent( cent, cent->lerpOrigin );
+ cg.predictableEvents[ i & ( MAX_PREDICTED_EVENTS - 1 ) ] = event;
cg.eventSequence++;
- }
- }
+ }
+ }
}
@@ -243,32 +193,35 @@ void CG_CheckPlayerstateEvents( playerState_t *ps, playerState_t *ops ) {
CG_CheckChangedPredictableEvents
==================
*/
-void CG_CheckChangedPredictableEvents( playerState_t *ps ) {
- int i;
- int event;
+void CG_CheckChangedPredictableEvents( playerState_t *ps )
+{
+ int i;
+ int event;
centity_t *cent;
cent = &cg.predictedPlayerEntity;
- for ( i = ps->eventSequence - MAX_PS_EVENTS ; i < ps->eventSequence ; i++ ) {
+
+ for( i = ps->eventSequence - MAX_PS_EVENTS; i < ps->eventSequence; i++ )
+ {
//
- if (i >= cg.eventSequence) {
+ if( i >= cg.eventSequence )
continue;
- }
+
// if this event is not further back in than the maximum predictable events we remember
- if (i > cg.eventSequence - MAX_PREDICTED_EVENTS) {
+ if( i > cg.eventSequence - MAX_PREDICTED_EVENTS )
+ {
// if the new playerstate event is different from a previously predicted one
- if ( ps->events[i & (MAX_PS_EVENTS-1)] != cg.predictableEvents[i & (MAX_PREDICTED_EVENTS-1) ] ) {
-
- event = ps->events[ i & (MAX_PS_EVENTS-1) ];
+ if( ps->events[ i & ( MAX_PS_EVENTS - 1 ) ] != cg.predictableEvents[ i & ( MAX_PREDICTED_EVENTS - 1 ) ] )
+ {
+ event = ps->events[ i & ( MAX_PS_EVENTS - 1 ) ];
cent->currentState.event = event;
- cent->currentState.eventParm = ps->eventParms[ i & (MAX_PS_EVENTS-1) ];
+ cent->currentState.eventParm = ps->eventParms[ i & ( MAX_PS_EVENTS - 1 ) ];
CG_EntityEvent( cent, cent->lerpOrigin );
- cg.predictableEvents[ i & (MAX_PREDICTED_EVENTS-1) ] = event;
+ cg.predictableEvents[ i & ( MAX_PREDICTED_EVENTS - 1 ) ] = event;
- if ( cg_showmiss.integer ) {
- CG_Printf("WARNING: changed predicted event\n");
- }
+ if( cg_showmiss.integer )
+ CG_Printf( "WARNING: changed predicted event\n" );
}
}
}
@@ -276,72 +229,62 @@ void CG_CheckChangedPredictableEvents( playerState_t *ps ) {
/*
==================
-pushReward
-==================
-*/
-static void pushReward(sfxHandle_t sfx, qhandle_t shader, int rewardCount) {
- if (cg.rewardStack < (MAX_REWARDSTACK-1)) {
- cg.rewardStack++;
- cg.rewardSound[cg.rewardStack] = sfx;
- cg.rewardShader[cg.rewardStack] = shader;
- cg.rewardCount[cg.rewardStack] = rewardCount;
- }
-}
-
-
-/*
-==================
CG_CheckLocalSounds
==================
*/
-void CG_CheckLocalSounds( playerState_t *ps, playerState_t *ops ) {
- int highScore, health, armor, reward;
+void CG_CheckLocalSounds( playerState_t *ps, playerState_t *ops )
+{
+ int highScore, health, armor, reward;
sfxHandle_t sfx;
// don't play the sounds if the player just changed teams
- if ( ps->persistant[PERS_TEAM] != ops->persistant[PERS_TEAM] ) {
+ if( ps->persistant[ PERS_TEAM ] != ops->persistant[ PERS_TEAM ] )
return;
- }
// hit changes
- if ( ps->persistant[PERS_HITS] > ops->persistant[PERS_HITS] ) {
+ if( ps->persistant[ PERS_HITS ] > ops->persistant[ PERS_HITS ] )
+ {
/*armor = ps->persistant[PERS_ATTACKEE_ARMOR] & 0xff;
health = ps->persistant[PERS_ATTACKEE_ARMOR] >> 8;*/
trap_S_StartLocalSound( cgs.media.hitSound, CHAN_LOCAL_SOUND );
- } else if ( ps->persistant[PERS_HITS] < ops->persistant[PERS_HITS] ) {
- trap_S_StartLocalSound( cgs.media.hitTeamSound, CHAN_LOCAL_SOUND );
}
+ else if( ps->persistant[ PERS_HITS ] < ops->persistant[ PERS_HITS ] )
+ trap_S_StartLocalSound( cgs.media.hitTeamSound, CHAN_LOCAL_SOUND );
// health changes of more than -1 should make pain sounds
- if ( ps->stats[STAT_HEALTH] < ops->stats[STAT_HEALTH] - 1 ) {
- if ( ps->stats[STAT_HEALTH] > 0 ) {
- CG_PainEvent( &cg.predictedPlayerEntity, ps->stats[STAT_HEALTH] );
- }
+ if( ps->stats[ STAT_HEALTH ] < ops->stats[ STAT_HEALTH ] - 1 )
+ {
+ if( ps->stats[ STAT_HEALTH ] > 0 )
+ CG_PainEvent( &cg.predictedPlayerEntity, ps->stats[ STAT_HEALTH ] );
}
// if we are going into the intermission, don't start any voices
- if ( cg.intermissionStarted ) {
+ if( cg.intermissionStarted )
return;
- }
// reward sounds
reward = qfalse;
// timelimit warnings
- if ( cgs.timelimit > 0 ) {
+ if( cgs.timelimit > 0 )
+ {
int msec;
msec = cg.time - cgs.levelStartTime;
- if ( !( cg.timelimitWarnings & 4 ) && msec > ( cgs.timelimit * 60 + 2 ) * 1000 ) {
+
+ if( !( cg.timelimitWarnings & 4 ) && msec > ( cgs.timelimit * 60 + 2 ) * 1000 )
+ {
cg.timelimitWarnings |= 1 | 2 | 4;
trap_S_StartLocalSound( cgs.media.suddenDeathSound, CHAN_ANNOUNCER );
}
- else if ( !( cg.timelimitWarnings & 2 ) && msec > (cgs.timelimit - 1) * 60 * 1000 ) {
+ else if( !( cg.timelimitWarnings & 2 ) && msec > ( cgs.timelimit - 1 ) * 60 * 1000 )
+ {
cg.timelimitWarnings |= 1 | 2;
trap_S_StartLocalSound( cgs.media.oneMinuteSound, CHAN_ANNOUNCER );
}
- else if ( cgs.timelimit > 5 && !( cg.timelimitWarnings & 1 ) && msec > (cgs.timelimit - 5) * 60 * 1000 ) {
+ else if( cgs.timelimit > 5 && !( cg.timelimitWarnings & 1 ) && msec > ( cgs.timelimit - 5 ) * 60 * 1000 )
+ {
cg.timelimitWarnings |= 1;
trap_S_StartLocalSound( cgs.media.fiveMinuteSound, CHAN_ANNOUNCER );
}
@@ -355,44 +298,42 @@ CG_TransitionPlayerState
===============
*/
-void CG_TransitionPlayerState( playerState_t *ps, playerState_t *ops ) {
- // check for changing follow mode
- if ( ps->clientNum != ops->clientNum ) {
- cg.thisFrameTeleport = qtrue;
- // make sure we don't get any unwanted transition effects
- *ops = *ps;
- }
-
- // damage events (player is getting wounded)
- if ( ps->damageEvent != ops->damageEvent && ps->damageCount ) {
- CG_DamageFeedback( ps->damageYaw, ps->damagePitch, ps->damageCount );
- }
-
- // respawning
- if ( ps->persistant[PERS_SPAWN_COUNT] != ops->persistant[PERS_SPAWN_COUNT] ) {
- CG_Respawn();
- }
-
- if ( cg.mapRestart ) {
- CG_Respawn();
- cg.mapRestart = qfalse;
+void CG_TransitionPlayerState( playerState_t *ps, playerState_t *ops )
+{
+ // check for changing follow mode
+ if( ps->clientNum != ops->clientNum )
+ {
+ cg.thisFrameTeleport = qtrue;
+ // make sure we don't get any unwanted transition effects
+ *ops = *ps;
}
- if ( cg.snap->ps.pm_type != PM_INTERMISSION
- && ps->persistant[PERS_TEAM] != TEAM_SPECTATOR ) {
- CG_CheckLocalSounds( ps, ops );
- }
+ // damage events (player is getting wounded)
+ if( ps->damageEvent != ops->damageEvent && ps->damageCount )
+ CG_DamageFeedback( ps->damageYaw, ps->damagePitch, ps->damageCount );
+
+ // respawning
+ if( ps->persistant[ PERS_SPAWN_COUNT ] != ops->persistant[ PERS_SPAWN_COUNT ] )
+ CG_Respawn( );
+
+ if( cg.mapRestart )
+ {
+ CG_Respawn( );
+ cg.mapRestart = qfalse;
+ }
- // check for going low on ammo
- //CG_CheckAmmo(); //TA: don't display ammo warnings
+ if( cg.snap->ps.pm_type != PM_INTERMISSION &&
+ ps->persistant[ PERS_TEAM ] != TEAM_SPECTATOR )
+ CG_CheckLocalSounds( ps, ops );
- // run events
- CG_CheckPlayerstateEvents( ps, ops );
+ // run events
+ CG_CheckPlayerstateEvents( ps, ops );
- // smooth the ducking viewheight change
- if ( ps->viewheight != ops->viewheight ) {
- cg.duckChange = ps->viewheight - ops->viewheight;
- cg.duckTime = cg.time;
- }
+ // smooth the ducking viewheight change
+ if( ps->viewheight != ops->viewheight )
+ {
+ cg.duckChange = ps->viewheight - ops->viewheight;
+ cg.duckTime = cg.time;
+ }
}
diff --git a/src/cgame/cg_predict.c b/src/cgame/cg_predict.c
index d28c9ba6..fabe1065 100644
--- a/src/cgame/cg_predict.c
+++ b/src/cgame/cg_predict.c
@@ -36,33 +36,36 @@ of the entities that are actually solid, to make for more
efficient collision detection
====================
*/
-void CG_BuildSolidList( void ) {
- int i;
- centity_t *cent;
- snapshot_t *snap;
+void CG_BuildSolidList( void )
+{
+ int i;
+ centity_t *cent;
+ snapshot_t *snap;
entityState_t *ent;
cg_numSolidEntities = 0;
cg_numTriggerEntities = 0;
- if ( cg.nextSnap && !cg.nextFrameTeleport && !cg.thisFrameTeleport ) {
+ if( cg.nextSnap && !cg.nextFrameTeleport && !cg.thisFrameTeleport )
snap = cg.nextSnap;
- } else {
+ else
snap = cg.snap;
- }
- for ( i = 0 ; i < snap->numEntities ; i++ ) {
+ for( i = 0; i < snap->numEntities; i++ )
+ {
cent = &cg_entities[ snap->entities[ i ].number ];
ent = &cent->currentState;
- if ( ent->eType == ET_ITEM || ent->eType == ET_PUSH_TRIGGER || ent->eType == ET_TELEPORT_TRIGGER ) {
- cg_triggerEntities[cg_numTriggerEntities] = cent;
+ if( ent->eType == ET_ITEM || ent->eType == ET_PUSH_TRIGGER || ent->eType == ET_TELEPORT_TRIGGER )
+ {
+ cg_triggerEntities[ cg_numTriggerEntities ] = cent;
cg_numTriggerEntities++;
continue;
}
- if ( cent->nextState.solid ) {
- cg_solidEntities[cg_numSolidEntities] = cent;
+ if( cent->nextState.solid )
+ {
+ cg_solidEntities[ cg_numSolidEntities ] = cent;
cg_numSolidEntities++;
continue;
}
@@ -76,38 +79,42 @@ CG_ClipMoveToEntities
====================
*/
static void CG_ClipMoveToEntities ( const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end,
- int skipNumber, int mask, trace_t *tr, qboolean capsule ) {
- int i, x, zd, zu;
- trace_t trace;
+ int skipNumber, int mask, trace_t *tr, qboolean capsule )
+{
+ int i, x, zd, zu;
+ trace_t trace;
entityState_t *ent;
clipHandle_t cmodel;
- vec3_t bmins, bmaxs;
- vec3_t origin, angles;
- centity_t *cent;
+ vec3_t bmins, bmaxs;
+ vec3_t origin, angles;
+ centity_t *cent;
- for ( i = 0 ; i < cg_numSolidEntities ; i++ ) {
+ for( i = 0; i < cg_numSolidEntities; i++ )
+ {
cent = cg_solidEntities[ i ];
ent = &cent->currentState;
- if ( ent->number == skipNumber ) {
+ if( ent->number == skipNumber )
continue;
- }
- if ( ent->solid == SOLID_BMODEL ) {
+ if( ent->solid == SOLID_BMODEL )
+ {
// special value for bmodel
cmodel = trap_CM_InlineModel( ent->modelindex );
VectorCopy( cent->lerpAngles, angles );
BG_EvaluateTrajectory( &cent->currentState.pos, cg.physicsTime, origin );
- } else {
+ }
+ else
+ {
// encoded bbox
- x = (ent->solid & 255);
- zd = ((ent->solid>>8) & 255);
- zu = ((ent->solid>>16) & 255) - 32;
+ x = ( ent->solid & 255 );
+ zd = ( ( ent->solid >> 8 ) & 255 );
+ zu = ( ( ent->solid >> 16 ) & 255 ) - 32;
- bmins[0] = bmins[1] = -x;
- bmaxs[0] = bmaxs[1] = x;
- bmins[2] = -zd;
- bmaxs[2] = zu;
+ bmins[ 0 ] = bmins[ 1 ] = -x;
+ bmaxs[ 0 ] = bmaxs[ 1 ] = x;
+ bmins[ 2 ] = -zd;
+ bmaxs[ 2 ] = zu;
cmodel = trap_CM_TempBoxModel( bmins, bmaxs );
VectorCopy( vec3_origin, angles );
@@ -118,23 +125,24 @@ static void CG_ClipMoveToEntities ( const vec3_t start, const vec3_t mins, const
if( capsule )
{
trap_CM_TransformedCapsuleTrace ( &trace, start, end,
- mins, maxs, cmodel, mask, origin, angles);
- }
+ mins, maxs, cmodel, mask, origin, angles );
+ }
else
{
trap_CM_TransformedBoxTrace ( &trace, start, end,
- mins, maxs, cmodel, mask, origin, angles);
+ mins, maxs, cmodel, mask, origin, angles );
}
- if (trace.allsolid || trace.fraction < tr->fraction) {
+ if( trace.allsolid || trace.fraction < tr->fraction )
+ {
trace.entityNum = ent->number;
*tr = trace;
- } else if (trace.startsolid) {
- tr->startsolid = qtrue;
}
- if ( tr->allsolid ) {
+ else if( trace.startsolid )
+ tr->startsolid = qtrue;
+
+ if( tr->allsolid )
return;
- }
}
}
@@ -144,13 +152,14 @@ CG_Trace
================
*/
void CG_Trace( trace_t *result, const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end,
- int skipNumber, int mask ) {
+ int skipNumber, int mask )
+{
trace_t t;
- trap_CM_BoxTrace ( &t, start, end, mins, maxs, 0, mask);
+ trap_CM_BoxTrace( &t, start, end, mins, maxs, 0, mask );
t.entityNum = t.fraction != 1.0 ? ENTITYNUM_WORLD : ENTITYNUM_NONE;
// check all other solid models
- CG_ClipMoveToEntities (start, mins, maxs, end, skipNumber, mask, &t, qfalse);
+ CG_ClipMoveToEntities( start, mins, maxs, end, skipNumber, mask, &t, qfalse );
*result = t;
}
@@ -161,13 +170,14 @@ CG_CapTrace
================
*/
void CG_CapTrace( trace_t *result, const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end,
- int skipNumber, int mask ) {
+ int skipNumber, int mask )
+{
trace_t t;
- trap_CM_CapsuleTrace ( &t, start, end, mins, maxs, 0, mask);
+ trap_CM_CapsuleTrace( &t, start, end, mins, maxs, 0, mask );
t.entityNum = t.fraction != 1.0 ? ENTITYNUM_WORLD : ENTITYNUM_NONE;
// check all other solid models
- CG_ClipMoveToEntities (start, mins, maxs, end, skipNumber, mask, &t, qtrue);
+ CG_ClipMoveToEntities( start, mins, maxs, end, skipNumber, mask, &t, qtrue );
*result = t;
}
@@ -219,9 +229,10 @@ Generates cg.predictedPlayerState by interpolating between
cg.snap->player_state and cg.nextFrame->player_state
========================
*/
-static void CG_InterpolatePlayerState( qboolean grabAngles ) {
- float f;
- int i;
+static void CG_InterpolatePlayerState( qboolean grabAngles )
+{
+ float f;
+ int i;
playerState_t *out;
snapshot_t *prev, *next;
@@ -232,84 +243,42 @@ static void CG_InterpolatePlayerState( qboolean grabAngles ) {
*out = cg.snap->ps;
// if we are still allowing local input, short circuit the view angles
- if ( grabAngles ) {
+ if( grabAngles )
+ {
usercmd_t cmd;
int cmdNum;
- cmdNum = trap_GetCurrentCmdNumber();
+ cmdNum = trap_GetCurrentCmdNumber( );
trap_GetUserCmd( cmdNum, &cmd );
PM_UpdateViewAngles( out, &cmd );
}
// if the next frame is a teleport, we can't lerp to it
- if ( cg.nextFrameTeleport ) {
+ if( cg.nextFrameTeleport )
return;
- }
- if ( !next || next->serverTime <= prev->serverTime ) {
+ if( !next || next->serverTime <= prev->serverTime )
return;
- }
f = (float)( cg.time - prev->serverTime ) / ( next->serverTime - prev->serverTime );
i = next->ps.bobCycle;
- if ( i < prev->ps.bobCycle ) {
+ if( i < prev->ps.bobCycle )
i += 256; // handle wraparound
- }
+
out->bobCycle = prev->ps.bobCycle + f * ( i - prev->ps.bobCycle );
- for ( i = 0 ; i < 3 ; i++ ) {
- out->origin[i] = prev->ps.origin[i] + f * (next->ps.origin[i] - prev->ps.origin[i] );
- if ( !grabAngles ) {
- out->viewangles[i] = LerpAngle(
- prev->ps.viewangles[i], next->ps.viewangles[i], f );
- }
- out->velocity[i] = prev->ps.velocity[i] +
- f * (next->ps.velocity[i] - prev->ps.velocity[i] );
- }
-
-}
-
-/*
-===================
-CG_TouchItem
-===================
-*/
-static void CG_TouchItem( centity_t *cent ) {
- gitem_t *item;
- int ammo, clips, maxclips;
-
- BG_unpackAmmoArray( item->giTag, cg.predictedPlayerState.ammo, cg.predictedPlayerState.powerups, &ammo, &clips, &maxclips );
-
- if ( !cg_predictItems.integer ) {
- return;
+ for( i = 0; i < 3; i++ )
+ {
+ out->origin[ i ] = prev->ps.origin[ i ] + f * ( next->ps.origin[ i ] - prev->ps.origin[ i ] );
+
+ if( !grabAngles )
+ out->viewangles[ i ] = LerpAngle( prev->ps.viewangles[ i ], next->ps.viewangles[ i ], f );
+
+ out->velocity[ i ] = prev->ps.velocity[ i ] +
+ f * (next->ps.velocity[ i ] - prev->ps.velocity[ i ] );
}
-/* if ( !BG_PlayerTouchesItem( &cg.predictedPlayerState, &cent->currentState, cg.time ) ) {
- return;
- }*/
-
- // never pick an item up twice in a prediction
- if ( cent->miscTime == cg.time ) {
- return;
- }
-
- // grab it
- BG_AddPredictableEventToPlayerstate( EV_ITEM_PICKUP, cent->currentState.modelindex , &cg.predictedPlayerState);
-
- // remove it from the frame so it won't be drawn
- cent->currentState.eFlags |= EF_NODRAW;
-
- // don't touch it again this prediction
- cent->miscTime = cg.time;
-
- // if its a weapon, give them some predicted ammo so the autoswitch will work
-/* if ( item->giType == IT_WEAPON ) {
- BG_packWeapon( item->giTag, cg.predictedPlayerState.stats );
- if ( ammo == 0 && clips == 0 ) {
- BG_packAmmoArray( item->giTag, cg.predictedPlayerState.ammo, cg.predictedPlayerState.powerups, 1, 0, 0 );
- }
- }*/
}
@@ -320,59 +289,51 @@ CG_TouchTriggerPrediction
Predict push triggers and items
=========================
*/
-static void CG_TouchTriggerPrediction( void ) {
- int i;
- trace_t trace;
+static void CG_TouchTriggerPrediction( void )
+{
+ int i;
+ trace_t trace;
entityState_t *ent;
- clipHandle_t cmodel;
- centity_t *cent;
- qboolean spectator;
+ clipHandle_t cmodel;
+ centity_t *cent;
+ qboolean spectator;
// dead clients don't activate triggers
- if ( cg.predictedPlayerState.stats[STAT_HEALTH] <= 0 ) {
+ if( cg.predictedPlayerState.stats[ STAT_HEALTH ] <= 0 )
return;
- }
spectator = ( cg.predictedPlayerState.pm_type == PM_SPECTATOR );
- if ( cg.predictedPlayerState.pm_type != PM_NORMAL && !spectator ) {
+ if( cg.predictedPlayerState.pm_type != PM_NORMAL && !spectator )
return;
- }
- for ( i = 0 ; i < cg_numTriggerEntities ; i++ ) {
+ for( i = 0; i < cg_numTriggerEntities; i++ )
+ {
cent = cg_triggerEntities[ i ];
ent = &cent->currentState;
- if ( ent->eType == ET_ITEM && !spectator ) {
- CG_TouchItem( cent );
+ if( ent->solid != SOLID_BMODEL )
continue;
- }
-
- if ( ent->solid != SOLID_BMODEL ) {
- continue;
- }
cmodel = trap_CM_InlineModel( ent->modelindex );
- if ( !cmodel ) {
+ if( !cmodel )
continue;
- }
trap_CM_BoxTrace( &trace, cg.predictedPlayerState.origin, cg.predictedPlayerState.origin,
- cg_pmove.mins, cg_pmove.maxs, cmodel, -1 );
+ cg_pmove.mins, cg_pmove.maxs, cmodel, -1 );
- if ( !trace.startsolid ) {
+ if( !trace.startsolid )
continue;
- }
- if ( ent->eType == ET_TELEPORT_TRIGGER ) {
+ if( ent->eType == ET_TELEPORT_TRIGGER )
cg.hyperspace = qtrue;
- } else if ( ent->eType == ET_PUSH_TRIGGER ) {
+ else if( ent->eType == ET_PUSH_TRIGGER )
BG_TouchJumpPad( &cg.predictedPlayerState, ent );
- }
}
// if we didn't touch a jump pad this pmove frame
- if ( cg.predictedPlayerState.jumppad_frame != cg.predictedPlayerState.pmove_framecount ) {
+ if( cg.predictedPlayerState.jumppad_frame != cg.predictedPlayerState.pmove_framecount )
+ {
cg.predictedPlayerState.jumppad_frame = 0;
cg.predictedPlayerState.jumppad_ent = 0;
}
@@ -406,7 +367,8 @@ We detect prediction errors and allow them to be decayed off over several frames
to ease the jerk.
=================
*/
-void CG_PredictPlayerState( void ) {
+void CG_PredictPlayerState( void )
+{
int cmdNum, current, i;
playerState_t oldPlayerState;
qboolean moved;
@@ -418,20 +380,23 @@ void CG_PredictPlayerState( void ) {
// if this is the first frame we must guarantee
// predictedPlayerState is valid even if there is some
// other error condition
- if ( !cg.validPPS ) {
+ if( !cg.validPPS )
+ {
cg.validPPS = qtrue;
cg.predictedPlayerState = cg.snap->ps;
}
// demo playback just copies the moves
- if ( cg.demoPlayback || (cg.snap->ps.pm_flags & PMF_FOLLOW) ) {
+ if( cg.demoPlayback || (cg.snap->ps.pm_flags & PMF_FOLLOW) )
+ {
CG_InterpolatePlayerState( qfalse );
return;
}
// non-predicting local movement will grab the latest angles
- if ( cg_nopredict.integer || cg_synchronousClients.integer ) {
+ if( cg_nopredict.integer || cg_synchronousClients.integer )
+ {
CG_InterpolatePlayerState( qtrue );
return;
}
@@ -441,33 +406,33 @@ void CG_PredictPlayerState( void ) {
cg_pmove.trace = CG_Trace;
cg_pmove.pointcontents = CG_PointContents;
- //TA: FIXME BIG NEON SIGN..... COULD MAYBE BE A FIX FOR THAT HACK IN bg_pmove.c.. MAYBE \/
- if ( cg_pmove.ps->pm_type == PM_DEAD ) {
+ if( cg_pmove.ps->pm_type == PM_DEAD )
cg_pmove.tracemask = MASK_PLAYERSOLID & ~CONTENTS_BODY;
- }
- else {
+ else
cg_pmove.tracemask = MASK_PLAYERSOLID;
- }
- if ( cg.snap->ps.persistant[PERS_TEAM] == TEAM_SPECTATOR ) {
+
+ if( cg.snap->ps.persistant[ PERS_TEAM ] == TEAM_SPECTATOR )
cg_pmove.tracemask &= ~CONTENTS_BODY; // spectators can fly through bodies
- }
+
cg_pmove.noFootsteps = ( cgs.dmflags & DF_NO_FOOTSTEPS ) > 0;
// save the state before the pmove so we can detect transitions
oldPlayerState = cg.predictedPlayerState;
- current = trap_GetCurrentCmdNumber();
+ current = trap_GetCurrentCmdNumber( );
// if we don't have the commands right after the snapshot, we
// can't accurately predict a current position, so just freeze at
// the last good position we had
cmdNum = current - CMD_BACKUP + 1;
trap_GetUserCmd( cmdNum, &oldestCmd );
- if ( oldestCmd.serverTime > cg.snap->ps.commandTime
- && oldestCmd.serverTime < cg.time ) { // special check for map_restart
- if ( cg_showmiss.integer ) {
- CG_Printf ("exceeded PACKET_BACKUP on commands\n");
- }
+
+ if( oldestCmd.serverTime > cg.snap->ps.commandTime &&
+ oldestCmd.serverTime < cg.time )
+ { // special check for map_restart
+ if( cg_showmiss.integer )
+ CG_Printf( "exceeded PACKET_BACKUP on commands\n" );
+
return;
}
@@ -478,92 +443,103 @@ void CG_PredictPlayerState( void ) {
// the server time is beyond our current cg.time,
// because predicted player positions are going to
// be ahead of everything else anyway
- if ( cg.nextSnap && !cg.nextFrameTeleport && !cg.thisFrameTeleport ) {
+ if( cg.nextSnap && !cg.nextFrameTeleport && !cg.thisFrameTeleport )
+ {
cg.predictedPlayerState = cg.nextSnap->ps;
cg.physicsTime = cg.nextSnap->serverTime;
- } else {
+ }
+ else
+ {
cg.predictedPlayerState = cg.snap->ps;
cg.physicsTime = cg.snap->serverTime;
}
- if ( pmove_msec.integer < 8 ) {
- trap_Cvar_Set("pmove_msec", "8");
- }
- else if (pmove_msec.integer > 33) {
- trap_Cvar_Set("pmove_msec", "33");
- }
+ if( pmove_msec.integer < 8 )
+ trap_Cvar_Set( "pmove_msec", "8" );
+ else if( pmove_msec.integer > 33 )
+ trap_Cvar_Set( "pmove_msec", "33" );
cg_pmove.pmove_fixed = pmove_fixed.integer;// | cg_pmove_fixed.integer;
cg_pmove.pmove_msec = pmove_msec.integer;
// run cmds
moved = qfalse;
- for ( cmdNum = current - CMD_BACKUP + 1 ; cmdNum <= current ; cmdNum++ ) {
+
+ for( cmdNum = current - CMD_BACKUP + 1; cmdNum <= current; cmdNum++ )
+ {
// get the command
trap_GetUserCmd( cmdNum, &cg_pmove.cmd );
- if ( cg_pmove.pmove_fixed ) {
+ if( cg_pmove.pmove_fixed )
PM_UpdateViewAngles( cg_pmove.ps, &cg_pmove.cmd );
- }
// don't do anything if the time is before the snapshot player time
- if ( cg_pmove.cmd.serverTime <= cg.predictedPlayerState.commandTime ) {
+ if( cg_pmove.cmd.serverTime <= cg.predictedPlayerState.commandTime )
continue;
- }
// don't do anything if the command was from a previous map_restart
- if ( cg_pmove.cmd.serverTime > latestCmd.serverTime ) {
+ if( cg_pmove.cmd.serverTime > latestCmd.serverTime )
continue;
- }
// check for a prediction error from last frame
// on a lan, this will often be the exact value
// from the snapshot, but on a wan we will have
// to predict several commands to get to the point
// we want to compare
- if ( cg.predictedPlayerState.commandTime == oldPlayerState.commandTime ) {
+ if( cg.predictedPlayerState.commandTime == oldPlayerState.commandTime )
+ {
vec3_t delta;
- float len;
+ float len;
- if ( cg.thisFrameTeleport ) {
+ if( cg.thisFrameTeleport )
+ {
// a teleport will not cause an error decay
VectorClear( cg.predictedError );
- if ( cg_showmiss.integer ) {
+
+ if( cg_showmiss.integer )
CG_Printf( "PredictionTeleport\n" );
- }
+
cg.thisFrameTeleport = qfalse;
- } else {
+ }
+ else
+ {
vec3_t adjusted;
CG_AdjustPositionForMover( cg.predictedPlayerState.origin,
cg.predictedPlayerState.groundEntityNum, cg.physicsTime, cg.oldTime, adjusted );
- if ( cg_showmiss.integer ) {
- if (!VectorCompare( oldPlayerState.origin, adjusted )) {
+ if( cg_showmiss.integer )
+ {
+ if( !VectorCompare( oldPlayerState.origin, adjusted ) )
CG_Printf("prediction error\n");
- }
}
+
VectorSubtract( oldPlayerState.origin, adjusted, delta );
len = VectorLength( delta );
- if ( len > 0.1 ) {
- if ( cg_showmiss.integer ) {
- CG_Printf("Prediction miss: %f\n", len);
- }
- if ( cg_errorDecay.integer ) {
+
+ if( len > 0.1 )
+ {
+ if( cg_showmiss.integer )
+ CG_Printf( "Prediction miss: %f\n", len );
+
+ if( cg_errorDecay.integer )
+ {
int t;
float f;
t = cg.time - cg.predictedErrorTime;
f = ( cg_errorDecay.value - t ) / cg_errorDecay.value;
- if ( f < 0 ) {
+
+ if( f < 0 )
f = 0;
- }
- if ( f > 0 && cg_showmiss.integer ) {
- CG_Printf("Double prediction decay: %f\n", f);
- }
+
+ if( f > 0 && cg_showmiss.integer )
+ CG_Printf( "Double prediction decay: %f\n", f );
+
VectorScale( cg.predictedError, f, cg.predictedError );
- } else {
- VectorClear( cg.predictedError );
}
+ else
+ VectorClear( cg.predictedError );
+
VectorAdd( delta, cg.predictedError, cg.predictedError );
cg.predictedErrorTime = cg.oldTime;
}
@@ -575,29 +551,29 @@ void CG_PredictPlayerState( void ) {
for( i = WP_NONE + 1; i < WP_NUM_WEAPONS; i++ )
cg_pmove.autoWeaponHit[ i ] = qfalse;
- if ( cg_pmove.pmove_fixed ) {
- cg_pmove.cmd.serverTime = ((cg_pmove.cmd.serverTime + pmove_msec.integer-1) / pmove_msec.integer) * pmove_msec.integer;
- }
+ if( cg_pmove.pmove_fixed )
+ cg_pmove.cmd.serverTime = ( ( cg_pmove.cmd.serverTime + pmove_msec.integer - 1 ) /
+ pmove_msec.integer ) * pmove_msec.integer;
- Pmove (&cg_pmove);
+ Pmove( &cg_pmove );
moved = qtrue;
// add push trigger movement effects
- CG_TouchTriggerPrediction();
+ CG_TouchTriggerPrediction( );
// check for predictable events that changed from previous predictions
//CG_CheckChangedPredictableEvents(&cg.predictedPlayerState);
}
- if ( cg_showmiss.integer > 1 ) {
+ if( cg_showmiss.integer > 1 )
CG_Printf( "[%i : %i] ", cg_pmove.cmd.serverTime, cg.time );
- }
- if ( !moved ) {
- if ( cg_showmiss.integer ) {
+ if( !moved )
+ {
+ if( cg_showmiss.integer )
CG_Printf( "not moved\n" );
- }
+
return;
}
@@ -606,21 +582,21 @@ void CG_PredictPlayerState( void ) {
cg.predictedPlayerState.groundEntityNum,
cg.physicsTime, cg.time, cg.predictedPlayerState.origin );
- if ( cg_showmiss.integer ) {
- if (cg.predictedPlayerState.eventSequence > oldPlayerState.eventSequence + MAX_PS_EVENTS) {
- CG_Printf("WARNING: dropped event\n");
- }
+ if( cg_showmiss.integer )
+ {
+ if( cg.predictedPlayerState.eventSequence > oldPlayerState.eventSequence + MAX_PS_EVENTS )
+ CG_Printf( "WARNING: dropped event\n" );
}
// fire events and other transition triggered things
CG_TransitionPlayerState( &cg.predictedPlayerState, &oldPlayerState );
- if ( cg_showmiss.integer ) {
- if (cg.eventSequence > cg.predictedPlayerState.eventSequence) {
- CG_Printf("WARNING: double event\n");
+ if( cg_showmiss.integer )
+ {
+ if( cg.eventSequence > cg.predictedPlayerState.eventSequence )
+ {
+ CG_Printf( "WARNING: double event\n" );
cg.eventSequence = cg.predictedPlayerState.eventSequence;
}
}
}
-
-
diff --git a/src/cgame/cg_scanner.c b/src/cgame/cg_scanner.c
index bec5f195..4135eec9 100644
--- a/src/cgame/cg_scanner.c
+++ b/src/cgame/cg_scanner.c
@@ -113,7 +113,7 @@ static void CG_DrawDir( vec3_t origin, vec4_t colour )
CG_AlienSense
=============
*/
-void CG_AlienSense( )
+void CG_AlienSense( void )
{
int i;
vec3_t origin;
@@ -149,7 +149,7 @@ void CG_AlienSense( )
CG_Scanner
=============
*/
-void CG_Scanner( )
+void CG_Scanner( void )
{
int i;
vec3_t origin;
diff --git a/src/cgame/cg_servercmds.c b/src/cgame/cg_servercmds.c
index 4107cc49..88df68f2 100644
--- a/src/cgame/cg_servercmds.c
+++ b/src/cgame/cg_servercmds.c
@@ -19,60 +19,41 @@
#include "cg_local.h"
-#include "../../ui/menudef.h"
-
-typedef struct {
- const char *order;
- int taskNum;
-} orderTask_t;
-
-static const orderTask_t validOrders[] = {
- /*{ VOICECHAT_GETFLAG, TEAMTASK_OFFENSE },
- { VOICECHAT_OFFENSE, TEAMTASK_OFFENSE },
- { VOICECHAT_DEFEND, TEAMTASK_DEFENSE },
- { VOICECHAT_DEFENDFLAG, TEAMTASK_DEFENSE },
- { VOICECHAT_PATROL, TEAMTASK_PATROL },
- { VOICECHAT_CAMP, TEAMTASK_CAMP },
- { VOICECHAT_FOLLOWME, TEAMTASK_FOLLOW },
- { VOICECHAT_RETURNFLAG, TEAMTASK_RETRIEVE },
- { VOICECHAT_FOLLOWFLAGCARRIER, TEAMTASK_ESCORT }*/
- { NULL, 0 }
-};
-
-static const int numValidOrders = sizeof(validOrders) / sizeof(orderTask_t);
-
/*
=================
CG_ParseScores
=================
*/
-static void CG_ParseScores( void ) {
+static void CG_ParseScores( void )
+{
int i, powerups;
cg.numScores = atoi( CG_Argv( 1 ) );
- if ( cg.numScores > MAX_CLIENTS ) {
+
+ if( cg.numScores > MAX_CLIENTS )
cg.numScores = MAX_CLIENTS;
- }
- cg.teamScores[0] = atoi( CG_Argv( 2 ) );
- cg.teamScores[1] = atoi( CG_Argv( 3 ) );
+ cg.teamScores[ 0 ] = atoi( CG_Argv( 2 ) );
+ cg.teamScores[ 1 ] = atoi( CG_Argv( 3 ) );
memset( cg.scores, 0, sizeof( cg.scores ) );
- for ( i = 0 ; i < cg.numScores ; i++ ) {
+
+ for( i = 0; i < cg.numScores; i++ )
+ {
//
- cg.scores[i].client = atoi( CG_Argv( i * 4 + 4 ) );
- cg.scores[i].score = atoi( CG_Argv( i * 4 + 5 ) );
- cg.scores[i].ping = atoi( CG_Argv( i * 4 + 6 ) );
- cg.scores[i].time = atoi( CG_Argv( i * 4 + 7 ) );
+ cg.scores[ i ].client = atoi( CG_Argv( i * 4 + 4 ) );
+ cg.scores[ i ].score = atoi( CG_Argv( i * 4 + 5 ) );
+ cg.scores[ i ].ping = atoi( CG_Argv( i * 4 + 6 ) );
+ cg.scores[ i ].time = atoi( CG_Argv( i * 4 + 7 ) );
- if ( cg.scores[i].client < 0 || cg.scores[i].client >= MAX_CLIENTS ) {
- cg.scores[i].client = 0;
- }
- cgs.clientinfo[ cg.scores[i].client ].score = cg.scores[i].score;
- cgs.clientinfo[ cg.scores[i].client ].powerups = powerups;
+ if( cg.scores[ i ].client < 0 || cg.scores[ i ].client >= MAX_CLIENTS )
+ cg.scores[ i ].client = 0;
+
+ cgs.clientinfo[ cg.scores[ i ].client ].score = cg.scores[ i ].score;
+ cgs.clientinfo[ cg.scores[ i ].client ].powerups = powerups;
- cg.scores[i].team = cgs.clientinfo[cg.scores[i].client].team;
+ cg.scores[ i ].team = cgs.clientinfo[ cg.scores[ i ].client ].team;
}
}
@@ -82,16 +63,18 @@ CG_ParseTeamInfo
=================
*/
-static void CG_ParseTeamInfo( void ) {
+static void CG_ParseTeamInfo( void )
+{
int i;
int client;
numSortedTeamPlayers = atoi( CG_Argv( 1 ) );
- for ( i = 0 ; i < numSortedTeamPlayers ; i++ ) {
+ for( i = 0; i < numSortedTeamPlayers; i++ )
+ {
client = atoi( CG_Argv( i * 6 + 2 ) );
- sortedTeamPlayers[i] = client;
+ sortedTeamPlayers[ i ] = client;
cgs.clientinfo[ client ].location = atoi( CG_Argv( i * 6 + 3 ) );
cgs.clientinfo[ client ].health = atoi( CG_Argv( i * 6 + 4 ) );
@@ -110,23 +93,18 @@ This is called explicitly when the gamestate is first received,
and whenever the server updates any serverinfo flagged cvars
================
*/
-void CG_ParseServerinfo( void ) {
+void CG_ParseServerinfo( void )
+{
const char *info;
char *mapname;
info = CG_ConfigString( CS_SERVERINFO );
cgs.dmflags = atoi( Info_ValueForKey( info, "dmflags" ) );
cgs.teamflags = atoi( Info_ValueForKey( info, "teamflags" ) );
- cgs.fraglimit = atoi( Info_ValueForKey( info, "fraglimit" ) );
- cgs.capturelimit = atoi( Info_ValueForKey( info, "capturelimit" ) );
cgs.timelimit = atoi( Info_ValueForKey( info, "timelimit" ) );
cgs.maxclients = atoi( Info_ValueForKey( info, "sv_maxclients" ) );
mapname = Info_ValueForKey( info, "mapname" );
Com_sprintf( cgs.mapname, sizeof( cgs.mapname ), "maps/%s.bsp", mapname );
- Q_strncpyz( cgs.redTeam, Info_ValueForKey( info, "g_redTeam" ), sizeof(cgs.redTeam) );
- trap_Cvar_Set("g_redTeam", cgs.redTeam);
- Q_strncpyz( cgs.blueTeam, Info_ValueForKey( info, "g_blueTeam" ), sizeof(cgs.blueTeam) );
- trap_Cvar_Set("g_blueTeam", cgs.blueTeam);
}
/*
@@ -134,20 +112,21 @@ void CG_ParseServerinfo( void ) {
CG_ParseWarmup
==================
*/
-static void CG_ParseWarmup( void ) {
+static void CG_ParseWarmup( void )
+{
const char *info;
- int warmup;
+ int warmup;
info = CG_ConfigString( CS_WARMUP );
warmup = atoi( info );
cg.warmupCount = -1;
- if ( warmup == 0 && cg.warmup ) {
-
- } else if ( warmup > 0 && cg.warmup <= 0 ) {
- trap_S_StartLocalSound( cgs.media.countPrepareSound, CHAN_ANNOUNCER );
+ if( warmup == 0 && cg.warmup )
+ {
}
+ else if( warmup > 0 && cg.warmup <= 0 )
+ trap_S_StartLocalSound( cgs.media.countPrepareSound, CHAN_ANNOUNCER );
cg.warmup = warmup;
}
@@ -185,38 +164,48 @@ void CG_SetConfigValues( void )
CG_ShaderStateChanged
=====================
*/
-void CG_ShaderStateChanged(void) {
- char originalShader[MAX_QPATH];
- char newShader[MAX_QPATH];
- char timeOffset[16];
- const char *o;
- char *n,*t;
+void CG_ShaderStateChanged( void )
+{
+ char originalShader[ MAX_QPATH ];
+ char newShader[ MAX_QPATH ];
+ char timeOffset[ 16 ];
+ const char *o;
+ char *n, *t;
o = CG_ConfigString( CS_SHADERSTATE );
- while (o && *o) {
- n = strstr(o, "=");
- if (n && *n) {
- strncpy(originalShader, o, n-o);
- originalShader[n-o] = 0;
+
+ while( o && *o )
+ {
+ n = strstr( o, "=" );
+
+ if( n && *n )
+ {
+ strncpy( originalShader, o, n - o );
+ originalShader[ n - o ] = 0;
n++;
- t = strstr(n, ":");
- if (t && *t) {
- strncpy(newShader, n, t-n);
- newShader[t-n] = 0;
- } else {
- break;
+ t = strstr( n, ":" );
+
+ if( t && *t )
+ {
+ strncpy( newShader, n, t - n );
+ newShader[ t - n ] = 0;
}
+ else
+ break;
+
t++;
- o = strstr(t, "@");
- if (o) {
- strncpy(timeOffset, t, o-t);
- timeOffset[o-t] = 0;
+ o = strstr( t, "@" );
+
+ if( o )
+ {
+ strncpy( timeOffset, t, o - t );
+ timeOffset[ o - t ] = 0;
o++;
trap_R_RemapShader( originalShader, newShader, timeOffset );
}
- } else {
- break;
}
+ else
+ break;
}
}
@@ -254,9 +243,10 @@ CG_ConfigStringModified
================
*/
-static void CG_ConfigStringModified( void ) {
+static void CG_ConfigStringModified( void )
+{
const char *str;
- int num;
+ int num;
num = atoi( CG_Argv( 1 ) );
@@ -268,23 +258,23 @@ static void CG_ConfigStringModified( void ) {
str = CG_ConfigString( num );
// do something with it if necessary
- if ( num == CS_MUSIC ) {
- CG_StartMusic();
- } else if ( num == CS_SERVERINFO ) {
- CG_ParseServerinfo();
- } else if ( num == CS_WARMUP ) {
- CG_ParseWarmup();
- } else if ( num == CS_SCORES1 ) {
+ if( num == CS_MUSIC )
+ CG_StartMusic( );
+ else if( num == CS_SERVERINFO )
+ CG_ParseServerinfo( );
+ else if( num == CS_WARMUP )
+ CG_ParseWarmup( );
+ else if( num == CS_SCORES1 )
cgs.scores1 = atoi( str );
- } else if ( num == CS_SCORES2 ) {
+ else if( num == CS_SCORES2 )
cgs.scores2 = atoi( str );
- } else if( num == CS_BUILDPOINTS ) {
+ else if( num == CS_BUILDPOINTS )
sscanf( str, "%d %d %d %d %d", &cgs.alienBuildPoints,
&cgs.alienBuildPointsTotal,
&cgs.humanBuildPoints,
&cgs.humanBuildPointsTotal,
&cgs.humanBuildPointsPowered );
- } else if( num == CS_STAGES )
+ else if( num == CS_STAGES )
{
stage_t oldAlienStage = cgs.alienStage;
stage_t oldHumanStage = cgs.humanStage;
@@ -297,49 +287,67 @@ static void CG_ConfigStringModified( void ) {
if( cgs.humanStage != oldHumanStage )
CG_AnnounceHumanStageTransistion( oldHumanStage, cgs.humanStage );
}
- else if ( num == CS_LEVEL_START_TIME ) {
+ else if( num == CS_LEVEL_START_TIME )
cgs.levelStartTime = atoi( str );
- } else if ( num == CS_VOTE_TIME ) {
+ else if( num == CS_VOTE_TIME )
+ {
cgs.voteTime = atoi( str );
cgs.voteModified = qtrue;
- } else if ( num == CS_VOTE_YES ) {
+ }
+ else if( num == CS_VOTE_YES )
+ {
cgs.voteYes = atoi( str );
cgs.voteModified = qtrue;
- } else if ( num == CS_VOTE_NO ) {
+ }
+ else if( num == CS_VOTE_NO )
+ {
cgs.voteNo = atoi( str );
cgs.voteModified = qtrue;
- } else if ( num == CS_VOTE_STRING ) {
+ }
+ else if( num == CS_VOTE_STRING )
Q_strncpyz( cgs.voteString, str, sizeof( cgs.voteString ) );
- } else if ( num >= CS_TEAMVOTE_TIME && num <= CS_TEAMVOTE_TIME + 1) {
- cgs.teamVoteTime[num-CS_TEAMVOTE_TIME] = atoi( str );
- cgs.teamVoteModified[num-CS_TEAMVOTE_TIME] = qtrue;
- } else if ( num >= CS_TEAMVOTE_YES && num <= CS_TEAMVOTE_YES + 1) {
- cgs.teamVoteYes[num-CS_TEAMVOTE_YES] = atoi( str );
- cgs.teamVoteModified[num-CS_TEAMVOTE_YES] = qtrue;
- } else if ( num >= CS_TEAMVOTE_NO && num <= CS_TEAMVOTE_NO + 1) {
- cgs.teamVoteNo[num-CS_TEAMVOTE_NO] = atoi( str );
- cgs.teamVoteModified[num-CS_TEAMVOTE_NO] = qtrue;
- } else if ( num >= CS_TEAMVOTE_STRING && num <= CS_TEAMVOTE_STRING + 1) {
- Q_strncpyz( cgs.teamVoteString[num-CS_TEAMVOTE_STRING], str, sizeof( cgs.teamVoteString ) );
- } else if ( num == CS_INTERMISSION ) {
+ else if( num >= CS_TEAMVOTE_TIME && num <= CS_TEAMVOTE_TIME + 1 )
+ {
+ cgs.teamVoteTime[ num - CS_TEAMVOTE_TIME ] = atoi( str );
+ cgs.teamVoteModified[ num - CS_TEAMVOTE_TIME ] = qtrue;
+ }
+ else if( num >= CS_TEAMVOTE_YES && num <= CS_TEAMVOTE_YES + 1 )
+ {
+ cgs.teamVoteYes[ num - CS_TEAMVOTE_YES ] = atoi( str );
+ cgs.teamVoteModified[ num - CS_TEAMVOTE_YES ] = qtrue;
+ }
+ else if( num >= CS_TEAMVOTE_NO && num <= CS_TEAMVOTE_NO + 1 )
+ {
+ cgs.teamVoteNo[ num - CS_TEAMVOTE_NO ] = atoi( str );
+ cgs.teamVoteModified[ num - CS_TEAMVOTE_NO ] = qtrue;
+ }
+ else if( num >= CS_TEAMVOTE_STRING && num <= CS_TEAMVOTE_STRING + 1 )
+ Q_strncpyz( cgs.teamVoteString[ num - CS_TEAMVOTE_STRING ], str, sizeof( cgs.teamVoteString ) );
+ else if( num == CS_INTERMISSION )
cg.intermissionStarted = atoi( str );
- } else if ( num >= CS_MODELS && num < CS_MODELS+MAX_MODELS ) {
- cgs.gameModels[ num-CS_MODELS ] = trap_R_RegisterModel( str );
- } else if ( num >= CS_SHADERS && num < CS_SHADERS+MAX_SHADERS ) {
- cgs.gameShaders[ num-CS_SHADERS ] = trap_R_RegisterShader( str );
- } else if ( num >= CS_SOUNDS && num < CS_SOUNDS+MAX_SOUNDS ) {
- if ( str[0] != '*' ) { // player specific sounds don't register here
- cgs.gameSounds[ num-CS_SOUNDS] = trap_S_RegisterSound( str, qfalse );
+ else if( num >= CS_MODELS && num < CS_MODELS+MAX_MODELS )
+ cgs.gameModels[ num - CS_MODELS ] = trap_R_RegisterModel( str );
+ else if( num >= CS_SHADERS && num < CS_SHADERS+MAX_SHADERS )
+ cgs.gameShaders[ num - CS_SHADERS ] = trap_R_RegisterShader( str );
+ else if( num >= CS_SOUNDS && num < CS_SOUNDS+MAX_SOUNDS )
+ {
+ if( str[ 0 ] != '*' )
+ { // player specific sounds don't register here
+ cgs.gameSounds[ num - CS_SOUNDS ] = trap_S_RegisterSound( str, qfalse );
}
- } else if ( num >= CS_PLAYERS && num < CS_PLAYERS+MAX_CLIENTS ) {
+ }
+ else if( num >= CS_PLAYERS && num < CS_PLAYERS+MAX_CLIENTS )
+ {
CG_NewClientInfo( num - CS_PLAYERS );
- CG_BuildSpectatorString();
- } else if ( num == CS_FLAGSTATUS ) {
+ CG_BuildSpectatorString( );
}
- else if ( num == CS_SHADERSTATE ) {
- CG_ShaderStateChanged();
+ else if( num == CS_FLAGSTATUS )
+ {
+ }
+ else if( num == CS_SHADERSTATE )
+ {
+ CG_ShaderStateChanged( );
}
-
}
@@ -349,19 +357,20 @@ CG_AddToTeamChat
=======================
*/
-static void CG_AddToTeamChat( const char *str ) {
- int len;
- char *p, *ls;
- int lastcolor;
- int chatHeight;
+static void CG_AddToTeamChat( const char *str )
+{
+ int len;
+ char *p, *ls;
+ int lastcolor;
+ int chatHeight;
- if (cg_teamChatHeight.integer < TEAMCHAT_HEIGHT) {
+ if( cg_teamChatHeight.integer < TEAMCHAT_HEIGHT )
chatHeight = cg_teamChatHeight.integer;
- } else {
+ else
chatHeight = TEAMCHAT_HEIGHT;
- }
- if (chatHeight <= 0 || cg_teamChatTime.integer <= 0) {
+ if( chatHeight <= 0 || cg_teamChatTime.integer <= 0 )
+ {
// team chat disabled, dump into normal chat
cgs.teamChatPos = cgs.teamLastChatPos = 0;
return;
@@ -375,19 +384,23 @@ static void CG_AddToTeamChat( const char *str ) {
lastcolor = '7';
ls = NULL;
- while (*str) {
- if (len > TEAMCHAT_WIDTH - 1) {
- if (ls) {
- str -= (p - ls);
+ while( *str )
+ {
+ if( len > TEAMCHAT_WIDTH - 1 )
+ {
+ if( ls )
+ {
+ str -= ( p - ls );
str++;
- p -= (p - ls);
+ p -= ( p - ls );
}
+
*p = 0;
- cgs.teamChatMsgTimes[cgs.teamChatPos % chatHeight] = cg.time;
+ cgs.teamChatMsgTimes[ cgs.teamChatPos % chatHeight ] = cg.time;
cgs.teamChatPos++;
- p = cgs.teamChatMsgs[cgs.teamChatPos % chatHeight];
+ p = cgs.teamChatMsgs[ cgs.teamChatPos % chatHeight ];
*p = 0;
*p++ = Q_COLOR_ESCAPE;
*p++ = lastcolor;
@@ -395,24 +408,26 @@ static void CG_AddToTeamChat( const char *str ) {
ls = NULL;
}
- if ( Q_IsColorString( str ) ) {
+ if( Q_IsColorString( str ) )
+ {
*p++ = *str++;
lastcolor = *str;
*p++ = *str++;
continue;
}
- if (*str == ' ') {
+
+ if( *str == ' ' )
ls = p;
- }
+
*p++ = *str++;
len++;
}
*p = 0;
- cgs.teamChatMsgTimes[cgs.teamChatPos % chatHeight] = cg.time;
+ cgs.teamChatMsgTimes[ cgs.teamChatPos % chatHeight ] = cg.time;
cgs.teamChatPos++;
- if (cgs.teamChatPos - cgs.teamLastChatPos > chatHeight)
+ if( cgs.teamChatPos - cgs.teamLastChatPos > chatHeight )
cgs.teamLastChatPos = cgs.teamChatPos - chatHeight;
}
@@ -429,16 +444,16 @@ A tournement restart will clear everything, but doesn't
require a reload of all the media
===============
*/
-static void CG_MapRestart( void ) {
- if ( cg_showmiss.integer ) {
+static void CG_MapRestart( void )
+{
+ if( cg_showmiss.integer )
CG_Printf( "CG_MapRestart\n" );
- }
- CG_InitLocalEntities();
- CG_InitMarkPolys();
+ CG_InitLocalEntities( );
+ CG_InitMarkPolys( );
// Ridah, trails
- CG_ClearTrails ();
+ CG_ClearTrails( );
// done.
// make sure the "3 frags left" warnings play again
@@ -452,9 +467,9 @@ static void CG_MapRestart( void ) {
cg.mapRestart = qtrue;
- CG_StartMusic();
+ CG_StartMusic( );
- trap_S_ClearLoopingSounds(qtrue);
+ trap_S_ClearLoopingSounds( qtrue );
// we really should clear more parts of cg here and stop sounds
@@ -462,470 +477,10 @@ static void CG_MapRestart( void ) {
if( cg.warmup == 0 )
{
trap_S_StartLocalSound( cgs.media.countFightSound, CHAN_ANNOUNCER );
- CG_CenterPrint( "FIGHT!", 120, GIANTCHAR_WIDTH*2 );
- }
- trap_Cvar_Set("cg_thirdPerson", "0");
-}
-
-#define MAX_VOICEFILESIZE 16384
-#define MAX_VOICEFILES 8
-#define MAX_VOICECHATS 64
-#define MAX_VOICESOUNDS 64
-#define MAX_CHATSIZE 64
-#define MAX_HEADMODELS 64
-
-typedef struct voiceChat_s
-{
- char id[64];
- int numSounds;
- sfxHandle_t sounds[MAX_VOICESOUNDS];
- char chats[MAX_VOICESOUNDS][MAX_CHATSIZE];
-} voiceChat_t;
-
-typedef struct voiceChatList_s
-{
- char name[64];
- int gender;
- int numVoiceChats;
- voiceChat_t voiceChats[MAX_VOICECHATS];
-} voiceChatList_t;
-
-typedef struct headModelVoiceChat_s
-{
- char headmodel[64];
- int voiceChatNum;
-} headModelVoiceChat_t;
-
-voiceChatList_t voiceChatLists[MAX_VOICEFILES];
-headModelVoiceChat_t headModelVoiceChat[MAX_HEADMODELS];
-
-/*
-=================
-CG_ParseVoiceChats
-=================
-*/
-int CG_ParseVoiceChats( const char *filename, voiceChatList_t *voiceChatList, int maxVoiceChats ) {
- int len, i;
- fileHandle_t f;
- char buf[MAX_VOICEFILESIZE];
- char **p, *ptr;
- char *token;
- voiceChat_t *voiceChats;
- qboolean compress;
-
- compress = qtrue;
- if (cg_buildScript.integer) {
- compress = qfalse;
- }
-
- len = trap_FS_FOpenFile( filename, &f, FS_READ );
- if ( !f ) {
- //trap_Print( va( S_COLOR_RED "voice chat file not found: %s\n", filename ) );
- return qfalse;
- }
- if ( len >= MAX_VOICEFILESIZE ) {
- trap_Print( va( S_COLOR_RED "voice chat file too large: %s is %i, max allowed is %i", filename, len, MAX_VOICEFILESIZE ) );
- trap_FS_FCloseFile( f );
- return qfalse;
- }
-
- trap_FS_Read( buf, len, f );
- buf[len] = 0;
- trap_FS_FCloseFile( f );
-
- ptr = buf;
- p = &ptr;
-
- Com_sprintf(voiceChatList->name, sizeof(voiceChatList->name), "%s", filename);
- voiceChats = voiceChatList->voiceChats;
- for ( i = 0; i < maxVoiceChats; i++ ) {
- voiceChats[i].id[0] = 0;
- }
- token = COM_ParseExt(p, qtrue);
- if (!token || token[0] == 0) {
- return qtrue;
- }
- if (!Q_stricmp(token, "female")) {
- voiceChatList->gender = GENDER_FEMALE;
- }
- else if (!Q_stricmp(token, "male")) {
- voiceChatList->gender = GENDER_MALE;
- }
- else if (!Q_stricmp(token, "neuter")) {
- voiceChatList->gender = GENDER_NEUTER;
- }
- else {
- trap_Print( va( S_COLOR_RED "expected gender not found in voice chat file: %s\n", filename ) );
- return qfalse;
- }
-
- voiceChatList->numVoiceChats = 0;
- while ( 1 ) {
- token = COM_ParseExt(p, qtrue);
- if (!token || token[0] == 0) {
- return qtrue;
- }
- Com_sprintf(voiceChats[voiceChatList->numVoiceChats].id, sizeof( voiceChats[voiceChatList->numVoiceChats].id ), "%s", token);
- token = COM_ParseExt(p, qtrue);
- if (Q_stricmp(token, "{")) {
- trap_Print( va( S_COLOR_RED "expected { found %s in voice chat file: %s\n", token, filename ) );
- return qfalse;
- }
- voiceChats[voiceChatList->numVoiceChats].numSounds = 0;
- while(1) {
- token = COM_ParseExt(p, qtrue);
- if (!token || token[0] == 0) {
- return qtrue;
- }
- if (!Q_stricmp(token, "}"))
- break;
- voiceChats[voiceChatList->numVoiceChats].sounds[voiceChats[voiceChatList->numVoiceChats].numSounds] =
- trap_S_RegisterSound( token , compress );
- token = COM_ParseExt(p, qtrue);
- if (!token || token[0] == 0) {
- return qtrue;
- }
- Com_sprintf(voiceChats[voiceChatList->numVoiceChats].chats[
- voiceChats[voiceChatList->numVoiceChats].numSounds], MAX_CHATSIZE, "%s", token);
- voiceChats[voiceChatList->numVoiceChats].numSounds++;
- if (voiceChats[voiceChatList->numVoiceChats].numSounds >= MAX_VOICESOUNDS)
- break;
- }
- voiceChatList->numVoiceChats++;
- if (voiceChatList->numVoiceChats >= maxVoiceChats)
- return qtrue;
- }
- return qtrue;
-}
-
-/*
-=================
-CG_LoadVoiceChats
-=================
-*/
-void CG_LoadVoiceChats( void ) {
- int size;
-
- size = trap_MemoryRemaining();
- CG_ParseVoiceChats( "scripts/female1.voice", &voiceChatLists[0], MAX_VOICECHATS );
- CG_ParseVoiceChats( "scripts/female2.voice", &voiceChatLists[1], MAX_VOICECHATS );
- CG_ParseVoiceChats( "scripts/female3.voice", &voiceChatLists[2], MAX_VOICECHATS );
- CG_ParseVoiceChats( "scripts/male1.voice", &voiceChatLists[3], MAX_VOICECHATS );
- CG_ParseVoiceChats( "scripts/male2.voice", &voiceChatLists[4], MAX_VOICECHATS );
- CG_ParseVoiceChats( "scripts/male3.voice", &voiceChatLists[5], MAX_VOICECHATS );
- CG_ParseVoiceChats( "scripts/male4.voice", &voiceChatLists[6], MAX_VOICECHATS );
- CG_ParseVoiceChats( "scripts/male5.voice", &voiceChatLists[7], MAX_VOICECHATS );
- CG_Printf("voice chat memory size = %d\n", size - trap_MemoryRemaining());
-}
-
-/*
-=================
-CG_HeadModelVoiceChats
-=================
-*/
-int CG_HeadModelVoiceChats( char *filename ) {
- int len, i;
- fileHandle_t f;
- char buf[MAX_VOICEFILESIZE];
- char **p, *ptr;
- char *token;
-
- len = trap_FS_FOpenFile( filename, &f, FS_READ );
- if ( !f ) {
- trap_Print( va( "voice chat file not found: %s\n", filename ) );
- return -1;
- }
- if ( len >= MAX_VOICEFILESIZE ) {
- trap_Print( va( S_COLOR_RED "voice chat file too large: %s is %i, max allowed is %i", filename, len, MAX_VOICEFILESIZE ) );
- trap_FS_FCloseFile( f );
- return -1;
- }
-
- trap_FS_Read( buf, len, f );
- buf[len] = 0;
- trap_FS_FCloseFile( f );
-
- ptr = buf;
- p = &ptr;
-
- token = COM_ParseExt(p, qtrue);
- if (!token || token[0] == 0) {
- return -1;
- }
-
- for ( i = 0; i < MAX_VOICEFILES; i++ ) {
- if ( !Q_stricmp(token, voiceChatLists[i].name) ) {
- return i;
- }
- }
-
- //FIXME: maybe try to load the .voice file which name is stored in token?
-
- return -1;
-}
-
-/*
-=================
-CG_GetVoiceChat
-=================
-*/
-int CG_GetVoiceChat( voiceChatList_t *voiceChatList, const char *id, sfxHandle_t *snd, char **chat) {
- int i, rnd;
-
- for ( i = 0; i < voiceChatList->numVoiceChats; i++ ) {
- if ( !Q_stricmp( id, voiceChatList->voiceChats[i].id ) ) {
- rnd = random() * voiceChatList->voiceChats[i].numSounds;
- *snd = voiceChatList->voiceChats[i].sounds[rnd];
- *chat = voiceChatList->voiceChats[i].chats[rnd];
- return qtrue;
- }
+ CG_CenterPrint( "FIGHT!", 120, GIANTCHAR_WIDTH * 2 );
}
- return qfalse;
-}
-
-/*
-=================
-CG_VoiceChatListForClient
-=================
-*/
-voiceChatList_t *CG_VoiceChatListForClient( int clientNum ) {
- clientInfo_t *ci;
- int voiceChatNum, i, j, k, gender;
- char filename[MAX_QPATH], headModelName[MAX_QPATH];
- if ( clientNum < 0 || clientNum >= MAX_CLIENTS ) {
- clientNum = 0;
- }
- ci = &cgs.clientinfo[ clientNum ];
-
- for ( k = 0; k < 2; k++ ) {
- if ( k == 0 ) {
- if (ci->headModelName[0] == '*') {
- Com_sprintf( headModelName, sizeof(headModelName), "%s/%s", ci->headModelName+1, ci->headSkinName );
- }
- else {
- Com_sprintf( headModelName, sizeof(headModelName), "%s/%s", ci->headModelName, ci->headSkinName );
- }
- }
- else {
- if (ci->headModelName[0] == '*') {
- Com_sprintf( headModelName, sizeof(headModelName), "%s", ci->headModelName+1 );
- }
- else {
- Com_sprintf( headModelName, sizeof(headModelName), "%s", ci->headModelName );
- }
- }
- // find the voice file for the head model the client uses
- for ( i = 0; i < MAX_HEADMODELS; i++ ) {
- if (!Q_stricmp(headModelVoiceChat[i].headmodel, headModelName)) {
- break;
- }
- }
- if (i < MAX_HEADMODELS) {
- return &voiceChatLists[headModelVoiceChat[i].voiceChatNum];
- }
- // find a <headmodelname>.vc file
- for ( i = 0; i < MAX_HEADMODELS; i++ ) {
- if (!strlen(headModelVoiceChat[i].headmodel)) {
- Com_sprintf(filename, sizeof(filename), "scripts/%s.vc", headModelName);
- voiceChatNum = CG_HeadModelVoiceChats(filename);
- if (voiceChatNum == -1)
- break;
- Com_sprintf(headModelVoiceChat[i].headmodel, sizeof ( headModelVoiceChat[i].headmodel ),
- "%s", headModelName);
- headModelVoiceChat[i].voiceChatNum = voiceChatNum;
- return &voiceChatLists[headModelVoiceChat[i].voiceChatNum];
- }
- }
- }
- gender = ci->gender;
- for (k = 0; k < 2; k++) {
- // just pick the first with the right gender
- for ( i = 0; i < MAX_VOICEFILES; i++ ) {
- if (strlen(voiceChatLists[i].name)) {
- if (voiceChatLists[i].gender == gender) {
- // store this head model with voice chat for future reference
- for ( j = 0; j < MAX_HEADMODELS; j++ ) {
- if (!strlen(headModelVoiceChat[j].headmodel)) {
- Com_sprintf(headModelVoiceChat[j].headmodel, sizeof ( headModelVoiceChat[j].headmodel ),
- "%s", headModelName);
- headModelVoiceChat[j].voiceChatNum = i;
- break;
- }
- }
- return &voiceChatLists[i];
- }
- }
- }
- // fall back to male gender because we don't have neuter in the mission pack
- if (gender == GENDER_MALE)
- break;
- gender = GENDER_MALE;
- }
- // store this head model with voice chat for future reference
- for ( j = 0; j < MAX_HEADMODELS; j++ ) {
- if (!strlen(headModelVoiceChat[j].headmodel)) {
- Com_sprintf(headModelVoiceChat[j].headmodel, sizeof ( headModelVoiceChat[j].headmodel ),
- "%s", headModelName);
- headModelVoiceChat[j].voiceChatNum = 0;
- break;
- }
- }
- // just return the first voice chat list
- return &voiceChatLists[0];
-}
-
-#define MAX_VOICECHATBUFFER 32
-
-typedef struct bufferedVoiceChat_s
-{
- int clientNum;
- sfxHandle_t snd;
- int voiceOnly;
- char cmd[MAX_SAY_TEXT];
- char message[MAX_SAY_TEXT];
-} bufferedVoiceChat_t;
-
-bufferedVoiceChat_t voiceChatBuffer[MAX_VOICECHATBUFFER];
-
-/*
-=================
-CG_PlayVoiceChat
-=================
-*/
-void CG_PlayVoiceChat( bufferedVoiceChat_t *vchat ) {
-#ifdef MISSIONPACK
- // if we are going into the intermission, don't start any voices
- if ( cg.intermissionStarted ) {
- return;
- }
-
- if ( !cg_noVoiceChats.integer ) {
- trap_S_StartLocalSound( vchat->snd, CHAN_VOICE);
- }
- if (!vchat->voiceOnly && !cg_noVoiceText.integer) {
- CG_AddToTeamChat( vchat->message );
- CG_Printf( "%s\n", vchat->message );
- }
- voiceChatBuffer[cg.voiceChatBufferOut].snd = 0;
-#endif
-}
-
-/*
-=====================
-CG_PlayBufferedVoiceChats
-=====================
-*/
-void CG_PlayBufferedVoiceChats( void ) {
-#ifdef MISSIONPACK
- if ( voiceChatTime < cg.time ) {
- if (voiceChatBufferOut != voiceChatBufferIn && voiceChatBuffer[voiceChatBufferOut].snd) {
- //
- CG_PlayVoiceChat(&voiceChatBuffer[voiceChatBufferOut]);
- //
- voiceChatBufferOut = (voiceChatBufferOut + 1) % MAX_VOICECHATBUFFER;
- voiceChatTime = cg.time + 1000;
- }
- }
-#endif
-}
-
-/*
-=====================
-CG_AddBufferedVoiceChat
-=====================
-*/
-void CG_AddBufferedVoiceChat( bufferedVoiceChat_t *vchat ) {
-#ifdef MISSIONPACK
- // if we are going into the intermission, don't start any voices
- if ( cg.intermissionStarted ) {
- return;
- }
-
- memcpy(&voiceChatBuffer[cg.voiceChatBufferIn], vchat, sizeof(bufferedVoiceChat_t));
- cg.voiceChatBufferIn = (cg.voiceChatBufferIn + 1) % MAX_VOICECHATBUFFER;
- if (cg.voiceChatBufferIn == cg.voiceChatBufferOut) {
- CG_PlayVoiceChat( &voiceChatBuffer[cg.voiceChatBufferOut] );
- cg.voiceChatBufferOut++;
- }
-#endif
-}
-
-/*
-=================
-CG_VoiceChatLocal
-=================
-*/
-void CG_VoiceChatLocal( int mode, qboolean voiceOnly, int clientNum, int color, const char *cmd ) {
-#ifdef MISSIONPACK
- char *chat;
- voiceChatList_t *voiceChatList;
- clientInfo_t *ci;
- sfxHandle_t snd;
- bufferedVoiceChat_t vchat;
-
- // if we are going into the intermission, don't start any voices
- if ( cg.intermissionStarted ) {
- return;
- }
-
- if ( clientNum < 0 || clientNum >= MAX_CLIENTS ) {
- clientNum = 0;
- }
- ci = &cgs.clientinfo[ clientNum ];
-
- cgs.currentVoiceClient = clientNum;
-
- voiceChatList = CG_VoiceChatListForClient( clientNum );
-
- if ( CG_GetVoiceChat( voiceChatList, cmd, &snd, &chat ) ) {
- //
- if ( mode == SAY_TEAM || !cg_teamChatsOnly.integer ) {
- vchat.clientNum = clientNum;
- vchat.snd = snd;
- vchat.voiceOnly = voiceOnly;
- Q_strncpyz(vchat.cmd, cmd, sizeof(vchat.cmd));
- if ( mode == SAY_TELL ) {
- Com_sprintf(vchat.message, sizeof(vchat.message), "[%s]: %c%c%s", ci->name, Q_COLOR_ESCAPE, color, chat);
- }
- else if ( mode == SAY_TEAM ) {
- Com_sprintf(vchat.message, sizeof(vchat.message), "(%s): %c%c%s", ci->name, Q_COLOR_ESCAPE, color, chat);
- }
- else {
- Com_sprintf(vchat.message, sizeof(vchat.message), "%s: %c%c%s", ci->name, Q_COLOR_ESCAPE, color, chat);
- }
- CG_AddBufferedVoiceChat(&vchat);
- }
- }
-#endif
-}
-
-/*
-=================
-CG_VoiceChat
-=================
-*/
-void CG_VoiceChat( int mode ) {
-#ifdef MISSIONPACK
- const char *cmd;
- int clientNum, color;
- qboolean voiceOnly;
-
- voiceOnly = atoi(CG_Argv(1));
- clientNum = atoi(CG_Argv(2));
- color = atoi(CG_Argv(3));
- cmd = CG_Argv(4);
-
- if (cg_noTaunt.integer != 0) {
- /*if (!strcmp(cmd, VOICECHAT_KILLINSULT) || !strcmp(cmd, VOICECHAT_TAUNT) || \
- !strcmp(cmd, VOICECHAT_DEATHINSULT) || !strcmp(cmd, VOICECHAT_KILLGAUNTLET) || \
- !strcmp(cmd, VOICECHAT_PRAISE)) {
- return;
- }*/
- }
-
- CG_VoiceChatLocal( mode, voiceOnly, clientNum, color, cmd );
-#endif
+ trap_Cvar_Set( "cg_thirdPerson", "0" );
}
/*
@@ -933,16 +488,20 @@ void CG_VoiceChat( int mode ) {
CG_RemoveChatEscapeChar
=================
*/
-static void CG_RemoveChatEscapeChar( char *text ) {
+static void CG_RemoveChatEscapeChar( char *text )
+{
int i, l;
l = 0;
- for ( i = 0; text[i]; i++ ) {
- if (text[i] == '\x19')
+ for( i = 0; text[ i ]; i++ )
+ {
+ if( text[ i ] == '\x19' )
continue;
- text[l++] = text[i];
+
+ text[ l++ ] = text[ i ];
}
- text[l] = '\0';
+
+ text[ l ] = '\0';
}
/*
@@ -953,95 +512,95 @@ The string has been tokenized and can be retrieved with
Cmd_Argc() / Cmd_Argv()
=================
*/
-static void CG_ServerCommand( void ) {
+static void CG_ServerCommand( void )
+{
const char *cmd;
- char text[MAX_SAY_TEXT];
+ char text[ MAX_SAY_TEXT ];
- cmd = CG_Argv(0);
+ cmd = CG_Argv( 0 );
- if ( !cmd[0] ) {
+ if( !cmd[ 0 ] )
+ {
// server claimed the command
return;
}
- if ( !strcmp( cmd, "cp" ) ) {
- CG_CenterPrint( CG_Argv(1), SCREEN_HEIGHT * 0.30, BIGCHAR_WIDTH );
+ if( !strcmp( cmd, "cp" ) )
+ {
+ CG_CenterPrint( CG_Argv( 1 ), SCREEN_HEIGHT * 0.30, BIGCHAR_WIDTH );
return;
}
- if ( !strcmp( cmd, "cs" ) ) {
- CG_ConfigStringModified();
+ if( !strcmp( cmd, "cs" ) )
+ {
+ CG_ConfigStringModified( );
return;
}
- if ( !strcmp( cmd, "print" ) ) {
- CG_Printf( "%s", CG_Argv(1) );
+ if( !strcmp( cmd, "print" ) )
+ {
+ CG_Printf( "%s", CG_Argv( 1 ) );
return;
}
- if ( !strcmp( cmd, "chat" ) ) {
- if ( !cg_teamChatsOnly.integer ) {
+ if( !strcmp( cmd, "chat" ) )
+ {
+ if( !cg_teamChatsOnly.integer )
+ {
trap_S_StartLocalSound( cgs.media.talkSound, CHAN_LOCAL_SOUND );
- Q_strncpyz( text, CG_Argv(1), MAX_SAY_TEXT );
+ Q_strncpyz( text, CG_Argv( 1 ), MAX_SAY_TEXT );
CG_RemoveChatEscapeChar( text );
CG_Printf( "%s\n", text );
}
+
return;
}
- if ( !strcmp( cmd, "tchat" ) ) {
+ if( !strcmp( cmd, "tchat" ) )
+ {
trap_S_StartLocalSound( cgs.media.talkSound, CHAN_LOCAL_SOUND );
- Q_strncpyz( text, CG_Argv(1), MAX_SAY_TEXT );
+ Q_strncpyz( text, CG_Argv( 1 ), MAX_SAY_TEXT );
CG_RemoveChatEscapeChar( text );
CG_AddToTeamChat( text );
CG_Printf( "%s\n", text );
return;
}
- if ( !strcmp( cmd, "vchat" ) ) {
- CG_VoiceChat( SAY_ALL );
- return;
- }
-
- if ( !strcmp( cmd, "vtchat" ) ) {
- CG_VoiceChat( SAY_TEAM );
- return;
- }
-
- if ( !strcmp( cmd, "vtell" ) ) {
- CG_VoiceChat( SAY_TELL );
+
+ if( !strcmp( cmd, "scores" ) )
+ {
+ CG_ParseScores( );
return;
}
- if ( !strcmp( cmd, "scores" ) ) {
- CG_ParseScores();
+ if( !strcmp( cmd, "tinfo" ) )
+ {
+ CG_ParseTeamInfo( );
return;
}
- if ( !strcmp( cmd, "tinfo" ) ) {
- CG_ParseTeamInfo();
+ if( !strcmp( cmd, "map_restart" ) )
+ {
+ CG_MapRestart( );
return;
}
- if ( !strcmp( cmd, "map_restart" ) ) {
- CG_MapRestart();
- return;
+ if( Q_stricmp( cmd, "remapShader" ) == 0 )
+ {
+ if( trap_Argc( ) == 4 )
+ trap_R_RemapShader( CG_Argv( 1 ), CG_Argv( 2 ), CG_Argv( 3 ) );
}
-/* if ( Q_stricmp (cmd, "remapShader") == 0 ) {
- if (trap_Argc() == 4) {
- trap_R_RemapShader(CG_Argv(1), CG_Argv(2), CG_Argv(3));
- }
- }*/
-
// loaddeferred can be both a servercmd and a consolecmd
- if ( !strcmp( cmd, "loaddefered" ) ) { // FIXME: spelled wrong, but not changing for demo
- CG_LoadDeferredPlayers();
+ if( !strcmp( cmd, "loaddefered" ) )
+ { // FIXME: spelled wrong, but not changing for demo
+ CG_LoadDeferredPlayers( );
return;
}
// clientLevelShot is sent before taking a special screenshot for
// the menu system during development
- if ( !strcmp( cmd, "clientLevelShot" ) ) {
+ if( !strcmp( cmd, "clientLevelShot" ) )
+ {
cg.levelShot = qtrue;
return;
}
@@ -1058,10 +617,11 @@ Execute all of the server commands that were received along
with this this snapshot.
====================
*/
-void CG_ExecuteNewServerCommands( int latestSequence ) {
- while ( cgs.serverCommandSequence < latestSequence ) {
- if ( trap_GetServerCommand( ++cgs.serverCommandSequence ) ) {
- CG_ServerCommand();
- }
+void CG_ExecuteNewServerCommands( int latestSequence )
+{
+ while( cgs.serverCommandSequence < latestSequence )
+ {
+ if( trap_GetServerCommand( ++cgs.serverCommandSequence ) )
+ CG_ServerCommand( );
}
}
diff --git a/src/cgame/cg_snapshot.c b/src/cgame/cg_snapshot.c
index 60520dc1..0e8103fb 100644
--- a/src/cgame/cg_snapshot.c
+++ b/src/cgame/cg_snapshot.c
@@ -18,27 +18,25 @@
#include "cg_local.h"
-
-
/*
==================
CG_ResetEntity
==================
*/
-static void CG_ResetEntity( centity_t *cent ) {
+static void CG_ResetEntity( centity_t *cent )
+{
// if the previous snapshot this entity was updated in is at least
// an event window back in time then we can reset the previous event
- if ( cent->snapShotTime < cg.time - EVENT_VALID_MSEC ) {
- cent->previousEvent = 0;
- }
+ if( cent->snapShotTime < cg.time - EVENT_VALID_MSEC )
+ cent->previousEvent = 0;
- cent->trailTime = cg.snap->serverTime;
+ cent->trailTime = cg.snap->serverTime;
- VectorCopy (cent->currentState.origin, cent->lerpOrigin);
- VectorCopy (cent->currentState.angles, cent->lerpAngles);
- if ( cent->currentState.eType == ET_PLAYER ) {
- CG_ResetPlayerEntity( cent );
- }
+ VectorCopy( cent->currentState.origin, cent->lerpOrigin );
+ VectorCopy( cent->currentState.angles, cent->lerpAngles );
+
+ if( cent->currentState.eType == ET_PLAYER )
+ CG_ResetPlayerEntity( cent );
}
/*
@@ -48,20 +46,20 @@ CG_TransitionEntity
cent->nextState is moved to cent->currentState and events are fired
===============
*/
-static void CG_TransitionEntity( centity_t *cent ) {
- cent->currentState = cent->nextState;
- cent->currentValid = qtrue;
+static void CG_TransitionEntity( centity_t *cent )
+{
+ cent->currentState = cent->nextState;
+ cent->currentValid = qtrue;
- // reset if the entity wasn't in the last frame or was teleported
- if ( !cent->interpolate ) {
- CG_ResetEntity( cent );
- }
+ // reset if the entity wasn't in the last frame or was teleported
+ if( !cent->interpolate )
+ CG_ResetEntity( cent );
- // clear the next state. if will be set by the next CG_SetNextSnap
- cent->interpolate = qfalse;
+ // clear the next state. if will be set by the next CG_SetNextSnap
+ cent->interpolate = qfalse;
- // check for events
- CG_CheckEvents( cent );
+ // check for events
+ CG_CheckEvents( cent );
}
@@ -76,38 +74,40 @@ CG_TransitionSnapshot instead.
FIXME: Also called by map_restart?
==================
*/
-void CG_SetInitialSnapshot( snapshot_t *snap ) {
- int i;
- centity_t *cent;
- entityState_t *state;
+void CG_SetInitialSnapshot( snapshot_t *snap )
+{
+ int i;
+ centity_t *cent;
+ entityState_t *state;
- cg.snap = snap;
+ cg.snap = snap;
- BG_PlayerStateToEntityState( &snap->ps, &cg_entities[ snap->ps.clientNum ].currentState, qfalse );
+ BG_PlayerStateToEntityState( &snap->ps, &cg_entities[ snap->ps.clientNum ].currentState, qfalse );
- // sort out solid entities
- CG_BuildSolidList();
+ // sort out solid entities
+ CG_BuildSolidList( );
- CG_ExecuteNewServerCommands( snap->serverCommandSequence );
+ CG_ExecuteNewServerCommands( snap->serverCommandSequence );
- // set our local weapon selection pointer to
- // what the server has indicated the current weapon is
- CG_Respawn();
+ // set our local weapon selection pointer to
+ // what the server has indicated the current weapon is
+ CG_Respawn( );
- for ( i = 0 ; i < cg.snap->numEntities ; i++ ) {
- state = &cg.snap->entities[ i ];
- cent = &cg_entities[ state->number ];
+ for( i = 0; i < cg.snap->numEntities; i++ )
+ {
+ state = &cg.snap->entities[ i ];
+ cent = &cg_entities[ state->number ];
- memcpy(&cent->currentState, state, sizeof(entityState_t));
- //cent->currentState = *state;
- cent->interpolate = qfalse;
- cent->currentValid = qtrue;
+ memcpy( &cent->currentState, state, sizeof( entityState_t ) );
+ //cent->currentState = *state;
+ cent->interpolate = qfalse;
+ cent->currentValid = qtrue;
- CG_ResetEntity( cent );
+ CG_ResetEntity( cent );
- // check for events
- CG_CheckEvents( cent );
- }
+ // check for events
+ CG_CheckEvents( cent );
+ }
}
@@ -118,68 +118,66 @@ CG_TransitionSnapshot
The transition point from snap to nextSnap has passed
===================
*/
-static void CG_TransitionSnapshot( void ) {
- centity_t *cent;
- snapshot_t *oldFrame;
- int i;
-
- if ( !cg.snap ) {
- CG_Error( "CG_TransitionSnapshot: NULL cg.snap" );
- }
- if ( !cg.nextSnap ) {
- CG_Error( "CG_TransitionSnapshot: NULL cg.nextSnap" );
- }
-
- // execute any server string commands before transitioning entities
- CG_ExecuteNewServerCommands( cg.nextSnap->serverCommandSequence );
-
- // if we had a map_restart, set everthing with initial
- if ( !cg.snap ) {
- }
-
- // clear the currentValid flag for all entities in the existing snapshot
- for ( i = 0 ; i < cg.snap->numEntities ; i++ ) {
- cent = &cg_entities[ cg.snap->entities[ i ].number ];
- cent->currentValid = qfalse;
- }
-
- // move nextSnap to snap and do the transitions
- oldFrame = cg.snap;
- cg.snap = cg.nextSnap;
-
- BG_PlayerStateToEntityState( &cg.snap->ps, &cg_entities[ cg.snap->ps.clientNum ].currentState, qfalse );
- cg_entities[ cg.snap->ps.clientNum ].interpolate = qfalse;
-
- for ( i = 0 ; i < cg.snap->numEntities ; i++ ) {
- cent = &cg_entities[ cg.snap->entities[ i ].number ];
- CG_TransitionEntity( cent );
+static void CG_TransitionSnapshot( void )
+{
+ centity_t *cent;
+ snapshot_t *oldFrame;
+ int i;
+
+ if( !cg.snap )
+ CG_Error( "CG_TransitionSnapshot: NULL cg.snap" );
+
+ if( !cg.nextSnap )
+ CG_Error( "CG_TransitionSnapshot: NULL cg.nextSnap" );
+
+ // execute any server string commands before transitioning entities
+ CG_ExecuteNewServerCommands( cg.nextSnap->serverCommandSequence );
+
+ // if we had a map_restart, set everthing with initial
+ if( !cg.snap ) { } //TA: ?
+
+ // clear the currentValid flag for all entities in the existing snapshot
+ for( i = 0; i < cg.snap->numEntities; i++ )
+ {
+ cent = &cg_entities[ cg.snap->entities[ i ].number ];
+ cent->currentValid = qfalse;
+ }
+
+ // move nextSnap to snap and do the transitions
+ oldFrame = cg.snap;
+ cg.snap = cg.nextSnap;
+
+ BG_PlayerStateToEntityState( &cg.snap->ps, &cg_entities[ cg.snap->ps.clientNum ].currentState, qfalse );
+ cg_entities[ cg.snap->ps.clientNum ].interpolate = qfalse;
+
+ for( i = 0; i < cg.snap->numEntities; i++ )
+ {
+ cent = &cg_entities[ cg.snap->entities[ i ].number ];
+ CG_TransitionEntity( cent );
// remember time of snapshot this entity was last updated in
cent->snapShotTime = cg.snap->serverTime;
- }
-
- cg.nextSnap = NULL;
-
- // check for playerstate transition events
- if ( oldFrame ) {
- playerState_t *ops, *ps;
+ }
- ops = &oldFrame->ps;
- ps = &cg.snap->ps;
- // teleporting checks are irrespective of prediction
- if ( ( ps->eFlags ^ ops->eFlags ) & EF_TELEPORT_BIT ) {
- cg.thisFrameTeleport = qtrue; // will be cleared by prediction code
- }
+ cg.nextSnap = NULL;
- // if we are not doing client side movement prediction for any
- // reason, then the client events and view changes will be issued now
- if ( cg.demoPlayback || (cg.snap->ps.pm_flags & PMF_FOLLOW)
- || cg_nopredict.integer || cg_synchronousClients.integer ) {
- CG_TransitionPlayerState( ps, ops );
- }
+ // check for playerstate transition events
+ if( oldFrame )
+ {
+ playerState_t *ops, *ps;
- }
+ ops = &oldFrame->ps;
+ ps = &cg.snap->ps;
+ // teleporting checks are irrespective of prediction
+ if( ( ps->eFlags ^ ops->eFlags ) & EF_TELEPORT_BIT )
+ cg.thisFrameTeleport = qtrue; // will be cleared by prediction code
+ // if we are not doing client side movement prediction for any
+ // reason, then the client events and view changes will be issued now
+ if( cg.demoPlayback || ( cg.snap->ps.pm_flags & PMF_FOLLOW ) ||
+ cg_nopredict.integer || cg_synchronousClients.integer )
+ CG_TransitionPlayerState( ps, ops );
+ }
}
@@ -190,53 +188,51 @@ CG_SetNextSnap
A new snapshot has just been read in from the client system.
===================
*/
-static void CG_SetNextSnap( snapshot_t *snap ) {
- int num;
- entityState_t *es;
- centity_t *cent;
-
- cg.nextSnap = snap;
-
- BG_PlayerStateToEntityState( &snap->ps, &cg_entities[ snap->ps.clientNum ].nextState, qfalse );
- cg_entities[ cg.snap->ps.clientNum ].interpolate = qtrue;
-
- // check for extrapolation errors
- for ( num = 0 ; num < snap->numEntities ; num++ ) {
- es = &snap->entities[num];
- cent = &cg_entities[ es->number ];
-
- memcpy(&cent->nextState, es, sizeof(entityState_t));
- //cent->nextState = *es;
-
- // if this frame is a teleport, or the entity wasn't in the
- // previous frame, don't interpolate
- if ( !cent->currentValid || ( ( cent->currentState.eFlags ^ es->eFlags ) & EF_TELEPORT_BIT ) ) {
- cent->interpolate = qfalse;
- } else {
- cent->interpolate = qtrue;
- }
- }
-
- // if the next frame is a teleport for the playerstate, we
- // can't interpolate during demos
- if ( cg.snap && ( ( snap->ps.eFlags ^ cg.snap->ps.eFlags ) & EF_TELEPORT_BIT ) ) {
- cg.nextFrameTeleport = qtrue;
- } else {
- cg.nextFrameTeleport = qfalse;
- }
-
- // if changing follow mode, don't interpolate
- if ( cg.nextSnap->ps.clientNum != cg.snap->ps.clientNum ) {
- cg.nextFrameTeleport = qtrue;
- }
-
- // if changing server restarts, don't interpolate
- if ( ( cg.nextSnap->snapFlags ^ cg.snap->snapFlags ) & SNAPFLAG_SERVERCOUNT ) {
- cg.nextFrameTeleport = qtrue;
- }
-
- // sort out solid entities
- CG_BuildSolidList();
+static void CG_SetNextSnap( snapshot_t *snap )
+{
+ int num;
+ entityState_t *es;
+ centity_t *cent;
+
+ cg.nextSnap = snap;
+
+ BG_PlayerStateToEntityState( &snap->ps, &cg_entities[ snap->ps.clientNum ].nextState, qfalse );
+ cg_entities[ cg.snap->ps.clientNum ].interpolate = qtrue;
+
+ // check for extrapolation errors
+ for( num = 0 ; num < snap->numEntities ; num++ )
+ {
+ es = &snap->entities[ num ];
+ cent = &cg_entities[ es->number ];
+
+ memcpy( &cent->nextState, es, sizeof( entityState_t ) );
+ //cent->nextState = *es;
+
+ // if this frame is a teleport, or the entity wasn't in the
+ // previous frame, don't interpolate
+ if( !cent->currentValid || ( ( cent->currentState.eFlags ^ es->eFlags ) & EF_TELEPORT_BIT ) )
+ cent->interpolate = qfalse;
+ else
+ cent->interpolate = qtrue;
+ }
+
+ // if the next frame is a teleport for the playerstate, we
+ // can't interpolate during demos
+ if( cg.snap && ( ( snap->ps.eFlags ^ cg.snap->ps.eFlags ) & EF_TELEPORT_BIT ) )
+ cg.nextFrameTeleport = qtrue;
+ else
+ cg.nextFrameTeleport = qfalse;
+
+ // if changing follow mode, don't interpolate
+ if( cg.nextSnap->ps.clientNum != cg.snap->ps.clientNum )
+ cg.nextFrameTeleport = qtrue;
+
+ // if changing server restarts, don't interpolate
+ if( ( cg.nextSnap->snapFlags ^ cg.snap->snapFlags ) & SNAPFLAG_SERVERCOUNT )
+ cg.nextFrameTeleport = qtrue;
+
+ // sort out solid entities
+ CG_BuildSolidList( );
}
@@ -250,52 +246,56 @@ times if the client system fails to return a
valid snapshot.
========================
*/
-static snapshot_t *CG_ReadNextSnapshot( void ) {
- qboolean r;
- snapshot_t *dest;
+static snapshot_t *CG_ReadNextSnapshot( void )
+{
+ qboolean r;
+ snapshot_t *dest;
- if ( cg.latestSnapshotNum > cgs.processedSnapshotNum + 1000 ) {
+ if( cg.latestSnapshotNum > cgs.processedSnapshotNum + 1000 )
+ {
CG_Printf( "WARNING: CG_ReadNextSnapshot: way out of range, %i > %i",
- cg.latestSnapshotNum, cgs.processedSnapshotNum );
- }
+ cg.latestSnapshotNum, cgs.processedSnapshotNum );
+ }
- while ( cgs.processedSnapshotNum < cg.latestSnapshotNum ) {
- // decide which of the two slots to load it into
- if ( cg.snap == &cg.activeSnapshots[0] ) {
- dest = &cg.activeSnapshots[1];
- } else {
- dest = &cg.activeSnapshots[0];
- }
+ while( cgs.processedSnapshotNum < cg.latestSnapshotNum )
+ {
+ // decide which of the two slots to load it into
+ if( cg.snap == &cg.activeSnapshots[ 0 ] )
+ dest = &cg.activeSnapshots[ 1 ];
+ else
+ dest = &cg.activeSnapshots[ 0 ];
- // try to read the snapshot from the client system
- cgs.processedSnapshotNum++;
- r = trap_GetSnapshot( cgs.processedSnapshotNum, dest );
+ // try to read the snapshot from the client system
+ cgs.processedSnapshotNum++;
+ r = trap_GetSnapshot( cgs.processedSnapshotNum, dest );
// FIXME: why would trap_GetSnapshot return a snapshot with the same server time
- if ( cg.snap && r && dest->serverTime == cg.snap->serverTime ) {
+ if( cg.snap && r && dest->serverTime == cg.snap->serverTime )
+ {
//continue;
}
- // if it succeeded, return
- if ( r ) {
- CG_AddLagometerSnapshotInfo( dest );
- return dest;
- }
-
- // a GetSnapshot will return failure if the snapshot
- // never arrived, or is so old that its entities
- // have been shoved off the end of the circular
- // buffer in the client system.
-
- // record as a dropped packet
- CG_AddLagometerSnapshotInfo( NULL );
-
- // If there are additional snapshots, continue trying to
- // read them.
- }
-
- // nothing left to read
- return NULL;
+ // if it succeeded, return
+ if( r )
+ {
+ CG_AddLagometerSnapshotInfo( dest );
+ return dest;
+ }
+
+ // a GetSnapshot will return failure if the snapshot
+ // never arrived, or is so old that its entities
+ // have been shoved off the end of the circular
+ // buffer in the client system.
+
+ // record as a dropped packet
+ CG_AddLagometerSnapshotInfo( NULL );
+
+ // If there are additional snapshots, continue trying to
+ // read them.
+ }
+
+ // nothing left to read
+ return NULL;
}
@@ -318,79 +318,85 @@ of an interpolating one)
============
*/
-void CG_ProcessSnapshots( void ) {
- snapshot_t *snap;
- int n;
-
- // see what the latest snapshot the client system has is
- trap_GetCurrentSnapshotNumber( &n, &cg.latestSnapshotTime );
- if ( n != cg.latestSnapshotNum ) {
- if ( n < cg.latestSnapshotNum ) {
- // this should never happen
- CG_Error( "CG_ProcessSnapshots: n < cg.latestSnapshotNum" );
- }
- cg.latestSnapshotNum = n;
- }
-
- // If we have yet to receive a snapshot, check for it.
- // Once we have gotten the first snapshot, cg.snap will
- // always have valid data for the rest of the game
- while ( !cg.snap ) {
- snap = CG_ReadNextSnapshot();
- if ( !snap ) {
- // we can't continue until we get a snapshot
- return;
- }
-
- // set our weapon selection to what
- // the playerstate is currently using
- if ( !( snap->snapFlags & SNAPFLAG_NOT_ACTIVE ) ) {
- CG_SetInitialSnapshot( snap );
- }
- }
-
- // loop until we either have a valid nextSnap with a serverTime
- // greater than cg.time to interpolate towards, or we run
- // out of available snapshots
- do {
- // if we don't have a nextframe, try and read a new one in
- if ( !cg.nextSnap ) {
- snap = CG_ReadNextSnapshot();
-
- // if we still don't have a nextframe, we will just have to
- // extrapolate
- if ( !snap ) {
- break;
- }
-
- CG_SetNextSnap( snap );
-
- // if time went backwards, we have a level restart
- if ( cg.nextSnap->serverTime < cg.snap->serverTime ) {
- CG_Error( "CG_ProcessSnapshots: Server time went backwards" );
- }
- }
-
- // if our time is < nextFrame's, we have a nice interpolating state
- if ( cg.time >= cg.snap->serverTime && cg.time < cg.nextSnap->serverTime ) {
- break;
- }
-
- // we have passed the transition from nextFrame to frame
- CG_TransitionSnapshot();
- } while ( 1 );
-
- // assert our valid conditions upon exiting
- if ( cg.snap == NULL ) {
- CG_Error( "CG_ProcessSnapshots: cg.snap == NULL" );
- }
- if ( cg.time < cg.snap->serverTime ) {
- // this can happen right after a vid_restart
- cg.time = cg.snap->serverTime;
- }
- if ( cg.nextSnap != NULL && cg.nextSnap->serverTime <= cg.time ) {
- CG_Error( "CG_ProcessSnapshots: cg.nextSnap->serverTime <= cg.time" );
- }
+void CG_ProcessSnapshots( void )
+{
+ snapshot_t *snap;
+ int n;
+
+ // see what the latest snapshot the client system has is
+ trap_GetCurrentSnapshotNumber( &n, &cg.latestSnapshotTime );
+
+ if( n != cg.latestSnapshotNum )
+ {
+ if( n < cg.latestSnapshotNum )
+ {
+ // this should never happen
+ CG_Error( "CG_ProcessSnapshots: n < cg.latestSnapshotNum" );
+ }
+
+ cg.latestSnapshotNum = n;
+ }
+ // If we have yet to receive a snapshot, check for it.
+ // Once we have gotten the first snapshot, cg.snap will
+ // always have valid data for the rest of the game
+ while( !cg.snap )
+ {
+ snap = CG_ReadNextSnapshot( );
+
+ if( !snap )
+ {
+ // we can't continue until we get a snapshot
+ return;
+ }
+
+ // set our weapon selection to what
+ // the playerstate is currently using
+ if( !( snap->snapFlags & SNAPFLAG_NOT_ACTIVE ) )
+ CG_SetInitialSnapshot( snap );
+ }
+
+ // loop until we either have a valid nextSnap with a serverTime
+ // greater than cg.time to interpolate towards, or we run
+ // out of available snapshots
+ do
+ {
+ // if we don't have a nextframe, try and read a new one in
+ if( !cg.nextSnap )
+ {
+ snap = CG_ReadNextSnapshot( );
+
+ // if we still don't have a nextframe, we will just have to
+ // extrapolate
+ if( !snap )
+ break;
+
+ CG_SetNextSnap( snap );
+
+ // if time went backwards, we have a level restart
+ if( cg.nextSnap->serverTime < cg.snap->serverTime )
+ CG_Error( "CG_ProcessSnapshots: Server time went backwards" );
+ }
+
+ // if our time is < nextFrame's, we have a nice interpolating state
+ if( cg.time >= cg.snap->serverTime && cg.time < cg.nextSnap->serverTime )
+ break;
+
+ // we have passed the transition from nextFrame to frame
+ CG_TransitionSnapshot( );
+ } while( 1 );
+
+ // assert our valid conditions upon exiting
+ if( cg.snap == NULL )
+ CG_Error( "CG_ProcessSnapshots: cg.snap == NULL" );
+
+ if( cg.time < cg.snap->serverTime )
+ {
+ // this can happen right after a vid_restart
+ cg.time = cg.snap->serverTime;
+ }
+
+ if( cg.nextSnap != NULL && cg.nextSnap->serverTime <= cg.time )
+ CG_Error( "CG_ProcessSnapshots: cg.nextSnap->serverTime <= cg.time" );
}
diff --git a/src/cgame/cg_syscalls.asm b/src/cgame/cg_syscalls.asm
index 3f26c6dd..6cc032f8 100644
--- a/src/cgame/cg_syscalls.asm
+++ b/src/cgame/cg_syscalls.asm
@@ -1,104 +1,104 @@
code
-equ trap_Print -1
-equ trap_Error -2
-equ trap_Milliseconds -3
-equ trap_Cvar_Register -4
-equ trap_Cvar_Update -5
-equ trap_Cvar_Set -6
-equ trap_Cvar_VariableStringBuffer -7
-equ trap_Argc -8
-equ trap_Argv -9
-equ trap_Args -10
-equ trap_FS_FOpenFile -11
-equ trap_FS_Read -12
-equ trap_FS_Write -13
-equ trap_FS_FCloseFile -14
-equ trap_SendConsoleCommand -15
-equ trap_AddCommand -16
-equ trap_SendClientCommand -17
-equ trap_UpdateScreen -18
-equ trap_CM_LoadMap -19
-equ trap_CM_NumInlineModels -20
-equ trap_CM_InlineModel -21
-equ trap_CM_LoadModel -22
-equ trap_CM_TempBoxModel -23
-equ trap_CM_PointContents -24
-equ trap_CM_TransformedPointContents -25
-equ trap_CM_BoxTrace -26
-equ trap_CM_TransformedBoxTrace -27
-equ trap_CM_MarkFragments -28
-equ trap_S_StartSound -29
-equ trap_S_StartLocalSound -30
-equ trap_S_ClearLoopingSounds -31
-equ trap_S_AddLoopingSound -32
-equ trap_S_UpdateEntityPosition -33
-equ trap_S_Respatialize -34
-equ trap_S_RegisterSound -35
-equ trap_S_StartBackgroundTrack -36
-equ trap_R_LoadWorldMap -37
-equ trap_R_RegisterModel -38
-equ trap_R_RegisterSkin -39
-equ trap_R_RegisterShader -40
-equ trap_R_ClearScene -41
-equ trap_R_AddRefEntityToScene -42
-equ trap_R_AddPolyToScene -43
-equ trap_R_AddLightToScene -44
-equ trap_R_RenderScene -45
-equ trap_R_SetColor -46
-equ trap_R_DrawStretchPic -47
-equ trap_R_ModelBounds -48
-equ trap_R_LerpTag -49
-equ trap_GetGlconfig -50
-equ trap_GetGameState -51
-equ trap_GetCurrentSnapshotNumber -52
-equ trap_GetSnapshot -53
-equ trap_GetServerCommand -54
-equ trap_GetCurrentCmdNumber -55
-equ trap_GetUserCmd -56
-equ trap_SetUserCmdValue -57
-equ trap_R_RegisterShaderNoMip -58
-equ trap_MemoryRemaining -59
-equ trap_R_RegisterFont -60
-equ trap_Key_IsDown -61
-equ trap_Key_GetCatcher -62
-equ trap_Key_SetCatcher -63
-equ trap_Key_GetKey -64
-equ trap_PC_AddGlobalDefine -65
-equ trap_PC_LoadSource -66
-equ trap_PC_FreeSource -67
-equ trap_PC_ReadToken -68
-equ trap_PC_SourceFileAndLine -69
-equ trap_S_StopBackgroundTrack -70
-equ trap_RealTime -71
-equ trap_SnapVector -72
-equ trap_RemoveCommand -73
-equ trap_R_LightForPoint -74
-equ trap_CIN_PlayCinematic -75
-equ trap_CIN_StopCinematic -76
-equ trap_CIN_RunCinematic -77
-equ trap_CIN_DrawCinematic -78
-equ trap_CIN_SetExtents -79
-equ trap_R_RemapShader -80
-equ trap_S_AddRealLoopingSound -81
-equ trap_S_StopLoopingSound -82
-equ trap_CM_TempCapsuleModel -83
-equ trap_CM_CapsuleTrace -84
+equ trap_Print -1
+equ trap_Error -2
+equ trap_Milliseconds -3
+equ trap_Cvar_Register -4
+equ trap_Cvar_Update -5
+equ trap_Cvar_Set -6
+equ trap_Cvar_VariableStringBuffer -7
+equ trap_Argc -8
+equ trap_Argv -9
+equ trap_Args -10
+equ trap_FS_FOpenFile -11
+equ trap_FS_Read -12
+equ trap_FS_Write -13
+equ trap_FS_FCloseFile -14
+equ trap_SendConsoleCommand -15
+equ trap_AddCommand -16
+equ trap_SendClientCommand -17
+equ trap_UpdateScreen -18
+equ trap_CM_LoadMap -19
+equ trap_CM_NumInlineModels -20
+equ trap_CM_InlineModel -21
+equ trap_CM_LoadModel -22
+equ trap_CM_TempBoxModel -23
+equ trap_CM_PointContents -24
+equ trap_CM_TransformedPointContents -25
+equ trap_CM_BoxTrace -26
+equ trap_CM_TransformedBoxTrace -27
+equ trap_CM_MarkFragments -28
+equ trap_S_StartSound -29
+equ trap_S_StartLocalSound -30
+equ trap_S_ClearLoopingSounds -31
+equ trap_S_AddLoopingSound -32
+equ trap_S_UpdateEntityPosition -33
+equ trap_S_Respatialize -34
+equ trap_S_RegisterSound -35
+equ trap_S_StartBackgroundTrack -36
+equ trap_R_LoadWorldMap -37
+equ trap_R_RegisterModel -38
+equ trap_R_RegisterSkin -39
+equ trap_R_RegisterShader -40
+equ trap_R_ClearScene -41
+equ trap_R_AddRefEntityToScene -42
+equ trap_R_AddPolyToScene -43
+equ trap_R_AddLightToScene -44
+equ trap_R_RenderScene -45
+equ trap_R_SetColor -46
+equ trap_R_DrawStretchPic -47
+equ trap_R_ModelBounds -48
+equ trap_R_LerpTag -49
+equ trap_GetGlconfig -50
+equ trap_GetGameState -51
+equ trap_GetCurrentSnapshotNumber -52
+equ trap_GetSnapshot -53
+equ trap_GetServerCommand -54
+equ trap_GetCurrentCmdNumber -55
+equ trap_GetUserCmd -56
+equ trap_SetUserCmdValue -57
+equ trap_R_RegisterShaderNoMip -58
+equ trap_MemoryRemaining -59
+equ trap_R_RegisterFont -60
+equ trap_Key_IsDown -61
+equ trap_Key_GetCatcher -62
+equ trap_Key_SetCatcher -63
+equ trap_Key_GetKey -64
+equ trap_PC_AddGlobalDefine -65
+equ trap_PC_LoadSource -66
+equ trap_PC_FreeSource -67
+equ trap_PC_ReadToken -68
+equ trap_PC_SourceFileAndLine -69
+equ trap_S_StopBackgroundTrack -70
+equ trap_RealTime -71
+equ trap_SnapVector -72
+equ trap_RemoveCommand -73
+equ trap_R_LightForPoint -74
+equ trap_CIN_PlayCinematic -75
+equ trap_CIN_StopCinematic -76
+equ trap_CIN_RunCinematic -77
+equ trap_CIN_DrawCinematic -78
+equ trap_CIN_SetExtents -79
+equ trap_R_RemapShader -80
+equ trap_S_AddRealLoopingSound -81
+equ trap_S_StopLoopingSound -82
+equ trap_CM_TempCapsuleModel -83
+equ trap_CM_CapsuleTrace -84
equ trap_CM_TransformedCapsuleTrace -85
equ trap_R_AddAdditiveLightToScene -86
-equ trap_GetEntityToken -87
-equ trap_R_AddPolysToScene -88
-equ trap_R_inPVS -89
+equ trap_GetEntityToken -87
+equ trap_R_AddPolysToScene -88
+equ trap_R_inPVS -89
-equ memset -101
-equ memcpy -102
-equ strncpy -103
-equ sin -104
-equ cos -105
-equ atan2 -106
-equ sqrt -107
-equ floor -108
-equ ceil -109
-equ testPrintInt -110
-equ testPrintFloat -111
+equ memset -101
+equ memcpy -102
+equ strncpy -103
+equ sin -104
+equ cos -105
+equ atan2 -106
+equ sqrt -107
+equ floor -108
+equ ceil -109
+equ testPrintInt -110
+equ testPrintFloat -111
diff --git a/src/cgame/cg_syscalls.c b/src/cgame/cg_syscalls.c
index 517314d0..f5383a9d 100644
--- a/src/cgame/cg_syscalls.c
+++ b/src/cgame/cg_syscalls.c
@@ -21,390 +21,482 @@
static int (QDECL *syscall)( int arg, ... ) = (int (QDECL *)( int, ...))-1;
-void dllEntry( int (QDECL *syscallptr)( int arg,... ) ) {
- syscall = syscallptr;
+void dllEntry( int (QDECL *syscallptr)( int arg,... ) )
+{
+ syscall = syscallptr;
}
-int PASSFLOAT( float x ) {
- float floatTemp;
- floatTemp = x;
- return *(int *)&floatTemp;
+int PASSFLOAT( float x )
+{
+ float floatTemp;
+ floatTemp = x;
+ return *(int *)&floatTemp;
}
-void trap_Print( const char *fmt ) {
- syscall( CG_PRINT, fmt );
+void trap_Print( const char *fmt )
+{
+ syscall( CG_PRINT, fmt );
}
-void trap_Error( const char *fmt ) {
- syscall( CG_ERROR, fmt );
+void trap_Error( const char *fmt )
+{
+ syscall( CG_ERROR, fmt );
}
-int trap_Milliseconds( void ) {
- return syscall( CG_MILLISECONDS );
+int trap_Milliseconds( void )
+{
+ return syscall( CG_MILLISECONDS );
}
-void trap_Cvar_Register( vmCvar_t *vmCvar, const char *varName, const char *defaultValue, int flags ) {
- syscall( CG_CVAR_REGISTER, vmCvar, varName, defaultValue, flags );
+void trap_Cvar_Register( vmCvar_t *vmCvar, const char *varName, const char *defaultValue, int flags )
+{
+ syscall( CG_CVAR_REGISTER, vmCvar, varName, defaultValue, flags );
}
-void trap_Cvar_Update( vmCvar_t *vmCvar ) {
- syscall( CG_CVAR_UPDATE, vmCvar );
+void trap_Cvar_Update( vmCvar_t *vmCvar )
+{
+ syscall( CG_CVAR_UPDATE, vmCvar );
}
-void trap_Cvar_Set( const char *var_name, const char *value ) {
- syscall( CG_CVAR_SET, var_name, value );
+void trap_Cvar_Set( const char *var_name, const char *value )
+{
+ syscall( CG_CVAR_SET, var_name, value );
}
-void trap_Cvar_VariableStringBuffer( const char *var_name, char *buffer, int bufsize ) {
- syscall( CG_CVAR_VARIABLESTRINGBUFFER, var_name, buffer, bufsize );
+void trap_Cvar_VariableStringBuffer( const char *var_name, char *buffer, int bufsize )
+{
+ syscall( CG_CVAR_VARIABLESTRINGBUFFER, var_name, buffer, bufsize );
}
-int trap_Argc( void ) {
- return syscall( CG_ARGC );
+int trap_Argc( void )
+{
+ return syscall( CG_ARGC );
}
-void trap_Argv( int n, char *buffer, int bufferLength ) {
- syscall( CG_ARGV, n, buffer, bufferLength );
+void trap_Argv( int n, char *buffer, int bufferLength )
+{
+ syscall( CG_ARGV, n, buffer, bufferLength );
}
-void trap_Args( char *buffer, int bufferLength ) {
- syscall( CG_ARGS, buffer, bufferLength );
+void trap_Args( char *buffer, int bufferLength )
+{
+ syscall( CG_ARGS, buffer, bufferLength );
}
-int trap_FS_FOpenFile( const char *qpath, fileHandle_t *f, fsMode_t mode ) {
- return syscall( CG_FS_FOPENFILE, qpath, f, mode );
+int trap_FS_FOpenFile( const char *qpath, fileHandle_t *f, fsMode_t mode )
+{
+ return syscall( CG_FS_FOPENFILE, qpath, f, mode );
}
-void trap_FS_Read( void *buffer, int len, fileHandle_t f ) {
- syscall( CG_FS_READ, buffer, len, f );
+void trap_FS_Read( void *buffer, int len, fileHandle_t f )
+{
+ syscall( CG_FS_READ, buffer, len, f );
}
-void trap_FS_Write( const void *buffer, int len, fileHandle_t f ) {
- syscall( CG_FS_WRITE, buffer, len, f );
+void trap_FS_Write( const void *buffer, int len, fileHandle_t f )
+{
+ syscall( CG_FS_WRITE, buffer, len, f );
}
-void trap_FS_FCloseFile( fileHandle_t f ) {
- syscall( CG_FS_FCLOSEFILE, f );
+void trap_FS_FCloseFile( fileHandle_t f )
+{
+ syscall( CG_FS_FCLOSEFILE, f );
}
-void trap_SendConsoleCommand( const char *text ) {
- syscall( CG_SENDCONSOLECOMMAND, text );
+void trap_SendConsoleCommand( const char *text )
+{
+ syscall( CG_SENDCONSOLECOMMAND, text );
}
-void trap_AddCommand( const char *cmdName ) {
- syscall( CG_ADDCOMMAND, cmdName );
+void trap_AddCommand( const char *cmdName )
+{
+ syscall( CG_ADDCOMMAND, cmdName );
}
-void trap_RemoveCommand( const char *cmdName ) {
+void trap_RemoveCommand( const char *cmdName )
+{
syscall( CG_REMOVECOMMAND, cmdName );
}
-void trap_SendClientCommand( const char *s ) {
- syscall( CG_SENDCLIENTCOMMAND, s );
+void trap_SendClientCommand( const char *s )
+{
+ syscall( CG_SENDCLIENTCOMMAND, s );
}
-void trap_UpdateScreen( void ) {
- syscall( CG_UPDATESCREEN );
+void trap_UpdateScreen( void )
+{
+ syscall( CG_UPDATESCREEN );
}
-void trap_CM_LoadMap( const char *mapname ) {
- syscall( CG_CM_LOADMAP, mapname );
+void trap_CM_LoadMap( const char *mapname )
+{
+ syscall( CG_CM_LOADMAP, mapname );
}
-int trap_CM_NumInlineModels( void ) {
- return syscall( CG_CM_NUMINLINEMODELS );
+int trap_CM_NumInlineModels( void )
+{
+ return syscall( CG_CM_NUMINLINEMODELS );
}
-clipHandle_t trap_CM_InlineModel( int index ) {
- return syscall( CG_CM_INLINEMODEL, index );
+clipHandle_t trap_CM_InlineModel( int index )
+{
+ return syscall( CG_CM_INLINEMODEL, index );
}
-clipHandle_t trap_CM_TempBoxModel( const vec3_t mins, const vec3_t maxs ) {
- return syscall( CG_CM_TEMPBOXMODEL, mins, maxs );
+clipHandle_t trap_CM_TempBoxModel( const vec3_t mins, const vec3_t maxs )
+{
+ return syscall( CG_CM_TEMPBOXMODEL, mins, maxs );
}
-clipHandle_t trap_CM_TempCapsuleModel( const vec3_t mins, const vec3_t maxs ) {
+clipHandle_t trap_CM_TempCapsuleModel( const vec3_t mins, const vec3_t maxs )
+{
return syscall( CG_CM_TEMPCAPSULEMODEL, mins, maxs );
}
-int trap_CM_PointContents( const vec3_t p, clipHandle_t model ) {
- return syscall( CG_CM_POINTCONTENTS, p, model );
+int trap_CM_PointContents( const vec3_t p, clipHandle_t model )
+{
+ return syscall( CG_CM_POINTCONTENTS, p, model );
}
-int trap_CM_TransformedPointContents( const vec3_t p, clipHandle_t model, const vec3_t origin, const vec3_t angles ) {
- return syscall( CG_CM_TRANSFORMEDPOINTCONTENTS, p, model, origin, angles );
+int trap_CM_TransformedPointContents( const vec3_t p, clipHandle_t model, const vec3_t origin,
+ const vec3_t angles )
+{
+ return syscall( CG_CM_TRANSFORMEDPOINTCONTENTS, p, model, origin, angles );
}
-void trap_CM_BoxTrace( trace_t *results, const vec3_t start, const vec3_t end,
- const vec3_t mins, const vec3_t maxs,
- clipHandle_t model, int brushmask ) {
- syscall( CG_CM_BOXTRACE, results, start, end, mins, maxs, model, brushmask );
+void trap_CM_BoxTrace( trace_t *results, const vec3_t start, const vec3_t end,
+ const vec3_t mins, const vec3_t maxs,
+ clipHandle_t model, int brushmask )
+{
+ syscall( CG_CM_BOXTRACE, results, start, end, mins, maxs, model, brushmask );
}
void trap_CM_CapsuleTrace( trace_t *results, const vec3_t start, const vec3_t end,
const vec3_t mins, const vec3_t maxs,
- clipHandle_t model, int brushmask ) {
+ clipHandle_t model, int brushmask )
+{
syscall( CG_CM_CAPSULETRACE, results, start, end, mins, maxs, model, brushmask );
}
-void trap_CM_TransformedBoxTrace( trace_t *results, const vec3_t start, const vec3_t end,
- const vec3_t mins, const vec3_t maxs,
- clipHandle_t model, int brushmask,
- const vec3_t origin, const vec3_t angles ) {
- syscall( CG_CM_TRANSFORMEDBOXTRACE, results, start, end, mins, maxs, model, brushmask, origin, angles );
+void trap_CM_TransformedBoxTrace( trace_t *results, const vec3_t start, const vec3_t end,
+ const vec3_t mins, const vec3_t maxs,
+ clipHandle_t model, int brushmask,
+ const vec3_t origin, const vec3_t angles )
+{
+ syscall( CG_CM_TRANSFORMEDBOXTRACE, results, start, end, mins, maxs, model, brushmask, origin, angles );
}
void trap_CM_TransformedCapsuleTrace( trace_t *results, const vec3_t start, const vec3_t end,
const vec3_t mins, const vec3_t maxs,
clipHandle_t model, int brushmask,
- const vec3_t origin, const vec3_t angles ) {
+ const vec3_t origin, const vec3_t angles )
+{
syscall( CG_CM_TRANSFORMEDCAPSULETRACE, results, start, end, mins, maxs, model, brushmask, origin, angles );
}
-int trap_CM_MarkFragments( int numPoints, const vec3_t *points,
- const vec3_t projection,
- int maxPoints, vec3_t pointBuffer,
- int maxFragments, markFragment_t *fragmentBuffer ) {
- return syscall( CG_CM_MARKFRAGMENTS, numPoints, points, projection, maxPoints, pointBuffer, maxFragments, fragmentBuffer );
+int trap_CM_MarkFragments( int numPoints, const vec3_t *points,
+ const vec3_t projection,
+ int maxPoints, vec3_t pointBuffer,
+ int maxFragments, markFragment_t *fragmentBuffer )
+{
+ return syscall( CG_CM_MARKFRAGMENTS, numPoints, points, projection, maxPoints,
+ pointBuffer, maxFragments, fragmentBuffer );
}
-void trap_S_StartSound( vec3_t origin, int entityNum, int entchannel, sfxHandle_t sfx ) {
- syscall( CG_S_STARTSOUND, origin, entityNum, entchannel, sfx );
+void trap_S_StartSound( vec3_t origin, int entityNum, int entchannel, sfxHandle_t sfx )
+{
+ syscall( CG_S_STARTSOUND, origin, entityNum, entchannel, sfx );
}
-void trap_S_StartLocalSound( sfxHandle_t sfx, int channelNum ) {
+void trap_S_StartLocalSound( sfxHandle_t sfx, int channelNum )
+{
syscall( CG_S_STARTLOCALSOUND, sfx, channelNum );
}
-void trap_S_ClearLoopingSounds( qboolean killall ) {
+void trap_S_ClearLoopingSounds( qboolean killall )
+{
syscall( CG_S_CLEARLOOPINGSOUNDS, killall );
}
-void trap_S_AddLoopingSound( int entityNum, const vec3_t origin, const vec3_t velocity, sfxHandle_t sfx ) {
- syscall( CG_S_ADDLOOPINGSOUND, entityNum, origin, velocity, sfx );
+void trap_S_AddLoopingSound( int entityNum, const vec3_t origin, const vec3_t velocity, sfxHandle_t sfx )
+{
+ syscall( CG_S_ADDLOOPINGSOUND, entityNum, origin, velocity, sfx );
}
-void trap_S_AddRealLoopingSound( int entityNum, const vec3_t origin, const vec3_t velocity, sfxHandle_t sfx ) {
+void trap_S_AddRealLoopingSound( int entityNum, const vec3_t origin, const vec3_t velocity, sfxHandle_t sfx )
+{
syscall( CG_S_ADDREALLOOPINGSOUND, entityNum, origin, velocity, sfx );
}
-void trap_S_StopLoopingSound( int entityNum ) {
+void trap_S_StopLoopingSound( int entityNum )
+{
syscall( CG_S_STOPLOOPINGSOUND, entityNum );
}
-void trap_S_UpdateEntityPosition( int entityNum, const vec3_t origin ) {
- syscall( CG_S_UPDATEENTITYPOSITION, entityNum, origin );
+void trap_S_UpdateEntityPosition( int entityNum, const vec3_t origin )
+{
+ syscall( CG_S_UPDATEENTITYPOSITION, entityNum, origin );
}
-void trap_S_Respatialize( int entityNum, const vec3_t origin, vec3_t axis[3], int inwater ) {
- syscall( CG_S_RESPATIALIZE, entityNum, origin, axis, inwater );
+void trap_S_Respatialize( int entityNum, const vec3_t origin, vec3_t axis[3], int inwater )
+{
+ syscall( CG_S_RESPATIALIZE, entityNum, origin, axis, inwater );
}
-sfxHandle_t trap_S_RegisterSound( const char *sample, qboolean compressed ) {
+sfxHandle_t trap_S_RegisterSound( const char *sample, qboolean compressed )
+{
return syscall( CG_S_REGISTERSOUND, sample, compressed );
}
-void trap_S_StartBackgroundTrack( const char *intro, const char *loop ) {
- syscall( CG_S_STARTBACKGROUNDTRACK, intro, loop );
+void trap_S_StartBackgroundTrack( const char *intro, const char *loop )
+{
+ syscall( CG_S_STARTBACKGROUNDTRACK, intro, loop );
}
-void trap_R_LoadWorldMap( const char *mapname ) {
- syscall( CG_R_LOADWORLDMAP, mapname );
+void trap_R_LoadWorldMap( const char *mapname )
+{
+ syscall( CG_R_LOADWORLDMAP, mapname );
}
-qhandle_t trap_R_RegisterModel( const char *name ) {
- return syscall( CG_R_REGISTERMODEL, name );
+qhandle_t trap_R_RegisterModel( const char *name )
+{
+ return syscall( CG_R_REGISTERMODEL, name );
}
-qhandle_t trap_R_RegisterSkin( const char *name ) {
- return syscall( CG_R_REGISTERSKIN, name );
+qhandle_t trap_R_RegisterSkin( const char *name )
+{
+ return syscall( CG_R_REGISTERSKIN, name );
}
-qhandle_t trap_R_RegisterShader( const char *name ) {
- return syscall( CG_R_REGISTERSHADER, name );
+qhandle_t trap_R_RegisterShader( const char *name )
+{
+ return syscall( CG_R_REGISTERSHADER, name );
}
-qhandle_t trap_R_RegisterShaderNoMip( const char *name ) {
- return syscall( CG_R_REGISTERSHADERNOMIP, name );
+qhandle_t trap_R_RegisterShaderNoMip( const char *name )
+{
+ return syscall( CG_R_REGISTERSHADERNOMIP, name );
}
-void trap_R_RegisterFont(const char *fontName, int pointSize, fontInfo_t *font) {
+void trap_R_RegisterFont( const char *fontName, int pointSize, fontInfo_t *font )
+{
syscall(CG_R_REGISTERFONT, fontName, pointSize, font );
}
-void trap_R_ClearScene( void ) {
- syscall( CG_R_CLEARSCENE );
+void trap_R_ClearScene( void )
+{
+ syscall( CG_R_CLEARSCENE );
}
-void trap_R_AddRefEntityToScene( const refEntity_t *re ) {
- syscall( CG_R_ADDREFENTITYTOSCENE, re );
+void trap_R_AddRefEntityToScene( const refEntity_t *re )
+{
+ syscall( CG_R_ADDREFENTITYTOSCENE, re );
}
-void trap_R_AddPolyToScene( qhandle_t hShader , int numVerts, const polyVert_t *verts ) {
- syscall( CG_R_ADDPOLYTOSCENE, hShader, numVerts, verts );
+void trap_R_AddPolyToScene( qhandle_t hShader , int numVerts, const polyVert_t *verts )
+{
+ syscall( CG_R_ADDPOLYTOSCENE, hShader, numVerts, verts );
}
-void trap_R_AddPolysToScene( qhandle_t hShader , int numVerts, const polyVert_t *verts, int num ) {
+void trap_R_AddPolysToScene( qhandle_t hShader , int numVerts, const polyVert_t *verts, int num )
+{
syscall( CG_R_ADDPOLYSTOSCENE, hShader, numVerts, verts, num );
}
-int trap_R_LightForPoint( vec3_t point, vec3_t ambientLight, vec3_t directedLight, vec3_t lightDir ) {
+int trap_R_LightForPoint( vec3_t point, vec3_t ambientLight, vec3_t directedLight, vec3_t lightDir )
+{
return syscall( CG_R_LIGHTFORPOINT, point, ambientLight, directedLight, lightDir );
}
-void trap_R_AddLightToScene( const vec3_t org, float intensity, float r, float g, float b ) {
- syscall( CG_R_ADDLIGHTTOSCENE, org, PASSFLOAT(intensity), PASSFLOAT(r), PASSFLOAT(g), PASSFLOAT(b) );
+void trap_R_AddLightToScene( const vec3_t org, float intensity, float r, float g, float b )
+{
+ syscall( CG_R_ADDLIGHTTOSCENE, org, PASSFLOAT(intensity), PASSFLOAT(r), PASSFLOAT(g), PASSFLOAT(b) );
}
-void trap_R_AddAdditiveLightToScene( const vec3_t org, float intensity, float r, float g, float b ) {
- syscall( CG_R_ADDADDITIVELIGHTTOSCENE, org, PASSFLOAT(intensity), PASSFLOAT(r), PASSFLOAT(g), PASSFLOAT(b) );
+void trap_R_AddAdditiveLightToScene( const vec3_t org, float intensity, float r, float g, float b )
+{
+ syscall( CG_R_ADDADDITIVELIGHTTOSCENE, org, PASSFLOAT(intensity), PASSFLOAT(r), PASSFLOAT(g), PASSFLOAT(b) );
}
-void trap_R_RenderScene( const refdef_t *fd ) {
- syscall( CG_R_RENDERSCENE, fd );
+void trap_R_RenderScene( const refdef_t *fd )
+{
+ syscall( CG_R_RENDERSCENE, fd );
}
-void trap_R_SetColor( const float *rgba ) {
- syscall( CG_R_SETCOLOR, rgba );
+void trap_R_SetColor( const float *rgba )
+{
+ syscall( CG_R_SETCOLOR, rgba );
}
-void trap_R_DrawStretchPic( float x, float y, float w, float h,
- float s1, float t1, float s2, float t2, qhandle_t hShader ) {
- syscall( CG_R_DRAWSTRETCHPIC, PASSFLOAT(x), PASSFLOAT(y), PASSFLOAT(w), PASSFLOAT(h), PASSFLOAT(s1), PASSFLOAT(t1), PASSFLOAT(s2), PASSFLOAT(t2), hShader );
+void trap_R_DrawStretchPic( float x, float y, float w, float h,
+ float s1, float t1, float s2, float t2, qhandle_t hShader )
+{
+ syscall( CG_R_DRAWSTRETCHPIC, PASSFLOAT(x), PASSFLOAT(y), PASSFLOAT(w), PASSFLOAT(h),
+ PASSFLOAT(s1), PASSFLOAT(t1), PASSFLOAT(s2), PASSFLOAT(t2), hShader );
}
-void trap_R_ModelBounds( clipHandle_t model, vec3_t mins, vec3_t maxs ) {
- syscall( CG_R_MODELBOUNDS, model, mins, maxs );
+void trap_R_ModelBounds( clipHandle_t model, vec3_t mins, vec3_t maxs ) {
+ syscall( CG_R_MODELBOUNDS, model, mins, maxs );
}
int trap_R_LerpTag( orientation_t *tag, clipHandle_t mod, int startFrame, int endFrame,
- float frac, const char *tagName ) {
+ float frac, const char *tagName )
+{
return syscall( CG_R_LERPTAG, tag, mod, startFrame, endFrame, PASSFLOAT(frac), tagName );
}
-void trap_R_RemapShader( const char *oldShader, const char *newShader, const char *timeOffset ) {
+void trap_R_RemapShader( const char *oldShader, const char *newShader, const char *timeOffset )
+{
syscall( CG_R_REMAP_SHADER, oldShader, newShader, timeOffset );
}
-void trap_GetGlconfig( glconfig_t *glconfig ) {
- syscall( CG_GETGLCONFIG, glconfig );
+void trap_GetGlconfig( glconfig_t *glconfig )
+{
+ syscall( CG_GETGLCONFIG, glconfig );
}
-void trap_GetGameState( gameState_t *gamestate ) {
- syscall( CG_GETGAMESTATE, gamestate );
+void trap_GetGameState( gameState_t *gamestate )
+{
+ syscall( CG_GETGAMESTATE, gamestate );
}
-void trap_GetCurrentSnapshotNumber( int *snapshotNumber, int *serverTime ) {
- syscall( CG_GETCURRENTSNAPSHOTNUMBER, snapshotNumber, serverTime );
+void trap_GetCurrentSnapshotNumber( int *snapshotNumber, int *serverTime )
+{
+ syscall( CG_GETCURRENTSNAPSHOTNUMBER, snapshotNumber, serverTime );
}
-qboolean trap_GetSnapshot( int snapshotNumber, snapshot_t *snapshot ) {
- return syscall( CG_GETSNAPSHOT, snapshotNumber, snapshot );
+qboolean trap_GetSnapshot( int snapshotNumber, snapshot_t *snapshot )
+{
+ return syscall( CG_GETSNAPSHOT, snapshotNumber, snapshot );
}
-qboolean trap_GetServerCommand( int serverCommandNumber ) {
- return syscall( CG_GETSERVERCOMMAND, serverCommandNumber );
+qboolean trap_GetServerCommand( int serverCommandNumber )
+{
+ return syscall( CG_GETSERVERCOMMAND, serverCommandNumber );
}
-int trap_GetCurrentCmdNumber( void ) {
- return syscall( CG_GETCURRENTCMDNUMBER );
+int trap_GetCurrentCmdNumber( void )
+{
+ return syscall( CG_GETCURRENTCMDNUMBER );
}
-qboolean trap_GetUserCmd( int cmdNumber, usercmd_t *ucmd ) {
- return syscall( CG_GETUSERCMD, cmdNumber, ucmd );
+qboolean trap_GetUserCmd( int cmdNumber, usercmd_t *ucmd )
+{
+ return syscall( CG_GETUSERCMD, cmdNumber, ucmd );
}
-void trap_SetUserCmdValue( int stateValue, float sensitivityScale ) {
- syscall( CG_SETUSERCMDVALUE, stateValue, PASSFLOAT(sensitivityScale) );
+void trap_SetUserCmdValue( int stateValue, float sensitivityScale )
+{
+ syscall( CG_SETUSERCMDVALUE, stateValue, PASSFLOAT( sensitivityScale ) );
}
-void testPrintInt( char *string, int i ) {
- syscall( CG_TESTPRINTINT, string, i );
+void testPrintInt( char *string, int i )
+{
+ syscall( CG_TESTPRINTINT, string, i );
}
-void testPrintFloat( char *string, float f ) {
- syscall( CG_TESTPRINTFLOAT, string, PASSFLOAT(f) );
+void testPrintFloat( char *string, float f )
+{
+ syscall( CG_TESTPRINTFLOAT, string, PASSFLOAT(f) );
}
-int trap_MemoryRemaining( void ) {
- return syscall( CG_MEMORY_REMAINING );
+int trap_MemoryRemaining( void )
+{
+ return syscall( CG_MEMORY_REMAINING );
}
-qboolean trap_Key_IsDown( int keynum ) {
+qboolean trap_Key_IsDown( int keynum )
+{
return syscall( CG_KEY_ISDOWN, keynum );
}
-int trap_Key_GetCatcher( void ) {
+int trap_Key_GetCatcher( void )
+{
return syscall( CG_KEY_GETCATCHER );
}
-void trap_Key_SetCatcher( int catcher ) {
+void trap_Key_SetCatcher( int catcher )
+{
syscall( CG_KEY_SETCATCHER, catcher );
}
-int trap_Key_GetKey( const char *binding ) {
+int trap_Key_GetKey( const char *binding )
+{
return syscall( CG_KEY_GETKEY, binding );
}
-int trap_PC_AddGlobalDefine( char *define ) {
+int trap_PC_AddGlobalDefine( char *define )
+{
return syscall( CG_PC_ADD_GLOBAL_DEFINE, define );
}
-int trap_PC_LoadSource( const char *filename ) {
+int trap_PC_LoadSource( const char *filename )
+{
return syscall( CG_PC_LOAD_SOURCE, filename );
}
-int trap_PC_FreeSource( int handle ) {
+int trap_PC_FreeSource( int handle )
+{
return syscall( CG_PC_FREE_SOURCE, handle );
}
-int trap_PC_ReadToken( int handle, pc_token_t *pc_token ) {
+int trap_PC_ReadToken( int handle, pc_token_t *pc_token )
+{
return syscall( CG_PC_READ_TOKEN, handle, pc_token );
}
-int trap_PC_SourceFileAndLine( int handle, char *filename, int *line ) {
+int trap_PC_SourceFileAndLine( int handle, char *filename, int *line )
+{
return syscall( CG_PC_SOURCE_FILE_AND_LINE, handle, filename, line );
}
-void trap_S_StopBackgroundTrack( void ) {
+void trap_S_StopBackgroundTrack( void )
+{
syscall( CG_S_STOPBACKGROUNDTRACK );
}
-int trap_RealTime(qtime_t *qtime) {
+int trap_RealTime(qtime_t *qtime)
+{
return syscall( CG_REAL_TIME, qtime );
}
-void trap_SnapVector( float *v ) {
+void trap_SnapVector( float *v )
+{
syscall( CG_SNAPVECTOR, v );
}
// this returns a handle. arg0 is the name in the format "idlogo.roq", set arg1 to NULL, alteredstates to qfalse (do not alter gamestate)
-int trap_CIN_PlayCinematic( const char *arg0, int xpos, int ypos, int width, int height, int bits) {
+int trap_CIN_PlayCinematic( const char *arg0, int xpos, int ypos, int width, int height, int bits )
+{
return syscall(CG_CIN_PLAYCINEMATIC, arg0, xpos, ypos, width, height, bits);
}
// stops playing the cinematic and ends it. should always return FMV_EOF
// cinematics must be stopped in reverse order of when they are started
-e_status trap_CIN_StopCinematic(int handle) {
+e_status trap_CIN_StopCinematic( int handle )
+{
return syscall(CG_CIN_STOPCINEMATIC, handle);
}
// will run a frame of the cinematic but will not draw it. Will return FMV_EOF if the end of the cinematic has been reached.
-e_status trap_CIN_RunCinematic (int handle) {
+e_status trap_CIN_RunCinematic( int handle )
+{
return syscall(CG_CIN_RUNCINEMATIC, handle);
}
// draws the current frame
-void trap_CIN_DrawCinematic (int handle) {
+void trap_CIN_DrawCinematic( int handle )
+{
syscall(CG_CIN_DRAWCINEMATIC, handle);
}
// allows you to resize the animation dynamically
-void trap_CIN_SetExtents (int handle, int x, int y, int w, int h) {
+void trap_CIN_SetExtents( int handle, int x, int y, int w, int h )
+{
syscall(CG_CIN_SETEXTENTS, handle, x, y, w, h);
}
diff --git a/src/cgame/cg_trails.c b/src/cgame/cg_trails.c
index 9a2bc8a1..8839a757 100644
--- a/src/cgame/cg_trails.c
+++ b/src/cgame/cg_trails.c
@@ -4,35 +4,35 @@
typedef struct trailJunc_s
{
- struct trailJunc_s *nextGlobal, *prevGlobal; // next junction in the global list it is in (free or used)
- struct trailJunc_s *nextJunc; // next junction in the trail
- struct trailJunc_s *nextHead, *prevHead; // next head junc in the world
-
- qboolean inuse, freed;
- int ownerIndex;
- qhandle_t shader;
-
- int sType;
- int flags;
- float sTex;
- vec3_t pos;
- int spawnTime, endTime;
- float alphaStart, alphaEnd;
- vec3_t colorStart, colorEnd;
- float widthStart, widthEnd;
-
- // current settings
- float alpha;
- float width;
- vec3_t color;
+ struct trailJunc_s *nextGlobal, *prevGlobal; // next junction in the global list it is in (free or used)
+ struct trailJunc_s *nextJunc; // next junction in the trail
+ struct trailJunc_s *nextHead, *prevHead; // next head junc in the world
+
+ qboolean inuse, freed;
+ int ownerIndex;
+ qhandle_t shader;
+
+ int sType;
+ int flags;
+ float sTex;
+ vec3_t pos;
+ int spawnTime, endTime;
+ float alphaStart, alphaEnd;
+ vec3_t colorStart, colorEnd;
+ float widthStart, widthEnd;
+
+ // current settings
+ float alpha;
+ float width;
+ vec3_t color;
} trailJunc_t;
-#define MAX_TRAILJUNCS 4096
+#define MAX_TRAILJUNCS 4096
-trailJunc_t trailJuncs[MAX_TRAILJUNCS];
+trailJunc_t trailJuncs[ MAX_TRAILJUNCS ];
trailJunc_t *freeTrails, *activeTrails;
-trailJunc_t *headTrails;
+trailJunc_t *headTrails;
qboolean initTrails = qfalse;
@@ -43,31 +43,32 @@ int numTrailsInuse;
CG_ClearTrails
===============
*/
-void CG_ClearTrails (void)
+void CG_ClearTrails( void )
{
- int i;
+ int i;
- memset( trailJuncs, 0, sizeof(trailJunc_t) * MAX_TRAILJUNCS );
+ memset( trailJuncs, 0, sizeof( trailJunc_t ) * MAX_TRAILJUNCS );
- freeTrails = trailJuncs;
- activeTrails = NULL;
- headTrails = NULL;
+ freeTrails = trailJuncs;
+ activeTrails = NULL;
+ headTrails = NULL;
- for (i=0 ;i<MAX_TRAILJUNCS ; i++)
- {
- trailJuncs[i].nextGlobal = &trailJuncs[i+1];
+ for( i = 0; i < MAX_TRAILJUNCS; i++ )
+ {
+ trailJuncs[ i ].nextGlobal = &trailJuncs[ i + 1 ];
- if (i>0)
- trailJuncs[i].prevGlobal = &trailJuncs[i-1];
- else
- trailJuncs[i].prevGlobal = NULL;
+ if( i > 0 )
+ trailJuncs[ i ].prevGlobal = &trailJuncs[ i - 1 ];
+ else
+ trailJuncs[ i ].prevGlobal = NULL;
- trailJuncs[i].inuse = qfalse;
- }
- trailJuncs[MAX_TRAILJUNCS-1].nextGlobal = NULL;
+ trailJuncs[ i ].inuse = qfalse;
+ }
+
+ trailJuncs[ MAX_TRAILJUNCS - 1 ].nextGlobal = NULL;
- initTrails = qtrue;
- numTrailsInuse = 0;
+ initTrails = qtrue;
+ numTrailsInuse = 0;
}
/*
@@ -77,59 +78,70 @@ CG_SpawnTrailJunc
*/
trailJunc_t *CG_SpawnTrailJunc( trailJunc_t *headJunc )
{
- trailJunc_t *j;
-
- if (!freeTrails)
- return NULL;
-
- if ( cg_paused.integer )
- return NULL;
-
- // select the first free trail, and remove it from the list
- j = freeTrails;
- freeTrails = j->nextGlobal;
- if (freeTrails)
- freeTrails->prevGlobal = NULL;
-
- j->nextGlobal = activeTrails;
- if (activeTrails)
- activeTrails->prevGlobal = j;
- activeTrails = j;
- j->prevGlobal = NULL;
- j->inuse = qtrue;
- j->freed = qfalse;
-
- // if this owner has a headJunc, add us to the start
- if (headJunc) {
- // remove the headJunc from the list of heads
- if (headJunc == headTrails) {
- headTrails = headJunc->nextHead;
- if (headTrails)
- headTrails->prevHead = NULL;
- } else {
- if (headJunc->nextHead)
- headJunc->nextHead->prevHead = headJunc->prevHead;
- if (headJunc->prevHead)
- headJunc->prevHead->nextHead = headJunc->nextHead;
- }
- headJunc->prevHead = NULL;
- headJunc->nextHead = NULL;
- }
- // make us the headTrail
- if (headTrails)
- headTrails->prevHead = j;
- j->nextHead = headTrails;
- j->prevHead = NULL;
- headTrails = j;
-
- j->nextJunc = headJunc; // if headJunc is NULL, then we'll just be the end of the list
-
- numTrailsInuse++;
-
- // debugging
-// CG_Printf( "NumTrails: %i\n", numTrailsInuse );
-
- return j;
+ trailJunc_t *j;
+
+ if( !freeTrails )
+ return NULL;
+
+ if( cg_paused.integer )
+ return NULL;
+
+ // select the first free trail, and remove it from the list
+ j = freeTrails;
+ freeTrails = j->nextGlobal;
+
+ if( freeTrails )
+ freeTrails->prevGlobal = NULL;
+
+ j->nextGlobal = activeTrails;
+
+ if( activeTrails )
+ activeTrails->prevGlobal = j;
+
+ activeTrails = j;
+ j->prevGlobal = NULL;
+ j->inuse = qtrue;
+ j->freed = qfalse;
+
+ // if this owner has a headJunc, add us to the start
+ if( headJunc )
+ {
+ // remove the headJunc from the list of heads
+ if( headJunc == headTrails )
+ {
+ headTrails = headJunc->nextHead;
+
+ if( headTrails )
+ headTrails->prevHead = NULL;
+ }
+ else
+ {
+ if( headJunc->nextHead )
+ headJunc->nextHead->prevHead = headJunc->prevHead;
+
+ if( headJunc->prevHead )
+ headJunc->prevHead->nextHead = headJunc->nextHead;
+ }
+ headJunc->prevHead = NULL;
+ headJunc->nextHead = NULL;
+ }
+
+ // make us the headTrail
+ if( headTrails )
+ headTrails->prevHead = j;
+
+ j->nextHead = headTrails;
+ j->prevHead = NULL;
+ headTrails = j;
+
+ j->nextJunc = headJunc; // if headJunc is NULL, then we'll just be the end of the list
+
+ numTrailsInuse++;
+
+ // debugging
+// CG_Printf( "NumTrails: %i\n", numTrailsInuse );
+
+ return j;
}
@@ -142,59 +154,74 @@ CG_AddTrailJunc
Used for generic trails
===============
*/
-int CG_AddTrailJunc(int headJuncIndex, qhandle_t shader, int spawnTime, int sType, vec3_t pos, int trailLife, float alphaStart, float alphaEnd, float startWidth, float endWidth, int flags, vec3_t colorStart, vec3_t colorEnd, float sRatio, float animSpeed)
+int CG_AddTrailJunc( int headJuncIndex, qhandle_t shader, int spawnTime, int sType, vec3_t pos,
+ int trailLife, float alphaStart, float alphaEnd, float startWidth,
+ float endWidth, int flags, vec3_t colorStart, vec3_t colorEnd,
+ float sRatio, float animSpeed )
{
- trailJunc_t *j, *headJunc;
-
- if (headJuncIndex > 0) {
- headJunc = &trailJuncs[headJuncIndex-1];
-
- if (!headJunc->inuse)
- headJunc = NULL;
- }
- else
- headJunc = NULL;
-
- j = CG_SpawnTrailJunc(headJunc);
- if (!j) {
-// CG_Printf("couldnt spawn trail junc\n");
- return 0;
- }
-
- if (alphaStart > 1.0) alphaStart = 1.0;
- if (alphaStart < 0.0) alphaStart = 0.0;
- if (alphaEnd > 1.0) alphaEnd = 1.0;
- if (alphaEnd < 0.0) alphaEnd = 0.0;
-
- // setup the trail junction
- j->shader = shader;
- j->sType = sType;
- VectorCopy( pos, j->pos );
- j->flags = flags;
-
- j->spawnTime = spawnTime;
- j->endTime = spawnTime + trailLife;
-
- VectorCopy( colorStart, j->colorStart );
- VectorCopy( colorEnd, j->colorEnd );
-
- j->alphaStart = alphaStart;
- j->alphaEnd = alphaEnd;
-
- j->widthStart = startWidth;
- j->widthEnd = endWidth;
-
- if (sType == STYPE_REPEAT) {
- if (headJunc) {
- j->sTex = headJunc->sTex + ((Distance( headJunc->pos, pos ) / sRatio) / j->widthEnd);
- } else {
- // FIXME: need a way to specify offset timing
- j->sTex = (animSpeed * (1.0 - ((float)(cg.time%1000) / 1000.0))) / (sRatio);
-// j->sTex = 0;
- }
- }
-
- return ((int)(j - trailJuncs) + 1);
+ trailJunc_t *j, *headJunc;
+
+ if( headJuncIndex > 0 )
+ {
+ headJunc = &trailJuncs[ headJuncIndex - 1 ];
+
+ if( !headJunc->inuse )
+ headJunc = NULL;
+ }
+ else
+ headJunc = NULL;
+
+ j = CG_SpawnTrailJunc( headJunc );
+
+ if( !j )
+ {
+// CG_Printf("couldnt spawn trail junc\n");
+ return 0;
+ }
+
+ if( alphaStart > 1.0 )
+ alphaStart = 1.0;
+
+ if( alphaStart < 0.0 )
+ alphaStart = 0.0;
+
+ if( alphaEnd > 1.0 )
+ alphaEnd = 1.0;
+
+ if( alphaEnd < 0.0 )
+ alphaEnd = 0.0;
+
+ // setup the trail junction
+ j->shader = shader;
+ j->sType = sType;
+ VectorCopy( pos, j->pos );
+ j->flags = flags;
+
+ j->spawnTime = spawnTime;
+ j->endTime = spawnTime + trailLife;
+
+ VectorCopy( colorStart, j->colorStart );
+ VectorCopy( colorEnd, j->colorEnd );
+
+ j->alphaStart = alphaStart;
+ j->alphaEnd = alphaEnd;
+
+ j->widthStart = startWidth;
+ j->widthEnd = endWidth;
+
+ if( sType == STYPE_REPEAT )
+ {
+ if( headJunc )
+ j->sTex = headJunc->sTex + ( ( Distance( headJunc->pos, pos ) / sRatio) / j->widthEnd );
+ else
+ {
+ // FIXME: need a way to specify offset timing
+ j->sTex = ( animSpeed * ( 1.0 - ( (float)( cg.time % 1000 ) / 1000.0 ) ) ) / ( sRatio );
+// j->sTex = 0;
+ }
+ }
+
+ return ( (int)( j - trailJuncs ) + 1 );
}
/*
@@ -204,46 +231,49 @@ CG_AddSparkJunc
returns the index of the trail junction created
===============
*/
-int CG_AddSparkJunc(int headJuncIndex, qhandle_t shader, vec3_t pos, int trailLife, float alphaStart, float alphaEnd, float startWidth, float endWidth)
+int CG_AddSparkJunc( int headJuncIndex, qhandle_t shader, vec3_t pos, int trailLife,
+ float alphaStart, float alphaEnd, float startWidth, float endWidth )
{
- trailJunc_t *j, *headJunc;
-
- if (headJuncIndex > 0) {
- headJunc = &trailJuncs[headJuncIndex-1];
-
- if (!headJunc->inuse)
- headJunc = NULL;
- }
- else
- headJunc = NULL;
-
- j = CG_SpawnTrailJunc(headJunc);
- if (!j)
- return 0;
-
- // setup the trail junction
- j->shader = shader;
- j->sType = STYPE_STRETCH;
- VectorCopy( pos, j->pos );
- j->flags = TJFL_NOCULL; // don't worry about fading up close
-
- j->spawnTime = cg.time;
- j->endTime = cg.time + trailLife;
-
- VectorSet(j->colorStart, 1.0, 0.8 + 0.2 * alphaStart, 0.4 + 0.4 * alphaStart);
- VectorSet(j->colorEnd, 1.0, 0.8 + 0.2 * alphaEnd, 0.4 + 0.4 * alphaEnd);
-// VectorScale( j->colorStart, alphaStart, j->colorStart );
-// VectorScale( j->colorEnd, alphaEnd, j->colorEnd );
-
- j->alphaStart = alphaStart*2;
- j->alphaEnd = alphaEnd*2;
-// j->alphaStart = 1.0;
-// j->alphaEnd = 1.0;
-
- j->widthStart = startWidth;
- j->widthEnd = endWidth;
-
- return ((int)(j - trailJuncs) + 1);
+ trailJunc_t *j, *headJunc;
+
+ if( headJuncIndex > 0 )
+ {
+ headJunc = &trailJuncs[ headJuncIndex - 1 ];
+
+ if( !headJunc->inuse )
+ headJunc = NULL;
+ }
+ else
+ headJunc = NULL;
+
+ j = CG_SpawnTrailJunc( headJunc );
+
+ if( !j )
+ return 0;
+
+ // setup the trail junction
+ j->shader = shader;
+ j->sType = STYPE_STRETCH;
+ VectorCopy( pos, j->pos );
+ j->flags = TJFL_NOCULL; // don't worry about fading up close
+
+ j->spawnTime = cg.time;
+ j->endTime = cg.time + trailLife;
+
+ VectorSet( j->colorStart, 1.0, 0.8 + 0.2 * alphaStart, 0.4 + 0.4 * alphaStart );
+ VectorSet( j->colorEnd, 1.0, 0.8 + 0.2 * alphaEnd, 0.4 + 0.4 * alphaEnd );
+// VectorScale( j->colorStart, alphaStart, j->colorStart );
+// VectorScale( j->colorEnd, alphaEnd, j->colorEnd );
+
+ j->alphaStart = alphaStart*2;
+ j->alphaEnd = alphaEnd*2;
+// j->alphaStart = 1.0;
+// j->alphaEnd = 1.0;
+
+ j->widthStart = startWidth;
+ j->widthEnd = endWidth;
+
+ return ( (int)( j - trailJuncs ) + 1 );
}
/*
@@ -253,54 +283,58 @@ CG_AddSmokeJunc
returns the index of the trail junction created
===============
*/
-int CG_AddSmokeJunc(int headJuncIndex, qhandle_t shader, vec3_t pos, int trailLife, float alpha, float startWidth, float endWidth)
+int CG_AddSmokeJunc( int headJuncIndex, qhandle_t shader, vec3_t pos, int trailLife,
+ float alpha, float startWidth, float endWidth )
{
-#define ST_RATIO 4.0 // sprite image: width / height
- trailJunc_t *j, *headJunc;
-
- if (headJuncIndex > 0) {
- headJunc = &trailJuncs[headJuncIndex-1];
-
- if (!headJunc->inuse)
- headJunc = NULL;
- }
- else
- headJunc = NULL;
-
- j = CG_SpawnTrailJunc(headJunc);
- if (!j)
- return 0;
-
- // setup the trail junction
- j->shader = shader;
- j->sType = STYPE_REPEAT;
- VectorCopy( pos, j->pos );
- j->flags = TJFL_FADEIN;
-
- j->spawnTime = cg.time;
- j->endTime = cg.time + trailLife;
-
- // VectorSet(j->colorStart, 0.2, 0.2, 0.2);
- VectorSet(j->colorStart, 0.0, 0.0, 0.0);
- // VectorSet(j->colorEnd, 0.1, 0.1, 0.1);
- VectorSet(j->colorEnd, 0.0, 0.0, 0.0);
-
- j->alphaStart = alpha;
- j->alphaEnd = 0.0;
-
- j->widthStart = startWidth;
- j->widthEnd = endWidth;
-
- if (headJunc) {
- j->sTex = headJunc->sTex + ((Distance( headJunc->pos, pos ) / ST_RATIO) / j->widthEnd);
- } else {
- // first junction, so this will become the "tail" very soon, make it fade out
- j->sTex = 0;
- j->alphaStart = 0.0;
- j->alphaEnd = 0.0;
- }
-
- return ((int)(j - trailJuncs) + 1);
+#define ST_RATIO 4.0 // sprite image: width / height
+ trailJunc_t *j, *headJunc;
+
+ if( headJuncIndex > 0 )
+ {
+ headJunc = &trailJuncs[ headJuncIndex - 1 ];
+
+ if( !headJunc->inuse )
+ headJunc = NULL;
+ }
+ else
+ headJunc = NULL;
+
+ j = CG_SpawnTrailJunc( headJunc );
+
+ if( !j )
+ return 0;
+
+ // setup the trail junction
+ j->shader = shader;
+ j->sType = STYPE_REPEAT;
+ VectorCopy( pos, j->pos );
+ j->flags = TJFL_FADEIN;
+
+ j->spawnTime = cg.time;
+ j->endTime = cg.time + trailLife;
+
+ // VectorSet(j->colorStart, 0.2, 0.2, 0.2);
+ VectorSet(j->colorStart, 0.0, 0.0, 0.0);
+ // VectorSet(j->colorEnd, 0.1, 0.1, 0.1);
+ VectorSet(j->colorEnd, 0.0, 0.0, 0.0);
+
+ j->alphaStart = alpha;
+ j->alphaEnd = 0.0;
+
+ j->widthStart = startWidth;
+ j->widthEnd = endWidth;
+
+ if( headJunc )
+ j->sTex = headJunc->sTex + ( ( Distance( headJunc->pos, pos ) / ST_RATIO ) / j->widthEnd );
+ else
+ {
+ // first junction, so this will become the "tail" very soon, make it fade out
+ j->sTex = 0;
+ j->alphaStart = 0.0;
+ j->alphaEnd = 0.0;
+ }
+
+ return ( (int)( j - trailJuncs ) + 1 );
}
void CG_KillTrail( trailJunc_t *t );
@@ -312,38 +346,46 @@ CG_FreeTrailJunc
*/
void CG_FreeTrailJunc( trailJunc_t *junc )
{
- // kill any juncs after us, so they aren't left hanging
- if (junc->nextJunc)
- CG_KillTrail( junc );
-
- // make it non-active
- junc->inuse = qfalse;
- junc->freed = qtrue;
- if (junc->nextGlobal)
- junc->nextGlobal->prevGlobal = junc->prevGlobal;
- if (junc->prevGlobal)
- junc->prevGlobal->nextGlobal = junc->nextGlobal;
- if (junc == activeTrails)
- activeTrails = junc->nextGlobal;
-
- // if it's a head, remove it
- if (junc == headTrails)
- headTrails = junc->nextHead;
- if (junc->nextHead)
- junc->nextHead->prevHead = junc->prevHead;
- if (junc->prevHead)
- junc->prevHead->nextHead = junc->nextHead;
- junc->nextHead = NULL;
- junc->prevHead = NULL;
-
- // stick it in the free list
- junc->prevGlobal = NULL;
- junc->nextGlobal = freeTrails;
- if (freeTrails)
- freeTrails->prevGlobal = junc;
- freeTrails = junc;
-
- numTrailsInuse--;
+ // kill any juncs after us, so they aren't left hanging
+ if( junc->nextJunc )
+ CG_KillTrail( junc );
+
+ // make it non-active
+ junc->inuse = qfalse;
+ junc->freed = qtrue;
+
+ if( junc->nextGlobal )
+ junc->nextGlobal->prevGlobal = junc->prevGlobal;
+
+ if( junc->prevGlobal )
+ junc->prevGlobal->nextGlobal = junc->nextGlobal;
+
+ if( junc == activeTrails )
+ activeTrails = junc->nextGlobal;
+
+ // if it's a head, remove it
+ if( junc == headTrails )
+ headTrails = junc->nextHead;
+
+ if( junc->nextHead )
+ junc->nextHead->prevHead = junc->prevHead;
+
+ if( junc->prevHead )
+ junc->prevHead->nextHead = junc->nextHead;
+
+ junc->nextHead = NULL;
+ junc->prevHead = NULL;
+
+ // stick it in the free list
+ junc->prevGlobal = NULL;
+ junc->nextGlobal = freeTrails;
+
+ if( freeTrails )
+ freeTrails->prevGlobal = junc;
+
+ freeTrails = junc;
+
+ numTrailsInuse--;
}
/*
@@ -353,15 +395,15 @@ CG_KillTrail
*/
void CG_KillTrail( trailJunc_t *t )
{
- trailJunc_t *next;
+ trailJunc_t *next;
- next = t->nextJunc;
+ next = t->nextJunc;
- // kill the trail here
- t->nextJunc = NULL;
+ // kill the trail here
+ t->nextJunc = NULL;
- if (next)
- CG_FreeTrailJunc( next );
+ if( next )
+ CG_FreeTrailJunc( next );
}
/*
@@ -374,301 +416,331 @@ CG_AddTrailToScene
static vec3_t vforward, vright, vup;
//TA: staticised to please QVM
- #define MAX_TRAIL_VERTS 2048
-static polyVert_t verts[MAX_TRAIL_VERTS];
-static polyVert_t outVerts[MAX_TRAIL_VERTS*3];
+ #define MAX_TRAIL_VERTS 2048
+static polyVert_t verts[ MAX_TRAIL_VERTS ];
+static polyVert_t outVerts[ MAX_TRAIL_VERTS * 3 ];
void CG_AddTrailToScene( trailJunc_t *trail, int iteration, int numJuncs )
{
- int k, i, n, l, numOutVerts;
- polyVert_t mid;
- float mod[4];
- float sInc = 0.0f, s = 0.0f; // TTimo: init
- trailJunc_t *j, *jNext;
- vec3_t fwd, up, p, v;
- // clipping vars
- #define TRAIL_FADE_CLOSE_DIST 64.0
- #define TRAIL_FADE_FAR_SCALE 4.0
- vec3_t viewProj;
- float viewDist, fadeAlpha;
-
- // add spark shader at head position
- if (trail->flags & TJFL_SPARKHEADFLARE) {
- j = trail;
- VectorCopy( j->pos, p );
- VectorMA (p, -j->width*2, vup, p);
- VectorMA (p, -j->width*2, vright, p);
- VectorCopy (p, verts[0].xyz);
- verts[0].st[0] = 0;
- verts[0].st[1] = 0;
- verts[0].modulate[0] = 255;
- verts[0].modulate[1] = 255;
- verts[0].modulate[2] = 255;
- verts[0].modulate[3] = (unsigned char)(j->alpha*255.0);
-
- VectorCopy( j->pos, p );
- VectorMA (p, -j->width*2, vup, p);
- VectorMA (p, j->width*2, vright, p);
- VectorCopy (p, verts[1].xyz);
- verts[1].st[0] = 0;
- verts[1].st[1] = 1;
- verts[1].modulate[0] = 255;
- verts[1].modulate[1] = 255;
- verts[1].modulate[2] = 255;
- verts[1].modulate[3] = (unsigned char)(j->alpha*255.0);
-
- VectorCopy( j->pos, p );
- VectorMA (p, j->width*2, vup, p);
- VectorMA (p, j->width*2, vright, p);
- VectorCopy (p, verts[2].xyz);
- verts[2].st[0] = 1;
- verts[2].st[1] = 1;
- verts[2].modulate[0] = 255;
- verts[2].modulate[1] = 255;
- verts[2].modulate[2] = 255;
- verts[2].modulate[3] = (unsigned char)(j->alpha*255.0);
-
- VectorCopy( j->pos, p );
- VectorMA (p, j->width*2, vup, p);
- VectorMA (p, -j->width*2, vright, p);
- VectorCopy (p, verts[3].xyz);
- verts[3].st[0] = 1;
- verts[3].st[1] = 0;
- verts[3].modulate[0] = 255;
- verts[3].modulate[1] = 255;
- verts[3].modulate[2] = 255;
- verts[3].modulate[3] = (unsigned char)(j->alpha*255.0);
-
- trap_R_AddPolyToScene( cgs.media.sparkFlareShader, 4, verts );
- }
-
-// if (trail->flags & TJFL_CROSSOVER && iteration < 1) {
-// iteration = 1;
-// }
-
- if (!numJuncs) {
- // first count the number of juncs in the trail
- j = trail;
- numJuncs = 0;
- sInc = 0;
- while (j) {
- numJuncs++;
-
- // check for a dead next junc
- if (!j->inuse && j->nextJunc && !j->nextJunc->inuse) {
- CG_KillTrail( j );
- } else if (j->nextJunc && j->nextJunc->freed) {
- // not sure how this can happen, but it does, and causes infinite loops
- j->nextJunc = NULL;
- }
-
- if (j->nextJunc)
- sInc += VectorDistance( j->nextJunc->pos, j->pos );
-
- j = j->nextJunc;
- }
- }
-
- if (numJuncs < 2) {
- return;
- }
-
- if (trail->sType == STYPE_STRETCH) {
- //sInc = ((1.0 - 0.1) / (float)(numJuncs)); // hack, the end of funnel shows a bit of the start (looping)
- s = 0.05;
- //s = 0.05;
- } else if (trail->sType == STYPE_REPEAT) {
- s = trail->sTex;
- }
-
- // now traverse the list
- j = trail;
- jNext = j->nextJunc;
- i = 0;
- while (jNext) {
-
- // first get the directional vectors to the next junc
- VectorSubtract( jNext->pos, j->pos, fwd );
- GetPerpendicularViewVector( cg.refdef.vieworg, j->pos, jNext->pos, up );
-
- // if it's a crossover, draw it twice
- if (j->flags & TJFL_CROSSOVER) {
- if (iteration > 0) {
- ProjectPointOntoVector( cg.refdef.vieworg, j->pos, jNext->pos, viewProj );
- VectorSubtract( cg.refdef.vieworg, viewProj, v );
- VectorNormalize( v );
-
- if (iteration == 1) {
- VectorMA( up, 0.3, v, up );
- } else {
- VectorMA( up, -0.3, v, up );
- }
- VectorNormalize( up );
- }
- }
- // do fading when moving towards the projection point onto the trail segment vector
- else if (!(j->flags & TJFL_NOCULL) && (j->widthEnd > 4 || jNext->widthEnd > 4)) {
- ProjectPointOntoVector( cg.refdef.vieworg, j->pos, jNext->pos, viewProj );
- viewDist = Distance( viewProj, cg.refdef.vieworg );
- if (viewDist < (TRAIL_FADE_CLOSE_DIST * TRAIL_FADE_FAR_SCALE)) {
- if (viewDist < TRAIL_FADE_CLOSE_DIST) {
- fadeAlpha = 0.0;
- } else {
- fadeAlpha = (viewDist - TRAIL_FADE_CLOSE_DIST) / (TRAIL_FADE_CLOSE_DIST * TRAIL_FADE_FAR_SCALE);
- }
- if (fadeAlpha < j->alpha) {
- j->alpha = fadeAlpha;
- }
- if (fadeAlpha < jNext->alpha) {
- jNext->alpha = fadeAlpha;
- }
- }
- }
-
- // now output the QUAD for this segment
-
- // 1 ----
- VectorMA( j->pos, 0.5*j->width, up, p );
- VectorCopy( p, verts[i].xyz );
- verts[i].st[0] = s;
- verts[i].st[1] = 1.0;
- for (k=0; k<3; k++)
- verts[i].modulate[k] = (unsigned char)(j->color[k]*255.0);
- verts[i].modulate[3] = (unsigned char)(j->alpha*255.0);
-
- // blend this with the previous junc
- if (j != trail) {
- VectorAdd( verts[i].xyz, verts[i-1].xyz, verts[i].xyz );
- VectorScale( verts[i].xyz, 0.5, verts[i].xyz );
- VectorCopy( verts[i].xyz, verts[i-1].xyz );
- } else if (j->flags & TJFL_FADEIN) {
- verts[i].modulate[3] = 0; // fade in
- }
-
- i++;
-
- // 2 ----
- VectorMA( p, -1*j->width, up, p );
- VectorCopy( p, verts[i].xyz );
- verts[i].st[0] = s;
- verts[i].st[1] = 0.0;
- for (k=0; k<3; k++)
- verts[i].modulate[k] = (unsigned char)(j->color[k]*255.0);
- verts[i].modulate[3] = (unsigned char)(j->alpha*255.0);
-
- // blend this with the previous junc
- if (j != trail) {
- VectorAdd( verts[i].xyz, verts[i-3].xyz, verts[i].xyz );
- VectorScale( verts[i].xyz, 0.5, verts[i].xyz );
- VectorCopy( verts[i].xyz, verts[i-3].xyz );
- } else if (j->flags & TJFL_FADEIN) {
- verts[i].modulate[3] = 0; // fade in
- }
-
- i++;
-
- if (trail->sType == STYPE_REPEAT)
- s = jNext->sTex;
- else {
- //s += sInc;
- s += VectorDistance( j->pos, jNext->pos ) / sInc;
- if (s > 1.0) s = 1.0;
- }
-
- // 3 ----
- VectorMA( jNext->pos, -0.5*jNext->width, up, p );
- VectorCopy( p, verts[i].xyz );
- verts[i].st[0] = s;
- verts[i].st[1] = 0.0;
- for (k=0; k<3; k++)
- verts[i].modulate[k] = (unsigned char)(jNext->color[k]*255.0);
- verts[i].modulate[3] = (unsigned char)(jNext->alpha*255.0);
- i++;
-
- // 4 ----
- VectorMA( p, jNext->width, up, p );
- VectorCopy( p, verts[i].xyz );
- verts[i].st[0] = s;
- verts[i].st[1] = 1.0;
- for (k=0; k<3; k++)
- verts[i].modulate[k] = (unsigned char)(jNext->color[k]*255.0);
- verts[i].modulate[3] = (unsigned char)(jNext->alpha*255.0);
- i++;
-
- if (i+4 > MAX_TRAIL_VERTS)
- break;
-
- j = jNext;
- jNext = j->nextJunc;
- }
-
- if (trail->flags & TJFL_FIXDISTORT) {
- // build the list of outVerts, by dividing up the QUAD's into 4 Tri's each, so as to allow
- // any shaped (convex) Quad without bilinear distortion
- for (k=0, numOutVerts=0; k<i; k+=4) {
- VectorCopy(verts[k].xyz, mid.xyz);
- mid.st[0] = verts[k].st[0];
- mid.st[1] = verts[k].st[1];
- for (l=0; l<4; l++) {
- mod[l] = (float)verts[k].modulate[l];
- }
- for (n=1; n<4; n++) {
- VectorAdd( verts[k+n].xyz, mid.xyz, mid.xyz );
- mid.st[0] += verts[k+n].st[0];
- mid.st[1] += verts[k+n].st[1];
- for (l=0; l<4; l++) {
- mod[l] += (float)verts[k+n].modulate[l];
- }
- }
- VectorScale( mid.xyz, 0.25, mid.xyz );
- mid.st[0] *= 0.25;
- mid.st[1] *= 0.25;
- for (l=0; l<4; l++) {
- mid.modulate[l] = (unsigned char)(mod[l]/4.0);
- }
-
- // now output the tri's
- for (n=0; n<4; n++) {
- outVerts[numOutVerts++] = verts[k+n];
- outVerts[numOutVerts++] = mid;
- if (n<3) {
- outVerts[numOutVerts++] = verts[k+n+1];
- } else {
- outVerts[numOutVerts++] = verts[k];
- }
- }
-
- }
-
- if (!(trail->flags & TJFL_NOPOLYMERGE)) {
- trap_R_AddPolysToScene( trail->shader, 3, &outVerts[0], numOutVerts/3 );
- } else {
- int k;
- for (k=0; k<numOutVerts/3; k++) {
- trap_R_AddPolyToScene( trail->shader, 3, &outVerts[k*3] );
- }
- }
- }
- else
- {
- // send the polygons
- // FIXME: is it possible to send a GL_STRIP here? We are actually sending 2x the verts we really need to
- if (!(trail->flags & TJFL_NOPOLYMERGE)) {
- trap_R_AddPolysToScene( trail->shader, 4, &verts[0], i/4 );
- } else {
- int k;
- for (k=0; k<i/4; k++) {
- trap_R_AddPolyToScene( trail->shader, 4, &verts[k*4] );
- }
- }
- }
-
- // do we need to make another pass?
- if (trail->flags & TJFL_CROSSOVER) {
- if (iteration < 2) {
- CG_AddTrailToScene( trail, iteration + 1, numJuncs );
- }
- }
+ int k, i, n, l, numOutVerts;
+ polyVert_t mid;
+ float mod[ 4 ];
+ float sInc = 0.0f, s = 0.0f; // TTimo: init
+ trailJunc_t *j, *jNext;
+ vec3_t fwd, up, p, v;
+
+ // clipping vars
+ #define TRAIL_FADE_CLOSE_DIST 64.0
+ #define TRAIL_FADE_FAR_SCALE 4.0
+ vec3_t viewProj;
+ float viewDist, fadeAlpha;
+
+ // add spark shader at head position
+ if( trail->flags & TJFL_SPARKHEADFLARE )
+ {
+ j = trail;
+ VectorCopy( j->pos, p );
+ VectorMA( p, -j->width * 2, vup, p );
+ VectorMA( p, -j->width * 2, vright, p );
+ VectorCopy( p, verts[ 0 ].xyz );
+ verts[ 0 ].st[ 0 ] = 0;
+ verts[ 0 ].st[ 1 ] = 0;
+ verts[ 0 ].modulate[ 0 ] = 255;
+ verts[ 0 ].modulate[ 1 ] = 255;
+ verts[ 0 ].modulate[ 2 ] = 255;
+ verts[ 0 ].modulate[ 3 ] = (unsigned char)( j->alpha * 255.0 );
+
+ VectorCopy( j->pos, p );
+ VectorMA( p, -j->width * 2, vup, p );
+ VectorMA( p, j->width * 2, vright, p );
+ VectorCopy( p, verts[ 1 ].xyz );
+ verts[ 1 ].st[ 0 ] = 0;
+ verts[ 1 ].st[ 1 ] = 1;
+ verts[ 1 ].modulate[ 0 ] = 255;
+ verts[ 1 ].modulate[ 1 ] = 255;
+ verts[ 1 ].modulate[ 2 ] = 255;
+ verts[ 1 ].modulate[ 3 ] = (unsigned char)( j->alpha * 255.0 );
+
+ VectorCopy( j->pos, p );
+ VectorMA( p, j->width * 2, vup, p );
+ VectorMA( p, j->width * 2, vright, p );
+ VectorCopy( p, verts[ 2 ].xyz );
+ verts[ 2 ].st[ 0 ] = 1;
+ verts[ 2 ].st[ 1 ] = 1;
+ verts[ 2 ].modulate[ 0 ] = 255;
+ verts[ 2 ].modulate[ 1 ] = 255;
+ verts[ 2 ].modulate[ 2 ] = 255;
+ verts[ 2 ].modulate[ 3 ] = (unsigned char)( j->alpha * 255.0 );
+
+ VectorCopy( j->pos, p );
+ VectorMA( p, j->width * 2, vup, p );
+ VectorMA( p, -j->width * 2, vright, p );
+ VectorCopy( p, verts[ 3 ].xyz );
+ verts[ 3 ].st[ 0 ] = 1;
+ verts[ 3 ].st[ 1 ] = 0;
+ verts[ 3 ].modulate[ 0 ] = 255;
+ verts[ 3 ].modulate[ 1 ] = 255;
+ verts[ 3 ].modulate[ 2 ] = 255;
+ verts[ 3 ].modulate[ 3 ] = (unsigned char)( j->alpha * 255.0 );
+
+ trap_R_AddPolyToScene( cgs.media.sparkFlareShader, 4, verts );
+ }
+
+// if (trail->flags & TJFL_CROSSOVER && iteration < 1) {
+// iteration = 1;
+// }
+
+ if( !numJuncs )
+ {
+ // first count the number of juncs in the trail
+ j = trail;
+ numJuncs = 0;
+ sInc = 0;
+
+ while( j )
+ {
+ numJuncs++;
+
+ // check for a dead next junc
+ if( !j->inuse && j->nextJunc && !j->nextJunc->inuse )
+ CG_KillTrail( j );
+ else if( j->nextJunc && j->nextJunc->freed )
+ {
+ // not sure how this can happen, but it does, and causes infinite loops
+ j->nextJunc = NULL;
+ }
+
+ if( j->nextJunc )
+ sInc += VectorDistance( j->nextJunc->pos, j->pos );
+
+ j = j->nextJunc;
+ }
+ }
+
+ if( numJuncs < 2 )
+ return;
+
+ if( trail->sType == STYPE_STRETCH )
+ {
+ //sInc = ((1.0 - 0.1) / (float)(numJuncs)); // hack, the end of funnel shows a bit of the start (looping)
+ s = 0.05;
+ //s = 0.05;
+ }
+ else if( trail->sType == STYPE_REPEAT )
+ s = trail->sTex;
+
+ // now traverse the list
+ j = trail;
+ jNext = j->nextJunc;
+ i = 0;
+ while( jNext )
+ {
+ // first get the directional vectors to the next junc
+ VectorSubtract( jNext->pos, j->pos, fwd );
+ GetPerpendicularViewVector( cg.refdef.vieworg, j->pos, jNext->pos, up );
+
+ // if it's a crossover, draw it twice
+ if( j->flags & TJFL_CROSSOVER )
+ {
+ if( iteration > 0 )
+ {
+ ProjectPointOntoVector( cg.refdef.vieworg, j->pos, jNext->pos, viewProj );
+ VectorSubtract( cg.refdef.vieworg, viewProj, v );
+ VectorNormalize( v );
+
+ if( iteration == 1 )
+ VectorMA( up, 0.3, v, up );
+ else
+ VectorMA( up, -0.3, v, up );
+
+ VectorNormalize( up );
+ }
+ }
+ // do fading when moving towards the projection point onto the trail segment vector
+ else if( !( j->flags & TJFL_NOCULL ) && ( j->widthEnd > 4 || jNext->widthEnd > 4 ) )
+ {
+ ProjectPointOntoVector( cg.refdef.vieworg, j->pos, jNext->pos, viewProj );
+ viewDist = Distance( viewProj, cg.refdef.vieworg );
+
+ if( viewDist < ( TRAIL_FADE_CLOSE_DIST * TRAIL_FADE_FAR_SCALE ) )
+ {
+ if( viewDist < TRAIL_FADE_CLOSE_DIST )
+ fadeAlpha = 0.0;
+ else
+ fadeAlpha = ( viewDist - TRAIL_FADE_CLOSE_DIST ) / ( TRAIL_FADE_CLOSE_DIST * TRAIL_FADE_FAR_SCALE );
+
+ if( fadeAlpha < j->alpha )
+ j->alpha = fadeAlpha;
+
+ if( fadeAlpha < jNext->alpha )
+ jNext->alpha = fadeAlpha;
+ }
+ }
+
+ // now output the QUAD for this segment
+
+ // 1 ----
+ VectorMA( j->pos, 0.5 * j->width, up, p );
+ VectorCopy( p, verts[ i ].xyz );
+ verts[ i ].st[ 0 ] = s;
+ verts[ i ].st[ 1 ] = 1.0;
+
+ for( k = 0; k < 3; k++ )
+ verts[ i ].modulate[ k ] = (unsigned char)( j->color[ k ] * 255.0 );
+
+ verts[ i ].modulate[ 3 ] = (unsigned char)( j->alpha * 255.0 );
+
+ // blend this with the previous junc
+ if( j != trail )
+ {
+ VectorAdd( verts[ i ].xyz, verts[ i - 1 ].xyz, verts[ i ].xyz );
+ VectorScale( verts[ i ].xyz, 0.5, verts[ i ].xyz );
+ VectorCopy( verts[ i ].xyz, verts[ i - 1 ].xyz );
+ }
+ else if( j->flags & TJFL_FADEIN )
+ verts[ i ].modulate[ 3 ] = 0; // fade in
+
+ i++;
+
+ // 2 ----
+ VectorMA( p, -1 * j->width, up, p );
+ VectorCopy( p, verts[ i ].xyz );
+ verts[ i ].st[ 0 ] = s;
+ verts[ i ].st[ 1 ] = 0.0;
+
+ for( k = 0; k < 3; k++ )
+ verts[ i ].modulate[ k ] = (unsigned char)( j->color[ k ] * 255.0 );
+
+ verts[ i ].modulate[ 3 ] = (unsigned char)( j->alpha * 255.0 );
+
+ // blend this with the previous junc
+ if( j != trail )
+ {
+ VectorAdd( verts[ i ].xyz, verts[ i - 3 ].xyz, verts[ i ].xyz );
+ VectorScale( verts[ i ].xyz, 0.5, verts[ i ].xyz );
+ VectorCopy( verts[ i ].xyz, verts[ i - 3 ].xyz );
+ }
+ else if( j->flags & TJFL_FADEIN )
+ verts[ i ].modulate[ 3 ] = 0; // fade in
+
+ i++;
+
+ if( trail->sType == STYPE_REPEAT )
+ s = jNext->sTex;
+ else
+ {
+ //s += sInc;
+ s += VectorDistance( j->pos, jNext->pos ) / sInc;
+ if( s > 1.0 )
+ s = 1.0;
+ }
+
+ // 3 ----
+ VectorMA( jNext->pos, -0.5 * jNext->width, up, p );
+ VectorCopy( p, verts[ i ].xyz );
+ verts[ i ].st[ 0 ] = s;
+ verts[ i ].st[ 1 ] = 0.0;
+
+ for( k = 0; k < 3; k++ )
+ verts[ i ].modulate[ k ] = (unsigned char)( jNext->color[ k ] * 255.0 );
+
+ verts[ i ].modulate[ 3 ] = (unsigned char)( jNext->alpha * 255.0 );
+ i++;
+
+ // 4 ----
+ VectorMA( p, jNext->width, up, p );
+ VectorCopy( p, verts[ i ].xyz );
+ verts[ i ].st[ 0 ] = s;
+ verts[ i ].st[ 1 ] = 1.0;
+
+ for( k = 0; k < 3; k++ )
+ verts[ i ].modulate[ k ] = (unsigned char)( jNext->color[ k ] * 255.0 );
+
+ verts[ i ].modulate[ 3 ] = (unsigned char)( jNext->alpha * 255.0 );
+ i++;
+
+ if( i + 4 > MAX_TRAIL_VERTS )
+ break;
+
+ j = jNext;
+ jNext = j->nextJunc;
+ }
+
+ if( trail->flags & TJFL_FIXDISTORT )
+ {
+ // build the list of outVerts, by dividing up the QUAD's into 4 Tri's each, so as to allow
+ // any shaped (convex) Quad without bilinear distortion
+ for( k = 0, numOutVerts = 0; k < i; k += 4 )
+ {
+ VectorCopy( verts[ k ].xyz, mid.xyz );
+ mid.st[ 0 ] = verts[ k ].st[ 0 ];
+ mid.st[ 1 ] = verts[ k ].st[ 1 ];
+
+ for( l = 0; l < 4; l++ )
+ mod[ l ] = (float)verts[ k ].modulate[ l ];
+
+ for( n = 1; n < 4; n++ )
+ {
+ VectorAdd( verts[ k + n ].xyz, mid.xyz, mid.xyz );
+ mid.st[ 0 ] += verts[ k + n ].st[ 0 ];
+ mid.st[ 1 ] += verts[ k + n ].st[ 1 ];
+
+ for( l = 0; l < 4; l++ )
+ mod[ l ] += (float)verts[ k + n ].modulate[ l ];
+ }
+
+ VectorScale( mid.xyz, 0.25, mid.xyz );
+ mid.st[ 0 ] *= 0.25;
+ mid.st[ 1 ] *= 0.25;
+
+ for( l = 0; l < 4; l++ )
+ mid.modulate[ l ] = (unsigned char)( mod[ l ] / 4.0 );
+
+ // now output the tri's
+ for( n = 0; n < 4; n++ )
+ {
+ outVerts[ numOutVerts++ ] = verts[ k + n ];
+ outVerts[ numOutVerts++ ] = mid;
+
+ if( n < 3 )
+ outVerts[ numOutVerts++ ] = verts[ k + n + 1 ];
+ else
+ outVerts[ numOutVerts++ ] = verts[ k ];
+ }
+
+ }
+
+ if( !( trail->flags & TJFL_NOPOLYMERGE ) )
+ trap_R_AddPolysToScene( trail->shader, 3, &outVerts[ 0 ], numOutVerts / 3 );
+ else
+ {
+ int k;
+
+ for( k = 0; k < numOutVerts / 3; k++ )
+ trap_R_AddPolyToScene( trail->shader, 3, &outVerts[ k * 3 ] );
+ }
+ }
+ else
+ {
+ // send the polygons
+ // FIXME: is it possible to send a GL_STRIP here? We are actually sending 2x the verts we really need to
+ if( !( trail->flags & TJFL_NOPOLYMERGE ) )
+ trap_R_AddPolysToScene( trail->shader, 4, &verts[ 0 ], i / 4 );
+ else
+ {
+ int k;
+
+ for( k = 0; k < i / 4; k++ )
+ trap_R_AddPolyToScene( trail->shader, 4, &verts[ k * 4 ] );
+ }
+ }
+
+ // do we need to make another pass?
+ if( trail->flags & TJFL_CROSSOVER )
+ {
+ if( iteration < 2 )
+ CG_AddTrailToScene( trail, iteration + 1, numJuncs );
+ }
}
@@ -677,52 +749,68 @@ void CG_AddTrailToScene( trailJunc_t *trail, int iteration, int numJuncs )
CG_AddTrails
===============
*/
-void CG_AddTrails(void)
+void CG_AddTrails( void )
{
- float lifeFrac;
- trailJunc_t *j, *jNext;
-
- if (!initTrails) {
- CG_ClearTrails();
- }
-
- //AngleVectors( cg.snap->ps.viewangles, vforward, vright, vup );
- VectorCopy( cg.refdef.viewaxis[0], vforward );
- VectorCopy( cg.refdef.viewaxis[1], vright );
- VectorCopy( cg.refdef.viewaxis[2], vup );
-
- // update the settings for each junc
- j = activeTrails;
- while (j) {
- lifeFrac = (float)(cg.time - j->spawnTime) / (float)(j->endTime - j->spawnTime);
- if (lifeFrac >= 1.0) {
- j->inuse = qfalse; // flag it as dead
- j->width = j->widthEnd;
- j->alpha = j->alphaEnd;
- if (j->alpha > 1.0) j->alpha = 1.0;
- else if (j->alpha < 0.0) j->alpha = 0.0;
- VectorCopy( j->colorEnd, j->color );
- } else {
- j->width = j->widthStart + (j->widthEnd - j->widthStart) * lifeFrac;
- j->alpha = j->alphaStart + (j->alphaEnd - j->alphaStart) * lifeFrac;
- if (j->alpha > 1.0) j->alpha = 1.0;
- else if (j->alpha < 0.0) j->alpha = 0.0;
- VectorSubtract( j->colorEnd, j->colorStart, j->color );
- VectorMA( j->colorStart, lifeFrac, j->color, j->color );
- }
-
- j = j->nextGlobal;
- }
-
- // draw the trailHeads
- j = headTrails;
- while (j) {
- jNext = j->nextHead; // in case it gets removed
- if (!j->inuse) {
- CG_FreeTrailJunc(j);
- } else {
- CG_AddTrailToScene( j, 0, 0 );
- }
- j = jNext;
- }
+ float lifeFrac;
+ trailJunc_t *j, *jNext;
+
+ if( !initTrails )
+ CG_ClearTrails( );
+
+ //AngleVectors( cg.snap->ps.viewangles, vforward, vright, vup );
+ VectorCopy( cg.refdef.viewaxis[ 0 ], vforward );
+ VectorCopy( cg.refdef.viewaxis[ 1 ], vright );
+ VectorCopy( cg.refdef.viewaxis[ 2 ], vup );
+
+ // update the settings for each junc
+ j = activeTrails;
+
+ while( j )
+ {
+ lifeFrac = (float)( cg.time - j->spawnTime ) / (float)( j->endTime - j->spawnTime );
+
+ if( lifeFrac >= 1.0 )
+ {
+ j->inuse = qfalse; // flag it as dead
+ j->width = j->widthEnd;
+ j->alpha = j->alphaEnd;
+
+ if( j->alpha > 1.0 )
+ j->alpha = 1.0;
+ else if( j->alpha < 0.0 )
+ j->alpha = 0.0;
+
+ VectorCopy( j->colorEnd, j->color );
+ }
+ else
+ {
+ j->width = j->widthStart + ( j->widthEnd - j->widthStart ) * lifeFrac;
+ j->alpha = j->alphaStart + ( j->alphaEnd - j->alphaStart ) * lifeFrac;
+
+ if( j->alpha > 1.0 )
+ j->alpha = 1.0;
+ else if( j->alpha < 0.0 )
+ j->alpha = 0.0;
+
+ VectorSubtract( j->colorEnd, j->colorStart, j->color );
+ VectorMA( j->colorStart, lifeFrac, j->color, j->color );
+ }
+
+ j = j->nextGlobal;
+ }
+
+ // draw the trailHeads
+ j = headTrails;
+
+ while( j )
+ {
+ jNext = j->nextHead; // in case it gets removed
+
+ if( !j->inuse )
+ CG_FreeTrailJunc( j );
+ else
+ CG_AddTrailToScene( j, 0, 0 );
+
+ j = jNext;
+ }
}
diff --git a/src/cgame/cg_view.c b/src/cgame/cg_view.c
index 6c5d2ad3..afe9c979 100644
--- a/src/cgame/cg_view.c
+++ b/src/cgame/cg_view.c
@@ -62,32 +62,36 @@ Creates an entity in front of the current position, which
can then be moved around
=================
*/
-void CG_TestModel_f (void) {
+void CG_TestModel_f( void )
+{
vec3_t angles;
- memset( &cg.testModelEntity, 0, sizeof(cg.testModelEntity) );
- if ( trap_Argc() < 2 ) {
+ memset( &cg.testModelEntity, 0, sizeof( cg.testModelEntity ) );
+
+ if( trap_Argc( ) < 2 )
return;
- }
- Q_strncpyz (cg.testModelName, CG_Argv( 1 ), MAX_QPATH );
+ Q_strncpyz( cg.testModelName, CG_Argv( 1 ), MAX_QPATH );
cg.testModelEntity.hModel = trap_R_RegisterModel( cg.testModelName );
- if ( trap_Argc() == 3 ) {
+ if( trap_Argc( ) == 3 )
+ {
cg.testModelEntity.backlerp = atof( CG_Argv( 2 ) );
cg.testModelEntity.frame = 1;
cg.testModelEntity.oldframe = 0;
}
- if (! cg.testModelEntity.hModel ) {
+
+ if( !cg.testModelEntity.hModel )
+ {
CG_Printf( "Can't register model\n" );
return;
}
- VectorMA( cg.refdef.vieworg, 100, cg.refdef.viewaxis[0], cg.testModelEntity.origin );
+ VectorMA( cg.refdef.vieworg, 100, cg.refdef.viewaxis[ 0 ], cg.testModelEntity.origin );
- angles[PITCH] = 0;
- angles[YAW] = 180 + cg.refdefViewAngles[1];
- angles[ROLL] = 0;
+ angles[ PITCH ] = 0;
+ angles[ YAW ] = 180 + cg.refdefViewAngles[ 1 ];
+ angles[ ROLL ] = 0;
AnglesToAxis( angles, cg.testModelEntity.axis );
cg.testGun = qfalse;
@@ -100,61 +104,73 @@ CG_TestGun_f
Replaces the current view weapon with the given model
=================
*/
-void CG_TestGun_f (void) {
- CG_TestModel_f();
+void CG_TestGun_f( void )
+{
+ CG_TestModel_f( );
cg.testGun = qtrue;
cg.testModelEntity.renderfx = RF_MINLIGHT | RF_DEPTHHACK | RF_FIRST_PERSON;
}
-void CG_TestModelNextFrame_f (void) {
+void CG_TestModelNextFrame_f( void )
+{
cg.testModelEntity.frame++;
CG_Printf( "frame %i\n", cg.testModelEntity.frame );
}
-void CG_TestModelPrevFrame_f (void) {
+void CG_TestModelPrevFrame_f( void )
+{
cg.testModelEntity.frame--;
- if ( cg.testModelEntity.frame < 0 ) {
+
+ if( cg.testModelEntity.frame < 0 )
cg.testModelEntity.frame = 0;
- }
+
CG_Printf( "frame %i\n", cg.testModelEntity.frame );
}
-void CG_TestModelNextSkin_f (void) {
+void CG_TestModelNextSkin_f( void )
+{
cg.testModelEntity.skinNum++;
CG_Printf( "skin %i\n", cg.testModelEntity.skinNum );
}
-void CG_TestModelPrevSkin_f (void) {
+void CG_TestModelPrevSkin_f( void )
+{
cg.testModelEntity.skinNum--;
- if ( cg.testModelEntity.skinNum < 0 ) {
+
+ if( cg.testModelEntity.skinNum < 0 )
cg.testModelEntity.skinNum = 0;
- }
+
CG_Printf( "skin %i\n", cg.testModelEntity.skinNum );
}
-static void CG_AddTestModel (void) {
+static void CG_AddTestModel( void )
+{
int i;
// re-register the model, because the level may have changed
cg.testModelEntity.hModel = trap_R_RegisterModel( cg.testModelName );
- if (! cg.testModelEntity.hModel ) {
+
+ if( ! cg.testModelEntity.hModel )
+ {
CG_Printf ("Can't register model\n");
return;
}
// if testing a gun, set the origin reletive to the view origin
- if ( cg.testGun ) {
+ if( cg.testGun )
+ {
VectorCopy( cg.refdef.vieworg, cg.testModelEntity.origin );
- VectorCopy( cg.refdef.viewaxis[0], cg.testModelEntity.axis[0] );
- VectorCopy( cg.refdef.viewaxis[1], cg.testModelEntity.axis[1] );
- VectorCopy( cg.refdef.viewaxis[2], cg.testModelEntity.axis[2] );
+ VectorCopy( cg.refdef.viewaxis[ 0 ], cg.testModelEntity.axis[ 0 ] );
+ VectorCopy( cg.refdef.viewaxis[ 1 ], cg.testModelEntity.axis[ 1 ] );
+ VectorCopy( cg.refdef.viewaxis[ 2 ], cg.testModelEntity.axis[ 2 ] );
// allow the position to be adjusted
- for (i=0 ; i<3 ; i++) {
- cg.testModelEntity.origin[i] += cg.refdef.viewaxis[0][i] * cg_gun_x.value;
- cg.testModelEntity.origin[i] += cg.refdef.viewaxis[1][i] * cg_gun_y.value;
- cg.testModelEntity.origin[i] += cg.refdef.viewaxis[2][i] * cg_gun_z.value;
+ for( i = 0; i < 3; i++ )
+ {
+ cg.testModelEntity.origin[ i ] += cg.refdef.viewaxis[ 0 ][ i ] * cg_gun_x.value;
+ cg.testModelEntity.origin[ i ] += cg.refdef.viewaxis[ 1 ][ i ] * cg_gun_y.value;
+ cg.testModelEntity.origin[ i ] += cg.refdef.viewaxis[ 2 ][ i ] * cg_gun_z.value;
}
}
@@ -173,33 +189,38 @@ CG_CalcVrect
Sets the coordinates of the rendered window
=================
*/
-static void CG_CalcVrect (void) {
+static void CG_CalcVrect( void )
+{
int size;
// the intermission should allways be full screen
- if ( cg.snap->ps.pm_type == PM_INTERMISSION ) {
+ if( cg.snap->ps.pm_type == PM_INTERMISSION )
size = 100;
- } else {
+ else
+ {
// bound normal viewsize
- if (cg_viewsize.integer < 30) {
- trap_Cvar_Set ("cg_viewsize","30");
+ if( cg_viewsize.integer < 30 )
+ {
+ trap_Cvar_Set( "cg_viewsize", "30" );
size = 30;
- } else if (cg_viewsize.integer > 100) {
- trap_Cvar_Set ("cg_viewsize","100");
+ }
+ else if( cg_viewsize.integer > 100 )
+ {
+ trap_Cvar_Set( "cg_viewsize","100" );
size = 100;
- } else {
- size = cg_viewsize.integer;
}
-
+ else
+ size = cg_viewsize.integer;
}
- cg.refdef.width = cgs.glconfig.vidWidth*size/100;
+
+ cg.refdef.width = cgs.glconfig.vidWidth * size / 100;
cg.refdef.width &= ~1;
- cg.refdef.height = cgs.glconfig.vidHeight*size/100;
+ cg.refdef.height = cgs.glconfig.vidHeight * size / 100;
cg.refdef.height &= ~1;
- cg.refdef.x = (cgs.glconfig.vidWidth - cg.refdef.width)/2;
- cg.refdef.y = (cgs.glconfig.vidHeight - cg.refdef.height)/2;
+ cg.refdef.x = ( cgs.glconfig.vidWidth - cg.refdef.width ) / 2;
+ cg.refdef.y = ( cgs.glconfig.vidHeight - cg.refdef.height ) / 2;
}
//==============================================================================
@@ -328,7 +349,7 @@ static void CG_StepOffset( void )
if( ps->stats[ STAT_STATE ] & SS_WALLCLIMBING )
VectorMA( cg.refdef.vieworg, -stepChange, normal, cg.refdef.vieworg );
else
- cg.refdef.vieworg[2] -= stepChange;
+ cg.refdef.vieworg[ 2 ] -= stepChange;
}
}
@@ -345,17 +366,18 @@ CG_OffsetFirstPersonView
===============
*/
-static void CG_OffsetFirstPersonView( void ) {
- float *origin;
- float *angles;
- float bob;
- float ratio;
- float delta;
- float speed;
- float f;
- vec3_t predictedVelocity;
- int timeDelta;
- float bob2;
+static void CG_OffsetFirstPersonView( void )
+{
+ float *origin;
+ float *angles;
+ float bob;
+ float ratio;
+ float delta;
+ float speed;
+ float f;
+ vec3_t predictedVelocity;
+ int timeDelta;
+ float bob2;
vec3_t normal, baseOrigin;
playerState_t *ps = &cg.predictedPlayerState;
@@ -370,9 +392,8 @@ static void CG_OffsetFirstPersonView( void ) {
VectorSet( normal, 0.0f, 0.0f, 1.0f );
- if ( cg.snap->ps.pm_type == PM_INTERMISSION ) {
+ if( cg.snap->ps.pm_type == PM_INTERMISSION )
return;
- }
origin = cg.refdef.vieworg;
angles = cg.refdefViewAngles;
@@ -380,29 +401,35 @@ static void CG_OffsetFirstPersonView( void ) {
VectorCopy( origin, baseOrigin );
// if dead, fix the angle and don't add any kick
- if ( cg.snap->ps.stats[STAT_HEALTH] <= 0 ) {
- angles[ROLL] = 40;
- angles[PITCH] = -15;
- angles[YAW] = cg.snap->ps.generic1;
- origin[2] += cg.predictedPlayerState.viewheight;
+ if( cg.snap->ps.stats[ STAT_HEALTH ] <= 0 )
+ {
+ angles[ ROLL ] = 40;
+ angles[ PITCH ] = -15;
+ angles[ YAW ] = cg.snap->ps.generic1;
+ origin[ 2 ] += cg.predictedPlayerState.viewheight;
return;
}
// add angles based on weapon kick
- VectorAdd (angles, cg.kick_angles, angles);
+ VectorAdd( angles, cg.kick_angles, angles );
// add angles based on damage kick
- if ( cg.damageTime ) {
+ if( cg.damageTime )
+ {
ratio = cg.time - cg.damageTime;
- if ( ratio < DAMAGE_DEFLECT_TIME ) {
+ if( ratio < DAMAGE_DEFLECT_TIME )
+ {
ratio /= DAMAGE_DEFLECT_TIME;
- angles[PITCH] += ratio * cg.v_dmg_pitch;
- angles[ROLL] += ratio * cg.v_dmg_roll;
- } else {
+ angles[ PITCH ] += ratio * cg.v_dmg_pitch;
+ angles[ ROLL ] += ratio * cg.v_dmg_roll;
+ }
+ else
+ {
ratio = 1.0 - ( ratio - DAMAGE_DEFLECT_TIME ) / DAMAGE_RETURN_TIME;
- if ( ratio > 0 ) {
- angles[PITCH] += ratio * cg.v_dmg_pitch;
- angles[ROLL] += ratio * cg.v_dmg_roll;
+ if( ratio > 0 )
+ {
+ angles[ PITCH ] += ratio * cg.v_dmg_pitch;
+ angles[ ROLL ] += ratio * cg.v_dmg_roll;
}
}
}
@@ -418,11 +445,11 @@ static void CG_OffsetFirstPersonView( void ) {
// add angles based on velocity
VectorCopy( cg.predictedPlayerState.velocity, predictedVelocity );
- delta = DotProduct ( predictedVelocity, cg.refdef.viewaxis[0]);
- angles[PITCH] += delta * cg_runpitch.value;
+ delta = DotProduct( predictedVelocity, cg.refdef.viewaxis[ 0 ] );
+ angles[ PITCH ] += delta * cg_runpitch.value;
- delta = DotProduct ( predictedVelocity, cg.refdef.viewaxis[1]);
- angles[ROLL] -= delta * cg_runroll.value;
+ delta = DotProduct( predictedVelocity, cg.refdef.viewaxis[ 1 ] );
+ angles[ ROLL ] -= delta * cg_runroll.value;
// add angles based on bob
//TA: bob amount is class dependant
@@ -433,15 +460,18 @@ static void CG_OffsetFirstPersonView( void ) {
speed = cg.xyspeed > 200 ? cg.xyspeed : 200;
delta = cg.bobfracsin * ( bob2 ) * speed;
- if (cg.predictedPlayerState.pm_flags & PMF_DUCKED)
+ if( cg.predictedPlayerState.pm_flags & PMF_DUCKED )
delta *= 3; // crouching
- angles[PITCH] += delta;
+
+ angles[ PITCH ] += delta;
delta = cg.bobfracsin * ( bob2 ) * speed;
- if (cg.predictedPlayerState.pm_flags & PMF_DUCKED)
+ if( cg.predictedPlayerState.pm_flags & PMF_DUCKED )
delta *= 3; // crouching accentuates roll
- if (cg.bobcycle & 1)
+
+ if( cg.bobcycle & 1 )
delta = -delta;
- angles[ROLL] += delta;
+
+ angles[ ROLL ] += delta;
}
//provide some feedback for pouncing
@@ -665,77 +695,68 @@ static void CG_OffsetFirstPersonView( void ) {
if( cg.predictedPlayerState.stats[ STAT_STATE ] & SS_WALLCLIMBING )
VectorMA( origin, ps->viewheight, normal, origin );
else
- origin[2] += cg.predictedPlayerState.viewheight;
+ origin[ 2 ] += cg.predictedPlayerState.viewheight;
// smooth out duck height changes
timeDelta = cg.time - cg.duckTime;
- if ( timeDelta < DUCK_TIME) {
- cg.refdef.vieworg[2] -= cg.duckChange
- * (DUCK_TIME - timeDelta) / DUCK_TIME;
+ if( timeDelta < DUCK_TIME)
+ {
+ cg.refdef.vieworg[ 2 ] -= cg.duckChange
+ * ( DUCK_TIME - timeDelta ) / DUCK_TIME;
}
// add bob height
bob = cg.bobfracsin * cg.xyspeed * cg_bobup.value;
- if (bob > 6) {
+
+ if( bob > 6 )
bob = 6;
- }
//TA: likewise for bob
if( cg.predictedPlayerState.stats[ STAT_STATE ] & SS_WALLCLIMBING )
VectorMA( origin, bob, normal, origin );
else
- origin[2] += bob;
+ origin[ 2 ] += bob;
// add fall height
delta = cg.time - cg.landTime;
+
if( delta < LAND_DEFLECT_TIME )
{
f = delta / LAND_DEFLECT_TIME;
- cg.refdef.vieworg[2] += cg.landChange * f;
+ cg.refdef.vieworg[ 2 ] += cg.landChange * f;
}
else if( delta < LAND_DEFLECT_TIME + LAND_RETURN_TIME )
{
delta -= LAND_DEFLECT_TIME;
f = 1.0 - ( delta / LAND_RETURN_TIME );
- cg.refdef.vieworg[2] += cg.landChange * f;
+ cg.refdef.vieworg[ 2 ] += cg.landChange * f;
}
// add step offset
- CG_StepOffset();
+ CG_StepOffset( );
// add kick offset
VectorAdd (origin, cg.kick_origin, origin);
-
- // pivot the eye based on a neck length
-#if 0
- {
-#define NECK_LENGTH 8
- vec3_t forward, up;
-
- cg.refdef.vieworg[2] -= NECK_LENGTH;
- AngleVectors( cg.refdefViewAngles, forward, NULL, up );
- VectorMA( cg.refdef.vieworg, 3, forward, cg.refdef.vieworg );
- VectorMA( cg.refdef.vieworg, NECK_LENGTH, up, cg.refdef.vieworg );
- }
-#endif
}
//======================================================================
-void CG_ZoomDown_f( void ) {
- if ( cg.zoomed ) {
+void CG_ZoomDown_f( void )
+{
+ if( cg.zoomed )
return;
- }
+
cg.zoomed = qtrue;
cg.zoomTime = cg.time;
}
-void CG_ZoomUp_f( void ) {
- if ( !cg.zoomed ) {
+void CG_ZoomUp_f( void )
+{
+ if( !cg.zoomed )
return;
- }
+
cg.zoomed = qfalse;
cg.zoomTime = cg.time;
}
@@ -753,7 +774,8 @@ Fixed fov at intermissions, otherwise account for fov variable and zooms.
#define FOVWARPTIME 400.0
-static int CG_CalcFov( void ) {
+static int CG_CalcFov( void )
+{
float x;
float phase;
float v;
@@ -768,7 +790,8 @@ static int CG_CalcFov( void ) {
attribFov = BG_FindFovForClass( cg.predictedPlayerState.stats[ STAT_PCLASS ] );
- if ( cg.predictedPlayerState.pm_type == PM_INTERMISSION ) {
+ if( cg.predictedPlayerState.pm_type == PM_INTERMISSION )
+ {
// if in intermission, use a fixed value
fov_x = 90;
}
@@ -832,16 +855,17 @@ static int CG_CalcFov( void ) {
// warp if underwater
contents = CG_PointContents( cg.refdef.vieworg, -1 );
- if ( contents & ( CONTENTS_WATER | CONTENTS_SLIME | CONTENTS_LAVA ) ){
+
+ if( contents & ( CONTENTS_WATER | CONTENTS_SLIME | CONTENTS_LAVA ) )
+ {
phase = cg.time / 1000.0 * WAVE_FREQUENCY * M_PI * 2;
v = WAVE_AMPLITUDE * sin( phase );
fov_x += v;
fov_y -= v;
inwater = qtrue;
}
- else {
+ else
inwater = qfalse;
- }
if( cg.predictedPlayerState.stats[ STAT_STATE ] & SS_POISONCLOUDED &&
cg.predictedPlayerState.stats[ STAT_HEALTH ] > 0 )
@@ -858,11 +882,10 @@ static int CG_CalcFov( void ) {
cg.refdef.fov_x = fov_x;
cg.refdef.fov_y = fov_y;
- if ( !cg.zoomed ) {
+ if( !cg.zoomed )
cg.zoomSensitivity = 1;
- } else {
+ else
cg.zoomSensitivity = cg.refdef.fov_y / 75.0;
- }
return inwater;
}
@@ -875,41 +898,40 @@ CG_DamageBlendBlob
===============
*/
-static void CG_DamageBlendBlob( void ) {
- int t;
- int maxTime;
- refEntity_t ent;
+static void CG_DamageBlendBlob( void )
+{
+ int t;
+ int maxTime;
+ refEntity_t ent;
- if ( !cg.damageValue ) {
+ if( !cg.damageValue )
return;
- }
// ragePro systems can't fade blends, so don't obscure the screen
- if ( cgs.glconfig.hardwareType == GLHW_RAGEPRO ) {
+ if( cgs.glconfig.hardwareType == GLHW_RAGEPRO )
return;
- }
maxTime = DAMAGE_TIME;
t = cg.time - cg.damageTime;
- if ( t <= 0 || t >= maxTime ) {
+
+ if( t <= 0 || t >= maxTime )
return;
- }
memset( &ent, 0, sizeof( ent ) );
ent.reType = RT_SPRITE;
ent.renderfx = RF_FIRST_PERSON;
- VectorMA( cg.refdef.vieworg, 8, cg.refdef.viewaxis[0], ent.origin );
- VectorMA( ent.origin, cg.damageX * -8, cg.refdef.viewaxis[1], ent.origin );
- VectorMA( ent.origin, cg.damageY * 8, cg.refdef.viewaxis[2], ent.origin );
+ VectorMA( cg.refdef.vieworg, 8, cg.refdef.viewaxis[ 0 ], ent.origin );
+ VectorMA( ent.origin, cg.damageX * -8, cg.refdef.viewaxis[ 1 ], ent.origin );
+ VectorMA( ent.origin, cg.damageY * 8, cg.refdef.viewaxis[ 2 ], ent.origin );
ent.radius = cg.damageValue * 3;
ent.customShader = cgs.media.viewBloodShader;
- ent.shaderRGBA[0] = 255;
- ent.shaderRGBA[1] = 255;
- ent.shaderRGBA[2] = 255;
- ent.shaderRGBA[3] = 200 * ( 1.0 - ((float)t / maxTime) );
+ ent.shaderRGBA[ 0 ] = 255;
+ ent.shaderRGBA[ 1 ] = 255;
+ ent.shaderRGBA[ 2 ] = 255;
+ ent.shaderRGBA[ 3 ] = 200 * ( 1.0 - ( (float)t / maxTime) );
trap_R_AddRefEntityToScene( &ent );
}
@@ -934,41 +956,41 @@ static void CG_DrawSurfNormal( void )
CG_Trace( &tr, cg.refdef.vieworg, NULL, NULL, end, cg.predictedPlayerState.clientNum, MASK_SOLID );
//CG_Printf( "%f %f %f\n", tr.plane.normal[ 0 ], tr.plane.normal[ 1 ], tr.plane.normal[ 2 ] );
- VectorCopy( tr.endpos, normal[0].xyz );
- normal[0].st[0] = 0;
- normal[0].st[1] = 0;
- normal[0].modulate[0] = 255;
- normal[0].modulate[1] = 255;
- normal[0].modulate[2] = 255;
- normal[0].modulate[3] = 255;
+ VectorCopy( tr.endpos, normal[ 0 ].xyz );
+ normal[ 0 ].st[ 0 ] = 0;
+ normal[ 0 ].st[ 1 ] = 0;
+ normal[ 0 ].modulate[ 0 ] = 255;
+ normal[ 0 ].modulate[ 1 ] = 255;
+ normal[ 0 ].modulate[ 2 ] = 255;
+ normal[ 0 ].modulate[ 3 ] = 255;
VectorAdd( up, tr.endpos, temp );
- VectorCopy( temp, normal[1].xyz);
- normal[1].st[0] = 0;
- normal[1].st[1] = 1;
- normal[1].modulate[0] = 255;
- normal[1].modulate[1] = 255;
- normal[1].modulate[2] = 255;
- normal[1].modulate[3] = 255;
+ VectorCopy( temp, normal[ 1 ].xyz);
+ normal[ 1 ].st[ 0 ] = 0;
+ normal[ 1 ].st[ 1 ] = 1;
+ normal[ 1 ].modulate[ 0 ] = 255;
+ normal[ 1 ].modulate[ 1 ] = 255;
+ normal[ 1 ].modulate[ 2 ] = 255;
+ normal[ 1 ].modulate[ 3 ] = 255;
VectorMA( tr.endpos, 64, tr.plane.normal, temp );
VectorAdd( temp, up, temp );
- VectorCopy( temp, normal[2].xyz );
- normal[2].st[0] = 1;
- normal[2].st[1] = 1;
- normal[2].modulate[0] = 255;
- normal[2].modulate[1] = 255;
- normal[2].modulate[2] = 255;
- normal[2].modulate[3] = 255;
+ VectorCopy( temp, normal[ 2 ].xyz );
+ normal[ 2 ].st[ 0 ] = 1;
+ normal[ 2 ].st[ 1 ] = 1;
+ normal[ 2 ].modulate[ 0 ] = 255;
+ normal[ 2 ].modulate[ 1 ] = 255;
+ normal[ 2 ].modulate[ 2 ] = 255;
+ normal[ 2 ].modulate[ 3 ] = 255;
VectorMA( tr.endpos, 64, tr.plane.normal, temp );
- VectorCopy( temp, normal[3].xyz );
- normal[3].st[0] = 1;
- normal[3].st[1] = 0;
- normal[3].modulate[0] = 255;
- normal[3].modulate[1] = 255;
- normal[3].modulate[2] = 255;
- normal[3].modulate[3] = 255;
+ VectorCopy( temp, normal[ 3 ].xyz );
+ normal[ 3 ].st[ 0 ] = 1;
+ normal[ 3 ].st[ 1 ] = 0;
+ normal[ 3 ].modulate[ 0 ] = 255;
+ normal[ 3 ].modulate[ 1 ] = 255;
+ normal[ 3 ].modulate[ 2 ] = 255;
+ normal[ 3 ].modulate[ 3 ] = 255;
trap_R_AddPolyToScene( cgs.media.whiteShader, 4, normal );
}
@@ -1096,7 +1118,8 @@ CG_CalcViewValues
Sets cg.refdef view values
===============
*/
-static int CG_CalcViewValues( void ) {
+static int CG_CalcViewValues( void )
+{
playerState_t *ps;
memset( &cg.refdef, 0, sizeof( cg.refdef ) );
@@ -1106,22 +1129,24 @@ static int CG_CalcViewValues( void ) {
// Q_strncpyz( cg.refdef.text[1], "19", sizeof(cg.refdef.text[1]) );
// calculate size of 3D view
- CG_CalcVrect();
+ CG_CalcVrect( );
ps = &cg.predictedPlayerState;
// intermission view
- if ( ps->pm_type == PM_INTERMISSION ) {
+ if( ps->pm_type == PM_INTERMISSION )
+ {
VectorCopy( ps->origin, cg.refdef.vieworg );
VectorCopy( ps->viewangles, cg.refdefViewAngles );
AnglesToAxis( cg.refdefViewAngles, cg.refdef.viewaxis );
- return CG_CalcFov();
+
+ return CG_CalcFov( );
}
cg.bobcycle = ( ps->bobCycle & 128 ) >> 7;
cg.bobfracsin = fabs( sin( ( ps->bobCycle & 127 ) / 127.0 * M_PI ) );
- cg.xyspeed = sqrt( ps->velocity[0] * ps->velocity[0] +
- ps->velocity[1] * ps->velocity[1] );
+ cg.xyspeed = sqrt( ps->velocity[ 0 ] * ps->velocity[ 0 ] +
+ ps->velocity[ 1 ] * ps->velocity[ 1 ] );
VectorCopy( ps->origin, cg.refdef.vieworg );
@@ -1133,72 +1158,44 @@ static int CG_CalcViewValues( void ) {
if( !( ps->stats[ STAT_STATE ] & SS_WALLCLIMBING ) )
VectorSet( cg.lastNormal, 0.0f, 0.0f, 1.0f );
- if (cg_cameraOrbit.integer) {
- if (cg.time > cg.nextOrbitTime) {
- cg.nextOrbitTime = cg.time + cg_cameraOrbitDelay.integer;
- cg_thirdPersonAngle.value += cg_cameraOrbit.value;
- }
- }
// add error decay
- if ( cg_errorDecay.value > 0 ) {
+ if( cg_errorDecay.value > 0 )
+ {
int t;
float f;
t = cg.time - cg.predictedErrorTime;
f = ( cg_errorDecay.value - t ) / cg_errorDecay.value;
- if ( f > 0 && f < 1 ) {
+
+ if( f > 0 && f < 1 )
VectorMA( cg.refdef.vieworg, f, cg.predictedError, cg.refdef.vieworg );
- } else {
+ else
cg.predictedErrorTime = 0;
- }
}
- if ( cg.renderingThirdPerson ) {
+ if( cg.renderingThirdPerson )
+ {
// back away from character
- CG_OffsetThirdPersonView();
- } else {
+ CG_OffsetThirdPersonView( );
+ }
+ else
+ {
// offset for local bobbing and kicks
- CG_OffsetFirstPersonView();
+ CG_OffsetFirstPersonView( );
}
// position eye reletive to origin
AnglesToAxis( cg.refdefViewAngles, cg.refdef.viewaxis );
- if ( cg.hyperspace ) {
+ if( cg.hyperspace )
cg.refdef.rdflags |= RDF_NOWORLDMODEL | RDF_HYPERSPACE;
- }
//draw the surface normal looking at
if( cg_drawSurfNormal.integer )
CG_DrawSurfNormal( );
// field of view
- return CG_CalcFov();
-}
-
-
-/*
-=====================
-CG_PowerupTimerSounds
-=====================
-*/
-static void CG_PowerupTimerSounds( void ) {
- int i;
- int t;
-
- // powerup timers going away
- for ( i = 0 ; i < MAX_POWERUPS ; i++ ) {
- t = cg.snap->ps.powerups[i];
- if ( t <= cg.time ) {
- continue;
- }
- if ( t - cg.time >= POWERUP_BLINKS * POWERUP_BLINK_TIME ) {
- continue;
- }
- if ( ( t - cg.time ) / POWERUP_BLINK_TIME != ( t - cg.oldTime ) / POWERUP_BLINK_TIME ) {
- trap_S_StartSound( NULL, cg.snap->ps.clientNum, CHAN_ITEM, cgs.media.wearOffSound );
- }
- }
+ return CG_CalcFov( );
}
/*
@@ -1206,14 +1203,16 @@ static void CG_PowerupTimerSounds( void ) {
CG_AddBufferedSound
=====================
*/
-void CG_AddBufferedSound( sfxHandle_t sfx ) {
- if ( !sfx )
+void CG_AddBufferedSound( sfxHandle_t sfx )
+{
+ if( !sfx )
return;
- cg.soundBuffer[cg.soundBufferIn] = sfx;
- cg.soundBufferIn = (cg.soundBufferIn + 1) % MAX_SOUNDBUFFER;
- if (cg.soundBufferIn == cg.soundBufferOut) {
+
+ cg.soundBuffer[ cg.soundBufferIn ] = sfx;
+ cg.soundBufferIn = ( cg.soundBufferIn + 1 ) % MAX_SOUNDBUFFER;
+
+ if( cg.soundBufferIn == cg.soundBufferOut )
cg.soundBufferOut++;
- }
}
/*
@@ -1221,12 +1220,15 @@ void CG_AddBufferedSound( sfxHandle_t sfx ) {
CG_PlayBufferedSounds
=====================
*/
-static void CG_PlayBufferedSounds( void ) {
- if ( cg.soundTime < cg.time ) {
- if (cg.soundBufferOut != cg.soundBufferIn && cg.soundBuffer[cg.soundBufferOut]) {
- trap_S_StartLocalSound(cg.soundBuffer[cg.soundBufferOut], CHAN_ANNOUNCER);
- cg.soundBuffer[cg.soundBufferOut] = 0;
- cg.soundBufferOut = (cg.soundBufferOut + 1) % MAX_SOUNDBUFFER;
+static void CG_PlayBufferedSounds( void )
+{
+ if( cg.soundTime < cg.time )
+ {
+ if( cg.soundBufferOut != cg.soundBufferIn && cg.soundBuffer[ cg.soundBufferOut ] )
+ {
+ trap_S_StartLocalSound( cg.soundBuffer[ cg.soundBufferOut ], CHAN_ANNOUNCER );
+ cg.soundBuffer[ cg.soundBufferOut ] = 0;
+ cg.soundBufferOut = ( cg.soundBufferOut + 1 ) % MAX_SOUNDBUFFER;
cg.soundTime = cg.time + 750;
}
}
@@ -1241,35 +1243,38 @@ CG_DrawActiveFrame
Generates and draws a game scene and status information at the given time.
=================
*/
-void CG_DrawActiveFrame( int serverTime, stereoFrame_t stereoView, qboolean demoPlayback ) {
+void CG_DrawActiveFrame( int serverTime, stereoFrame_t stereoView, qboolean demoPlayback )
+{
int inwater;
cg.time = serverTime;
cg.demoPlayback = demoPlayback;
// update cvars
- CG_UpdateCvars();
+ CG_UpdateCvars( );
// if we are only updating the screen as a loading
// pacifier, don't even try to read snapshots
- if ( cg.infoScreenText[0] != 0 ) {
+ if( cg.infoScreenText[ 0 ] != 0 )
+ {
CG_DrawLoadingScreen( );
return;
}
// any looped sounds will be respecified as entities
// are added to the render list
- trap_S_ClearLoopingSounds(qfalse);
+ trap_S_ClearLoopingSounds( qfalse );
// clear all the render lists
- trap_R_ClearScene();
+ trap_R_ClearScene( );
// set up cg.snap and possibly cg.nextSnap
- CG_ProcessSnapshots();
+ CG_ProcessSnapshots( );
// if we haven't received any snapshots yet, all
// we can draw is the information screen
- if ( !cg.snap || ( cg.snap->snapFlags & SNAPFLAG_NOT_ACTIVE ) ) {
+ if( !cg.snap || ( cg.snap->snapFlags & SNAPFLAG_NOT_ACTIVE ) )
+ {
CG_DrawLoadingScreen( );
return;
}
@@ -1281,46 +1286,41 @@ void CG_DrawActiveFrame( int serverTime, stereoFrame_t stereoView, qboolean demo
cg.clientFrame++;
// update cg.predictedPlayerState
- CG_PredictPlayerState();
+ CG_PredictPlayerState( );
// decide on third person view
- cg.renderingThirdPerson = cg_thirdPerson.integer || (cg.snap->ps.stats[STAT_HEALTH] <= 0);
+ cg.renderingThirdPerson = cg_thirdPerson.integer || ( cg.snap->ps.stats[ STAT_HEALTH ] <= 0 );
// build cg.refdef
- inwater = CG_CalcViewValues();
+ inwater = CG_CalcViewValues( );
// first person blend blobs, done after AnglesToAxis
- if ( !cg.renderingThirdPerson ) {
- CG_DamageBlendBlob();
- }
+ if( !cg.renderingThirdPerson )
+ CG_DamageBlendBlob( );
// build the render lists
- if ( !cg.hyperspace ) {
- CG_AddPacketEntities(); // adter calcViewValues, so predicted player state is correct
- CG_AddMarks();
- CG_AddLocalEntities();
+ if( !cg.hyperspace )
+ {
+ CG_AddPacketEntities( ); // adter calcViewValues, so predicted player state is correct
+ CG_AddMarks( );
+ CG_AddLocalEntities( );
//TA: wolf trails stuff
CG_AddTrails( ); // this must come last, so the trails dropped this frame get drawn
}
+
CG_AddViewWeapon( &cg.predictedPlayerState );
// add buffered sounds
- CG_PlayBufferedSounds();
-
- // play buffered voice chats
- CG_PlayBufferedVoiceChats();
+ CG_PlayBufferedSounds( );
// finish up the rest of the refdef
- if ( cg.testModelEntity.hModel ) {
- CG_AddTestModel();
- }
+ if( cg.testModelEntity.hModel )
+ CG_AddTestModel( );
+
cg.refdef.time = cg.time;
memcpy( cg.refdef.areamask, cg.snap->areamask, sizeof( cg.refdef.areamask ) );
- // warning sounds when powerup is wearing off
- /*CG_PowerupTimerSounds();*/
-
//remove expired console lines
if( cg.consoleLines[ 0 ].time + cg_consoleLatency.integer < cg.time && cg_consoleLatency.integer > 0 )
CG_RemoveConsoleLine( );
@@ -1329,35 +1329,40 @@ void CG_DrawActiveFrame( int serverTime, stereoFrame_t stereoView, qboolean demo
trap_S_Respatialize( cg.snap->ps.clientNum, cg.refdef.vieworg, cg.refdef.viewaxis, inwater );
// make sure the lagometerSample and frame timing isn't done twice when in stereo
- if ( stereoView != STEREO_RIGHT ) {
+ if( stereoView != STEREO_RIGHT )
+ {
cg.frametime = cg.time - cg.oldTime;
- if ( cg.frametime < 0 ) {
+
+ if( cg.frametime < 0 )
cg.frametime = 0;
- }
+
cg.oldTime = cg.time;
- CG_AddLagometerFrameInfo();
+ CG_AddLagometerFrameInfo( );
}
- if (cg_timescale.value != cg_timescaleFadeEnd.value) {
- if (cg_timescale.value < cg_timescaleFadeEnd.value) {
- cg_timescale.value += cg_timescaleFadeSpeed.value * ((float)cg.frametime) / 1000;
- if (cg_timescale.value > cg_timescaleFadeEnd.value)
+
+ if( cg_timescale.value != cg_timescaleFadeEnd.value )
+ {
+ if( cg_timescale.value < cg_timescaleFadeEnd.value )
+ {
+ cg_timescale.value += cg_timescaleFadeSpeed.value * ( (float)cg.frametime ) / 1000;
+ if( cg_timescale.value > cg_timescaleFadeEnd.value )
cg_timescale.value = cg_timescaleFadeEnd.value;
}
- else {
- cg_timescale.value -= cg_timescaleFadeSpeed.value * ((float)cg.frametime) / 1000;
- if (cg_timescale.value < cg_timescaleFadeEnd.value)
+ else
+ {
+ cg_timescale.value -= cg_timescaleFadeSpeed.value * ( (float)cg.frametime ) / 1000;
+ if( cg_timescale.value < cg_timescaleFadeEnd.value )
cg_timescale.value = cg_timescaleFadeEnd.value;
}
- if (cg_timescaleFadeSpeed.value) {
- trap_Cvar_Set("timescale", va("%f", cg_timescale.value));
- }
+
+ if( cg_timescaleFadeSpeed.value )
+ trap_Cvar_Set( "timescale", va( "%f", cg_timescale.value ) );
}
// actually issue the rendering calls
CG_DrawActive( stereoView );
- if ( cg_stats.integer ) {
+ if( cg_stats.integer )
CG_Printf( "cg.clientFrame:%i\n", cg.clientFrame );
- }
}
diff --git a/src/cgame/cg_weapons.c b/src/cgame/cg_weapons.c
index 8f83e288..91b048e4 100644
--- a/src/cgame/cg_weapons.c
+++ b/src/cgame/cg_weapons.c
@@ -22,52 +22,51 @@
CG_MachineGunEjectBrass
==========================
*/
-static void CG_MachineGunEjectBrass( centity_t *cent ) {
+static void CG_MachineGunEjectBrass( centity_t *cent )
+{
localEntity_t *le;
refEntity_t *re;
- vec3_t velocity, xvelocity;
- vec3_t offset, xoffset;
- float waterScale = 1.0f;
- vec3_t v[3];
+ vec3_t velocity, xvelocity;
+ vec3_t offset, xoffset;
+ float waterScale = 1.0f;
+ vec3_t v[ 3 ];
- if ( cg_brassTime.integer <= 0 ) {
+ if( cg_brassTime.integer <= 0 )
return;
- }
- le = CG_AllocLocalEntity();
+ le = CG_AllocLocalEntity( );
re = &le->refEntity;
- velocity[0] = 0;
- velocity[1] = -50 + 40 * crandom();
- velocity[2] = 100 + 50 * crandom();
+ velocity[ 0 ] = 0;
+ velocity[ 1 ] = -50 + 40 * crandom( );
+ velocity[ 2 ] = 100 + 50 * crandom( );
le->leType = LE_FRAGMENT;
le->startTime = cg.time;
- le->endTime = le->startTime + cg_brassTime.integer + ( cg_brassTime.integer / 4 ) * random();
+ le->endTime = le->startTime + cg_brassTime.integer + ( cg_brassTime.integer / 4 ) * random( );
le->pos.trType = TR_GRAVITY;
- le->pos.trTime = cg.time - (rand()&15);
+ le->pos.trTime = cg.time - ( rand( ) & 15 );
AnglesToAxis( cent->lerpAngles, v );
- offset[0] = 8;
- offset[1] = -4;
- offset[2] = 24;
+ offset[ 0 ] = 8;
+ offset[ 1 ] = -4;
+ offset[ 2 ] = 24;
- xoffset[0] = offset[0] * v[0][0] + offset[1] * v[1][0] + offset[2] * v[2][0];
- xoffset[1] = offset[0] * v[0][1] + offset[1] * v[1][1] + offset[2] * v[2][1];
- xoffset[2] = offset[0] * v[0][2] + offset[1] * v[1][2] + offset[2] * v[2][2];
+ xoffset[ 0 ] = offset[ 0 ] * v[ 0 ][ 0 ] + offset[ 1 ] * v[ 1 ][ 0 ] + offset[ 2 ] * v[ 2 ][ 0 ];
+ xoffset[ 1 ] = offset[ 0 ] * v[ 0 ][ 1 ] + offset[ 1 ] * v[ 1 ][ 1 ] + offset[ 2 ] * v[ 2 ][ 1 ];
+ xoffset[ 2 ] = offset[ 0 ] * v[ 0 ][ 2 ] + offset[ 1 ] * v[ 1 ][ 2 ] + offset[ 2 ] * v[ 2 ][ 2 ];
VectorAdd( cent->lerpOrigin, xoffset, re->origin );
VectorCopy( re->origin, le->pos.trBase );
- if ( CG_PointContents( re->origin, -1 ) & CONTENTS_WATER ) {
+ if( CG_PointContents( re->origin, -1 ) & CONTENTS_WATER )
waterScale = 0.10f;
- }
- xvelocity[0] = velocity[0] * v[0][0] + velocity[1] * v[1][0] + velocity[2] * v[2][0];
- xvelocity[1] = velocity[0] * v[0][1] + velocity[1] * v[1][1] + velocity[2] * v[2][1];
- xvelocity[2] = velocity[0] * v[0][2] + velocity[1] * v[1][2] + velocity[2] * v[2][2];
+ xvelocity[ 0 ] = velocity[ 0 ] * v[ 0 ][ 0 ] + velocity[ 1 ] * v[ 1 ][ 0 ] + velocity[ 2 ] * v[ 2 ][ 0 ];
+ xvelocity[ 1 ] = velocity[ 0 ] * v[ 0 ][ 1 ] + velocity[ 1 ] * v[ 1 ][ 1 ] + velocity[ 2 ] * v[ 2 ][ 1 ];
+ xvelocity[ 2 ] = velocity[ 0 ] * v[ 0 ][ 2 ] + velocity[ 1 ] * v[ 1 ][ 2 ] + velocity[ 2 ] * v[ 2 ][ 2 ];
VectorScale( xvelocity, waterScale, le->pos.trDelta );
AxisCopy( axisDefault, re->axis );
@@ -77,12 +76,12 @@ static void CG_MachineGunEjectBrass( centity_t *cent ) {
le->angles.trType = TR_LINEAR;
le->angles.trTime = cg.time;
- le->angles.trBase[0] = rand()&31;
- le->angles.trBase[1] = rand()&31;
- le->angles.trBase[2] = rand()&31;
- le->angles.trDelta[0] = 2;
- le->angles.trDelta[1] = 1;
- le->angles.trDelta[2] = 0;
+ le->angles.trBase[ 0 ] = rand( ) & 31;
+ le->angles.trBase[ 1 ] = rand( ) & 31;
+ le->angles.trBase[ 2 ] = rand( ) & 31;
+ le->angles.trDelta[ 0 ] = 2;
+ le->angles.trDelta[ 1 ] = 1;
+ le->angles.trDelta[ 2 ] = 0;
le->leFlags = LEF_TUMBLE;
le->leBounceSoundType = LEBS_BRASS;
@@ -91,195 +90,6 @@ static void CG_MachineGunEjectBrass( centity_t *cent ) {
/*
==========================
-CG_ShotgunEjectBrass
-==========================
-*/
-static void CG_ShotgunEjectBrass( centity_t *cent ) {
- localEntity_t *le;
- refEntity_t *re;
- vec3_t velocity, xvelocity;
- vec3_t offset, xoffset;
- vec3_t v[3];
- int i;
-
- if ( cg_brassTime.integer <= 0 ) {
- return;
- }
-
- for ( i = 0; i < 2; i++ ) {
- float waterScale = 1.0f;
-
- le = CG_AllocLocalEntity();
- re = &le->refEntity;
-
- velocity[0] = 60 + 60 * crandom();
- if ( i == 0 ) {
- velocity[1] = 40 + 10 * crandom();
- } else {
- velocity[1] = -40 + 10 * crandom();
- }
- velocity[2] = 100 + 50 * crandom();
-
- le->leType = LE_FRAGMENT;
- le->startTime = cg.time;
- le->endTime = le->startTime + cg_brassTime.integer*3 + cg_brassTime.integer * random();
-
- le->pos.trType = TR_GRAVITY;
- le->pos.trTime = cg.time;
-
- AnglesToAxis( cent->lerpAngles, v );
-
- offset[0] = 8;
- offset[1] = 0;
- offset[2] = 24;
-
- xoffset[0] = offset[0] * v[0][0] + offset[1] * v[1][0] + offset[2] * v[2][0];
- xoffset[1] = offset[0] * v[0][1] + offset[1] * v[1][1] + offset[2] * v[2][1];
- xoffset[2] = offset[0] * v[0][2] + offset[1] * v[1][2] + offset[2] * v[2][2];
- VectorAdd( cent->lerpOrigin, xoffset, re->origin );
- VectorCopy( re->origin, le->pos.trBase );
- if ( CG_PointContents( re->origin, -1 ) & CONTENTS_WATER ) {
- waterScale = 0.10f;
- }
-
- xvelocity[0] = velocity[0] * v[0][0] + velocity[1] * v[1][0] + velocity[2] * v[2][0];
- xvelocity[1] = velocity[0] * v[0][1] + velocity[1] * v[1][1] + velocity[2] * v[2][1];
- xvelocity[2] = velocity[0] * v[0][2] + velocity[1] * v[1][2] + velocity[2] * v[2][2];
- VectorScale( xvelocity, waterScale, le->pos.trDelta );
-
- AxisCopy( axisDefault, re->axis );
- re->hModel = cgs.media.shotgunBrassModel;
- le->bounceFactor = 0.3f;
-
- le->angles.trType = TR_LINEAR;
- le->angles.trTime = cg.time;
- le->angles.trBase[0] = rand()&31;
- le->angles.trBase[1] = rand()&31;
- le->angles.trBase[2] = rand()&31;
- le->angles.trDelta[0] = 1;
- le->angles.trDelta[1] = 0.5;
- le->angles.trDelta[2] = 0;
-
- le->leFlags = LEF_TUMBLE;
- le->leBounceSoundType = LEBS_BRASS;
- le->leMarkType = LEMT_NONE;
- }
-}
-
-
-/*
-==========================
-CG_RailTrail
-==========================
-*/
-void CG_RailTrail( vec3_t start, vec3_t end )
-{
- vec3_t axis[36], move, move2, next_move, vec, temp;
- float len;
- int i, j, skip;
-
- localEntity_t *le;
- refEntity_t *re;
-
-#define RADIUS 4
-#define ROTATION 1
-#define SPACING 5
-
- start[2] -= 4;
- VectorCopy (start, move);
- VectorSubtract (end, start, vec);
- len = VectorNormalize (vec);
- PerpendicularVector(temp, vec);
- for (i = 0 ; i < 36; i++) {
- RotatePointAroundVector(axis[i], vec, temp, i * 10);//banshee 2.4 was 10
- }
-
- le = CG_AllocLocalEntity();
- re = &le->refEntity;
-
- le->leType = LE_FADE_RGB;
- le->startTime = cg.time;
- le->endTime = cg.time + cg_railTrailTime.value;
- le->lifeRate = 1.0 / ( le->endTime - le->startTime );
-
- re->shaderTime = cg.time / 1000.0f;
- re->reType = RT_RAIL_CORE;
- re->customShader = cgs.media.railCoreShader;
-
- VectorCopy( start, re->origin );
- VectorCopy( end, re->oldorigin );
-
- re->shaderRGBA[0] = 255;
- re->shaderRGBA[1] = 255;
- re->shaderRGBA[2] = 255;
- re->shaderRGBA[3] = 255;
-
- le->color[0] = 0.75f;
- le->color[1] = 0.75f;
- le->color[2] = 0.75f;
- le->color[3] = 1.0f;
-
- AxisClear( re->axis );
-
- VectorMA(move, 20, vec, move);
- VectorCopy(move, next_move);
- VectorScale (vec, SPACING, vec);
-
- if (cg_oldRail.integer != 0) {
- // nudge down a bit so it isn't exactly in center
- re->origin[2] -= 8;
- re->oldorigin[2] -= 8;
- return;
- }
- skip = -1;
-
- j = 18;
- for (i = 0; i < len; i += SPACING) {
- if (i != skip) {
- skip = i + SPACING;
- le = CG_AllocLocalEntity();
- re = &le->refEntity;
- le->leFlags = LEF_PUFF_DONT_SCALE;
- le->leType = LE_MOVE_SCALE_FADE;
- le->startTime = cg.time;
- le->endTime = cg.time + (i>>1) + 600;
- le->lifeRate = 1.0 / (le->endTime - le->startTime);
-
- re->shaderTime = cg.time / 1000.0f;
- re->reType = RT_SPRITE;
- re->radius = 1.1f;
- re->customShader = cgs.media.railRingsShader;
-
- re->shaderRGBA[0] = 255;
- re->shaderRGBA[1] = 255;
- re->shaderRGBA[2] = 255;
- re->shaderRGBA[3] = 255;
-
- le->color[0] = 0.75f;
- le->color[1] = 0.75f;
- le->color[2] = 0.75f;
- le->color[3] = 1.0f;
-
- le->pos.trType = TR_LINEAR;
- le->pos.trTime = cg.time;
-
- VectorCopy( move, move2);
- VectorMA(move2, RADIUS , axis[j], move2);
- VectorCopy(move2, le->pos.trBase);
-
- le->pos.trDelta[0] = axis[j][0]*6;
- le->pos.trDelta[1] = axis[j][1]*6;
- le->pos.trDelta[2] = axis[j][2]*6;
- }
-
- VectorAdd (move, vec, move);
-
- j = j + ROTATION < 36 ? j + ROTATION : (j + ROTATION) % 36;
- }
-}
-
-/*
-==========================
CG_TeslaTrail
==========================
*/
@@ -301,7 +111,7 @@ void CG_TeslaTrail( vec3_t start, vec3_t end, int srcENum, int destENum )
le->srcENum = srcENum;
le->destENum = destENum;
le->vOffset = 28;
- le->maxRange = BG_FindRangeForBuildable( BA_H_DEF3 );
+ le->maxRange = BG_FindRangeForBuildable( BA_H_TESLAGEN );
VectorCopy( start, re->origin );
VectorCopy( end, re->oldorigin );
@@ -330,223 +140,15 @@ void CG_AlienZap( vec3_t start, vec3_t end, int srcENum, int destENum )
le->srcENum = srcENum;
le->destENum = destENum;
le->vOffset = -4;
- le->maxRange = BG_FindRangeForBuildable( BA_H_DEF3 );
+
+ //FIXME: share with server
+ le->maxRange = 200;
VectorCopy( start, re->origin );
VectorCopy( end, re->oldorigin );
}
/*
-==========================
-CG_RocketTrail
-==========================
-*/
-static void CG_RocketTrail( centity_t *ent, const weaponInfo_t *wi ) {
- int step;
- vec3_t origin, lastPos;
- int t;
- int startTime, contents;
- int lastContents;
- entityState_t *es;
- vec3_t up;
- localEntity_t *smoke;
-
- if ( cg_noProjectileTrail.integer ) {
- return;
- }
-
- up[0] = 0;
- up[1] = 0;
- up[2] = 0;
-
- step = 50;
-
- es = &ent->currentState;
- startTime = ent->trailTime;
- t = step * ( (startTime + step) / step );
-
- BG_EvaluateTrajectory( &es->pos, cg.time, origin );
- contents = CG_PointContents( origin, -1 );
-
- // if object (e.g. grenade) is stationary, don't toss up smoke
- if ( es->pos.trType == TR_STATIONARY ) {
- ent->trailTime = cg.time;
- return;
- }
-
- BG_EvaluateTrajectory( &es->pos, ent->trailTime, lastPos );
- lastContents = CG_PointContents( lastPos, -1 );
-
- ent->trailTime = cg.time;
-
- if ( contents & ( CONTENTS_WATER | CONTENTS_SLIME | CONTENTS_LAVA ) ) {
- if ( contents & lastContents & CONTENTS_WATER ) {
- CG_BubbleTrail( lastPos, origin, 8 );
- }
- return;
- }
-
- for ( ; t <= ent->trailTime ; t += step ) {
- BG_EvaluateTrajectory( &es->pos, t, lastPos );
-
- smoke = CG_SmokePuff( lastPos, up,
- wi->trailRadius,
- 1, 1, 1, 0.33f,
- wi->wiTrailTime,
- t,
- 0,
- 0,
- cgs.media.smokePuffShader );
- // use the optimized local entity add
- smoke->leType = LE_SCALE_FADE;
- }
-
-}
-
-/*
-==========================
-CG_PlasmaTrail
-==========================
-*/
-static void CG_PlasmaTrail( centity_t *cent, const weaponInfo_t *wi ) {
- localEntity_t *le;
- refEntity_t *re;
- entityState_t *es;
- vec3_t velocity, xvelocity, origin;
- vec3_t offset, xoffset;
- vec3_t v[3];
- int t, startTime, step;
-
- float waterScale = 1.0f;
-
- if ( cg_noProjectileTrail.integer || cg_oldPlasma.integer ) {
- return;
- }
-
- step = 50;
-
- es = &cent->currentState;
- startTime = cent->trailTime;
- t = step * ( (startTime + step) / step );
-
- BG_EvaluateTrajectory( &es->pos, cg.time, origin );
-
- le = CG_AllocLocalEntity();
- re = &le->refEntity;
-
- velocity[0] = 60 - 120 * crandom();
- velocity[1] = 40 - 80 * crandom();
- velocity[2] = 100 - 200 * crandom();
-
- le->leType = LE_MOVE_SCALE_FADE;
- le->leFlags = LEF_TUMBLE;
- le->leBounceSoundType = LEBS_NONE;
- le->leMarkType = LEMT_NONE;
-
- le->startTime = cg.time;
- le->endTime = le->startTime + 600;
-
- le->pos.trType = TR_GRAVITY;
- le->pos.trTime = cg.time;
-
- AnglesToAxis( cent->lerpAngles, v );
-
- offset[0] = 2;
- offset[1] = 2;
- offset[2] = 2;
-
- xoffset[0] = offset[0] * v[0][0] + offset[1] * v[1][0] + offset[2] * v[2][0];
- xoffset[1] = offset[0] * v[0][1] + offset[1] * v[1][1] + offset[2] * v[2][1];
- xoffset[2] = offset[0] * v[0][2] + offset[1] * v[1][2] + offset[2] * v[2][2];
-
- VectorAdd( origin, xoffset, re->origin );
- VectorCopy( re->origin, le->pos.trBase );
-
- if ( CG_PointContents( re->origin, -1 ) & CONTENTS_WATER ) {
- waterScale = 0.10f;
- }
-
- xvelocity[0] = velocity[0] * v[0][0] + velocity[1] * v[1][0] + velocity[2] * v[2][0];
- xvelocity[1] = velocity[0] * v[0][1] + velocity[1] * v[1][1] + velocity[2] * v[2][1];
- xvelocity[2] = velocity[0] * v[0][2] + velocity[1] * v[1][2] + velocity[2] * v[2][2];
- VectorScale( xvelocity, waterScale, le->pos.trDelta );
-
- AxisCopy( axisDefault, re->axis );
- re->shaderTime = cg.time / 1000.0f;
- re->reType = RT_SPRITE;
- re->radius = 0.25f;
- re->customShader = cgs.media.railRingsShader;
- le->bounceFactor = 0.3f;
-
- re->shaderRGBA[0] = wi->flashDlightColor[0] * 63;
- re->shaderRGBA[1] = wi->flashDlightColor[1] * 63;
- re->shaderRGBA[2] = wi->flashDlightColor[2] * 63;
- re->shaderRGBA[3] = 63;
-
- le->color[0] = wi->flashDlightColor[0] * 0.2;
- le->color[1] = wi->flashDlightColor[1] * 0.2;
- le->color[2] = wi->flashDlightColor[2] * 0.2;
- le->color[3] = 0.25f;
-
- le->angles.trType = TR_LINEAR;
- le->angles.trTime = cg.time;
- le->angles.trBase[0] = rand()&31;
- le->angles.trBase[1] = rand()&31;
- le->angles.trBase[2] = rand()&31;
- le->angles.trDelta[0] = 1;
- le->angles.trDelta[1] = 0.5;
- le->angles.trDelta[2] = 0;
-
-}
-
-/*
-==========================
-CG_GrappleTrail
-==========================
-*/
-void CG_GrappleTrail( centity_t *ent, const weaponInfo_t *wi ) {
- vec3_t origin;
- entityState_t *es;
- vec3_t forward, up;
- refEntity_t beam;
-
- es = &ent->currentState;
-
- BG_EvaluateTrajectory( &es->pos, cg.time, origin );
- ent->trailTime = cg.time;
-
- memset( &beam, 0, sizeof( beam ) );
- //FIXME adjust for muzzle position
- VectorCopy ( cg_entities[ ent->currentState.otherEntityNum ].lerpOrigin, beam.origin );
- beam.origin[2] += 26;
- AngleVectors( cg_entities[ ent->currentState.otherEntityNum ].lerpAngles, forward, NULL, up );
- VectorMA( beam.origin, -6, up, beam.origin );
- VectorCopy( origin, beam.oldorigin );
-
- if (Distance( beam.origin, beam.oldorigin ) < 64 )
- return; // Don't draw if close
-
- beam.reType = RT_LIGHTNING;
- beam.customShader = cgs.media.lightningShader;
-
- AxisClear( beam.axis );
- beam.shaderRGBA[0] = 0xff;
- beam.shaderRGBA[1] = 0xff;
- beam.shaderRGBA[2] = 0xff;
- beam.shaderRGBA[3] = 0xff;
- trap_R_AddRefEntityToScene( &beam );
-}
-
-/*
-==========================
-CG_GrenadeTrail
-==========================
-*/
-static void CG_GrenadeTrail( centity_t *ent, const weaponInfo_t *wi ) {
- CG_RocketTrail( ent, wi );
-}
-
-/*
=================
CG_RegisterUpgrade
@@ -587,7 +189,7 @@ CG_InitUpgrades
Precaches upgrades
===============
*/
-void CG_InitUpgrades( )
+void CG_InitUpgrades( void )
{
int i;
@@ -635,7 +237,7 @@ void CG_RegisterWeapon( int weaponNum )
// calc midpoint for rotation
trap_R_ModelBounds( weaponInfo->weaponModel, mins, maxs );
for( i = 0 ; i < 3 ; i++ )
- weaponInfo->weaponMidpoint[i] = mins[i] + 0.5 * ( maxs[i] - mins[i] );
+ weaponInfo->weaponMidpoint[ i ] = mins[ i ] + 0.5 * ( maxs[ i ] - mins[ i ] );
if( icon = BG_FindIconForWeapon( weaponNum ) )
{
@@ -658,9 +260,8 @@ void CG_RegisterWeapon( int weaponNum )
strcat( path, "_hand.md3" );
weaponInfo->handsModel = trap_R_RegisterModel( path );
- if ( !weaponInfo->handsModel ) {
+ if( !weaponInfo->handsModel )
weaponInfo->handsModel = trap_R_RegisterModel( "models/weapons2/shotgun/shotgun_hand.md3" );
- }
weaponInfo->loopFireSound = qfalse;
@@ -673,7 +274,7 @@ void CG_RegisterWeapon( int weaponNum )
weaponInfo->readySound = trap_S_RegisterSound( "sound/weapons/melee/fsthum.wav", qfalse );
weaponInfo->firingSound = trap_S_RegisterSound( "sound/weapons/lightning/lg_hum.wav", qfalse );
- weaponInfo->flashSound[0] = trap_S_RegisterSound( "sound/weapons/lightning/lg_fire.wav", qfalse );
+ weaponInfo->flashSound[ 0 ] = trap_S_RegisterSound( "sound/weapons/lightning/lg_fire.wav", qfalse );
cgs.media.lightningShader = trap_R_RegisterShader( "models/ammo/tesla/tesla_bolt");
cgs.media.lightningExplosionModel = trap_R_RegisterModel( "models/weaphits/crackle.md3" );
cgs.media.sfx_lghit = trap_S_RegisterSound( "sound/weapons/lightning/lg_fire.wav", qfalse );
@@ -681,28 +282,28 @@ void CG_RegisterWeapon( int weaponNum )
case WP_MACHINEGUN:
MAKERGB( weaponInfo->flashDlightColor, 1, 1, 0 );
- weaponInfo->flashSound[0] = trap_S_RegisterSound( "sound/weapons/machinegun/machgf1b.wav", qfalse );
- weaponInfo->flashSound[1] = trap_S_RegisterSound( "sound/weapons/machinegun/machgf2b.wav", qfalse );
- weaponInfo->flashSound[2] = trap_S_RegisterSound( "sound/weapons/machinegun/machgf3b.wav", qfalse );
- weaponInfo->flashSound[3] = trap_S_RegisterSound( "sound/weapons/machinegun/machgf4b.wav", qfalse );
+ weaponInfo->flashSound[ 0 ] = trap_S_RegisterSound( "sound/weapons/machinegun/machgf1b.wav", qfalse );
+ weaponInfo->flashSound[ 1 ] = trap_S_RegisterSound( "sound/weapons/machinegun/machgf2b.wav", qfalse );
+ weaponInfo->flashSound[ 2 ] = trap_S_RegisterSound( "sound/weapons/machinegun/machgf3b.wav", qfalse );
+ weaponInfo->flashSound[ 3 ] = trap_S_RegisterSound( "sound/weapons/machinegun/machgf4b.wav", qfalse );
weaponInfo->ejectBrassFunc = CG_MachineGunEjectBrass;
cgs.media.bulletExplosionShader = trap_R_RegisterShader( "bulletExplosion" );
break;
case WP_MASS_DRIVER:
MAKERGB( weaponInfo->flashDlightColor, 0, 0, 1 );
- weaponInfo->flashSound[0] = trap_S_RegisterSound( "sound/weapons/machinegun/machgf1b.wav", qfalse );
- weaponInfo->flashSound[1] = trap_S_RegisterSound( "sound/weapons/machinegun/machgf2b.wav", qfalse );
- weaponInfo->flashSound[2] = trap_S_RegisterSound( "sound/weapons/machinegun/machgf3b.wav", qfalse );
- weaponInfo->flashSound[3] = trap_S_RegisterSound( "sound/weapons/machinegun/machgf4b.wav", qfalse );
+ weaponInfo->flashSound[ 0 ] = trap_S_RegisterSound( "sound/weapons/machinegun/machgf1b.wav", qfalse );
+ weaponInfo->flashSound[ 1 ] = trap_S_RegisterSound( "sound/weapons/machinegun/machgf2b.wav", qfalse );
+ weaponInfo->flashSound[ 2 ] = trap_S_RegisterSound( "sound/weapons/machinegun/machgf3b.wav", qfalse );
+ weaponInfo->flashSound[ 3 ] = trap_S_RegisterSound( "sound/weapons/machinegun/machgf4b.wav", qfalse );
break;
case WP_CHAINGUN:
MAKERGB( weaponInfo->flashDlightColor, 1, 1, 0 );
- weaponInfo->flashSound[0] = trap_S_RegisterSound( "sound/weapons/machinegun/machgf1b.wav", qfalse );
- weaponInfo->flashSound[1] = trap_S_RegisterSound( "sound/weapons/machinegun/machgf2b.wav", qfalse );
- weaponInfo->flashSound[2] = trap_S_RegisterSound( "sound/weapons/machinegun/machgf3b.wav", qfalse );
- weaponInfo->flashSound[3] = trap_S_RegisterSound( "sound/weapons/machinegun/machgf4b.wav", qfalse );
+ weaponInfo->flashSound[ 0 ] = trap_S_RegisterSound( "sound/weapons/machinegun/machgf1b.wav", qfalse );
+ weaponInfo->flashSound[ 1 ] = trap_S_RegisterSound( "sound/weapons/machinegun/machgf2b.wav", qfalse );
+ weaponInfo->flashSound[ 2 ] = trap_S_RegisterSound( "sound/weapons/machinegun/machgf3b.wav", qfalse );
+ weaponInfo->flashSound[ 3 ] = trap_S_RegisterSound( "sound/weapons/machinegun/machgf4b.wav", qfalse );
weaponInfo->ejectBrassFunc = CG_MachineGunEjectBrass;
cgs.media.bulletExplosionShader = trap_R_RegisterShader( "bulletExplosion" );
break;
@@ -716,44 +317,35 @@ void CG_RegisterWeapon( int weaponNum )
MAKERGB( weaponInfo->missileDlightColor, 1, 0.75f, 0 );
MAKERGB( weaponInfo->flashDlightColor, 1, 0.75f, 0 );*/
weaponInfo->missileModel = trap_R_RegisterModel( "models/ammo/grenade1.md3" );
- weaponInfo->flashSound[0] = trap_S_RegisterSound( "sound/weapons/rocket/rocklf1a.wav", qfalse );
+ weaponInfo->flashSound[ 0 ] = trap_S_RegisterSound( "sound/weapons/rocket/rocklf1a.wav", qfalse );
/*cgs.media.rocketExplosionShader = trap_R_RegisterShader( "rocketExplosion" );*/
break;
case WP_FLAMER:
weaponInfo->missileSound = trap_S_RegisterSound( "sound/weapons/flamer/fireloop.wav", qfalse );
MAKERGB( weaponInfo->flashDlightColor, 0.25, 0.1, 0 );
- //weaponInfo->flashSound[0] = trap_S_RegisterSound( "sound/weapons/railgun/railgf1a.wav", qfalse );
+ //weaponInfo->flashSound[ 0 ] = trap_S_RegisterSound( "sound/weapons/railgun/railgf1a.wav", qfalse );
/*cgs.media.flameExplShader = trap_R_RegisterShader( "rocketExplosion" );*/
break;
-
- case WP_PLASMAGUN:
- weaponInfo->missileTrailFunc = CG_PlasmaTrail;
- weaponInfo->missileSound = trap_S_RegisterSound( "sound/weapons/plasma/lasfly.wav", qfalse );
- MAKERGB( weaponInfo->flashDlightColor, 0.6f, 0.6f, 1.0f );
- weaponInfo->flashSound[0] = trap_S_RegisterSound( "sound/weapons/plasma/hyprbf1a.wav", qfalse );
- cgs.media.plasmaExplosionShader = trap_R_RegisterShader( "plasmaExplosion" );
- cgs.media.railRingsShader = trap_R_RegisterShader( "railDisc" );
- break;
case WP_PULSE_RIFLE:
weaponInfo->missileSound = trap_S_RegisterSound( "sound/weapons/plasma/lasfly.wav", qfalse );
MAKERGB( weaponInfo->flashDlightColor, 0.6f, 0.6f, 1.0f );
- weaponInfo->flashSound[0] = trap_S_RegisterSound( "sound/weapons/plasma/hyprbf1a.wav", qfalse );
+ weaponInfo->flashSound[ 0 ] = trap_S_RegisterSound( "sound/weapons/plasma/hyprbf1a.wav", qfalse );
cgs.media.plasmaExplosionShader = trap_R_RegisterShader( "plasmaExplosion" );
cgs.media.railRingsShader = trap_R_RegisterShader( "railDisc" );
break;
case WP_LAS_GUN:
MAKERGB( weaponInfo->flashDlightColor, 1, 1, 0 );
- weaponInfo->flashSound[0] = trap_S_RegisterSound( "sound/weapons/plasma/hyprbf1a.wav", qfalse );
+ weaponInfo->flashSound[ 0 ] = trap_S_RegisterSound( "sound/weapons/plasma/hyprbf1a.wav", qfalse );
cgs.media.bulletExplosionShader = trap_R_RegisterShader( "bulletExplosion" );
break;
case WP_LUCIFER_CANON:
weaponInfo->readySound = trap_S_RegisterSound( "sound/weapons/bfg/bfg_hum.wav", qfalse );
MAKERGB( weaponInfo->flashDlightColor, 1, 0.7f, 1 );
- weaponInfo->flashSound[0] = trap_S_RegisterSound( "sound/weapons/bfg/bfg_fire.wav", qfalse );
+ weaponInfo->flashSound[ 0 ] = trap_S_RegisterSound( "sound/weapons/bfg/bfg_fire.wav", qfalse );
cgs.media.bfgExplosionShader = trap_R_RegisterShader( "bfgExplosion" );
weaponInfo->missileModel = trap_R_RegisterModel( "models/weaphits/bfg.md3" );
weaponInfo->missileSound = trap_S_RegisterSound( "sound/weapons/rocket/rockfly.wav", qfalse );
@@ -761,30 +353,30 @@ void CG_RegisterWeapon( int weaponNum )
case WP_VENOM:
MAKERGB( weaponInfo->flashDlightColor, 0, 0, 0 );
- weaponInfo->flashSound[0] = trap_S_RegisterSound( "sound/weapons/melee/fstatck.wav", qfalse );
+ weaponInfo->flashSound[ 0 ] = trap_S_RegisterSound( "sound/weapons/melee/fstatck.wav", qfalse );
break;
case WP_PAIN_SAW:
MAKERGB( weaponInfo->flashDlightColor, 0, 0, 0 );
- weaponInfo->flashSound[0] = trap_S_RegisterSound( "sound/weapons/melee/fstatck.wav", qfalse );
+ weaponInfo->flashSound[ 0 ] = trap_S_RegisterSound( "sound/weapons/melee/fstatck.wav", qfalse );
break;
case WP_GRAB_CLAW:
case WP_GRAB_CLAW_UPG:
MAKERGB( weaponInfo->flashDlightColor, 0, 0, 0 );
- weaponInfo->flashSound[0] = trap_S_RegisterSound( "sound/weapons/melee/fstatck.wav", qfalse );
+ weaponInfo->flashSound[ 0 ] = trap_S_RegisterSound( "sound/weapons/melee/fstatck.wav", qfalse );
break;
case WP_POUNCE:
case WP_POUNCE_UPG:
MAKERGB( weaponInfo->flashDlightColor, 0, 0, 0 );
- weaponInfo->flashSound[0] = trap_S_RegisterSound( "sound/weapons/melee/fstatck.wav", qfalse );
+ weaponInfo->flashSound[ 0 ] = trap_S_RegisterSound( "sound/weapons/melee/fstatck.wav", qfalse );
weaponInfo->missileModel = trap_R_RegisterModel( "models/ammo/grenade1.md3" );
break;
case WP_GROUND_POUND:
MAKERGB( weaponInfo->flashDlightColor, 0, 0, 0 );
- weaponInfo->flashSound[0] = trap_S_RegisterSound( "sound/weapons/melee/fstatck.wav", qfalse );
+ weaponInfo->flashSound[ 0 ] = trap_S_RegisterSound( "sound/weapons/melee/fstatck.wav", qfalse );
break;
case WP_ABUILD:
@@ -796,7 +388,7 @@ void CG_RegisterWeapon( int weaponNum )
default:
MAKERGB( weaponInfo->flashDlightColor, 1, 1, 1 );
- weaponInfo->flashSound[0] = trap_S_RegisterSound( "sound/weapons/rocket/rocklf1a.wav", qfalse );
+ weaponInfo->flashSound[ 0 ] = trap_S_RegisterSound( "sound/weapons/rocket/rocklf1a.wav", qfalse );
break;
}
}
@@ -808,7 +400,7 @@ CG_InitWeapons
Precaches weapons
===============
*/
-void CG_InitWeapons( )
+void CG_InitWeapons( void )
{
int i;
@@ -833,25 +425,23 @@ CG_MapTorsoToWeaponFrame
=================
*/
-static int CG_MapTorsoToWeaponFrame( clientInfo_t *ci, int frame ) {
+static int CG_MapTorsoToWeaponFrame( clientInfo_t *ci, int frame )
+{
// change weapon
- if ( frame >= ci->animations[TORSO_DROP].firstFrame
- && frame < ci->animations[TORSO_DROP].firstFrame + 9 ) {
- return frame - ci->animations[TORSO_DROP].firstFrame + 6;
- }
+ if( frame >= ci->animations[ TORSO_DROP ].firstFrame &&
+ frame < ci->animations[ TORSO_DROP ].firstFrame + 9 )
+ return frame - ci->animations[ TORSO_DROP ].firstFrame + 6;
// stand attack
- if ( frame >= ci->animations[TORSO_ATTACK].firstFrame
- && frame < ci->animations[TORSO_ATTACK].firstFrame + 6 ) {
- return 1 + frame - ci->animations[TORSO_ATTACK].firstFrame;
- }
+ if( frame >= ci->animations[ TORSO_ATTACK ].firstFrame &&
+ frame < ci->animations[ TORSO_ATTACK ].firstFrame + 6 )
+ return 1 + frame - ci->animations[ TORSO_ATTACK ].firstFrame;
// stand attack 2
- if ( frame >= ci->animations[TORSO_ATTACK2].firstFrame
- && frame < ci->animations[TORSO_ATTACK2].firstFrame + 6 ) {
- return 1 + frame - ci->animations[TORSO_ATTACK].firstFrame;
- }
+ if( frame >= ci->animations[ TORSO_ATTACK2 ].firstFrame &&
+ frame < ci->animations[ TORSO_ATTACK2 ].firstFrame + 6 )
+ return 1 + frame - ci->animations[ TORSO_ATTACK ].firstFrame;
return 0;
}
@@ -862,7 +452,8 @@ static int CG_MapTorsoToWeaponFrame( clientInfo_t *ci, int frame ) {
CG_CalculateWeaponPosition
==============
*/
-static void CG_CalculateWeaponPosition( vec3_t origin, vec3_t angles ) {
+static void CG_CalculateWeaponPosition( vec3_t origin, vec3_t angles )
+{
float scale;
int delta;
float fracsin;
@@ -872,53 +463,38 @@ static void CG_CalculateWeaponPosition( vec3_t origin, vec3_t angles ) {
VectorCopy( cg.refdefViewAngles, angles );
// on odd legs, invert some angles
- if ( cg.bobcycle & 1 ) {
+ if( cg.bobcycle & 1 )
scale = -cg.xyspeed;
- } else {
+ else
scale = cg.xyspeed;
- }
// gun angles from bobbing
//TA: bob amount is class dependant
bob = BG_FindBobForClass( cg.predictedPlayerState.stats[ STAT_PCLASS ] );
+
if( bob != 0 )
{
- angles[ROLL] += scale * cg.bobfracsin * 0.005;
- angles[YAW] += scale * cg.bobfracsin * 0.01;
- angles[PITCH] += cg.xyspeed * cg.bobfracsin * 0.005;
+ angles[ ROLL ] += scale * cg.bobfracsin * 0.005;
+ angles[ YAW ] += scale * cg.bobfracsin * 0.01;
+ angles[ PITCH ] += cg.xyspeed * cg.bobfracsin * 0.005;
}
// drop the weapon when landing
if( !BG_ClassHasAbility( cg.predictedPlayerState.stats[ STAT_PCLASS ], SCA_NOWEAPONDRIFT ) )
{
delta = cg.time - cg.landTime;
- if ( delta < LAND_DEFLECT_TIME )
- {
- origin[2] += cg.landChange*0.25 * delta / LAND_DEFLECT_TIME;
- }
- else if ( delta < LAND_DEFLECT_TIME + LAND_RETURN_TIME )
- {
- origin[2] += cg.landChange*0.25 *
- (LAND_DEFLECT_TIME + LAND_RETURN_TIME - delta) / LAND_RETURN_TIME;
- }
-
- //TA: huh? why drop the weapon when stair climbing... just as well this isn't actually used :)
-#if 0
- // drop the weapon when stair climbing
- delta = cg.time - cg.stepTime;
- if ( delta < STEP_TIME/2 ) {
- origin[2] -= cg.stepChange*0.25 * delta / (STEP_TIME/2);
- } else if ( delta < STEP_TIME ) {
- origin[2] -= cg.stepChange*0.25 * (STEP_TIME - delta) / (STEP_TIME/2);
- }
-#endif
+ if( delta < LAND_DEFLECT_TIME )
+ origin[ 2 ] += cg.landChange*0.25 * delta / LAND_DEFLECT_TIME;
+ else if( delta < LAND_DEFLECT_TIME + LAND_RETURN_TIME )
+ origin[ 2 ] += cg.landChange*0.25 *
+ ( LAND_DEFLECT_TIME + LAND_RETURN_TIME - delta ) / LAND_RETURN_TIME;
- // idle drift
+ // idle drift
scale = cg.xyspeed + 40;
fracsin = sin( cg.time * 0.001 );
- angles[ROLL] += scale * fracsin * 0.01;
- angles[YAW] += scale * fracsin * 0.01;
- angles[PITCH] += scale * fracsin * 0.01;
+ angles[ ROLL ] += scale * fracsin * 0.01;
+ angles[ YAW ] += scale * fracsin * 0.01;
+ angles[ PITCH ] += scale * fracsin * 0.01;
}
}
@@ -934,52 +510,56 @@ so the endpoint will reflect the simulated strike (lagging the predicted
angle)
===============
*/
-static void CG_LightningBolt( centity_t *cent, vec3_t origin ) {
- trace_t trace;
+static void CG_LightningBolt( centity_t *cent, vec3_t origin )
+{
+ trace_t trace;
refEntity_t beam;
- vec3_t forward;
- vec3_t muzzlePoint, endPoint;
+ vec3_t forward;
+ vec3_t muzzlePoint, endPoint;
- if ( cent->currentState.weapon != WP_TESLAGEN ) {
+ if( cent->currentState.weapon != WP_TESLAGEN )
return;
- }
memset( &beam, 0, sizeof( beam ) );
- // CPMA "true" lightning
- if ((cent->currentState.number == cg.predictedPlayerState.clientNum) && (cg_trueLightning.value != 0)) {
- vec3_t angle;
- int i;
-
- for (i = 0; i < 3; i++) {
- float a = cent->lerpAngles[i] - cg.refdefViewAngles[i];
- if (a > 180) {
- a -= 360;
- }
- if (a < -180) {
- a += 360;
- }
-
- angle[i] = cg.refdefViewAngles[i] + a * (1.0 - cg_trueLightning.value);
- if (angle[i] < 0) {
- angle[i] += 360;
- }
- if (angle[i] > 360) {
- angle[i] -= 360;
- }
- }
-
- AngleVectors(angle, forward, NULL, NULL );
- VectorCopy(cent->lerpOrigin, muzzlePoint );
-// VectorCopy(cg.refdef.vieworg, muzzlePoint );
- } else {
- // !CPMA
- AngleVectors( cent->lerpAngles, forward, NULL, NULL );
- VectorCopy(cent->lerpOrigin, muzzlePoint );
- }
+ // CPMA "true" lightning
+ if( ( cent->currentState.number == cg.predictedPlayerState.clientNum ) &&
+ ( cg_trueLightning.value != 0 ) )
+ {
+ vec3_t angle;
+ int i;
+
+ for( i = 0; i < 3; i++ )
+ {
+ float a = cent->lerpAngles[ i ] - cg.refdefViewAngles[ i ];
+ if( a > 180 )
+ a -= 360;
+
+ if( a < -180 )
+ a += 360;
+
+ angle[ i ] = cg.refdefViewAngles[ i ] + a * ( 1.0 - cg_trueLightning.value );
+
+ if( angle[ i ] < 0 )
+ angle[ i ] += 360;
+
+ if( angle[ i ] > 360 )
+ angle[ i ] -= 360;
+ }
+
+ AngleVectors( angle, forward, NULL, NULL );
+ VectorCopy( cent->lerpOrigin, muzzlePoint );
+// VectorCopy(cg.refdef.vieworg, muzzlePoint );
+ }
+ else
+ {
+ // !CPMA
+ AngleVectors( cent->lerpAngles, forward, NULL, NULL );
+ VectorCopy( cent->lerpOrigin, muzzlePoint );
+ }
// FIXME: crouch
- muzzlePoint[2] += DEFAULT_VIEWHEIGHT;
+ muzzlePoint[ 2 ] += DEFAULT_VIEWHEIGHT;
VectorMA( muzzlePoint, 14, forward, muzzlePoint );
@@ -1002,7 +582,8 @@ static void CG_LightningBolt( centity_t *cent, vec3_t origin ) {
trap_R_AddRefEntityToScene( &beam );
// add the impact flare if it hit something
- if ( trace.fraction < 1.0 ) {
+ if( trace.fraction < 1.0 )
+ {
vec3_t angles;
vec3_t dir;
@@ -1015,9 +596,9 @@ static void CG_LightningBolt( centity_t *cent, vec3_t origin ) {
VectorMA( trace.endpos, -16, dir, beam.origin );
// make a random orientation
- angles[0] = rand() % 360;
- angles[1] = rand() % 360;
- angles[2] = rand() % 360;
+ angles[ 0 ] = rand( ) % 360;
+ angles[ 1 ] = rand( ) % 360;
+ angles[ 2 ] = rand( ) % 360;
AnglesToAxis( angles, beam.axis );
trap_R_AddRefEntityToScene( &beam );
}
@@ -1153,27 +734,30 @@ CG_MachinegunSpinAngle
*/
#define SPIN_SPEED 0.9
#define COAST_TIME 1000
-static float CG_MachinegunSpinAngle( centity_t *cent ) {
+static float CG_MachinegunSpinAngle( centity_t *cent )
+{
int delta;
float angle;
float speed;
delta = cg.time - cent->pe.barrelTime;
- if ( cent->pe.barrelSpinning ) {
+ if( cent->pe.barrelSpinning )
angle = cent->pe.barrelAngle + delta * SPIN_SPEED;
- } else {
- if ( delta > COAST_TIME ) {
+ else
+ {
+ if( delta > COAST_TIME )
delta = COAST_TIME;
- }
speed = 0.5 * ( SPIN_SPEED + (float)( COAST_TIME - delta ) / COAST_TIME );
angle = cent->pe.barrelAngle + delta * speed;
}
- if ( cent->pe.barrelSpinning == !(cent->currentState.eFlags & EF_FIRING) ) {
+ if( cent->pe.barrelSpinning == !( cent->currentState.eFlags & EF_FIRING ) )
+ {
cent->pe.barrelTime = cg.time;
cent->pe.barrelAngle = AngleMod( angle );
- cent->pe.barrelSpinning = !!(cent->currentState.eFlags & EF_FIRING);
+ cent->pe.barrelSpinning = !!( cent->currentState.eFlags & EF_FIRING );
+ //TA: um?
}
return angle;
@@ -1185,23 +769,9 @@ static float CG_MachinegunSpinAngle( centity_t *cent ) {
CG_AddWeaponWithPowerups
========================
*/
-static void CG_AddWeaponWithPowerups( refEntity_t *gun, int powerups ) {
- // add powerup effects
- /*if ( powerups & ( 1 << PW_INVIS ) ) {
- gun->customShader = cgs.media.invisShader;
- trap_R_AddRefEntityToScene( gun );
- } else*/ {
- trap_R_AddRefEntityToScene( gun );
-
- /*if ( powerups & ( 1 << PW_BATTLESUIT ) ) {
- gun->customShader = cgs.media.battleWeaponShader;
- trap_R_AddRefEntityToScene( gun );
- }
- if ( powerups & ( 1 << PW_QUAD ) ) {
- gun->customShader = cgs.media.quadWeaponShader;
- trap_R_AddRefEntityToScene( gun );
- }*/
- }
+static void CG_AddWeaponWithPowerups( refEntity_t *gun, int powerups )
+{
+ trap_R_AddRefEntityToScene( gun );
}
@@ -1216,13 +786,13 @@ sound should only be done on the world model case.
*/
void CG_AddPlayerWeapon( refEntity_t *parent, playerState_t *ps, centity_t *cent )
{
- refEntity_t gun;
- refEntity_t barrel;
- refEntity_t flash;
- vec3_t angles;
- weapon_t weaponNum;
+ refEntity_t gun;
+ refEntity_t barrel;
+ refEntity_t flash;
+ vec3_t angles;
+ weapon_t weaponNum;
weaponInfo_t *weapon;
- centity_t *nonPredictedCent;
+ centity_t *nonPredictedCent;
weaponNum = cent->currentState.weapon;
@@ -1288,9 +858,9 @@ void CG_AddPlayerWeapon( refEntity_t *parent, playerState_t *ps, centity_t *cent
barrel.renderfx = parent->renderfx;
barrel.hModel = weapon->barrelModel;
- angles[YAW] = 0;
- angles[PITCH] = 0;
- angles[ROLL] = CG_MachinegunSpinAngle( cent );
+ angles[ YAW ] = 0;
+ angles[ PITCH ] = 0;
+ angles[ ROLL ] = CG_MachinegunSpinAngle( cent );
AnglesToAxis( angles, barrel.axis );
CG_PositionRotatedEntityOnTag( &barrel, &gun, weapon->weaponModel, "tag_barrel" );
@@ -1363,12 +933,13 @@ CG_AddViewWeapon
Add the weapon, and flash for the player's view
==============
*/
-void CG_AddViewWeapon( playerState_t *ps ) {
- refEntity_t hand;
- centity_t *cent;
+void CG_AddViewWeapon( playerState_t *ps )
+{
+ refEntity_t hand;
+ centity_t *cent;
clientInfo_t *ci;
- float fovOffset;
- vec3_t angles;
+ float fovOffset;
+ vec3_t angles;
weaponInfo_t *weapon;
if( ( ps->persistant[PERS_TEAM] == TEAM_SPECTATOR ) ||
@@ -1380,38 +951,38 @@ void CG_AddViewWeapon( playerState_t *ps ) {
if( ps->weapon == WP_NONE )
return;
- if ( ps->pm_type == PM_INTERMISSION ) {
+ if( ps->pm_type == PM_INTERMISSION )
return;
- }
//TA: draw a prospective buildable infront of the player
if( ( ps->stats[ STAT_BUILDABLE ] & ~SB_VALID_TOGGLEBIT ) > BA_NONE )
CG_GhostBuildable( ps->stats[ STAT_BUILDABLE ] & ~SB_VALID_TOGGLEBIT );
// no gun if in third person view
- if ( cg.renderingThirdPerson ) {
+ if( cg.renderingThirdPerson )
return;
- }
// allow the gun to be completely removed
- if ( !cg_drawGun.integer ) {
- vec3_t origin;
+ if( !cg_drawGun.integer )
+ {
+ vec3_t origin;
- if ( cg.predictedPlayerState.eFlags & EF_FIRING ) {
+ if( cg.predictedPlayerState.eFlags & EF_FIRING )
+ {
// special hack for lightning gun...
// TA: and flamer
VectorCopy( cg.refdef.vieworg, origin );
- VectorMA( origin, -8, cg.refdef.viewaxis[2], origin );
- CG_LightningBolt( &cg_entities[ps->clientNum], origin );
+ VectorMA( origin, -8, cg.refdef.viewaxis[ 2 ], origin );
+ CG_LightningBolt( &cg_entities[ ps->clientNum ], origin );
CG_FlameTrail( &cg_entities[ ps->clientNum ] );
}
+
return;
}
// don't draw if testing a gun model
- if ( cg.testGun ) {
+ if( cg.testGun )
return;
- }
// drop gun lower at higher fov
//if ( cg_fov.integer > 90 ) {
@@ -1425,21 +996,21 @@ void CG_AddViewWeapon( playerState_t *ps ) {
CG_RegisterWeapon( ps->weapon );
weapon = &cg_weapons[ ps->weapon ];
- memset (&hand, 0, sizeof(hand));
+ memset( &hand, 0, sizeof( hand ) );
// set up gun position
CG_CalculateWeaponPosition( hand.origin, angles );
- VectorMA( hand.origin, cg_gun_x.value, cg.refdef.viewaxis[0], hand.origin );
- VectorMA( hand.origin, cg_gun_y.value, cg.refdef.viewaxis[1], hand.origin );
- VectorMA( hand.origin, (cg_gun_z.value+fovOffset), cg.refdef.viewaxis[2], hand.origin );
+ VectorMA( hand.origin, cg_gun_x.value, cg.refdef.viewaxis[ 0 ], hand.origin );
+ VectorMA( hand.origin, cg_gun_y.value, cg.refdef.viewaxis[ 1 ], hand.origin );
+ VectorMA( hand.origin, ( cg_gun_z.value + fovOffset ), cg.refdef.viewaxis[ 2 ], hand.origin );
if( ps->weapon == WP_LUCIFER_CANON && ps->stats[ STAT_MISC ] > 0 )
{
float fraction = (float)ps->stats[ STAT_MISC ] / (float)LC_TOTAL_CHARGE;
- VectorMA( hand.origin, random( ) * fraction, cg.refdef.viewaxis[0], hand.origin );
- VectorMA( hand.origin, random( ) * fraction, cg.refdef.viewaxis[1], hand.origin );
+ VectorMA( hand.origin, random( ) * fraction, cg.refdef.viewaxis[ 0 ], hand.origin );
+ VectorMA( hand.origin, random( ) * fraction, cg.refdef.viewaxis[ 1 ], hand.origin );
}
if( cg.predictedPlayerState.stats[ STAT_STATE ] & SS_KNOCKEDOVER )
@@ -1456,11 +1027,14 @@ void CG_AddViewWeapon( playerState_t *ps ) {
AnglesToAxis( angles, hand.axis );
// map torso animations to weapon animations
- if ( cg_gun_frame.integer ) {
+ if( cg_gun_frame.integer )
+ {
// development tool
hand.frame = hand.oldframe = cg_gun_frame.integer;
hand.backlerp = 0;
- } else {
+ }
+ else
+ {
// get clientinfo for animation map
ci = &cgs.clientinfo[ cent->currentState.clientNum ];
hand.frame = CG_MapTorsoToWeaponFrame( ci, cent->pe.torso.frame );
@@ -1472,7 +1046,8 @@ void CG_AddViewWeapon( playerState_t *ps ) {
hand.renderfx = RF_DEPTHHACK | RF_FIRST_PERSON | RF_MINLIGHT;
// add everything onto the hand
- CG_AddPlayerWeapon( &hand, ps, &cg.predictedPlayerEntity );}
+ CG_AddPlayerWeapon( &hand, ps, &cg.predictedPlayerEntity );
+}
/*
==============================================================================
@@ -1482,32 +1057,6 @@ WEAPON SELECTION
==============================================================================
*/
-qboolean haveWeapon( int *weapons, int num, int weapon )
-{
- int i;
-
- for( i = 0; i < num; i++ )
- {
- if( weapons[ i ] == weapon )
- return qtrue;
- }
-
- return qfalse;
-}
-
-qboolean haveUpgrade( int *upgrades, int num, int upgrade )
-{
- int i;
-
- for( i = 0; i < num; i++ )
- {
- if( upgrades[ i ] == upgrade )
- return qtrue;
- }
-
- return qfalse;
-}
-
#define ICON_BORDER 4
/*
@@ -1681,9 +1230,8 @@ CG_ItemSelectable
*/
static qboolean CG_ItemSelectable( int i )
{
- if( !BG_gotItem( i, cg.snap->ps.stats ) ) {
+ if( !BG_gotItem( i, cg.snap->ps.stats ) )
return qfalse;
- }
return qtrue;
}
@@ -1694,45 +1242,40 @@ static qboolean CG_ItemSelectable( int i )
CG_NextWeapon_f
===============
*/
-void CG_NextWeapon_f( void ) {
+void CG_NextWeapon_f( void )
+{
int i;
int original;
- if ( !cg.snap ) {
+ if( !cg.snap )
return;
- }
- if ( cg.snap->ps.pm_flags & PMF_FOLLOW ) {
+
+ if( cg.snap->ps.pm_flags & PMF_FOLLOW )
return;
- }
cg.weaponSelectTime = cg.time;
original = cg.weaponSelect;
- for ( i = 0 ; i < 64 ; i++ ) {
+ for( i = 0; i < 64; i++ )
+ {
cg.weaponSelect++;
- if ( cg.weaponSelect == 64 ) {
+ if( cg.weaponSelect == 64 )
cg.weaponSelect = 0;
- }
- /*if ( cg.weaponSelect == WP_GAUNTLET ) {
- continue; // never cycle to gauntlet
- }*/
if( cg.weaponSelect <= 32 )
{
- if ( CG_WeaponSelectable( cg.weaponSelect ) ) {
+ if( CG_WeaponSelectable( cg.weaponSelect ) )
break;
- }
}
else if( cg.weaponSelect > 32 )
{
- if ( CG_ItemSelectable( cg.weaponSelect - 32 ) ) {
+ if( CG_ItemSelectable( cg.weaponSelect - 32 ) )
break;
- }
}
}
- if ( i == 64 ) {
+
+ if( i == 64 )
cg.weaponSelect = original;
- }
}
/*
@@ -1740,44 +1283,40 @@ void CG_NextWeapon_f( void ) {
CG_PrevWeapon_f
===============
*/
-void CG_PrevWeapon_f( void ) {
+void CG_PrevWeapon_f( void )
+{
int i;
int original;
- if ( !cg.snap ) {
+ if( !cg.snap )
return;
- }
- if ( cg.snap->ps.pm_flags & PMF_FOLLOW ) {
+
+ if( cg.snap->ps.pm_flags & PMF_FOLLOW )
return;
- }
cg.weaponSelectTime = cg.time;
original = cg.weaponSelect;
- for ( i = 0 ; i < 64 ; i++ ) {
+ for( i = 0; i < 64; i++ )
+ {
cg.weaponSelect--;
- if ( cg.weaponSelect == -1 ) {
+ if( cg.weaponSelect == -1 )
cg.weaponSelect = 63;
- }
- /*if ( cg.weaponSelect == WP_GAUNTLET ) {
- continue; // never cycle to gauntlet
- }*/
+
if( cg.weaponSelect <= 32 )
{
- if ( CG_WeaponSelectable( cg.weaponSelect ) ) {
+ if( CG_WeaponSelectable( cg.weaponSelect ) )
break;
- }
}
else if( cg.weaponSelect > 32 )
{
- if ( CG_ItemSelectable( cg.weaponSelect - 32 ) ) {
+ if( CG_ItemSelectable( cg.weaponSelect - 32 ) )
break;
- }
}
}
- if ( i == 64 ) {
+
+ if( i == 64 )
cg.weaponSelect = original;
- }
}
/*
@@ -1785,53 +1324,29 @@ void CG_PrevWeapon_f( void ) {
CG_Weapon_f
===============
*/
-void CG_Weapon_f( void ) {
+void CG_Weapon_f( void )
+{
int num;
- if ( !cg.snap ) {
+ if( !cg.snap )
return;
- }
- if ( cg.snap->ps.pm_flags & PMF_FOLLOW ) {
+
+ if( cg.snap->ps.pm_flags & PMF_FOLLOW )
return;
- }
num = atoi( CG_Argv( 1 ) );
- if ( num < 1 || num > 31 ) {
+ if( num < 1 || num > 31 )
return;
- }
cg.weaponSelectTime = cg.time;
- if ( !BG_gotWeapon( num, cg.snap->ps.stats ) ) {
+ if( !BG_gotWeapon( num, cg.snap->ps.stats ) )
return; // don't have the weapon
- }
cg.weaponSelect = num;
}
-/*
-===================
-CG_OutOfAmmoChange
-
-The current weapon has just run out of ammo
-===================
-*/
-void CG_OutOfAmmoChange( void ) {
- int i;
-
- //TA: mwhaha, must manually change weapons
- /*cg.weaponSelectTime = cg.time;
-
- for ( i = 31 ; i > 0 ; i-- ) {
- if ( CG_WeaponSelectable( i ) ) {
- cg.weaponSelect = i;
- break;
- }
- }*/
-}
-
-
/*
===================================================================================================
@@ -1855,13 +1370,15 @@ void CG_FireWeapon( centity_t *cent, int mode )
weaponInfo_t *weap;
ent = &cent->currentState;
- if ( ent->weapon == WP_NONE ) {
+ if( ent->weapon == WP_NONE )
return;
- }
- if ( ent->weapon >= WP_NUM_WEAPONS ) {
+
+ if( ent->weapon >= WP_NUM_WEAPONS )
+ {
CG_Error( "CG_FireWeapon: ent->weapon >= WP_NUM_WEAPONS" );
return;
}
+
weap = &cg_weapons[ ent->weapon ];
// mark the entity as muzzle flashing, so when it is added it will
@@ -1872,35 +1389,29 @@ void CG_FireWeapon( centity_t *cent, int mode )
cent->firstPoisonTime = cg.time;
// lightning gun only does this this on initial press
- if ( ent->weapon == WP_TESLAGEN ) {
- if ( cent->pe.lightningFiring ) {
+ if( ent->weapon == WP_TESLAGEN )
+ {
+ if( cent->pe.lightningFiring )
return;
- }
}
- // play quad sound if needed
- /*if ( cent->currentState.powerups & ( 1 << PW_QUAD ) ) {
- trap_S_StartSound (NULL, cent->currentState.number, CHAN_ITEM, cgs.media.quadSound );
- }*/
-
// play a sound
- for ( c = 0 ; c < 4 ; c++ ) {
- if ( !weap->flashSound[c] ) {
+ for( c = 0; c < 4; c++ )
+ {
+ if( !weap->flashSound[ c ] )
break;
- }
}
- if ( c > 0 ) {
- c = rand() % c;
- if ( weap->flashSound[c] )
- {
- trap_S_StartSound( NULL, ent->number, CHAN_WEAPON, weap->flashSound[c] );
- }
+
+ if( c > 0 )
+ {
+ c = rand( ) % c;
+ if( weap->flashSound[ c ] )
+ trap_S_StartSound( NULL, ent->number, CHAN_WEAPON, weap->flashSound[ c ] );
}
// do brass ejection
- if ( weap->ejectBrassFunc && cg_brassTime.integer > 0 ) {
+ if( weap->ejectBrassFunc && cg_brassTime.integer > 0 )
weap->ejectBrassFunc( cent );
- }
}
@@ -1912,20 +1423,20 @@ Caused by an EV_MISSILE_MISS event, or directly by local bullet tracing
=================
*/
void CG_MissileHitWall( int weapon, int clientNum, vec3_t origin, vec3_t dir, impactSound_t soundType, int damage ) {
- qhandle_t mod;
- qhandle_t mark;
- qhandle_t shader;
+ qhandle_t mod;
+ qhandle_t mark;
+ qhandle_t shader;
sfxHandle_t sfx;
- float radius;
- float light;
- vec3_t lightColor;
+ float radius;
+ float light;
+ vec3_t lightColor;
localEntity_t *le;
- int r, i;
- qboolean alphaFade;
- qboolean isSprite;
- int duration;
- vec3_t sprOrg;
- vec3_t sprVel;
+ int r, i;
+ qboolean alphaFade;
+ qboolean isSprite;
+ int duration;
+ vec3_t sprOrg;
+ vec3_t sprVel;
mark = 0;
radius = 32;
@@ -1933,9 +1444,9 @@ void CG_MissileHitWall( int weapon, int clientNum, vec3_t origin, vec3_t dir, im
mod = 0;
shader = 0;
light = 0;
- lightColor[0] = 1;
- lightColor[1] = 1;
- lightColor[2] = 0;
+ lightColor[ 0 ] = 1;
+ lightColor[ 1 ] = 1;
+ lightColor[ 2 ] = 0;
// set defaults
isSprite = qfalse;
@@ -1943,118 +1454,111 @@ void CG_MissileHitWall( int weapon, int clientNum, vec3_t origin, vec3_t dir, im
switch( weapon )
{
- default:
- case WP_TESLAGEN:
- case WP_AREA_ZAP:
- case WP_DIRECT_ZAP:
- mod = cgs.media.lightningExplosionModel;
- shader = cgs.media.lightningShader;
- sfx = cgs.media.sfx_lghit;
- mark = cgs.media.energyMarkShader;
- radius = 24;
- break;
- case WP_LOCKBLOB_LAUNCHER:
- case WP_POUNCE_UPG:
- sfx = cgs.media.gibBounce1Sound;
- mark = cgs.media.greenBloodMarkShader;
- radius = 64;
- isSprite = qtrue;
- break;
- case WP_FLAMER:
- sfx = cgs.media.sfx_flamerexp;
- mark = cgs.media.burnMarkShader;
- radius = 32;
- break;
- case WP_PLASMAGUN:
- mod = cgs.media.ringFlashModel;
- shader = cgs.media.plasmaExplosionShader;
- sfx = cgs.media.sfx_plasmaexp;
- mark = cgs.media.energyMarkShader;
- radius = 16;
- break;
- case WP_PULSE_RIFLE:
- mod = cgs.media.ringFlashModel;
- shader = cgs.media.plasmaExplosionShader;
- sfx = cgs.media.sfx_plasmaexp;
- mark = cgs.media.energyMarkShader;
- radius = 16;
- break;
- case WP_MASS_DRIVER:
- shader = cgs.media.bulletExplosionShader;
- mark = cgs.media.bulletMarkShader;
- radius = 8;
- break;
- case WP_MACHINEGUN:
- case WP_CHAINGUN:
- case WP_LAS_GUN:
- mod = cgs.media.bulletFlashModel;
- shader = cgs.media.bulletExplosionShader;
- mark = cgs.media.bulletMarkShader;
-
- r = rand() & 3;
- if ( r == 0 ) {
- sfx = cgs.media.sfx_ric1;
- } else if ( r == 1 ) {
- sfx = cgs.media.sfx_ric2;
- } else {
- sfx = cgs.media.sfx_ric3;
- }
-
- radius = 8;
- break;
-
- #define LCANON_EJECTION_VEL 300
-
- case WP_LUCIFER_CANON:
- mod = cgs.media.dishFlashModel;
- shader = cgs.media.bfgExplosionShader;
- mark = cgs.media.bulletMarkShader;
- radius = 8;
- sfx = cgs.media.sfx_plasmaexp;
- isSprite = qtrue;
-
- for( i = 0; i <= damage / 20; i++ )
- {
- qhandle_t spark;
- vec3_t velocity;
- vec3_t accel = { 0.0f, 0.0f, -DEFAULT_GRAVITY };
-
- VectorMA( origin, 1.0f, dir, origin );
-
- if( random( ) > 0.5f )
- spark = cgs.media.gibSpark1;
+ default:
+ case WP_TESLAGEN:
+ case WP_AREA_ZAP:
+ case WP_DIRECT_ZAP:
+ mod = cgs.media.lightningExplosionModel;
+ shader = cgs.media.lightningShader;
+ sfx = cgs.media.sfx_lghit;
+ mark = cgs.media.energyMarkShader;
+ radius = 24;
+ break;
+
+ case WP_LOCKBLOB_LAUNCHER:
+ case WP_POUNCE_UPG:
+ sfx = cgs.media.gibBounce1Sound;
+ mark = cgs.media.greenBloodMarkShader;
+ radius = 64;
+ isSprite = qtrue;
+ break;
+
+ case WP_FLAMER:
+ sfx = cgs.media.sfx_flamerexp;
+ mark = cgs.media.burnMarkShader;
+ radius = 32;
+ break;
+
+ case WP_PULSE_RIFLE:
+ mod = cgs.media.ringFlashModel;
+ shader = cgs.media.plasmaExplosionShader;
+ sfx = cgs.media.sfx_plasmaexp;
+ mark = cgs.media.energyMarkShader;
+ radius = 16;
+ break;
+
+ case WP_MASS_DRIVER:
+ shader = cgs.media.bulletExplosionShader;
+ mark = cgs.media.bulletMarkShader;
+ radius = 8;
+ break;
+
+ case WP_MACHINEGUN:
+ case WP_CHAINGUN:
+ case WP_LAS_GUN:
+ mod = cgs.media.bulletFlashModel;
+ shader = cgs.media.bulletExplosionShader;
+ mark = cgs.media.bulletMarkShader;
+
+ r = rand( ) & 3;
+ if( r == 0 )
+ sfx = cgs.media.sfx_ric1;
+ else if( r == 1 )
+ sfx = cgs.media.sfx_ric2;
else
- spark = cgs.media.scannerBlipShader;
+ sfx = cgs.media.sfx_ric3;
- velocity[ 0 ] = ( 2 * random( ) - 1.0f ) * LCANON_EJECTION_VEL;
- velocity[ 1 ] = ( 2 * random( ) - 1.0f ) * LCANON_EJECTION_VEL;
- velocity[ 2 ] = ( 2 * random( ) - 1.0f ) * LCANON_EJECTION_VEL;
+ radius = 8;
+ break;
- CG_LaunchSprite( origin, velocity, accel, 0.0f,
- 0.9f, 1.0f, 40.0f, 255, 0, rand( ) % 360,
- cg.time, cg.time, 2000 + ( crandom( ) * 1000 ),
- spark, qfalse, qfalse );
- }
- break;
+ #define LCANON_EJECTION_VEL 300
+
+ case WP_LUCIFER_CANON:
+ mod = cgs.media.dishFlashModel;
+ shader = cgs.media.bfgExplosionShader;
+ mark = cgs.media.bulletMarkShader;
+ radius = 8;
+ sfx = cgs.media.sfx_plasmaexp;
+ isSprite = qtrue;
+
+ for( i = 0; i <= damage / 20; i++ )
+ {
+ qhandle_t spark;
+ vec3_t velocity;
+ vec3_t accel = { 0.0f, 0.0f, -DEFAULT_GRAVITY };
+
+ VectorMA( origin, 1.0f, dir, origin );
+
+ if( random( ) > 0.5f )
+ spark = cgs.media.gibSpark1;
+ else
+ spark = cgs.media.scannerBlipShader;
+
+ velocity[ 0 ] = ( 2 * random( ) - 1.0f ) * LCANON_EJECTION_VEL;
+ velocity[ 1 ] = ( 2 * random( ) - 1.0f ) * LCANON_EJECTION_VEL;
+ velocity[ 2 ] = ( 2 * random( ) - 1.0f ) * LCANON_EJECTION_VEL;
+
+ CG_LaunchSprite( origin, velocity, accel, 0.0f,
+ 0.9f, 1.0f, 40.0f, 255, 0, rand( ) % 360,
+ cg.time, cg.time, 2000 + ( crandom( ) * 1000 ),
+ spark, qfalse, qfalse );
+ }
+ break;
}
- if ( sfx ) {
+ if( sfx )
trap_S_StartSound( origin, ENTITYNUM_WORLD, CHAN_AUTO, sfx );
- }
//
// create the explosion
//
- if ( mod ) {
+ if( mod )
+ {
le = CG_MakeExplosion( origin, dir,
- mod, shader,
- duration, isSprite );
+ mod, shader,
+ duration, isSprite );
le->light = light;
VectorCopy( lightColor, le->lightColor );
-/* if ( weapon == WP_RAILGUN ) {
- // colorize with client color
- VectorCopy( cgs.clientinfo[clientNum].color1, le->color );
- }*/
}
//
@@ -2064,18 +1568,7 @@ void CG_MissileHitWall( int weapon, int clientNum, vec3_t origin, vec3_t dir, im
alphaFade = ( mark == cgs.media.energyMarkShader ||
mark == cgs.media.greenBloodMarkShader );
-/* if( weapon == WP_RAILGUN )
- {
- float *color;
-
- // colorize with client color
- color = cgs.clientinfo[clientNum].color2;
- CG_ImpactMark( mark, origin, dir, random()*360, color[0],color[1], color[2],1, alphaFade, radius, qfalse );
- }
- else*/
- {
- CG_ImpactMark( mark, origin, dir, random()*360, 1,1,1,1, alphaFade, radius, qfalse );
- }
+ CG_ImpactMark( mark, origin, dir, random( ) * 360, 1, 1, 1, 1, alphaFade, radius, qfalse );
}
@@ -2084,138 +1577,23 @@ void CG_MissileHitWall( int weapon, int clientNum, vec3_t origin, vec3_t dir, im
CG_MissileHitPlayer
=================
*/
-void CG_MissileHitPlayer( int weapon, vec3_t origin, vec3_t dir, int entityNum, int damage ) {
+void CG_MissileHitPlayer( int weapon, vec3_t origin, vec3_t dir, int entityNum, int damage )
+{
CG_Bleed( origin, entityNum );
// some weapons will make an explosion with the blood, while
// others will just make the blood
- switch ( weapon ) {
-/* case WP_GRENADE_LAUNCHER:
- case WP_ROCKET_LAUNCHER:
- CG_MissileHitWall( weapon, 0, origin, dir, IMPACTSOUND_FLESH );
- break;*/
- default:
- break;
- }
-}
-
-
-
-/*
-============================================================================
-
-SHOTGUN TRACING
-
-============================================================================
-*/
-
-/*
-================
-CG_ShotgunPellet
-================
-*/
-static void CG_ShotgunPellet( vec3_t start, vec3_t end, int skipNum ) {
- trace_t tr;
- int sourceContentType, destContentType;
-
- CG_Trace( &tr, start, NULL, NULL, end, skipNum, MASK_SHOT );
-
- sourceContentType = trap_CM_PointContents( start, 0 );
- destContentType = trap_CM_PointContents( tr.endpos, 0 );
-
- // FIXME: should probably move this cruft into CG_BubbleTrail
- if ( sourceContentType == destContentType ) {
- if ( sourceContentType & CONTENTS_WATER ) {
- CG_BubbleTrail( start, tr.endpos, 32 );
- }
- } else if ( sourceContentType & CONTENTS_WATER ) {
- trace_t trace;
-
- trap_CM_BoxTrace( &trace, end, start, NULL, NULL, 0, CONTENTS_WATER );
- CG_BubbleTrail( start, trace.endpos, 32 );
- } else if ( destContentType & CONTENTS_WATER ) {
- trace_t trace;
-
- trap_CM_BoxTrace( &trace, start, end, NULL, NULL, 0, CONTENTS_WATER );
- CG_BubbleTrail( tr.endpos, trace.endpos, 32 );
- }
-
- if ( tr.surfaceFlags & SURF_NOIMPACT ) {
- return;
- }
-
- if ( cg_entities[tr.entityNum].currentState.eType == ET_PLAYER ) {
- /*CG_MissileHitPlayer( WP_SHOTGUN, tr.endpos, tr.plane.normal, tr.entityNum );*/
- } else {
- if ( tr.surfaceFlags & SURF_NOIMPACT ) {
- // SURF_NOIMPACT will not make a flame puff or a mark
- return;
- }
- if ( tr.surfaceFlags & SURF_METALSTEPS ) {
- /*CG_MissileHitWall( WP_SHOTGUN, 0, tr.endpos, tr.plane.normal, IMPACTSOUND_METAL );*/
- } else {
- /*CG_MissileHitWall( WP_SHOTGUN, 0, tr.endpos, tr.plane.normal, IMPACTSOUND_DEFAULT );*/
- }
- }
-}
-
-/*
-================
-CG_ShotgunPattern
-
-Perform the same traces the server did to locate the
-hit splashes
-================
-*/
-static void CG_ShotgunPattern( vec3_t origin, vec3_t origin2, int seed, int otherEntNum ) {
- int i;
- float r, u;
- vec3_t end;
- vec3_t forward, right, up;
-
- // derive the right and up vectors from the forward vector, because
- // the client won't have any other information
- VectorNormalize2( origin2, forward );
- PerpendicularVector( right, forward );
- CrossProduct( forward, right, up );
-
- // generate the "random" spread pattern
- for ( i = 0 ; i < DEFAULT_SHOTGUN_COUNT ; i++ ) {
- r = Q_crandom( &seed ) * DEFAULT_SHOTGUN_SPREAD * 16;
- u = Q_crandom( &seed ) * DEFAULT_SHOTGUN_SPREAD * 16;
- VectorMA( origin, 8192 * 16, forward, end);
- VectorMA (end, r, right, end);
- VectorMA (end, u, up, end);
-
- CG_ShotgunPellet( origin, end, otherEntNum );
+ switch( weapon )
+ {
+ /* case WP_GRENADE_LAUNCHER:
+ case WP_ROCKET_LAUNCHER:
+ CG_MissileHitWall( weapon, 0, origin, dir, IMPACTSOUND_FLESH );
+ break;*/
+ default:
+ break;
}
}
-/*
-==============
-CG_ShotgunFire
-==============
-*/
-void CG_ShotgunFire( entityState_t *es ) {
- vec3_t v;
- int contents;
-
- VectorSubtract( es->origin2, es->pos.trBase, v );
- VectorNormalize( v );
- VectorScale( v, 32, v );
- VectorAdd( es->pos.trBase, v, v );
- if ( cgs.glconfig.hardwareType != GLHW_RAGEPRO ) {
- // ragepro can't alpha fade, so don't even bother with smoke
- vec3_t up;
-
- contents = trap_CM_PointContents( es->pos.trBase, 0 );
- if ( !( contents & CONTENTS_WATER ) ) {
- VectorSet( up, 0, 0, 8 );
- CG_SmokePuff( v, up, 32, 1, 1, 1, 0.33f, 900, cg.time, 0, LEF_PUFF_DONT_SCALE, cgs.media.shotgunSmokePuffShader );
- }
- }
- CG_ShotgunPattern( es->pos.trBase, es->origin2, es->eventParm, es->otherEntityNum );
-}
/*
============================================================================
@@ -2231,78 +1609,78 @@ BULLETS
CG_Tracer
===============
*/
-void CG_Tracer( vec3_t source, vec3_t dest ) {
- vec3_t forward, right;
- polyVert_t verts[4];
- vec3_t line;
- float len, begin, end;
- vec3_t start, finish;
- vec3_t midpoint;
+void CG_Tracer( vec3_t source, vec3_t dest )
+{
+ vec3_t forward, right;
+ polyVert_t verts[ 4 ];
+ vec3_t line;
+ float len, begin, end;
+ vec3_t start, finish;
+ vec3_t midpoint;
// tracer
VectorSubtract( dest, source, forward );
len = VectorNormalize( forward );
// start at least a little ways from the muzzle
- if ( len < 100 ) {
+ if( len < 100 )
return;
- }
- begin = 50 + random() * (len - 60);
+
+ begin = 50 + random( ) * ( len - 60 );
end = begin + cg_tracerLength.value;
- if ( end > len ) {
+ if( end > len )
end = len;
- }
+
VectorMA( source, begin, forward, start );
VectorMA( source, end, forward, finish );
- line[0] = DotProduct( forward, cg.refdef.viewaxis[1] );
- line[1] = DotProduct( forward, cg.refdef.viewaxis[2] );
+ line[ 0 ] = DotProduct( forward, cg.refdef.viewaxis[ 1 ] );
+ line[ 1 ] = DotProduct( forward, cg.refdef.viewaxis[ 2 ] );
- VectorScale( cg.refdef.viewaxis[1], line[1], right );
- VectorMA( right, -line[0], cg.refdef.viewaxis[2], right );
+ VectorScale( cg.refdef.viewaxis[ 1 ], line[ 1 ], right );
+ VectorMA( right, -line[ 0 ], cg.refdef.viewaxis[ 2 ], right );
VectorNormalize( right );
- VectorMA( finish, cg_tracerWidth.value, right, verts[0].xyz );
- verts[0].st[0] = 0;
- verts[0].st[1] = 1;
- verts[0].modulate[0] = 255;
- verts[0].modulate[1] = 255;
- verts[0].modulate[2] = 255;
- verts[0].modulate[3] = 255;
-
- VectorMA( finish, -cg_tracerWidth.value, right, verts[1].xyz );
- verts[1].st[0] = 1;
- verts[1].st[1] = 0;
- verts[1].modulate[0] = 255;
- verts[1].modulate[1] = 255;
- verts[1].modulate[2] = 255;
- verts[1].modulate[3] = 255;
-
- VectorMA( start, -cg_tracerWidth.value, right, verts[2].xyz );
- verts[2].st[0] = 1;
- verts[2].st[1] = 1;
- verts[2].modulate[0] = 255;
- verts[2].modulate[1] = 255;
- verts[2].modulate[2] = 255;
- verts[2].modulate[3] = 255;
-
- VectorMA( start, cg_tracerWidth.value, right, verts[3].xyz );
- verts[3].st[0] = 0;
- verts[3].st[1] = 0;
- verts[3].modulate[0] = 255;
- verts[3].modulate[1] = 255;
- verts[3].modulate[2] = 255;
- verts[3].modulate[3] = 255;
+ VectorMA( finish, cg_tracerWidth.value, right, verts[ 0 ].xyz );
+ verts[ 0 ].st[ 0 ] = 0;
+ verts[ 0 ].st[ 1 ] = 1;
+ verts[ 0 ].modulate[ 0 ] = 255;
+ verts[ 0 ].modulate[ 1 ] = 255;
+ verts[ 0 ].modulate[ 2 ] = 255;
+ verts[ 0 ].modulate[ 3 ] = 255;
+
+ VectorMA( finish, -cg_tracerWidth.value, right, verts[ 1 ].xyz );
+ verts[ 1 ].st[ 0 ] = 1;
+ verts[ 1 ].st[ 1 ] = 0;
+ verts[ 1 ].modulate[ 0 ] = 255;
+ verts[ 1 ].modulate[ 1 ] = 255;
+ verts[ 1 ].modulate[ 2 ] = 255;
+ verts[ 1 ].modulate[ 3 ] = 255;
+
+ VectorMA( start, -cg_tracerWidth.value, right, verts[ 2 ].xyz );
+ verts[ 2 ].st[ 0 ] = 1;
+ verts[ 2 ].st[ 1 ] = 1;
+ verts[ 2 ].modulate[ 0 ] = 255;
+ verts[ 2 ].modulate[ 1 ] = 255;
+ verts[ 2 ].modulate[ 2 ] = 255;
+ verts[ 2 ].modulate[ 3 ] = 255;
+
+ VectorMA( start, cg_tracerWidth.value, right, verts[ 3 ].xyz );
+ verts[ 3 ].st[ 0 ] = 0;
+ verts[ 3 ].st[ 1 ] = 0;
+ verts[ 3 ].modulate[ 0 ] = 255;
+ verts[ 3 ].modulate[ 1 ] = 255;
+ verts[ 3 ].modulate[ 2 ] = 255;
+ verts[ 3 ].modulate[ 3 ] = 255;
trap_R_AddPolyToScene( cgs.media.tracerShader, 4, verts );
- midpoint[0] = ( start[0] + finish[0] ) * 0.5;
- midpoint[1] = ( start[1] + finish[1] ) * 0.5;
- midpoint[2] = ( start[2] + finish[2] ) * 0.5;
+ midpoint[ 0 ] = ( start[ 0 ] + finish[ 0 ] ) * 0.5;
+ midpoint[ 1 ] = ( start[ 1 ] + finish[ 1 ] ) * 0.5;
+ midpoint[ 2 ] = ( start[ 2 ] + finish[ 2 ] ) * 0.5;
// add the tracer sound
trap_S_StartSound( midpoint, ENTITYNUM_WORLD, CHAN_AUTO, cgs.media.tracerSound );
-
}
@@ -2311,33 +1689,35 @@ void CG_Tracer( vec3_t source, vec3_t dest ) {
CG_CalcMuzzlePoint
======================
*/
-static qboolean CG_CalcMuzzlePoint( int entityNum, vec3_t muzzle ) {
+static qboolean CG_CalcMuzzlePoint( int entityNum, vec3_t muzzle )
+{
vec3_t forward;
centity_t *cent;
- int anim;
+ int anim;
- if ( entityNum == cg.snap->ps.clientNum ) {
+ if( entityNum == cg.snap->ps.clientNum )
+ {
VectorCopy( cg.snap->ps.origin, muzzle );
- muzzle[2] += cg.snap->ps.viewheight;
+ muzzle[ 2 ] += cg.snap->ps.viewheight;
AngleVectors( cg.snap->ps.viewangles, forward, NULL, NULL );
VectorMA( muzzle, 14, forward, muzzle );
return qtrue;
}
cent = &cg_entities[entityNum];
- if ( !cent->currentValid ) {
+
+ if( !cent->currentValid )
return qfalse;
- }
VectorCopy( cent->currentState.pos.trBase, muzzle );
AngleVectors( cent->currentState.apos.trBase, forward, NULL, NULL );
anim = cent->currentState.legsAnim & ~ANIM_TOGGLEBIT;
- if ( anim == LEGS_WALKCR || anim == LEGS_IDLECR ) {
- muzzle[2] += CROUCH_VIEWHEIGHT;
- } else {
- muzzle[2] += DEFAULT_VIEWHEIGHT;
- }
+
+ if( anim == LEGS_WALKCR || anim == LEGS_IDLECR )
+ muzzle[ 2 ] += CROUCH_VIEWHEIGHT;
+ else
+ muzzle[ 2 ] += DEFAULT_VIEWHEIGHT;
VectorMA( muzzle, 14, forward, muzzle );
@@ -2383,44 +1763,47 @@ CG_Bullet
Renders bullet effects.
======================
*/
-void CG_Bullet( vec3_t end, int sourceEntityNum, vec3_t normal, qboolean flesh, int fleshEntityNum ) {
+void CG_Bullet( vec3_t end, int sourceEntityNum, vec3_t normal, qboolean flesh, int fleshEntityNum )
+{
trace_t trace;
- int sourceContentType, destContentType;
- vec3_t start;
+ int sourceContentType, destContentType;
+ vec3_t start;
// if the shooter is currently valid, calc a source point and possibly
// do trail effects
- if ( sourceEntityNum >= 0 && cg_tracerChance.value > 0 ) {
- if ( CG_CalcMuzzlePoint( sourceEntityNum, start ) ) {
+ if( sourceEntityNum >= 0 && cg_tracerChance.value > 0 )
+ {
+ if( CG_CalcMuzzlePoint( sourceEntityNum, start ) )
+ {
sourceContentType = trap_CM_PointContents( start, 0 );
destContentType = trap_CM_PointContents( end, 0 );
// do a complete bubble trail if necessary
- if ( ( sourceContentType == destContentType ) && ( sourceContentType & CONTENTS_WATER ) ) {
+ if( ( sourceContentType == destContentType ) && ( sourceContentType & CONTENTS_WATER ) )
CG_BubbleTrail( start, end, 32 );
- }
+
// bubble trail from water into air
- else if ( ( sourceContentType & CONTENTS_WATER ) ) {
+ else if( ( sourceContentType & CONTENTS_WATER ) )
+ {
trap_CM_BoxTrace( &trace, end, start, NULL, NULL, 0, CONTENTS_WATER );
CG_BubbleTrail( start, trace.endpos, 32 );
}
// bubble trail from air into water
- else if ( ( destContentType & CONTENTS_WATER ) ) {
+ else if( ( destContentType & CONTENTS_WATER ) )
+ {
trap_CM_BoxTrace( &trace, start, end, NULL, NULL, 0, CONTENTS_WATER );
CG_BubbleTrail( trace.endpos, end, 32 );
}
// draw a tracer
- if ( random() < cg_tracerChance.value ) {
+ if( random( ) < cg_tracerChance.value )
CG_Tracer( start, end );
- }
}
}
// impact splash and mark
- if ( flesh ) {
+ if( flesh )
CG_Bleed( end, fleshEntityNum );
- } else {
+ else
CG_MissileHitWall( WP_MACHINEGUN, 0, end, normal, IMPACTSOUND_DEFAULT, 0 );
- }
}
diff --git a/src/cgame/tr_types.h b/src/cgame/tr_types.h
index fa5ae08f..e424cacc 100644
--- a/src/cgame/tr_types.h
+++ b/src/cgame/tr_types.h
@@ -18,115 +18,121 @@
#define __TR_TYPES_H
-#define MAX_DLIGHTS 32 // can't be increased, because bit flags are used on surfaces
-#define MAX_ENTITIES 1023 // can't be increased without changing drawsurf bit packing
+#define MAX_DLIGHTS 32 // can't be increased, because bit flags are used on surfaces
+#define MAX_ENTITIES 1023 // can't be increased without changing drawsurf bit packing
// renderfx flags
-#define RF_MINLIGHT 1 // allways have some light (viewmodel, some items)
-#define RF_THIRD_PERSON 2 // don't draw through eyes, only mirrors (player bodies, chat sprites)
-#define RF_FIRST_PERSON 4 // only draw through eyes (view weapon, damage blood blob)
-#define RF_DEPTHHACK 8 // for view weapon Z crunching
-#define RF_NOSHADOW 64 // don't add stencil shadows
-
-#define RF_LIGHTING_ORIGIN 128 // use refEntity->lightingOrigin instead of refEntity->origin
- // for lighting. This allows entities to sink into the floor
- // with their origin going solid, and allows all parts of a
- // player to get the same lighting
-#define RF_SHADOW_PLANE 256 // use refEntity->shadowPlane
-#define RF_WRAP_FRAMES 512 // mod the model frames by the maxframes to allow continuous
- // animation without needing to know the frame count
+#define RF_MINLIGHT 1 // allways have some light (viewmodel, some items)
+#define RF_THIRD_PERSON 2 // don't draw through eyes, only mirrors (player bodies, chat sprites)
+#define RF_FIRST_PERSON 4 // only draw through eyes (view weapon, damage blood blob)
+#define RF_DEPTHHACK 8 // for view weapon Z crunching
+#define RF_NOSHADOW 64 // don't add stencil shadows
+
+#define RF_LIGHTING_ORIGIN 128 // use refEntity->lightingOrigin instead of refEntity->origin
+ // for lighting. This allows entities to sink into the floor
+ // with their origin going solid, and allows all parts of a
+ // player to get the same lighting
+#define RF_SHADOW_PLANE 256 // use refEntity->shadowPlane
+#define RF_WRAP_FRAMES 512 // mod the model frames by the maxframes to allow continuous
+ // animation without needing to know the frame count
// refdef flags
-#define RDF_NOWORLDMODEL 1 // used for player configuration screen
-#define RDF_HYPERSPACE 4 // teleportation effect
-
-typedef struct {
- vec3_t xyz;
- float st[2];
- byte modulate[4];
+#define RDF_NOWORLDMODEL 1 // used for player configuration screen
+#define RDF_HYPERSPACE 4 // teleportation effect
+
+typedef struct
+{
+ vec3_t xyz;
+ float st[ 2 ];
+ byte modulate[ 4 ];
} polyVert_t;
-typedef struct poly_s {
- qhandle_t hShader;
- int numVerts;
- polyVert_t *verts;
+typedef struct poly_s
+{
+ qhandle_t hShader;
+ int numVerts;
+ polyVert_t *verts;
} poly_t;
-typedef enum {
- RT_MODEL,
- RT_POLY,
- RT_SPRITE,
- RT_BEAM,
- RT_RAIL_CORE,
- RT_RAIL_RINGS,
- RT_LIGHTNING,
- RT_PORTALSURFACE, // doesn't draw anything, just info for portals
-
- RT_MAX_REF_ENTITY_TYPE
+typedef enum
+{
+ RT_MODEL,
+ RT_POLY,
+ RT_SPRITE,
+ RT_BEAM,
+ RT_RAIL_CORE,
+ RT_RAIL_RINGS,
+ RT_LIGHTNING,
+ RT_PORTALSURFACE, // doesn't draw anything, just info for portals
+
+ RT_MAX_REF_ENTITY_TYPE
} refEntityType_t;
-typedef struct {
- refEntityType_t reType;
- int renderfx;
+typedef struct
+{
+ refEntityType_t reType;
+ int renderfx;
- qhandle_t hModel; // opaque type outside refresh
+ qhandle_t hModel; // opaque type outside refresh
- // most recent data
- vec3_t lightingOrigin; // so multi-part models can be lit identically (RF_LIGHTING_ORIGIN)
- float shadowPlane; // projection shadows go here, stencils go slightly lower
+ // most recent data
+ vec3_t lightingOrigin; // so multi-part models can be lit identically (RF_LIGHTING_ORIGIN)
+ float shadowPlane; // projection shadows go here, stencils go slightly lower
- vec3_t axis[3]; // rotation vectors
- qboolean nonNormalizedAxes; // axis are not normalized, i.e. they have scale
- float origin[3]; // also used as MODEL_BEAM's "from"
- int frame; // also used as MODEL_BEAM's diameter
+ vec3_t axis[ 3 ]; // rotation vectors
+ qboolean nonNormalizedAxes; // axis are not normalized, i.e. they have scale
+ float origin[ 3 ]; // also used as MODEL_BEAM's "from"
+ int frame; // also used as MODEL_BEAM's diameter
- // previous data for frame interpolation
- float oldorigin[3]; // also used as MODEL_BEAM's "to"
- int oldframe;
- float backlerp; // 0.0 = current, 1.0 = old
+ // previous data for frame interpolation
+ float oldorigin[ 3 ]; // also used as MODEL_BEAM's "to"
+ int oldframe;
+ float backlerp; // 0.0 = current, 1.0 = old
- // texturing
- int skinNum; // inline skin index
- qhandle_t customSkin; // NULL for default skin
- qhandle_t customShader; // use one image for the entire thing
+ // texturing
+ int skinNum; // inline skin index
+ qhandle_t customSkin; // NULL for default skin
+ qhandle_t customShader; // use one image for the entire thing
- // misc
- byte shaderRGBA[4]; // colors used by rgbgen entity shaders
- float shaderTexCoord[2]; // texture coordinates used by tcMod entity modifiers
- float shaderTime; // subtracted from refdef time to control effect start times
+ // misc
+ byte shaderRGBA[ 4 ]; // colors used by rgbgen entity shaders
+ float shaderTexCoord[ 2 ];// texture coordinates used by tcMod entity modifiers
+ float shaderTime; // subtracted from refdef time to control effect start times
- // extra sprite information
- float radius;
- float rotation;
+ // extra sprite information
+ float radius;
+ float rotation;
} refEntity_t;
-#define MAX_RENDER_STRINGS 8
-#define MAX_RENDER_STRING_LENGTH 32
+#define MAX_RENDER_STRINGS 8
+#define MAX_RENDER_STRING_LENGTH 32
-typedef struct {
- int x, y, width, height;
- float fov_x, fov_y;
- vec3_t vieworg;
- vec3_t viewaxis[3]; // transformation matrix
+typedef struct
+{
+ int x, y, width, height;
+ float fov_x, fov_y;
+ vec3_t vieworg;
+ vec3_t viewaxis[ 3 ]; // transformation matrix
- // time in milliseconds for shader effects and other time dependent rendering issues
- int time;
+ // time in milliseconds for shader effects and other time dependent rendering issues
+ int time;
- int rdflags; // RDF_NOWORLDMODEL, etc
+ int rdflags; // RDF_NOWORLDMODEL, etc
- // 1 bits will prevent the associated area from rendering at all
- byte areamask[MAX_MAP_AREA_BYTES];
+ // 1 bits will prevent the associated area from rendering at all
+ byte areamask[ MAX_MAP_AREA_BYTES ];
- // text messages for deform text shaders
- char text[MAX_RENDER_STRINGS][MAX_RENDER_STRING_LENGTH];
+ // text messages for deform text shaders
+ char text[ MAX_RENDER_STRINGS ][ MAX_RENDER_STRING_LENGTH ];
} refdef_t;
-typedef enum {
- STEREO_CENTER,
- STEREO_LEFT,
- STEREO_RIGHT
+typedef enum
+{
+ STEREO_CENTER,
+ STEREO_LEFT,
+ STEREO_RIGHT
} stereoFrame_t;
@@ -137,77 +143,82 @@ typedef enum {
** being run right now. These are constant once the OpenGL
** subsystem is initialized.
*/
-typedef enum {
- TC_NONE,
- TC_S3TC
+typedef enum
+{
+ TC_NONE,
+ TC_S3TC
} textureCompression_t;
-typedef enum {
- GLDRV_ICD, // driver is integrated with window system
- // WARNING: there are tests that check for
- // > GLDRV_ICD for minidriverness, so this
- // should always be the lowest value in this
- // enum set
- GLDRV_STANDALONE, // driver is a non-3Dfx standalone driver
- GLDRV_VOODOO // driver is a 3Dfx standalone driver
+typedef enum
+{
+ GLDRV_ICD, // driver is integrated with window system
+ // WARNING: there are tests that check for
+ // > GLDRV_ICD for minidriverness, so this
+ // should always be the lowest value in this
+ // enum set
+ GLDRV_STANDALONE, // driver is a non-3Dfx standalone driver
+ GLDRV_VOODOO // driver is a 3Dfx standalone driver
} glDriverType_t;
-typedef enum {
- GLHW_GENERIC, // where everthing works the way it should
- GLHW_3DFX_2D3D, // Voodoo Banshee or Voodoo3, relevant since if this is
- // the hardware type then there can NOT exist a secondary
- // display adapter
- GLHW_RIVA128, // where you can't interpolate alpha
- GLHW_RAGEPRO, // where you can't modulate alpha on alpha textures
- GLHW_PERMEDIA2 // where you don't have src*dst
+typedef enum
+{
+ GLHW_GENERIC, // where everthing works the way it should
+ GLHW_3DFX_2D3D, // Voodoo Banshee or Voodoo3, relevant since if this is
+ // the hardware type then there can NOT exist a secondary
+ // display adapter
+ GLHW_RIVA128, // where you can't interpolate alpha
+ GLHW_RAGEPRO, // where you can't modulate alpha on alpha textures
+ GLHW_PERMEDIA2 // where you don't have src*dst
} glHardwareType_t;
-typedef struct {
- char renderer_string[MAX_STRING_CHARS];
- char vendor_string[MAX_STRING_CHARS];
- char version_string[MAX_STRING_CHARS];
- char extensions_string[BIG_INFO_STRING];
+typedef struct
+{
+ char renderer_string[ MAX_STRING_CHARS ];
+ char vendor_string[ MAX_STRING_CHARS ];
+ char version_string[ MAX_STRING_CHARS ];
+ char extensions_string[ BIG_INFO_STRING ];
- int maxTextureSize; // queried from GL
- int maxActiveTextures; // multitexture ability
+ int maxTextureSize; // queried from GL
+ int maxActiveTextures; // multitexture ability
- int colorBits, depthBits, stencilBits;
+ int colorBits, depthBits, stencilBits;
- glDriverType_t driverType;
- glHardwareType_t hardwareType;
+ glDriverType_t driverType;
+ glHardwareType_t hardwareType;
- qboolean deviceSupportsGamma;
- textureCompression_t textureCompression;
- qboolean textureEnvAddAvailable;
+ qboolean deviceSupportsGamma;
+ textureCompression_t textureCompression;
+ qboolean textureEnvAddAvailable;
- int vidWidth, vidHeight;
- // aspect is the screen's physical width / height, which may be different
- // than scrWidth / scrHeight if the pixels are non-square
- // normal screens should be 4/3, but wide aspect monitors may be 16/9
- float windowAspect;
+ int vidWidth, vidHeight;
+
+ // aspect is the screen's physical width / height, which may be different
+ // than scrWidth / scrHeight if the pixels are non-square
+ // normal screens should be 4/3, but wide aspect monitors may be 16/9
+ float windowAspect;
- int displayFrequency;
+ int displayFrequency;
- // synonymous with "does rendering consume the entire screen?", therefore
- // a Voodoo or Voodoo2 will have this set to TRUE, as will a Win32 ICD that
- // used CDS.
- qboolean isFullscreen;
- qboolean stereoEnabled;
- qboolean smpActive; // dual processor
+ // synonymous with "does rendering consume the entire screen?", therefore
+ // a Voodoo or Voodoo2 will have this set to TRUE, as will a Win32 ICD that
+ // used CDS.
+ qboolean isFullscreen;
+ qboolean stereoEnabled;
+ qboolean smpActive; // dual processor
} glconfig_t;
#if !defined _WIN32
-#define _3DFX_DRIVER_NAME "libMesaVoodooGL.so"
-#define OPENGL_DRIVER_NAME "libGL.so"
+#define _3DFX_DRIVER_NAME "libMesaVoodooGL.so"
+#define OPENGL_DRIVER_NAME "libGL.so"
#else
-#define _3DFX_DRIVER_NAME "3dfxvgl"
-#define OPENGL_DRIVER_NAME "opengl32"
+#define _3DFX_DRIVER_NAME "3dfxvgl"
+#define OPENGL_DRIVER_NAME "opengl32"
-#endif // !defined _WIN32
+#endif // !defined _WIN32
-#endif // __TR_TYPES_H
+#endif // __TR_TYPES_H
diff --git a/src/game/bg_lib.c b/src/game/bg_lib.c
index cd241f77..f5aea779 100644
--- a/src/game/bg_lib.c
+++ b/src/game/bg_lib.c
@@ -1,7 +1,5 @@
// Copyright (C) 1999-2000 Id Software, Inc.
//
-// Copyright (C) 1999-2000 Id Software, Inc.
-//
// bg_lib,c -- standard C library replacement routines used by code
// compiled for the virtual machine
@@ -22,7 +20,7 @@
/*-
* Copyright (c) 1992, 1993
- * The Regents of the University of California. All rights reserved.
+ * The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -34,8 +32,8 @@
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
@@ -55,7 +53,7 @@
#if defined(LIBC_SCCS) && !defined(lint)
#if 0
-static char sccsid[] = "@(#)qsort.c 8.1 (Berkeley) 6/4/93";
+static char sccsid[] = "@(#)qsort.c 8.1 (Berkeley) 6/4/93";
#endif
static const char rcsid[] =
"$Id$";
@@ -67,140 +65,140 @@ typedef int cmp_t(const void *, const void *);
#endif
static char* med3(char *, char *, char *, cmp_t *);
-static void swapfunc(char *, char *, int, int);
+static void swapfunc(char *, char *, int, int);
#ifndef min
-#define min(a, b) (a) < (b) ? a : b
+#define min(a, b) (a) < (b) ? a : b
#endif
/*
* Qsort routine from Bentley & McIlroy's "Engineering a Sort Function".
*/
-#define swapcode(TYPE, parmi, parmj, n) { \
- long i = (n) / sizeof (TYPE); \
- register TYPE *pi = (TYPE *) (parmi); \
- register TYPE *pj = (TYPE *) (parmj); \
- do { \
- register TYPE t = *pi; \
- *pi++ = *pj; \
- *pj++ = t; \
- } while (--i > 0); \
+#define swapcode(TYPE, parmi, parmj, n) { \
+ long i = (n) / sizeof (TYPE); \
+ register TYPE *pi = (TYPE *) (parmi); \
+ register TYPE *pj = (TYPE *) (parmj); \
+ do { \
+ register TYPE t = *pi; \
+ *pi++ = *pj; \
+ *pj++ = t; \
+ } while (--i > 0); \
}
#define SWAPINIT(a, es) swaptype = ((char *)a - (char *)0) % sizeof(long) || \
- es % sizeof(long) ? 2 : es == sizeof(long)? 0 : 1;
+ es % sizeof(long) ? 2 : es == sizeof(long)? 0 : 1;
static void
swapfunc(a, b, n, swaptype)
- char *a, *b;
- int n, swaptype;
+ char *a, *b;
+ int n, swaptype;
{
- if(swaptype <= 1)
- swapcode(long, a, b, n)
- else
- swapcode(char, a, b, n)
+ if(swaptype <= 1)
+ swapcode(long, a, b, n)
+ else
+ swapcode(char, a, b, n)
}
-#define swap(a, b) \
- if (swaptype == 0) { \
- long t = *(long *)(a); \
- *(long *)(a) = *(long *)(b); \
- *(long *)(b) = t; \
- } else \
- swapfunc(a, b, es, swaptype)
+#define swap(a, b) \
+ if (swaptype == 0) { \
+ long t = *(long *)(a); \
+ *(long *)(a) = *(long *)(b); \
+ *(long *)(b) = t; \
+ } else \
+ swapfunc(a, b, es, swaptype)
-#define vecswap(a, b, n) if ((n) > 0) swapfunc(a, b, n, swaptype)
+#define vecswap(a, b, n) if ((n) > 0) swapfunc(a, b, n, swaptype)
static char *
med3(a, b, c, cmp)
- char *a, *b, *c;
- cmp_t *cmp;
+ char *a, *b, *c;
+ cmp_t *cmp;
{
- return cmp(a, b) < 0 ?
- (cmp(b, c) < 0 ? b : (cmp(a, c) < 0 ? c : a ))
+ return cmp(a, b) < 0 ?
+ (cmp(b, c) < 0 ? b : (cmp(a, c) < 0 ? c : a ))
:(cmp(b, c) > 0 ? b : (cmp(a, c) < 0 ? a : c ));
}
void
qsort(a, n, es, cmp)
- void *a;
- size_t n, es;
- cmp_t *cmp;
+ void *a;
+ size_t n, es;
+ cmp_t *cmp;
{
- char *pa, *pb, *pc, *pd, *pl, *pm, *pn;
- int d, r, swaptype, swap_cnt;
-
-loop: SWAPINIT(a, es);
- swap_cnt = 0;
- if (n < 7) {
- for (pm = (char *)a + es; pm < (char *)a + n * es; pm += es)
- for (pl = pm; pl > (char *)a && cmp(pl - es, pl) > 0;
- pl -= es)
- swap(pl, pl - es);
- return;
- }
- pm = (char *)a + (n / 2) * es;
- if (n > 7) {
- pl = a;
- pn = (char *)a + (n - 1) * es;
- if (n > 40) {
- d = (n / 8) * es;
- pl = med3(pl, pl + d, pl + 2 * d, cmp);
- pm = med3(pm - d, pm, pm + d, cmp);
- pn = med3(pn - 2 * d, pn - d, pn, cmp);
- }
- pm = med3(pl, pm, pn, cmp);
- }
- swap(a, pm);
- pa = pb = (char *)a + es;
-
- pc = pd = (char *)a + (n - 1) * es;
- for (;;) {
- while (pb <= pc && (r = cmp(pb, a)) <= 0) {
- if (r == 0) {
- swap_cnt = 1;
- swap(pa, pb);
- pa += es;
- }
- pb += es;
- }
- while (pb <= pc && (r = cmp(pc, a)) >= 0) {
- if (r == 0) {
- swap_cnt = 1;
- swap(pc, pd);
- pd -= es;
- }
- pc -= es;
- }
- if (pb > pc)
- break;
- swap(pb, pc);
- swap_cnt = 1;
- pb += es;
- pc -= es;
- }
- if (swap_cnt == 0) { /* Switch to insertion sort */
- for (pm = (char *)a + es; pm < (char *)a + n * es; pm += es)
- for (pl = pm; pl > (char *)a && cmp(pl - es, pl) > 0;
- pl -= es)
- swap(pl, pl - es);
- return;
- }
-
- pn = (char *)a + n * es;
- r = min(pa - (char *)a, pb - pa);
- vecswap(a, pb - r, r);
- r = min(pd - pc, pn - pd - es);
- vecswap(pb, pn - r, r);
- if ((r = pb - pa) > es)
- qsort(a, r / es, es, cmp);
- if ((r = pd - pc) > es) {
- /* Iterate rather than recurse to save stack space */
- a = pn - r;
- n = r / es;
- goto loop;
- }
-/* qsort(pn - r, r / es, es, cmp);*/
+ char *pa, *pb, *pc, *pd, *pl, *pm, *pn;
+ int d, r, swaptype, swap_cnt;
+
+loop: SWAPINIT(a, es);
+ swap_cnt = 0;
+ if (n < 7) {
+ for (pm = (char *)a + es; pm < (char *)a + n * es; pm += es)
+ for (pl = pm; pl > (char *)a && cmp(pl - es, pl) > 0;
+ pl -= es)
+ swap(pl, pl - es);
+ return;
+ }
+ pm = (char *)a + (n / 2) * es;
+ if (n > 7) {
+ pl = a;
+ pn = (char *)a + (n - 1) * es;
+ if (n > 40) {
+ d = (n / 8) * es;
+ pl = med3(pl, pl + d, pl + 2 * d, cmp);
+ pm = med3(pm - d, pm, pm + d, cmp);
+ pn = med3(pn - 2 * d, pn - d, pn, cmp);
+ }
+ pm = med3(pl, pm, pn, cmp);
+ }
+ swap(a, pm);
+ pa = pb = (char *)a + es;
+
+ pc = pd = (char *)a + (n - 1) * es;
+ for (;;) {
+ while (pb <= pc && (r = cmp(pb, a)) <= 0) {
+ if (r == 0) {
+ swap_cnt = 1;
+ swap(pa, pb);
+ pa += es;
+ }
+ pb += es;
+ }
+ while (pb <= pc && (r = cmp(pc, a)) >= 0) {
+ if (r == 0) {
+ swap_cnt = 1;
+ swap(pc, pd);
+ pd -= es;
+ }
+ pc -= es;
+ }
+ if (pb > pc)
+ break;
+ swap(pb, pc);
+ swap_cnt = 1;
+ pb += es;
+ pc -= es;
+ }
+ if (swap_cnt == 0) { /* Switch to insertion sort */
+ for (pm = (char *)a + es; pm < (char *)a + n * es; pm += es)
+ for (pl = pm; pl > (char *)a && cmp(pl - es, pl) > 0;
+ pl -= es)
+ swap(pl, pl - es);
+ return;
+ }
+
+ pn = (char *)a + n * es;
+ r = min(pa - (char *)a, pb - pa);
+ vecswap(a, pb - r, r);
+ r = min(pd - pc, pn - pd - es);
+ vecswap(pb, pn - r, r);
+ if ((r = pb - pa) > es)
+ qsort(a, r / es, es, cmp);
+ if ((r = pd - pc) > es) {
+ /* Iterate rather than recurse to save stack space */
+ a = pn - r;
+ n = r / es;
+ goto loop;
+ }
+/* qsort(pn - r, r / es, es, cmp);*/
}
//==================================================================================
@@ -211,49 +209,56 @@ loop: SWAPINIT(a, es);
// bk001211 - gcc errors on compiling strcpy: parse error before `__extension__'
#if defined ( Q3_VM )
-size_t strlen( const char *string ) {
- const char *s;
+size_t strlen( const char *string )
+{
+ const char *s;
+
+ s = string;
+ while( *s )
+ s++;
- s = string;
- while ( *s ) {
- s++;
- }
- return s - string;
+ return s - string;
}
-char *strcat( char *strDestination, const char *strSource ) {
- char *s;
+char *strcat( char *strDestination, const char *strSource )
+{
+ char *s;
- s = strDestination;
- while ( *s ) {
- s++;
- }
- while ( *strSource ) {
- *s++ = *strSource++;
- }
- *s = 0;
- return strDestination;
+ s = strDestination;
+ while( *s )
+ s++;
+
+ while( *strSource )
+ *s++ = *strSource++;
+
+ *s = 0;
+ return strDestination;
}
-char *strcpy( char *strDestination, const char *strSource ) {
- char *s;
+char *strcpy( char *strDestination, const char *strSource )
+{
+ char *s;
- s = strDestination;
- while ( *strSource ) {
- *s++ = *strSource++;
- }
- *s = 0;
- return strDestination;
+ s = strDestination;
+
+ while( *strSource )
+ *s++ = *strSource++;
+
+ *s = 0;
+ return strDestination;
}
-int strcmp( const char *string1, const char *string2 ) {
- while ( *string1 == *string2 && *string1 && *string2 ) {
- string1++;
- string2++;
- }
- return *string1 - *string2;
+int strcmp( const char *string1, const char *string2 )
+{
+ while( *string1 == *string2 && *string1 && *string2 )
+ {
+ string1++;
+ string2++;
+ }
+
+ return *string1 - *string2;
}
//TA:
@@ -262,42 +267,47 @@ char *strrchr( const char *string, int c )
int i, length = strlen( string );
char *p;
- for( i = length - 1; i >= 0; i-- )
+ for( i = length - 1; i >= 0; i-- )
{
p = (char *)&string[ i ];
- if( *p == c )
- return (char *)p;
- }
+ if( *p == c )
+ return (char *)p;
+ }
- return (char *)0;
+ return (char *)0;
}
-char *strchr( const char *string, int c ) {
- while ( *string ) {
- if ( *string == c ) {
- return ( char * )string;
- }
- string++;
- }
- return (char *)0;
+char *strchr( const char *string, int c )
+{
+ while( *string )
+ {
+ if( *string == c )
+ return ( char * )string;
+
+ string++;
+ }
+ return (char *)0;
}
-char *strstr( const char *string, const char *strCharSet ) {
- while ( *string ) {
- int i;
-
- for ( i = 0 ; strCharSet[i] ; i++ ) {
- if ( string[i] != strCharSet[i] ) {
- break;
- }
- }
- if ( !strCharSet[i] ) {
- return (char *)string;
- }
- string++;
- }
- return (char *)0;
+char *strstr( const char *string, const char *strCharSet )
+{
+ while( *string )
+ {
+ int i;
+
+ for( i = 0; strCharSet[ i ]; i++ )
+ {
+ if( string[ i ] != strCharSet[ i ] )
+ break;
+ }
+
+ if( !strCharSet[ i ] )
+ return (char *)string;
+
+ string++;
+ }
+ return (char *)0;
}
#endif // bk001211
@@ -307,95 +317,100 @@ char *strstr( const char *string, const char *strCharSet ) {
// bk001127 - undid undo
#if defined ( Q3_VM )
-int tolower( int c ) {
- if ( c >= 'A' && c <= 'Z' ) {
- c += 'a' - 'A';
- }
- return c;
+int tolower( int c )
+{
+ if( c >= 'A' && c <= 'Z' )
+ c += 'a' - 'A';
+
+ return c;
}
-int toupper( int c ) {
- if ( c >= 'a' && c <= 'z' ) {
- c += 'A' - 'a';
- }
- return c;
+int toupper( int c )
+{
+ if( c >= 'a' && c <= 'z' )
+ c += 'A' - 'a';
+
+ return c;
}
#endif
//#ifndef _MSC_VER
-void *memmove( void *dest, const void *src, size_t count ) {
- int i;
-
- if ( dest > src ) {
- for ( i = count-1 ; i >= 0 ; i-- ) {
- ((char *)dest)[i] = ((char *)src)[i];
- }
- } else {
- for ( i = 0 ; i < count ; i++ ) {
- ((char *)dest)[i] = ((char *)src)[i];
- }
- }
- return dest;
+void *memmove( void *dest, const void *src, size_t count )
+{
+ int i;
+
+ if( dest > src )
+ {
+ for( i = count - 1; i >= 0; i-- )
+ ( (char *)dest )[ i ] = ( (char *)src )[ i ];
+ }
+ else
+ {
+ for( i = 0; i < count; i++ )
+ ( (char *)dest )[ i ] = ( (char *)src )[ i ];
+ }
+
+ return dest;
}
#if 0
double floor( double x ) {
- return (int)(x + 0x40000000) - 0x40000000;
+ return (int)(x + 0x40000000) - 0x40000000;
}
void *memset( void *dest, int c, size_t count ) {
- while ( count-- ) {
- ((char *)dest)[count] = c;
- }
- return dest;
+ while ( count-- ) {
+ ((char *)dest)[count] = c;
+ }
+ return dest;
}
void *memcpy( void *dest, const void *src, size_t count ) {
- while ( count-- ) {
- ((char *)dest)[count] = ((char *)src)[count];
- }
- return dest;
+ while ( count-- ) {
+ ((char *)dest)[count] = ((char *)src)[count];
+ }
+ return dest;
}
char *strncpy( char *strDest, const char *strSource, size_t count ) {
- char *s;
-
- s = strDest;
- while ( *strSource && count ) {
- *s++ = *strSource++;
- count--;
- }
- while ( count-- ) {
- *s++ = 0;
- }
- return strDest;
+ char *s;
+
+ s = strDest;
+ while ( *strSource && count ) {
+ *s++ = *strSource++;
+ count--;
+ }
+ while ( count-- ) {
+ *s++ = 0;
+ }
+ return strDest;
}
double sqrt( double x ) {
- float y;
- float delta;
- float maxError;
+ float y;
+ float delta;
+ float maxError;
- if ( x <= 0 ) {
- return 0;
- }
+ if ( x <= 0 ) {
+ return 0;
+ }
- // initial guess
- y = x / 2;
+ // initial guess
+ y = x / 2;
- // refine
- maxError = x * 0.001;
+ // refine
+ maxError = x * 0.001;
- do {
- delta = ( y * y ) - x;
- y -= delta / ( 2 * y );
- } while ( delta > maxError || delta < -maxError );
+ do {
+ delta = ( y * y ) - x;
+ y -= delta / ( 2 * y );
+ } while ( delta > maxError || delta < -maxError );
- return y;
+ return y;
}
@@ -531,44 +546,44 @@ float sintable[1024] = {
};
double sin( double x ) {
- int index;
- int quad;
-
- index = 1024 * x / (M_PI * 0.5);
- quad = ( index >> 10 ) & 3;
- index &= 1023;
- switch ( quad ) {
- case 0:
- return sintable[index];
- case 1:
- return sintable[1023-index];
- case 2:
- return -sintable[index];
- case 3:
- return -sintable[1023-index];
- }
- return 0;
+ int index;
+ int quad;
+
+ index = 1024 * x / (M_PI * 0.5);
+ quad = ( index >> 10 ) & 3;
+ index &= 1023;
+ switch ( quad ) {
+ case 0:
+ return sintable[index];
+ case 1:
+ return sintable[1023-index];
+ case 2:
+ return -sintable[index];
+ case 3:
+ return -sintable[1023-index];
+ }
+ return 0;
}
double cos( double x ) {
- int index;
- int quad;
-
- index = 1024 * x / (M_PI * 0.5);
- quad = ( index >> 10 ) & 3;
- index &= 1023;
- switch ( quad ) {
- case 3:
- return sintable[index];
- case 0:
- return sintable[1023-index];
- case 1:
- return -sintable[index];
- case 2:
- return -sintable[1023-index];
- }
- return 0;
+ int index;
+ int quad;
+
+ index = 1024 * x / (M_PI * 0.5);
+ quad = ( index >> 10 ) & 3;
+ index &= 1023;
+ switch ( quad ) {
+ case 3:
+ return sintable[index];
+ case 0:
+ return sintable[1023-index];
+ case 1:
+ return -sintable[index];
+ case 2:
+ return -sintable[1023-index];
+ }
+ return 0;
}
@@ -736,59 +751,59 @@ double acos( double x ) {
double atan2( double y, double x ) {
- float base;
- float temp;
- float dir;
- float test;
- int i;
-
- if ( x < 0 ) {
- if ( y >= 0 ) {
- // quad 1
- base = M_PI / 2;
- temp = x;
- x = y;
- y = -temp;
- } else {
- // quad 2
- base = M_PI;
- x = -x;
- y = -y;
- }
- } else {
- if ( y < 0 ) {
- // quad 3
- base = 3 * M_PI / 2;
- temp = x;
- x = -y;
- y = temp;
- }
- }
-
- if ( y > x ) {
- base += M_PI/2;
- temp = x;
- x = y;
- y = temp;
- dir = -1;
- } else {
- dir = 1;
- }
-
- // calcualte angle in octant 0
- if ( x == 0 ) {
- return base;
- }
- y /= x;
-
- for ( i = 0 ; i < 512 ; i++ ) {
- test = sintable[i] / sintable[1023-i];
- if ( test > y ) {
- break;
- }
- }
-
- return base + dir * i * ( M_PI/2048);
+ float base;
+ float temp;
+ float dir;
+ float test;
+ int i;
+
+ if ( x < 0 ) {
+ if ( y >= 0 ) {
+ // quad 1
+ base = M_PI / 2;
+ temp = x;
+ x = y;
+ y = -temp;
+ } else {
+ // quad 2
+ base = M_PI;
+ x = -x;
+ y = -y;
+ }
+ } else {
+ if ( y < 0 ) {
+ // quad 3
+ base = 3 * M_PI / 2;
+ temp = x;
+ x = -y;
+ y = temp;
+ }
+ }
+
+ if ( y > x ) {
+ base += M_PI/2;
+ temp = x;
+ x = y;
+ y = temp;
+ dir = -1;
+ } else {
+ dir = 1;
+ }
+
+ // calcualte angle in octant 0
+ if ( x == 0 ) {
+ return base;
+ }
+ y /= x;
+
+ for ( i = 0 ; i < 512 ; i++ ) {
+ test = sintable[i] / sintable[1023-i];
+ if ( test > y ) {
+ break;
+ }
+ }
+
+ return base + dir * i * ( M_PI/2048);
}
@@ -797,8 +812,9 @@ double atan2( double y, double x ) {
#ifdef Q3_VM
// bk001127 - guarded this tan replacement
// ld: undefined versioned symbol name tan@@GLIBC_2.0
-double tan( double x ) {
- return sin(x) / cos(x);
+double tan( double x )
+{
+ return sin( x ) / cos( x );
}
/*
@@ -862,27 +878,27 @@ acos
*/
double acos( double x )
{
- float z, p, q, r, w, s, c, df;
- int hx, ix;
+ float z, p, q, r, w, s, c, df;
+ int hx, ix;
- GET_FLOAT_WORD( hx, x );
- ix = hx & 0x7fffffff;
+ GET_FLOAT_WORD( hx, x );
+ ix = hx & 0x7fffffff;
- if( ix == 0x3f800000 )
- { /* |x|==1 */
- if( hx > 0 )
- return 0.0; /* acos(1) = 0 */
- else
- return pi + (float)2.0 * pio2_lo; /* acos(-1)= pi */
- }
+ if( ix == 0x3f800000 )
+ { /* |x|==1 */
+ if( hx > 0 )
+ return 0.0; /* acos(1) = 0 */
+ else
+ return pi + (float)2.0 * pio2_lo; /* acos(-1)= pi */
+ }
else if( ix > 0x3f800000 )
- { /* |x| >= 1 */
- return (x-x)/(x-x); /* acos(|x|>1) is NaN */
- }
+ { /* |x| >= 1 */
+ return (x-x)/(x-x); /* acos(|x|>1) is NaN */
+ }
- if( ix < 0x3f000000 )
- { /* |x| < 0.5 */
- if( ix <= 0x23000000 )
+ if( ix < 0x3f000000 )
+ { /* |x| < 0.5 */
+ if( ix <= 0x23000000 )
return pio2_hi + pio2_lo;/*if|x|<2**-57*/
z = x * x;
@@ -890,9 +906,9 @@ double acos( double x )
q = 1.0 + z * ( qS1 + z * ( qS2 + z * ( qS3 + z * qS4 ) ) );
r = p / q;
return pio2_hi - ( x - ( pio2_lo - x * r ) );
- }
+ }
else if( hx < 0 )
- { /* x < -0.5 */
+ { /* x < -0.5 */
z = ( 1.0 + x ) * (float)0.5;
p = z * ( pS0 + z * ( pS1 + z * ( pS2 + z * ( pS3 + z * ( pS4 + z * pS5 ) ) ) ) );
q = 1.0 + z * ( qS1 + z * ( qS2 + z * ( qS3 + z * qS4 ) ) );
@@ -900,9 +916,9 @@ double acos( double x )
r = p / q;
w = r * s - pio2_lo;
return pi - (float)2.0 * ( s + w );
- }
+ }
else
- { /* x > 0.5 */
+ { /* x > 0.5 */
int idf;
z = ( 1.0 - x ) * (float)0.5;
s = sqrt( z );
@@ -915,7 +931,7 @@ double acos( double x )
r = p / q;
w = r * s + c;
return (double)( 2.0 * ( df + w ) );
- }
+ }
}
//pow
@@ -1276,148 +1292,170 @@ float pow( float x, float y )
static int randSeed = 0;
-void srand( unsigned seed ) {
- randSeed = seed;
+void srand( unsigned seed )
+{
+ randSeed = seed;
}
-int rand( void ) {
- randSeed = (69069 * randSeed + 1);
- return randSeed & 0x7fff;
+int rand( void )
+{
+ randSeed = ( 69069 * randSeed + 1 );
+ return randSeed & 0x7fff;
}
-double atof( const char *string ) {
- float sign;
- float value;
- int c;
-
-
- // skip whitespace
- while ( *string <= ' ' ) {
- if ( !*string ) {
- return 0;
- }
- string++;
- }
-
- // check sign
- switch ( *string ) {
- case '+':
- string++;
- sign = 1;
- break;
- case '-':
- string++;
- sign = -1;
- break;
- default:
- sign = 1;
- break;
- }
-
- // read digits
- value = 0;
- c = string[0];
- if ( c != '.' ) {
- do {
- c = *string++;
- if ( c < '0' || c > '9' ) {
- break;
- }
- c -= '0';
- value = value * 10 + c;
- } while ( 1 );
- } else {
- string++;
- }
-
- // check for decimal point
- if ( c == '.' ) {
- double fraction;
-
- fraction = 0.1;
- do {
- c = *string++;
- if ( c < '0' || c > '9' ) {
- break;
- }
- c -= '0';
- value += c * fraction;
- fraction *= 0.1;
- } while ( 1 );
-
- }
-
- // not handling 10e10 notation...
-
- return value * sign;
+double atof( const char *string )
+{
+ float sign;
+ float value;
+ int c;
+
+ // skip whitespace
+ while( *string <= ' ' )
+ {
+ if( !*string )
+ return 0;
+
+ string++;
+ }
+
+ // check sign
+ switch( *string )
+ {
+ case '+':
+ string++;
+ sign = 1;
+ break;
+
+ case '-':
+ string++;
+ sign = -1;
+ break;
+
+ default:
+ sign = 1;
+ break;
+ }
+
+ // read digits
+ value = 0;
+ c = string[ 0 ];
+
+ if( c != '.' )
+ {
+ do
+ {
+ c = *string++;
+ if( c < '0' || c > '9' )
+ break;
+
+ c -= '0';
+ value = value * 10 + c;
+ } while( 1 );
+ }
+ else
+ string++;
+
+ // check for decimal point
+ if( c == '.' )
+ {
+ double fraction;
+
+ fraction = 0.1;
+ do
+ {
+ c = *string++;
+ if( c < '0' || c > '9' )
+ break;
+
+ c -= '0';
+ value += c * fraction;
+ fraction *= 0.1;
+ } while( 1 );
+
+ }
+
+ // not handling 10e10 notation...
+
+ return value * sign;
}
-double _atof( const char **stringPtr ) {
- const char *string;
- float sign;
- float value;
+double _atof( const char **stringPtr )
+{
+ const char *string;
+ float sign;
+ float value;
int c = '0'; // bk001211 - uninitialized use possible
- string = *stringPtr;
-
- // skip whitespace
- while ( *string <= ' ' ) {
- if ( !*string ) {
- *stringPtr = string;
- return 0;
- }
- string++;
- }
-
- // check sign
- switch ( *string ) {
- case '+':
- string++;
- sign = 1;
- break;
- case '-':
- string++;
- sign = -1;
- break;
- default:
- sign = 1;
- break;
- }
-
- // read digits
- value = 0;
- if ( string[0] != '.' ) {
- do {
- c = *string++;
- if ( c < '0' || c > '9' ) {
- break;
- }
- c -= '0';
- value = value * 10 + c;
- } while ( 1 );
- }
-
- // check for decimal point
- if ( c == '.' ) {
- double fraction;
-
- fraction = 0.1;
- do {
- c = *string++;
- if ( c < '0' || c > '9' ) {
- break;
- }
- c -= '0';
- value += c * fraction;
- fraction *= 0.1;
- } while ( 1 );
-
- }
-
- // not handling 10e10 notation...
- *stringPtr = string;
-
- return value * sign;
+ string = *stringPtr;
+
+ // skip whitespace
+ while( *string <= ' ' )
+ {
+ if( !*string )
+ {
+ *stringPtr = string;
+ return 0;
+ }
+
+ string++;
+ }
+
+ // check sign
+ switch( *string )
+ {
+ case '+':
+ string++;
+ sign = 1;
+ break;
+
+ case '-':
+ string++;
+ sign = -1;
+ break;
+
+ default:
+ sign = 1;
+ break;
+ }
+
+ // read digits
+ value = 0;
+ if( string[ 0 ] != '.' )
+ {
+ do
+ {
+ c = *string++;
+ if( c < '0' || c > '9' )
+ break;
+
+ c -= '0';
+ value = value * 10 + c;
+ } while( 1 );
+ }
+
+ // check for decimal point
+ if( c == '.' )
+ {
+ double fraction;
+
+ fraction = 0.1;
+ do
+ {
+ c = *string++;
+ if( c < '0' || c > '9' )
+ break;
+
+ c -= '0';
+ value += c * fraction;
+ fraction *= 0.1;
+ } while( 1 );
+
+ }
+
+ // not handling 10e10 notation...
+ *stringPtr = string;
+
+ return value * sign;
}
@@ -1427,107 +1465,120 @@ double _atof( const char **stringPtr ) {
// bk001127 - undid undo
#if defined ( Q3_VM )
-int atoi( const char *string ) {
- int sign;
- int value;
- int c;
-
-
- // skip whitespace
- while ( *string <= ' ' ) {
- if ( !*string ) {
- return 0;
- }
- string++;
- }
-
- // check sign
- switch ( *string ) {
- case '+':
- string++;
- sign = 1;
- break;
- case '-':
- string++;
- sign = -1;
- break;
- default:
- sign = 1;
- break;
- }
-
- // read digits
- value = 0;
- do {
- c = *string++;
- if ( c < '0' || c > '9' ) {
- break;
- }
- c -= '0';
- value = value * 10 + c;
- } while ( 1 );
-
- // not handling 10e10 notation...
-
- return value * sign;
+int atoi( const char *string )
+{
+ int sign;
+ int value;
+ int c;
+
+ // skip whitespace
+ while( *string <= ' ' )
+ {
+ if( !*string )
+ return 0;
+
+ string++;
+ }
+
+ // check sign
+ switch( *string )
+ {
+ case '+':
+ string++;
+ sign = 1;
+ break;
+
+ case '-':
+ string++;
+ sign = -1;
+ break;
+
+ default:
+ sign = 1;
+ break;
+ }
+
+ // read digits
+ value = 0;
+ do
+ {
+ c = *string++;
+ if( c < '0' || c > '9' )
+ break;
+
+ c -= '0';
+ value = value * 10 + c;
+ } while( 1 );
+
+ // not handling 10e10 notation...
+
+ return value * sign;
}
-int _atoi( const char **stringPtr ) {
- int sign;
- int value;
- int c;
- const char *string;
-
- string = *stringPtr;
-
- // skip whitespace
- while ( *string <= ' ' ) {
- if ( !*string ) {
- return 0;
- }
- string++;
- }
-
- // check sign
- switch ( *string ) {
- case '+':
- string++;
- sign = 1;
- break;
- case '-':
- string++;
- sign = -1;
- break;
- default:
- sign = 1;
- break;
- }
-
- // read digits
- value = 0;
- do {
- c = *string++;
- if ( c < '0' || c > '9' ) {
- break;
- }
- c -= '0';
- value = value * 10 + c;
- } while ( 1 );
-
- // not handling 10e10 notation...
-
- *stringPtr = string;
-
- return value * sign;
+int _atoi( const char **stringPtr )
+{
+ int sign;
+ int value;
+ int c;
+ const char *string;
+
+ string = *stringPtr;
+
+ // skip whitespace
+ while( *string <= ' ' )
+ {
+ if( !*string )
+ return 0;
+
+ string++;
+ }
+
+ // check sign
+ switch( *string )
+ {
+ case '+':
+ string++;
+ sign = 1;
+ break;
+
+ case '-':
+ string++;
+ sign = -1;
+ break;
+
+ default:
+ sign = 1;
+ break;
+ }
+
+ // read digits
+ value = 0;
+ do
+ {
+ c = *string++;
+ if( c < '0' || c > '9' )
+ break;
+
+ c -= '0';
+ value = value * 10 + c;
+ } while( 1 );
+
+ // not handling 10e10 notation...
+
+ *stringPtr = string;
+
+ return value * sign;
}
-int abs( int n ) {
- return n < 0 ? -n : n;
+int abs( int n )
+{
+ return n < 0 ? -n : n;
}
-double fabs( double x ) {
- return x < 0 ? -x : x;
+double fabs( double x )
+{
+ return x < 0 ? -x : x;
}
@@ -1535,156 +1586,163 @@ double fabs( double x ) {
//=========================================================
-#define ALT 0x00000001 /* alternate form */
-#define HEXPREFIX 0x00000002 /* add 0x or 0X prefix */
-#define LADJUST 0x00000004 /* left adjustment */
-#define LONGDBL 0x00000008 /* long double */
-#define LONGINT 0x00000010 /* long integer */
-#define QUADINT 0x00000020 /* quad integer */
-#define SHORTINT 0x00000040 /* short integer */
-#define ZEROPAD 0x00000080 /* zero (as opposed to blank) pad */
-#define FPT 0x00000100 /* floating point number */
-
-#define to_digit(c) ((c) - '0')
-#define is_digit(c) ((unsigned)to_digit(c) <= 9)
-#define to_char(n) ((n) + '0')
-
-void AddInt( char **buf_p, int val, int width, int flags ) {
- char text[32];
- int digits;
- int signedVal;
- char *buf;
-
- digits = 0;
- signedVal = val;
- if ( val < 0 ) {
- val = -val;
- }
- do {
- text[digits++] = '0' + val % 10;
- val /= 10;
- } while ( val );
-
- if ( signedVal < 0 ) {
- text[digits++] = '-';
- }
-
- buf = *buf_p;
-
- if( !( flags & LADJUST ) ) {
- while ( digits < width ) {
- *buf++ = ( flags & ZEROPAD ) ? '0' : ' ';
- width--;
- }
- }
-
- while ( digits-- ) {
- *buf++ = text[digits];
- width--;
- }
-
- if( flags & LADJUST ) {
- while ( width-- ) {
- *buf++ = ( flags & ZEROPAD ) ? '0' : ' ';
- }
- }
-
- *buf_p = buf;
+#define ALT 0x00000001 /* alternate form */
+#define HEXPREFIX 0x00000002 /* add 0x or 0X prefix */
+#define LADJUST 0x00000004 /* left adjustment */
+#define LONGDBL 0x00000008 /* long double */
+#define LONGINT 0x00000010 /* long integer */
+#define QUADINT 0x00000020 /* quad integer */
+#define SHORTINT 0x00000040 /* short integer */
+#define ZEROPAD 0x00000080 /* zero (as opposed to blank) pad */
+#define FPT 0x00000100 /* floating point number */
+
+#define to_digit(c) ((c) - '0')
+#define is_digit(c) ((unsigned)to_digit(c) <= 9)
+#define to_char(n) ((n) + '0')
+
+void AddInt( char **buf_p, int val, int width, int flags )
+{
+ char text[ 32 ];
+ int digits;
+ int signedVal;
+ char *buf;
+
+ digits = 0;
+ signedVal = val;
+ if( val < 0 )
+ val = -val;
+
+ do
+ {
+ text[ digits++ ] = '0' + val % 10;
+ val /= 10;
+ } while( val );
+
+ if( signedVal < 0 )
+ text[ digits++ ] = '-';
+
+ buf = *buf_p;
+
+ if( !( flags & LADJUST ) )
+ {
+ while( digits < width )
+ {
+ *buf++ = ( flags & ZEROPAD ) ? '0' : ' ';
+ width--;
+ }
+ }
+
+ while( digits-- )
+ {
+ *buf++ = text[ digits ];
+ width--;
+ }
+
+ if( flags & LADJUST )
+ {
+ while( width-- )
+ *buf++ = ( flags & ZEROPAD ) ? '0' : ' ';
+ }
+
+ *buf_p = buf;
}
-void AddFloat( char **buf_p, float fval, int width, int prec ) {
- char text[32];
- int digits;
- float signedVal;
- char *buf;
- int val;
+void AddFloat( char **buf_p, float fval, int width, int prec )
+{
+ char text[ 32 ];
+ int digits;
+ float signedVal;
+ char *buf;
+ int val;
// get the sign
- signedVal = fval;
- if ( fval < 0 ) {
- fval = -fval;
- }
+ signedVal = fval;
+ if( fval < 0 )
+ fval = -fval;
// write the float number
digits = 0;
- val = (int)fval;
- do {
- text[digits++] = '0' + val % 10;
- val /= 10;
- } while ( val );
+ val = (int)fval;
+
+ do
+ {
+ text[ digits++ ] = '0' + val % 10;
+ val /= 10;
+ } while( val );
- if ( signedVal < 0 ) {
- text[digits++] = '-';
- }
+ if( signedVal < 0 )
+ text[digits++] = '-';
- buf = *buf_p;
+ buf = *buf_p;
- while ( digits < width ) {
- *buf++ = ' ';
- width--;
- }
+ while( digits < width )
+ *buf++ = ' ';
+ width--;
- while ( digits-- ) {
- *buf++ = text[digits];
- }
+ while( digits-- )
+ *buf++ = text[ digits ];
- *buf_p = buf;
+ *buf_p = buf;
- if (prec < 0)
+ if( prec < 0 )
prec = 6;
+
// write the fraction
digits = 0;
- while (digits < prec) {
- fval -= (int) fval;
+
+ while( digits < prec )
+ {
+ fval -= (int)fval;
fval *= 10.0;
- val = (int) fval;
- text[digits++] = '0' + val % 10;
+ val = (int)fval;
+ text[ digits++ ] = '0' + val % 10;
}
- if (digits > 0) {
+ if( digits > 0 )
+ {
buf = *buf_p;
*buf++ = '.';
- for (prec = 0; prec < digits; prec++) {
- *buf++ = text[prec];
- }
+ for( prec = 0; prec < digits; prec++ )
+ *buf++ = text[ prec ];
+
*buf_p = buf;
}
}
-void AddString( char **buf_p, char *string, int width, int prec ) {
- int size;
- char *buf;
+void AddString( char **buf_p, char *string, int width, int prec )
+{
+ int size;
+ char *buf;
- buf = *buf_p;
+ buf = *buf_p;
- if ( string == NULL ) {
- string = "(null)";
- prec = -1;
- }
+ if( string == NULL )
+ {
+ string = "(null)";
+ prec = -1;
+ }
- if ( prec >= 0 ) {
- for( size = 0; size < prec; size++ ) {
- if( string[size] == '\0' ) {
- break;
- }
- }
- }
- else {
- size = strlen( string );
- }
+ if( prec >= 0 )
+ {
+ for( size = 0; size < prec; size++ )
+ {
+ if( string[ size ] == '\0' )
+ break;
+ }
+ }
+ else
+ size = strlen( string );
- width -= size;
+ width -= size;
- while( size-- ) {
- *buf++ = *string++;
- }
+ while( size-- )
+ *buf++ = *string++;
- while( width-- > 0 ) {
- *buf++ = ' ';
- }
+ while( width-- > 0 )
+ *buf++ = ' ';
- *buf_p = buf;
+ *buf_p = buf;
}
/*
@@ -1695,139 +1753,157 @@ just to keep it simpler. For example, the '*' and '$' are not
currently supported. I've tried to make it so that it will just
parse and ignore formats we don't support.
*/
-int vsprintf( char *buffer, const char *fmt, va_list argptr ) {
- int *arg;
- char *buf_p;
- char ch;
- int flags;
- int width;
- int prec;
- int n;
- char sign;
-
- buf_p = buffer;
- arg = (int *)argptr;
-
- while( qtrue ) {
- // run through the format string until we hit a '%' or '\0'
- for ( ch = *fmt; (ch = *fmt) != '\0' && ch != '%'; fmt++ ) {
- *buf_p++ = ch;
- }
- if ( ch == '\0' ) {
- goto done;
- }
-
- // skip over the '%'
- fmt++;
-
- // reset formatting state
- flags = 0;
- width = 0;
- prec = -1;
- sign = '\0';
+int vsprintf( char *buffer, const char *fmt, va_list argptr )
+{
+ int *arg;
+ char *buf_p;
+ char ch;
+ int flags;
+ int width;
+ int prec;
+ int n;
+ char sign;
+
+ buf_p = buffer;
+ arg = (int *)argptr;
+
+ while( qtrue )
+ {
+ // run through the format string until we hit a '%' or '\0'
+ for( ch = *fmt; ( ch = *fmt ) != '\0' && ch != '%'; fmt++ )
+ *buf_p++ = ch;
+
+ if( ch == '\0' )
+ goto done;
+
+ // skip over the '%'
+ fmt++;
+
+ // reset formatting state
+ flags = 0;
+ width = 0;
+ prec = -1;
+ sign = '\0';
rflag:
- ch = *fmt++;
+ ch = *fmt++;
reswitch:
- switch( ch ) {
- case '-':
- flags |= LADJUST;
- goto rflag;
- case '.':
- n = 0;
- while( is_digit( ( ch = *fmt++ ) ) ) {
- n = 10 * n + ( ch - '0' );
- }
- prec = n < 0 ? -1 : n;
- goto reswitch;
- case '0':
- flags |= ZEROPAD;
- goto rflag;
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- case '6':
- case '7':
- case '8':
- case '9':
- n = 0;
- do {
- n = 10 * n + ( ch - '0' );
- ch = *fmt++;
- } while( is_digit( ch ) );
- width = n;
- goto reswitch;
- case 'c':
- *buf_p++ = (char)*arg;
- arg++;
- break;
- case 'd':
- case 'i':
- AddInt( &buf_p, *arg, width, flags );
- arg++;
- break;
- case 'f':
- AddFloat( &buf_p, *(double *)arg, width, prec );
+ switch( ch )
+ {
+ case '-':
+ flags |= LADJUST;
+ goto rflag;
+
+ case '.':
+ n = 0;
+ while( is_digit( ( ch = *fmt++ ) ) )
+ n = 10 * n + ( ch - '0' );
+
+ prec = n < 0 ? -1 : n;
+ goto reswitch;
+
+ case '0':
+ flags |= ZEROPAD;
+ goto rflag;
+
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9':
+ n = 0;
+ do
+ {
+ n = 10 * n + ( ch - '0' );
+ ch = *fmt++;
+ } while( is_digit( ch ) );
+
+ width = n;
+ goto reswitch;
+
+ case 'c':
+ *buf_p++ = (char)*arg;
+ arg++;
+ break;
+
+ case 'd':
+ case 'i':
+ AddInt( &buf_p, *arg, width, flags );
+ arg++;
+ break;
+
+ case 'f':
+ AddFloat( &buf_p, *(double *)arg, width, prec );
#ifdef __LCC__
- arg += 1; // everything is 32 bit in my compiler
+ arg += 1; // everything is 32 bit in my compiler
#else
- arg += 2;
+ arg += 2;
#endif
- break;
- case 's':
- AddString( &buf_p, (char *)*arg, width, prec );
- arg++;
- break;
- case '%':
- *buf_p++ = ch;
- break;
- default:
- *buf_p++ = (char)*arg;
- arg++;
- break;
- }
- }
+ break;
+
+ case 's':
+ AddString( &buf_p, (char *)*arg, width, prec );
+ arg++;
+ break;
+
+ case '%':
+ *buf_p++ = ch;
+ break;
+
+ default:
+ *buf_p++ = (char)*arg;
+ arg++;
+ break;
+ }
+ }
done:
- *buf_p = 0;
- return buf_p - buffer;
+ *buf_p = 0;
+ return buf_p - buffer;
}
/* this is really crappy */
-int sscanf( const char *buffer, const char *fmt, ... ) {
- int cmd;
- int **arg;
- int count;
-
- arg = (int **)&fmt + 1;
- count = 0;
-
- while ( *fmt ) {
- if ( fmt[0] != '%' ) {
- fmt++;
- continue;
- }
-
- cmd = fmt[1];
- fmt += 2;
-
- switch ( cmd ) {
- case 'i':
- case 'd':
- case 'u':
- **arg = _atoi( &buffer );
- break;
- case 'f':
- *(float *)*arg = _atof( &buffer );
- break;
- }
- arg++;
- }
-
- return count;
+int sscanf( const char *buffer, const char *fmt, ... )
+{
+ int cmd;
+ int **arg;
+ int count;
+
+ arg = (int **)&fmt + 1;
+ count = 0;
+
+ while( *fmt )
+ {
+ if( fmt[ 0 ] != '%' )
+ {
+ fmt++;
+ continue;
+ }
+
+ cmd = fmt[ 1 ];
+ fmt += 2;
+
+ switch( cmd )
+ {
+ case 'i':
+ case 'd':
+ case 'u':
+ **arg = _atoi( &buffer );
+ break;
+ case 'f':
+ *(float *)*arg = _atof( &buffer );
+ break;
+ }
+
+ arg++;
+ }
+
+ return count;
}
#endif
diff --git a/src/game/bg_lib.h b/src/game/bg_lib.h
index b651c9a6..221e19e4 100644
--- a/src/game/bg_lib.h
+++ b/src/game/bg_lib.h
@@ -40,46 +40,46 @@ typedef char * va_list;
#define ULONG_MAX 0xffffffffUL /* maximum unsigned long value */
// Misc functions
-typedef int cmp_t(const void *, const void *);
-void qsort(void *a, size_t n, size_t es, cmp_t *cmp);
-void srand( unsigned seed );
-int rand( void );
+typedef int cmp_t( const void *, const void * );
+void qsort( void *a, size_t n, size_t es, cmp_t *cmp );
+void srand( unsigned seed );
+int rand( void );
// String functions
-size_t strlen( const char *string );
-char *strcat( char *strDestination, const char *strSource );
-char *strcpy( char *strDestination, const char *strSource );
-int strcmp( const char *string1, const char *string2 );
-char *strchr( const char *string, int c );
-char *strrchr( const char *string, int c );
-char *strstr( const char *string, const char *strCharSet );
-char *strncpy( char *strDest, const char *strSource, size_t count );
-int tolower( int c );
-int toupper( int c );
+size_t strlen( const char *string );
+char *strcat( char *strDestination, const char *strSource );
+char *strcpy( char *strDestination, const char *strSource );
+int strcmp( const char *string1, const char *string2 );
+char *strchr( const char *string, int c );
+char *strrchr( const char *string, int c );
+char *strstr( const char *string, const char *strCharSet );
+char *strncpy( char *strDest, const char *strSource, size_t count );
+int tolower( int c );
+int toupper( int c );
-double atof( const char *string );
-double _atof( const char **stringPtr );
-int atoi( const char *string );
-int _atoi( const char **stringPtr );
+double atof( const char *string );
+double _atof( const char **stringPtr );
+int atoi( const char *string );
+int _atoi( const char **stringPtr );
-int vsprintf( char *buffer, const char *fmt, va_list argptr );
-int sscanf( const char *buffer, const char *fmt, ... );
+int vsprintf( char *buffer, const char *fmt, va_list argptr );
+int sscanf( const char *buffer, const char *fmt, ... );
// Memory functions
-void *memmove( void *dest, const void *src, size_t count );
-void *memset( void *dest, int c, size_t count );
-void *memcpy( void *dest, const void *src, size_t count );
+void *memmove( void *dest, const void *src, size_t count );
+void *memset( void *dest, int c, size_t count );
+void *memcpy( void *dest, const void *src, size_t count );
// Math functions
-double ceil( double x );
-double floor( double x );
-double sqrt( double x );
-double sin( double x );
-double cos( double x );
-double atan2( double y, double x );
-double tan( double x );
-int abs( int n );
-double fabs( double x );
-double acos( double x );
-float pow( float x, float y );
+double ceil( double x );
+double floor( double x );
+double sqrt( double x );
+double sin( double x );
+double cos( double x );
+double atan2( double y, double x );
+double tan( double x );
+int abs( int n );
+double fabs( double x );
+double acos( double x );
+float pow( float x, float y );
diff --git a/src/game/bg_local.h b/src/game/bg_local.h
index da4987ac..f7d4c00d 100644
--- a/src/game/bg_local.h
+++ b/src/game/bg_local.h
@@ -29,21 +29,22 @@
// all of the locals will be zeroed before each
// pmove, just to make damn sure we don't have
// any differences when running on client or server
-typedef struct {
+typedef struct
+{
vec3_t forward, right, up;
- float frametime;
+ float frametime;
- int msec;
+ int msec;
qboolean walking;
qboolean groundPlane;
trace_t groundTrace;
- float impactSpeed;
+ float impactSpeed;
vec3_t previous_origin;
vec3_t previous_velocity;
- int previous_waterlevel;
+ int previous_waterlevel;
} pml_t;
extern pmove_t *pm;
@@ -73,4 +74,4 @@ void PM_AddEvent( int newEvent );
qboolean PM_SlideMove( qboolean gravity );
void PM_StepEvent( vec3_t from, vec3_t to, vec3_t normal );
qboolean PM_StepSlideMove( qboolean gravity, qboolean predictive );
-qboolean PM_PredictStepMove( );
+qboolean PM_PredictStepMove( void );
diff --git a/src/game/bg_misc.c b/src/game/bg_misc.c
index e3bba6e8..8870abe0 100644
--- a/src/game/bg_misc.c
+++ b/src/game/bg_misc.c
@@ -373,39 +373,7 @@ buildableAttributes_t bg_buildableList[ ] =
qfalse //qboolean reactorTest;
},
{
- BA_H_DEF1, //int buildNum;
- "plasmaturret", //char *buildName;
- "Plasma Turret", //char *humanName;
- "team_human_def1", //char *entityName;
- { "base.md3", "barrel.md3", "top.md3", 0 },
- { -24, -24, -11 }, //vec3_t mins;
- { 24, 24, 11 }, //vec3_t maxs;
- TR_GRAVITY, //trType_t traj;
- 0.0, //float bounce;
- 80, //int buildPoints;
- ( 1 << S2 )|( 1 << S3 ), //int stages
- 1000, //int health;
- 0, //int regenRate;
- 50, //int damage;
- 20, //int splashDamage;
- 50, //int splashRadius;
- MOD_HSPAWN, //int meansOfDeath;
- BIT_HUMANS, //int team;
- ( 1 << WP_HBUILD2 ), //weapon_t buildWeapon;
- BANIM_IDLE1, //int idleAnim;
- 50, //int nextthink;
- 500, //int turretFireSpeed;
- 500, //int turretRange;
- WP_PLASMAGUN, //weapon_t turretProjType;
- 0.707f, //float minNormal;
- qfalse, //qboolean invertNormal;
- qfalse, //qboolean creepTest;
- 0, //int creepSize;
- qfalse, //qboolean dccTest;
- qfalse //qboolean reactorTest;
- },
- {
- BA_H_DEF2, //int buildNum;
+ BA_H_MGTURRET, //int buildNum;
"mgturret", //char *buildName;
"Machinegun Turret", //char *humanName;
"team_human_def2", //char *entityName;
@@ -439,7 +407,7 @@ buildableAttributes_t bg_buildableList[ ] =
qfalse //qboolean reactorTest;
},
{
- BA_H_DEF3, //int buildNum;
+ BA_H_TESLAGEN, //int buildNum;
"tesla", //char *buildName;
"Tesla Generator", //char *humanName;
"team_human_tesla", //char *entityName;
@@ -2608,28 +2576,6 @@ weaponAttributes_t bg_weapons[ ] =
qfalse, //qboolean purchasable;
0, //int buildDelay;
WUT_HUMANS //WUTeam_t team;
- },
- {
- WP_PLASMAGUN, //int weaponNum;
- 100, //int price;
- ( 1 << S1 )|( 1 << S2 )|( 1 << S3 ), //int stages
- SLOT_WEAPON, //int slots;
- "plasmagun", //char *weaponName;
- "Plasma Gun", //char *weaponHumanName;
- { "models/weapons2/gauntlet/gauntlet.md3", 0, 0, 0 },
- "icons/iconw_gauntlet",
- 0, //int quan;
- 0, //int clips;
- 0, //int maxClips;
- qtrue, //int infiniteAmmo;
- qtrue, //int usesEnergy;
- 500, //int repeatRate;
- 0, //int reloadTime;
- qfalse, //qboolean hasAltMode;
- qfalse, //qboolean hasThirdMode;
- qfalse, //qboolean purchasable;
- 0, //int buildDelay;
- WUT_HUMANS //WUTeam_t team;
}
};
@@ -3344,47 +3290,55 @@ BG_EvaluateTrajectory
================
*/
-void BG_EvaluateTrajectory( const trajectory_t *tr, int atTime, vec3_t result ) {
+void BG_EvaluateTrajectory( const trajectory_t *tr, int atTime, vec3_t result )
+{
float deltaTime;
float phase;
- switch( tr->trType ) {
- case TR_STATIONARY:
- case TR_INTERPOLATE:
- VectorCopy( tr->trBase, result );
- break;
- case TR_LINEAR:
- deltaTime = ( atTime - tr->trTime ) * 0.001; // milliseconds to seconds
- VectorMA( tr->trBase, deltaTime, tr->trDelta, result );
- break;
- case TR_SINE:
- deltaTime = ( atTime - tr->trTime ) / (float) tr->trDuration;
- phase = sin( deltaTime * M_PI * 2 );
- VectorMA( tr->trBase, phase, tr->trDelta, result );
- break;
- case TR_LINEAR_STOP:
- if ( atTime > tr->trTime + tr->trDuration ) {
- atTime = tr->trTime + tr->trDuration;
- }
- deltaTime = ( atTime - tr->trTime ) * 0.001; // milliseconds to seconds
- if ( deltaTime < 0 ) {
- deltaTime = 0;
- }
- VectorMA( tr->trBase, deltaTime, tr->trDelta, result );
- break;
- case TR_GRAVITY:
- deltaTime = ( atTime - tr->trTime ) * 0.001; // milliseconds to seconds
- VectorMA( tr->trBase, deltaTime, tr->trDelta, result );
- result[2] -= 0.5 * DEFAULT_GRAVITY * deltaTime * deltaTime; // FIXME: local gravity...
- break;
- case TR_BUOYANCY:
- deltaTime = ( atTime - tr->trTime ) * 0.001; // milliseconds to seconds
- VectorMA( tr->trBase, deltaTime, tr->trDelta, result );
- result[2] += 0.5 * DEFAULT_GRAVITY * deltaTime * deltaTime; // FIXME: local gravity...
- break;
- default:
- Com_Error( ERR_DROP, "BG_EvaluateTrajectory: unknown trType: %i", tr->trTime );
- break;
+ switch( tr->trType )
+ {
+ case TR_STATIONARY:
+ case TR_INTERPOLATE:
+ VectorCopy( tr->trBase, result );
+ break;
+
+ case TR_LINEAR:
+ deltaTime = ( atTime - tr->trTime ) * 0.001; // milliseconds to seconds
+ VectorMA( tr->trBase, deltaTime, tr->trDelta, result );
+ break;
+
+ case TR_SINE:
+ deltaTime = ( atTime - tr->trTime ) / (float)tr->trDuration;
+ phase = sin( deltaTime * M_PI * 2 );
+ VectorMA( tr->trBase, phase, tr->trDelta, result );
+ break;
+
+ case TR_LINEAR_STOP:
+ if( atTime > tr->trTime + tr->trDuration )
+ atTime = tr->trTime + tr->trDuration;
+
+ deltaTime = ( atTime - tr->trTime ) * 0.001; // milliseconds to seconds
+ if( deltaTime < 0 )
+ deltaTime = 0;
+
+ VectorMA( tr->trBase, deltaTime, tr->trDelta, result );
+ break;
+
+ case TR_GRAVITY:
+ deltaTime = ( atTime - tr->trTime ) * 0.001; // milliseconds to seconds
+ VectorMA( tr->trBase, deltaTime, tr->trDelta, result );
+ result[ 2 ] -= 0.5 * DEFAULT_GRAVITY * deltaTime * deltaTime; // FIXME: local gravity...
+ break;
+
+ case TR_BUOYANCY:
+ deltaTime = ( atTime - tr->trTime ) * 0.001; // milliseconds to seconds
+ VectorMA( tr->trBase, deltaTime, tr->trDelta, result );
+ result[ 2 ] += 0.5 * DEFAULT_GRAVITY * deltaTime * deltaTime; // FIXME: local gravity...
+ break;
+
+ default:
+ Com_Error( ERR_DROP, "BG_EvaluateTrajectory: unknown trType: %i", tr->trTime );
+ break;
}
}
@@ -3395,48 +3349,58 @@ BG_EvaluateTrajectoryDelta
For determining velocity at a given time
================
*/
-void BG_EvaluateTrajectoryDelta( const trajectory_t *tr, int atTime, vec3_t result ) {
+void BG_EvaluateTrajectoryDelta( const trajectory_t *tr, int atTime, vec3_t result )
+{
float deltaTime;
float phase;
- switch( tr->trType ) {
- case TR_STATIONARY:
- case TR_INTERPOLATE:
- VectorClear( result );
- break;
- case TR_LINEAR:
- VectorCopy( tr->trDelta, result );
- break;
- case TR_SINE:
- deltaTime = ( atTime - tr->trTime ) / (float) tr->trDuration;
- phase = cos( deltaTime * M_PI * 2 ); // derivative of sin = cos
- phase *= 0.5;
- VectorScale( tr->trDelta, phase, result );
- break;
- case TR_LINEAR_STOP:
- if ( atTime > tr->trTime + tr->trDuration ) {
+ switch( tr->trType )
+ {
+ case TR_STATIONARY:
+ case TR_INTERPOLATE:
VectorClear( result );
- return;
- }
- VectorCopy( tr->trDelta, result );
- break;
- case TR_GRAVITY:
- deltaTime = ( atTime - tr->trTime ) * 0.001; // milliseconds to seconds
- VectorCopy( tr->trDelta, result );
- result[2] -= DEFAULT_GRAVITY * deltaTime; // FIXME: local gravity...
- break;
- case TR_BUOYANCY:
- deltaTime = ( atTime - tr->trTime ) * 0.001; // milliseconds to seconds
- VectorCopy( tr->trDelta, result );
- result[2] += DEFAULT_GRAVITY * deltaTime; // FIXME: local gravity...
- break;
- default:
- Com_Error( ERR_DROP, "BG_EvaluateTrajectoryDelta: unknown trType: %i", tr->trTime );
- break;
- }
-}
-
-char *eventnames[] = {
+ break;
+
+ case TR_LINEAR:
+ VectorCopy( tr->trDelta, result );
+ break;
+
+ case TR_SINE:
+ deltaTime = ( atTime - tr->trTime ) / (float)tr->trDuration;
+ phase = cos( deltaTime * M_PI * 2 ); // derivative of sin = cos
+ phase *= 0.5;
+ VectorScale( tr->trDelta, phase, result );
+ break;
+
+ case TR_LINEAR_STOP:
+ if( atTime > tr->trTime + tr->trDuration )
+ {
+ VectorClear( result );
+ return;
+ }
+ VectorCopy( tr->trDelta, result );
+ break;
+
+ case TR_GRAVITY:
+ deltaTime = ( atTime - tr->trTime ) * 0.001; // milliseconds to seconds
+ VectorCopy( tr->trDelta, result );
+ result[ 2 ] -= DEFAULT_GRAVITY * deltaTime; // FIXME: local gravity...
+ break;
+
+ case TR_BUOYANCY:
+ deltaTime = ( atTime - tr->trTime ) * 0.001; // milliseconds to seconds
+ VectorCopy( tr->trDelta, result );
+ result[ 2 ] += DEFAULT_GRAVITY * deltaTime; // FIXME: local gravity...
+ break;
+
+ default:
+ Com_Error( ERR_DROP, "BG_EvaluateTrajectoryDelta: unknown trType: %i", tr->trTime );
+ break;
+ }
+}
+
+char *eventnames[ ] =
+{
"EV_NONE",
"EV_FOOTSTEP",
@@ -3515,7 +3479,7 @@ char *eventnames[] = {
"EV_MISSILE_HIT",
"EV_MISSILE_MISS",
"EV_MISSILE_MISS_METAL",
- "EV_ITEM_EXPLOSION", //TA: human item explosions
+ "EV_BUILDABLE_EXPLOSION", //TA: human item explosions
"EV_RAILTRAIL",
"EV_TESLATRAIL",
"EV_ALIENZAP",
@@ -3565,22 +3529,27 @@ Handles the sequence numbers
void trap_Cvar_VariableStringBuffer( const char *var_name, char *buffer, int bufsize );
-void BG_AddPredictableEventToPlayerstate( int newEvent, int eventParm, playerState_t *ps ) {
+void BG_AddPredictableEventToPlayerstate( int newEvent, int eventParm, playerState_t *ps )
+{
#ifdef _DEBUG
{
- char buf[256];
- trap_Cvar_VariableStringBuffer("showevents", buf, sizeof(buf));
- if ( atof(buf) != 0 ) {
+ char buf[ 256 ];
+ trap_Cvar_VariableStringBuffer( "showevents", buf, sizeof( buf ) );
+
+ if( atof( buf ) != 0 )
+ {
#ifdef QAGAME
- Com_Printf(" game event svt %5d -> %5d: num = %20s parm %d\n", ps->pmove_framecount/*ps->commandTime*/, ps->eventSequence, eventnames[newEvent], eventParm);
+ Com_Printf( " game event svt %5d -> %5d: num = %20s parm %d\n",
+ ps->pmove_framecount/*ps->commandTime*/, ps->eventSequence, eventnames[ newEvent ], eventParm);
#else
- Com_Printf("Cgame event svt %5d -> %5d: num = %20s parm %d\n", ps->pmove_framecount/*ps->commandTime*/, ps->eventSequence, eventnames[newEvent], eventParm);
+ Com_Printf( "Cgame event svt %5d -> %5d: num = %20s parm %d\n",
+ ps->pmove_framecount/*ps->commandTime*/, ps->eventSequence, eventnames[ newEvent ], eventParm);
#endif
}
}
#endif
- ps->events[ps->eventSequence & (MAX_PS_EVENTS-1)] = newEvent;
- ps->eventParms[ps->eventSequence & (MAX_PS_EVENTS-1)] = eventParm;
+ ps->events[ ps->eventSequence & ( MAX_PS_EVENTS - 1 ) ] = newEvent;
+ ps->eventParms[ ps->eventSequence & ( MAX_PS_EVENTS - 1 ) ] = eventParm;
ps->eventSequence++;
}
@@ -3590,34 +3559,32 @@ void BG_AddPredictableEventToPlayerstate( int newEvent, int eventParm, playerSta
BG_TouchJumpPad
========================
*/
-void BG_TouchJumpPad( playerState_t *ps, entityState_t *jumppad ) {
+void BG_TouchJumpPad( playerState_t *ps, entityState_t *jumppad )
+{
vec3_t angles;
- float p;
- int effectNum;
+ float p;
+ int effectNum;
// spectators don't use jump pads
- if ( ps->pm_type != PM_NORMAL ) {
+ if( ps->pm_type != PM_NORMAL )
return;
- }
-
- // flying characters don't hit bounce pads
- if ( ps->powerups[PW_FLIGHT] ) {
- return;
- }
// if we didn't hit this same jumppad the previous frame
// then don't play the event sound again if we are in a fat trigger
- if ( ps->jumppad_ent != jumppad->number ) {
-
+ if( ps->jumppad_ent != jumppad->number )
+ {
vectoangles( jumppad->origin2, angles);
- p = fabs( AngleNormalize180( angles[PITCH] ) );
- if( p < 45 ) {
+
+ p = fabs( AngleNormalize180( angles[ PITCH ] ) );
+
+ if( p < 45 )
effectNum = 0;
- } else {
+ else
effectNum = 1;
- }
+
BG_AddPredictableEventToPlayerstate( EV_JUMP_PAD, effectNum, ps );
}
+
// remember hitting this jumppad this frame
ps->jumppad_ent = jumppad->number;
ps->jumppad_frame = ps->pmove_framecount;
@@ -3634,33 +3601,34 @@ This is done after each set of usercmd_t on the server,
and after local prediction on the client
========================
*/
-void BG_PlayerStateToEntityState( playerState_t *ps, entityState_t *s, qboolean snap ) {
- int i;
+void BG_PlayerStateToEntityState( playerState_t *ps, entityState_t *s, qboolean snap )
+{
+ int i;
vec3_t ceilingNormal = { 0, 0, -1 };
- if ( ps->pm_type == PM_INTERMISSION || ps->pm_type == PM_SPECTATOR || ps->pm_type == PM_FREEZE ) {
+ if( ps->pm_type == PM_INTERMISSION || ps->pm_type == PM_SPECTATOR || ps->pm_type == PM_FREEZE )
s->eType = ET_INVISIBLE;
- } else if ( ps->stats[STAT_HEALTH] <= GIB_HEALTH ) {
+ else if ( ps->stats[STAT_HEALTH] <= GIB_HEALTH )
s->eType = ET_INVISIBLE;
- } else {
+ else
s->eType = ET_PLAYER;
- }
s->number = ps->clientNum;
s->pos.trType = TR_INTERPOLATE;
VectorCopy( ps->origin, s->pos.trBase );
- if ( snap ) {
+
+ if( snap )
SnapVector( s->pos.trBase );
- }
+
//set the trDelta for flag direction
VectorCopy( ps->velocity, s->pos.trDelta );
s->apos.trType = TR_INTERPOLATE;
VectorCopy( ps->viewangles, s->apos.trBase );
- if ( snap ) {
+
+ if( snap )
SnapVector( s->apos.trBase );
- }
//TA: i need for other things :)
//s->angles2[YAW] = ps->movementDir;
@@ -3670,22 +3638,24 @@ void BG_PlayerStateToEntityState( playerState_t *ps, entityState_t *s, qboolean
s->clientNum = ps->clientNum; // ET_PLAYER looks here instead of at number
// so corpses can also reference the proper config
s->eFlags = ps->eFlags;
- if ( ps->stats[STAT_HEALTH] <= 0 ) {
+ if( ps->stats[STAT_HEALTH] <= 0 )
s->eFlags |= EF_DEAD;
- } else {
+ else
s->eFlags &= ~EF_DEAD;
- }
- if ( ps->externalEvent ) {
+ if( ps->externalEvent )
+ {
s->event = ps->externalEvent;
s->eventParm = ps->externalEventParm;
- } else if ( ps->entityEventSequence < ps->eventSequence ) {
+ }
+ else if( ps->entityEventSequence < ps->eventSequence )
+ {
int seq;
- if ( ps->entityEventSequence < ps->eventSequence - MAX_PS_EVENTS) {
+ if( ps->entityEventSequence < ps->eventSequence - MAX_PS_EVENTS )
ps->entityEventSequence = ps->eventSequence - MAX_PS_EVENTS;
- }
- seq = ps->entityEventSequence & (MAX_PS_EVENTS-1);
+
+ seq = ps->entityEventSequence & ( MAX_PS_EVENTS - 1 );
s->event = ps->events[ seq ] | ( ( ps->entityEventSequence & 3 ) << 8 );
s->eventParm = ps->eventParms[ seq ];
ps->entityEventSequence++;
@@ -3729,25 +3699,26 @@ This is done after each set of usercmd_t on the server,
and after local prediction on the client
========================
*/
-void BG_PlayerStateToEntityStateExtraPolate( playerState_t *ps, entityState_t *s, int time, qboolean snap ) {
- int i;
+void BG_PlayerStateToEntityStateExtraPolate( playerState_t *ps, entityState_t *s, int time, qboolean snap )
+{
+ int i;
vec3_t ceilingNormal = { 0, 0, -1 };
- if ( ps->pm_type == PM_INTERMISSION || ps->pm_type == PM_SPECTATOR || ps->pm_type == PM_FREEZE ) {
+ if( ps->pm_type == PM_INTERMISSION || ps->pm_type == PM_SPECTATOR || ps->pm_type == PM_FREEZE )
s->eType = ET_INVISIBLE;
- } else if ( ps->stats[STAT_HEALTH] <= GIB_HEALTH ) {
+ else if( ps->stats[STAT_HEALTH] <= GIB_HEALTH )
s->eType = ET_INVISIBLE;
- } else {
+ else
s->eType = ET_PLAYER;
- }
s->number = ps->clientNum;
s->pos.trType = TR_LINEAR_STOP;
VectorCopy( ps->origin, s->pos.trBase );
- if ( snap ) {
+
+ if( snap )
SnapVector( s->pos.trBase );
- }
+
// set the trDelta for flag direction and linear prediction
VectorCopy( ps->velocity, s->pos.trDelta );
// set the time for linear prediction
@@ -3757,9 +3728,8 @@ void BG_PlayerStateToEntityStateExtraPolate( playerState_t *ps, entityState_t *s
s->apos.trType = TR_INTERPOLATE;
VectorCopy( ps->viewangles, s->apos.trBase );
- if ( snap ) {
+ if( snap )
SnapVector( s->apos.trBase );
- }
//TA: i need for other things :)
//s->angles2[YAW] = ps->movementDir;
@@ -3769,22 +3739,25 @@ void BG_PlayerStateToEntityStateExtraPolate( playerState_t *ps, entityState_t *s
s->clientNum = ps->clientNum; // ET_PLAYER looks here instead of at number
// so corpses can also reference the proper config
s->eFlags = ps->eFlags;
- if ( ps->stats[STAT_HEALTH] <= 0 ) {
+
+ if( ps->stats[STAT_HEALTH] <= 0 )
s->eFlags |= EF_DEAD;
- } else {
+ else
s->eFlags &= ~EF_DEAD;
- }
- if ( ps->externalEvent ) {
+ if( ps->externalEvent )
+ {
s->event = ps->externalEvent;
s->eventParm = ps->externalEventParm;
- } else if ( ps->entityEventSequence < ps->eventSequence ) {
+ }
+ else if( ps->entityEventSequence < ps->eventSequence )
+ {
int seq;
- if ( ps->entityEventSequence < ps->eventSequence - MAX_PS_EVENTS) {
+ if( ps->entityEventSequence < ps->eventSequence - MAX_PS_EVENTS )
ps->entityEventSequence = ps->eventSequence - MAX_PS_EVENTS;
- }
- seq = ps->entityEventSequence & (MAX_PS_EVENTS-1);
+
+ seq = ps->entityEventSequence & ( MAX_PS_EVENTS - 1 );
s->event = ps->events[ seq ] | ( ( ps->entityEventSequence & 3 ) << 8 );
s->eventParm = ps->eventParms[ seq ];
ps->entityEventSequence++;
@@ -3796,6 +3769,7 @@ void BG_PlayerStateToEntityStateExtraPolate( playerState_t *ps, entityState_t *s
//store items held and active items in otherEntityNum
s->modelindex = 0;
s->modelindex2 = 0;
+
for( i = UP_NONE + 1; i < UP_NUM_UPGRADES; i++ )
{
if( BG_gotItem( i, ps->stats ) )
diff --git a/src/game/bg_pmove.c b/src/game/bg_pmove.c
index e79a3a8c..cae5470b 100644
--- a/src/game/bg_pmove.c
+++ b/src/game/bg_pmove.c
@@ -47,7 +47,8 @@ PM_AddEvent
===============
*/
-void PM_AddEvent( int newEvent ) {
+void PM_AddEvent( int newEvent )
+{
BG_AddPredictableEventToPlayerstate( newEvent, 0, pm->ps );
}
@@ -56,25 +57,25 @@ void PM_AddEvent( int newEvent ) {
PM_AddTouchEnt
===============
*/
-void PM_AddTouchEnt( int entityNum ) {
+void PM_AddTouchEnt( int entityNum )
+{
int i;
- if ( entityNum == ENTITYNUM_WORLD ) {
+ if( entityNum == ENTITYNUM_WORLD )
return;
- }
- if ( pm->numtouch == MAXTOUCH ) {
+
+ if( pm->numtouch == MAXTOUCH )
return;
- }
// see if it is already added
- for ( i = 0 ; i < pm->numtouch ; i++ ) {
- if ( pm->touchents[ i ] == entityNum ) {
+ for( i = 0 ; i < pm->numtouch ; i++ )
+ {
+ if( pm->touchents[ i ] == entityNum )
return;
- }
}
// add it
- pm->touchents[pm->numtouch] = entityNum;
+ pm->touchents[ pm->numtouch ] = entityNum;
pm->numtouch++;
}
@@ -83,45 +84,51 @@ void PM_AddTouchEnt( int entityNum ) {
PM_StartTorsoAnim
===================
*/
-static void PM_StartTorsoAnim( int anim ) {
- if ( pm->ps->pm_type >= PM_DEAD ) {
+static void PM_StartTorsoAnim( int anim )
+{
+ if( pm->ps->pm_type >= PM_DEAD )
return;
- }
+
pm->ps->torsoAnim = ( ( pm->ps->torsoAnim & ANIM_TOGGLEBIT ) ^ ANIM_TOGGLEBIT )
| anim;
}
-static void PM_StartLegsAnim( int anim ) {
- if ( pm->ps->pm_type >= PM_DEAD ) {
+
+static void PM_StartLegsAnim( int anim )
+{
+ if( pm->ps->pm_type >= PM_DEAD )
return;
- }
- if ( pm->ps->legsTimer > 0 ) {
+
+ if( pm->ps->legsTimer > 0 )
return; // a high priority animation is running
- }
+
pm->ps->legsAnim = ( ( pm->ps->legsAnim & ANIM_TOGGLEBIT ) ^ ANIM_TOGGLEBIT )
| anim;
}
-static void PM_ContinueLegsAnim( int anim ) {
- if ( ( pm->ps->legsAnim & ~ANIM_TOGGLEBIT ) == anim ) {
+static void PM_ContinueLegsAnim( int anim )
+{
+ if( ( pm->ps->legsAnim & ~ANIM_TOGGLEBIT ) == anim )
return;
- }
- if ( pm->ps->legsTimer > 0 ) {
+
+ if( pm->ps->legsTimer > 0 )
return; // a high priority animation is running
- }
+
PM_StartLegsAnim( anim );
}
-static void PM_ContinueTorsoAnim( int anim ) {
- if ( ( pm->ps->torsoAnim & ~ANIM_TOGGLEBIT ) == anim ) {
+static void PM_ContinueTorsoAnim( int anim )
+{
+ if( ( pm->ps->torsoAnim & ~ANIM_TOGGLEBIT ) == anim )
return;
- }
- if ( pm->ps->torsoTimer > 0 ) {
+
+ if( pm->ps->torsoTimer > 0 )
return; // a high priority animation is running
- }
+
PM_StartTorsoAnim( anim );
}
-static void PM_ForceLegsAnim( int anim ) {
+static void PM_ForceLegsAnim( int anim )
+{
pm->ps->legsTimer = 0;
PM_StartLegsAnim( anim );
}
@@ -134,25 +141,26 @@ PM_ClipVelocity
Slide off of the impacting surface
==================
*/
-void PM_ClipVelocity( vec3_t in, vec3_t normal, vec3_t out, float overbounce ) {
+void PM_ClipVelocity( vec3_t in, vec3_t normal, vec3_t out, float overbounce )
+{
float backoff;
float change;
int i;
- backoff = DotProduct (in, normal);
+ backoff = DotProduct( in, normal );
//Com_Printf( "%1.0f ", backoff );
- if ( backoff < 0 ) {
+ if( backoff < 0 )
backoff *= overbounce;
- } else {
+ else
backoff /= overbounce;
- }
- for ( i=0 ; i<3 ; i++ ) {
- change = normal[i]*backoff;
+ for( i = 0; i < 3; i++ )
+ {
+ change = normal[ i ] * backoff;
//Com_Printf( "%1.0f ", change );
- out[i] = in[i] - change;
+ out[ i ] = in[ i ] - change;
}
//Com_Printf( " " );
@@ -166,25 +174,27 @@ PM_Friction
Handles both ground friction and water friction
==================
*/
-static void PM_Friction( void ) {
+static void PM_Friction( void )
+{
vec3_t vec;
- float *vel;
- float speed, newspeed, control;
- float drop;
+ float *vel;
+ float speed, newspeed, control;
+ float drop;
vel = pm->ps->velocity;
//TA: make sure vertical velocity is NOT set to zero when wall climbing
VectorCopy( vel, vec );
- if ( pml.walking &&
- !( pm->ps->stats[ STAT_STATE ] & SS_WALLCLIMBING ) ) {
+ if( pml.walking &&
+ !( pm->ps->stats[ STAT_STATE ] & SS_WALLCLIMBING ) )
vec[2] = 0; // ignore slope movement
- }
- speed = VectorLength(vec);
- if (speed < 1) {
- vel[0] = 0;
- vel[1] = 0; // allow sinking underwater
+ speed = VectorLength( vec );
+
+ if( speed < 1 )
+ {
+ vel[ 0 ] = 0;
+ vel[ 1 ] = 0; // allow sinking underwater
// FIXME: still have z friction underwater?
return;
}
@@ -192,42 +202,42 @@ static void PM_Friction( void ) {
drop = 0;
// apply ground friction
- if ( pm->waterlevel <= 1 ) {
- if ( pml.walking && !(pml.groundTrace.surfaceFlags & SURF_SLICK) ) {
+ if( pm->waterlevel <= 1 )
+ {
+ if( pml.walking && !( pml.groundTrace.surfaceFlags & SURF_SLICK ) )
+ {
// if getting knocked back, no friction
- if ( ! (pm->ps->pm_flags & PMF_TIME_KNOCKBACK) )
+ if( !( pm->ps->pm_flags & PMF_TIME_KNOCKBACK ) )
{
float sticky = BG_FindStickyForClass( pm->ps->stats[ STAT_PCLASS ] );
- control = speed < pm_stopspeed*sticky ? pm_stopspeed*sticky : speed;
+ control = speed < pm_stopspeed * sticky ? pm_stopspeed * sticky : speed;
drop += control*pm_friction*pml.frametime;
}
}
}
// apply water friction even if just wading
- if ( pm->waterlevel ) {
- drop += speed*pm_waterfriction*pm->waterlevel*pml.frametime;
- }
+ if( pm->waterlevel )
+ drop += speed * pm_waterfriction * pm->waterlevel * pml.frametime;
// apply flying friction
if( BG_gotItem( UP_JETPACK, pm->ps->stats ) && BG_activated( UP_JETPACK, pm->ps->stats ) )
drop += speed * pm_flightfriction * pml.frametime;
- if ( pm->ps->pm_type == PM_SPECTATOR ) {
- drop += speed*pm_spectatorfriction*pml.frametime;
- }
+ if( pm->ps->pm_type == PM_SPECTATOR )
+ drop += speed * pm_spectatorfriction * pml.frametime;
// scale the velocity
newspeed = speed - drop;
- if (newspeed < 0) {
+ if( newspeed < 0 )
newspeed = 0;
- }
+
newspeed /= speed;
- vel[0] = vel[0] * newspeed;
- vel[1] = vel[1] * newspeed;
- vel[2] = vel[2] * newspeed;
+ vel[ 0 ] = vel[ 0 ] * newspeed;
+ vel[ 1 ] = vel[ 1 ] * newspeed;
+ vel[ 2 ] = vel[ 2 ] * newspeed;
}
@@ -238,40 +248,38 @@ PM_Accelerate
Handles user intended acceleration
==============
*/
-static void PM_Accelerate( vec3_t wishdir, float wishspeed, float accel ) {
+static void PM_Accelerate( vec3_t wishdir, float wishspeed, float accel )
+{
#if 1
// q2 style
int i;
float addspeed, accelspeed, currentspeed;
- currentspeed = DotProduct (pm->ps->velocity, wishdir);
+ currentspeed = DotProduct( pm->ps->velocity, wishdir );
addspeed = wishspeed - currentspeed;
- if (addspeed <= 0) {
+ if( addspeed <= 0 )
return;
- }
- accelspeed = accel*pml.frametime*wishspeed;
- if (accelspeed > addspeed) {
+
+ accelspeed = accel * pml.frametime * wishspeed;
+ if( accelspeed > addspeed )
accelspeed = addspeed;
- }
- for (i=0 ; i<3 ; i++) {
- pm->ps->velocity[i] += accelspeed*wishdir[i];
- }
+ for( i = 0; i < 3; i++ )
+ pm->ps->velocity[ i ] += accelspeed*wishdir[ i ];
#else
// proper way (avoids strafe jump maxspeed bug), but feels bad
vec3_t wishVelocity;
vec3_t pushDir;
- float pushLen;
- float canPush;
+ float pushLen;
+ float canPush;
VectorScale( wishdir, wishspeed, wishVelocity );
VectorSubtract( wishVelocity, pm->ps->velocity, pushDir );
pushLen = VectorNormalize( pushDir );
- canPush = accel*pml.frametime*wishspeed;
- if (canPush > pushLen) {
+ canPush = accel * pml.frametime * wishspeed;
+ if( canPush > pushLen )
canPush = pushLen;
- }
VectorMA( pm->ps->velocity, canPush, pushDir, pm->ps->velocity );
#endif
@@ -288,14 +296,15 @@ This allows the clients to use axial -127 to 127 values for all directions
without getting a sqrt(2) distortion in speed.
============
*/
-static float PM_CmdScale( usercmd_t *cmd ) {
- int max;
- float total;
- float scale;
- float modifier = 1.0f;
- static int time;
- int dTime;
- int aForward, aRight;
+static float PM_CmdScale( usercmd_t *cmd )
+{
+ int max;
+ float total;
+ float scale;
+ float modifier = 1.0f;
+ static int time;
+ int dTime;
+ int aForward, aRight;
dTime = pm->cmd.serverTime - time;
time = pm->cmd.serverTime;
@@ -336,15 +345,14 @@ static float PM_CmdScale( usercmd_t *cmd ) {
cmd->upmove = 0;
max = abs( cmd->forwardmove );
- if ( abs( cmd->rightmove ) > max ) {
+ if( abs( cmd->rightmove ) > max )
max = abs( cmd->rightmove );
- }
- if ( abs( cmd->upmove ) > max ) {
+
+ if( abs( cmd->upmove ) > max )
max = abs( cmd->upmove );
- }
- if ( !max ) {
+
+ if( !max )
return 0;
- }
total = sqrt( cmd->forwardmove * cmd->forwardmove
+ cmd->rightmove * cmd->rightmove + cmd->upmove * cmd->upmove );
@@ -363,34 +371,36 @@ Determine the rotation of the legs reletive
to the facing dir
================
*/
-static void PM_SetMovementDir( void ) {
- if ( pm->cmd.forwardmove || pm->cmd.rightmove ) {
- if ( pm->cmd.rightmove == 0 && pm->cmd.forwardmove > 0 ) {
+static void PM_SetMovementDir( void )
+{
+ if( pm->cmd.forwardmove || pm->cmd.rightmove )
+ {
+ if( pm->cmd.rightmove == 0 && pm->cmd.forwardmove > 0 )
pm->ps->movementDir = 0;
- } else if ( pm->cmd.rightmove < 0 && pm->cmd.forwardmove > 0 ) {
+ else if( pm->cmd.rightmove < 0 && pm->cmd.forwardmove > 0 )
pm->ps->movementDir = 1;
- } else if ( pm->cmd.rightmove < 0 && pm->cmd.forwardmove == 0 ) {
+ else if( pm->cmd.rightmove < 0 && pm->cmd.forwardmove == 0 )
pm->ps->movementDir = 2;
- } else if ( pm->cmd.rightmove < 0 && pm->cmd.forwardmove < 0 ) {
+ else if( pm->cmd.rightmove < 0 && pm->cmd.forwardmove < 0 )
pm->ps->movementDir = 3;
- } else if ( pm->cmd.rightmove == 0 && pm->cmd.forwardmove < 0 ) {
+ else if( pm->cmd.rightmove == 0 && pm->cmd.forwardmove < 0 )
pm->ps->movementDir = 4;
- } else if ( pm->cmd.rightmove > 0 && pm->cmd.forwardmove < 0 ) {
+ else if( pm->cmd.rightmove > 0 && pm->cmd.forwardmove < 0 )
pm->ps->movementDir = 5;
- } else if ( pm->cmd.rightmove > 0 && pm->cmd.forwardmove == 0 ) {
+ else if( pm->cmd.rightmove > 0 && pm->cmd.forwardmove == 0 )
pm->ps->movementDir = 6;
- } else if ( pm->cmd.rightmove > 0 && pm->cmd.forwardmove > 0 ) {
+ else if( pm->cmd.rightmove > 0 && pm->cmd.forwardmove > 0 )
pm->ps->movementDir = 7;
- }
- } else {
+ }
+ else
+ {
// if they aren't actively going directly sideways,
// change the animation to the diagonal so they
// don't stop too crooked
- if ( pm->ps->movementDir == 2 ) {
+ if( pm->ps->movementDir == 2 )
pm->ps->movementDir = 1;
- } else if ( pm->ps->movementDir == 6 ) {
+ else if( pm->ps->movementDir == 6 )
pm->ps->movementDir = 7;
- }
}
}
@@ -453,14 +463,12 @@ static qboolean PM_CheckJump( void )
( pm->ps->stats[ STAT_STAMINA ] < 0 ) )
return qfalse;
- if ( pm->ps->pm_flags & PMF_RESPAWNED ) {
+ if( pm->ps->pm_flags & PMF_RESPAWNED )
return qfalse; // don't allow jump until all buttons are up
- }
- if ( pm->cmd.upmove < 10 ) {
+ if( pm->cmd.upmove < 10 )
// not holding jump
return qfalse;
- }
//can't jump whilst grabbed
if( pm->ps->pm_type == PM_GRABBED && pm->ps->pm_type == PM_KNOCKED )
@@ -470,7 +478,8 @@ static qboolean PM_CheckJump( void )
}
// must wait for jump to be released
- if ( pm->ps->pm_flags & PMF_JUMP_HELD ) {
+ if( pm->ps->pm_flags & PMF_JUMP_HELD )
+ {
// clear upmove so cmdscale doesn't lower running speed
pm->cmd.upmove = 0;
return qfalse;
@@ -497,14 +506,17 @@ static qboolean PM_CheckJump( void )
VectorMA( pm->ps->velocity, JUMP_VELOCITY, normal, pm->ps->velocity );
}
else
- pm->ps->velocity[2] = JUMP_VELOCITY;
+ pm->ps->velocity[ 2 ] = JUMP_VELOCITY;
PM_AddEvent( EV_JUMP );
- if ( pm->cmd.forwardmove >= 0 ) {
+ if( pm->cmd.forwardmove >= 0 )
+ {
PM_ForceLegsAnim( LEGS_JUMP );
pm->ps->pm_flags &= ~PMF_BACKWARDS_JUMP;
- } else {
+ }
+ else
+ {
PM_ForceLegsAnim( LEGS_JUMPB );
pm->ps->pm_flags |= PMF_BACKWARDS_JUMP;
}
@@ -517,41 +529,40 @@ static qboolean PM_CheckJump( void )
PM_CheckWaterJump
=============
*/
-static qboolean PM_CheckWaterJump( void ) {
+static qboolean PM_CheckWaterJump( void )
+{
vec3_t spot;
- int cont;
+ int cont;
vec3_t flatforward;
- if (pm->ps->pm_time) {
+ if( pm->ps->pm_time )
return qfalse;
- }
// check for water jump
- if ( pm->waterlevel != 2 ) {
+ if( pm->waterlevel != 2 )
return qfalse;
- }
- flatforward[0] = pml.forward[0];
- flatforward[1] = pml.forward[1];
- flatforward[2] = 0;
- VectorNormalize (flatforward);
+ flatforward[ 0 ] = pml.forward[ 0 ];
+ flatforward[ 1 ] = pml.forward[ 1 ];
+ flatforward[ 2 ] = 0;
+ VectorNormalize( flatforward );
- VectorMA (pm->ps->origin, 30, flatforward, spot);
- spot[2] += 4;
- cont = pm->pointcontents (spot, pm->ps->clientNum );
- if ( !(cont & CONTENTS_SOLID) ) {
+ VectorMA( pm->ps->origin, 30, flatforward, spot );
+ spot[ 2 ] += 4;
+ cont = pm->pointcontents( spot, pm->ps->clientNum );
+
+ if( !( cont & CONTENTS_SOLID ) )
return qfalse;
- }
- spot[2] += 16;
- cont = pm->pointcontents (spot, pm->ps->clientNum );
- if ( cont ) {
+ spot[ 2 ] += 16;
+ cont = pm->pointcontents( spot, pm->ps->clientNum );
+
+ if( cont )
return qfalse;
- }
// jump out of water
- VectorScale (pml.forward, 200, pm->ps->velocity);
- pm->ps->velocity[2] = 350;
+ VectorScale( pml.forward, 200, pm->ps->velocity );
+ pm->ps->velocity[ 2 ] = 350;
pm->ps->pm_flags |= PMF_TIME_WATERJUMP;
pm->ps->pm_time = 2000;
@@ -569,13 +580,15 @@ PM_WaterJumpMove
Flying out of the water
===================
*/
-static void PM_WaterJumpMove( void ) {
+static void PM_WaterJumpMove( void )
+{
// waterjump has no control, but falls
PM_StepSlideMove( qtrue, qfalse );
- pm->ps->velocity[2] -= pm->ps->gravity * pml.frametime;
- if (pm->ps->velocity[2] < 0) {
+ pm->ps->velocity[ 2 ] -= pm->ps->gravity * pml.frametime;
+ if( pm->ps->velocity[ 2 ] < 0 )
+ {
// cancel as soon as we are falling down again
pm->ps->pm_flags &= ~PMF_ALL_TIMES;
pm->ps->pm_time = 0;
@@ -588,7 +601,8 @@ PM_WaterMove
===================
*/
-static void PM_WaterMove( void ) {
+static void PM_WaterMove( void )
+{
int i;
vec3_t wishvel;
float wishspeed;
@@ -596,7 +610,8 @@ static void PM_WaterMove( void ) {
float scale;
float vel;
- if ( PM_CheckWaterJump() ) {
+ if( PM_CheckWaterJump( ) )
+ {
PM_WaterJumpMove();
return;
}
@@ -614,41 +629,44 @@ static void PM_WaterMove( void ) {
}
}
#endif
- PM_Friction ();
+ PM_Friction( );
scale = PM_CmdScale( &pm->cmd );
//
// user intentions
//
- if ( !scale ) {
- wishvel[0] = 0;
- wishvel[1] = 0;
- wishvel[2] = -60; // sink towards bottom
- } else {
- for (i=0 ; i<3 ; i++)
- wishvel[i] = scale * pml.forward[i]*pm->cmd.forwardmove + scale * pml.right[i]*pm->cmd.rightmove;
+ if( !scale )
+ {
+ wishvel[ 0 ] = 0;
+ wishvel[ 1 ] = 0;
+ wishvel[ 2 ] = -60; // sink towards bottom
+ }
+ else
+ {
+ for( i = 0; i < 3; i++ )
+ wishvel[ i ] = scale * pml.forward[ i ] * pm->cmd.forwardmove + scale * pml.right[ i ] * pm->cmd.rightmove;
- wishvel[2] += scale * pm->cmd.upmove;
+ wishvel[ 2 ] += scale * pm->cmd.upmove;
}
- VectorCopy (wishvel, wishdir);
- wishspeed = VectorNormalize(wishdir);
+ VectorCopy( wishvel, wishdir );
+ wishspeed = VectorNormalize( wishdir );
- if ( wishspeed > pm->ps->speed * pm_swimScale ) {
+ if( wishspeed > pm->ps->speed * pm_swimScale )
wishspeed = pm->ps->speed * pm_swimScale;
- }
- PM_Accelerate (wishdir, wishspeed, pm_wateraccelerate);
+ PM_Accelerate( wishdir, wishspeed, pm_wateraccelerate );
// make sure we can go up slopes easily under water
- if ( pml.groundPlane && DotProduct( pm->ps->velocity, pml.groundTrace.plane.normal ) < 0 ) {
- vel = VectorLength(pm->ps->velocity);
+ if( pml.groundPlane && DotProduct( pm->ps->velocity, pml.groundTrace.plane.normal ) < 0 )
+ {
+ vel = VectorLength( pm->ps->velocity );
// slide along the ground plane
- PM_ClipVelocity (pm->ps->velocity, pml.groundTrace.plane.normal,
+ PM_ClipVelocity( pm->ps->velocity, pml.groundTrace.plane.normal,
pm->ps->velocity, OVERCLIP );
- VectorNormalize(pm->ps->velocity);
- VectorScale(pm->ps->velocity, vel, pm->ps->velocity);
+ VectorNormalize( pm->ps->velocity );
+ VectorScale( pm->ps->velocity, vel, pm->ps->velocity );
}
PM_SlideMove( qfalse );
@@ -661,7 +679,8 @@ PM_JetPackMove
Only with the jetpack
===================
*/
-static void PM_JetPackMove( void ) {
+static void PM_JetPackMove( void )
+{
int i;
vec3_t wishvel;
float wishspeed;
@@ -702,36 +721,39 @@ PM_FlyMove
Only with the flight powerup
===================
*/
-static void PM_FlyMove( void ) {
- int i;
+static void PM_FlyMove( void )
+{
+ int i;
vec3_t wishvel;
- float wishspeed;
+ float wishspeed;
vec3_t wishdir;
- float scale;
+ float scale;
// normal slowdown
- PM_Friction ();
+ PM_Friction( );
scale = PM_CmdScale( &pm->cmd );
//
// user intentions
//
- if ( !scale ) {
- wishvel[0] = 0;
- wishvel[1] = 0;
- wishvel[2] = 0;
- } else {
- for (i=0 ; i<3 ; i++) {
- wishvel[i] = scale * pml.forward[i]*pm->cmd.forwardmove + scale * pml.right[i]*pm->cmd.rightmove;
- }
+ if( !scale )
+ {
+ wishvel[ 0 ] = 0;
+ wishvel[ 1 ] = 0;
+ wishvel[ 2 ] = 0;
+ }
+ else
+ {
+ for( i = 0; i < 3; i++ )
+ wishvel[ i ] = scale * pml.forward[ i ] * pm->cmd.forwardmove + scale * pml.right[ i ] * pm->cmd.rightmove;
- wishvel[2] += scale * pm->cmd.upmove;
+ wishvel[ 2 ] += scale * pm->cmd.upmove;
}
- VectorCopy (wishvel, wishdir);
- wishspeed = VectorNormalize(wishdir);
+ VectorCopy( wishvel, wishdir );
+ wishspeed = VectorNormalize( wishdir );
- PM_Accelerate (wishdir, wishspeed, pm_flyaccelerate);
+ PM_Accelerate( wishdir, wishspeed, pm_flyaccelerate );
PM_StepSlideMove( qfalse, qfalse );
}
@@ -743,16 +765,17 @@ PM_AirMove
===================
*/
-static void PM_AirMove( void ) {
- int i;
+static void PM_AirMove( void )
+{
+ int i;
vec3_t wishvel;
- float fmove, smove;
+ float fmove, smove;
vec3_t wishdir;
- float wishspeed;
- float scale;
+ float wishspeed;
+ float scale;
usercmd_t cmd;
- PM_Friction();
+ PM_Friction( );
fmove = pm->cmd.forwardmove;
smove = pm->cmd.rightmove;
@@ -761,33 +784,32 @@ static void PM_AirMove( void ) {
scale = PM_CmdScale( &cmd );
// set the movementDir so clients can rotate the legs for strafing
- PM_SetMovementDir();
+ PM_SetMovementDir( );
// project moves down to flat plane
- pml.forward[2] = 0;
- pml.right[2] = 0;
- VectorNormalize (pml.forward);
- VectorNormalize (pml.right);
+ pml.forward[ 2 ] = 0;
+ pml.right[ 2 ] = 0;
+ VectorNormalize( pml.forward );
+ VectorNormalize( pml.right );
- for ( i = 0 ; i < 2 ; i++ ) {
- wishvel[i] = pml.forward[i]*fmove + pml.right[i]*smove;
- }
- wishvel[2] = 0;
+ for( i = 0; i < 2; i++ )
+ wishvel[ i ] = pml.forward[ i ] * fmove + pml.right[ i ] * smove;
- VectorCopy (wishvel, wishdir);
- wishspeed = VectorNormalize(wishdir);
+ wishvel[ 2 ] = 0;
+
+ VectorCopy( wishvel, wishdir );
+ wishspeed = VectorNormalize( wishdir );
wishspeed *= scale;
// not on ground, so little effect on velocity
- PM_Accelerate (wishdir, wishspeed, pm_airaccelerate);
+ PM_Accelerate( wishdir, wishspeed, pm_airaccelerate );
// we may have a ground plane that is very steep, even
// though we don't have a groundentity
// slide along the steep plane
- if ( pml.groundPlane ) {
- PM_ClipVelocity (pm->ps->velocity, pml.groundTrace.plane.normal,
+ if( pml.groundPlane )
+ PM_ClipVelocity( pm->ps->velocity, pml.groundTrace.plane.normal,
pm->ps->velocity, OVERCLIP );
- }
#if 0
//ZOID: If we are on the grapple, try stair-stepping
@@ -799,7 +821,7 @@ static void PM_AirMove( void ) {
PM_SlideMove ( qtrue );
#endif
- PM_StepSlideMove ( qtrue, qfalse );
+ PM_StepSlideMove( qtrue, qfalse );
}
/*
@@ -808,22 +830,23 @@ PM_GrappleMove
===================
*/
-static void PM_GrappleMove( void ) {
- vec3_t vel, v;
- float vlen;
-
- VectorScale(pml.forward, -16, v);
- VectorAdd(pm->ps->grapplePoint, v, v);
- VectorSubtract(v, pm->ps->origin, vel);
- vlen = VectorLength(vel);
+static void PM_GrappleMove( void )
+{
+ vec3_t vel, v;
+ float vlen;
+
+ VectorScale( pml.forward, -16, v );
+ VectorAdd( pm->ps->grapplePoint, v, v );
+ VectorSubtract( v, pm->ps->origin, vel );
+ vlen = VectorLength( vel );
VectorNormalize( vel );
- if (vlen <= 100)
- VectorScale(vel, 10 * vlen, vel);
+ if( vlen <= 100 )
+ VectorScale( vel, 10 * vlen, vel );
else
- VectorScale(vel, 800, vel);
+ VectorScale( vel, 800, vel );
- VectorCopy(vel, pm->ps->velocity);
+ VectorCopy( vel, pm->ps->velocity );
pml.groundPlane = qfalse;
}
@@ -835,35 +858,38 @@ PM_ClimbMove
===================
*/
-static void PM_ClimbMove( void ) {
- int i;
+static void PM_ClimbMove( void )
+{
+ int i;
vec3_t wishvel;
- float fmove, smove;
+ float fmove, smove;
vec3_t wishdir;
- float wishspeed;
- float scale;
+ float wishspeed;
+ float scale;
usercmd_t cmd;
- float accelerate;
- float vel;
+ float accelerate;
+ float vel;
- if ( pm->waterlevel > 2 && DotProduct( pml.forward, pml.groundTrace.plane.normal ) > 0 ) {
+ if( pm->waterlevel > 2 && DotProduct( pml.forward, pml.groundTrace.plane.normal ) > 0 )
+ {
// begin swimming
- PM_WaterMove();
+ PM_WaterMove( );
return;
}
- if ( PM_CheckJump( ) || PM_CheckPounce( ) ) {
+ if( PM_CheckJump( ) || PM_CheckPounce( ) )
+ {
// jumped away
- if ( pm->waterlevel > 1 ) {
- PM_WaterMove();
- } else {
- PM_AirMove();
- }
+ if( pm->waterlevel > 1 )
+ PM_WaterMove( );
+ else
+ PM_AirMove( );
+
return;
}
- PM_Friction ();
+ PM_Friction( );
fmove = pm->cmd.forwardmove;
smove = pm->cmd.rightmove;
@@ -872,71 +898,68 @@ static void PM_ClimbMove( void ) {
scale = PM_CmdScale( &cmd );
// set the movementDir so clients can rotate the legs for strafing
- PM_SetMovementDir();
+ PM_SetMovementDir( );
// project the forward and right directions onto the ground plane
- PM_ClipVelocity (pml.forward, pml.groundTrace.plane.normal, pml.forward, OVERCLIP );
- PM_ClipVelocity (pml.right, pml.groundTrace.plane.normal, pml.right, OVERCLIP );
+ PM_ClipVelocity( pml.forward, pml.groundTrace.plane.normal, pml.forward, OVERCLIP );
+ PM_ClipVelocity( pml.right, pml.groundTrace.plane.normal, pml.right, OVERCLIP );
//
- VectorNormalize (pml.forward);
- VectorNormalize (pml.right);
+ VectorNormalize( pml.forward );
+ VectorNormalize( pml.right );
+
+ for( i = 0; i < 3; i++ )
+ wishvel[ i ] = pml.forward[ i ] * fmove + pml.right[ i ] * smove;
- for ( i = 0 ; i < 3 ; i++ ) {
- wishvel[i] = pml.forward[i]*fmove + pml.right[i]*smove;
- }
// when going up or down slopes the wish velocity should Not be zero
// wishvel[2] = 0;
- VectorCopy (wishvel, wishdir);
- wishspeed = VectorNormalize(wishdir);
+ VectorCopy( wishvel, wishdir );
+ wishspeed = VectorNormalize( wishdir );
wishspeed *= scale;
// clamp the speed lower if ducking
- if ( pm->ps->pm_flags & PMF_DUCKED ) {
- if ( wishspeed > pm->ps->speed * pm_duckScale ) {
+ if( pm->ps->pm_flags & PMF_DUCKED )
+ {
+ if( wishspeed > pm->ps->speed * pm_duckScale )
wishspeed = pm->ps->speed * pm_duckScale;
- }
}
// clamp the speed lower if wading or walking on the bottom
- if ( pm->waterlevel ) {
+ if( pm->waterlevel )
+ {
float waterScale;
waterScale = pm->waterlevel / 3.0;
waterScale = 1.0 - ( 1.0 - pm_swimScale ) * waterScale;
- if ( wishspeed > pm->ps->speed * waterScale ) {
+ if( wishspeed > pm->ps->speed * waterScale )
wishspeed = pm->ps->speed * waterScale;
- }
}
// when a player gets hit, they temporarily lose
// full control, which allows them to be moved a bit
- if ( ( pml.groundTrace.surfaceFlags & SURF_SLICK ) || pm->ps->pm_flags & PMF_TIME_KNOCKBACK ) {
+ if( ( pml.groundTrace.surfaceFlags & SURF_SLICK ) || pm->ps->pm_flags & PMF_TIME_KNOCKBACK )
accelerate = pm_airaccelerate;
- } else {
+ else
accelerate = pm_accelerate;
- }
- PM_Accelerate (wishdir, wishspeed, accelerate);
+ PM_Accelerate( wishdir, wishspeed, accelerate );
- if ( ( pml.groundTrace.surfaceFlags & SURF_SLICK ) || pm->ps->pm_flags & PMF_TIME_KNOCKBACK ) {
- pm->ps->velocity[2] -= pm->ps->gravity * pml.frametime;
- }
+ if( ( pml.groundTrace.surfaceFlags & SURF_SLICK ) || pm->ps->pm_flags & PMF_TIME_KNOCKBACK )
+ pm->ps->velocity[ 2 ] -= pm->ps->gravity * pml.frametime;
- vel = VectorLength(pm->ps->velocity);
+ vel = VectorLength( pm->ps->velocity );
// slide along the ground plane
- PM_ClipVelocity (pm->ps->velocity, pml.groundTrace.plane.normal,
+ PM_ClipVelocity( pm->ps->velocity, pml.groundTrace.plane.normal,
pm->ps->velocity, OVERCLIP );
// don't decrease velocity when going up or down a slope
- VectorNormalize(pm->ps->velocity);
- VectorScale(pm->ps->velocity, vel, pm->ps->velocity);
+ VectorNormalize( pm->ps->velocity );
+ VectorScale( pm->ps->velocity, vel, pm->ps->velocity );
// don't do anything if standing still
- if (!pm->ps->velocity[0] && !pm->ps->velocity[1] && !pm->ps->velocity[2]) {
+ if( !pm->ps->velocity[ 0 ] && !pm->ps->velocity[ 1 ] && !pm->ps->velocity[ 2 ] )
return;
- }
PM_StepSlideMove( qfalse, qfalse );
}
@@ -948,35 +971,38 @@ PM_WalkMove
===================
*/
-static void PM_WalkMove( void ) {
- int i;
+static void PM_WalkMove( void )
+{
+ int i;
vec3_t wishvel;
- float fmove, smove;
+ float fmove, smove;
vec3_t wishdir;
- float wishspeed;
- float scale;
+ float wishspeed;
+ float scale;
usercmd_t cmd;
- float accelerate;
- float vel;
+ float accelerate;
+ float vel;
- if ( pm->waterlevel > 2 && DotProduct( pml.forward, pml.groundTrace.plane.normal ) > 0 ) {
+ if( pm->waterlevel > 2 && DotProduct( pml.forward, pml.groundTrace.plane.normal ) > 0 )
+ {
// begin swimming
- PM_WaterMove();
+ PM_WaterMove( );
return;
}
- if( PM_CheckJump( ) || PM_CheckPounce( ) ) {
+ if( PM_CheckJump( ) || PM_CheckPounce( ) )
+ {
// jumped away
- if ( pm->waterlevel > 1 ) {
- PM_WaterMove();
- } else {
- PM_AirMove();
- }
+ if( pm->waterlevel > 1 )
+ PM_WaterMove( );
+ else
+ PM_AirMove( );
+
return;
}
- PM_Friction ();
+ PM_Friction( );
fmove = pm->cmd.forwardmove;
smove = pm->cmd.rightmove;
@@ -985,81 +1011,80 @@ static void PM_WalkMove( void ) {
scale = PM_CmdScale( &cmd );
// set the movementDir so clients can rotate the legs for strafing
- PM_SetMovementDir();
+ PM_SetMovementDir( );
// project moves down to flat plane
- pml.forward[2] = 0;
- pml.right[2] = 0;
+ pml.forward[ 2 ] = 0;
+ pml.right[ 2 ] = 0;
// project the forward and right directions onto the ground plane
- PM_ClipVelocity (pml.forward, pml.groundTrace.plane.normal, pml.forward, OVERCLIP );
- PM_ClipVelocity (pml.right, pml.groundTrace.plane.normal, pml.right, OVERCLIP );
+ PM_ClipVelocity( pml.forward, pml.groundTrace.plane.normal, pml.forward, OVERCLIP );
+ PM_ClipVelocity( pml.right, pml.groundTrace.plane.normal, pml.right, OVERCLIP );
//
- VectorNormalize (pml.forward);
- VectorNormalize (pml.right);
+ VectorNormalize( pml.forward );
+ VectorNormalize( pml.right );
+
+ for( i = 0; i < 3; i++ )
+ wishvel[ i ] = pml.forward[ i ] * fmove + pml.right[ i ] * smove;
- for ( i = 0 ; i < 3 ; i++ ) {
- wishvel[i] = pml.forward[i]*fmove + pml.right[i]*smove;
- }
// when going up or down slopes the wish velocity should Not be zero
// wishvel[2] = 0;
- VectorCopy (wishvel, wishdir);
- wishspeed = VectorNormalize(wishdir);
+ VectorCopy( wishvel, wishdir );
+ wishspeed = VectorNormalize( wishdir );
wishspeed *= scale;
// clamp the speed lower if ducking
- if ( pm->ps->pm_flags & PMF_DUCKED ) {
- if ( wishspeed > pm->ps->speed * pm_duckScale ) {
+ if( pm->ps->pm_flags & PMF_DUCKED )
+ {
+ if( wishspeed > pm->ps->speed * pm_duckScale )
wishspeed = pm->ps->speed * pm_duckScale;
- }
}
// clamp the speed lower if wading or walking on the bottom
- if ( pm->waterlevel ) {
+ if( pm->waterlevel )
+ {
float waterScale;
waterScale = pm->waterlevel / 3.0;
waterScale = 1.0 - ( 1.0 - pm_swimScale ) * waterScale;
- if ( wishspeed > pm->ps->speed * waterScale ) {
+ if( wishspeed > pm->ps->speed * waterScale )
wishspeed = pm->ps->speed * waterScale;
- }
}
// when a player gets hit, they temporarily lose
// full control, which allows them to be moved a bit
- if ( ( pml.groundTrace.surfaceFlags & SURF_SLICK ) || pm->ps->pm_flags & PMF_TIME_KNOCKBACK ) {
+ if( ( pml.groundTrace.surfaceFlags & SURF_SLICK ) || pm->ps->pm_flags & PMF_TIME_KNOCKBACK )
accelerate = pm_airaccelerate;
- } else {
+ else
accelerate = pm_accelerate;
- }
- PM_Accelerate (wishdir, wishspeed, accelerate);
+ PM_Accelerate( wishdir, wishspeed, accelerate );
//Com_Printf("velocity = %1.1f %1.1f %1.1f\n", pm->ps->velocity[0], pm->ps->velocity[1], pm->ps->velocity[2]);
//Com_Printf("velocity1 = %1.1f\n", VectorLength(pm->ps->velocity));
- if ( ( pml.groundTrace.surfaceFlags & SURF_SLICK ) || pm->ps->pm_flags & PMF_TIME_KNOCKBACK ) {
- pm->ps->velocity[2] -= pm->ps->gravity * pml.frametime;
- } else {
+ if( ( pml.groundTrace.surfaceFlags & SURF_SLICK ) || pm->ps->pm_flags & PMF_TIME_KNOCKBACK )
+ pm->ps->velocity[ 2 ] -= pm->ps->gravity * pml.frametime;
+ else
+ {
// don't reset the z velocity for slopes
// pm->ps->velocity[2] = 0;
}
- vel = VectorLength(pm->ps->velocity);
+ vel = VectorLength( pm->ps->velocity );
// slide along the ground plane
- PM_ClipVelocity (pm->ps->velocity, pml.groundTrace.plane.normal,
+ PM_ClipVelocity( pm->ps->velocity, pml.groundTrace.plane.normal,
pm->ps->velocity, OVERCLIP );
// don't decrease velocity when going up or down a slope
- VectorNormalize(pm->ps->velocity);
- VectorScale(pm->ps->velocity, vel, pm->ps->velocity);
+ VectorNormalize( pm->ps->velocity );
+ VectorScale( pm->ps->velocity, vel, pm->ps->velocity );
// don't do anything if standing still
- if (!pm->ps->velocity[0] && !pm->ps->velocity[1]) {
+ if( !pm->ps->velocity[ 0 ] && !pm->ps->velocity[ 1 ] )
return;
- }
PM_StepSlideMove( qfalse, qfalse );
@@ -1073,22 +1098,24 @@ static void PM_WalkMove( void ) {
PM_DeadMove
==============
*/
-static void PM_DeadMove( void ) {
+static void PM_DeadMove( void )
+{
float forward;
- if ( !pml.walking ) {
+ if( !pml.walking )
return;
- }
// extra friction
- forward = VectorLength (pm->ps->velocity);
+ forward = VectorLength( pm->ps->velocity );
forward -= 20;
- if ( forward <= 0 ) {
- VectorClear (pm->ps->velocity);
- } else {
- VectorNormalize (pm->ps->velocity);
- VectorScale (pm->ps->velocity, forward, pm->ps->velocity);
+
+ if( forward <= 0 )
+ VectorClear( pm->ps->velocity );
+ else
+ {
+ VectorNormalize( pm->ps->velocity );
+ VectorScale( pm->ps->velocity, forward, pm->ps->velocity );
}
}
@@ -1098,12 +1125,13 @@ static void PM_DeadMove( void ) {
PM_NoclipMove
===============
*/
-static void PM_NoclipMove( void ) {
- float speed, drop, friction, control, newspeed;
+static void PM_NoclipMove( void )
+{
+ float speed, drop, friction, control, newspeed;
int i;
- vec3_t wishvel;
+ vec3_t wishvel;
float fmove, smove;
- vec3_t wishdir;
+ vec3_t wishdir;
float wishspeed;
float scale;
@@ -1111,26 +1139,29 @@ static void PM_NoclipMove( void ) {
// friction
- speed = VectorLength (pm->ps->velocity);
- if (speed < 1)
+ speed = VectorLength( pm->ps->velocity );
+
+ if( speed < 1 )
{
- VectorCopy (vec3_origin, pm->ps->velocity);
+ VectorCopy( vec3_origin, pm->ps->velocity );
}
else
{
drop = 0;
- friction = pm_friction*1.5; // extra friction
+ friction = pm_friction * 1.5; // extra friction
control = speed < pm_stopspeed ? pm_stopspeed : speed;
- drop += control*friction*pml.frametime;
+ drop += control * friction * pml.frametime;
// scale the velocity
newspeed = speed - drop;
- if (newspeed < 0)
+
+ if( newspeed < 0 )
newspeed = 0;
+
newspeed /= speed;
- VectorScale (pm->ps->velocity, newspeed, pm->ps->velocity);
+ VectorScale( pm->ps->velocity, newspeed, pm->ps->velocity );
}
// accelerate
@@ -1139,18 +1170,19 @@ static void PM_NoclipMove( void ) {
fmove = pm->cmd.forwardmove;
smove = pm->cmd.rightmove;
- for (i=0 ; i<3 ; i++)
- wishvel[i] = pml.forward[i]*fmove + pml.right[i]*smove;
- wishvel[2] += pm->cmd.upmove;
+ for( i = 0; i < 3; i++ )
+ wishvel[ i ] = pml.forward[ i ] * fmove + pml.right[ i ] * smove;
+
+ wishvel[ 2 ] += pm->cmd.upmove;
- VectorCopy (wishvel, wishdir);
- wishspeed = VectorNormalize(wishdir);
+ VectorCopy( wishvel, wishdir );
+ wishspeed = VectorNormalize( wishdir );
wishspeed *= scale;
PM_Accelerate( wishdir, wishspeed, pm_accelerate );
// move
- VectorMA (pm->ps->origin, pml.frametime, pm->ps->velocity, pm->ps->origin);
+ VectorMA( pm->ps->origin, pml.frametime, pm->ps->velocity, pm->ps->origin );
}
//============================================================================
@@ -1185,7 +1217,8 @@ PM_CrashLand
Check for hard landings that generate sound events
=================
*/
-static void PM_CrashLand( void ) {
+static void PM_CrashLand( void )
+{
float delta;
float dist;
float vel, acc;
@@ -1193,17 +1226,16 @@ static void PM_CrashLand( void ) {
float a, b, c, den;
// decide which landing animation to use
- if ( pm->ps->pm_flags & PMF_BACKWARDS_JUMP ) {
+ if( pm->ps->pm_flags & PMF_BACKWARDS_JUMP )
PM_ForceLegsAnim( LEGS_LANDB );
- } else {
+ else
PM_ForceLegsAnim( LEGS_LAND );
- }
pm->ps->legsTimer = TIMER_LAND;
// calculate the exact velocity on landing
- dist = pm->ps->origin[2] - pml.previous_origin[2];
- vel = pml.previous_velocity[2];
+ dist = pm->ps->origin[ 2 ] - pml.previous_origin[ 2 ];
+ vel = pml.previous_velocity[ 2 ];
acc = -pm->ps->gravity;
a = acc / 2;
@@ -1211,53 +1243,52 @@ static void PM_CrashLand( void ) {
c = -dist;
den = b * b - 4 * a * c;
- if ( den < 0 ) {
+ if( den < 0 )
return;
- }
+
t = (-b - sqrt( den ) ) / ( 2 * a );
delta = vel + t * acc;
delta = delta*delta * 0.0001;
// ducking while falling doubles damage
- if ( pm->ps->pm_flags & PMF_DUCKED ) {
+ if( pm->ps->pm_flags & PMF_DUCKED )
delta *= 2;
- }
// never take falling damage if completely underwater
- if ( pm->waterlevel == 3 ) {
+ if( pm->waterlevel == 3 )
return;
- }
// reduce falling damage if there is standing water
- if ( pm->waterlevel == 2 ) {
+ if( pm->waterlevel == 2 )
delta *= 0.25;
- }
- if ( pm->waterlevel == 1 ) {
+
+ if( pm->waterlevel == 1 )
delta *= 0.5;
- }
- if ( delta < 1 ) {
+ if( delta < 1 )
return;
- }
// create a local entity event to play the sound
// SURF_NODAMAGE is used for bounce pads where you don't ever
// want to take damage or play a crunch sound
- if ( !(pml.groundTrace.surfaceFlags & SURF_NODAMAGE) ) {
- if ( delta > 60 ) {
+ if( !( pml.groundTrace.surfaceFlags & SURF_NODAMAGE ) )
+ {
+ if( delta > 60 )
+ {
PM_AddEvent( EV_FALL_FAR );
- } else if ( delta > 40 ) {
+ }
+ else if( delta > 40 )
+ {
// this is a pain grunt, so don't play it if dead
- if ( pm->ps->stats[STAT_HEALTH] > 0 ) {
+ if( pm->ps->stats[STAT_HEALTH] > 0 )
PM_AddEvent( EV_FALL_MEDIUM );
- }
- } else if ( delta > 7 ) {
- PM_AddEvent( EV_FALL_SHORT );
- } else {
- PM_AddEvent( PM_FootstepForSurface() );
}
+ else if( delta > 7 )
+ PM_AddEvent( EV_FALL_SHORT );
+ else
+ PM_AddEvent( PM_FootstepForSurface( ) );
}
// start footstep cycle over
@@ -1270,29 +1301,34 @@ static void PM_CrashLand( void ) {
PM_CorrectAllSolid
=============
*/
-static int PM_CorrectAllSolid( trace_t *trace ) {
- int i, j, k;
+static int PM_CorrectAllSolid( trace_t *trace )
+{
+ int i, j, k;
vec3_t point;
- if ( pm->debugLevel ) {
+ if( pm->debugLevel )
Com_Printf("%i:allsolid\n", c_pmove);
- }
// jitter around
- for (i = -1; i <= 1; i++) {
- for (j = -1; j <= 1; j++) {
- for (k = -1; k <= 1; k++) {
- VectorCopy(pm->ps->origin, point);
- point[0] += (float) i;
- point[1] += (float) j;
- point[2] += (float) k;
- pm->trace (trace, point, pm->mins, pm->maxs, point, pm->ps->clientNum, pm->tracemask);
- if ( !trace->allsolid ) {
- point[0] = pm->ps->origin[0];
- point[1] = pm->ps->origin[1];
- point[2] = pm->ps->origin[2] - 0.25;
-
- pm->trace (trace, pm->ps->origin, pm->mins, pm->maxs, point, pm->ps->clientNum, pm->tracemask);
+ for( i = -1; i <= 1; i++ )
+ {
+ for( j = -1; j <= 1; j++ )
+ {
+ for( k = -1; k <= 1; k++ )
+ {
+ VectorCopy( pm->ps->origin, point );
+ point[ 0 ] += (float)i;
+ point[ 1 ] += (float)j;
+ point[ 2 ] += (float)k;
+ pm->trace( trace, point, pm->mins, pm->maxs, point, pm->ps->clientNum, pm->tracemask );
+
+ if( !trace->allsolid )
+ {
+ point[ 0 ] = pm->ps->origin[ 0 ];
+ point[ 1 ] = pm->ps->origin[ 1 ];
+ point[ 2 ] = pm->ps->origin[ 2 ] - 0.25;
+
+ pm->trace( trace, pm->ps->origin, pm->mins, pm->maxs, point, pm->ps->clientNum, pm->tracemask );
pml.groundTrace = *trace;
return qtrue;
}
@@ -1315,27 +1351,32 @@ PM_GroundTraceMissed
The ground trace didn't hit a surface, so we are in freefall
=============
*/
-static void PM_GroundTraceMissed( void ) {
+static void PM_GroundTraceMissed( void )
+{
trace_t trace;
vec3_t point;
- if ( pm->ps->groundEntityNum != ENTITYNUM_NONE ) {
+ if( pm->ps->groundEntityNum != ENTITYNUM_NONE )
+ {
// we just transitioned into freefall
- if ( pm->debugLevel ) {
- Com_Printf("%i:lift\n", c_pmove);
- }
+ if( pm->debugLevel )
+ Com_Printf( "%i:lift\n", c_pmove );
// if they aren't in a jumping animation and the ground is a ways away, force into it
// if we didn't do the trace, the player would be backflipping down staircases
VectorCopy( pm->ps->origin, point );
- point[2] -= 64;
+ point[ 2 ] -= 64;
- pm->trace (&trace, pm->ps->origin, pm->mins, pm->maxs, point, pm->ps->clientNum, pm->tracemask);
- if ( trace.fraction == 1.0 ) {
- if ( pm->cmd.forwardmove >= 0 ) {
+ pm->trace( &trace, pm->ps->origin, pm->mins, pm->maxs, point, pm->ps->clientNum, pm->tracemask );
+ if( trace.fraction == 1.0 )
+ {
+ if( pm->cmd.forwardmove >= 0 )
+ {
PM_ForceLegsAnim( LEGS_JUMP );
pm->ps->pm_flags &= ~PMF_BACKWARDS_JUMP;
- } else {
+ }
+ else
+ {
PM_ForceLegsAnim( LEGS_JUMPB );
pm->ps->pm_flags |= PMF_BACKWARDS_JUMP;
}
@@ -1639,7 +1680,8 @@ static void PM_GroundClimbTrace( void )
PM_GroundTrace
=============
*/
-static void PM_GroundTrace( void ) {
+static void PM_GroundTrace( void )
+{
vec3_t point, forward, srotAxis;
vec3_t refNormal = { 0.0f, 0.0f, 1.0f };
trace_t trace;
@@ -1678,26 +1720,27 @@ static void PM_GroundTrace( void ) {
if( BG_ClassHasAbility( pm->ps->stats[ STAT_PCLASS ], SCA_WALLCLIMBER ) )
VectorCopy( refNormal, pm->ps->grapplePoint );
- point[0] = pm->ps->origin[0];
- point[1] = pm->ps->origin[1];
- point[2] = pm->ps->origin[2] - 0.25;
+ point[ 0 ] = pm->ps->origin[ 0 ];
+ point[ 1 ] = pm->ps->origin[ 1 ];
+ point[ 2 ] = pm->ps->origin[ 2 ] - 0.25;
//FIXME: hack until i find out where CONTENTS_BODY is getting unset for uhm.. bodies.
if( pm->ps->pm_type == PM_DEAD )
- pm->trace (&trace, pm->ps->origin, pm->mins, pm->maxs, point, pm->ps->clientNum, MASK_PLAYERSOLID );
+ pm->trace( &trace, pm->ps->origin, pm->mins, pm->maxs, point, pm->ps->clientNum, MASK_PLAYERSOLID );
else
- pm->trace (&trace, pm->ps->origin, pm->mins, pm->maxs, point, pm->ps->clientNum, pm->tracemask);
+ pm->trace( &trace, pm->ps->origin, pm->mins, pm->maxs, point, pm->ps->clientNum, pm->tracemask );
+
pml.groundTrace = trace;
// do something corrective if the trace starts in a solid...
if( trace.allsolid )
- if( !PM_CorrectAllSolid(&trace) )
+ if( !PM_CorrectAllSolid( &trace ) )
return;
// if the trace didn't hit anything, we are in free fall
if( trace.fraction == 1.0 )
{
- PM_GroundTraceMissed();
+ PM_GroundTraceMissed( );
pml.groundPlane = qfalse;
pml.walking = qfalse;
@@ -1705,15 +1748,19 @@ static void PM_GroundTrace( void ) {
}
// check if getting thrown off the ground
- if ( pm->ps->velocity[2] > 0 && DotProduct( pm->ps->velocity, trace.plane.normal ) > 10 ) {
- if ( pm->debugLevel ) {
- Com_Printf("%i:kickoff\n", c_pmove);
- }
+ if( pm->ps->velocity[ 2 ] > 0 && DotProduct( pm->ps->velocity, trace.plane.normal ) > 10 )
+ {
+ if( pm->debugLevel )
+ Com_Printf( "%i:kickoff\n", c_pmove );
+
// go into jump animation
- if ( pm->cmd.forwardmove >= 0 ) {
+ if( pm->cmd.forwardmove >= 0 )
+ {
PM_ForceLegsAnim( LEGS_JUMP );
pm->ps->pm_flags &= ~PMF_BACKWARDS_JUMP;
- } else {
+ }
+ else
+ {
PM_ForceLegsAnim( LEGS_JUMPB );
pm->ps->pm_flags |= PMF_BACKWARDS_JUMP;
}
@@ -1725,10 +1772,11 @@ static void PM_GroundTrace( void ) {
}
// slopes that are too steep will not be considered onground
- if ( trace.plane.normal[2] < MIN_WALK_NORMAL ) {
- if ( pm->debugLevel ) {
- Com_Printf("%i:steep\n", c_pmove);
- }
+ if( trace.plane.normal[ 2 ] < MIN_WALK_NORMAL )
+ {
+ if( pm->debugLevel )
+ Com_Printf( "%i:steep\n", c_pmove );
+
// FIXME: if they can't slide down the slope, let them
// walk (sharp crevices)
pm->ps->groundEntityNum = ENTITYNUM_NONE;
@@ -1741,23 +1789,24 @@ static void PM_GroundTrace( void ) {
pml.walking = qtrue;
// hitting solid ground will end a waterjump
- if (pm->ps->pm_flags & PMF_TIME_WATERJUMP)
+ if( pm->ps->pm_flags & PMF_TIME_WATERJUMP )
{
- pm->ps->pm_flags &= ~(PMF_TIME_WATERJUMP | PMF_TIME_LAND);
+ pm->ps->pm_flags &= ~( PMF_TIME_WATERJUMP | PMF_TIME_LAND );
pm->ps->pm_time = 0;
}
- if ( pm->ps->groundEntityNum == ENTITYNUM_NONE ) {
+ if( pm->ps->groundEntityNum == ENTITYNUM_NONE )
+ {
// just hit the ground
- if ( pm->debugLevel ) {
- Com_Printf("%i:Land\n", c_pmove);
- }
+ if( pm->debugLevel )
+ Com_Printf( "%i:Land\n", c_pmove );
if( BG_ClassHasAbility( pm->ps->stats[ STAT_PCLASS ], SCA_TAKESFALLDAMAGE ) )
- PM_CrashLand();
+ PM_CrashLand( );
// don't do landing time if we were just going down a slope
- if ( pml.previous_velocity[2] < -200 ) {
+ if( pml.previous_velocity[ 2 ] < -200 )
+ {
// don't allow another jump for a little while
pm->ps->pm_flags |= PMF_TIME_LAND;
pm->ps->pm_time = 250;
@@ -1778,8 +1827,9 @@ static void PM_GroundTrace( void ) {
PM_SetWaterLevel FIXME: avoid this twice? certainly if not moving
=============
*/
-static void PM_SetWaterLevel( void ) {
- vec3_t point;
+static void PM_SetWaterLevel( void )
+{
+ vec3_t point;
int cont;
int sample1;
int sample2;
@@ -1790,29 +1840,31 @@ static void PM_SetWaterLevel( void ) {
pm->waterlevel = 0;
pm->watertype = 0;
- point[0] = pm->ps->origin[0];
- point[1] = pm->ps->origin[1];
- point[2] = pm->ps->origin[2] + MINS_Z + 1;
+ point[ 0 ] = pm->ps->origin[ 0 ];
+ point[ 1 ] = pm->ps->origin[ 1 ];
+ point[ 2 ] = pm->ps->origin[ 2 ] + MINS_Z + 1;
cont = pm->pointcontents( point, pm->ps->clientNum );
- if ( cont & MASK_WATER ) {
+ if( cont & MASK_WATER )
+ {
sample2 = pm->ps->viewheight - MINS_Z;
sample1 = sample2 / 2;
pm->watertype = cont;
pm->waterlevel = 1;
- point[2] = pm->ps->origin[2] + MINS_Z + sample1;
- cont = pm->pointcontents (point, pm->ps->clientNum );
- if ( cont & MASK_WATER ) {
+ point[ 2 ] = pm->ps->origin[ 2 ] + MINS_Z + sample1;
+ cont = pm->pointcontents( point, pm->ps->clientNum );
+
+ if( cont & MASK_WATER )
+ {
pm->waterlevel = 2;
- point[2] = pm->ps->origin[2] + MINS_Z + sample2;
- cont = pm->pointcontents (point, pm->ps->clientNum );
- if ( cont & MASK_WATER ){
+ point[ 2 ] = pm->ps->origin[ 2 ] + MINS_Z + sample2;
+ cont = pm->pointcontents( point, pm->ps->clientNum );
+
+ if( cont & MASK_WATER )
pm->waterlevel = 3;
- }
}
}
-
}
@@ -1837,13 +1889,13 @@ static void PM_CheckDuck (void)
if( pm->ps->persistant[ PERS_TEAM ] == TEAM_SPECTATOR )
PCcvh = PCvh;
- pm->mins[0] = PCmins[0];
- pm->mins[1] = PCmins[1];
+ pm->mins[ 0 ] = PCmins[ 0 ];
+ pm->mins[ 1 ] = PCmins[ 1 ];
- pm->maxs[0] = PCmaxs[0];
- pm->maxs[1] = PCmaxs[1];
+ pm->maxs[ 0 ] = PCmaxs[ 0 ];
+ pm->maxs[ 1 ] = PCmaxs[ 1 ];
- pm->mins[2] = PCmins[2];
+ pm->mins[ 2 ] = PCmins[ 2 ];
if (pm->ps->pm_type == PM_DEAD)
{
@@ -1863,21 +1915,21 @@ static void PM_CheckDuck (void)
if (pm->ps->pm_flags & PMF_DUCKED)
{
// try to stand up
- pm->maxs[2] = PCmaxs[2];
- pm->trace (&trace, pm->ps->origin, pm->mins, pm->maxs, pm->ps->origin, pm->ps->clientNum, pm->tracemask );
- if (!trace.allsolid)
+ pm->maxs[ 2 ] = PCmaxs[ 2 ];
+ pm->trace( &trace, pm->ps->origin, pm->mins, pm->maxs, pm->ps->origin, pm->ps->clientNum, pm->tracemask );
+ if( !trace.allsolid )
pm->ps->pm_flags &= ~PMF_DUCKED;
}
}
- if (pm->ps->pm_flags & PMF_DUCKED)
+ if( pm->ps->pm_flags & PMF_DUCKED )
{
- pm->maxs[2] = PCcmaxs[2];
+ pm->maxs[ 2 ] = PCcmaxs[ 2 ];
pm->ps->viewheight = PCcvh;
}
else
{
- pm->maxs[2] = PCmaxs[2];
+ pm->maxs[ 2 ] = PCmaxs[ 2 ];
pm->ps->viewheight = PCvh;
}
}
@@ -1892,9 +1944,10 @@ static void PM_CheckDuck (void)
PM_Footsteps
===============
*/
-static void PM_Footsteps( void ) {
- float bobmove;
- int old;
+static void PM_Footsteps( void )
+{
+ float bobmove;
+ int old;
qboolean footstep;
//
@@ -1904,31 +1957,33 @@ static void PM_Footsteps( void ) {
if( BG_ClassHasAbility( pm->ps->stats[ STAT_PCLASS ], SCA_WALLCLIMBER ) && ( pml.groundPlane ) )
{
//TA: FIXME: yes yes i know this is wrong
- pm->xyspeed = sqrt( pm->ps->velocity[0] * pm->ps->velocity[0]
- + pm->ps->velocity[1] * pm->ps->velocity[1]
- + pm->ps->velocity[2] * pm->ps->velocity[2] );
+ pm->xyspeed = sqrt( pm->ps->velocity[ 0 ] * pm->ps->velocity[ 0 ]
+ + pm->ps->velocity[ 1 ] * pm->ps->velocity[ 1 ]
+ + pm->ps->velocity[ 2 ] * pm->ps->velocity[ 2 ] );
}
else
- pm->xyspeed = sqrt( pm->ps->velocity[0] * pm->ps->velocity[0]
- + pm->ps->velocity[1] * pm->ps->velocity[1] );
+ pm->xyspeed = sqrt( pm->ps->velocity[ 0 ] * pm->ps->velocity[ 0 ]
+ + pm->ps->velocity[ 1 ] * pm->ps->velocity[ 1 ] );
- if ( pm->ps->groundEntityNum == ENTITYNUM_NONE ) {
+ if( pm->ps->groundEntityNum == ENTITYNUM_NONE )
+ {
// airborne leaves position in cycle intact, but doesn't advance
- if ( pm->waterlevel > 1 ) {
+ if( pm->waterlevel > 1 )
PM_ContinueLegsAnim( LEGS_SWIM );
- }
+
return;
}
// if not trying to move
- if ( !pm->cmd.forwardmove && !pm->cmd.rightmove ) {
- if ( pm->xyspeed < 5 ) {
+ if( !pm->cmd.forwardmove && !pm->cmd.rightmove )
+ {
+ if( pm->xyspeed < 5 )
+ {
pm->ps->bobCycle = 0; // start at beginning of cycle again
- if ( pm->ps->pm_flags & PMF_DUCKED ) {
+ if( pm->ps->pm_flags & PMF_DUCKED )
PM_ContinueLegsAnim( LEGS_IDLECR );
- } else {
+ else
PM_ContinueLegsAnim( LEGS_IDLE );
- }
}
return;
}
@@ -1936,14 +1991,15 @@ static void PM_Footsteps( void ) {
footstep = qfalse;
- if ( pm->ps->pm_flags & PMF_DUCKED ) {
+ if( pm->ps->pm_flags & PMF_DUCKED )
+ {
bobmove = 0.5; // ducked characters bob much faster
- if ( pm->ps->pm_flags & PMF_BACKWARDS_RUN ) {
+
+ if( pm->ps->pm_flags & PMF_BACKWARDS_RUN )
PM_ContinueLegsAnim( LEGS_BACKCR );
- }
- else {
+ else
PM_ContinueLegsAnim( LEGS_WALKCR );
- }
+
// ducked characters never play footsteps
/*
} else if ( pm->ps->pm_flags & PMF_BACKWARDS_RUN ) {
@@ -1955,26 +2011,28 @@ static void PM_Footsteps( void ) {
}
PM_ContinueLegsAnim( LEGS_BACK );
*/
- } else {
+ }
+ else
+ {
//TA: switch walking/running anims based on speed
//if ( !( pm->cmd.buttons & BUTTON_WALKING ) ) {
- if ( pm->xyspeed > 160 ) {
+ if( pm->xyspeed > 160 )
+ {
bobmove = 0.4f; // faster speeds bob faster
- if ( pm->ps->pm_flags & PMF_BACKWARDS_RUN ) {
+ if( pm->ps->pm_flags & PMF_BACKWARDS_RUN )
PM_ContinueLegsAnim( LEGS_BACK );
- }
- else {
+ else
PM_ContinueLegsAnim( LEGS_RUN );
- }
+
footstep = qtrue;
- } else {
+ }
+ else
+ {
bobmove = 0.3f; // walking bobs slow
- if ( pm->ps->pm_flags & PMF_BACKWARDS_RUN ) {
+ if( pm->ps->pm_flags & PMF_BACKWARDS_RUN )
PM_ContinueLegsAnim( LEGS_BACKWALK );
- }
- else {
+ else
PM_ContinueLegsAnim( LEGS_WALK );
- }
}
}
@@ -1983,21 +2041,27 @@ static void PM_Footsteps( void ) {
pm->ps->bobCycle = (int)( old + bobmove * pml.msec ) & 255;
// if we just crossed a cycle boundary, play an apropriate footstep event
- if ( ( ( old + 64 ) ^ ( pm->ps->bobCycle + 64 ) ) & 128 ) {
- if ( pm->waterlevel == 0 ) {
+ if( ( ( old + 64 ) ^ ( pm->ps->bobCycle + 64 ) ) & 128 )
+ {
+ if( pm->waterlevel == 0 )
+ {
// on ground will only play sounds if running
- if ( footstep && !pm->noFootsteps ) {
- PM_AddEvent( PM_FootstepForSurface() );
- }
- } else if ( pm->waterlevel == 1 ) {
+ if( footstep && !pm->noFootsteps )
+ PM_AddEvent( PM_FootstepForSurface( ) );
+ }
+ else if( pm->waterlevel == 1 )
+ {
// splashing
PM_AddEvent( EV_FOOTSPLASH );
- } else if ( pm->waterlevel == 2 ) {
+ }
+ else if( pm->waterlevel == 2 )
+ {
// wading / swimming at surface
PM_AddEvent( EV_SWIM );
- } else if ( pm->waterlevel == 3 ) {
+ }
+ else if( pm->waterlevel == 3 )
+ {
// no sound when completely underwater
-
}
}
}
@@ -2009,34 +2073,32 @@ PM_WaterEvents
Generate sound events for entering and leaving water
==============
*/
-static void PM_WaterEvents( void ) { // FIXME?
+static void PM_WaterEvents( void )
+{
+ // FIXME?
//
// if just entered a water volume, play a sound
//
- if (!pml.previous_waterlevel && pm->waterlevel) {
+ if( !pml.previous_waterlevel && pm->waterlevel )
PM_AddEvent( EV_WATER_TOUCH );
- }
//
// if just completely exited a water volume, play a sound
//
- if (pml.previous_waterlevel && !pm->waterlevel) {
+ if( pml.previous_waterlevel && !pm->waterlevel )
PM_AddEvent( EV_WATER_LEAVE );
- }
//
// check for head just going under water
//
- if (pml.previous_waterlevel != 3 && pm->waterlevel == 3) {
+ if( pml.previous_waterlevel != 3 && pm->waterlevel == 3 )
PM_AddEvent( EV_WATER_UNDER );
- }
//
// check for head just coming out of water
//
- if (pml.previous_waterlevel == 3 && pm->waterlevel != 3) {
+ if( pml.previous_waterlevel == 3 && pm->waterlevel != 3 )
PM_AddEvent( EV_WATER_CLEAR );
- }
}
@@ -2045,18 +2107,16 @@ static void PM_WaterEvents( void ) { // FIXME?
PM_BeginWeaponChange
===============
*/
-static void PM_BeginWeaponChange( int weapon ) {
- if ( weapon < WP_NONE || weapon >= WP_NUM_WEAPONS ) {
+static void PM_BeginWeaponChange( int weapon )
+{
+ if( weapon < WP_NONE || weapon >= WP_NUM_WEAPONS )
return;
- }
- if ( !BG_gotWeapon( weapon, pm->ps->stats ) && weapon != WP_NONE ) {
+ if( !BG_gotWeapon( weapon, pm->ps->stats ) && weapon != WP_NONE )
return;
- }
- if ( pm->ps->weaponstate == WEAPON_DROPPING ) {
+ if( pm->ps->weaponstate == WEAPON_DROPPING )
return;
- }
PM_AddEvent( EV_CHANGE_WEAPON );
pm->ps->weaponstate = WEAPON_DROPPING;
@@ -2070,17 +2130,16 @@ static void PM_BeginWeaponChange( int weapon ) {
PM_FinishWeaponChange
===============
*/
-static void PM_FinishWeaponChange( void ) {
+static void PM_FinishWeaponChange( void )
+{
int weapon;
weapon = pm->cmd.weapon;
- if ( weapon < WP_NONE || weapon >= WP_NUM_WEAPONS ) {
+ if( weapon < WP_NONE || weapon >= WP_NUM_WEAPONS )
weapon = WP_NONE;
- }
- if ( !BG_gotWeapon( weapon, pm->ps->stats ) ) {
+ if( !BG_gotWeapon( weapon, pm->ps->stats ) )
weapon = WP_NONE;
- }
pm->ps->weapon = weapon;
pm->ps->weaponstate = WEAPON_RAISING;
@@ -2097,7 +2156,7 @@ PM_TorsoAnimation
*/
static void PM_TorsoAnimation( void )
{
- if ( pm->ps->weaponstate == WEAPON_READY )
+ if( pm->ps->weaponstate == WEAPON_READY )
PM_ContinueTorsoAnim( TORSO_STAND );
}
@@ -2139,11 +2198,11 @@ static void PM_Weapon( void )
qboolean attack3 = qfalse;
// don't allow attack until all buttons are up
- if ( pm->ps->pm_flags & PMF_RESPAWNED )
+ if( pm->ps->pm_flags & PMF_RESPAWNED )
return;
// ignore if spectator
- if ( pm->ps->persistant[PERS_TEAM] == TEAM_SPECTATOR )
+ if( pm->ps->persistant[ PERS_TEAM ] == TEAM_SPECTATOR )
return;
if( pm->ps->stats[ STAT_STATE ] & SS_INFESTING )
@@ -2156,16 +2215,15 @@ static void PM_Weapon( void )
return;
// check for dead player
- if ( pm->ps->stats[STAT_HEALTH] <= 0 )
+ if( pm->ps->stats[ STAT_HEALTH ] <= 0 )
{
pm->ps->weapon = WP_NONE;
return;
}
// make weapon function
- if ( pm->ps->weaponTime > 0 ) {
+ if( pm->ps->weaponTime > 0 )
pm->ps->weaponTime -= pml.msec;
- }
//TA: if we haven't got the weapon
if( !BG_gotWeapon( pm->ps->weapon, pm->ps->stats ) && pm->ps->weapon != WP_NONE )
@@ -2433,9 +2491,12 @@ static void PM_Weapon( void )
PM_Animate
================
*/
-static void PM_Animate( void ) {
- if ( pm->cmd.buttons & BUTTON_GESTURE ) {
- if ( pm->ps->torsoTimer == 0 ) {
+static void PM_Animate( void )
+{
+ if( pm->cmd.buttons & BUTTON_GESTURE )
+ {
+ if( pm->ps->torsoTimer == 0 )
+ {
PM_StartTorsoAnim( TORSO_GESTURE );
pm->ps->torsoTimer = TIMER_GESTURE;
PM_AddEvent( EV_TAUNT );
@@ -2449,30 +2510,35 @@ static void PM_Animate( void ) {
PM_DropTimers
================
*/
-static void PM_DropTimers( void ) {
+static void PM_DropTimers( void )
+{
// drop misc timing counter
- if ( pm->ps->pm_time ) {
- if ( pml.msec >= pm->ps->pm_time ) {
+ if( pm->ps->pm_time )
+ {
+ if( pml.msec >= pm->ps->pm_time )
+ {
pm->ps->pm_flags &= ~PMF_ALL_TIMES;
pm->ps->pm_time = 0;
- } else {
- pm->ps->pm_time -= pml.msec;
}
+ else
+ pm->ps->pm_time -= pml.msec;
}
// drop animation counter
- if ( pm->ps->legsTimer > 0 ) {
+ if( pm->ps->legsTimer > 0 )
+ {
pm->ps->legsTimer -= pml.msec;
- if ( pm->ps->legsTimer < 0 ) {
+
+ if( pm->ps->legsTimer < 0 )
pm->ps->legsTimer = 0;
- }
}
- if ( pm->ps->torsoTimer > 0 ) {
+ if( pm->ps->torsoTimer > 0 )
+ {
pm->ps->torsoTimer -= pml.msec;
- if ( pm->ps->torsoTimer < 0 ) {
+
+ if( pm->ps->torsoTimer < 0 )
pm->ps->torsoTimer = 0;
- }
}
}
@@ -2616,44 +2682,42 @@ void PmoveSingle (pmove_t *pmove)
// make sure walking button is clear if they are running, to avoid
// proxy no-footsteps cheats
- if ( abs( pm->cmd.forwardmove ) > 64 || abs( pm->cmd.rightmove ) > 64 ) {
+ if( abs( pm->cmd.forwardmove ) > 64 || abs( pm->cmd.rightmove ) > 64 )
pm->cmd.buttons &= ~BUTTON_WALKING;
- }
// set the talk balloon flag
- if ( pm->cmd.buttons & BUTTON_TALK ) {
+ if( pm->cmd.buttons & BUTTON_TALK )
pm->ps->eFlags |= EF_TALK;
- } else {
+ else
pm->ps->eFlags &= ~EF_TALK;
- }
// set the firing flag for continuous beam weapons
- if ( !(pm->ps->pm_flags & PMF_RESPAWNED) && pm->ps->pm_type != PM_INTERMISSION
- && ( pm->cmd.buttons & BUTTON_ATTACK )
- && ( ( ammo > 0 || clips > 0 ) || BG_FindInfinteAmmoForWeapon( pm->ps->weapon ) ) )
+ if( !(pm->ps->pm_flags & PMF_RESPAWNED) && pm->ps->pm_type != PM_INTERMISSION &&
+ ( pm->cmd.buttons & BUTTON_ATTACK ) &&
+ ( ( ammo > 0 || clips > 0 ) || BG_FindInfinteAmmoForWeapon( pm->ps->weapon ) ) )
pm->ps->eFlags |= EF_FIRING;
else
pm->ps->eFlags &= ~EF_FIRING;
// set the firing flag for continuous beam weapons
- if ( !(pm->ps->pm_flags & PMF_RESPAWNED) && pm->ps->pm_type != PM_INTERMISSION
- && ( pm->cmd.buttons & BUTTON_ATTACK2 )
- && ( ( ammo > 0 || clips > 0 ) || BG_FindInfinteAmmoForWeapon( pm->ps->weapon ) ) )
+ if( !(pm->ps->pm_flags & PMF_RESPAWNED) && pm->ps->pm_type != PM_INTERMISSION &&
+ ( pm->cmd.buttons & BUTTON_ATTACK2 ) &&
+ ( ( ammo > 0 || clips > 0 ) || BG_FindInfinteAmmoForWeapon( pm->ps->weapon ) ) )
pm->ps->eFlags |= EF_FIRING2;
else
pm->ps->eFlags &= ~EF_FIRING2;
// clear the respawned flag if attack and use are cleared
- if ( pm->ps->stats[STAT_HEALTH] > 0 &&
- !( pm->cmd.buttons & (BUTTON_ATTACK | BUTTON_USE_HOLDABLE) ) ) {
+ if( pm->ps->stats[STAT_HEALTH] > 0 &&
+ !( pm->cmd.buttons & ( BUTTON_ATTACK | BUTTON_USE_HOLDABLE ) ) )
pm->ps->pm_flags &= ~PMF_RESPAWNED;
- }
// if talk button is down, dissallow all other input
// this is to prevent any possible intercept proxy from
// adding fake talk balloons
- if ( pmove->cmd.buttons & BUTTON_TALK ) {
+ if( pmove->cmd.buttons & BUTTON_TALK )
+ {
pmove->cmd.buttons = BUTTON_TALK;
pmove->cmd.forwardmove = 0;
pmove->cmd.rightmove = 0;
@@ -2661,38 +2725,39 @@ void PmoveSingle (pmove_t *pmove)
}
// clear all pmove local vars
- memset (&pml, 0, sizeof(pml));
+ memset( &pml, 0, sizeof( pml ) );
// determine the time
pml.msec = pmove->cmd.serverTime - pm->ps->commandTime;
- if ( pml.msec < 1 ) {
+
+ if( pml.msec < 1 )
pml.msec = 1;
- } else if ( pml.msec > 200 ) {
+ else if( pml.msec > 200 )
pml.msec = 200;
- }
+
pm->ps->commandTime = pmove->cmd.serverTime;
// save old org in case we get stuck
- VectorCopy (pm->ps->origin, pml.previous_origin);
+ VectorCopy( pm->ps->origin, pml.previous_origin );
// save old velocity for crashlanding
- VectorCopy (pm->ps->velocity, pml.previous_velocity);
+ VectorCopy( pm->ps->velocity, pml.previous_velocity );
pml.frametime = pml.msec * 0.001;
AngleVectors( pm->ps->viewangles, pml.forward, pml.right, pml.up );
- if ( pm->cmd.upmove < 10 ) {
+ if( pm->cmd.upmove < 10 )
+ {
// not holding jump
pm->ps->pm_flags &= ~PMF_JUMP_HELD;
}
// decide if backpedaling animations should be used
- if ( pm->cmd.forwardmove < 0 ) {
+ if( pm->cmd.forwardmove < 0 )
pm->ps->pm_flags |= PMF_BACKWARDS_RUN;
- } else if ( pm->cmd.forwardmove > 0 || ( pm->cmd.forwardmove == 0 && pm->cmd.rightmove ) ) {
+ else if( pm->cmd.forwardmove > 0 || ( pm->cmd.forwardmove == 0 && pm->cmd.rightmove ) )
pm->ps->pm_flags &= ~PMF_BACKWARDS_RUN;
- }
if ( pm->ps->pm_type >= PM_DEAD )
{
@@ -2701,38 +2766,38 @@ void PmoveSingle (pmove_t *pmove)
pm->cmd.upmove = 0;
}
- if ( pm->ps->pm_type == PM_SPECTATOR ) {
+ if( pm->ps->pm_type == PM_SPECTATOR )
+ {
// update the viewangles
PM_UpdateViewAngles( pm->ps, &pm->cmd );
- PM_CheckDuck ();
- PM_FlyMove ();
- PM_DropTimers ();
+ PM_CheckDuck( );
+ PM_FlyMove( );
+ PM_DropTimers( );
return;
}
- if ( pm->ps->pm_type == PM_NOCLIP ) {
- PM_NoclipMove ();
- PM_DropTimers ();
+ if( pm->ps->pm_type == PM_NOCLIP )
+ {
+ PM_NoclipMove( );
+ PM_DropTimers( );
return;
}
- if (pm->ps->pm_type == PM_FREEZE) {
+ if( pm->ps->pm_type == PM_FREEZE)
return; // no movement at all
- }
- if ( pm->ps->pm_type == PM_INTERMISSION || pm->ps->pm_type == PM_SPINTERMISSION ) {
+ if( pm->ps->pm_type == PM_INTERMISSION || pm->ps->pm_type == PM_SPINTERMISSION )
return; // no movement at all
- }
// set watertype, and waterlevel
- PM_SetWaterLevel();
+ PM_SetWaterLevel( );
pml.previous_waterlevel = pmove->waterlevel;
// set mins, maxs, and viewheight
- PM_CheckDuck ();
+ PM_CheckDuck( );
// set groundentity
- PM_GroundTrace();
+ PM_GroundTrace( );
// update the viewangles
PM_UpdateViewAngles( pm->ps, &pm->cmd );
@@ -2798,46 +2863,44 @@ Pmove
Can be called by either the server or the client
================
*/
-void Pmove (pmove_t *pmove) {
- int finalTime;
+void Pmove( pmove_t *pmove )
+{
+ int finalTime;
finalTime = pmove->cmd.serverTime;
- if ( finalTime < pmove->ps->commandTime ) {
+ if( finalTime < pmove->ps->commandTime )
return; // should not happen
- }
- if ( finalTime > pmove->ps->commandTime + 1000 ) {
+ if( finalTime > pmove->ps->commandTime + 1000 )
pmove->ps->commandTime = finalTime - 1000;
- }
- pmove->ps->pmove_framecount = (pmove->ps->pmove_framecount+1) & ((1<<PS_PMOVEFRAMECOUNTBITS)-1);
+ pmove->ps->pmove_framecount = ( pmove->ps->pmove_framecount + 1 ) & ( ( 1 << PS_PMOVEFRAMECOUNTBITS ) - 1 );
// chop the move up if it is too long, to prevent framerate
// dependent behavior
- while ( pmove->ps->commandTime != finalTime ) {
+ while( pmove->ps->commandTime != finalTime )
+ {
int msec;
msec = finalTime - pmove->ps->commandTime;
- if ( pmove->pmove_fixed ) {
- if ( msec > pmove->pmove_msec ) {
+ if( pmove->pmove_fixed )
+ {
+ if( msec > pmove->pmove_msec )
msec = pmove->pmove_msec;
- }
}
- else {
- if ( msec > 66 ) {
+ else
+ {
+ if( msec > 66 )
msec = 66;
- }
}
pmove->cmd.serverTime = pmove->ps->commandTime + msec;
PmoveSingle( pmove );
- if ( pmove->ps->pm_flags & PMF_JUMP_HELD ) {
+ if( pmove->ps->pm_flags & PMF_JUMP_HELD )
pmove->cmd.upmove = 20;
- }
}
-
}
diff --git a/src/game/bg_public.h b/src/game/bg_public.h
index 97def1db..c8341ce1 100644
--- a/src/game/bg_public.h
+++ b/src/game/bg_public.h
@@ -103,7 +103,12 @@
#error overflow: (CS_MAX) > MAX_CONFIGSTRINGS
#endif
-typedef enum { GENDER_MALE, GENDER_FEMALE, GENDER_NEUTER } gender_t;
+typedef enum
+{
+ GENDER_MALE,
+ GENDER_FEMALE,
+ GENDER_NEUTER
+} gender_t;
/*
===================================================================================
@@ -116,7 +121,8 @@ movement on the server game.
===================================================================================
*/
-typedef enum {
+typedef enum
+{
PM_NORMAL, // can accelerate and turn
PM_NOCLIP, // noclip movement
PM_SPECTATOR, // still run into walls
@@ -128,7 +134,8 @@ typedef enum {
PM_SPINTERMISSION // no movement or status bar
} pmtype_t;
-typedef enum {
+typedef enum
+{
WEAPON_READY,
WEAPON_RAISING,
WEAPON_DROPPING,
@@ -157,52 +164,55 @@ typedef enum {
#define PMF_ALL_TIMES (PMF_TIME_WATERJUMP|PMF_TIME_LAND|PMF_TIME_KNOCKBACK)
#define MAXTOUCH 32
-typedef struct {
+typedef struct
+{
// state (in / out)
playerState_t *ps;
// command (in)
- usercmd_t cmd;
- int tracemask; // collide against these types of surfaces
- int debugLevel; // if set, diagnostic output will be printed
- qboolean noFootsteps; // if the game is setup for no footsteps by the server
- qboolean autoWeaponHit[ 32 ]; //FIXME: TA: remind myself later this might be a problem
+ usercmd_t cmd;
+ int tracemask; // collide against these types of surfaces
+ int debugLevel; // if set, diagnostic output will be printed
+ qboolean noFootsteps; // if the game is setup for no footsteps by the server
+ qboolean autoWeaponHit[ 32 ]; //FIXME: TA: remind myself later this might be a problem
- int framecount;
+ int framecount;
// results (out)
- int numtouch;
- int touchents[MAXTOUCH];
+ int numtouch;
+ int touchents[ MAXTOUCH ];
- vec3_t mins, maxs; // bounding box size
+ vec3_t mins, maxs; // bounding box size
- int watertype;
- int waterlevel;
+ int watertype;
+ int waterlevel;
- float xyspeed;
+ float xyspeed;
// for fixed msec Pmove
- int pmove_fixed;
- int pmove_msec;
+ int pmove_fixed;
+ int pmove_msec;
// callbacks to test the world
// these will be different functions during game and cgame
/*void (*trace)( trace_t *results, const vec3_t start, vec3_t mins, vec3_t maxs, const vec3_t end, int passEntityNum, int contentMask );*/
- void (*trace)( trace_t *results, const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end, int passEntityNum, int contentMask );
+ void (*trace)( trace_t *results, const vec3_t start, const vec3_t mins, const vec3_t maxs,
+ const vec3_t end, int passEntityNum, int contentMask );
- int (*pointcontents)( const vec3_t point, int passEntityNum );
+ int (*pointcontents)( const vec3_t point, int passEntityNum );
} pmove_t;
// if a full pmove isn't done on the client, you can just update the angles
void PM_UpdateViewAngles( playerState_t *ps, const usercmd_t *cmd );
-void Pmove (pmove_t *pmove);
+void Pmove( pmove_t *pmove );
//===================================================================================
// player_state->stats[] indexes
-typedef enum {
+typedef enum
+{
STAT_HEALTH,
STAT_ITEMS,
STAT_SLOTS, //TA: tracks the amount of stuff human players are carrying
@@ -248,14 +258,13 @@ typedef enum {
// player_state->persistant[] indexes
// these fields are the only part of player_state that isn't
// cleared on respawn
-typedef enum {
+typedef enum
+{
PERS_SCORE, // !!! MUST NOT CHANGE, SERVER AND GAME BOTH REFERENCE !!!
PERS_HITS, // total points damage inflicted so damage beeps can sound on change
PERS_RANK,
PERS_TEAM,
PERS_SPAWN_COUNT, // incremented every respawn
- PERS_PLAYEREVENTS, // 16 bits that can be flipped for events
- PERS_REWARD, // a reward_t
PERS_ATTACKER, // clientnum of last damage inflicter
PERS_KILLED, // count of the number of times you died
@@ -286,7 +295,8 @@ typedef enum {
#define EF_OVERDRAW_OFF 0x00008000 // TA: disable overdraw protection on sprites
#define EF_REAL_LIGHT 0x00010000 // TA: light sprites according to ambient light
-typedef enum {
+typedef enum
+{
PW_NONE,
PW_QUAD,
@@ -303,7 +313,8 @@ typedef enum {
PW_NUM_POWERUPS
} powerup_t;
-typedef enum {
+typedef enum
+{
HI_NONE,
HI_TELEPORTER,
@@ -334,7 +345,6 @@ typedef enum
WP_MACHINEGUN,
WP_CHAINGUN,
WP_FLAMER,
- WP_PLASMAGUN,
WP_MASS_DRIVER,
WP_PULSE_RIFLE,
WP_LUCIFER_CANON,
@@ -384,14 +394,14 @@ typedef enum
} WUTeam_t;
//TA: bitmasks for upgrade slots
-#define SLOT_NONE 0
-#define SLOT_HEAD 1
-#define SLOT_TORSO 2
-#define SLOT_ARMS 4
-#define SLOT_LEGS 8
-#define SLOT_BACKPACK 16
-#define SLOT_WEAPON 32
-#define SLOT_SIDEARM 64
+#define SLOT_NONE 0x00000000
+#define SLOT_HEAD 0x00000001
+#define SLOT_TORSO 0x00000002
+#define SLOT_ARMS 0x00000004
+#define SLOT_LEGS 0x00000008
+#define SLOT_BACKPACK 0x00000010
+#define SLOT_WEAPON 0x00000020
+#define SLOT_SIDEARM 0x00000040
typedef enum
{
@@ -410,9 +420,8 @@ typedef enum
BA_H_SPAWN,
- BA_H_DEF1,
- BA_H_DEF2,
- BA_H_DEF3,
+ BA_H_MGTURRET,
+ BA_H_TESLAGEN,
BA_H_MCU,
BA_H_DCC,
@@ -443,9 +452,9 @@ typedef enum
// reward sounds (stored in ps->persistant[PERS_PLAYEREVENTS])
-#define PLAYEREVENT_DENIEDREWARD 0x0001
+#define PLAYEREVENT_DENIEDREWARD 0x0001
#define PLAYEREVENT_GAUNTLETREWARD 0x0002
-#define PLAYEREVENT_HOLYSHIT 0x0004
+#define PLAYEREVENT_HOLYSHIT 0x0004
// entityState_t->event values
// entity events are for effects that take place reletive
@@ -462,7 +471,8 @@ typedef enum
#define EVENT_VALID_MSEC 300
-typedef enum {
+typedef enum
+{
EV_NONE,
EV_FOOTSTEP,
@@ -541,7 +551,7 @@ typedef enum {
EV_MISSILE_HIT,
EV_MISSILE_MISS,
EV_MISSILE_MISS_METAL,
- EV_ITEM_EXPLOSION, //TA: human item explosions
+ EV_BUILDABLE_EXPLOSION, //TA: human item explosions
EV_RAILTRAIL,
EV_TESLATRAIL,
EV_ALIENZAP,
@@ -614,12 +624,12 @@ typedef enum
MN_H_NOSLOTS,
MN_H_NOFUNDS,
MN_H_NODCC,
- MN_H_ITEMHELD
-
+ MN_H_ITEMHELD
} dynMenu_t;
// animations
-typedef enum {
+typedef enum
+{
BOTH_DEATH1,
BOTH_DEAD1,
BOTH_DEATH2,
@@ -701,7 +711,8 @@ typedef enum
MAX_BUILDABLE_ANIMATIONS
} buildableAnimNumber_t;
-typedef struct animation_s {
+typedef struct animation_s
+{
int firstFrame;
int numFrames;
int loopFrames; // 0 to numFrames
@@ -717,7 +728,8 @@ typedef struct animation_s {
#define ANIM_TOGGLEBIT 128
-typedef enum {
+typedef enum
+{
TEAM_FREE,
TEAM_SPECTATOR,
@@ -757,7 +769,8 @@ typedef enum
//TA: player teams
-typedef enum {
+typedef enum
+{
PTE_NONE,
PTE_ALIENS,
PTE_HUMANS,
@@ -767,7 +780,8 @@ typedef enum {
// means of death
-typedef enum {
+typedef enum
+{
MOD_UNKNOWN,
MOD_SHOTGUN,
MOD_GAUNTLET,
@@ -802,7 +816,8 @@ typedef enum {
//---------------------------------------------------------
// gitem_t->type
-typedef enum {
+typedef enum
+{
IT_BAD,
IT_WEAPON, // EFX: rotate + upscale + minlight
IT_BUILDABLE, //TA: gitem_t->type for buildable items (spawns etc.)
@@ -819,7 +834,8 @@ typedef enum {
#define MAX_ITEM_MODELS 4
-typedef struct gitem_s {
+typedef struct gitem_s
+{
char *classname; // spawning name
char *pickup_sound;
char *world_model[MAX_ITEM_MODELS];
@@ -1115,7 +1131,8 @@ WUTeam_t BG_FindTeamForUpgrade( int upgrade );
//
// entityState_t->eType
//
-typedef enum {
+typedef enum
+{
ET_GENERAL,
ET_PLAYER,
ET_ITEM,
diff --git a/src/game/bg_slidemove.c b/src/game/bg_slidemove.c
index b3ee8fa7..4abd5ddf 100644
--- a/src/game/bg_slidemove.c
+++ b/src/game/bg_slidemove.c
@@ -34,187 +34,193 @@ PM_SlideMove
Returns qtrue if the velocity was clipped in some way
==================
*/
-#define MAX_CLIP_PLANES 5
-qboolean PM_SlideMove( qboolean gravity ) {
- int bumpcount, numbumps;
- vec3_t dir;
- float d;
- int numplanes;
- vec3_t planes[MAX_CLIP_PLANES];
- vec3_t primal_velocity;
- vec3_t clipVelocity;
- int i, j, k;
- trace_t trace;
- vec3_t end;
- float time_left;
- float into;
- vec3_t endVelocity;
- vec3_t endClipVelocity;
-
- numbumps = 4;
-
- VectorCopy (pm->ps->velocity, primal_velocity);
-
- if ( gravity ) {
- VectorCopy( pm->ps->velocity, endVelocity );
- endVelocity[2] -= pm->ps->gravity * pml.frametime;
- pm->ps->velocity[2] = ( pm->ps->velocity[2] + endVelocity[2] ) * 0.5;
- primal_velocity[2] = endVelocity[2];
- if ( pml.groundPlane ) {
- // slide along the ground plane
- PM_ClipVelocity (pm->ps->velocity, pml.groundTrace.plane.normal,
- pm->ps->velocity, OVERCLIP );
- }
- }
-
- time_left = pml.frametime;
-
- // never turn against the ground plane
- if ( pml.groundPlane ) {
- numplanes = 1;
- VectorCopy( pml.groundTrace.plane.normal, planes[0] );
- } else {
- numplanes = 0;
- }
-
- // never turn against original velocity
- VectorNormalize2( pm->ps->velocity, planes[numplanes] );
- numplanes++;
-
- for ( bumpcount=0 ; bumpcount < numbumps ; bumpcount++ ) {
-
- // calculate position we are trying to move to
- VectorMA( pm->ps->origin, time_left, pm->ps->velocity, end );
-
- // see if we can make it there
- pm->trace ( &trace, pm->ps->origin, pm->mins, pm->maxs, end, pm->ps->clientNum, pm->tracemask);
-
- if (trace.allsolid) {
- // entity is completely trapped in another solid
- pm->ps->velocity[2] = 0; // don't build up falling damage, but allow sideways acceleration
- return qtrue;
- }
-
- if (trace.fraction > 0) {
- // actually covered some distance
- VectorCopy (trace.endpos, pm->ps->origin);
- }
-
- if (trace.fraction == 1) {
- break; // moved the entire distance
- }
-
- // save entity for contact
- PM_AddTouchEnt( trace.entityNum );
-
- time_left -= time_left * trace.fraction;
-
- if (numplanes >= MAX_CLIP_PLANES) {
- // this shouldn't really happen
- VectorClear( pm->ps->velocity );
- return qtrue;
- }
-
- //
- // if this is the same plane we hit before, nudge velocity
- // out along it, which fixes some epsilon issues with
- // non-axial planes
- //
- for ( i = 0 ; i < numplanes ; i++ ) {
- if ( DotProduct( trace.plane.normal, planes[i] ) > 0.99 ) {
- VectorAdd( trace.plane.normal, pm->ps->velocity, pm->ps->velocity );
- break;
- }
- }
- if ( i < numplanes ) {
- continue;
- }
- VectorCopy (trace.plane.normal, planes[numplanes]);
- numplanes++;
-
- //
- // modify velocity so it parallels all of the clip planes
- //
-
- // find a plane that it enters
- for ( i = 0 ; i < numplanes ; i++ ) {
- into = DotProduct( pm->ps->velocity, planes[i] );
- if ( into >= 0.1 ) {
- continue; // move doesn't interact with the plane
- }
-
- // see how hard we are hitting things
- if ( -into > pml.impactSpeed ) {
- pml.impactSpeed = -into;
- }
-
- // slide along the plane
- PM_ClipVelocity (pm->ps->velocity, planes[i], clipVelocity, OVERCLIP );
-
- // slide along the plane
- PM_ClipVelocity (endVelocity, planes[i], endClipVelocity, OVERCLIP );
-
- // see if there is a second plane that the new move enters
- for ( j = 0 ; j < numplanes ; j++ ) {
- if ( j == i ) {
- continue;
- }
- if ( DotProduct( clipVelocity, planes[j] ) >= 0.1 ) {
- continue; // move doesn't interact with the plane
- }
-
- // try clipping the move to the plane
- PM_ClipVelocity( clipVelocity, planes[j], clipVelocity, OVERCLIP );
- PM_ClipVelocity( endClipVelocity, planes[j], endClipVelocity, OVERCLIP );
-
- // see if it goes back into the first clip plane
- if ( DotProduct( clipVelocity, planes[i] ) >= 0 ) {
- continue;
- }
-
- // slide the original velocity along the crease
- CrossProduct (planes[i], planes[j], dir);
- VectorNormalize( dir );
- d = DotProduct( dir, pm->ps->velocity );
- VectorScale( dir, d, clipVelocity );
-
- CrossProduct (planes[i], planes[j], dir);
- VectorNormalize( dir );
- d = DotProduct( dir, endVelocity );
- VectorScale( dir, d, endClipVelocity );
-
- // see if there is a third plane the the new move enters
- for ( k = 0 ; k < numplanes ; k++ ) {
- if ( k == i || k == j ) {
- continue;
- }
- if ( DotProduct( clipVelocity, planes[k] ) >= 0.1 ) {
- continue; // move doesn't interact with the plane
- }
-
- // stop dead at a tripple plane interaction
- VectorClear( pm->ps->velocity );
- return qtrue;
- }
- }
-
- // if we have fixed all interactions, try another move
- VectorCopy( clipVelocity, pm->ps->velocity );
- VectorCopy( endClipVelocity, endVelocity );
- break;
- }
- }
-
- if ( gravity ) {
- VectorCopy( endVelocity, pm->ps->velocity );
- }
-
- // don't change velocity if in a timer (FIXME: is this correct?)
- if ( pm->ps->pm_time ) {
- VectorCopy( primal_velocity, pm->ps->velocity );
- }
-
- return ( bumpcount != 0 );
+#define MAX_CLIP_PLANES 5
+qboolean PM_SlideMove( qboolean gravity )
+{
+ int bumpcount, numbumps;
+ vec3_t dir;
+ float d;
+ int numplanes;
+ vec3_t planes[MAX_CLIP_PLANES];
+ vec3_t primal_velocity;
+ vec3_t clipVelocity;
+ int i, j, k;
+ trace_t trace;
+ vec3_t end;
+ float time_left;
+ float into;
+ vec3_t endVelocity;
+ vec3_t endClipVelocity;
+
+ numbumps = 4;
+
+ VectorCopy( pm->ps->velocity, primal_velocity );
+
+ if( gravity )
+ {
+ VectorCopy( pm->ps->velocity, endVelocity );
+ endVelocity[ 2 ] -= pm->ps->gravity * pml.frametime;
+ pm->ps->velocity[ 2 ] = ( pm->ps->velocity[ 2 ] + endVelocity[ 2 ] ) * 0.5;
+ primal_velocity[ 2 ] = endVelocity[ 2 ];
+
+ if( pml.groundPlane )
+ {
+ // slide along the ground plane
+ PM_ClipVelocity( pm->ps->velocity, pml.groundTrace.plane.normal,
+ pm->ps->velocity, OVERCLIP );
+ }
+ }
+
+ time_left = pml.frametime;
+
+ // never turn against the ground plane
+ if( pml.groundPlane )
+ {
+ numplanes = 1;
+ VectorCopy( pml.groundTrace.plane.normal, planes[ 0 ] );
+ }
+ else
+ numplanes = 0;
+
+ // never turn against original velocity
+ VectorNormalize2( pm->ps->velocity, planes[ numplanes ] );
+ numplanes++;
+
+ for( bumpcount = 0; bumpcount < numbumps; bumpcount++ )
+ {
+ // calculate position we are trying to move to
+ VectorMA( pm->ps->origin, time_left, pm->ps->velocity, end );
+
+ // see if we can make it there
+ pm->trace( &trace, pm->ps->origin, pm->mins, pm->maxs, end, pm->ps->clientNum, pm->tracemask );
+
+ if( trace.allsolid )
+ {
+ // entity is completely trapped in another solid
+ pm->ps->velocity[ 2 ] = 0; // don't build up falling damage, but allow sideways acceleration
+ return qtrue;
+ }
+
+ if( trace.fraction > 0 )
+ {
+ // actually covered some distance
+ VectorCopy( trace.endpos, pm->ps->origin );
+ }
+
+ if( trace.fraction == 1 )
+ break; // moved the entire distance
+
+ // save entity for contact
+ PM_AddTouchEnt( trace.entityNum );
+
+ time_left -= time_left * trace.fraction;
+
+ if( numplanes >= MAX_CLIP_PLANES )
+ {
+ // this shouldn't really happen
+ VectorClear( pm->ps->velocity );
+ return qtrue;
+ }
+
+ //
+ // if this is the same plane we hit before, nudge velocity
+ // out along it, which fixes some epsilon issues with
+ // non-axial planes
+ //
+ for( i = 0 ; i < numplanes ; i++ )
+ {
+ if( DotProduct( trace.plane.normal, planes[i] ) > 0.99 )
+ {
+ VectorAdd( trace.plane.normal, pm->ps->velocity, pm->ps->velocity );
+ break;
+ }
+ }
+
+ if( i < numplanes )
+ continue;
+
+ VectorCopy( trace.plane.normal, planes[ numplanes ] );
+ numplanes++;
+
+ //
+ // modify velocity so it parallels all of the clip planes
+ //
+
+ // find a plane that it enters
+ for( i = 0; i < numplanes; i++ )
+ {
+ into = DotProduct( pm->ps->velocity, planes[ i ] );
+ if( into >= 0.1 )
+ continue; // move doesn't interact with the plane
+
+ // see how hard we are hitting things
+ if( -into > pml.impactSpeed )
+ pml.impactSpeed = -into;
+
+ // slide along the plane
+ PM_ClipVelocity( pm->ps->velocity, planes[ i ], clipVelocity, OVERCLIP );
+
+ // slide along the plane
+ PM_ClipVelocity( endVelocity, planes[ i ], endClipVelocity, OVERCLIP );
+
+ // see if there is a second plane that the new move enters
+ for( j = 0; j < numplanes; j++ )
+ {
+ if( j == i )
+ continue;
+
+ if( DotProduct( clipVelocity, planes[ j ] ) >= 0.1 )
+ continue; // move doesn't interact with the plane
+
+ // try clipping the move to the plane
+ PM_ClipVelocity( clipVelocity, planes[ j ], clipVelocity, OVERCLIP );
+ PM_ClipVelocity( endClipVelocity, planes[ j ], endClipVelocity, OVERCLIP );
+
+ // see if it goes back into the first clip plane
+ if( DotProduct( clipVelocity, planes[ i ] ) >= 0 )
+ continue;
+
+ // slide the original velocity along the crease
+ CrossProduct( planes[ i ], planes[ j ], dir );
+ VectorNormalize( dir );
+ d = DotProduct( dir, pm->ps->velocity );
+ VectorScale( dir, d, clipVelocity );
+
+ CrossProduct( planes[ i ], planes[ j ], dir);
+ VectorNormalize( dir );
+ d = DotProduct( dir, endVelocity );
+ VectorScale( dir, d, endClipVelocity );
+
+ // see if there is a third plane the the new move enters
+ for( k = 0; k < numplanes; k++ )
+ {
+ if( k == i || k == j )
+ continue;
+
+ if( DotProduct( clipVelocity, planes[ k ] ) >= 0.1 )
+ continue; // move doesn't interact with the plane
+
+ // stop dead at a tripple plane interaction
+ VectorClear( pm->ps->velocity );
+ return qtrue;
+ }
+ }
+
+ // if we have fixed all interactions, try another move
+ VectorCopy( clipVelocity, pm->ps->velocity );
+ VectorCopy( endClipVelocity, endVelocity );
+ break;
+ }
+ }
+
+ if( gravity )
+ VectorCopy( endVelocity, pm->ps->velocity );
+
+ // don't change velocity if in a timer (FIXME: is this correct?)
+ if( pm->ps->pm_time )
+ VectorCopy( primal_velocity, pm->ps->velocity );
+
+ return ( bumpcount != 0 );
}
/*
@@ -275,9 +281,9 @@ PM_StepSlideMove
*/
qboolean PM_StepSlideMove( qboolean gravity, qboolean predictive )
{
- vec3_t start_o, start_v;
- vec3_t down_o, down_v;
- trace_t trace;
+ vec3_t start_o, start_v;
+ vec3_t down_o, down_v;
+ trace_t trace;
vec3_t normal;
vec3_t step_v, step_vNormal;
vec3_t up, down;
@@ -294,8 +300,8 @@ qboolean PM_StepSlideMove( qboolean gravity, qboolean predictive )
else
VectorSet( normal, 0.0f, 0.0f, 1.0f );
- VectorCopy( pm->ps->origin, start_o );
- VectorCopy( pm->ps->velocity, start_v );
+ VectorCopy( pm->ps->origin, start_o );
+ VectorCopy( pm->ps->velocity, start_v );
if( PM_SlideMove( gravity ) == 0 )
{
@@ -384,7 +390,7 @@ qboolean PM_StepSlideMove( qboolean gravity, qboolean predictive )
PM_PredictStepMove
==================
*/
-qboolean PM_PredictStepMove( )
+qboolean PM_PredictStepMove( void )
{
vec3_t velocity, origin;
float impactSpeed;
diff --git a/src/game/g_active.c b/src/game/g_active.c
index cef172a5..63e4c0e8 100644
--- a/src/game/g_active.c
+++ b/src/game/g_active.c
@@ -26,43 +26,45 @@ damage values to that client for pain blends and kicks, and
global pain sound events for all clients.
===============
*/
-void P_DamageFeedback( gentity_t *player ) {
+void P_DamageFeedback( gentity_t *player )
+{
gclient_t *client;
- float count;
- vec3_t angles;
+ float count;
+ vec3_t angles;
client = player->client;
- if ( client->ps.pm_type == PM_DEAD ) {
+ if( client->ps.pm_type == PM_DEAD )
return;
- }
// total points of damage shot at the player this frame
count = client->damage_blood + client->damage_armor;
- if ( count == 0 ) {
+ if( count == 0 )
return; // didn't take any damage
- }
- if ( count > 255 ) {
+ if( count > 255 )
count = 255;
- }
// send the information to the client
// world damage (falling, slime, etc) uses a special code
// to make the blend blob centered instead of positional
- if ( client->damage_fromWorld ) {
+ if( client->damage_fromWorld )
+ {
client->ps.damagePitch = 255;
client->ps.damageYaw = 255;
client->damage_fromWorld = qfalse;
- } else {
+ }
+ else
+ {
vectoangles( client->damage_from, angles );
- client->ps.damagePitch = angles[PITCH]/360.0 * 256;
- client->ps.damageYaw = angles[YAW]/360.0 * 256;
+ client->ps.damagePitch = angles[ PITCH ] / 360.0 * 256;
+ client->ps.damageYaw = angles[ YAW ] / 360.0 * 256;
}
// play an apropriate pain sound
- if ( (level.time > player->pain_debounce_time) && !(player->flags & FL_GODMODE) ) {
+ if( ( level.time > player->pain_debounce_time ) && !( player->flags & FL_GODMODE ) )
+ {
player->pain_debounce_time = level.time + 700;
G_AddEvent( player, EV_PAIN, player->health );
client->ps.damageEvent++;
@@ -88,55 +90,53 @@ P_WorldEffects
Check for lava / slime contents and drowning
=============
*/
-void P_WorldEffects( gentity_t *ent ) {
- qboolean envirosuit;
- int waterlevel;
+void P_WorldEffects( gentity_t *ent )
+{
+ int waterlevel;
- if ( ent->client->noclip ) {
+ if( ent->client->noclip )
+ {
ent->client->airOutTime = level.time + 12000; // don't need air
return;
}
waterlevel = ent->waterlevel;
- envirosuit = /*ent->client->ps.powerups[PW_BATTLESUIT]*/ 0 > level.time;
-
//
// check for drowning
//
- if ( waterlevel == 3 ) {
- // envirosuit give air
- if ( envirosuit ) {
- ent->client->airOutTime = level.time + 10000;
- }
-
+ if( waterlevel == 3 )
+ {
// if out of air, start drowning
- if ( ent->client->airOutTime < level.time) {
+ if( ent->client->airOutTime < level.time)
+ {
// drown!
ent->client->airOutTime += 1000;
- if ( ent->health > 0 ) {
+ if( ent->health > 0 )
+ {
// take more damage the longer underwater
ent->damage += 2;
- if (ent->damage > 15)
+ if( ent->damage > 15 )
ent->damage = 15;
// play a gurp sound instead of a normal pain sound
- if (ent->health <= ent->damage) {
- G_Sound(ent, CHAN_VOICE, G_SoundIndex("*drown.wav"));
- } else if (rand()&1) {
- G_Sound(ent, CHAN_VOICE, G_SoundIndex("sound/player/gurp1.wav"));
- } else {
- G_Sound(ent, CHAN_VOICE, G_SoundIndex("sound/player/gurp2.wav"));
- }
+ if( ent->health <= ent->damage )
+ G_Sound( ent, CHAN_VOICE, G_SoundIndex( "*drown.wav" ) );
+ else if( rand( ) & 1 )
+ G_Sound( ent, CHAN_VOICE, G_SoundIndex( "sound/player/gurp1.wav" ) );
+ else
+ G_Sound( ent, CHAN_VOICE, G_SoundIndex( "sound/player/gurp2.wav" ) );
// don't play a normal pain sound
ent->pain_debounce_time = level.time + 200;
- G_Damage (ent, NULL, NULL, NULL, NULL,
- ent->damage, DAMAGE_NO_ARMOR, MOD_WATER);
+ G_Damage( ent, NULL, NULL, NULL, NULL,
+ ent->damage, DAMAGE_NO_ARMOR, MOD_WATER );
}
}
- } else {
+ }
+ else
+ {
ent->client->airOutTime = level.time + 12000;
ent->damage = 2;
}
@@ -144,23 +144,22 @@ void P_WorldEffects( gentity_t *ent ) {
//
// check for sizzle damage (move to pmove?)
//
- if (waterlevel &&
- (ent->watertype&(CONTENTS_LAVA|CONTENTS_SLIME)) ) {
- if (ent->health > 0
- && ent->pain_debounce_time <= level.time ) {
-
- if ( envirosuit ) {
- G_AddEvent( ent, EV_POWERUP_BATTLESUIT, 0 );
- } else {
- if (ent->watertype & CONTENTS_LAVA) {
- G_Damage (ent, NULL, NULL, NULL, NULL,
- 30*waterlevel, 0, MOD_LAVA);
- }
+ if( waterlevel &&
+ ( ent->watertype & ( CONTENTS_LAVA | CONTENTS_SLIME ) ) )
+ {
+ if( ent->health > 0 &&
+ ent->pain_debounce_time <= level.time )
+ {
+ if( ent->watertype & CONTENTS_LAVA )
+ {
+ G_Damage( ent, NULL, NULL, NULL, NULL,
+ 30 * waterlevel, 0, MOD_LAVA );
+ }
- if (ent->watertype & CONTENTS_SLIME) {
- G_Damage (ent, NULL, NULL, NULL, NULL,
- 10*waterlevel, 0, MOD_SLIME);
- }
+ if( ent->watertype & CONTENTS_SLIME )
+ {
+ G_Damage( ent, NULL, NULL, NULL, NULL,
+ 10 * waterlevel, 0, MOD_SLIME );
}
}
}
@@ -173,12 +172,12 @@ void P_WorldEffects( gentity_t *ent ) {
G_SetClientSound
===============
*/
-void G_SetClientSound( gentity_t *ent ) {
- if (ent->waterlevel && (ent->watertype&(CONTENTS_LAVA|CONTENTS_SLIME)) ) {
+void G_SetClientSound( gentity_t *ent )
+{
+ if( ent->waterlevel && ( ent->watertype & ( CONTENTS_LAVA | CONTENTS_SLIME ) ) )
ent->client->ps.loopSound = level.snd_fry;
- } else {
+ else
ent->client->ps.loopSound = 0;
- }
}
@@ -190,34 +189,35 @@ void G_SetClientSound( gentity_t *ent ) {
ClientImpacts
==============
*/
-void ClientImpacts( gentity_t *ent, pmove_t *pm ) {
- int i, j;
- trace_t trace;
+void ClientImpacts( gentity_t *ent, pmove_t *pm )
+{
+ int i, j;
+ trace_t trace;
gentity_t *other;
memset( &trace, 0, sizeof( trace ) );
- for (i=0 ; i<pm->numtouch ; i++) {
- for (j=0 ; j<i ; j++) {
- if (pm->touchents[j] == pm->touchents[i] ) {
+
+ for( i = 0; i < pm->numtouch; i++ )
+ {
+ for( j = 0; j < i; j++ )
+ {
+ if( pm->touchents[ j ] == pm->touchents[ i ] )
break;
- }
}
- if (j != i) {
+
+ if( j != i )
continue; // duplicated
- }
- other = &g_entities[ pm->touchents[i] ];
+
+ other = &g_entities[ pm->touchents[ i ] ];
- if ( ( ent->r.svFlags & SVF_BOT ) && ( ent->touch ) ) {
+ if( ( ent->r.svFlags & SVF_BOT ) && ( ent->touch ) )
ent->touch( ent, other, &trace );
- }
- if ( !other->touch ) {
+ if( !other->touch )
continue;
- }
other->touch( other, ent, &trace );
}
-
}
/*
@@ -228,22 +228,21 @@ Find all trigger entities that ent's current position touches.
Spectators will only interact with teleporters.
============
*/
-void G_TouchTriggers( gentity_t *ent ) {
- int i, num;
- int touch[MAX_GENTITIES];
+void G_TouchTriggers( gentity_t *ent )
+{
+ int i, num;
+ int touch[MAX_GENTITIES];
gentity_t *hit;
trace_t trace;
vec3_t mins, maxs;
- static vec3_t range = { 40, 40, 52 };
+ static vec3_t range = { 40, 40, 52 };
- if ( !ent->client ) {
+ if( !ent->client )
return;
- }
// dead clients don't activate triggers!
- if ( ent->client->ps.stats[STAT_HEALTH] <= 0 ) {
+ if( ent->client->ps.stats[ STAT_HEALTH ] <= 0 )
return;
- }
VectorSubtract( ent->client->ps.origin, range, mins );
VectorAdd( ent->client->ps.origin, range, maxs );
@@ -254,53 +253,43 @@ void G_TouchTriggers( gentity_t *ent ) {
VectorAdd( ent->client->ps.origin, ent->r.mins, mins );
VectorAdd( ent->client->ps.origin, ent->r.maxs, maxs );
- for ( i=0 ; i<num ; i++ ) {
- hit = &g_entities[touch[i]];
+ for( i = 0; i < num; i++ )
+ {
+ hit = &g_entities[ touch[ i ] ];
- if ( !hit->touch && !ent->touch ) {
+ if( !hit->touch && !ent->touch )
continue;
- }
- if ( !( hit->r.contents & CONTENTS_TRIGGER ) ) {
+
+ if( !( hit->r.contents & CONTENTS_TRIGGER ) )
continue;
- }
// ignore most entities if a spectator
if( ( ent->client->sess.sessionTeam == TEAM_SPECTATOR ) ||
( ent->client->ps.stats[ STAT_STATE ] & SS_INFESTING ) ||
- ( ent->client->ps.stats[ STAT_STATE ] & SS_HOVELING ) ) {
- if ( hit->s.eType != ET_TELEPORT_TRIGGER &&
- // this is ugly but adding a new ET_? type will
- // most likely cause network incompatibilities
- hit->touch != Touch_DoorTrigger) {
+ ( ent->client->ps.stats[ STAT_STATE ] & SS_HOVELING ) )
+ {
+ if( hit->s.eType != ET_TELEPORT_TRIGGER &&
+ // this is ugly but adding a new ET_? type will
+ // most likely cause network incompatibilities
+ hit->touch != Touch_DoorTrigger )
continue;
- }
}
- // use seperate code for determining if an item is picked up
- // so you don't have to actually contact its bounding box
-/* if ( hit->s.eType == ET_ITEM || hit->s.eType == ET_BUILDABLE ) {
- if ( !BG_PlayerTouchesItem( &ent->client->ps, &hit->s, level.time ) ) {
- continue;
- }
- } else {*/
- if ( !trap_EntityContact( mins, maxs, hit ) ) {
- continue;
- }
- /*}*/
+ if( !trap_EntityContact( mins, maxs, hit ) )
+ continue;
- memset( &trace, 0, sizeof(trace) );
+ memset( &trace, 0, sizeof( trace ) );
- if ( hit->touch ) {
- hit->touch (hit, ent, &trace);
- }
+ if( hit->touch )
+ hit->touch( hit, ent, &trace );
- if ( ( ent->r.svFlags & SVF_BOT ) && ( ent->touch ) ) {
+ if( ( ent->r.svFlags & SVF_BOT ) && ( ent->touch ) )
ent->touch( ent, hit, &trace );
- }
}
// if we didn't touch a jump pad this pmove frame
- if ( ent->client->ps.jumppad_frame != ent->client->ps.pmove_framecount ) {
+ if( ent->client->ps.jumppad_frame != ent->client->ps.pmove_framecount )
+ {
ent->client->ps.jumppad_frame = 0;
ent->client->ps.jumppad_ent = 0;
}
@@ -311,14 +300,15 @@ void G_TouchTriggers( gentity_t *ent ) {
SpectatorThink
=================
*/
-void SpectatorThink( gentity_t *ent, usercmd_t *ucmd ) {
+void SpectatorThink( gentity_t *ent, usercmd_t *ucmd )
+{
pmove_t pm;
gclient_t *client;
client = ent->client;
- if ( client->sess.spectatorState != SPECTATOR_FOLLOW ) {
-
+ if( client->sess.spectatorState != SPECTATOR_FOLLOW )
+ {
if( client->sess.spectatorState == SPECTATOR_LOCKED )
client->ps.pm_type = PM_FREEZE;
else
@@ -327,7 +317,7 @@ void SpectatorThink( gentity_t *ent, usercmd_t *ucmd ) {
client->ps.speed = 400; // faster than normal
// set up for pmove
- memset (&pm, 0, sizeof(pm));
+ memset( &pm, 0, sizeof( pm ) );
pm.ps = &client->ps;
pm.cmd = *ucmd;
pm.tracemask = MASK_PLAYERSOLID & ~CONTENTS_BODY; // spectators can fly through bodies
@@ -335,7 +325,7 @@ void SpectatorThink( gentity_t *ent, usercmd_t *ucmd ) {
pm.pointcontents = trap_PointContents;
// perform a pmove
- Pmove (&pm);
+ Pmove( &pm );
// save results of pmove
VectorCopy( client->ps.origin, ent->s.origin );
@@ -374,28 +364,38 @@ ClientInactivityTimer
Returns qfalse if the client is dropped
=================
*/
-qboolean ClientInactivityTimer( gclient_t *client ) {
- if ( ! g_inactivity.integer ) {
+qboolean ClientInactivityTimer( gclient_t *client )
+{
+ if( ! g_inactivity.integer )
+ {
// give everyone some time, so if the operator sets g_inactivity during
// gameplay, everyone isn't kicked
client->inactivityTime = level.time + 60 * 1000;
client->inactivityWarning = qfalse;
- } else if ( client->pers.cmd.forwardmove ||
- client->pers.cmd.rightmove ||
- client->pers.cmd.upmove ||
- (client->pers.cmd.buttons & BUTTON_ATTACK) ) {
+ }
+ else if( client->pers.cmd.forwardmove ||
+ client->pers.cmd.rightmove ||
+ client->pers.cmd.upmove ||
+ ( client->pers.cmd.buttons & BUTTON_ATTACK ) )
+ {
client->inactivityTime = level.time + g_inactivity.integer * 1000;
client->inactivityWarning = qfalse;
- } else if ( !client->pers.localClient ) {
- if ( level.time > client->inactivityTime ) {
+ }
+ else if( !client->pers.localClient )
+ {
+ if( level.time > client->inactivityTime )
+ {
trap_DropClient( client - level.clients, "Dropped due to inactivity" );
return qfalse;
}
- if ( level.time > client->inactivityTime - 10000 && !client->inactivityWarning ) {
+
+ if( level.time > client->inactivityTime - 10000 && !client->inactivityWarning )
+ {
client->inactivityWarning = qtrue;
trap_SendServerCommand( client - level.clients, "cp \"Ten seconds until inactivity drop!\n\"" );
}
}
+
return qtrue;
}
@@ -589,7 +589,8 @@ void ClientTimerActions( gentity_t *ent, int msec )
ClientIntermissionThink
====================
*/
-void ClientIntermissionThink( gclient_t *client ) {
+void ClientIntermissionThink( gclient_t *client )
+{
client->ps.eFlags &= ~EF_TALK;
client->ps.eFlags &= ~EF_FIRING;
client->ps.eFlags &= ~EF_FIRING2;
@@ -599,9 +600,8 @@ void ClientIntermissionThink( gclient_t *client ) {
// swap and latch button actions
client->oldbuttons = client->buttons;
client->buttons = client->pers.cmd.buttons;
- if ( client->buttons & ( BUTTON_ATTACK | BUTTON_USE_HOLDABLE ) & ( client->oldbuttons ^ client->buttons ) ) {
+ if( client->buttons & ( BUTTON_ATTACK | BUTTON_USE_HOLDABLE ) & ( client->oldbuttons ^ client->buttons ) )
client->readyToExit = 1;
- }
}
@@ -613,61 +613,63 @@ Events will be passed on to the clients for presentation,
but any server game effects are handled here
================
*/
-void ClientEvents( gentity_t *ent, int oldEventSequence ) {
- int i, j;
- int event;
+void ClientEvents( gentity_t *ent, int oldEventSequence )
+{
+ int i, j;
+ int event;
gclient_t *client;
- int damage;
- vec3_t dir;
- vec3_t origin, angles;
+ int damage;
+ vec3_t dir;
+ vec3_t origin, angles;
// qboolean fired;
- gitem_t *item;
+ gitem_t *item;
gentity_t *drop;
client = ent->client;
- if ( oldEventSequence < client->ps.eventSequence - MAX_PS_EVENTS ) {
+ if( oldEventSequence < client->ps.eventSequence - MAX_PS_EVENTS )
oldEventSequence = client->ps.eventSequence - MAX_PS_EVENTS;
- }
- for ( i = oldEventSequence ; i < client->ps.eventSequence ; i++ ) {
- event = client->ps.events[ i & (MAX_PS_EVENTS-1) ];
-
- switch ( event ) {
- case EV_FALL_MEDIUM:
- case EV_FALL_FAR:
- if ( ent->s.eType != ET_PLAYER ) {
- break; // not in the player model
- }
- if ( g_dmflags.integer & DF_NO_FALLING ) {
+
+ for( i = oldEventSequence; i < client->ps.eventSequence; i++ )
+ {
+ event = client->ps.events[ i & ( MAX_PS_EVENTS - 1 ) ];
+
+ switch( event )
+ {
+ case EV_FALL_MEDIUM:
+ case EV_FALL_FAR:
+ if( ent->s.eType != ET_PLAYER )
+ break; // not in the player model
+
+ if( g_dmflags.integer & DF_NO_FALLING )
+ break;
+
+ if( event == EV_FALL_FAR )
+ damage = 10;
+ else
+ damage = 5;
+
+ VectorSet( dir, 0, 0, 1 );
+ ent->pain_debounce_time = level.time + 200; // no normal pain sound
+ G_Damage( ent, NULL, NULL, NULL, NULL, damage, 0, MOD_FALLING );
break;
- }
- if ( event == EV_FALL_FAR ) {
- damage = 10;
- } else {
- damage = 5;
- }
- VectorSet (dir, 0, 0, 1);
- ent->pain_debounce_time = level.time + 200; // no normal pain sound
- G_Damage (ent, NULL, NULL, NULL, NULL, damage, 0, MOD_FALLING);
- break;
- case EV_FIRE_WEAPON:
- FireWeapon( ent );
- break;
+ case EV_FIRE_WEAPON:
+ FireWeapon( ent );
+ break;
- case EV_FIRE_WEAPON2:
- FireWeapon2( ent );
- break;
+ case EV_FIRE_WEAPON2:
+ FireWeapon2( ent );
+ break;
- case EV_FIRE_WEAPON3:
- FireWeapon3( ent );
- break;
+ case EV_FIRE_WEAPON3:
+ FireWeapon3( ent );
+ break;
- default:
- break;
+ default:
+ break;
}
}
-
}
/*
@@ -675,39 +677,49 @@ void ClientEvents( gentity_t *ent, int oldEventSequence ) {
StuckInOtherClient
==============
*/
-static int StuckInOtherClient(gentity_t *ent) {
- int i;
+static int StuckInOtherClient( gentity_t *ent )
+{
+ int i;
gentity_t *ent2;
- ent2 = &g_entities[0];
- for ( i = 0; i < MAX_CLIENTS; i++, ent2++ ) {
- if ( ent2 == ent ) {
+ ent2 = &g_entities[ 0 ];
+
+ for( i = 0; i < MAX_CLIENTS; i++, ent2++ )
+ {
+ if( ent2 == ent )
continue;
- }
- if ( !ent2->inuse ) {
+
+ if( !ent2->inuse )
continue;
- }
- if ( !ent2->client ) {
+
+ if( !ent2->client )
continue;
- }
- if ( ent2->health <= 0 ) {
+
+ if( ent2->health <= 0 )
continue;
- }
+
//
- if (ent2->r.absmin[0] > ent->r.absmax[0])
+ if( ent2->r.absmin[ 0 ] > ent->r.absmax[ 0 ] )
continue;
- if (ent2->r.absmin[1] > ent->r.absmax[1])
+
+ if( ent2->r.absmin[ 1 ] > ent->r.absmax[ 1 ] )
continue;
- if (ent2->r.absmin[2] > ent->r.absmax[2])
+
+ if( ent2->r.absmin[ 2 ] > ent->r.absmax[ 2 ] )
continue;
- if (ent2->r.absmax[0] < ent->r.absmin[0])
+
+ if( ent2->r.absmax[ 0 ] < ent->r.absmin[ 0 ] )
continue;
- if (ent2->r.absmax[1] < ent->r.absmin[1])
+
+ if( ent2->r.absmax[ 1 ] < ent->r.absmin[ 1 ] )
continue;
- if (ent2->r.absmax[2] < ent->r.absmin[2])
+
+ if( ent2->r.absmax[ 2 ] < ent->r.absmin[ 2 ] )
continue;
+
return qtrue;
- }
+ }
+
return qfalse;
}
@@ -716,16 +728,18 @@ static int StuckInOtherClient(gentity_t *ent) {
SendPendingPredictableEvents
==============
*/
-void SendPendingPredictableEvents( playerState_t *ps ) {
+void SendPendingPredictableEvents( playerState_t *ps )
+{
gentity_t *t;
- int event, seq;
- int extEvent, number;
+ int event, seq;
+ int extEvent, number;
// if there are still events pending
- if ( ps->entityEventSequence < ps->eventSequence ) {
+ if( ps->entityEventSequence < ps->eventSequence )
+ {
// create a temporary entity for this event which is sent to everyone
// except the client who generated the event
- seq = ps->entityEventSequence & (MAX_PS_EVENTS-1);
+ seq = ps->entityEventSequence & ( MAX_PS_EVENTS - 1 );
event = ps->events[ seq ] | ( ( ps->entityEventSequence & 3 ) << 8 );
// set external event to zero before calling BG_PlayerStateToEntityState
extEvent = ps->externalEvent;
@@ -757,13 +771,14 @@ If "g_synchronousClients 1" is set, this will be called exactly
once for each server frame, which makes for smooth demo recording.
==============
*/
-void ClientThink_real( gentity_t *ent ) {
+void ClientThink_real( gentity_t *ent )
+{
gclient_t *client;
pmove_t pm;
- int oldEventSequence;
- int msec;
+ int oldEventSequence;
+ int msec;
usercmd_t *ucmd;
- float speed;
+ float speed;
//TA: creep variables
gentity_t *creepNode;
@@ -774,19 +789,21 @@ void ClientThink_real( gentity_t *ent ) {
client = ent->client;
// don't think if the client is not yet connected (and thus not yet spawned in)
- if (client->pers.connected != CON_CONNECTED) {
+ if( client->pers.connected != CON_CONNECTED )
return;
- }
// mark the time, so the connection sprite can be removed
ucmd = &ent->client->pers.cmd;
// sanity check the command time to prevent speedup cheating
- if ( ucmd->serverTime > level.time + 200 ) {
+ if( ucmd->serverTime > level.time + 200 )
+ {
ucmd->serverTime = level.time + 200;
// G_Printf("serverTime <<<<<\n" );
}
- if ( ucmd->serverTime < level.time - 1000 ) {
+
+ if( ucmd->serverTime < level.time - 1000 )
+ {
ucmd->serverTime = level.time - 1000;
// G_Printf("serverTime >>>>>\n" );
}
@@ -794,22 +811,20 @@ void ClientThink_real( gentity_t *ent ) {
msec = ucmd->serverTime - client->ps.commandTime;
// following others may result in bad times, but we still want
// to check for follow toggles
- if ( msec < 1 && client->sess.spectatorState != SPECTATOR_FOLLOW ) {
+ if( msec < 1 && client->sess.spectatorState != SPECTATOR_FOLLOW )
return;
- }
- if ( msec > 200 ) {
+
+ if( msec > 200 )
msec = 200;
- }
- if ( pmove_msec.integer < 8 ) {
- trap_Cvar_Set("pmove_msec", "8");
- }
- else if (pmove_msec.integer > 33) {
- trap_Cvar_Set("pmove_msec", "33");
- }
+ if( pmove_msec.integer < 8 )
+ trap_Cvar_Set( "pmove_msec", "8" );
+ else if( pmove_msec.integer > 33 )
+ trap_Cvar_Set( "pmove_msec", "33" );
- if ( pmove_fixed.integer || client->pers.pmoveFixed ) {
- ucmd->serverTime = ((ucmd->serverTime + pmove_msec.integer-1) / pmove_msec.integer) * pmove_msec.integer;
+ if( pmove_fixed.integer || client->pers.pmoveFixed )
+ {
+ ucmd->serverTime = ( ( ucmd->serverTime + pmove_msec.integer - 1 ) / pmove_msec.integer ) * pmove_msec.integer;
//if (ucmd->serverTime - client->ps.commandTime <= 0)
// return;
}
@@ -817,24 +832,25 @@ void ClientThink_real( gentity_t *ent ) {
//
// check for exiting intermission
//
- if ( level.intermissiontime ) {
+ if( level.intermissiontime )
+ {
ClientIntermissionThink( client );
return;
}
// spectators don't do much
- if ( client->sess.sessionTeam == TEAM_SPECTATOR ) {
- if ( client->sess.spectatorState == SPECTATOR_SCOREBOARD ) {
+ if( client->sess.sessionTeam == TEAM_SPECTATOR )
+ {
+ if( client->sess.spectatorState == SPECTATOR_SCOREBOARD )
return;
- }
+
SpectatorThink( ent, ucmd );
return;
}
// check for inactivity timer, but never drop the local client of a non-dedicated server
- if ( !ClientInactivityTimer( client ) ) {
+ if( !ClientInactivityTimer( client ) )
return;
- }
if( client->noclip )
client->ps.pm_type = PM_NOCLIP;
@@ -943,16 +959,6 @@ void ClientThink_real( gentity_t *ent ) {
if( !cSlowed )
client->ps.stats[ STAT_STATE ] &= ~SS_CREEPSLOWED;
- /*if ( client->ps.powerups[PW_HASTE] ) {
- client->ps.speed *= 1.3;
- }*/
-
- // Let go of the hook if we aren't firing
-/* if ( client->ps.weapon == WP_GRAPPLING_HOOK &&
- client->hook && !( ucmd->buttons & BUTTON_ATTACK ) ) {
- Weapon_HookFree(client->hook);
- }*/
-
// set up for pmove
oldEventSequence = client->ps.eventSequence;
@@ -969,8 +975,7 @@ void ClientThink_real( gentity_t *ent ) {
case WP_GRAB_CLAW:
case WP_GRAB_CLAW_UPG:
- /*if( client->ps.weaponTime <= 0 )*/ //FIXME: correct decision?
- CheckGrabAttack( ent );
+ CheckGrabAttack( ent );
break;
case WP_POUNCE:
@@ -984,26 +989,24 @@ void ClientThink_real( gentity_t *ent ) {
}
}
- if ( ent->flags & FL_FORCE_GESTURE ) {
+ if( ent->flags & FL_FORCE_GESTURE )
+ {
ent->flags &= ~FL_FORCE_GESTURE;
ent->client->pers.cmd.buttons |= BUTTON_GESTURE;
}
pm.ps = &client->ps;
pm.cmd = *ucmd;
- if ( pm.ps->pm_type == PM_DEAD ) {
+
+ if( pm.ps->pm_type == PM_DEAD )
pm.tracemask = MASK_PLAYERSOLID; // & ~CONTENTS_BODY;
- }
+
if( pm.ps->stats[ STAT_STATE ] & SS_INFESTING ||
pm.ps->stats[ STAT_STATE ] & SS_HOVELING )
pm.tracemask = MASK_PLAYERSOLID & ~CONTENTS_BODY;
-
- else if ( ent->r.svFlags & SVF_BOT ) {
- pm.tracemask = MASK_PLAYERSOLID | CONTENTS_BOTCLIP;
- }
- else {
+ else
pm.tracemask = MASK_PLAYERSOLID;
- }
+
pm.trace = trap_Trace;
pm.pointcontents = trap_PointContents;
pm.debugLevel = g_debugMove.integer;
@@ -1014,18 +1017,17 @@ void ClientThink_real( gentity_t *ent ) {
VectorCopy( client->ps.origin, client->oldOrigin );
- Pmove (&pm);
+ Pmove( &pm);
// save results of pmove
- if ( ent->client->ps.eventSequence != oldEventSequence ) {
+ if( ent->client->ps.eventSequence != oldEventSequence )
ent->eventTime = level.time;
- }
- if (g_smoothClients.integer) {
+
+ if( g_smoothClients.integer )
BG_PlayerStateToEntityStateExtraPolate( &ent->client->ps, &ent->s, ent->client->ps.commandTime, qtrue );
- }
- else {
+ else
BG_PlayerStateToEntityState( &ent->client->ps, &ent->s, qtrue );
- }
+
SendPendingPredictableEvents( &ent->client->ps );
if( !( ent->client->ps.eFlags & EF_FIRING ) )
@@ -1036,8 +1038,8 @@ void ClientThink_real( gentity_t *ent ) {
// use the snapped origin for linking so it matches client predicted versions
VectorCopy( ent->s.pos.trBase, ent->r.currentOrigin );
- VectorCopy (pm.mins, ent->r.mins);
- VectorCopy (pm.maxs, ent->r.maxs);
+ VectorCopy( pm.mins, ent->r.mins );
+ VectorCopy( pm.maxs, ent->r.maxs );
ent->waterlevel = pm.waterlevel;
ent->watertype = pm.watertype;
@@ -1046,10 +1048,10 @@ void ClientThink_real( gentity_t *ent ) {
ClientEvents( ent, oldEventSequence );
// link entity now, after any personal teleporters have been used
- trap_LinkEntity (ent);
- if ( !ent->client->noclip ) {
+ trap_LinkEntity( ent );
+
+ if( !ent->client->noclip )
G_TouchTriggers( ent );
- }
// NOTE: now copy the exact origin over otherwise clients can be snapped into solid
VectorCopy( ent->client->ps.origin, ent->r.currentOrigin );
@@ -1058,9 +1060,8 @@ void ClientThink_real( gentity_t *ent ) {
ClientImpacts( ent, &pm );
// save results of triggers and client events
- if (ent->client->ps.eventSequence != oldEventSequence) {
+ if( ent->client->ps.eventSequence != oldEventSequence )
ent->eventTime = level.time;
- }
// swap and latch button actions
client->oldbuttons = client->buttons;
@@ -1171,7 +1172,8 @@ ClientThink
A new command has arrived from the client
==================
*/
-void ClientThink( int clientNum ) {
+void ClientThink( int clientNum )
+{
gentity_t *ent;
ent = g_entities + clientNum;
@@ -1181,16 +1183,16 @@ void ClientThink( int clientNum ) {
// phone jack if they don't get any for a while
ent->client->lastCmdTime = level.time;
- if ( !(ent->r.svFlags & SVF_BOT) && !g_synchronousClients.integer ) {
+ if( !(ent->r.svFlags & SVF_BOT) && !g_synchronousClients.integer )
ClientThink_real( ent );
- }
}
-void G_RunClient( gentity_t *ent ) {
- if ( !(ent->r.svFlags & SVF_BOT) && !g_synchronousClients.integer ) {
+void G_RunClient( gentity_t *ent )
+{
+ if( !( ent->r.svFlags & SVF_BOT ) && !g_synchronousClients.integer )
return;
- }
+
ent->client->pers.cmd.serverTime = level.time;
ClientThink_real( ent );
}
@@ -1202,32 +1204,40 @@ SpectatorClientEndFrame
==================
*/
-void SpectatorClientEndFrame( gentity_t *ent ) {
+void SpectatorClientEndFrame( gentity_t *ent )
+{
gclient_t *cl;
// if we are doing a chase cam or a remote view, grab the latest info
- if ( ent->client->sess.spectatorState == SPECTATOR_FOLLOW ) {
+ if( ent->client->sess.spectatorState == SPECTATOR_FOLLOW )
+ {
int clientNum, flags;
clientNum = ent->client->sess.spectatorClient;
// team follow1 and team follow2 go to whatever clients are playing
- if ( clientNum == -1 ) {
+ if( clientNum == -1 )
clientNum = level.follow1;
- } else if ( clientNum == -2 ) {
+ else if( clientNum == -2 )
clientNum = level.follow2;
- }
- if ( clientNum >= 0 ) {
+
+ if( clientNum >= 0 )
+ {
cl = &level.clients[ clientNum ];
- if ( cl->pers.connected == CON_CONNECTED && cl->sess.sessionTeam != TEAM_SPECTATOR ) {
- flags = (cl->ps.eFlags & ~(EF_VOTED | EF_TEAMVOTED)) | (ent->client->ps.eFlags & (EF_VOTED | EF_TEAMVOTED));
+
+ if( cl->pers.connected == CON_CONNECTED && cl->sess.sessionTeam != TEAM_SPECTATOR )
+ {
+ flags = ( cl->ps.eFlags & ~( EF_VOTED | EF_TEAMVOTED ) ) | ( ent->client->ps.eFlags & ( EF_VOTED | EF_TEAMVOTED ) );
ent->client->ps = cl->ps;
ent->client->ps.pm_flags |= PMF_FOLLOW;
ent->client->ps.eFlags = flags;
return;
- } else {
+ }
+ else
+ {
// drop them to free spectators unless they are dedicated camera followers
- if ( ent->client->sess.spectatorClient >= 0 ) {
+ if( ent->client->sess.spectatorClient >= 0 )
+ {
ent->client->sess.spectatorState = SPECTATOR_FREE;
ClientBegin( ent->client - level.clients );
}
@@ -1235,11 +1245,10 @@ void SpectatorClientEndFrame( gentity_t *ent ) {
}
}
- if ( ent->client->sess.spectatorState == SPECTATOR_SCOREBOARD ) {
+ if( ent->client->sess.spectatorState == SPECTATOR_SCOREBOARD )
ent->client->ps.pm_flags |= PMF_SCOREBOARD;
- } else {
+ else
ent->client->ps.pm_flags &= ~PMF_SCOREBOARD;
- }
}
/*
@@ -1251,69 +1260,49 @@ A fast client will have multiple ClientThink for each ClientEdFrame,
while a slow client may have multiple ClientEndFrame between ClientThink.
==============
*/
-void ClientEndFrame( gentity_t *ent ) {
- int i;
+void ClientEndFrame( gentity_t *ent )
+{
+ int i;
clientPersistant_t *pers;
- if ( ent->client->sess.sessionTeam == TEAM_SPECTATOR ) {
+ if( ent->client->sess.sessionTeam == TEAM_SPECTATOR )
+ {
SpectatorClientEndFrame( ent );
return;
}
pers = &ent->client->pers;
- // turn off any expired powerups
-/* for ( i = 0 ; i < MAX_POWERUPS ; i++ ) {
- if ( ent->client->ps.powerups[ i ] < level.time ) {
- ent->client->ps.powerups[ i ] = 0;
- }
- }*/
-
- // save network bandwidth
-#if 0
- if ( !g_synchronousClients->integer && ent->client->ps.pm_type == PM_NORMAL ) {
- // FIXME: this must change eventually for non-sync demo recording
- VectorClear( ent->client->ps.viewangles );
- }
-#endif
-
//
// If the end of unit layout is displayed, don't give
// the player any normal movement attributes
//
- if ( level.intermissiontime ) {
+ if( level.intermissiontime )
return;
- }
// burn from lava, etc
- P_WorldEffects (ent);
+ P_WorldEffects( ent );
// apply all the damage taken this frame
- P_DamageFeedback (ent);
+ P_DamageFeedback( ent );
// add the EF_CONNECTION flag if we haven't gotten commands recently
- if ( level.time - ent->client->lastCmdTime > 1000 ) {
+ if( level.time - ent->client->lastCmdTime > 1000 )
ent->s.eFlags |= EF_CONNECTION;
- } else {
+ else
ent->s.eFlags &= ~EF_CONNECTION;
- }
- ent->client->ps.stats[STAT_HEALTH] = ent->health; // FIXME: get rid of ent->health...
+ ent->client->ps.stats[ STAT_HEALTH ] = ent->health; // FIXME: get rid of ent->health...
- G_SetClientSound (ent);
+ G_SetClientSound( ent );
// set the latest infor
- if (g_smoothClients.integer) {
+ if( g_smoothClients.integer )
BG_PlayerStateToEntityStateExtraPolate( &ent->client->ps, &ent->s, ent->client->ps.commandTime, qtrue );
- }
- else {
+ else
BG_PlayerStateToEntityState( &ent->client->ps, &ent->s, qtrue );
- }
+
SendPendingPredictableEvents( &ent->client->ps );
-
- // set the bit for the reachability area the client is currently in
- // i = trap_AAS_PointReachabilityAreaIndex( ent->client->ps.origin );
- // ent->client->areabits[i >> 3] |= 1 << (i & 7);
}
diff --git a/src/game/g_buildable.c b/src/game/g_buildable.c
index 93d5619d..43690497 100644
--- a/src/game/g_buildable.c
+++ b/src/game/g_buildable.c
@@ -1334,7 +1334,7 @@ void HFM_Die( gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int da
//pretty events and item cleanup
self->s.modelindex = 0; //don't draw the model once its destroyed
- G_AddEvent( self, EV_ITEM_EXPLOSION, DirToByte( dir ) );
+ G_AddEvent( self, EV_BUILDABLE_EXPLOSION, DirToByte( dir ) );
self->r.contents = CONTENTS_TRIGGER;
self->timestamp = level.time;
@@ -1366,130 +1366,18 @@ void HFM_Think( gentity_t *self )
//==================================================================================
-
-
-
-//TA: the following defense turret code was written by
-// "fuzzysteve" (fuzzysteve@quakefiles.com) and
-// Anthony "inolen" Pesch (www.inolen.com)
-//with (heavy) modifications by me of course :)
-
-#define HDEF1_ANGULARSPEED 10 //degrees/think ~= 200deg/sec
-#define HDEF1_ACCURACYTOLERANCE HDEF1_ANGULARSPEED / 2 //angular difference for turret to fire
-#define HDEF1_VERTICALCAP 90 //+/- maximum pitch
-#define HDEF1_PROJSPEED 2000.0f //speed of projectile (used in prediction)
-
-/*
-================
-hdef1_trackenemy
-
-Used by HDef1_Think to track enemy location
-================
-*/
-qboolean hdef1_trackenemy( gentity_t *self )
-{
- vec3_t dirToTarget, dttAdjusted, angleToTarget, angularDiff, xNormal;
- vec3_t refNormal = { 0.0f, 0.0f, 1.0f };
- float temp, rotAngle;
- float distanceToTarget = BG_FindRangeForBuildable( self->s.modelindex );
- float timeTilImpact;
- vec3_t halfAcceleration;
- vec3_t thirdJerk;
- int i;
-
- VectorSubtract( self->enemy->s.pos.trBase, self->s.pos.trBase, dirToTarget );
-
-//lead targets
-#if 0
- distanceToTarget = VectorLength( dirToTarget );
- timeTilImpact = distanceToTarget / 2000.0f;
- VectorMA( self->enemy->s.pos.trBase, timeTilImpact, self->enemy->s.pos.trDelta, dirToTarget );
- VectorSubtract( dirToTarget, self->s.pos.trBase, dirToTarget );
-#endif
-
- //better, but more expensive method
- if( self->dcced )
- {
- VectorScale( self->enemy->acceleration, 1.0f / 2.0f, halfAcceleration );
- VectorScale( self->enemy->jerk, 1.0f / 3.0f, thirdJerk );
-
- //O( time ) - worst case O( time ) = 250 iterations
- for( i = 0; ( i * HDEF1_PROJSPEED ) / 1000.0f < distanceToTarget; i++ )
- {
- float time = (float)i / 1000.0f;
-
- VectorMA( self->enemy->s.pos.trBase, time, self->enemy->s.pos.trDelta, dirToTarget );
- VectorMA( dirToTarget, time * time, halfAcceleration, dirToTarget );
- VectorMA( dirToTarget, time * time * time, thirdJerk, dirToTarget );
- VectorSubtract( dirToTarget, self->s.pos.trBase, dirToTarget );
- distanceToTarget = VectorLength( dirToTarget );
-
- distanceToTarget -= self->enemy->r.maxs[ 0 ];
- }
- }
-
- VectorNormalize( dirToTarget );
-
- CrossProduct( self->s.origin2, refNormal, xNormal );
- VectorNormalize( xNormal );
- rotAngle = RAD2DEG( acos( DotProduct( self->s.origin2, refNormal ) ) );
- RotatePointAroundVector( dttAdjusted, xNormal, dirToTarget, rotAngle );
-
- vectoangles( dttAdjusted, angleToTarget );
-
- angularDiff[ PITCH ] = AngleSubtract( self->s.angles2[ PITCH ], angleToTarget[ PITCH ] );
- angularDiff[ YAW ] = AngleSubtract( self->s.angles2[ YAW ], angleToTarget[ YAW ] );
-
- //if not pointing at our target then move accordingly
- if( angularDiff[ PITCH ] < -HDEF1_ACCURACYTOLERANCE )
- self->s.angles2[ PITCH ] += HDEF1_ANGULARSPEED;
- else if( angularDiff[ PITCH ] > HDEF1_ACCURACYTOLERANCE )
- self->s.angles2[ PITCH ] -= HDEF1_ANGULARSPEED;
- else
- self->s.angles2[ PITCH ] = angleToTarget[ PITCH ];
-
- //disallow vertical movement past a certain limit
- temp = fabs( self->s.angles2[ PITCH ] );
- if( temp > 180 )
- temp -= 360;
-
- if( temp < -HDEF1_VERTICALCAP )
- self->s.angles2[ PITCH ] = (-360)+HDEF1_VERTICALCAP;
- else if( temp > HDEF1_VERTICALCAP )
- self->s.angles2[ PITCH ] = -HDEF1_VERTICALCAP;
-
- //if not pointing at our target then move accordingly
- if( angularDiff[ YAW ] < -HDEF1_ACCURACYTOLERANCE )
- self->s.angles2[ YAW ] += HDEF1_ANGULARSPEED;
- else if( angularDiff[ YAW ] > HDEF1_ACCURACYTOLERANCE )
- self->s.angles2[ YAW ] -= HDEF1_ANGULARSPEED;
- else
- self->s.angles2[ YAW ] = angleToTarget[ YAW ];
-
- AngleVectors( self->s.angles2, dttAdjusted, NULL, NULL );
- RotatePointAroundVector( dirToTarget, xNormal, dttAdjusted, -rotAngle );
- vectoangles( dirToTarget, self->turretAim );
-
- //if pointing at our target return true
- if( abs( angleToTarget[ YAW ] - self->s.angles2[ YAW ] ) <= HDEF1_ACCURACYTOLERANCE &&
- abs( angleToTarget[ PITCH ] - self->s.angles2[ PITCH ] ) <= HDEF1_ACCURACYTOLERANCE )
- return qtrue;
-
- return qfalse;
-}
-
-#define HDEF2_ANGULARSPEED 20 //degrees/think ~= 200deg/sec
-#define HDEF2_ACCURACYTOLERANCE HDEF2_ANGULARSPEED / 2 //angular difference for turret to fire
-#define HDEF2_VERTICALCAP 30 //- maximum pitch
+#define HMGTURRET_ANGULARSPEED 20 //degrees/think ~= 200deg/sec
+#define HMGTURRET_ACCURACYTOLERANCE HMGTURRET_ANGULARSPEED / 2 //angular difference for turret to fire
+#define HMGTURRET_VERTICALCAP 30 //- maximum pitch
/*
================
-hdef2_trackenemy
+HMGTurret_TrackEnemy
-Used by HDef1_Think to track enemy location
+Used by HDef_Think to track enemy location
================
*/
-qboolean hdef2_trackenemy( gentity_t *self )
+qboolean HMGTurret_TrackEnemy( gentity_t *self )
{
vec3_t dirToTarget, dttAdjusted, angleToTarget, angularDiff, xNormal;
vec3_t refNormal = { 0.0f, 0.0f, 1.0f };
@@ -1510,10 +1398,10 @@ qboolean hdef2_trackenemy( gentity_t *self )
angularDiff[ YAW ] = AngleSubtract( self->s.angles2[ YAW ], angleToTarget[ YAW ] );
//if not pointing at our target then move accordingly
- if( angularDiff[ PITCH ] < -HDEF2_ACCURACYTOLERANCE )
- self->s.angles2[ PITCH ] += HDEF2_ANGULARSPEED;
- else if( angularDiff[ PITCH ] > HDEF2_ACCURACYTOLERANCE )
- self->s.angles2[ PITCH ] -= HDEF2_ANGULARSPEED;
+ if( angularDiff[ PITCH ] < -HMGTURRET_ACCURACYTOLERANCE )
+ self->s.angles2[ PITCH ] += HMGTURRET_ANGULARSPEED;
+ else if( angularDiff[ PITCH ] > HMGTURRET_ACCURACYTOLERANCE )
+ self->s.angles2[ PITCH ] -= HMGTURRET_ANGULARSPEED;
else
self->s.angles2[ PITCH ] = angleToTarget[ PITCH ];
@@ -1522,14 +1410,14 @@ qboolean hdef2_trackenemy( gentity_t *self )
if( temp > 180 )
temp -= 360;
- if( temp < -HDEF2_VERTICALCAP )
- self->s.angles2[ PITCH ] = (-360)+HDEF2_VERTICALCAP;
+ if( temp < -HMGTURRET_VERTICALCAP )
+ self->s.angles2[ PITCH ] = (-360)+HMGTURRET_VERTICALCAP;
//if not pointing at our target then move accordingly
- if( angularDiff[ YAW ] < -HDEF2_ACCURACYTOLERANCE )
- self->s.angles2[ YAW ] += HDEF2_ANGULARSPEED;
- else if( angularDiff[ YAW ] > HDEF2_ACCURACYTOLERANCE )
- self->s.angles2[ YAW ] -= HDEF2_ANGULARSPEED;
+ if( angularDiff[ YAW ] < -HMGTURRET_ACCURACYTOLERANCE )
+ self->s.angles2[ YAW ] += HMGTURRET_ANGULARSPEED;
+ else if( angularDiff[ YAW ] > HMGTURRET_ACCURACYTOLERANCE )
+ self->s.angles2[ YAW ] -= HMGTURRET_ANGULARSPEED;
else
self->s.angles2[ YAW ] = angleToTarget[ YAW ];
@@ -1538,8 +1426,8 @@ qboolean hdef2_trackenemy( gentity_t *self )
vectoangles( dirToTarget, self->turretAim );
//if pointing at our target return true
- if( abs( angleToTarget[ YAW ] - self->s.angles2[ YAW ] ) <= HDEF2_ACCURACYTOLERANCE &&
- abs( angleToTarget[ PITCH ] - self->s.angles2[ PITCH ] ) <= HDEF2_ACCURACYTOLERANCE )
+ if( abs( angleToTarget[ YAW ] - self->s.angles2[ YAW ] ) <= HMGTURRET_ACCURACYTOLERANCE &&
+ abs( angleToTarget[ PITCH ] - self->s.angles2[ PITCH ] ) <= HMGTURRET_ACCURACYTOLERANCE )
return qtrue;
return qfalse;
@@ -1547,12 +1435,12 @@ qboolean hdef2_trackenemy( gentity_t *self )
/*
================
-hdef3_fireonemeny
+HTeslaGen_FireOnEnemy
Used by HDef_Think to fire at enemy
================
*/
-void hdef3_fireonenemy( gentity_t *self, int firespeed )
+void HTeslaGen_FireOnEnemy( gentity_t *self, int firespeed )
{
vec3_t dirToTarget;
@@ -1572,12 +1460,12 @@ void hdef3_fireonenemy( gentity_t *self, int firespeed )
/*
================
-hdef_fireonemeny
+HMGTurret_FireOnEnemy
Used by HDef_Think to fire at enemy
================
*/
-void hdef_fireonenemy( gentity_t *self, int firespeed )
+void HMGTurret_FireOnEnemy( gentity_t *self, int firespeed )
{
//fire at target
FireWeapon( self );
@@ -1587,12 +1475,12 @@ void hdef_fireonenemy( gentity_t *self, int firespeed )
/*
================
-hdef_checktarget
+HDef_CheckTarget
Used by HDef_Think to check enemies for validity
================
*/
-qboolean hdef_checktarget( gentity_t *self, gentity_t *target, int range )
+qboolean HDef_CheckTarget( gentity_t *self, gentity_t *target, int range )
{
vec3_t distance;
trace_t trace;
@@ -1632,12 +1520,12 @@ qboolean hdef_checktarget( gentity_t *self, gentity_t *target, int range )
/*
================
-hdef_findenemy
+HDef_FindEnemy
Used by HDef_Think to locate enemy gentities
================
*/
-void hdef_findenemy( gentity_t *ent, int range )
+void HDef_FindEnemy( gentity_t *ent, int range )
{
gentity_t *target;
@@ -1645,7 +1533,7 @@ void hdef_findenemy( gentity_t *ent, int range )
for( target = g_entities; target < &g_entities[ level.num_entities ]; target++ )
{
//if target is not valid keep searching
- if( !hdef_checktarget( ent, target, range ) )
+ if( !HDef_CheckTarget( ent, target, range ) )
continue;
//we found a target
@@ -1683,12 +1571,12 @@ void HDef_Think( gentity_t *self )
self->dcced = findDCC( self );
//if the current target is not valid find a new one
- if( !hdef_checktarget( self, self->enemy, range ) )
+ if( !HDef_CheckTarget( self, self->enemy, range ) )
{
if( self->enemy )
self->enemy->targeted = NULL;
- hdef_findenemy( self, range );
+ HDef_FindEnemy( self, range );
}
//if a new target cannot be found don't do anything
@@ -1700,19 +1588,14 @@ void HDef_Think( gentity_t *self )
//if we are pointing at our target and we can fire shoot it
switch( self->s.modelindex )
{
- case BA_H_DEF1:
- if( hdef1_trackenemy( self ) && ( self->count < level.time ) )
- hdef_fireonenemy( self, firespeed );
- break;
-
- case BA_H_DEF2:
- if( hdef2_trackenemy( self ) && ( self->count < level.time ) )
- hdef_fireonenemy( self, firespeed );
+ case BA_H_MGTURRET:
+ if( HMGTurret_TrackEnemy( self ) && ( self->count < level.time ) )
+ HMGTurret_FireOnEnemy( self, firespeed );
break;
- case BA_H_DEF3:
+ case BA_H_TESLAGEN:
if( self->count < level.time )
- hdef3_fireonenemy( self, firespeed );
+ HTeslaGen_FireOnEnemy( self, firespeed );
break;
default:
@@ -1746,7 +1629,7 @@ void HSpawn_Blast( gentity_t *self )
dir[2] = 1;
self->s.modelindex = 0; //don't draw the model once its destroyed
- G_AddEvent( self, EV_ITEM_EXPLOSION, DirToByte( dir ) );
+ G_AddEvent( self, EV_BUILDABLE_EXPLOSION, DirToByte( dir ) );
self->r.contents = CONTENTS_TRIGGER;
self->timestamp = level.time;
@@ -2096,9 +1979,8 @@ gentity_t *G_buildItem( gentity_t *builder, buildable_t buildable, vec3_t origin
built->think = HSpawn_Think;
break;
- case BA_H_DEF1:
- case BA_H_DEF2:
- case BA_H_DEF3:
+ case BA_H_MGTURRET:
+ case BA_H_TESLAGEN:
built->die = HSpawn_Die;
built->think = HDef_Think;
break;
diff --git a/src/game/g_client.c b/src/game/g_client.c
index fc469041..b880d352 100644
--- a/src/game/g_client.c
+++ b/src/game/g_client.c
@@ -28,23 +28,25 @@ Targets will be fired when someone spawns in on them.
"nobots" will prevent bots from using this spot.
"nohumans" will prevent non-bots from using this spot.
*/
-void SP_info_player_deathmatch( gentity_t *ent ) {
+void SP_info_player_deathmatch( gentity_t *ent )
+{
int i;
G_SpawnInt( "nobots", "0", &i);
- if ( i ) {
+
+ if( i )
ent->flags |= FL_NO_BOTS;
- }
+
G_SpawnInt( "nohumans", "0", &i );
- if ( i ) {
+ if( i )
ent->flags |= FL_NO_HUMANS;
- }
}
/*QUAKED info_player_start (1 0 0) (-16 -16 -24) (16 16 32)
equivelant to info_player_deathmatch
*/
-void SP_info_player_start(gentity_t *ent) {
+void SP_info_player_start( gentity_t *ent )
+{
ent->classname = "info_player_deathmatch";
SP_info_player_deathmatch( ent );
}
@@ -52,22 +54,22 @@ void SP_info_player_start(gentity_t *ent) {
/*QUAKED info_player_intermission (1 0 1) (-16 -16 -24) (16 16 32)
The intermission will be viewed from this point. Target an info_notnull for the view direction.
*/
-void SP_info_player_intermission( gentity_t *ent ) {
-
+void SP_info_player_intermission( gentity_t *ent )
+{
}
/*QUAKED info_alien_intermission (1 0 1) (-16 -16 -24) (16 16 32)
The intermission will be viewed from this point. Target an info_notnull for the view direction.
*/
-void SP_info_alien_intermission( gentity_t *ent ) {
-
+void SP_info_alien_intermission( gentity_t *ent )
+{
}
/*QUAKED info_human_intermission (1 0 1) (-16 -16 -24) (16 16 32)
The intermission will be viewed from this point. Target an info_notnull for the view direction.
*/
-void SP_info_human_intermission( gentity_t *ent ) {
-
+void SP_info_human_intermission( gentity_t *ent )
+{
}
@@ -86,9 +88,10 @@ SpotWouldTelefrag
================
*/
-qboolean SpotWouldTelefrag( gentity_t *spot ) {
- int i, num;
- int touch[MAX_GENTITIES];
+qboolean SpotWouldTelefrag( gentity_t *spot )
+{
+ int i, num;
+ int touch[ MAX_GENTITIES ];
gentity_t *hit;
vec3_t mins, maxs;
@@ -96,13 +99,12 @@ qboolean SpotWouldTelefrag( gentity_t *spot ) {
VectorAdd( spot->s.origin, playerMaxs, maxs );
num = trap_EntitiesInBox( mins, maxs, touch, MAX_GENTITIES );
- for (i=0 ; i<num ; i++) {
- hit = &g_entities[touch[i]];
+ for( i = 0; i < num; i++ )
+ {
+ hit = &g_entities[ touch[ i ] ];
//if ( hit->client && hit->client->ps.stats[STAT_HEALTH] > 0 ) {
- if( hit->client ) {
+ if( hit->client )
return qtrue;
- }
-
}
return qfalse;
@@ -116,21 +118,24 @@ Find the spot that we DON'T want to use
================
*/
#define MAX_SPAWN_POINTS 128
-gentity_t *SelectNearestDeathmatchSpawnPoint( vec3_t from ) {
+gentity_t *SelectNearestDeathmatchSpawnPoint( vec3_t from )
+{
gentity_t *spot;
vec3_t delta;
- float dist, nearestDist;
+ float dist, nearestDist;
gentity_t *nearestSpot;
nearestDist = 999999;
nearestSpot = NULL;
spot = NULL;
- while ((spot = G_Find (spot, FOFS(classname), "info_player_deathmatch")) != NULL) {
-
+ while( (spot = G_Find( spot, FOFS( classname ), "info_player_deathmatch" ) ) != NULL )
+ {
VectorSubtract( spot->s.origin, from, delta );
dist = VectorLength( delta );
- if ( dist < nearestDist ) {
+
+ if( dist < nearestDist )
+ {
nearestDist = dist;
nearestSpot = spot;
}
@@ -148,28 +153,29 @@ go to a random point that doesn't telefrag
================
*/
#define MAX_SPAWN_POINTS 128
-gentity_t *SelectRandomDeathmatchSpawnPoint( void ) {
+gentity_t *SelectRandomDeathmatchSpawnPoint( void )
+{
gentity_t *spot;
- int count;
- int selection;
- gentity_t *spots[MAX_SPAWN_POINTS];
+ int count;
+ int selection;
+ gentity_t *spots[ MAX_SPAWN_POINTS ];
count = 0;
spot = NULL;
- while ((spot = G_Find (spot, FOFS(classname), "info_player_deathmatch")) != NULL) {
- if ( SpotWouldTelefrag( spot ) ) {
+ while( ( spot = G_Find( spot, FOFS( classname ), "info_player_deathmatch" ) ) != NULL )
+ {
+ if( SpotWouldTelefrag( spot ) )
continue;
- }
+
spots[ count ] = spot;
count++;
}
- if ( !count ) { // no spots that won't telefrag
- return G_Find( NULL, FOFS(classname), "info_player_deathmatch");
- }
+ if( !count ) // no spots that won't telefrag
+ return G_Find( NULL, FOFS( classname ), "info_player_deathmatch" );
- selection = rand() % count;
+ selection = rand( ) % count;
return spots[ selection ];
}
@@ -181,63 +187,79 @@ SelectRandomFurthestSpawnPoint
Chooses a player start, deathmatch start, etc
============
*/
-gentity_t *SelectRandomFurthestSpawnPoint ( vec3_t avoidPoint, vec3_t origin, vec3_t angles ) {
+gentity_t *SelectRandomFurthestSpawnPoint ( vec3_t avoidPoint, vec3_t origin, vec3_t angles )
+{
gentity_t *spot;
vec3_t delta;
- float dist;
- float list_dist[64];
- gentity_t *list_spot[64];
- int numSpots, rnd, i, j;
+ float dist;
+ float list_dist[ 64 ];
+ gentity_t *list_spot[ 64 ];
+ int numSpots, rnd, i, j;
numSpots = 0;
spot = NULL;
- while ((spot = G_Find (spot, FOFS(classname), "info_player_deathmatch")) != NULL) {
- if ( SpotWouldTelefrag( spot ) ) {
+ while( ( spot = G_Find( spot, FOFS( classname ), "info_player_deathmatch" ) ) != NULL )
+ {
+ if( SpotWouldTelefrag( spot ) )
continue;
- }
+
VectorSubtract( spot->s.origin, avoidPoint, delta );
dist = VectorLength( delta );
- for (i = 0; i < numSpots; i++) {
- if ( dist > list_dist[i] ) {
- if ( numSpots >= 64 )
- numSpots = 64-1;
- for (j = numSpots; j > i; j--) {
- list_dist[j] = list_dist[j-1];
- list_spot[j] = list_spot[j-1];
+
+ for( i = 0; i < numSpots; i++ )
+ {
+ if( dist > list_dist[ i ] )
+ {
+ if( numSpots >= 64 )
+ numSpots = 64 - 1;
+
+ for( j = numSpots; j > i; j-- )
+ {
+ list_dist[ j ] = list_dist[ j - 1 ];
+ list_spot[ j ] = list_spot[ j - 1 ];
}
- list_dist[i] = dist;
- list_spot[i] = spot;
+
+ list_dist[ i ] = dist;
+ list_spot[ i ] = spot;
numSpots++;
- if (numSpots > 64)
+
+ if( numSpots > 64 )
numSpots = 64;
+
break;
}
}
- if (i >= numSpots && numSpots < 64) {
- list_dist[numSpots] = dist;
- list_spot[numSpots] = spot;
+
+ if( i >= numSpots && numSpots < 64 )
+ {
+ list_dist[ numSpots ] = dist;
+ list_spot[ numSpots ] = spot;
numSpots++;
}
}
- if (!numSpots) {
- spot = G_Find( NULL, FOFS(classname), "info_player_deathmatch");
- if (!spot)
+
+ if( !numSpots )
+ {
+ spot = G_Find( NULL, FOFS( classname ), "info_player_deathmatch" );
+
+ if( !spot )
G_Error( "Couldn't find a spawn point" );
- VectorCopy (spot->s.origin, origin);
- origin[2] += 9;
- VectorCopy (spot->s.angles, angles);
+
+ VectorCopy( spot->s.origin, origin );
+ origin[ 2 ] += 9;
+ VectorCopy( spot->s.angles, angles );
return spot;
}
// select a random spot from the spawn points furthest away
- rnd = random() * (numSpots / 2);
+ rnd = random( ) * ( numSpots / 2 );
- VectorCopy (list_spot[rnd]->s.origin, origin);
- origin[2] += 9;
- VectorCopy (list_spot[rnd]->s.angles, angles);
+ VectorCopy( list_spot[ rnd ]->s.origin, origin );
+ origin[ 2 ] += 9;
+ VectorCopy( list_spot[ rnd ]->s.angles, angles );
- return list_spot[rnd];
+ return list_spot[ rnd ];
}
@@ -313,7 +335,8 @@ SelectHumanSpawnPoint
go to a random point that doesn't telefrag
================
*/
-gentity_t *SelectHumanSpawnPoint( void ) {
+gentity_t *SelectHumanSpawnPoint( void )
+{
gentity_t *spot;
int count;
int selection;
@@ -374,7 +397,8 @@ SelectSpawnPoint
Chooses a player start, deathmatch start, etc
============
*/
-gentity_t *SelectSpawnPoint ( vec3_t avoidPoint, vec3_t origin, vec3_t angles ) {
+gentity_t *SelectSpawnPoint( vec3_t avoidPoint, vec3_t origin, vec3_t angles )
+{
return SelectRandomFurthestSpawnPoint( avoidPoint, origin, angles );
/*
@@ -465,23 +489,25 @@ Try to find a spawn point marked 'initial', otherwise
use normal spawn selection.
============
*/
-gentity_t *SelectInitialSpawnPoint( vec3_t origin, vec3_t angles ) {
+gentity_t *SelectInitialSpawnPoint( vec3_t origin, vec3_t angles )
+{
gentity_t *spot;
spot = NULL;
- while ((spot = G_Find (spot, FOFS(classname), "info_player_deathmatch")) != NULL) {
- if ( spot->spawnflags & 1 ) {
+ while( ( spot = G_Find( spot, FOFS( classname ), "info_player_deathmatch" ) ) != NULL )
+ {
+ if( spot->spawnflags & 1 )
break;
- }
}
- if ( !spot || SpotWouldTelefrag( spot ) ) {
+ if( !spot || SpotWouldTelefrag( spot ) )
+ {
return SelectSpawnPoint( vec3_origin, origin, angles );
}
- VectorCopy (spot->s.origin, origin);
- origin[2] += 9;
- VectorCopy (spot->s.angles, angles);
+ VectorCopy( spot->s.origin, origin );
+ origin[ 2 ] += 9;
+ VectorCopy( spot->s.angles, angles );
return spot;
}
@@ -492,8 +518,9 @@ SelectSpectatorSpawnPoint
============
*/
-gentity_t *SelectSpectatorSpawnPoint( vec3_t origin, vec3_t angles ) {
- FindIntermissionPoint();
+gentity_t *SelectSpectatorSpawnPoint( vec3_t origin, vec3_t angles )
+{
+ FindIntermissionPoint( );
VectorCopy( level.intermission_origin, origin );
VectorCopy( level.intermission_angle, angles );
@@ -510,18 +537,18 @@ Try to find a spawn point for alien intermission otherwise
use normal intermission spawn.
============
*/
-gentity_t *SelectAlienLockSpawnPoint( vec3_t origin, vec3_t angles ) {
+gentity_t *SelectAlienLockSpawnPoint( vec3_t origin, vec3_t angles )
+{
gentity_t *spot;
spot = NULL;
- spot = G_Find (spot, FOFS(classname), "info_alien_intermission");
+ spot = G_Find( spot, FOFS( classname ), "info_alien_intermission" );
- if ( !spot ) {
+ if( !spot )
return SelectSpectatorSpawnPoint( origin, angles );
- }
- VectorCopy (spot->s.origin, origin);
- VectorCopy (spot->s.angles, angles);
+ VectorCopy( spot->s.origin, origin );
+ VectorCopy( spot->s.angles, angles );
return spot;
}
@@ -535,18 +562,18 @@ Try to find a spawn point for human intermission otherwise
use normal intermission spawn.
============
*/
-gentity_t *SelectHumanLockSpawnPoint( vec3_t origin, vec3_t angles ) {
+gentity_t *SelectHumanLockSpawnPoint( vec3_t origin, vec3_t angles )
+{
gentity_t *spot;
spot = NULL;
- spot = G_Find (spot, FOFS(classname), "info_human_intermission");
+ spot = G_Find( spot, FOFS( classname ), "info_human_intermission" );
- if ( !spot ) {
+ if( !spot )
return SelectSpectatorSpawnPoint( origin, angles );
- }
- VectorCopy (spot->s.origin, origin);
- VectorCopy (spot->s.angles, angles);
+ VectorCopy( spot->s.origin, origin );
+ VectorCopy( spot->s.angles, angles );
return spot;
}
@@ -774,18 +801,21 @@ SetClientViewAngle
==================
*/
-void SetClientViewAngle( gentity_t *ent, vec3_t angle ) {
+void SetClientViewAngle( gentity_t *ent, vec3_t angle )
+{
int i;
// set the delta angle
- for (i=0 ; i<3 ; i++) {
+ for( i = 0; i < 3; i++ )
+ {
int cmdAngle;
- cmdAngle = ANGLE2SHORT(angle[i]);
- ent->client->ps.delta_angles[i] = cmdAngle - ent->client->pers.cmd.angles[i];
+ cmdAngle = ANGLE2SHORT( angle[ i ] );
+ ent->client->ps.delta_angles[ i ] = cmdAngle - ent->client->pers.cmd.angles[ i ];
}
+
VectorCopy( angle, ent->s.angles );
- VectorCopy (ent->s.angles, ent->client->ps.viewangles);
+ VectorCopy( ent->s.angles, ent->client->ps.viewangles );
}
/*
@@ -793,7 +823,8 @@ void SetClientViewAngle( gentity_t *ent, vec3_t angle ) {
respawn
================
*/
-void respawn( gentity_t *ent ) {
+void respawn( gentity_t *ent )
+{
gentity_t *tent;
SpawnCorpse( ent );
@@ -815,20 +846,21 @@ TeamCount
Returns number of players on a team
================
*/
-team_t TeamCount( int ignoreClientNum, int team ) {
+team_t TeamCount( int ignoreClientNum, int team )
+{
int i;
int count = 0;
- for ( i = 0 ; i < level.maxclients ; i++ ) {
- if ( i == ignoreClientNum ) {
+ for( i = 0 ; i < level.maxclients ; i++ )
+ {
+ if( i == ignoreClientNum )
continue;
- }
- if ( level.clients[i].pers.connected == CON_DISCONNECTED ) {
+
+ if( level.clients[ i ].pers.connected == CON_DISCONNECTED )
continue;
- }
- if ( level.clients[i].sess.sessionTeam == team ) {
+
+ if( level.clients[ i ].sess.sessionTeam == team )
count++;
- }
}
return count;
@@ -836,34 +868,12 @@ team_t TeamCount( int ignoreClientNum, int team ) {
/*
-================
-TeamLeader
-
-Returns the client number of the team leader
-================
-*/
-int TeamLeader( int team ) {
- int i;
-
- for ( i = 0 ; i < level.maxclients ; i++ ) {
- if ( level.clients[i].pers.connected == CON_DISCONNECTED ) {
- continue;
- }
- if ( level.clients[i].sess.sessionTeam == team ) {
- if ( level.clients[i].sess.teamLeader )
- return i;
- }
- }
-
- return -1;
-}
-
-/*
===========
ClientCheckName
============
*/
-static void ClientCleanName( const char *in, char *out, int outSize ) {
+static void ClientCleanName( const char *in, char *out, int outSize )
+{
int len, colorlessLen;
char ch;
char *p;
@@ -878,34 +888,33 @@ static void ClientCleanName( const char *in, char *out, int outSize ) {
*p = 0;
spaces = 0;
- while( 1 ) {
+ while( 1 )
+ {
ch = *in++;
- if( !ch ) {
+ if( !ch )
break;
- }
// don't allow leading spaces
- if( !*p && ch == ' ' ) {
+ if( !*p && ch == ' ' )
continue;
- }
// check colors
- if( ch == Q_COLOR_ESCAPE ) {
+ if( ch == Q_COLOR_ESCAPE )
+ {
// solo trailing carat is not a color prefix
- if( !*in ) {
+ if( !*in )
break;
- }
// don't allow black in a name, period
- if( ColorIndex(*in) == 0 ) {
+ if( ColorIndex( *in ) == 0 )
+ {
in++;
continue;
}
// make sure room in dest for both chars
- if( len > outSize - 2 ) {
+ if( len > outSize - 2 )
break;
- }
*out++ = ch;
*out++ = *in++;
@@ -914,30 +923,28 @@ static void ClientCleanName( const char *in, char *out, int outSize ) {
}
// don't allow too many consecutive spaces
- if( ch == ' ' ) {
+ if( ch == ' ' )
+ {
spaces++;
- if( spaces > 3 ) {
+ if( spaces > 3 )
continue;
- }
}
- else {
+ else
spaces = 0;
- }
- if( len > outSize - 1 ) {
+ if( len > outSize - 1 )
break;
- }
*out++ = ch;
colorlessLen++;
len++;
}
+
*out = 0;
// don't allow empty names
- if( *p == 0 || colorlessLen == 0 ) {
+ if( *p == 0 || colorlessLen == 0 )
Q_strncpyz( p, "UnnamedPlayer", outSize );
- }
}
@@ -952,19 +959,20 @@ The game can override any of the settings and call trap_SetUserinfo
if desired.
============
*/
-void ClientUserinfoChanged( int clientNum ) {
+void ClientUserinfoChanged( int clientNum )
+{
gentity_t *ent;
- int teamTask, teamLeader, team, health;
- char *s;
- char model[MAX_QPATH];
- char buffer[ MAX_QPATH ];
- char oldname[MAX_STRING_CHARS];
+ int teamTask, teamLeader, team, health;
+ char *s;
+ char model[ MAX_QPATH ];
+ char buffer[ MAX_QPATH ];
+ char oldname[ MAX_STRING_CHARS ];
gclient_t *client;
- char c1[MAX_INFO_STRING];
- char c2[MAX_INFO_STRING];
- char redTeam[MAX_INFO_STRING];
- char blueTeam[MAX_INFO_STRING];
- char userinfo[MAX_INFO_STRING];
+ char c1[ MAX_INFO_STRING ];
+ char c2[ MAX_INFO_STRING ];
+ char redTeam[ MAX_INFO_STRING ];
+ char blueTeam[ MAX_INFO_STRING ];
+ char userinfo[ MAX_INFO_STRING ];
ent = g_entities + clientNum;
client = ent->client;
@@ -972,48 +980,49 @@ void ClientUserinfoChanged( int clientNum ) {
trap_GetUserinfo( clientNum, userinfo, sizeof( userinfo ) );
// check for malformed or illegal info strings
- if ( !Info_Validate(userinfo) ) {
- strcpy (userinfo, "\\name\\badinfo");
- }
+ if( !Info_Validate(userinfo) )
+ strcpy( userinfo, "\\name\\badinfo" );
// check for local client
s = Info_ValueForKey( userinfo, "ip" );
- if ( !strcmp( s, "localhost" ) ) {
+
+ if( !strcmp( s, "localhost" ) )
client->pers.localClient = qtrue;
- }
// check the item prediction
s = Info_ValueForKey( userinfo, "cg_predictItems" );
- if ( !atoi( s ) ) {
+
+ if( !atoi( s ) )
client->pers.predictItemPickup = qfalse;
- } else {
+ else
client->pers.predictItemPickup = qtrue;
- }
// set name
- Q_strncpyz ( oldname, client->pers.netname, sizeof( oldname ) );
- s = Info_ValueForKey (userinfo, "name");
- ClientCleanName( s, client->pers.netname, sizeof(client->pers.netname) );
+ Q_strncpyz( oldname, client->pers.netname, sizeof( oldname ) );
+ s = Info_ValueForKey( userinfo, "name" );
+ ClientCleanName( s, client->pers.netname, sizeof( client->pers.netname ) );
- if ( client->sess.sessionTeam == TEAM_SPECTATOR ) {
- if ( client->sess.spectatorState == SPECTATOR_SCOREBOARD ) {
- Q_strncpyz( client->pers.netname, "scoreboard", sizeof(client->pers.netname) );
- }
+ if( client->sess.sessionTeam == TEAM_SPECTATOR )
+ {
+ if( client->sess.spectatorState == SPECTATOR_SCOREBOARD )
+ Q_strncpyz( client->pers.netname, "scoreboard", sizeof( client->pers.netname ) );
}
- if ( client->pers.connected == CON_CONNECTED ) {
- if ( strcmp( oldname, client->pers.netname ) ) {
- trap_SendServerCommand( -1, va("print \"%s" S_COLOR_WHITE " renamed to %s\n\"", oldname,
- client->pers.netname) );
+ if( client->pers.connected == CON_CONNECTED )
+ {
+ if( strcmp( oldname, client->pers.netname ) )
+ {
+ trap_SendServerCommand( -1, va( "print \"%s" S_COLOR_WHITE " renamed to %s\n\"", oldname,
+ client->pers.netname ) );
}
}
// set max health
health = atoi( Info_ValueForKey( userinfo, "handicap" ) );
client->pers.maxHealth = health;
- if ( client->pers.maxHealth < 1 || client->pers.maxHealth > 100 ) {
+
+ if( client->pers.maxHealth < 1 || client->pers.maxHealth > 100 )
client->pers.maxHealth = 100;
- }
//hack to force a client update if the config string does not change between spawning
if( client->pers.pclass == PCL_NONE )
@@ -1026,6 +1035,7 @@ void ClientUserinfoChanged( int clientNum ) {
// wallwalk follow
s = Info_ValueForKey( userinfo, "cg_wwFollow" );
+
if( atoi( s ) )
client->ps.persistant[ PERS_STATE ] |= PS_WALLCLIMBINGFOLLOW;
else
@@ -1033,37 +1043,30 @@ void ClientUserinfoChanged( int clientNum ) {
// teamInfo
s = Info_ValueForKey( userinfo, "teamoverlay" );
- if ( ! *s || atoi( s ) != 0 ) {
+
+ if( ! *s || atoi( s ) != 0 )
client->pers.teamInfo = qtrue;
- } else {
+ else
client->pers.teamInfo = qfalse;
- }
// team task (0 = none, 1 = offence, 2 = defence)
- teamTask = atoi(Info_ValueForKey(userinfo, "teamtask"));
+ teamTask = atoi( Info_ValueForKey( userinfo, "teamtask" ) );
// team Leader (1 = leader, 0 is normal player)
teamLeader = client->sess.teamLeader;
// colors
- strcpy(c1, Info_ValueForKey( userinfo, "color1" ));
- strcpy(c2, Info_ValueForKey( userinfo, "color2" ));
- strcpy(redTeam, "humans");
- strcpy(blueTeam, "aliens");
+ strcpy( c1, Info_ValueForKey( userinfo, "color1" ) );
+ strcpy( c2, Info_ValueForKey( userinfo, "color2" ) );
+ strcpy( redTeam, "humans" );
+ strcpy( blueTeam, "aliens" );
// send over a subset of the userinfo keys so other clients can
// print scoreboards, display models, and play custom sounds
- if ( ent->r.svFlags & SVF_BOT ) {
- s = va("n\\%s\\t\\%i\\model\\%s\\hmodel\\%s\\c1\\%s\\c2\\%s\\hc\\%i\\w\\%i\\l\\%i\\skill\\%s\\tt\\%d\\tl\\%d",
- client->pers.netname, client->ps.stats[ STAT_PTEAM ], model, model, c1, c2,
- client->pers.maxHealth, client->sess.wins, client->sess.losses,
- Info_ValueForKey( userinfo, "skill" ), teamTask, teamLeader );
- } else {
- s = va("n\\%s\\t\\%i\\model\\%s\\hmodel\\%s\\g_redteam\\%s\\g_blueteam\\%s\\c1\\%s\\c2\\%s\\hc\\%i\\w\\%i\\l\\%i\\tt\\%d\\tl\\%d",
- client->pers.netname, client->ps.stats[ STAT_PTEAM ], model, model, redTeam, blueTeam, c1, c2,
- client->pers.maxHealth, client->sess.wins, client->sess.losses, teamTask, teamLeader);
- }
+ s = va( "n\\%s\\t\\%i\\model\\%s\\hmodel\\%s\\g_redteam\\%s\\g_blueteam\\%s\\c1\\%s\\c2\\%s\\hc\\%i\\w\\%i\\l\\%i\\tt\\%d\\tl\\%d",
+ client->pers.netname, client->ps.stats[ STAT_PTEAM ], model, model, redTeam, blueTeam, c1, c2,
+ client->pers.maxHealth, client->sess.wins, client->sess.losses, teamTask, teamLeader);
- trap_SetConfigstring( CS_PLAYERS+clientNum, s );
+ trap_SetConfigstring( CS_PLAYERS + clientNum, s );
G_LogPrintf( "ClientUserinfoChanged: %i %s\n", clientNum, s );
}
@@ -1089,10 +1092,11 @@ to the server machine, but qfalse on map changes and tournement
restarts.
============
*/
-char *ClientConnect( int clientNum, qboolean firstTime, qboolean isBot ) {
- char *value;
+char *ClientConnect( int clientNum, qboolean firstTime, qboolean isBot )
+{
+ char *value;
gclient_t *client;
- char userinfo[MAX_INFO_STRING];
+ char userinfo[ MAX_INFO_STRING ];
gentity_t *ent;
ent = &g_entities[ clientNum ];
@@ -1100,17 +1104,16 @@ char *ClientConnect( int clientNum, qboolean firstTime, qboolean isBot ) {
trap_GetUserinfo( clientNum, userinfo, sizeof( userinfo ) );
// check to see if they are on the banned IP list
- value = Info_ValueForKey (userinfo, "ip");
- if ( G_FilterPacket( value ) ) {
+ value = Info_ValueForKey( userinfo, "ip" );
+ if( G_FilterPacket( value ) )
return "Banned.";
- }
// check for a password
- value = Info_ValueForKey (userinfo, "password");
- if ( g_password.string[0] && Q_stricmp( g_password.string, "none" ) &&
- strcmp( g_password.string, value) != 0) {
+ value = Info_ValueForKey( userinfo, "password" );
+
+ if( g_password.string[ 0 ] && Q_stricmp( g_password.string, "none" ) &&
+ strcmp( g_password.string, value ) != 0 )
return "Invalid password";
- }
// they can connect
ent->client = level.clients + clientNum;
@@ -1121,9 +1124,9 @@ char *ClientConnect( int clientNum, qboolean firstTime, qboolean isBot ) {
client->pers.connected = CON_CONNECTING;
// read or initialize the session data
- if ( firstTime || level.newSession ) {
+ if( firstTime || level.newSession )
G_InitSessionData( client, userinfo );
- }
+
G_ReadSessionData( client );
// get and distribute relevent paramters
@@ -1131,12 +1134,11 @@ char *ClientConnect( int clientNum, qboolean firstTime, qboolean isBot ) {
ClientUserinfoChanged( clientNum );
// don't do the "xxx connected" messages if they were caried over from previous level
- if ( firstTime ) {
- trap_SendServerCommand( -1, va("print \"%s" S_COLOR_WHITE " connected\n\"", client->pers.netname) );
- }
+ if( firstTime )
+ trap_SendServerCommand( -1, va( "print \"%s" S_COLOR_WHITE " connected\n\"", client->pers.netname ) );
// count current clients and rank for scoreboard
- CalculateRanks();
+ CalculateRanks( );
return NULL;
}
@@ -1150,19 +1152,20 @@ to be placed into the level. This will happen every level load,
and on transition between teams, but doesn't happen on respawns
============
*/
-void ClientBegin( int clientNum ) {
+void ClientBegin( int clientNum )
+{
gentity_t *ent;
gclient_t *client;
gentity_t *tent;
- int flags;
+ int flags;
ent = g_entities + clientNum;
client = level.clients + clientNum;
- if ( ent->r.linked ) {
+ if( ent->r.linked )
trap_UnlinkEntity( ent );
- }
+
G_InitGentity( ent );
ent->touch = 0;
ent->pain = 0;
@@ -1185,17 +1188,19 @@ void ClientBegin( int clientNum ) {
ClientSpawn( ent, NULL );
- if ( client->sess.sessionTeam != TEAM_SPECTATOR ) {
+ if( client->sess.sessionTeam != TEAM_SPECTATOR )
+ {
// send event
tent = G_TempEntity( ent->client->ps.origin, EV_PLAYER_TELEPORT_IN );
tent->s.clientNum = ent->s.clientNum;
- trap_SendServerCommand( -1, va("print \"%s" S_COLOR_WHITE " entered the game\n\"", client->pers.netname) );
+ trap_SendServerCommand( -1, va( "print \"%s" S_COLOR_WHITE " entered the game\n\"", client->pers.netname ) );
}
+
G_LogPrintf( "ClientBegin: %i\n", clientNum );
// count current clients and rank for scoreboard
- CalculateRanks();
+ CalculateRanks( );
}
/*
@@ -1302,11 +1307,12 @@ void ClientSpawn( gentity_t *ent, gentity_t *spawn )
savedPing = client->ps.ping;
accuracy_hits = client->accuracy_hits;
accuracy_shots = client->accuracy_shots;
- for ( i = 0 ; i < MAX_PERSISTANT ; i++ ) {
- persistant[i] = client->ps.persistant[i];
- }
+
+ for( i = 0; i < MAX_PERSISTANT; i++ )
+ persistant[ i ] = client->ps.persistant[ i ];
+
eventSequence = client->ps.eventSequence;
- memset (client, 0, sizeof(*client));
+ memset( client, 0, sizeof( *client ) );
client->pers = saved;
client->sess = savedSess;
@@ -1314,9 +1320,10 @@ void ClientSpawn( gentity_t *ent, gentity_t *spawn )
client->accuracy_hits = accuracy_hits;
client->accuracy_shots = accuracy_shots;
client->lastkilled_client = -1;
- for ( i = 0 ; i < MAX_PERSISTANT ; i++ ) {
- client->ps.persistant[i] = persistant[i];
- }
+
+ for( i = 0; i < MAX_PERSISTANT; i++ )
+ client->ps.persistant[ i ] = persistant[ i ];
+
client->ps.eventSequence = eventSequence;
if( client->sess.sessionTeam == TEAM_SPECTATOR )
@@ -1328,18 +1335,18 @@ void ClientSpawn( gentity_t *ent, gentity_t *spawn )
}
// increment the spawncount so the client will detect the respawn
- client->ps.persistant[PERS_SPAWN_COUNT]++;
- client->ps.persistant[PERS_TEAM] = client->sess.sessionTeam;
+ client->ps.persistant[ PERS_SPAWN_COUNT ]++;
+ client->ps.persistant[ PERS_TEAM ] = client->sess.sessionTeam;
client->airOutTime = level.time + 12000;
- trap_GetUserinfo( index, userinfo, sizeof(userinfo) );
+ trap_GetUserinfo( index, userinfo, sizeof( userinfo ) );
client->ps.eFlags = flags;
//Com_Printf( "ent->client->pers->pclass = %i\n", ent->client->pers.pclass );
ent->s.groundEntityNum = ENTITYNUM_NONE;
- ent->client = &level.clients[index];
+ ent->client = &level.clients[ index ];
ent->takedamage = qtrue;
ent->inuse = qtrue;
ent->classname = "player";
@@ -1386,7 +1393,7 @@ void ClientSpawn( gentity_t *ent, gentity_t *spawn )
VectorSet( ent->client->ps.grapplePoint, 0.0f, 0.0f, 1.0f );
// health will count down towards max_health
- ent->health = client->ps.stats[STAT_HEALTH] = client->ps.stats[STAT_MAX_HEALTH]; //* 1.25;
+ ent->health = client->ps.stats[ STAT_HEALTH ] = client->ps.stats[ STAT_MAX_HEALTH ]; //* 1.25;
G_SetOrigin( ent, spawn_origin );
VectorCopy( spawn_origin, client->ps.origin );
@@ -1416,11 +1423,10 @@ void ClientSpawn( gentity_t *ent, gentity_t *spawn )
trap_GetUsercmd( client - level.clients, &ent->client->pers.cmd );
SetClientViewAngle( ent, spawn_angles );
- if ( client->sess.sessionTeam == TEAM_SPECTATOR ) {
-
- } else {
+ if( !( client->sess.sessionTeam == TEAM_SPECTATOR ) )
+ {
G_KillBox( ent );
- trap_LinkEntity (ent);
+ trap_LinkEntity( ent );
// force the base weapon up
client->ps.weapon = WP_NONE;
@@ -1443,9 +1449,10 @@ void ClientSpawn( gentity_t *ent, gentity_t *spawn )
client->ps.torsoAnim = TORSO_STAND;
client->ps.legsAnim = LEGS_IDLE;
- if ( level.intermissiontime ) {
+ if( level.intermissiontime )
MoveClientToIntermission( ent );
- } else {
+ else
+ {
// fire the targets of the spawn point
if( !spawn )
G_UseTargets( spawnPoint, ent );
@@ -1453,8 +1460,11 @@ void ClientSpawn( gentity_t *ent, gentity_t *spawn )
// select the highest weapon number available, after any
// spawn given items have fired
client->ps.weapon = 1;
- for ( i = WP_NUM_WEAPONS - 1 ; i > 0 ; i-- ) {
- if ( BG_gotWeapon( i, client->ps.stats ) ) {
+
+ for( i = WP_NUM_WEAPONS - 1; i > 0 ; i-- )
+ {
+ if( BG_gotWeapon( i, client->ps.stats ) )
+ {
client->ps.weapon = i;
break;
}
@@ -1468,14 +1478,15 @@ void ClientSpawn( gentity_t *ent, gentity_t *spawn )
ClientThink( ent-g_entities );
// positively link the client, even if the command times are weird
- if ( client->sess.sessionTeam != TEAM_SPECTATOR ) {
+ if( client->sess.sessionTeam != TEAM_SPECTATOR )
+ {
BG_PlayerStateToEntityState( &client->ps, &ent->s, qtrue );
VectorCopy( ent->client->ps.origin, ent->r.currentOrigin );
trap_LinkEntity( ent );
}
//TA: must do this here so the number of active clients is calculated
- CalculateRanks();
+ CalculateRanks( );
// run the presend to set anything else
ClientEndFrame( ent );
@@ -1497,38 +1508,36 @@ call trap_DropClient(), which will call this and do
server system housekeeping.
============
*/
-void ClientDisconnect( int clientNum ) {
+void ClientDisconnect( int clientNum )
+{
gentity_t *ent;
gentity_t *tent;
- int i;
+ int i;
ent = g_entities + clientNum;
- if ( !ent->client ) {
+
+ if( !ent->client )
return;
- }
// send effect if they were completely connected
- if ( ent->client->pers.connected == CON_CONNECTED
- && ent->client->sess.sessionTeam != TEAM_SPECTATOR ) {
+ if( ent->client->pers.connected == CON_CONNECTED &&
+ ent->client->sess.sessionTeam != TEAM_SPECTATOR )
+ {
tent = G_TempEntity( ent->client->ps.origin, EV_PLAYER_TELEPORT_OUT );
tent->s.clientNum = ent->s.clientNum;
-
- // They don't get to take powerups with them!
- // Especially important for stuff like CTF flags
- TossClientItems ( ent );
}
G_LogPrintf( "ClientDisconnect: %i\n", clientNum );
- trap_UnlinkEntity (ent);
+ trap_UnlinkEntity( ent );
ent->s.modelindex = 0;
ent->inuse = qfalse;
ent->classname = "disconnected";
ent->client->pers.connected = CON_DISCONNECTED;
- ent->client->ps.persistant[PERS_TEAM] = TEAM_FREE;
+ ent->client->ps.persistant[ PERS_TEAM ] = TEAM_FREE;
ent->client->sess.sessionTeam = TEAM_FREE;
trap_SetConfigstring( CS_PLAYERS + clientNum, "");
- CalculateRanks();
+ CalculateRanks( );
}
diff --git a/src/game/g_cmds.c b/src/game/g_cmds.c
index 37cc866e..1b2e0156 100644
--- a/src/game/g_cmds.c
+++ b/src/game/g_cmds.c
@@ -87,15 +87,20 @@ void Cmd_Score_f( gentity_t *ent )
CheatsOk
==================
*/
-qboolean CheatsOk( gentity_t *ent ) {
- if ( !g_cheats.integer ) {
- trap_SendServerCommand( ent-g_entities, va("print \"Cheats are not enabled on this server.\n\""));
+qboolean CheatsOk( gentity_t *ent )
+{
+ if( !g_cheats.integer )
+ {
+ trap_SendServerCommand( ent-g_entities, va( "print \"Cheats are not enabled on this server.\n\"" ) );
return qfalse;
}
- if ( ent->health <= 0 ) {
- trap_SendServerCommand( ent-g_entities, va("print \"You must be alive to use this command.\n\""));
- return qfalse;
+
+ if( ent->health <= 0 )
+ {
+ trap_SendServerCommand( ent-g_entities, va( "print \"You must be alive to use this command.\n\"" ) );
+ return qfalse;
}
+
return qtrue;
}
@@ -138,74 +143,6 @@ char *ConcatArgs( int start )
return line;
}
-/*
-==================
-SanitizeString
-
-Remove case and control characters
-==================
-*/
-void SanitizeString( char *in, char *out ) {
- while ( *in ) {
- if ( *in == 27 ) {
- in += 2; // skip color code
- continue;
- }
- if ( *in < 32 ) {
- in++;
- continue;
- }
- *out++ = tolower( *in++ );
- }
-
- *out = 0;
-}
-
-/*
-==================
-ClientNumberFromString
-
-Returns a player number for either a number or name string
-Returns -1 if invalid
-==================
-*/
-int ClientNumberFromString( gentity_t *to, char *s ) {
- gclient_t *cl;
- int idnum;
- char s2[MAX_STRING_CHARS];
- char n2[MAX_STRING_CHARS];
-
- // numeric values are just slot numbers
- if (s[0] >= '0' && s[0] <= '9') {
- idnum = atoi( s );
- if ( idnum < 0 || idnum >= level.maxclients ) {
- trap_SendServerCommand( to-g_entities, va("print \"Bad client slot: %i\n\"", idnum));
- return -1;
- }
-
- cl = &level.clients[idnum];
- if ( cl->pers.connected != CON_CONNECTED ) {
- trap_SendServerCommand( to-g_entities, va("print \"Client %i is not active\n\"", idnum));
- return -1;
- }
- return idnum;
- }
-
- // check for a name match
- SanitizeString( s, s2 );
- for ( idnum=0,cl=level.clients ; idnum < level.maxclients ; idnum++,cl++ ) {
- if ( cl->pers.connected != CON_CONNECTED ) {
- continue;
- }
- SanitizeString( cl->pers.netname, n2 );
- if ( !strcmp( n2, s2 ) ) {
- return idnum;
- }
- }
-
- trap_SendServerCommand( to-g_entities, va("print \"User %s is not on the server\n\"", s));
- return -1;
-}
/*
==================
@@ -214,46 +151,46 @@ Cmd_Give_f
Give items to a client
==================
*/
-void Cmd_Give_f (gentity_t *ent)
+void Cmd_Give_f( gentity_t *ent )
{
- char *name;
+ char *name;
gitem_t *it;
- int i;
+ int i;
qboolean give_all;
- gentity_t *it_ent;
+ gentity_t *it_ent;
trace_t trace;
- if ( !CheatsOk( ent ) ) {
+ if( !CheatsOk( ent ) )
return;
- }
name = ConcatArgs( 1 );
- if (Q_stricmp(name, "all") == 0)
+ if( Q_stricmp( name, "all" ) == 0 )
give_all = qtrue;
else
give_all = qfalse;
- if (give_all || Q_stricmp( name, "health") == 0)
+ if( give_all || Q_stricmp( name, "health" ) == 0 )
{
- ent->health = ent->client->ps.stats[STAT_MAX_HEALTH];
- if (!give_all)
+ ent->health = ent->client->ps.stats[ STAT_MAX_HEALTH ];
+ if( !give_all )
return;
}
- if (give_all || Q_stricmp(name, "weapons") == 0)
+ if( give_all || Q_stricmp( name, "weapons" ) == 0 )
{
- BG_packWeapon( (1 << WP_NUM_WEAPONS) - 1 - ( 1 << WP_NONE ), ent->client->ps.stats );
- if (!give_all)
+ BG_packWeapon( ( 1 << WP_NUM_WEAPONS ) - 1 - ( 1 << WP_NONE ), ent->client->ps.stats );
+
+ if( !give_all )
return;
}
- if (give_all || Q_stricmp(name, "ammo") == 0)
+ if( give_all || Q_stricmp( name, "ammo" ) == 0 )
{
- for ( i = 0 ; i < MAX_WEAPONS ; i++ ) {
+ for( i = 0; i < MAX_WEAPONS; i++ )
BG_packAmmoArray( i, ent->client->ps.ammo, ent->client->ps.powerups, 999, 0, 0 );
- }
- if (!give_all)
+
+ if( !give_all )
return;
}
@@ -264,25 +201,6 @@ void Cmd_Give_f (gentity_t *ent)
if( !give_all )
return;
}
-
- // spawn a specific item right on the player
-/* if ( !give_all ) {
- it = BG_FindItem (name);
- if (!it) {
- return;
- }
-
- it_ent = G_Spawn();
- VectorCopy( ent->r.currentOrigin, it_ent->s.origin );
- it_ent->classname = it->classname;
- G_SpawnItem (it_ent, it);
- FinishSpawningItem(it_ent );
- memset( &trace, 0, sizeof( trace ) );
- Touch_Item (it_ent, ent, &trace);
- if (it_ent->inuse) {
- G_FreeEntity( it_ent );
- }
- }*/
}
@@ -295,21 +213,21 @@ Sets client to godmode
argv(0) god
==================
*/
-void Cmd_God_f (gentity_t *ent)
+void Cmd_God_f( gentity_t *ent )
{
char *msg;
- if ( !CheatsOk( ent ) ) {
+ if( !CheatsOk( ent ) )
return;
- }
ent->flags ^= FL_GODMODE;
- if (!(ent->flags & FL_GODMODE) )
+
+ if( !( ent->flags & FL_GODMODE ) )
msg = "godmode OFF\n";
else
msg = "godmode ON\n";
- trap_SendServerCommand( ent-g_entities, va("print \"%s\"", msg));
+ trap_SendServerCommand( ent - g_entities, va( "print \"%s\"", msg ) );
}
@@ -322,20 +240,21 @@ Sets client to notarget
argv(0) notarget
==================
*/
-void Cmd_Notarget_f( gentity_t *ent ) {
+void Cmd_Notarget_f( gentity_t *ent )
+{
char *msg;
- if ( !CheatsOk( ent ) ) {
+ if( !CheatsOk( ent ) )
return;
- }
ent->flags ^= FL_NOTARGET;
- if (!(ent->flags & FL_NOTARGET) )
+
+ if( !( ent->flags & FL_NOTARGET ) )
msg = "notarget OFF\n";
else
msg = "notarget ON\n";
- trap_SendServerCommand( ent-g_entities, va("print \"%s\"", msg));
+ trap_SendServerCommand( ent - g_entities, va( "print \"%s\"", msg ) );
}
@@ -346,21 +265,21 @@ Cmd_Noclip_f
argv(0) noclip
==================
*/
-void Cmd_Noclip_f( gentity_t *ent ) {
+void Cmd_Noclip_f( gentity_t *ent )
+{
char *msg;
- if ( !CheatsOk( ent ) ) {
+ if( !CheatsOk( ent ) )
return;
- }
- if ( ent->client->noclip ) {
+ if( ent->client->noclip )
msg = "noclip OFF\n";
- } else {
+ else
msg = "noclip ON\n";
- }
+
ent->client->noclip = !ent->client->noclip;
- trap_SendServerCommand( ent-g_entities, va("print \"%s\"", msg));
+ trap_SendServerCommand( ent - g_entities, va( "print \"%s\"", msg ) );
}
@@ -380,29 +299,9 @@ void Cmd_LevelShot_f( gentity_t *ent )
return;
BeginIntermission( );
- trap_SendServerCommand( ent-g_entities, "clientLevelShot" );
+ trap_SendServerCommand( ent - g_entities, "clientLevelShot" );
}
-
-void Cmd_TeamTask_f( gentity_t *ent ) {
- char userinfo[MAX_INFO_STRING];
- char arg[MAX_TOKEN_CHARS];
- int task;
- int client = ent->client - level.clients;
-
- if ( trap_Argc() != 2 ) {
- return;
- }
- trap_Argv( 1, arg, sizeof( arg ) );
- task = atoi( arg );
-
- trap_GetUserinfo(client, userinfo, sizeof(userinfo));
- Info_SetValueForKey(userinfo, "teamtask", va("%d", task));
- trap_SetUserinfo(client, userinfo);
- ClientUserinfoChanged(client);
-}
-
-
/*
=================
Cmd_Kill_f
@@ -628,21 +527,11 @@ static void Cmd_Tell_f( gentity_t *ent )
Cmd_Where_f
==================
*/
-void Cmd_Where_f( gentity_t *ent ) {
- trap_SendServerCommand( ent-g_entities, va("print \"%s\n\"", vtos( ent->s.origin ) ) );
+void Cmd_Where_f( gentity_t *ent )
+{
+ trap_SendServerCommand( ent-g_entities, va( "print \"%s\n\"", vtos( ent->s.origin ) ) );
}
-static const char *gameNames[] = {
- "Free For All",
- "Tournament",
- "Single Player",
- "Team Deathmatch",
- "Capture the Flag",
- "One Flag CTF",
- "Overload",
- "Harvester"
-};
-
/*
==================
Cmd_CallVote_f
@@ -1021,28 +910,34 @@ void Cmd_TeamVote_f( gentity_t *ent )
Cmd_SetViewpos_f
=================
*/
-void Cmd_SetViewpos_f( gentity_t *ent ) {
- vec3_t origin, angles;
- char buffer[MAX_TOKEN_CHARS];
+void Cmd_SetViewpos_f( gentity_t *ent )
+{
+ vec3_t origin, angles;
+ char buffer[ MAX_TOKEN_CHARS ];
int i;
- if ( !g_cheats.integer ) {
- trap_SendServerCommand( ent-g_entities, va("print \"Cheats are not enabled on this server.\n\""));
+ if( !g_cheats.integer )
+ {
+ trap_SendServerCommand( ent-g_entities, va( "print \"Cheats are not enabled on this server.\n\"" ) );
return;
}
- if ( trap_Argc() != 5 ) {
- trap_SendServerCommand( ent-g_entities, va("print \"usage: setviewpos x y z yaw\n\""));
+
+ if( trap_Argc( ) != 5 )
+ {
+ trap_SendServerCommand( ent-g_entities, va( "print \"usage: setviewpos x y z yaw\n\"" ) );
return;
}
VectorClear( angles );
- for ( i = 0 ; i < 3 ; i++ ) {
+
+ for( i = 0 ; i < 3 ; i++ )
+ {
trap_Argv( i + 1, buffer, sizeof( buffer ) );
- origin[i] = atof( buffer );
+ origin[ i ] = atof( buffer );
}
trap_Argv( 4, buffer, sizeof( buffer ) );
- angles[YAW] = atof( buffer );
+ angles[ YAW ] = atof( buffer );
TeleportPlayer( ent, origin, angles );
}
@@ -1640,17 +1535,6 @@ void Cmd_Sell_f( gentity_t *ent )
/*
=================
-Cmd_Statement_f
-=================
-*/
-void Cmd_Statement_f( gentity_t *ent )
-{
- trap_SendServerCommand( ent-g_entities, va("print \"Credits: %d\n\"",
- ent->client->ps.persistant[ PERS_CREDIT ] ) );
-}
-
-/*
-=================
Cmd_Deposit_f
=================
*/
@@ -1951,8 +1835,11 @@ void Cmd_Spawnbody_f( gentity_t *ent )
return;
AngleVectors( ent->client->ps.viewangles, forward, NULL, NULL );
+ forward[ 2 ] = 0.0f;
+
VectorMA( ent->client->ps.origin, 128.0f, forward, dummy->r.currentOrigin );
-
+ dummy->r.currentOrigin[ 2 ] += 64.0f;
+
dummy->client->ps.stats[ STAT_PTEAM ] = PTE_HUMANS;
dummy->client->ps.stats[ STAT_PCLASS ] = PCL_H_BASE;
@@ -1963,8 +1850,16 @@ void Cmd_Spawnbody_f( gentity_t *ent )
G_FreeEntity( dummy );
}
+/*
+=================
+Cmd_Test_f
+=================
+*/
void Cmd_Test_f( gentity_t *ent )
{
+ if( !CheatsOk( ent ) )
+ return;
+
ent->client->ps.stats[ STAT_STATE ] |= SS_KNOCKEDOVER;
ent->client->lastKnockedOverTime = level.time;
G_AddPredictableEvent( ent, EV_KNOCKOVER, 0 );
@@ -1981,100 +1876,104 @@ void Cmd_Test_f( gentity_t *ent )
ClientCommand
=================
*/
-void ClientCommand( int clientNum ) {
+void ClientCommand( int clientNum )
+{
gentity_t *ent;
- char cmd[MAX_TOKEN_CHARS];
+ char cmd[ MAX_TOKEN_CHARS ];
ent = g_entities + clientNum;
- if ( !ent->client ) {
+ if( !ent->client )
return; // not fully in game yet
- }
trap_Argv( 0, cmd, sizeof( cmd ) );
- if (Q_stricmp (cmd, "say") == 0) {
- Cmd_Say_f (ent, SAY_ALL, qfalse);
+ if( Q_stricmp( cmd, "say" ) == 0 )
+ {
+ Cmd_Say_f( ent, SAY_ALL, qfalse );
return;
}
- if (Q_stricmp (cmd, "say_team") == 0) {
- Cmd_Say_f (ent, SAY_TEAM, qfalse);
+
+ if( Q_stricmp( cmd, "say_team" ) == 0 )
+ {
+ Cmd_Say_f( ent, SAY_TEAM, qfalse );
return;
}
- if (Q_stricmp (cmd, "tell") == 0) {
- Cmd_Tell_f ( ent );
+
+ if( Q_stricmp( cmd, "tell" ) == 0 )
+ {
+ Cmd_Tell_f( ent );
return;
}
- if (Q_stricmp (cmd, "score") == 0) {
- Cmd_Score_f (ent);
+
+ if( Q_stricmp( cmd, "score" ) == 0 )
+ {
+ Cmd_Score_f( ent );
return;
}
// ignore all other commands when at intermission
- if (level.intermissiontime) {
- Cmd_Say_f (ent, qfalse, qtrue);
+ if( level.intermissiontime )
+ {
+ Cmd_Say_f( ent, qfalse, qtrue );
return;
}
- if (Q_stricmp (cmd, "give") == 0)
- Cmd_Give_f (ent);
- else if (Q_stricmp (cmd, "god") == 0)
- Cmd_God_f (ent);
- else if (Q_stricmp (cmd, "notarget") == 0)
- Cmd_Notarget_f (ent);
- else if (Q_stricmp (cmd, "noclip") == 0)
- Cmd_Noclip_f (ent);
- else if (Q_stricmp (cmd, "kill") == 0)
- Cmd_Kill_f (ent);
- else if (Q_stricmp (cmd, "teamtask") == 0)
- Cmd_TeamTask_f (ent);
- else if (Q_stricmp (cmd, "levelshot") == 0)
- Cmd_LevelShot_f (ent);
- else if (Q_stricmp (cmd, "team") == 0)
- Cmd_Team_f (ent);
- else if (Q_stricmp (cmd, "class") == 0)
+ if( Q_stricmp( cmd, "give" ) == 0 )
+ Cmd_Give_f( ent );
+ else if( Q_stricmp( cmd, "god" ) == 0 )
+ Cmd_God_f( ent );
+ else if( Q_stricmp( cmd, "notarget" ) == 0 )
+ Cmd_Notarget_f( ent );
+ else if( Q_stricmp( cmd, "noclip" ) == 0 )
+ Cmd_Noclip_f( ent );
+ else if( Q_stricmp( cmd, "kill" ) == 0 )
+ Cmd_Kill_f( ent );
+ else if( Q_stricmp( cmd, "levelshot" ) == 0 )
+ Cmd_LevelShot_f( ent );
+ else if( Q_stricmp( cmd, "team" ) == 0 )
+ Cmd_Team_f( ent );
+ else if( Q_stricmp( cmd, "class" ) == 0 )
Cmd_Class_f( ent );
- else if (Q_stricmp (cmd, "build") == 0)
+ else if( Q_stricmp( cmd, "build" ) == 0 )
Cmd_Build_f( ent );
- else if (Q_stricmp (cmd, "buy") == 0)
+ else if( Q_stricmp( cmd, "buy" ) == 0 )
Cmd_Buy_f( ent );
- else if (Q_stricmp (cmd, "sell") == 0)
+ else if( Q_stricmp( cmd, "sell" ) == 0 )
Cmd_Sell_f( ent );
- else if (Q_stricmp (cmd, "statement") == 0)
- Cmd_Statement_f( ent );
- else if (Q_stricmp (cmd, "deposit") == 0)
+ else if( Q_stricmp( cmd, "deposit" ) == 0 )
Cmd_Deposit_f( ent );
- else if (Q_stricmp (cmd, "withdraw") == 0)
+ else if( Q_stricmp( cmd, "withdraw" ) == 0 )
Cmd_Withdraw_f( ent );
- else if (Q_stricmp (cmd, "itemact") == 0)
+ else if( Q_stricmp( cmd, "itemact" ) == 0 )
Cmd_ActivateItem_f( ent );
- else if (Q_stricmp (cmd, "itemdeact") == 0)
+ else if( Q_stricmp( cmd, "itemdeact" ) == 0 )
Cmd_DeActivateItem_f( ent );
- else if (Q_stricmp (cmd, "itemtoggle") == 0)
+ else if( Q_stricmp( cmd, "itemtoggle" ) == 0 )
Cmd_ToggleItem_f( ent );
- else if (Q_stricmp (cmd, "destroy") == 0)
+ else if( Q_stricmp( cmd, "destroy" ) == 0 )
Cmd_Destroy_f( ent, qfalse );
- else if (Q_stricmp (cmd, "deconstruct") == 0)
+ else if( Q_stricmp( cmd, "deconstruct" ) == 0 )
Cmd_Destroy_f( ent, qtrue );
- else if (Q_stricmp (cmd, "echo") == 0)
+ else if( Q_stricmp( cmd, "echo" ) == 0 )
Cmd_Echo_f( ent );
- else if (Q_stricmp (cmd, "boost") == 0)
+ else if( Q_stricmp( cmd, "boost" ) == 0 )
Cmd_Boost_f( ent );
- else if (Q_stricmp (cmd, "where") == 0)
- Cmd_Where_f (ent);
- else if (Q_stricmp (cmd, "callvote") == 0)
- Cmd_CallVote_f (ent);
- else if (Q_stricmp (cmd, "vote") == 0)
- Cmd_Vote_f (ent);
- else if (Q_stricmp (cmd, "callteamvote") == 0)
- Cmd_CallTeamVote_f (ent);
- else if (Q_stricmp (cmd, "teamvote") == 0)
- Cmd_TeamVote_f (ent);
- else if (Q_stricmp (cmd, "setviewpos") == 0)
+ else if( Q_stricmp( cmd, "where" ) == 0 )
+ Cmd_Where_f( ent );
+ else if( Q_stricmp( cmd, "callvote" ) == 0 )
+ Cmd_CallVote_f( ent );
+ else if( Q_stricmp( cmd, "vote" ) == 0 )
+ Cmd_Vote_f( ent );
+ else if( Q_stricmp( cmd, "callteamvote" ) == 0 )
+ Cmd_CallTeamVote_f( ent );
+ else if( Q_stricmp( cmd, "teamvote" ) == 0 )
+ Cmd_TeamVote_f( ent );
+ else if( Q_stricmp( cmd, "setviewpos" ) == 0 )
Cmd_SetViewpos_f( ent );
- else if (Q_stricmp (cmd, "spawnbody") == 0)
+ else if( Q_stricmp( cmd, "spawnbody" ) == 0 )
Cmd_Spawnbody_f( ent );
- else if (Q_stricmp (cmd, "test") == 0)
+ else if( Q_stricmp( cmd, "test" ) == 0 )
Cmd_Test_f( ent );
else
- trap_SendServerCommand( clientNum, va("print \"unknown cmd %s\n\"", cmd ) );
+ trap_SendServerCommand( clientNum, va( "print \"unknown cmd %s\n\"", cmd ) );
}
diff --git a/src/game/g_combat.c b/src/game/g_combat.c
index 0745b517..a394d29f 100644
--- a/src/game/g_combat.c
+++ b/src/game/g_combat.c
@@ -44,64 +44,30 @@ void AddScore( gentity_t *ent, int score )
}
/*
-=================
-TossClientItems
-
-Toss the weapon and powerups for the killed player
-=================
-*/
-void TossClientItems( gentity_t *self ) {
- gitem_t *item;
- int weapon;
- float angle;
- int i;
- gentity_t *drop;
- int ammo, clips, maxclips;
-
- // drop the weapon if not a gauntlet or machinegun
- weapon = self->s.weapon;
-
- BG_unpackAmmoArray( weapon, self->client->ps.ammo, self->client->ps.powerups, &ammo, &clips, &maxclips );
-
- // make a special check to see if they are changing to a new
- // weapon that isn't the mg or gauntlet. Without this, a client
- // can pick up a weapon, be killed, and not drop the weapon because
- // their weapon change hasn't completed yet and they are still holding the MG.
- if( weapon == WP_MACHINEGUN ) {
- if ( self->client->ps.weaponstate == WEAPON_DROPPING ) {
- weapon = self->client->pers.cmd.weapon;
- }
- if ( !BG_gotWeapon( weapon, self->client->ps.stats ) ) {
- weapon = WP_NONE;
- }
- }
-}
-
-
-/*
==================
LookAtKiller
==================
*/
-void LookAtKiller( gentity_t *self, gentity_t *inflictor, gentity_t *attacker ) {
+void LookAtKiller( gentity_t *self, gentity_t *inflictor, gentity_t *attacker )
+{
vec3_t dir;
vec3_t angles;
if ( attacker && attacker != self )
- VectorSubtract (attacker->s.pos.trBase, self->s.pos.trBase, dir);
- else if ( inflictor && inflictor != self )
- VectorSubtract (inflictor->s.pos.trBase, self->s.pos.trBase, dir);
+ VectorSubtract( attacker->s.pos.trBase, self->s.pos.trBase, dir );
+ else if( inflictor && inflictor != self )
+ VectorSubtract( inflictor->s.pos.trBase, self->s.pos.trBase, dir );
else
{
- self->client->ps.generic1 = self->s.angles[YAW];
+ self->client->ps.generic1 = self->s.angles[ YAW ];
return;
}
- self->client->ps.generic1 = vectoyaw ( dir );
+ self->client->ps.generic1 = vectoyaw( dir );
- angles[YAW] = vectoyaw ( dir );
- angles[PITCH] = 0;
- angles[ROLL] = 0;
+ angles[ YAW ] = vectoyaw( dir );
+ angles[ PITCH ] = 0;
+ angles[ ROLL ] = 0;
}
/*
@@ -126,12 +92,14 @@ void GibEntity( gentity_t *self, int killer )
body_die
==================
*/
-void body_die( gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int damage, int meansOfDeath ) {
- if ( self->health > GIB_HEALTH ) {
+void body_die( gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int damage, int meansOfDeath )
+{
+ if( self->health > GIB_HEALTH )
return;
- }
- if ( !g_blood.integer ) {
- self->health = GIB_HEALTH+1;
+
+ if( !g_blood.integer )
+ {
+ self->health = GIB_HEALTH + 1;
return;
}
@@ -141,7 +109,8 @@ void body_die( gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int d
// these are just for logging, the client prints its own messages
-char *modNames[] = {
+char *modNames[ ] =
+{
"MOD_UNKNOWN",
"MOD_SHOTGUN",
"MOD_GAUNTLET",
@@ -380,44 +349,6 @@ void player_die( gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int
}
-/*
-================
-RaySphereIntersections
-================
-*/
-int RaySphereIntersections( vec3_t origin, float radius, vec3_t point, vec3_t dir, vec3_t intersections[2] ) {
- float b, c, d, t;
-
- // | origin - (point + t * dir) | = radius
- // a = dir[0]^2 + dir[1]^2 + dir[2]^2;
- // b = 2 * (dir[0] * (point[0] - origin[0]) + dir[1] * (point[1] - origin[1]) + dir[2] * (point[2] - origin[2]));
- // c = (point[0] - origin[0])^2 + (point[1] - origin[1])^2 + (point[2] - origin[2])^2 - radius^2;
-
- // normalize dir so a = 1
- VectorNormalize(dir);
- b = 2 * (dir[0] * (point[0] - origin[0]) + dir[1] * (point[1] - origin[1]) + dir[2] * (point[2] - origin[2]));
- c = (point[0] - origin[0]) * (point[0] - origin[0]) +
- (point[1] - origin[1]) * (point[1] - origin[1]) +
- (point[2] - origin[2]) * (point[2] - origin[2]) -
- radius * radius;
-
- d = b * b - 4 * c;
- if (d > 0) {
- t = (- b + sqrt(d)) / 2;
- VectorMA(point, t, dir, intersections[0]);
- t = (- b - sqrt(d)) / 2;
- VectorMA(point, t, dir, intersections[1]);
- return 2;
- }
- else if (d == 0) {
- t = (- b ) / 2;
- VectorMA(point, t, dir, intersections[0]);
- return 1;
- }
- return 0;
-}
-
-
////////TA: locdamage
/*
@@ -748,7 +679,7 @@ float G_CalcDamageModifier( vec3_t point, gentity_t *targ, gentity_t *attacker,
G_InitDamageLocations
============
*/
-void G_InitDamageLocations( )
+void G_InitDamageLocations( void )
{
char *modelName;
char filename[ MAX_QPATH ];
@@ -854,19 +785,19 @@ void G_Damage( gentity_t *targ, gentity_t *inflictor, gentity_t *attacker,
int knockback;
int max;
- if(!targ->takedamage)
+ if( !targ->takedamage )
return;
// the intermission has allready been qualified for, so don't
// allow any extra scoring
- if ( level.intermissionQueued )
+ if( level.intermissionQueued )
return;
if( !inflictor )
- inflictor = &g_entities[ENTITYNUM_WORLD];
+ inflictor = &g_entities[ ENTITYNUM_WORLD ];
if( !attacker )
- attacker = &g_entities[ENTITYNUM_WORLD];
+ attacker = &g_entities[ ENTITYNUM_WORLD ];
// shootable doors / buttons don't actually have any health
if( targ->s.eType == ET_MOVER )
@@ -990,13 +921,14 @@ void G_Damage( gentity_t *targ, gentity_t *inflictor, gentity_t *attacker,
if( client )
{
if( attacker )
- client->ps.persistant[PERS_ATTACKER] = attacker->s.number;
+ client->ps.persistant[ PERS_ATTACKER ] = attacker->s.number;
else
- client->ps.persistant[PERS_ATTACKER] = ENTITYNUM_WORLD;
+ client->ps.persistant[ PERS_ATTACKER ] = ENTITYNUM_WORLD;
client->damage_armor += asave;
client->damage_blood += take;
client->damage_knockback += knockback;
+
if( dir )
{
VectorCopy ( dir, client->damage_from );
@@ -1046,11 +978,11 @@ void G_Damage( gentity_t *targ, gentity_t *inflictor, gentity_t *attacker,
targ->health = -999;
targ->enemy = attacker;
- targ->die (targ, inflictor, attacker, take, mod);
+ targ->die( targ, inflictor, attacker, take, mod );
return;
}
else if( targ->pain )
- targ->pain (targ, attacker, take);
+ targ->pain( targ, attacker, take );
}
}
@@ -1063,52 +995,52 @@ Returns qtrue if the inflictor can directly damage the target. Used for
explosions and melee attacks.
============
*/
-qboolean CanDamage (gentity_t *targ, vec3_t origin) {
+qboolean CanDamage( gentity_t *targ, vec3_t origin )
+{
vec3_t dest;
trace_t tr;
vec3_t midpoint;
// use the midpoint of the bounds instead of the origin, because
// bmodels may have their origin is 0,0,0
- VectorAdd (targ->r.absmin, targ->r.absmax, midpoint);
- VectorScale (midpoint, 0.5, midpoint);
+ VectorAdd( targ->r.absmin, targ->r.absmax, midpoint );
+ VectorScale( midpoint, 0.5, midpoint );
- VectorCopy (midpoint, dest);
- trap_Trace ( &tr, origin, vec3_origin, vec3_origin, dest, ENTITYNUM_NONE, MASK_SOLID);
- if (tr.fraction == 1.0 || tr.entityNum == targ->s.number)
+ VectorCopy( midpoint, dest );
+ trap_Trace( &tr, origin, vec3_origin, vec3_origin, dest, ENTITYNUM_NONE, MASK_SOLID );
+ if( tr.fraction == 1.0 || tr.entityNum == targ->s.number )
return qtrue;
// this should probably check in the plane of projection,
// rather than in world coordinate, and also include Z
- VectorCopy (midpoint, dest);
- dest[0] += 15.0;
- dest[1] += 15.0;
- trap_Trace ( &tr, origin, vec3_origin, vec3_origin, dest, ENTITYNUM_NONE, MASK_SOLID);
- if (tr.fraction == 1.0)
+ VectorCopy( midpoint, dest );
+ dest[ 0 ] += 15.0;
+ dest[ 1 ] += 15.0;
+ trap_Trace( &tr, origin, vec3_origin, vec3_origin, dest, ENTITYNUM_NONE, MASK_SOLID );
+ if( tr.fraction == 1.0 )
return qtrue;
- VectorCopy (midpoint, dest);
- dest[0] += 15.0;
- dest[1] -= 15.0;
- trap_Trace ( &tr, origin, vec3_origin, vec3_origin, dest, ENTITYNUM_NONE, MASK_SOLID);
- if (tr.fraction == 1.0)
+ VectorCopy( midpoint, dest );
+ dest[ 0 ] += 15.0;
+ dest[ 1 ] -= 15.0;
+ trap_Trace( &tr, origin, vec3_origin, vec3_origin, dest, ENTITYNUM_NONE, MASK_SOLID );
+ if( tr.fraction == 1.0 )
return qtrue;
- VectorCopy (midpoint, dest);
- dest[0] -= 15.0;
- dest[1] += 15.0;
- trap_Trace ( &tr, origin, vec3_origin, vec3_origin, dest, ENTITYNUM_NONE, MASK_SOLID);
- if (tr.fraction == 1.0)
+ VectorCopy( midpoint, dest );
+ dest[ 0 ] -= 15.0;
+ dest[ 1 ] += 15.0;
+ trap_Trace( &tr, origin, vec3_origin, vec3_origin, dest, ENTITYNUM_NONE, MASK_SOLID );
+ if( tr.fraction == 1.0 )
return qtrue;
- VectorCopy (midpoint, dest);
- dest[0] -= 15.0;
- dest[1] -= 15.0;
- trap_Trace ( &tr, origin, vec3_origin, vec3_origin, dest, ENTITYNUM_NONE, MASK_SOLID);
- if (tr.fraction == 1.0)
+ VectorCopy( midpoint, dest );
+ dest[ 0 ] -= 15.0;
+ dest[ 1 ] -= 15.0;
+ trap_Trace( &tr, origin, vec3_origin, vec3_origin, dest, ENTITYNUM_NONE, MASK_SOLID );
+ if( tr.fraction == 1.0 )
return qtrue;
-
return qfalse;
}
@@ -1116,64 +1048,67 @@ qboolean CanDamage (gentity_t *targ, vec3_t origin) {
//TA:
/*
============
-G_RadiusDamage
+G_SelectiveRadiusDamage
============
*/
-qboolean G_SelectiveRadiusDamage ( vec3_t origin, gentity_t *attacker, float damage, float radius,
- gentity_t *ignore, int mod, int team ) {
- float points, dist;
+qboolean G_SelectiveRadiusDamage( vec3_t origin, gentity_t *attacker, float damage,
+ float radius, gentity_t *ignore, int mod, int team )
+{
+ float points, dist;
gentity_t *ent;
- int entityList[MAX_GENTITIES];
- int numListedEntities;
+ int entityList[ MAX_GENTITIES ];
+ int numListedEntities;
vec3_t mins, maxs;
vec3_t v;
vec3_t dir;
- int i, e;
+ int i, e;
qboolean hitClient = qfalse;
- if ( radius < 1 ) {
+ if( radius < 1 )
radius = 1;
- }
- for ( i = 0 ; i < 3 ; i++ ) {
- mins[i] = origin[i] - radius;
- maxs[i] = origin[i] + radius;
+ for( i = 0; i < 3; i++ )
+ {
+ mins[ i ] = origin[ i ] - radius;
+ maxs[ i ] = origin[ i ] + radius;
}
numListedEntities = trap_EntitiesInBox( mins, maxs, entityList, MAX_GENTITIES );
- for ( e = 0 ; e < numListedEntities ; e++ ) {
- ent = &g_entities[entityList[ e ]];
+ for( e = 0; e < numListedEntities; e++ )
+ {
+ ent = &g_entities[ entityList[ e ] ];
- if (ent == ignore)
+ if( ent == ignore )
continue;
- if (!ent->takedamage)
+
+ if( !ent->takedamage )
continue;
// find the distance from the edge of the bounding box
- for ( i = 0 ; i < 3 ; i++ ) {
- if ( origin[i] < ent->r.absmin[i] ) {
- v[i] = ent->r.absmin[i] - origin[i];
- } else if ( origin[i] > ent->r.absmax[i] ) {
- v[i] = origin[i] - ent->r.absmax[i];
- } else {
- v[i] = 0;
- }
+ for( i = 0 ; i < 3 ; i++ )
+ {
+ if( origin[ i ] < ent->r.absmin[ i ] )
+ v[ i ] = ent->r.absmin[ i ] - origin[ i ];
+ else if( origin[ i ] > ent->r.absmax[ i ] )
+ v[ i ] = origin[ i ] - ent->r.absmax[ i ];
+ else
+ v[ i ] = 0;
}
dist = VectorLength( v );
- if ( dist >= radius ) {
+ if( dist >= radius )
continue;
- }
points = damage * ( 1.0 - dist / radius );
- if( CanDamage (ent, origin) ) {
- VectorSubtract (ent->r.currentOrigin, origin, dir);
+ if( CanDamage( ent, origin ) )
+ {
+ VectorSubtract( ent->r.currentOrigin, origin, dir );
// push the center of mass higher than the origin so players
// get knocked into the air more
- dir[2] += 24;
- G_SelectiveDamage (ent, NULL, attacker, dir, origin, (int)points, DAMAGE_RADIUS, mod, team );
+ dir[ 2 ] += 24;
+ G_SelectiveDamage( ent, NULL, attacker, dir, origin, (int)points, DAMAGE_RADIUS, mod, team );
}
}
@@ -1186,61 +1121,64 @@ qboolean G_SelectiveRadiusDamage ( vec3_t origin, gentity_t *attacker, float dam
G_RadiusDamage
============
*/
-qboolean G_RadiusDamage ( vec3_t origin, gentity_t *attacker, float damage, float radius,
- gentity_t *ignore, int mod) {
- float points, dist;
+qboolean G_RadiusDamage( vec3_t origin, gentity_t *attacker, float damage,
+ float radius, gentity_t *ignore, int mod )
+{
+ float points, dist;
gentity_t *ent;
- int entityList[MAX_GENTITIES];
- int numListedEntities;
+ int entityList[ MAX_GENTITIES ];
+ int numListedEntities;
vec3_t mins, maxs;
vec3_t v;
vec3_t dir;
- int i, e;
+ int i, e;
qboolean hitClient = qfalse;
- if ( radius < 1 ) {
+ if( radius < 1 )
radius = 1;
- }
- for ( i = 0 ; i < 3 ; i++ ) {
- mins[i] = origin[i] - radius;
- maxs[i] = origin[i] + radius;
+ for( i = 0; i < 3; i++ )
+ {
+ mins[ i ] = origin[ i ] - radius;
+ maxs[ i ] = origin[ i ] + radius;
}
numListedEntities = trap_EntitiesInBox( mins, maxs, entityList, MAX_GENTITIES );
- for ( e = 0 ; e < numListedEntities ; e++ ) {
- ent = &g_entities[entityList[ e ]];
+ for( e = 0; e < numListedEntities; e++ )
+ {
+ ent = &g_entities[ entityList[ e ] ];
- if (ent == ignore)
+ if( ent == ignore )
continue;
- if (!ent->takedamage)
+
+ if( !ent->takedamage )
continue;
// find the distance from the edge of the bounding box
- for ( i = 0 ; i < 3 ; i++ ) {
- if ( origin[i] < ent->r.absmin[i] ) {
- v[i] = ent->r.absmin[i] - origin[i];
- } else if ( origin[i] > ent->r.absmax[i] ) {
- v[i] = origin[i] - ent->r.absmax[i];
- } else {
- v[i] = 0;
- }
+ for( i = 0; i < 3; i++ )
+ {
+ if( origin[ i ] < ent->r.absmin[ i ] )
+ v[ i ] = ent->r.absmin[ i ] - origin[ i ];
+ else if( origin[ i ] > ent->r.absmax[ i ] )
+ v[ i ] = origin[ i ] - ent->r.absmax[ i ];
+ else
+ v[ i ] = 0;
}
dist = VectorLength( v );
- if ( dist >= radius ) {
+ if( dist >= radius )
continue;
- }
points = damage * ( 1.0 - dist / radius );
- if( CanDamage (ent, origin) ) {
- VectorSubtract (ent->r.currentOrigin, origin, dir);
+ if( CanDamage( ent, origin ) )
+ {
+ VectorSubtract( ent->r.currentOrigin, origin, dir );
// push the center of mass higher than the origin so players
// get knocked into the air more
- dir[2] += 24;
- G_Damage (ent, NULL, attacker, dir, origin, (int)points, DAMAGE_RADIUS, mod);
+ dir[ 2 ] += 24;
+ G_Damage( ent, NULL, attacker, dir, origin, (int)points, DAMAGE_RADIUS, mod );
}
}
diff --git a/src/game/g_local.h b/src/game/g_local.h
index 574cd822..e37bdd57 100644
--- a/src/game/g_local.h
+++ b/src/game/g_local.h
@@ -44,7 +44,8 @@
#define FL_FORCE_GESTURE 0x00008000 // spawn point just for bots
// movers are things like doors, plats, buttons, etc
-typedef enum {
+typedef enum
+{
MOVER_POS1,
MOVER_POS2,
MOVER_1TO2,
@@ -58,146 +59,149 @@ typedef enum {
typedef struct gentity_s gentity_t;
typedef struct gclient_s gclient_t;
-struct gentity_s {
- entityState_t s; // communicated by server to clients
- entityShared_t r; // shared by both the server system and game
+struct gentity_s
+{
+ entityState_t s; // communicated by server to clients
+ entityShared_t r; // shared by both the server system and game
// DO NOT MODIFY ANYTHING ABOVE THIS, THE SERVER
// EXPECTS THE FIELDS IN THAT ORDER!
//================================
- struct gclient_s *client; // NULL if not a client
+ struct gclient_s *client; // NULL if not a client
- qboolean inuse;
+ qboolean inuse;
- char *classname; // set in QuakeEd
- int spawnflags; // set in QuakeEd
+ char *classname; // set in QuakeEd
+ int spawnflags; // set in QuakeEd
- qboolean neverFree; // if true, FreeEntity will only unlink
- // bodyque uses this
+ qboolean neverFree; // if true, FreeEntity will only unlink
+ // bodyque uses this
- int flags; // FL_* variables
+ int flags; // FL_* variables
- char *model;
- char *model2;
- int freetime; // level.time when the object was freed
+ char *model;
+ char *model2;
+ int freetime; // level.time when the object was freed
- int eventTime; // events will be cleared EVENT_VALID_MSEC after set
- qboolean freeAfterEvent;
- qboolean unlinkAfterEvent;
+ int eventTime; // events will be cleared EVENT_VALID_MSEC after set
+ qboolean freeAfterEvent;
+ qboolean unlinkAfterEvent;
- qboolean physicsObject; // if true, it can be pushed by movers and fall off edges
- // all game items are physicsObjects,
- float physicsBounce; // 1.0 = continuous bounce, 0.0 = no bounce
- int clipmask; // brushes with this content value will be collided against
- // when moving. items and corpses do not collide against
- // players, for instance
+ qboolean physicsObject; // if true, it can be pushed by movers and fall off edges
+ // all game items are physicsObjects,
+ float physicsBounce; // 1.0 = continuous bounce, 0.0 = no bounce
+ int clipmask; // brushes with this content value will be collided against
+ // when moving. items and corpses do not collide against
+ // players, for instance
// movers
- moverState_t moverState;
- int soundPos1;
- int sound1to2;
- int sound2to1;
- int soundPos2;
- int soundLoop;
- gentity_t *parent;
- gentity_t *nextTrain;
- gentity_t *prevTrain;
- vec3_t pos1, pos2;
-
- char *message;
-
- int timestamp; // body queue sinking, etc
-
- float angle; // set in editor, -1 = up, -2 = down
- char *target;
- char *targetname;
- char *team;
- char *targetShaderName;
- char *targetShaderNewName;
- gentity_t *target_ent;
-
- float speed;
- vec3_t movedir;
+ moverState_t moverState;
+ int soundPos1;
+ int sound1to2;
+ int sound2to1;
+ int soundPos2;
+ int soundLoop;
+ gentity_t *parent;
+ gentity_t *nextTrain;
+ gentity_t *prevTrain;
+ vec3_t pos1, pos2;
+
+ char *message;
+
+ int timestamp; // body queue sinking, etc
+
+ float angle; // set in editor, -1 = up, -2 = down
+ char *target;
+ char *targetname;
+ char *team;
+ char *targetShaderName;
+ char *targetShaderNewName;
+ gentity_t *target_ent;
+
+ float speed;
+ vec3_t movedir;
//TA: acceleration evaluation
- qboolean evaluateAcceleration;
- vec3_t oldVelocity;
- vec3_t acceleration;
- vec3_t oldAccel;
- vec3_t jerk;
+ qboolean evaluateAcceleration;
+ vec3_t oldVelocity;
+ vec3_t acceleration;
+ vec3_t oldAccel;
+ vec3_t jerk;
- int nextthink;
- void (*think)(gentity_t *self);
- void (*reached)(gentity_t *self); // movers call this when hitting endpoint
- void (*blocked)(gentity_t *self, gentity_t *other);
- void (*touch)(gentity_t *self, gentity_t *other, trace_t *trace);
- void (*use)(gentity_t *self, gentity_t *other, gentity_t *activator);
- void (*pain)(gentity_t *self, gentity_t *attacker, int damage);
- void (*die)(gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int damage, int mod);
+ int nextthink;
+ void (*think)( gentity_t *self );
+ void (*reached)( gentity_t *self ); // movers call this when hitting endpoint
+ void (*blocked)( gentity_t *self, gentity_t *other );
+ void (*touch)( gentity_t *self, gentity_t *other, trace_t *trace );
+ void (*use)( gentity_t *self, gentity_t *other, gentity_t *activator );
+ void (*pain)( gentity_t *self, gentity_t *attacker, int damage );
+ void (*die)( gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int damage, int mod );
- int pain_debounce_time;
- int fly_sound_debounce_time; // wind tunnel
- int last_move_time;
+ int pain_debounce_time;
+ int fly_sound_debounce_time; // wind tunnel
+ int last_move_time;
- int health;
+ int health;
- qboolean takedamage;
+ qboolean takedamage;
- int damage;
- int splashDamage; // quad will increase this without increasing radius
- int splashRadius;
- int methodOfDeath;
- int splashMethodOfDeath;
+ int damage;
+ int splashDamage; // quad will increase this without increasing radius
+ int splashRadius;
+ int methodOfDeath;
+ int splashMethodOfDeath;
- int count;
+ int count;
- gentity_t *chain;
- gentity_t *enemy;
- gentity_t *activator;
- gentity_t *teamchain; // next entity in team
- gentity_t *teammaster; // master of the team
+ gentity_t *chain;
+ gentity_t *enemy;
+ gentity_t *activator;
+ gentity_t *teamchain; // next entity in team
+ gentity_t *teammaster; // master of the team
- int watertype;
- int waterlevel;
+ int watertype;
+ int waterlevel;
- int noise_index;
+ int noise_index;
// timing variables
- float wait;
- float random;
+ float wait;
+ float random;
- gitem_t *item; // for bonus items
+ gitem_t *item; // for bonus items
- int biteam; //TA: buildable item team
- gentity_t *parentNode; //TA: for creep and defence/spawn dependencies
- qboolean active; //TA: for power repeater, but could be useful elsewhere
- qboolean powered; //TA: for human buildables
- int builtBy; //TA: clientNum of person that built this
- gentity_t *dccNode; //TA: controlling dcc
- qboolean dcced; //TA: controlled by a dcc or not?
- int time1000; //TA: timer evaluated every second
+ int biteam; //TA: buildable item team
+ gentity_t *parentNode; //TA: for creep and defence/spawn dependencies
+ qboolean active; //TA: for power repeater, but could be useful elsewhere
+ qboolean powered; //TA: for human buildables
+ int builtBy; //TA: clientNum of person that built this
+ gentity_t *dccNode; //TA: controlling dcc
+ qboolean dcced; //TA: controlled by a dcc or not?
+ int time1000; //TA: timer evaluated every second
- int credits[ MAX_CLIENTS ]; //TA: human credits for each client
- qboolean creditsHash[ MAX_CLIENTS ]; //TA: track who has claimed credit
- int killedBy; //TA: clientNum of killer
+ int credits[ MAX_CLIENTS ]; //TA: human credits for each client
+ qboolean creditsHash[ MAX_CLIENTS ]; //TA: track who has claimed credit
+ int killedBy; //TA: clientNum of killer
- gentity_t *targeted; //TA: true if the player is currently a valid target of a turret
+ gentity_t *targeted; //TA: true if the player is currently a valid target of a turret
- vec4_t animation; //TA: animated map objects
+ vec4_t animation; //TA: animated map objects
- vec3_t turretAim; //TA: aim vector for turrets
+ vec3_t turretAim; //TA: aim vector for turrets
- gentity_t *builder; //TA: occupant of this hovel
+ gentity_t *builder; //TA: occupant of this hovel
};
-typedef enum {
+typedef enum
+{
CON_DISCONNECTED,
CON_CONNECTING,
CON_CONNECTED
} clientConnected_t;
-typedef enum {
+typedef enum
+{
SPECTATOR_NOT,
SPECTATOR_FREE,
SPECTATOR_LOCKED,
@@ -205,12 +209,14 @@ typedef enum {
SPECTATOR_SCOREBOARD
} spectatorState_t;
-typedef enum {
+typedef enum
+{
TEAM_BEGIN, // Beginning a team game, spawn at base
TEAM_ACTIVE // Now actively playing
} playerTeamStateState_t;
-typedef struct {
+typedef struct
+{
playerTeamStateState_t state;
int location;
@@ -237,13 +243,14 @@ typedef struct {
// this is achieved by writing all the data to cvar strings at game shutdown
// time and reading them back at connection time. Anything added here
// MUST be dealt with in G_InitSessionData() / G_ReadSessionData() / G_WriteSessionData()
-typedef struct {
- team_t sessionTeam;
- int spectatorTime; // for determining next-in-line to play
+typedef struct
+{
+ team_t sessionTeam;
+ int spectatorTime; // for determining next-in-line to play
spectatorState_t spectatorState;
- int spectatorClient; // for chasecam and follow mode
- int wins, losses; // tournament stats
- qboolean teamLeader; // true when this client is a team leader
+ int spectatorClient; // for chasecam and follow mode
+ int wins, losses; // tournament stats
+ qboolean teamLeader; // true when this client is a team leader
} clientSession_t;
#define MAX_NETNAME 36
@@ -251,110 +258,112 @@ typedef struct {
// client data that stays across multiple respawns, but is cleared
// on each level change or team change at ClientBegin()
-typedef struct {
+typedef struct
+{
clientConnected_t connected;
- usercmd_t cmd; // we would lose angles if not persistant
- qboolean localClient; // true if "ip" info key is "localhost"
- qboolean initialSpawn; // the first spawn should be at a cool location
- qboolean predictItemPickup; // based on cg_predictItems userinfo
- qboolean pmoveFixed; //
- char netname[ MAX_NETNAME ];
- int maxHealth; // for handicapping
- int enterTime; // level.time the client entered the game
- playerTeamState_t teamState; // status in teamplay games
- int voteCount; // to prevent people from constantly calling votes
- int teamVoteCount; // to prevent people from constantly calling votes
- qboolean teamInfo; // send team overlay updates?
-
- int pclass; //TA: player class (copied to ent->client->ps.stats[ STAT_PCLASS ] once spawned)
- //not really persistant.. this is just a nice place to stick it :)
- int pitem; //TA: humans have a starting item
- int pteam; //TA: player team (copied to ps.stats[ STAT_PTEAM ])
+ usercmd_t cmd; // we would lose angles if not persistant
+ qboolean localClient; // true if "ip" info key is "localhost"
+ qboolean initialSpawn; // the first spawn should be at a cool location
+ qboolean predictItemPickup; // based on cg_predictItems userinfo
+ qboolean pmoveFixed; //
+ char netname[ MAX_NETNAME ];
+ int maxHealth; // for handicapping
+ int enterTime; // level.time the client entered the game
+ playerTeamState_t teamState; // status in teamplay games
+ int voteCount; // to prevent people from constantly calling votes
+ int teamVoteCount; // to prevent people from constantly calling votes
+ qboolean teamInfo; // send team overlay updates?
+
+ int pclass; //TA: player class (copied to ent->client->ps.stats[ STAT_PCLASS ] once spawned)
+ //not really persistant.. this is just a nice place to stick it :)
+ int pitem; //TA: humans have a starting item
+ int pteam; //TA: player team (copied to ps.stats[ STAT_PTEAM ])
} clientPersistant_t;
// this structure is cleared on each ClientSpawn(),
// except for 'client->pers' and 'client->sess'
-struct gclient_s {
+struct gclient_s
+{
// ps MUST be the first element, because the server expects it
- playerState_t ps; // communicated by server to clients
+ playerState_t ps; // communicated by server to clients
// the rest of the structure is private to game
clientPersistant_t pers;
- clientSession_t sess;
+ clientSession_t sess;
- qboolean readyToExit; // wishes to leave the intermission
+ qboolean readyToExit; // wishes to leave the intermission
- qboolean noclip;
+ qboolean noclip;
- int lastCmdTime; // level.time of last usercmd_t, for EF_CONNECTION
- // we can't just use pers.lastCommand.time, because
- // of the g_sycronousclients case
- int buttons;
- int oldbuttons;
- int latched_buttons;
+ int lastCmdTime; // level.time of last usercmd_t, for EF_CONNECTION
+ // we can't just use pers.lastCommand.time, because
+ // of the g_sycronousclients case
+ int buttons;
+ int oldbuttons;
+ int latched_buttons;
- vec3_t oldOrigin;
+ vec3_t oldOrigin;
// sum up damage over an entire frame, so
// shotgun blasts give a single big kick
- int damage_armor; // damage absorbed by armor
- int damage_blood; // damage taken out of health
- int damage_knockback; // impact damage
- vec3_t damage_from; // origin for vector calculation
- qboolean damage_fromWorld; // if true, don't use the damage_from vector
-
- int accurateCount; // for "impressive" reward sound
- int accuracy_shots; // total number of shots
- int accuracy_hits; // total number of hits
+ int damage_armor; // damage absorbed by armor
+ int damage_blood; // damage taken out of health
+ int damage_knockback; // impact damage
+ vec3_t damage_from; // origin for vector calculation
+ qboolean damage_fromWorld; // if true, don't use the damage_from vector
+
+ int accurateCount; // for "impressive" reward sound
+ int accuracy_shots; // total number of shots
+ int accuracy_hits; // total number of hits
//
- int lastkilled_client; // last client that this client killed
- int lasthurt_client; // last client that damaged this client
- int lasthurt_mod; // type of damage the client did
+ int lastkilled_client;// last client that this client killed
+ int lasthurt_client; // last client that damaged this client
+ int lasthurt_mod; // type of damage the client did
// timers
- int respawnTime; // can respawn when time > this, force after g_forcerespwan
- int inactivityTime; // kick players when time > this
- qboolean inactivityWarning; // qtrue if the five seoond warning has been given
- int rewardTime; // clear the EF_AWARD_IMPRESSIVE, etc when time > this
+ int respawnTime; // can respawn when time > this, force after g_forcerespwan
+ int inactivityTime; // kick players when time > this
+ qboolean inactivityWarning;// qtrue if the five seoond warning has been given
+ int rewardTime; // clear the EF_AWARD_IMPRESSIVE, etc when time > this
- int airOutTime;
+ int airOutTime;
- int lastKillTime; // for multiple kill rewards
+ int lastKillTime; // for multiple kill rewards
- qboolean fireHeld; // used for hook
- qboolean fire2Held; // used for alt fire
- gentity_t *hook; // grapple hook if out
+ qboolean fireHeld; // used for hook
+ qboolean fire2Held; // used for alt fire
+ gentity_t *hook; // grapple hook if out
- int switchTeamTime; // time the player switched teams
+ int switchTeamTime; // time the player switched teams
// timeResidual is used to handle events that happen every second
// like health / armor countdowns and regeneration
//TA: two timers, one every 100 msecs, another every sec
- int time100;
- int time1000;
+ int time100;
+ int time1000;
- char *areabits;
+ char *areabits;
- int lastInfestTime; //TA: to keep track of how long infests take
- gentity_t *infestBody; //TA: body that is being infested. must be persistant
+ int lastInfestTime; //TA: to keep track of how long infests take
+ gentity_t *infestBody; //TA: body that is being infested. must be persistant
- int lastPoisonTime;
- int lastPoisonCloudedTime;
- int lastGrabTime;
- int lastLockTime;
- int lastSlowTime;
- int lastBoostedTime;
- int lastKnockedOverTime;
- int lastGetUpTime;
+ int lastPoisonTime;
+ int lastPoisonCloudedTime;
+ int lastGrabTime;
+ int lastLockTime;
+ int lastSlowTime;
+ int lastBoostedTime;
+ int lastKnockedOverTime;
+ int lastGetUpTime;
- int pouncePayload; //TA: amount of damage pounce attack will do
- qboolean allowedToPounce;
+ int pouncePayload; //TA: amount of damage pounce attack will do
+ qboolean allowedToPounce;
- vec3_t hovelOrigin; //TA: player origin before entering hovel
+ vec3_t hovelOrigin; //TA: player origin before entering hovel
- int lastFlameBall; //TA: s.number of the last flame ball fired
+ int lastFlameBall; //TA: s.number of the last flame ball fired
- int lastRefilTime; //TA: last time human got a refil from rpt/rctr
+ int lastRefilTime; //TA: last time human got a refil from rpt/rctr
};
#define MAX_LOCDAMAGE_TEXT 8192
@@ -391,102 +400,103 @@ typedef struct armourRegion_s
#define MAX_SPAWN_VARS 64
#define MAX_SPAWN_VARS_CHARS 4096
-typedef struct {
+typedef struct
+{
struct gclient_s *clients; // [maxclients]
struct gentity_s *gentities;
- int gentitySize;
- int num_entities; // current number, <= MAX_GENTITIES
+ int gentitySize;
+ int num_entities; // current number, <= MAX_GENTITIES
- int warmupTime; // restart match at this time
+ int warmupTime; // restart match at this time
- fileHandle_t logFile;
+ fileHandle_t logFile;
// store latched cvars here that we want to get at often
- int maxclients;
+ int maxclients;
- int framenum;
- int time; // in msec
- int previousTime; // so movers can back up when blocked
+ int framenum;
+ int time; // in msec
+ int previousTime; // so movers can back up when blocked
- int startTime; // level.time the map was started
+ int startTime; // level.time the map was started
- int teamScores[TEAM_NUM_TEAMS];
- int lastTeamLocationTime; // last time of client team location update
+ int teamScores[ TEAM_NUM_TEAMS ];
+ int lastTeamLocationTime; // last time of client team location update
- qboolean newSession; // don't use any old session data, because
- // we changed gametype
+ qboolean newSession; // don't use any old session data, because
+ // we changed gametype
- qboolean restarted; // waiting for a map_restart to fire
+ qboolean restarted; // waiting for a map_restart to fire
- int numConnectedClients;
- int numNonSpectatorClients; // includes connecting clients
- int numPlayingClients; // connected, non-spectators
- int sortedClients[MAX_CLIENTS]; // sorted by score
- int follow1, follow2; // clientNums for auto-follow spectators
+ int numConnectedClients;
+ int numNonSpectatorClients; // includes connecting clients
+ int numPlayingClients; // connected, non-spectators
+ int sortedClients[MAX_CLIENTS]; // sorted by score
+ int follow1, follow2; // clientNums for auto-follow spectators
- int snd_fry; // sound index for standing in lava
+ int snd_fry; // sound index for standing in lava
- int warmupModificationCount; // for detecting if g_warmup is changed
+ int warmupModificationCount; // for detecting if g_warmup is changed
// voting state
- char voteString[MAX_STRING_CHARS];
- char voteDisplayString[MAX_STRING_CHARS];
- int voteTime; // level.time vote was called
- int voteExecuteTime; // time the vote is executed
- int voteYes;
- int voteNo;
- int numVotingClients; // set by CalculateRanks
+ char voteString[MAX_STRING_CHARS];
+ char voteDisplayString[MAX_STRING_CHARS];
+ int voteTime; // level.time vote was called
+ int voteExecuteTime; // time the vote is executed
+ int voteYes;
+ int voteNo;
+ int numVotingClients; // set by CalculateRanks
// team voting state
- char teamVoteString[2][MAX_STRING_CHARS];
- int teamVoteTime[2]; // level.time vote was called
- int teamVoteYes[2];
- int teamVoteNo[2];
- int numteamVotingClients[2];// set by CalculateRanks
+ char teamVoteString[ 2 ][ MAX_STRING_CHARS ];
+ int teamVoteTime[ 2 ]; // level.time vote was called
+ int teamVoteYes[ 2 ];
+ int teamVoteNo[ 2 ];
+ int numteamVotingClients[ 2 ]; // set by CalculateRanks
// spawn variables
- qboolean spawning; // the G_Spawn*() functions are valid
- int numSpawnVars;
- char *spawnVars[MAX_SPAWN_VARS][2]; // key / value pairs
- int numSpawnVarChars;
- char spawnVarChars[MAX_SPAWN_VARS_CHARS];
+ qboolean spawning; // the G_Spawn*() functions are valid
+ int numSpawnVars;
+ char *spawnVars[ MAX_SPAWN_VARS ][ 2 ]; // key / value pairs
+ int numSpawnVarChars;
+ char spawnVarChars[ MAX_SPAWN_VARS_CHARS ];
// intermission state
- int intermissionQueued; // intermission was qualified, but
- // wait INTERMISSION_DELAY_TIME before
- // actually going there so the last
- // frag can be watched. Disable future
- // kills during this delay
- int intermissiontime; // time the intermission was started
- char *changemap;
- qboolean readyToExit; // at least one client wants to exit
- int exitTime;
- vec3_t intermission_origin; // also used for spectator spawns
- vec3_t intermission_angle;
-
- qboolean locationLinked; // target_locations get linked
- gentity_t *locationHead; // head of the location list
+ int intermissionQueued; // intermission was qualified, but
+ // wait INTERMISSION_DELAY_TIME before
+ // actually going there so the last
+ // frag can be watched. Disable future
+ // kills during this delay
+ int intermissiontime; // time the intermission was started
+ char *changemap;
+ qboolean readyToExit; // at least one client wants to exit
+ int exitTime;
+ vec3_t intermission_origin; // also used for spectator spawns
+ vec3_t intermission_angle;
+
+ qboolean locationLinked; // target_locations get linked
+ gentity_t *locationHead; // head of the location list
//TA: extra stuff:
- int numAlienSpawns;
- int numHumanSpawns;
+ int numAlienSpawns;
+ int numHumanSpawns;
- int numAlienClients;
- int numHumanClients;
+ int numAlienClients;
+ int numHumanClients;
- int numLiveAlienClients;
- int numLiveHumanClients;
+ int numLiveAlienClients;
+ int numLiveHumanClients;
- int alienBuildPoints;
- int humanBuildPoints;
- int humanBuildPointsPowered;
+ int alienBuildPoints;
+ int humanBuildPoints;
+ int humanBuildPointsPowered;
- int bankCredits[ MAX_CLIENTS ]; //global credits storage
- int oBankCredits[ MAX_CLIENTS ]; //global credits storage
+ int bankCredits[ MAX_CLIENTS ]; //global credits storage
+ int oBankCredits[ MAX_CLIENTS ]; //global credits storage
- int alienKills;
- int humanKills;
+ int alienKills;
+ int humanKills;
} level_locals_t;
//
@@ -497,8 +507,8 @@ qboolean G_SpawnString( const char *key, const char *defaultString, char **out
qboolean G_SpawnFloat( const char *key, const char *defaultString, float *out );
qboolean G_SpawnInt( const char *key, const char *defaultString, int *out );
qboolean G_SpawnVector( const char *key, const char *defaultString, float *out );
-void G_SpawnEntitiesFromString( void );
-char *G_NewString( const char *string );
+void G_SpawnEntitiesFromString( void );
+char *G_NewString( const char *string );
//
// g_cmds.c
@@ -549,49 +559,53 @@ void FinishSpawningBuildable( gentity_t *ent );
//
// g_utils.c
//
-int G_ModelIndex( char *name );
-int G_SoundIndex( char *name );
-void G_TeamCommand( pTeam_t team, char *cmd );
-void G_KillBox (gentity_t *ent);
-gentity_t *G_Find (gentity_t *from, int fieldofs, const char *match);
-gentity_t *G_PickTarget (char *targetname);
-void G_UseTargets (gentity_t *ent, gentity_t *activator);
-void G_SetMovedir ( vec3_t angles, vec3_t movedir);
-
-void G_InitGentity( gentity_t *e );
-gentity_t *G_Spawn (void);
-gentity_t *G_TempEntity( vec3_t origin, int event );
-void G_Sound( gentity_t *ent, int channel, int soundIndex );
-void G_FreeEntity( gentity_t *e );
-qboolean G_EntitiesFree( void );
-
-void G_TouchTriggers (gentity_t *ent);
-void G_TouchSolids (gentity_t *ent);
-
-float *tv (float x, float y, float z);
-char *vtos( const vec3_t v );
-
-float vectoyaw( const vec3_t vec );
-
-void G_AddPredictableEvent( gentity_t *ent, int event, int eventParm );
-void G_AddEvent( gentity_t *ent, int event, int eventParm );
-void G_SetOrigin( gentity_t *ent, vec3_t origin );
-void AddRemap(const char *oldShader, const char *newShader, float timeOffset);
-const char *BuildShaderStateConfig();
+int G_ModelIndex( char *name );
+int G_SoundIndex( char *name );
+void G_TeamCommand( pTeam_t team, char *cmd );
+void G_KillBox (gentity_t *ent);
+gentity_t *G_Find (gentity_t *from, int fieldofs, const char *match);
+gentity_t *G_PickTarget (char *targetname);
+void G_UseTargets (gentity_t *ent, gentity_t *activator);
+void G_SetMovedir ( vec3_t angles, vec3_t movedir);
+
+void G_InitGentity( gentity_t *e );
+gentity_t *G_Spawn( void );
+gentity_t *G_TempEntity( vec3_t origin, int event );
+void G_Sound( gentity_t *ent, int channel, int soundIndex );
+void G_FreeEntity( gentity_t *e );
+qboolean G_EntitiesFree( void );
+
+void G_TouchTriggers( gentity_t *ent );
+void G_TouchSolids( gentity_t *ent );
+
+float *tv( float x, float y, float z );
+char *vtos( const vec3_t v );
+
+float vectoyaw( const vec3_t vec );
+
+void G_AddPredictableEvent( gentity_t *ent, int event, int eventParm );
+void G_AddEvent( gentity_t *ent, int event, int eventParm );
+void G_SetOrigin( gentity_t *ent, vec3_t origin );
+void AddRemap(const char *oldShader, const char *newShader, float timeOffset);
+const char *BuildShaderStateConfig();
//
// g_combat.c
//
-qboolean CanDamage (gentity_t *targ, vec3_t origin);
-void G_Damage (gentity_t *targ, gentity_t *inflictor, gentity_t *attacker, vec3_t dir, vec3_t point, int damage, int dflags, int mod);
-void G_SelectiveDamage (gentity_t *targ, gentity_t *inflictor, gentity_t *attacker, vec3_t dir, vec3_t point, int damage, int dflags, int mod, int team);
-qboolean G_RadiusDamage (vec3_t origin, gentity_t *attacker, float damage, float radius, gentity_t *ignore, int mod);
-qboolean G_SelectiveRadiusDamage (vec3_t origin, gentity_t *attacker, float damage, float radius, gentity_t *ignore, int mod, int team );
-void body_die( gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int damage, int meansOfDeath );
-void TossClientItems( gentity_t *self );
+qboolean CanDamage( gentity_t *targ, vec3_t origin );
+void G_Damage( gentity_t *targ, gentity_t *inflictor, gentity_t *attacker,
+ vec3_t dir, vec3_t point, int damage, int dflags, int mod );
+void G_SelectiveDamage( gentity_t *targ, gentity_t *inflictor, gentity_t *attacker, vec3_t dir,
+ vec3_t point, int damage, int dflags, int mod, int team );
+qboolean G_RadiusDamage( vec3_t origin, gentity_t *attacker, float damage, float radius,
+ gentity_t *ignore, int mod );
+qboolean G_SelectiveRadiusDamage( vec3_t origin, gentity_t *attacker, float damage, float radius,
+ gentity_t *ignore, int mod, int team );
+void body_die( gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int damage, int meansOfDeath );
+void AddScore( gentity_t *ent, int score );
//TA:
-void G_InitDamageLocations( );
+void G_InitDamageLocations( void );
// damage flags
#define DAMAGE_RADIUS 0x00000001 // damage was indirect
@@ -602,20 +616,15 @@ void G_InitDamageLocations( );
//
// g_missile.c
//
-void G_RunMissile( gentity_t *ent );
+void G_RunMissile( gentity_t *ent );
-gentity_t *fire_blaster( gentity_t *self, vec3_t start, vec3_t aimdir );
gentity_t *fire_flamer( gentity_t *self, vec3_t start, vec3_t aimdir );
gentity_t *fire_plasma( gentity_t *self, vec3_t start, vec3_t aimdir );
gentity_t *fire_pulseRifle( gentity_t *self, vec3_t start, vec3_t dir );
gentity_t *fire_luciferCanon( gentity_t *self, vec3_t start, vec3_t dir, int damage );
-gentity_t *fire_grenade( gentity_t *self, vec3_t start, vec3_t aimdir );
-gentity_t *fire_rocket( gentity_t *self, vec3_t start, vec3_t dir );
gentity_t *fire_lockblob( gentity_t *self, vec3_t start, vec3_t dir );
gentity_t *fire_paraLockBlob( gentity_t *self, vec3_t start, vec3_t dir );
gentity_t *fire_slowBlob( gentity_t *self, vec3_t start, vec3_t dir );
-gentity_t *fire_bfg( gentity_t *self, vec3_t start, vec3_t dir );
-gentity_t *fire_grapple( gentity_t *self, vec3_t start, vec3_t dir );
//
@@ -627,7 +636,7 @@ void Touch_DoorTrigger( gentity_t *ent, gentity_t *other, trace_t *trace );
//
// g_trigger.c
//
-void trigger_teleporter_touch (gentity_t *self, gentity_t *other, trace_t *trace );
+void trigger_teleporter_touch( gentity_t *self, gentity_t *other, trace_t *trace );
//
@@ -639,46 +648,32 @@ void ShineTorch( gentity_t *self );
//
// g_weapon.c
//
-qboolean LogAccuracyHit( gentity_t *target, gentity_t *attacker );
-void CalcMuzzlePoint( gentity_t *ent, vec3_t forward, vec3_t right, vec3_t up, vec3_t muzzlePoint );
-void SnapVectorTowards( vec3_t v, vec3_t to );
-qboolean CheckVenomAttack( gentity_t *ent );
-void CheckGrabAttack( gentity_t *ent );
-qboolean CheckPounceAttack( gentity_t *ent );
-void Weapon_HookFree (gentity_t *ent);
-void Weapon_HookThink (gentity_t *ent);
+void CalcMuzzlePoint( gentity_t *ent, vec3_t forward, vec3_t right, vec3_t up, vec3_t muzzlePoint );
+void SnapVectorTowards( vec3_t v, vec3_t to );
+qboolean CheckVenomAttack( gentity_t *ent );
+void CheckGrabAttack( gentity_t *ent );
+qboolean CheckPounceAttack( gentity_t *ent );
//
// g_client.c
//
-team_t TeamCount( int ignoreClientNum, int team );
-int TeamLeader( int team );
-void SetClientViewAngle( gentity_t *ent, vec3_t angle );
-gentity_t *SelectSpawnPoint ( vec3_t avoidPoint, vec3_t origin, vec3_t angles );
-void SpawnCorpse( gentity_t *ent );
-void respawn (gentity_t *ent);
-void BeginIntermission (void);
-void InitClientPersistant (gclient_t *client);
-void InitClientResp (gclient_t *client);
-void InitBodyQue (void);
-void ClientSpawn( gentity_t *ent, gentity_t *spawn );
-void player_die (gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int damage, int mod);
-void AddScore( gentity_t *ent, int score );
-
-//TA: extra bits
-void AddPoints( gentity_t *ent, int score );
-int CalculatePoints( gentity_t *victim, gentity_t *attacker );
-
-void CalculateRanks( void );
-qboolean SpotWouldTelefrag( gentity_t *spot );
+team_t TeamCount( int ignoreClientNum, int team );
+void SetClientViewAngle( gentity_t *ent, vec3_t angle );
+gentity_t *SelectSpawnPoint( vec3_t avoidPoint, vec3_t origin, vec3_t angles );
+void SpawnCorpse( gentity_t *ent );
+void respawn( gentity_t *ent );
+void BeginIntermission( void );
+void ClientSpawn( gentity_t *ent, gentity_t *spawn );
+void player_die( gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int damage, int mod );
+qboolean SpotWouldTelefrag( gentity_t *spot );
//
// g_svcmds.c
//
qboolean ConsoleCommand( void );
-void G_ProcessIPBans(void);
-qboolean G_FilterPacket (char *from);
+void G_ProcessIPBans( void );
+qboolean G_FilterPacket( char *from );
//
// g_weapon.c
@@ -688,28 +683,17 @@ void FireWeapon2( gentity_t *ent );
void FireWeapon3( gentity_t *ent );
//
-// p_hud.c
-//
-void MoveClientToIntermission (gentity_t *client);
-void G_SetStats (gentity_t *ent);
-void ScoreboardMessage (gentity_t *client);
-
-//
// g_cmds.c
//
//
-// g_pweapon.c
-//
-
-
-//
// g_main.c
//
+void ScoreboardMessage( gentity_t *client );
+void MoveClientToIntermission( gentity_t *client );
+void CalculateRanks( void );
void FindIntermissionPoint( void );
-void SetLeader(int team, int client);
-void CheckTeamLeader( int team );
-void G_RunThink (gentity_t *ent);
+void G_RunThink( gentity_t *ent );
void QDECL G_LogPrintf( const char *fmt, ... );
void SendScoreboardMessageToAllClients( void );
void QDECL G_Printf( const char *fmt, ... );
@@ -734,8 +718,11 @@ void G_RunClient( gentity_t *ent );
//
// g_team.c
//
-qboolean OnSameTeam( gentity_t *ent1, gentity_t *ent2 );
-void Team_CheckDroppedItem( gentity_t *dropped );
+qboolean OnSameTeam( gentity_t *ent1, gentity_t *ent2 );
+gentity_t *Team_GetLocation( gentity_t *ent );
+qboolean Team_GetLocationMsg( gentity_t *ent, char *loc, int loclen );
+void TeamplayInfoMessage( gentity_t *ent );
+void CheckTeamStatus( void );
//
// g_mem.c
@@ -751,56 +738,13 @@ void Svcmd_GameMem_f( void );
//
void G_ReadSessionData( gclient_t *client );
void G_InitSessionData( gclient_t *client, char *userinfo );
-
-void G_InitWorldSession( void );
void G_WriteSessionData( void );
-//
-// g_arenas.c
-//
-void UpdateTournamentInfo( void );
-void SpawnModelsOnVictoryPads( void );
-void Svcmd_AbortPodium_f( void );
-
-//
-// g_bot.c
-//
-/*void G_InitBots( qboolean restart );
-char *G_GetBotInfoByNumber( int num );
-char *G_GetBotInfoByName( const char *name );
-void G_CheckBotSpawn( void );
-void G_QueueBotBegin( int clientNum );
-qboolean G_BotConnect( int clientNum, qboolean restart );
-void Svcmd_AddBot_f( void );
-void Svcmd_BotList_f( void );
-void BotInterbreedEndMatch( void );*/
-
-// ai_main.c
-
//some maxs
#define MAX_FILEPATH 144
-//bot settings
-/*typedef struct bot_settings_s
-{
- char characterfile[MAX_FILEPATH];
- float skill;
- char team[MAX_FILEPATH];
-} bot_settings_t;
-
-int BotAISetup( int restart );
-int BotAIShutdown( int restart );
-int BotAILoadMap( int restart );
-int BotAISetupClient( int client, bot_settings_t *settings );
-int BotAIShutdownClient( int client );
-int BotAIStartFrame( int time );*/
-
-
-#include "g_team.h" // teamplay specific stuff
-
-
extern level_locals_t level;
-extern gentity_t g_entities[MAX_GENTITIES];
+extern gentity_t g_entities[ MAX_GENTITIES ];
#define FOFS(x) ((int)&(((gentity_t *)0)->x))
@@ -811,9 +755,7 @@ extern vmCvar_t g_maxGameClients; // allow this many active
extern vmCvar_t g_restarted;
extern vmCvar_t g_dmflags;
-extern vmCvar_t g_fraglimit;
extern vmCvar_t g_timelimit;
-extern vmCvar_t g_capturelimit;
extern vmCvar_t g_friendlyFire;
extern vmCvar_t g_password;
extern vmCvar_t g_needpass;
@@ -857,208 +799,52 @@ extern vmCvar_t g_alienMaxStage;
extern vmCvar_t g_alienStage2Threshold;
extern vmCvar_t g_alienStage3Threshold;
-void trap_Printf( const char *fmt );
-void trap_Error( const char *fmt );
-int trap_Milliseconds( void );
-int trap_Argc( void );
-void trap_Argv( int n, char *buffer, int bufferLength );
-void trap_Args( char *buffer, int bufferLength );
-int trap_FS_FOpenFile( const char *qpath, fileHandle_t *f, fsMode_t mode );
-void trap_FS_Read( void *buffer, int len, fileHandle_t f );
-void trap_FS_Write( const void *buffer, int len, fileHandle_t f );
-void trap_FS_FCloseFile( fileHandle_t f );
-int trap_FS_GetFileList( const char *path, const char *extension, char *listbuf, int bufsize );
-void trap_SendConsoleCommand( int exec_when, const char *text );
-void trap_Cvar_Register( vmCvar_t *cvar, const char *var_name, const char *value, int flags );
-void trap_Cvar_Update( vmCvar_t *cvar );
-void trap_Cvar_Set( const char *var_name, const char *value );
-int trap_Cvar_VariableIntegerValue( const char *var_name );
-float trap_Cvar_VariableValue( const char *var_name );
-void trap_Cvar_VariableStringBuffer( const char *var_name, char *buffer, int bufsize );
-void trap_LocateGameData( gentity_t *gEnts, int numGEntities, int sizeofGEntity_t, playerState_t *gameClients, int sizeofGameClient );
-void trap_DropClient( int clientNum, const char *reason );
-void trap_SendServerCommand( int clientNum, const char *text );
-void trap_SetConfigstring( int num, const char *string );
-void trap_GetConfigstring( int num, char *buffer, int bufferSize );
-void trap_GetUserinfo( int num, char *buffer, int bufferSize );
-void trap_SetUserinfo( int num, const char *buffer );
-void trap_GetServerinfo( char *buffer, int bufferSize );
-void trap_SetBrushModel( gentity_t *ent, const char *name );
-void trap_Trace( trace_t *results, const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end, int passEntityNum, int contentmask );
-int trap_PointContents( const vec3_t point, int passEntityNum );
-qboolean trap_InPVS( const vec3_t p1, const vec3_t p2 );
-qboolean trap_InPVSIgnorePortals( const vec3_t p1, const vec3_t p2 );
-void trap_AdjustAreaPortalState( gentity_t *ent, qboolean open );
-qboolean trap_AreasConnected( int area1, int area2 );
-void trap_LinkEntity( gentity_t *ent );
-void trap_UnlinkEntity( gentity_t *ent );
-int trap_EntitiesInBox( const vec3_t mins, const vec3_t maxs, int *entityList, int maxcount );
-qboolean trap_EntityContact( const vec3_t mins, const vec3_t maxs, const gentity_t *ent );
-int trap_BotAllocateClient( void );
-void trap_BotFreeClient( int clientNum );
-void trap_GetUsercmd( int clientNum, usercmd_t *cmd );
+void trap_Printf( const char *fmt );
+void trap_Error( const char *fmt );
+int trap_Milliseconds( void );
+int trap_Argc( void );
+void trap_Argv( int n, char *buffer, int bufferLength );
+void trap_Args( char *buffer, int bufferLength );
+int trap_FS_FOpenFile( const char *qpath, fileHandle_t *f, fsMode_t mode );
+void trap_FS_Read( void *buffer, int len, fileHandle_t f );
+void trap_FS_Write( const void *buffer, int len, fileHandle_t f );
+void trap_FS_FCloseFile( fileHandle_t f );
+int trap_FS_GetFileList( const char *path, const char *extension, char *listbuf, int bufsize );
+void trap_SendConsoleCommand( int exec_when, const char *text );
+void trap_Cvar_Register( vmCvar_t *cvar, const char *var_name, const char *value, int flags );
+void trap_Cvar_Update( vmCvar_t *cvar );
+void trap_Cvar_Set( const char *var_name, const char *value );
+int trap_Cvar_VariableIntegerValue( const char *var_name );
+float trap_Cvar_VariableValue( const char *var_name );
+void trap_Cvar_VariableStringBuffer( const char *var_name, char *buffer, int bufsize );
+void trap_LocateGameData( gentity_t *gEnts, int numGEntities, int sizeofGEntity_t,
+ playerState_t *gameClients, int sizeofGameClient );
+void trap_DropClient( int clientNum, const char *reason );
+void trap_SendServerCommand( int clientNum, const char *text );
+void trap_SetConfigstring( int num, const char *string );
+void trap_GetConfigstring( int num, char *buffer, int bufferSize );
+void trap_GetUserinfo( int num, char *buffer, int bufferSize );
+void trap_SetUserinfo( int num, const char *buffer );
+void trap_GetServerinfo( char *buffer, int bufferSize );
+void trap_SetBrushModel( gentity_t *ent, const char *name );
+void trap_Trace( trace_t *results, const vec3_t start, const vec3_t mins, const vec3_t maxs,
+ const vec3_t end, int passEntityNum, int contentmask );
+int trap_PointContents( const vec3_t point, int passEntityNum );
+qboolean trap_InPVS( const vec3_t p1, const vec3_t p2 );
+qboolean trap_InPVSIgnorePortals( const vec3_t p1, const vec3_t p2 );
+void trap_AdjustAreaPortalState( gentity_t *ent, qboolean open );
+qboolean trap_AreasConnected( int area1, int area2 );
+void trap_LinkEntity( gentity_t *ent );
+void trap_UnlinkEntity( gentity_t *ent );
+int trap_EntitiesInBox( const vec3_t mins, const vec3_t maxs, int *entityList, int maxcount );
+qboolean trap_EntityContact( const vec3_t mins, const vec3_t maxs, const gentity_t *ent );
+int trap_BotAllocateClient( void );
+void trap_BotFreeClient( int clientNum );
+void trap_GetUsercmd( int clientNum, usercmd_t *cmd );
qboolean trap_GetEntityToken( char *buffer, int bufferSize );
-int trap_DebugPolygonCreate(int color, int numPoints, vec3_t *points);
-void trap_DebugPolygonDelete(int id);
-
-int trap_BotLibSetup( void );
-int trap_BotLibShutdown( void );
-int trap_BotLibVarSet(char *var_name, char *value);
-int trap_BotLibVarGet(char *var_name, char *value, int size);
-int trap_BotLibDefine(char *string);
-int trap_BotLibStartFrame(float time);
-int trap_BotLibLoadMap(const char *mapname);
-int trap_BotLibUpdateEntity(int ent, void /* struct bot_updateentity_s */ *bue);
-int trap_BotLibTest(int parm0, char *parm1, vec3_t parm2, vec3_t parm3);
-
-int trap_BotGetSnapshotEntity( int clientNum, int sequence );
-int trap_BotGetServerCommand(int clientNum, char *message, int size);
-void trap_BotUserCommand(int client, usercmd_t *ucmd);
-
-int trap_AAS_BBoxAreas(vec3_t absmins, vec3_t absmaxs, int *areas, int maxareas);
-int trap_AAS_AreaInfo( int areanum, void /* struct aas_areainfo_s */ *info );
-void trap_AAS_EntityInfo(int entnum, void /* struct aas_entityinfo_s */ *info);
-
-int trap_AAS_Initialized(void);
-void trap_AAS_PresenceTypeBoundingBox(int presencetype, vec3_t mins, vec3_t maxs);
-float trap_AAS_Time(void);
-
-int trap_AAS_PointAreaNum(vec3_t point);
-int trap_AAS_PointReachabilityAreaIndex(vec3_t point);
-int trap_AAS_TraceAreas(vec3_t start, vec3_t end, int *areas, vec3_t *points, int maxareas);
-
-int trap_AAS_PointContents(vec3_t point);
-int trap_AAS_NextBSPEntity(int ent);
-int trap_AAS_ValueForBSPEpairKey(int ent, char *key, char *value, int size);
-int trap_AAS_VectorForBSPEpairKey(int ent, char *key, vec3_t v);
-int trap_AAS_FloatForBSPEpairKey(int ent, char *key, float *value);
-int trap_AAS_IntForBSPEpairKey(int ent, char *key, int *value);
-
-int trap_AAS_AreaReachability(int areanum);
-
-int trap_AAS_AreaTravelTimeToGoalArea(int areanum, vec3_t origin, int goalareanum, int travelflags);
-int trap_AAS_EnableRoutingArea( int areanum, int enable );
-int trap_AAS_PredictRoute(void /*struct aas_predictroute_s*/ *route, int areanum, vec3_t origin,
- int goalareanum, int travelflags, int maxareas, int maxtime,
- int stopevent, int stopcontents, int stoptfl, int stopareanum);
-
-int trap_AAS_AlternativeRouteGoals(vec3_t start, int startareanum, vec3_t goal, int goalareanum, int travelflags,
- void /*struct aas_altroutegoal_s*/ *altroutegoals, int maxaltroutegoals,
- int type);
-
-int trap_AAS_Swimming(vec3_t origin);
-int trap_AAS_PredictClientMovement(void /* aas_clientmove_s */ *move, int entnum, vec3_t origin, int presencetype, int onground, vec3_t velocity, vec3_t cmdmove, int cmdframes, int maxframes, float frametime, int stopevent, int stopareanum, int visualize);
-
-
-void trap_EA_Say(int client, char *str);
-void trap_EA_SayTeam(int client, char *str);
-void trap_EA_Command(int client, char *command);
-
-void trap_EA_Action(int client, int action);
-void trap_EA_Gesture(int client);
-
-void trap_EA_Talk(int client);
-void trap_EA_Attack(int client);
-void trap_EA_Use(int client);
-void trap_EA_Respawn(int client);
-void trap_EA_Crouch(int client);
-void trap_EA_MoveUp(int client);
-void trap_EA_MoveDown(int client);
-void trap_EA_MoveForward(int client);
-void trap_EA_MoveBack(int client);
-void trap_EA_MoveLeft(int client);
-void trap_EA_MoveRight(int client);
-void trap_EA_SelectWeapon(int client, int weapon);
-void trap_EA_Jump(int client);
-void trap_EA_DelayedJump(int client);
-void trap_EA_Move(int client, vec3_t dir, float speed);
-void trap_EA_View(int client, vec3_t viewangles);
-
-void trap_EA_EndRegular(int client, float thinktime);
-void trap_EA_GetInput(int client, float thinktime, void /* struct bot_input_s */ *input);
-void trap_EA_ResetInput(int client);
-
-
-int trap_BotLoadCharacter(char *charfile, float skill);
-void trap_BotFreeCharacter(int character);
-float trap_Characteristic_Float(int character, int index);
-float trap_Characteristic_BFloat(int character, int index, float min, float max);
-int trap_Characteristic_Integer(int character, int index);
-int trap_Characteristic_BInteger(int character, int index, int min, int max);
-void trap_Characteristic_String(int character, int index, char *buf, int size);
-
-int trap_BotAllocChatState(void);
-void trap_BotFreeChatState(int handle);
-void trap_BotQueueConsoleMessage(int chatstate, int type, char *message);
-void trap_BotRemoveConsoleMessage(int chatstate, int handle);
-int trap_BotNextConsoleMessage(int chatstate, void /* struct bot_consolemessage_s */ *cm);
-int trap_BotNumConsoleMessages(int chatstate);
-void trap_BotInitialChat(int chatstate, char *type, int mcontext, char *var0, char *var1, char *var2, char *var3, char *var4, char *var5, char *var6, char *var7 );
-int trap_BotNumInitialChats(int chatstate, char *type);
-int trap_BotReplyChat(int chatstate, char *message, int mcontext, int vcontext, char *var0, char *var1, char *var2, char *var3, char *var4, char *var5, char *var6, char *var7 );
-int trap_BotChatLength(int chatstate);
-void trap_BotEnterChat(int chatstate, int client, int sendto);
-void trap_BotGetChatMessage(int chatstate, char *buf, int size);
-int trap_StringContains(char *str1, char *str2, int casesensitive);
-int trap_BotFindMatch(char *str, void /* struct bot_match_s */ *match, unsigned long int context);
-void trap_BotMatchVariable(void /* struct bot_match_s */ *match, int variable, char *buf, int size);
-void trap_UnifyWhiteSpaces(char *string);
-void trap_BotReplaceSynonyms(char *string, unsigned long int context);
-int trap_BotLoadChatFile(int chatstate, char *chatfile, char *chatname);
-void trap_BotSetChatGender(int chatstate, int gender);
-void trap_BotSetChatName(int chatstate, char *name, int client);
-void trap_BotResetGoalState(int goalstate);
-void trap_BotRemoveFromAvoidGoals(int goalstate, int number);
-void trap_BotResetAvoidGoals(int goalstate);
-void trap_BotPushGoal(int goalstate, void /* struct bot_goal_s */ *goal);
-void trap_BotPopGoal(int goalstate);
-void trap_BotEmptyGoalStack(int goalstate);
-void trap_BotDumpAvoidGoals(int goalstate);
-void trap_BotDumpGoalStack(int goalstate);
-void trap_BotGoalName(int number, char *name, int size);
-int trap_BotGetTopGoal(int goalstate, void /* struct bot_goal_s */ *goal);
-int trap_BotGetSecondGoal(int goalstate, void /* struct bot_goal_s */ *goal);
-int trap_BotChooseLTGItem(int goalstate, vec3_t origin, int *inventory, int travelflags);
-int trap_BotChooseNBGItem(int goalstate, vec3_t origin, int *inventory, int travelflags, void /* struct bot_goal_s */ *ltg, float maxtime);
-int trap_BotTouchingGoal(vec3_t origin, void /* struct bot_goal_s */ *goal);
-int trap_BotItemGoalInVisButNotVisible(int viewer, vec3_t eye, vec3_t viewangles, void /* struct bot_goal_s */ *goal);
-int trap_BotGetNextCampSpotGoal(int num, void /* struct bot_goal_s */ *goal);
-int trap_BotGetMapLocationGoal(char *name, void /* struct bot_goal_s */ *goal);
-int trap_BotGetLevelItemGoal(int index, char *classname, void /* struct bot_goal_s */ *goal);
-float trap_BotAvoidGoalTime(int goalstate, int number);
-void trap_BotSetAvoidGoalTime(int goalstate, int number, float avoidtime);
-void trap_BotInitLevelItems(void);
-void trap_BotUpdateEntityItems(void);
-int trap_BotLoadItemWeights(int goalstate, char *filename);
-void trap_BotFreeItemWeights(int goalstate);
-void trap_BotInterbreedGoalFuzzyLogic(int parent1, int parent2, int child);
-void trap_BotSaveGoalFuzzyLogic(int goalstate, char *filename);
-void trap_BotMutateGoalFuzzyLogic(int goalstate, float range);
-int trap_BotAllocGoalState(int state);
-void trap_BotFreeGoalState(int handle);
-
-void trap_BotResetMoveState(int movestate);
-void trap_BotMoveToGoal(void /* struct bot_moveresult_s */ *result, int movestate, void /* struct bot_goal_s */ *goal, int travelflags);
-int trap_BotMoveInDirection(int movestate, vec3_t dir, float speed, int type);
-void trap_BotResetAvoidReach(int movestate);
-void trap_BotResetLastAvoidReach(int movestate);
-int trap_BotReachabilityArea(vec3_t origin, int testground);
-int trap_BotMovementViewTarget(int movestate, void /* struct bot_goal_s */ *goal, int travelflags, float lookahead, vec3_t target);
-int trap_BotPredictVisiblePosition(vec3_t origin, int areanum, void /* struct bot_goal_s */ *goal, int travelflags, vec3_t target);
-int trap_BotAllocMoveState(void);
-void trap_BotFreeMoveState(int handle);
-void trap_BotInitMoveState(int handle, void /* struct bot_initmove_s */ *initmove);
-void trap_BotAddAvoidSpot(int movestate, vec3_t origin, float radius, int type);
-
-int trap_BotChooseBestFightWeapon(int weaponstate, int *inventory);
-void trap_BotGetWeaponInfo(int weaponstate, int weapon, void /* struct weaponinfo_s */ *weaponinfo);
-int trap_BotLoadWeaponWeights(int weaponstate, char *filename);
-int trap_BotAllocWeaponState(void);
-void trap_BotFreeWeaponState(int weaponstate);
-void trap_BotResetWeaponState(int weaponstate);
-
-int trap_GeneticParentsAndChildSelection(int numranks, float *ranks, int *parent1, int *parent2, int *child);
-
-void trap_SnapVector( float *v );
+int trap_DebugPolygonCreate(int color, int numPoints, vec3_t *points);
+void trap_DebugPolygonDelete(int id);
+
+void trap_SnapVector( float *v );
diff --git a/src/game/g_main.c b/src/game/g_main.c
index ba4616e5..478d0906 100644
--- a/src/game/g_main.c
+++ b/src/game/g_main.c
@@ -18,7 +18,8 @@
level_locals_t level;
-typedef struct {
+typedef struct
+{
vmCvar_t *vmCvar;
char *cvarName;
char *defaultString;
@@ -28,8 +29,8 @@ typedef struct {
qboolean teamShader; // track and if changed, update shader state
} cvarTable_t;
-gentity_t g_entities[MAX_GENTITIES];
-gclient_t g_clients[MAX_CLIENTS];
+gentity_t g_entities[ MAX_GENTITIES ];
+gclient_t g_clients[ MAX_CLIENTS ];
vmCvar_t g_dmflags;
vmCvar_t g_fraglimit;
@@ -86,7 +87,8 @@ vmCvar_t g_alienMaxStage;
vmCvar_t g_alienStage2Threshold;
vmCvar_t g_alienStage3Threshold;
-static cvarTable_t gameCvarTable[] = {
+static cvarTable_t gameCvarTable[ ] =
+{
// don't override the cheat state set by the system
{ &g_cheats, "sv_cheats", "", 0, 0, qfalse },
@@ -166,7 +168,7 @@ static cvarTable_t gameCvarTable[] = {
{ &g_rankings, "g_rankings", "0", 0, 0, qfalse}
};
-static int gameCvarTableSize = sizeof( gameCvarTable ) / sizeof( gameCvarTable[0] );
+static int gameCvarTableSize = sizeof( gameCvarTable ) / sizeof( gameCvarTable[ 0 ] );
void G_InitGame( int levelTime, int randomSeed, int restart );
@@ -185,60 +187,75 @@ This is the only way control passes into the module.
This must be the very first function compiled into the .q3vm file
================
*/
-int vmMain( int command, int arg0, int arg1, int arg2, int arg3, int arg4, int arg5, int arg6, int arg7, int arg8, int arg9, int arg10, int arg11 ) {
- switch ( command ) {
- case GAME_INIT:
- G_InitGame( arg0, arg1, arg2 );
- return 0;
- case GAME_SHUTDOWN:
- G_ShutdownGame( arg0 );
- return 0;
- case GAME_CLIENT_CONNECT:
- return (int)ClientConnect( arg0, arg1, arg2 );
- case GAME_CLIENT_THINK:
- ClientThink( arg0 );
- return 0;
- case GAME_CLIENT_USERINFO_CHANGED:
- ClientUserinfoChanged( arg0 );
- return 0;
- case GAME_CLIENT_DISCONNECT:
- ClientDisconnect( arg0 );
- return 0;
- case GAME_CLIENT_BEGIN:
- ClientBegin( arg0 );
- return 0;
- case GAME_CLIENT_COMMAND:
- ClientCommand( arg0 );
- return 0;
- case GAME_RUN_FRAME:
- G_RunFrame( arg0 );
- return 0;
- case GAME_CONSOLE_COMMAND:
- return ConsoleCommand();
+int vmMain( int command, int arg0, int arg1, int arg2, int arg3, int arg4,
+ int arg5, int arg6, int arg7, int arg8, int arg9,
+ int arg10, int arg11 )
+{
+ switch( command )
+ {
+ case GAME_INIT:
+ G_InitGame( arg0, arg1, arg2 );
+ return 0;
+
+ case GAME_SHUTDOWN:
+ G_ShutdownGame( arg0 );
+ return 0;
+
+ case GAME_CLIENT_CONNECT:
+ return (int)ClientConnect( arg0, arg1, arg2 );
+
+ case GAME_CLIENT_THINK:
+ ClientThink( arg0 );
+ return 0;
+
+ case GAME_CLIENT_USERINFO_CHANGED:
+ ClientUserinfoChanged( arg0 );
+ return 0;
+
+ case GAME_CLIENT_DISCONNECT:
+ ClientDisconnect( arg0 );
+ return 0;
+
+ case GAME_CLIENT_BEGIN:
+ ClientBegin( arg0 );
+ return 0;
+
+ case GAME_CLIENT_COMMAND:
+ ClientCommand( arg0 );
+ return 0;
+
+ case GAME_RUN_FRAME:
+ G_RunFrame( arg0 );
+ return 0;
+
+ case GAME_CONSOLE_COMMAND:
+ return ConsoleCommand( );
}
return -1;
}
-void QDECL G_Printf( const char *fmt, ... ) {
- va_list argptr;
- char text[1024];
+void QDECL G_Printf( const char *fmt, ... )
+{
+ va_list argptr;
+ char text[ 1024 ];
- va_start (argptr, fmt);
- vsprintf (text, fmt, argptr);
- va_end (argptr);
+ va_start( argptr, fmt );
+ vsprintf( text, fmt, argptr );
+ va_end( argptr );
trap_Printf( text );
}
-void QDECL G_Error( const char *fmt, ... ) {
- va_list argptr;
- char text[1024];
+void QDECL G_Error( const char *fmt, ... )
+{
+ va_list argptr;
+ char text[ 1024 ];
- va_start (argptr, fmt);
- vsprintf (text, fmt, argptr);
- va_end (argptr);
+ va_start( argptr, fmt );
+ vsprintf( text, fmt, argptr );
+ va_end( argptr );
trap_Error( text );
}
@@ -254,32 +271,42 @@ All but the first will have the FL_TEAMSLAVE flag set and teammaster field set
All but the last will have the teamchain field set to the next one
================
*/
-void G_FindTeams( void ) {
+void G_FindTeams( void )
+{
gentity_t *e, *e2;
- int i, j;
- int c, c2;
+ int i, j;
+ int c, c2;
c = 0;
c2 = 0;
- for ( i=1, e=g_entities+i ; i < level.num_entities ; i++,e++ ){
- if (!e->inuse)
+
+ for( i = 1, e = g_entities+i; i < level.num_entities; i++, e++ )
+ {
+ if( !e->inuse )
continue;
- if (!e->team)
+
+ if( !e->team )
continue;
- if (e->flags & FL_TEAMSLAVE)
+
+ if( e->flags & FL_TEAMSLAVE )
continue;
+
e->teammaster = e;
c++;
c2++;
- for (j=i+1, e2=e+1 ; j < level.num_entities ; j++,e2++)
+
+ for( j = i + 1, e2 = e + 1; j < level.num_entities; j++, e2++ )
{
- if (!e2->inuse)
+ if( !e2->inuse )
continue;
- if (!e2->team)
+
+ if( !e2->team )
continue;
- if (e2->flags & FL_TEAMSLAVE)
+
+ if( e2->flags & FL_TEAMSLAVE )
continue;
- if (!strcmp(e->team, e2->team))
+
+ if( !strcmp( e->team, e2->team ) )
{
c2++;
e2->teamchain = e->teamchain;
@@ -288,7 +315,8 @@ void G_FindTeams( void ) {
e2->flags |= FL_TEAMSLAVE;
// make sure that targets only point at the master
- if ( e2->targetname ) {
+ if( e2->targetname )
+ {
e->targetname = e2->targetname;
e2->targetname = NULL;
}
@@ -296,7 +324,7 @@ void G_FindTeams( void ) {
}
}
- G_Printf ("%i teams with %i entities\n", c, c2);
+ G_Printf( "%i teams with %i entities\n", c, c2 );
}
/*
@@ -324,7 +352,8 @@ void G_RegisterPlayerModels( void )
}
-void G_RemapTeamShaders() {
+void G_RemapTeamShaders( )
+{
}
@@ -363,33 +392,34 @@ void G_RegisterCvars( void )
G_UpdateCvars
=================
*/
-void G_UpdateCvars( void ) {
- int i;
+void G_UpdateCvars( void )
+{
+ int i;
cvarTable_t *cv;
- qboolean remapped = qfalse;
+ qboolean remapped = qfalse;
- for ( i = 0, cv = gameCvarTable ; i < gameCvarTableSize ; i++, cv++ ) {
- if ( cv->vmCvar ) {
+ for( i = 0, cv = gameCvarTable; i < gameCvarTableSize; i++, cv++ )
+ {
+ if( cv->vmCvar )
+ {
trap_Cvar_Update( cv->vmCvar );
- if ( cv->modificationCount != cv->vmCvar->modificationCount ) {
+ if( cv->modificationCount != cv->vmCvar->modificationCount )
+ {
cv->modificationCount = cv->vmCvar->modificationCount;
- if ( cv->trackChange ) {
- trap_SendServerCommand( -1, va("print \"Server: %s changed to %s\n\"",
+ if( cv->trackChange )
+ trap_SendServerCommand( -1, va( "print \"Server: %s changed to %s\n\"",
cv->cvarName, cv->vmCvar->string ) );
- }
- if (cv->teamShader) {
+ if( cv->teamShader )
remapped = qtrue;
- }
}
}
}
- if (remapped) {
- G_RemapTeamShaders();
- }
+ if( remapped )
+ G_RemapTeamShaders( );
}
@@ -420,7 +450,7 @@ void G_InitGame( int levelTime, int randomSeed, int restart )
level.time = levelTime;
level.startTime = levelTime;
- level.snd_fry = G_SoundIndex("sound/player/fry.wav"); // FIXME standing in lava / slime
+ level.snd_fry = G_SoundIndex( "sound/player/fry.wav" ); // FIXME standing in lava / slime
if( g_log.string[ 0 ] )
{
@@ -433,12 +463,12 @@ void G_InitGame( int levelTime, int randomSeed, int restart )
G_Printf( "WARNING: Couldn't open logfile: %s\n", g_log.string );
else
{
- char serverinfo[MAX_INFO_STRING];
+ char serverinfo[ MAX_INFO_STRING ];
trap_GetServerinfo( serverinfo, sizeof( serverinfo ) );
- G_LogPrintf("------------------------------------------------------------\n" );
- G_LogPrintf("InitGame: %s\n", serverinfo );
+ G_LogPrintf( "------------------------------------------------------------\n" );
+ G_LogPrintf( "InitGame: %s\n", serverinfo );
}
}
else
@@ -476,7 +506,7 @@ void G_InitGame( int levelTime, int randomSeed, int restart )
G_RegisterPlayerModels( );
G_InitDamageLocations( );
- G_Printf ("-----------------------------------\n");
+ G_Printf( "-----------------------------------\n" );
G_RemapTeamShaders( );
@@ -491,17 +521,19 @@ void G_InitGame( int levelTime, int randomSeed, int restart )
G_ShutdownGame
=================
*/
-void G_ShutdownGame( int restart ) {
- G_Printf ("==== ShutdownGame ====\n");
+void G_ShutdownGame( int restart )
+{
+ G_Printf( "==== ShutdownGame ====\n" );
- if ( level.logFile ) {
- G_LogPrintf("ShutdownGame:\n" );
- G_LogPrintf("------------------------------------------------------------\n" );
+ if( level.logFile )
+ {
+ G_LogPrintf( "ShutdownGame:\n" );
+ G_LogPrintf( "------------------------------------------------------------\n" );
trap_FS_FCloseFile( level.logFile );
}
// write all the client session data so we can get it back
- G_WriteSessionData();
+ G_WriteSessionData( );
}
@@ -511,26 +543,28 @@ void G_ShutdownGame( int restart ) {
#ifndef GAME_HARD_LINKED
// this is only here so the functions in q_shared.c and bg_*.c can link
-void QDECL Com_Error ( int level, const char *error, ... ) {
- va_list argptr;
- char text[1024];
+void QDECL Com_Error( int level, const char *error, ... )
+{
+ va_list argptr;
+ char text[ 1024 ];
- va_start (argptr, error);
- vsprintf (text, error, argptr);
- va_end (argptr);
+ va_start( argptr, error );
+ vsprintf( text, error, argptr );
+ va_end( argptr );
- G_Error( "%s", text);
+ G_Error( "%s", text );
}
-void QDECL Com_Printf( const char *msg, ... ) {
- va_list argptr;
- char text[1024];
+void QDECL Com_Printf( const char *msg, ... )
+{
+ va_list argptr;
+ char text[ 1024 ];
- va_start (argptr, msg);
- vsprintf (text, msg, argptr);
- va_end (argptr);
+ va_start( argptr, msg );
+ vsprintf( text, msg, argptr );
+ va_end( argptr );
- G_Printf ("%s", text);
+ G_Printf( "%s", text );
}
#endif
@@ -543,132 +577,6 @@ PLAYER COUNTING / SCORE SORTING
========================================================================
*/
-/*
-=============
-AddTournamentPlayer
-
-If there are less than two tournament players, put a
-spectator in the game and restart
-=============
-*/
-void AddTournamentPlayer( void ) {
- int i;
- gclient_t *client;
- gclient_t *nextInLine;
-
- if ( level.numPlayingClients >= 2 ) {
- return;
- }
-
- // never change during intermission
- if ( level.intermissiontime ) {
- return;
- }
-
- nextInLine = NULL;
-
- for ( i = 0 ; i < level.maxclients ; i++ ) {
- client = &level.clients[i];
- if ( client->pers.connected != CON_CONNECTED ) {
- continue;
- }
- if ( client->sess.sessionTeam != TEAM_SPECTATOR ) {
- continue;
- }
- // never select the dedicated follow or scoreboard clients
- if ( client->sess.spectatorState == SPECTATOR_SCOREBOARD ||
- client->sess.spectatorClient < 0 ) {
- continue;
- }
-
- if ( !nextInLine || client->sess.spectatorTime < nextInLine->sess.spectatorTime ) {
- nextInLine = client;
- }
- }
-
- if ( !nextInLine ) {
- return;
- }
-
- level.warmupTime = -1;
-
- // set them to free-for-all team
- /*SetTeam( &g_entities[ nextInLine - level.clients ], "f" );*/
-}
-
-
-/*
-=======================
-RemoveTournamentLoser
-
-Make the loser a spectator at the back of the line
-=======================
-*/
-void RemoveTournamentLoser( void ) {
- int clientNum;
-
- if ( level.numPlayingClients != 2 ) {
- return;
- }
-
- clientNum = level.sortedClients[1];
-
- if ( level.clients[ clientNum ].pers.connected != CON_CONNECTED ) {
- return;
- }
-
- // make them a spectator
- /*SetTeam( &g_entities[ clientNum ], "s" );*/
-}
-
-
-/*
-=======================
-RemoveTournamentWinner
-=======================
-*/
-void RemoveTournamentWinner( void ) {
- int clientNum;
-
- if ( level.numPlayingClients != 2 ) {
- return;
- }
-
- clientNum = level.sortedClients[0];
-
- if ( level.clients[ clientNum ].pers.connected != CON_CONNECTED ) {
- return;
- }
-
- // make them a spectator
- /*SetTeam( &g_entities[ clientNum ], "s" );*/
-}
-
-
-/*
-=======================
-AdjustTournamentScores
-
-=======================
-*/
-void AdjustTournamentScores( void ) {
- int clientNum;
-
- clientNum = level.sortedClients[0];
- if ( level.clients[ clientNum ].pers.connected == CON_CONNECTED ) {
- level.clients[ clientNum ].sess.wins++;
- ClientUserinfoChanged( clientNum );
- }
-
- clientNum = level.sortedClients[1];
- if ( level.clients[ clientNum ].pers.connected == CON_CONNECTED ) {
- level.clients[ clientNum ].sess.losses++;
- ClientUserinfoChanged( clientNum );
- }
-
-}
-
-
/*
=============
@@ -676,55 +584,53 @@ SortRanks
=============
*/
-int QDECL SortRanks( const void *a, const void *b ) {
+int QDECL SortRanks( const void *a, const void *b )
+{
gclient_t *ca, *cb;
- ca = &level.clients[*(int *)a];
- cb = &level.clients[*(int *)b];
+ ca = &level.clients[ *(int *)a ];
+ cb = &level.clients[ *(int *)b ];
// sort special clients last
- if ( ca->sess.spectatorState == SPECTATOR_SCOREBOARD || ca->sess.spectatorClient < 0 ) {
+ if( ca->sess.spectatorState == SPECTATOR_SCOREBOARD || ca->sess.spectatorClient < 0 )
return 1;
- }
- if ( cb->sess.spectatorState == SPECTATOR_SCOREBOARD || cb->sess.spectatorClient < 0 ) {
+
+ if( cb->sess.spectatorState == SPECTATOR_SCOREBOARD || cb->sess.spectatorClient < 0 )
return -1;
- }
// then connecting clients
- if ( ca->pers.connected == CON_CONNECTING ) {
+ if( ca->pers.connected == CON_CONNECTING )
return 1;
- }
- if ( cb->pers.connected == CON_CONNECTING ) {
+
+ if( cb->pers.connected == CON_CONNECTING )
return -1;
- }
// then spectators
- if ( ca->sess.sessionTeam == TEAM_SPECTATOR && cb->sess.sessionTeam == TEAM_SPECTATOR ) {
- if ( ca->sess.spectatorTime < cb->sess.spectatorTime ) {
+ if( ca->sess.sessionTeam == TEAM_SPECTATOR && cb->sess.sessionTeam == TEAM_SPECTATOR )
+ {
+ if( ca->sess.spectatorTime < cb->sess.spectatorTime )
return -1;
- }
- if ( ca->sess.spectatorTime > cb->sess.spectatorTime ) {
+
+ if( ca->sess.spectatorTime > cb->sess.spectatorTime )
return 1;
- }
+
return 0;
}
- if ( ca->sess.sessionTeam == TEAM_SPECTATOR ) {
+
+ if( ca->sess.sessionTeam == TEAM_SPECTATOR )
return 1;
- }
- if ( cb->sess.sessionTeam == TEAM_SPECTATOR ) {
+
+ if( cb->sess.sessionTeam == TEAM_SPECTATOR )
return -1;
- }
// then sort by score
- if ( ca->ps.persistant[PERS_SCORE]
- > cb->ps.persistant[PERS_SCORE] ) {
+ if( ca->ps.persistant[ PERS_SCORE ] > cb->ps.persistant[ PERS_SCORE ] )
return -1;
- }
- if ( ca->ps.persistant[PERS_SCORE]
- < cb->ps.persistant[PERS_SCORE] ) {
+
+ if( ca->ps.persistant[ PERS_SCORE ] < cb->ps.persistant[ PERS_SCORE ] )
return 1;
- }
+
return 0;
}
@@ -745,7 +651,7 @@ void countSpawns( void )
for ( i = 1, ent = g_entities + i ; i < level.num_entities ; i++, ent++ )
{
- if (!ent->inuse)
+ if( !ent->inuse )
continue;
if( ent->s.modelindex == BA_A_SPAWN && ent->health > 0 )
@@ -854,11 +760,12 @@ This will be called on every client connect, begin, disconnect, death,
and team change.
============
*/
-void CalculateRanks( void ) {
- int i;
- int rank;
- int score;
- int newScore;
+void CalculateRanks( void )
+{
+ int i;
+ int rank;
+ int score;
+ int newScore;
gclient_t *cl;
level.follow1 = -1;
@@ -872,47 +779,47 @@ void CalculateRanks( void ) {
level.numLiveAlienClients = 0;
level.numLiveHumanClients = 0;
- for ( i = 0; i < TEAM_NUM_TEAMS; i++ ) {
- level.numteamVotingClients[i] = 0;
- }
+ for( i = 0; i < TEAM_NUM_TEAMS; i++ )
+ level.numteamVotingClients[ i ] = 0;
- for ( i = 0 ; i < level.maxclients ; i++ )
+ for( i = 0; i < level.maxclients; i++ )
{
- if ( level.clients[i].pers.connected != CON_DISCONNECTED )
+ if ( level.clients[ i ].pers.connected != CON_DISCONNECTED )
{
- level.sortedClients[level.numConnectedClients] = i;
+ level.sortedClients[ level.numConnectedClients ] = i;
level.numConnectedClients++;
//TA: so we know when the game ends and for team leveling
- if( level.clients[i].pers.pteam == PTE_ALIENS )
+ if( level.clients[ i ].pers.pteam == PTE_ALIENS )
{
level.numAlienClients++;
- if ( level.clients[i].sess.sessionTeam != TEAM_SPECTATOR )
+ if( level.clients[ i ].sess.sessionTeam != TEAM_SPECTATOR )
level.numLiveAlienClients++;
}
- if( level.clients[i].pers.pteam == PTE_HUMANS )
+ if( level.clients[ i ].pers.pteam == PTE_HUMANS )
{
level.numHumanClients++;
- if ( level.clients[ i ].sess.sessionTeam != TEAM_SPECTATOR )
+ if( level.clients[ i ].sess.sessionTeam != TEAM_SPECTATOR )
level.numLiveHumanClients++;
}
////////////////
- if ( level.clients[ i ].sess.sessionTeam != TEAM_SPECTATOR )
+ if( level.clients[ i ].sess.sessionTeam != TEAM_SPECTATOR )
{
level.numNonSpectatorClients++;
// decide if this should be auto-followed
- if ( level.clients[i].pers.connected == CON_CONNECTED )
+ if( level.clients[ i ].pers.connected == CON_CONNECTED )
{
level.numPlayingClients++;
if( !(g_entities[ i ].r.svFlags & SVF_BOT) )
level.numVotingClients++;
- if( level.clients[ i ].ps.stats[ STAT_PTEAM ] == PTE_HUMANS )
- level.numteamVotingClients[ 0 ]++;
- else if( level.clients[ i ].ps.stats[ STAT_PTEAM ] == PTE_ALIENS )
- level.numteamVotingClients[ 1 ]++;
+
+ if( level.clients[ i ].ps.stats[ STAT_PTEAM ] == PTE_HUMANS )
+ level.numteamVotingClients[ 0 ]++;
+ else if( level.clients[ i ].ps.stats[ STAT_PTEAM ] == PTE_ALIENS )
+ level.numteamVotingClients[ 1 ]++;
if( level.follow1 == -1 )
level.follow1 = i;
@@ -925,31 +832,37 @@ void CalculateRanks( void ) {
}
qsort( level.sortedClients, level.numConnectedClients,
- sizeof(level.sortedClients[0]), SortRanks );
+ sizeof( level.sortedClients[ 0 ] ), SortRanks );
// set the rank value for all clients that are connected and not spectators
rank = -1;
score = 0;
- for ( i = 0; i < level.numPlayingClients; i++ ) {
- cl = &level.clients[ level.sortedClients[i] ];
- newScore = cl->ps.persistant[PERS_SCORE];
- if ( i == 0 || newScore != score ) {
+ for( i = 0; i < level.numPlayingClients; i++ )
+ {
+ cl = &level.clients[ level.sortedClients[ i ] ];
+ newScore = cl->ps.persistant[ PERS_SCORE ];
+
+ if( i == 0 || newScore != score )
+ {
rank = i;
// assume we aren't tied until the next client is checked
- level.clients[ level.sortedClients[i] ].ps.persistant[PERS_RANK] = rank;
- } else {
+ level.clients[ level.sortedClients[ i ] ].ps.persistant[ PERS_RANK ] = rank;
+ }
+ else
+ {
// we are tied with the previous client
- level.clients[ level.sortedClients[i-1] ].ps.persistant[PERS_RANK] = rank | RANK_TIED_FLAG;
- level.clients[ level.sortedClients[i] ].ps.persistant[PERS_RANK] = rank | RANK_TIED_FLAG;
+ level.clients[ level.sortedClients[ i - 1 ] ].ps.persistant[ PERS_RANK ] = rank | RANK_TIED_FLAG;
+ level.clients[ level.sortedClients[ i ] ].ps.persistant[ PERS_RANK ] = rank | RANK_TIED_FLAG;
}
+
score = newScore;
}
// set the CS_SCORES1/2 configstrings, which will be visible to everyone
if( level.numConnectedClients == 0 )
{
- trap_SetConfigstring( CS_SCORES1, va("%i", SCORE_NOT_PRESENT) );
- trap_SetConfigstring( CS_SCORES2, va("%i", SCORE_NOT_PRESENT) );
+ trap_SetConfigstring( CS_SCORES1, va( "%i", SCORE_NOT_PRESENT ) );
+ trap_SetConfigstring( CS_SCORES2, va( "%i", SCORE_NOT_PRESENT ) );
}
else if( level.numConnectedClients == 1 )
{
@@ -966,12 +879,11 @@ void CalculateRanks( void ) {
}
// see if it is time to end the level
- CheckExitRules();
+ CheckExitRules( );
// if we are at the intermission, send the new info to everyone
- if ( level.intermissiontime ) {
- SendScoreboardMessageToAllClients();
- }
+ if( level.intermissiontime )
+ SendScoreboardMessageToAllClients( );
}
@@ -1015,11 +927,11 @@ void MoveClientToIntermission( gentity_t *ent )
// move to the spot
VectorCopy( level.intermission_origin, ent->s.origin );
VectorCopy( level.intermission_origin, ent->client->ps.origin );
- VectorCopy (level.intermission_angle, ent->client->ps.viewangles);
+ VectorCopy( level.intermission_angle, ent->client->ps.viewangles );
ent->client->ps.pm_type = PM_INTERMISSION;
// clean up powerup info
- memset( ent->client->ps.powerups, 0, sizeof(ent->client->ps.powerups) );
+ memset( ent->client->ps.powerups, 0, sizeof( ent->client->ps.powerups ) );
ent->client->ps.eFlags = 0;
ent->s.eFlags = 0;
@@ -1037,21 +949,29 @@ FindIntermissionPoint
This is also used for spectator spawns
==================
*/
-void FindIntermissionPoint( void ) {
+void FindIntermissionPoint( void )
+{
gentity_t *ent, *target;
vec3_t dir;
// find the intermission spot
- ent = G_Find (NULL, FOFS(classname), "info_player_intermission");
- if ( !ent ) { // the map creator forgot to put in an intermission point...
- SelectSpawnPoint ( vec3_origin, level.intermission_origin, level.intermission_angle );
- } else {
- VectorCopy (ent->s.origin, level.intermission_origin);
- VectorCopy (ent->s.angles, level.intermission_angle);
+ ent = G_Find( NULL, FOFS( classname ), "info_player_intermission" );
+
+ if( !ent )
+ { // the map creator forgot to put in an intermission point...
+ SelectSpawnPoint( vec3_origin, level.intermission_origin, level.intermission_angle );
+ }
+ else
+ {
+ VectorCopy( ent->s.origin, level.intermission_origin );
+ VectorCopy( ent->s.angles, level.intermission_angle );
// if it has a target, look towards it
- if ( ent->target ) {
+ if( ent->target )
+ {
target = G_PickTarget( ent->target );
- if ( target ) {
+
+ if( target )
+ {
VectorSubtract( target->s.origin, level.intermission_origin, dir );
vectoangles( dir, level.intermission_angle );
}
@@ -1065,31 +985,34 @@ void FindIntermissionPoint( void ) {
BeginIntermission
==================
*/
-void BeginIntermission( void ) {
+void BeginIntermission( void )
+{
int i;
gentity_t *client;
- if ( level.intermissiontime ) {
+ if( level.intermissiontime )
return; // already active
- }
level.intermissiontime = level.time;
- FindIntermissionPoint();
+ FindIntermissionPoint( );
// move all clients to the intermission point
- for (i=0 ; i< level.maxclients ; i++) {
+ for( i = 0; i < level.maxclients; i++ )
+ {
client = g_entities + i;
- if (!client->inuse)
+
+ if( !client->inuse )
continue;
+
// respawn if dead
- if (client->health <= 0) {
+ if( client->health <= 0 )
respawn(client);
- }
+
MoveClientToIntermission( client );
}
// send the current scoring to all clients
- SendScoreboardMessageToAllClients();
+ SendScoreboardMessageToAllClients( );
}
@@ -1102,8 +1025,9 @@ or moved to a new level based on the "nextmap" cvar
=============
*/
-void ExitLevel (void) {
- int i;
+void ExitLevel( void )
+{
+ int i;
gclient_t *cl;
trap_SendConsoleCommand( EXEC_APPEND, "vstr nextmap\n" );
@@ -1140,9 +1064,10 @@ G_LogPrintf
Print to the logfile with a time stamp if it is open
=================
*/
-void QDECL G_LogPrintf( const char *fmt, ... ) {
- va_list argptr;
- char string[1024];
+void QDECL G_LogPrintf( const char *fmt, ... )
+{
+ va_list argptr;
+ char string[ 1024 ];
int min, tens, sec;
sec = level.time / 1000;
@@ -1152,19 +1077,17 @@ void QDECL G_LogPrintf( const char *fmt, ... ) {
tens = sec / 10;
sec -= tens * 10;
- Com_sprintf( string, sizeof(string), "%3i:%i%i ", min, tens, sec );
+ Com_sprintf( string, sizeof( string ), "%3i:%i%i ", min, tens, sec );
va_start( argptr, fmt );
vsprintf( string +7 , fmt,argptr );
va_end( argptr );
- if ( g_dedicated.integer ) {
+ if( g_dedicated.integer )
G_Printf( "%s", string + 7 );
- }
- if ( !level.logFile ) {
+ if( !level.logFile )
return;
- }
trap_FS_Write( string, strlen( string ), level.logFile );
}
@@ -1176,12 +1099,10 @@ LogExit
Append information about this game to the log file
================
*/
-void LogExit( const char *string ) {
- int i, numSorted;
+void LogExit( const char *string )
+{
+ int i, numSorted;
gclient_t *cl;
-#ifdef MISSIONPACK // bk001205
- qboolean won = qtrue;
-#endif
G_LogPrintf( "Exit: %s\n", string );
@@ -1228,76 +1149,69 @@ If one or more players have not acknowledged the continue, the game will
wait 10 seconds before going on.
=================
*/
-void CheckIntermissionExit( void ) {
- int ready, notReady;
- int i;
+void CheckIntermissionExit( void )
+{
+ int ready, notReady;
+ int i;
gclient_t *cl;
- int readyMask;
+ int readyMask;
// see which players are ready
ready = 0;
notReady = 0;
readyMask = 0;
- for (i=0 ; i< g_maxclients.integer ; i++) {
+ for( i = 0; i < g_maxclients.integer; i++ )
+ {
cl = level.clients + i;
- if ( cl->pers.connected != CON_CONNECTED ) {
+ if( cl->pers.connected != CON_CONNECTED )
continue;
- }
- if ( g_entities[cl->ps.clientNum].r.svFlags & SVF_BOT ) {
+
+ if( g_entities[ cl->ps.clientNum ].r.svFlags & SVF_BOT )
continue;
- }
- if ( cl->readyToExit ) {
+ if( cl->readyToExit )
+ {
ready++;
- if ( i < 16 ) {
+ if( i < 16 )
readyMask |= 1 << i;
- }
- } else {
- notReady++;
}
+ else
+ notReady++;
}
- // copy the readyMask to each player's stats so
- // it can be displayed on the scoreboard
-/* for (i=0 ; i< g_maxclients.integer ; i++) {
- cl = level.clients + i;
- if ( cl->pers.connected != CON_CONNECTED ) {
- continue;
- }
- cl->ps.stats[STAT_CLIENTS_READY] = readyMask;
- }*/
trap_SetConfigstring( CS_CLIENTS_READY, va( "%d", readyMask ) );
// never exit in less than five seconds
- if ( level.time < level.intermissiontime + 5000 ) {
+ if( level.time < level.intermissiontime + 5000 )
return;
- }
// if nobody wants to go, clear timer
- if ( !ready ) {
+ if( !ready )
+ {
level.readyToExit = qfalse;
return;
}
// if everyone wants to go, go now
- if ( !notReady ) {
- ExitLevel();
+ if( !notReady )
+ {
+ ExitLevel( );
return;
}
// the first person to ready starts the ten second timeout
- if ( !level.readyToExit ) {
+ if( !level.readyToExit )
+ {
level.readyToExit = qtrue;
level.exitTime = level.time;
}
// if we have waited ten seconds since at least one player
// wanted to exit, go ahead
- if ( level.time < level.exitTime + 10000 ) {
+ if( level.time < level.exitTime + 10000 )
return;
- }
- ExitLevel();
+ ExitLevel( );
}
/*
@@ -1401,113 +1315,48 @@ FUNCTIONS CALLED EVERY FRAME
CheckVote
==================
*/
-void CheckVote( void ) {
- if ( level.voteExecuteTime && level.voteExecuteTime < level.time ) {
+void CheckVote( void )
+{
+ if( level.voteExecuteTime && level.voteExecuteTime < level.time )
+ {
level.voteExecuteTime = 0;
trap_SendConsoleCommand( EXEC_APPEND, va("%s\n", level.voteString ) );
}
- if ( !level.voteTime ) {
+
+ if( !level.voteTime )
return;
- }
- if ( level.time - level.voteTime >= VOTE_TIME ) {
+
+ if( level.time - level.voteTime >= VOTE_TIME )
+ {
trap_SendServerCommand( -1, "print \"Vote failed.\n\"" );
- } else {
- if ( level.voteYes > level.numVotingClients/2 ) {
+ }
+ else
+ {
+ if( level.voteYes > level.numVotingClients / 2 )
+ {
// execute the command, then remove the vote
trap_SendServerCommand( -1, "print \"Vote passed.\n\"" );
level.voteExecuteTime = level.time + 3000;
- } else if ( level.voteNo >= level.numVotingClients/2 ) {
+ }
+ else if( level.voteNo >= level.numVotingClients / 2 )
+ {
// same behavior as a timeout
trap_SendServerCommand( -1, "print \"Vote failed.\n\"" );
- } else {
+ }
+ else
+ {
// still waiting for a majority
return;
}
}
+
level.voteTime = 0;
trap_SetConfigstring( CS_VOTE_TIME, "" );
-
}
/*
==================
-PrintTeam
-==================
-*/
-void PrintTeam(int team, char *message) {
- int i;
-
- for ( i = 0 ; i < level.maxclients ; i++ ) {
- if (level.clients[i].sess.sessionTeam != team)
- continue;
- trap_SendServerCommand( i, message );
- }
-}
-
-/*
-==================
-SetLeader
-==================
-*/
-void SetLeader(int team, int client) {
- int i;
-
- if ( level.clients[client].pers.connected == CON_DISCONNECTED ) {
- PrintTeam(team, va("print \"%s is not connected\n\"", level.clients[client].pers.netname) );
- return;
- }
- if (level.clients[client].sess.sessionTeam != team) {
- PrintTeam(team, va("print \"%s is not on the team anymore\n\"", level.clients[client].pers.netname) );
- return;
- }
- for ( i = 0 ; i < level.maxclients ; i++ ) {
- if (level.clients[i].sess.sessionTeam != team)
- continue;
- if (level.clients[i].sess.teamLeader) {
- level.clients[i].sess.teamLeader = qfalse;
- ClientUserinfoChanged(i);
- }
- }
- level.clients[client].sess.teamLeader = qtrue;
- ClientUserinfoChanged( client );
- PrintTeam(team, va("print \"%s is the new team leader\n\"", level.clients[client].pers.netname) );
-}
-
-/*
-==================
-CheckTeamLeader
-==================
-*/
-void CheckTeamLeader( int team ) {
- int i;
-
- for ( i = 0 ; i < level.maxclients ; i++ ) {
- if (level.clients[i].sess.sessionTeam != team)
- continue;
- if (level.clients[i].sess.teamLeader)
- break;
- }
- if (i >= level.maxclients) {
- for ( i = 0 ; i < level.maxclients ; i++ ) {
- if (level.clients[i].sess.sessionTeam != team)
- continue;
- if (!(g_entities[i].r.svFlags & SVF_BOT)) {
- level.clients[i].sess.teamLeader = qtrue;
- break;
- }
- }
- for ( i = 0 ; i < level.maxclients ; i++ ) {
- if (level.clients[i].sess.sessionTeam != team)
- continue;
- level.clients[i].sess.teamLeader = qtrue;
- break;
- }
- }
-}
-
-/*
-==================
CheckTeamVote
==================
*/
@@ -1536,15 +1385,7 @@ void CheckTeamVote( int team )
// execute the command, then remove the vote
trap_SendServerCommand( -1, "print \"Team vote passed.\n\"" );
//
- if( !Q_strncmp( "leader", level.teamVoteString[ cs_offset ], 6 ) )
- {
- //set the team leader
- SetLeader( team, atoi( level.teamVoteString[ cs_offset ] + 7 ) );
- }
- else
- {
- trap_SendConsoleCommand( EXEC_APPEND, va( "%s\n", level.teamVoteString[ cs_offset ] ) );
- }
+ trap_SendConsoleCommand( EXEC_APPEND, va( "%s\n", level.teamVoteString[ cs_offset ] ) );
}
else if( level.teamVoteNo[ cs_offset ] >= level.numteamVotingClients[ cs_offset ] / 2 )
{
@@ -1568,16 +1409,18 @@ void CheckTeamVote( int team )
CheckCvars
==================
*/
-void CheckCvars( void ) {
+void CheckCvars( void )
+{
static int lastMod = -1;
- if ( g_password.modificationCount != lastMod ) {
+ if( g_password.modificationCount != lastMod )
+ {
lastMod = g_password.modificationCount;
- if ( *g_password.string && Q_stricmp( g_password.string, "none" ) ) {
+
+ if( *g_password.string && Q_stricmp( g_password.string, "none" ) )
trap_Cvar_Set( "g_needpass", "1" );
- } else {
+ else
trap_Cvar_Set( "g_needpass", "0" );
- }
}
}
@@ -1588,22 +1431,22 @@ G_RunThink
Runs thinking code for this frame if necessary
=============
*/
-void G_RunThink (gentity_t *ent) {
+void G_RunThink( gentity_t *ent )
+{
float thinktime;
thinktime = ent->nextthink;
- if (thinktime <= 0) {
+ if( thinktime <= 0 )
return;
- }
- if (thinktime > level.time) {
+
+ if( thinktime > level.time )
return;
- }
ent->nextthink = 0;
- if (!ent->think) {
- G_Error ( "NULL ent->think");
- }
- ent->think (ent);
+ if( !ent->think )
+ G_Error( "NULL ent->think" );
+
+ ent->think( ent );
}
/*
@@ -1635,16 +1478,16 @@ G_RunFrame
Advances the non-player objects in the world
================
*/
-void G_RunFrame( int levelTime ) {
- int i;
+void G_RunFrame( int levelTime )
+{
+ int i;
gentity_t *ent;
- int msec;
-int start, end;
+ int msec;
+ int start, end;
// if we are waiting for the level to restart, do nothing
- if ( level.restarted ) {
+ if( level.restarted )
return;
- }
level.framenum++;
level.previousTime = level.time;
@@ -1652,15 +1495,15 @@ int start, end;
msec = level.time - level.previousTime;
// get any cvar changes
- G_UpdateCvars();
+ G_UpdateCvars( );
//
// go through all allocated objects
//
-start = trap_Milliseconds();
- ent = &g_entities[0];
+ start = trap_Milliseconds( );
+ ent = &g_entities[ 0 ];
- for ( i = 0; i < level.num_entities; i++, ent++ )
+ for( i = 0; i < level.num_entities; i++, ent++ )
{
if( !ent->inuse )
continue;
@@ -1694,18 +1537,17 @@ start = trap_Milliseconds();
}
// temporary entities don't think
- if ( ent->freeAfterEvent )
+ if( ent->freeAfterEvent )
continue;
//TA: calculate the acceleration of this entity
if( ent->evaluateAcceleration )
G_EvaluateAcceleration( ent, msec );
- if ( !ent->r.linked && ent->neverFree ) {
+ if( !ent->r.linked && ent->neverFree )
continue;
- }
- if ( ent->s.eType == ET_MISSILE )
+ if( ent->s.eType == ET_MISSILE )
{
G_RunMissile( ent );
continue;
@@ -1717,29 +1559,34 @@ start = trap_Milliseconds();
continue;
}
- if ( ent->s.eType == ET_MOVER ) {
+ if( ent->s.eType == ET_MOVER )
+ {
G_RunMover( ent );
continue;
}
- if ( i < MAX_CLIENTS ) {
+ if( i < MAX_CLIENTS )
+ {
G_RunClient( ent );
continue;
}
G_RunThink( ent );
}
-end = trap_Milliseconds();
+ end = trap_Milliseconds();
-start = trap_Milliseconds();
+ start = trap_Milliseconds();
+
// perform final fixups on the players
- ent = &g_entities[0];
- for (i=0 ; i < level.maxclients ; i++, ent++ ) {
- if ( ent->inuse ) {
+ ent = &g_entities[ 0 ];
+
+ for( i = 0; i < level.maxclients; i++, ent++ )
+ {
+ if( ent->inuse )
ClientEndFrame( ent );
- }
}
-end = trap_Milliseconds();
+
+ end = trap_Milliseconds();
//TA:
countSpawns( );
@@ -1747,26 +1594,27 @@ end = trap_Milliseconds();
CalculateStages( );
// see if it is time to end the level
- CheckExitRules();
+ CheckExitRules( );
// update to team status?
- CheckTeamStatus();
+ CheckTeamStatus( );
// cancel vote if timed out
- CheckVote();
+ CheckVote( );
// check team votes
CheckTeamVote( PTE_HUMANS );
CheckTeamVote( PTE_ALIENS );
// for tracking changes
- CheckCvars();
+ CheckCvars( );
- if (g_listEntity.integer) {
- for (i = 0; i < MAX_GENTITIES; i++) {
- G_Printf("%4i: %s\n", i, g_entities[i].classname);
- }
- trap_Cvar_Set("g_listEntity", "0");
+ if( g_listEntity.integer )
+ {
+ for( i = 0; i < MAX_GENTITIES; i++ )
+ G_Printf( "%4i: %s\n", i, g_entities[ i ].classname );
+
+ trap_Cvar_Set( "g_listEntity", "0" );
}
}
diff --git a/src/game/g_mem.c b/src/game/g_mem.c
index 1e2dc24a..c553859b 100644
--- a/src/game/g_mem.c
+++ b/src/game/g_mem.c
@@ -136,12 +136,12 @@ void G_InitMemory( void )
{
// Set up the initial node
- freehead = (struct freememnode *) memoryPool;
+ freehead = (struct freememnode *)memoryPool;
freehead->cookie = FREEMEMCOOKIE;
freehead->size = POOLSIZE;
freehead->next = NULL;
freehead->prev = NULL;
- freemem = sizeof(memoryPool);
+ freemem = sizeof( memoryPool );
}
void G_DefragmentMemory( void )
@@ -199,34 +199,3 @@ void Svcmd_GameMem_f( void )
G_Printf( "Status complete.\n" );
}
-/* Golliwog: All rewritten
-static int allocPoint;
-
-void *G_Alloc( int size ) {
- char *p;
-
- if ( g_debugAlloc.integer ) {
- G_Printf( "G_Alloc of %i bytes (%i left)\n", size, POOLSIZE - allocPoint - ( ( size + 31 ) & ~31 ) );
- }
-
- if ( allocPoint + size > POOLSIZE ) {
- G_Error( "G_Alloc: failed on allocation of %i bytes\n", size );
- return NULL;
- }
-
- p = &memoryPool[allocPoint];
-
- allocPoint += ( size + 31 ) & ~31;
-
- return p;
-}
-
-void G_InitMemory( void ) {
- allocPoint = 0;
-}
-
-void Svcmd_GameMem_f( void ) {
- G_Printf( "Game memory status: %i out of %i bytes allocated\n", allocPoint, POOLSIZE );
-}
-// Golliwog.
-*/
diff --git a/src/game/g_misc.c b/src/game/g_misc.c
index 3562a142..eac7f2f0 100644
--- a/src/game/g_misc.c
+++ b/src/game/g_misc.c
@@ -26,7 +26,8 @@ Used to group brushes together just for editor convenience. They are turned int
/*QUAKED info_camp (0 0.5 0) (-4 -4 -4) (4 4 4)
Used as a positional target for calculations in the utilities (spotlights, etc), but removed during gameplay.
*/
-void SP_info_camp( gentity_t *self ) {
+void SP_info_camp( gentity_t *self )
+{
G_SetOrigin( self, self->s.origin );
}
@@ -34,7 +35,8 @@ void SP_info_camp( gentity_t *self ) {
/*QUAKED info_null (0 0.5 0) (-4 -4 -4) (4 4 4)
Used as a positional target for calculations in the utilities (spotlights, etc), but removed during gameplay.
*/
-void SP_info_null( gentity_t *self ) {
+void SP_info_null( gentity_t *self )
+{
G_FreeEntity( self );
}
@@ -43,7 +45,8 @@ void SP_info_null( gentity_t *self ) {
Used as a positional target for in-game calculation, like jumppad targets.
target_position does the same thing
*/
-void SP_info_notnull( gentity_t *self ){
+void SP_info_notnull( gentity_t *self )
+{
G_SetOrigin( self, self->s.origin );
}
@@ -55,7 +58,8 @@ Linear checbox gives linear falloff instead of inverse square
Lights pointed at a target will be spotlights.
"radius" overrides the default 64 unit radius of a spotlight at the target point.
*/
-void SP_light( gentity_t *self ) {
+void SP_light( gentity_t *self )
+{
G_FreeEntity( self );
}
@@ -69,12 +73,14 @@ TELEPORTERS
=================================================================================
*/
-void TeleportPlayer( gentity_t *player, vec3_t origin, vec3_t angles ) {
+void TeleportPlayer( gentity_t *player, vec3_t origin, vec3_t angles )
+{
gentity_t *tent;
// use temp events at source and destination to prevent the effect
// from getting dropped by a second player event
- if ( player->client->sess.sessionTeam != TEAM_SPECTATOR ) {
+ if( player->client->sess.sessionTeam != TEAM_SPECTATOR )
+ {
tent = G_TempEntity( player->client->ps.origin, EV_PLAYER_TELEPORT_OUT );
tent->s.clientNum = player->s.clientNum;
@@ -83,10 +89,10 @@ void TeleportPlayer( gentity_t *player, vec3_t origin, vec3_t angles ) {
}
// unlink to make sure it can't possibly interfere with G_KillBox
- trap_UnlinkEntity (player);
+ trap_UnlinkEntity( player );
- VectorCopy ( origin, player->client->ps.origin );
- player->client->ps.origin[2] += 1;
+ VectorCopy( origin, player->client->ps.origin );
+ player->client->ps.origin[ 2 ] += 1;
// spit the player out
AngleVectors( angles, player->client->ps.velocity, NULL, NULL );
@@ -101,9 +107,8 @@ void TeleportPlayer( gentity_t *player, vec3_t origin, vec3_t angles ) {
SetClientViewAngle( player, angles );
// kill anything at the destination
- if ( player->client->sess.sessionTeam != TEAM_SPECTATOR ) {
- G_KillBox (player);
- }
+ if( player->client->sess.sessionTeam != TEAM_SPECTATOR )
+ G_KillBox( player );
// save results of pmove
BG_PlayerStateToEntityState( &player->client->ps, &player->s, qtrue );
@@ -111,9 +116,8 @@ void TeleportPlayer( gentity_t *player, vec3_t origin, vec3_t angles ) {
// use the precise origin for linking
VectorCopy( player->client->ps.origin, player->r.currentOrigin );
- if ( player->client->sess.sessionTeam != TEAM_SPECTATOR ) {
+ if( player->client->sess.sessionTeam != TEAM_SPECTATOR )
trap_LinkEntity (player);
- }
}
@@ -122,7 +126,8 @@ Point teleporters at these.
Now that we don't have teleport destination pads, this is just
an info_notnull
*/
-void SP_misc_teleporter_dest( gentity_t *ent ) {
+void SP_misc_teleporter_dest( gentity_t *ent )
+{
}
@@ -131,8 +136,8 @@ void SP_misc_teleporter_dest( gentity_t *ent ) {
/*QUAKED misc_model (1 0 0) (-16 -16 -16) (16 16 16)
"model" arbitrary .md3 file to display
*/
-void SP_misc_model( gentity_t *ent ) {
-
+void SP_misc_model( gentity_t *ent )
+{
#if 0
ent->s.modelindex = G_ModelIndex( ent->model );
VectorSet (ent->mins, -16, -16, -16);
@@ -148,13 +153,15 @@ void SP_misc_model( gentity_t *ent ) {
//===========================================================
-void locateCamera( gentity_t *ent ) {
+void locateCamera( gentity_t *ent )
+{
vec3_t dir;
gentity_t *target;
gentity_t *owner;
owner = G_PickTarget( ent->target );
- if ( !owner ) {
+ if( !owner )
+ {
G_Printf( "Couldn't find target for misc_partal_surface\n" );
G_FreeEntity( ent );
return;
@@ -162,20 +169,19 @@ void locateCamera( gentity_t *ent ) {
ent->r.ownerNum = owner->s.number;
// frame holds the rotate speed
- if ( owner->spawnflags & 1 ) {
+ if( owner->spawnflags & 1 )
ent->s.frame = 25;
- } else if ( owner->spawnflags & 2 ) {
+ else if( owner->spawnflags & 2 )
ent->s.frame = 75;
- }
// swing camera ?
- if ( owner->spawnflags & 4 ) {
+ if( owner->spawnflags & 4 )
+ {
// set to 0 for no rotation at all
ent->s.powerups = 0;
}
- else {
+ else
ent->s.powerups = 1;
- }
// clientNum holds the rotate offset
ent->s.clientNum = owner->s.clientNum;
@@ -184,12 +190,13 @@ void locateCamera( gentity_t *ent ) {
// see if the portal_camera has a target
target = G_PickTarget( owner->target );
- if ( target ) {
+ if( target )
+ {
VectorSubtract( target->s.origin, owner->s.origin, dir );
VectorNormalize( dir );
- } else {
- G_SetMovedir( owner->s.angles, dir );
}
+ else
+ G_SetMovedir( owner->s.angles, dir );
ent->s.eventParm = DirToByte( dir );
}
@@ -198,17 +205,21 @@ void locateCamera( gentity_t *ent ) {
The portal surface nearest this entity will show a view from the targeted misc_portal_camera, or a mirror view if untargeted.
This must be within 64 world units of the surface!
*/
-void SP_misc_portal_surface(gentity_t *ent) {
+void SP_misc_portal_surface( gentity_t *ent )
+{
VectorClear( ent->r.mins );
VectorClear( ent->r.maxs );
- trap_LinkEntity (ent);
+ trap_LinkEntity( ent );
ent->r.svFlags = SVF_PORTAL;
ent->s.eType = ET_PORTAL;
- if ( !ent->target ) {
+ if( !ent->target )
+ {
VectorCopy( ent->s.origin, ent->s.origin2 );
- } else {
+ }
+ else
+ {
ent->think = locateCamera;
ent->nextthink = level.time + 100;
}
@@ -219,16 +230,17 @@ void SP_misc_portal_surface(gentity_t *ent) {
The target for a misc_portal_director. You can set either angles or target another entity to determine the direction of view.
"roll" an angle modifier to orient the camera around the target vector;
*/
-void SP_misc_portal_camera(gentity_t *ent) {
+void SP_misc_portal_camera( gentity_t *ent )
+{
float roll;
VectorClear( ent->r.mins );
VectorClear( ent->r.maxs );
- trap_LinkEntity (ent);
+ trap_LinkEntity( ent );
G_SpawnFloat( "roll", "0", &roll );
- ent->s.clientNum = roll/360.0 * 256;
+ ent->s.clientNum = roll / 360.0f * 256;
}
/*
@@ -239,27 +251,29 @@ void SP_misc_portal_camera(gentity_t *ent) {
======================================================================
*/
-void Use_Shooter( gentity_t *ent, gentity_t *other, gentity_t *activator ) {
+void Use_Shooter( gentity_t *ent, gentity_t *other, gentity_t *activator )
+{
vec3_t dir;
- float deg;
+ float deg;
vec3_t up, right;
// see if we have a target
- if ( ent->enemy ) {
+ if( ent->enemy )
+ {
VectorSubtract( ent->enemy->r.currentOrigin, ent->s.origin, dir );
VectorNormalize( dir );
- } else {
- VectorCopy( ent->movedir, dir );
}
+ else
+ VectorCopy( ent->movedir, dir );
// randomize a bit
PerpendicularVector( up, dir );
CrossProduct( up, dir, right );
- deg = crandom() * ent->random;
+ deg = crandom( ) * ent->random;
VectorMA( dir, deg, up, dir );
- deg = crandom() * ent->random;
+ deg = crandom( ) * ent->random;
VectorMA( dir, deg, right, dir );
VectorNormalize( dir );
@@ -277,13 +291,15 @@ void Use_Shooter( gentity_t *ent, gentity_t *other, gentity_t *activator ) {
}
-static void InitShooter_Finish( gentity_t *ent ) {
+static void InitShooter_Finish( gentity_t *ent )
+{
ent->enemy = G_PickTarget( ent->target );
ent->think = 0;
ent->nextthink = 0;
}
-void InitShooter( gentity_t *ent, int weapon ) {
+void InitShooter( gentity_t *ent, int weapon )
+{
ent->use = Use_Shooter;
ent->s.weapon = weapon;
@@ -291,15 +307,17 @@ void InitShooter( gentity_t *ent, int weapon ) {
G_SetMovedir( ent->s.angles, ent->movedir );
- if ( !ent->random ) {
+ if( !ent->random )
ent->random = 1.0;
- }
+
ent->random = sin( M_PI * ent->random / 180 );
// target might be a moving object, so we can't set movedir for it
- if ( ent->target ) {
+ if( ent->target )
+ {
ent->think = InitShooter_Finish;
ent->nextthink = level.time + 500;
}
+
trap_LinkEntity( ent );
}
@@ -307,7 +325,8 @@ void InitShooter( gentity_t *ent, int weapon ) {
Fires at either the target or the current direction.
"random" the number of degrees of deviance from the taget. (1.0 default)
*/
-void SP_shooter_rocket( gentity_t *ent ) {
+void SP_shooter_rocket( gentity_t *ent )
+{
//InitShooter( ent, WP_ROCKET_LAUNCHER );
}
@@ -315,7 +334,8 @@ void SP_shooter_rocket( gentity_t *ent ) {
Fires at either the target or the current direction.
"random" is the number of degrees of deviance from the taget. (1.0 default)
*/
-void SP_shooter_plasma( gentity_t *ent ) {
+void SP_shooter_plasma( gentity_t *ent )
+{
//InitShooter( ent, WP_PLASMAGUN);
}
@@ -323,7 +343,8 @@ void SP_shooter_plasma( gentity_t *ent ) {
Fires at either the target or the current direction.
"random" is the number of degrees of deviance from the taget. (1.0 default)
*/
-void SP_shooter_grenade( gentity_t *ent ) {
+void SP_shooter_grenade( gentity_t *ent )
+{
//InitShooter( ent, WP_GRENADE_LAUNCHER);
}
diff --git a/src/game/g_missile.c b/src/game/g_missile.c
index 94381fdc..d7c44dcf 100644
--- a/src/game/g_missile.c
+++ b/src/game/g_missile.c
@@ -24,7 +24,8 @@ G_BounceMissile
================
*/
-void G_BounceMissile( gentity_t *ent, trace_t *trace ) {
+void G_BounceMissile( gentity_t *ent, trace_t *trace )
+{
vec3_t velocity;
float dot;
int hitTime;
@@ -33,18 +34,20 @@ void G_BounceMissile( gentity_t *ent, trace_t *trace ) {
hitTime = level.previousTime + ( level.time - level.previousTime ) * trace->fraction;
BG_EvaluateTrajectoryDelta( &ent->s.pos, hitTime, velocity );
dot = DotProduct( velocity, trace->plane.normal );
- VectorMA( velocity, -2*dot, trace->plane.normal, ent->s.pos.trDelta );
+ VectorMA( velocity, -2 * dot, trace->plane.normal, ent->s.pos.trDelta );
- if ( ent->s.eFlags & EF_BOUNCE_HALF ) {
+ if( ent->s.eFlags & EF_BOUNCE_HALF )
+ {
VectorScale( ent->s.pos.trDelta, 0.65, ent->s.pos.trDelta );
// check for stop
- if ( trace->plane.normal[2] > 0.2 && VectorLength( ent->s.pos.trDelta ) < 40 ) {
+ if( trace->plane.normal[ 2 ] > 0.2 && VectorLength( ent->s.pos.trDelta ) < 40 )
+ {
G_SetOrigin( ent, trace->endpos );
return;
}
}
- VectorAdd( ent->r.currentOrigin, trace->plane.normal, ent->r.currentOrigin);
+ VectorAdd( ent->r.currentOrigin, trace->plane.normal, ent->r.currentOrigin );
VectorCopy( ent->r.currentOrigin, ent->s.pos.trBase );
ent->s.pos.trTime = level.time;
}
@@ -57,7 +60,8 @@ G_ExplodeMissile
Explode a missile without an impact
================
*/
-void G_ExplodeMissile( gentity_t *ent ) {
+void G_ExplodeMissile( gentity_t *ent )
+{
vec3_t dir;
vec3_t origin;
@@ -66,8 +70,8 @@ void G_ExplodeMissile( gentity_t *ent ) {
G_SetOrigin( ent, origin );
// we don't have a valid direction, so just point straight up
- dir[0] = dir[1] = 0;
- dir[2] = 1;
+ dir[ 0 ] = dir[ 1 ] = 0;
+ dir[ 2 ] = 1;
ent->s.eType = ET_GENERAL;
@@ -77,13 +81,13 @@ void G_ExplodeMissile( gentity_t *ent ) {
ent->freeAfterEvent = qtrue;
-/* // splash damage
+ // splash damage
if ( ent->splashDamage ) {
if( G_RadiusDamage( ent->r.currentOrigin, ent->parent, ent->splashDamage, ent->splashRadius, ent
, ent->splashMethodOfDeath ) ) {
g_entities[ent->r.ownerNum].client->accuracy_hits++;
}
- }*/
+ }
trap_LinkEntity( ent );
}
@@ -95,33 +99,37 @@ G_MissileImpact
================
*/
-void G_MissileImpact( gentity_t *ent, trace_t *trace ) {
+void G_MissileImpact( gentity_t *ent, trace_t *trace )
+{
gentity_t *other;
qboolean hitClient = qfalse;
- other = &g_entities[trace->entityNum];
+ other = &g_entities[ trace->entityNum ];
// check for bounce
- if ( !other->takedamage &&
- ( ent->s.eFlags & ( EF_BOUNCE | EF_BOUNCE_HALF ) ) ) {
+ if( !other->takedamage &&
+ ( ent->s.eFlags & ( EF_BOUNCE | EF_BOUNCE_HALF ) ) )
+ {
G_BounceMissile( ent, trace );
G_AddEvent( ent, EV_GRENADE_BOUNCE, 0 );
return;
}
// impact damage
- if (other->takedamage) {
+ if( other->takedamage )
+ {
// FIXME: wrong damage direction?
- if ( ent->damage ) {
+ if( ent->damage )
+ {
vec3_t velocity;
BG_EvaluateTrajectoryDelta( &ent->s.pos, level.time, velocity );
- if ( VectorLength( velocity ) == 0 ) {
- velocity[2] = 1; // stepped on a grenade
- }
- G_Damage (other, ent, &g_entities[ent->r.ownerNum], velocity,
+ if( VectorLength( velocity ) == 0 )
+ velocity[ 2 ] = 1; // stepped on a grenade
+
+ G_Damage( other, ent, &g_entities[ ent->r.ownerNum ], velocity,
ent->s.origin, ent->damage,
- 0, ent->methodOfDeath);
+ 0, ent->methodOfDeath );
}
}
@@ -147,14 +155,15 @@ void G_MissileImpact( gentity_t *ent, trace_t *trace ) {
// is it cheaper in bandwidth to just remove this ent and create a new
// one, rather than changing the missile into the explosion?
- if ( other->takedamage && other->client ) {
+ if( other->takedamage && other->client )
+ {
G_AddEvent( ent, EV_MISSILE_HIT, DirToByte( trace->plane.normal ) );
ent->s.otherEntityNum = other->s.number;
- } else if( trace->surfaceFlags & SURF_METALSTEPS ) {
+ }
+ else if( trace->surfaceFlags & SURF_METALSTEPS )
G_AddEvent( ent, EV_MISSILE_MISS_METAL, DirToByte( trace->plane.normal ) );
- } else {
+ else
G_AddEvent( ent, EV_MISSILE_MISS, DirToByte( trace->plane.normal ) );
- }
ent->freeAfterEvent = qtrue;
@@ -166,12 +175,13 @@ void G_MissileImpact( gentity_t *ent, trace_t *trace ) {
G_SetOrigin( ent, trace->endpos );
// splash damage (doesn't apply to person directly hit)
- if ( ent->splashDamage ) {
+ if( ent->splashDamage )
+ {
if( G_RadiusDamage( trace->endpos, ent->parent, ent->splashDamage, ent->splashRadius,
- other, ent->splashMethodOfDeath ) ) {
- if( !hitClient ) {
- g_entities[ent->r.ownerNum].client->accuracy_hits++;
- }
+ other, ent->splashMethodOfDeath ) )
+ {
+ if( !hitClient )
+ g_entities[ ent->r.ownerNum ].client->accuracy_hits++;
}
}
@@ -221,10 +231,10 @@ void G_RunMissile( gentity_t *ent )
if( tr.fraction != 1 )
{
// never explode or bounce on sky
- if ( tr.surfaceFlags & SURF_NOIMPACT )
+ if( tr.surfaceFlags & SURF_NOIMPACT )
{
// If grapple, reset owner
- if (ent->parent && ent->parent->client && ent->parent->client->hook == ent)
+ if( ent->parent && ent->parent->client && ent->parent->client->hook == ent )
ent->parent->client->hook = NULL;
G_FreeEntity( ent );
@@ -289,46 +299,6 @@ gentity_t *fire_flamer( gentity_t *self, vec3_t start, vec3_t dir )
/*
=================
-fire_plasma
-
-=================
-*/
-gentity_t *fire_plasma( gentity_t *self, vec3_t start, vec3_t dir )
-{
- gentity_t *bolt;
-
- VectorNormalize (dir);
-
- bolt = G_Spawn();
- bolt->classname = "plasma";
- bolt->nextthink = level.time + 10000;
- bolt->think = G_ExplodeMissile;
- bolt->s.eType = ET_MISSILE;
- bolt->r.svFlags = SVF_USE_CURRENT_ORIGIN;
- bolt->s.weapon = WP_PLASMAGUN;
- bolt->r.ownerNum = self->s.number;
- bolt->parent = self;
- bolt->damage = 20;
- bolt->splashDamage = 15;
- bolt->splashRadius = 20;
- //bolt->methodOfDeath = MOD_FLAMER;
- //bolt->splashMethodOfDeath = MOD_FLAMER_SPLASH;
- bolt->clipmask = MASK_SHOT;
- bolt->target_ent = NULL;
-
- bolt->s.pos.trType = TR_LINEAR;
- bolt->s.pos.trTime = level.time - MISSILE_PRESTEP_TIME; // move a bit on the very first frame
- VectorCopy( start, bolt->s.pos.trBase );
- VectorScale( dir, 2000, bolt->s.pos.trDelta );
- SnapVector( bolt->s.pos.trDelta ); // save net bandwidth
-
- VectorCopy (start, bolt->r.currentOrigin);
-
- return bolt;
-}
-
-/*
-=================
fire_pulseRifle
=================
diff --git a/src/game/g_mover.c b/src/game/g_mover.c
index 13d99ff5..7327c4cd 100644
--- a/src/game/g_mover.c
+++ b/src/game/g_mover.c
@@ -28,13 +28,15 @@ PUSHMOVE
void MatchTeam( gentity_t *teamLeader, int moverState, int time );
-typedef struct {
+typedef struct
+{
gentity_t *ent;
vec3_t origin;
vec3_t angles;
float deltayaw;
} pushed_t;
-pushed_t pushed[MAX_GENTITIES], *pushed_p;
+
+pushed_t pushed[ MAX_GENTITIES ], *pushed_p;
/*
@@ -43,22 +45,22 @@ G_TestEntityPosition
============
*/
-gentity_t *G_TestEntityPosition( gentity_t *ent ) {
+gentity_t *G_TestEntityPosition( gentity_t *ent )
+{
trace_t tr;
int mask;
- if ( ent->clipmask ) {
+ if( ent->clipmask )
mask = ent->clipmask;
- } else {
+ else
mask = MASK_SOLID;
- }
- if ( ent->client ) {
+
+ if( ent->client )
trap_Trace( &tr, ent->client->ps.origin, ent->r.mins, ent->r.maxs, ent->client->ps.origin, ent->s.number, mask );
- } else {
+ else
trap_Trace( &tr, ent->s.pos.trBase, ent->r.mins, ent->r.maxs, ent->s.pos.trBase, ent->s.number, mask );
- }
- if (tr.startsolid)
+ if( tr.startsolid )
return &g_entities[ tr.entityNum ];
return NULL;
@@ -69,9 +71,10 @@ gentity_t *G_TestEntityPosition( gentity_t *ent ) {
G_CreateRotationMatrix
================
*/
-void G_CreateRotationMatrix(vec3_t angles, vec3_t matrix[3]) {
- AngleVectors(angles, matrix[0], matrix[1], matrix[2]);
- VectorInverse(matrix[1]);
+void G_CreateRotationMatrix( vec3_t angles, vec3_t matrix[ 3 ] )
+{
+ AngleVectors( angles, matrix[ 0 ], matrix[ 1 ], matrix[ 2 ] );
+ VectorInverse( matrix[ 1 ] );
}
/*
@@ -79,11 +82,15 @@ void G_CreateRotationMatrix(vec3_t angles, vec3_t matrix[3]) {
G_TransposeMatrix
================
*/
-void G_TransposeMatrix(vec3_t matrix[3], vec3_t transpose[3]) {
+void G_TransposeMatrix( vec3_t matrix[ 3 ], vec3_t transpose[ 3 ] )
+{
int i, j;
- for (i = 0; i < 3; i++) {
- for (j = 0; j < 3; j++) {
- transpose[i][j] = matrix[j][i];
+
+ for( i = 0; i < 3; i++ )
+ {
+ for( j = 0; j < 3; j++ )
+ {
+ transpose[ i ][ j ] = matrix[ j ][ i ];
}
}
}
@@ -93,13 +100,14 @@ void G_TransposeMatrix(vec3_t matrix[3], vec3_t transpose[3]) {
G_RotatePoint
================
*/
-void G_RotatePoint(vec3_t point, vec3_t matrix[3]) {
+void G_RotatePoint( vec3_t point, vec3_t matrix[ 3 ] )
+{
vec3_t tvec;
- VectorCopy(point, tvec);
- point[0] = DotProduct(matrix[0], tvec);
- point[1] = DotProduct(matrix[1], tvec);
- point[2] = DotProduct(matrix[2], tvec);
+ VectorCopy( point, tvec );
+ point[ 0 ] = DotProduct( matrix[ 0 ], tvec );
+ point[ 1 ] = DotProduct( matrix[ 1 ], tvec );
+ point[ 2 ] = DotProduct( matrix[ 2 ], tvec );
}
/*
@@ -109,28 +117,30 @@ G_TryPushingEntity
Returns qfalse if the move is blocked
==================
*/
-qboolean G_TryPushingEntity( gentity_t *check, gentity_t *pusher, vec3_t move, vec3_t amove ) {
- vec3_t matrix[3], transpose[3];
+qboolean G_TryPushingEntity( gentity_t *check, gentity_t *pusher, vec3_t move, vec3_t amove )
+{
+ vec3_t matrix[ 3 ], transpose[ 3 ];
vec3_t org, org2, move2;
gentity_t *block;
// EF_MOVER_STOP will just stop when contacting another entity
// instead of pushing it, but entities can still ride on top of it
- if ( ( pusher->s.eFlags & EF_MOVER_STOP ) &&
- check->s.groundEntityNum != pusher->s.number ) {
+ if( ( pusher->s.eFlags & EF_MOVER_STOP ) &&
+ check->s.groundEntityNum != pusher->s.number )
return qfalse;
- }
// save off the old position
- if (pushed_p > &pushed[MAX_GENTITIES]) {
+ if( pushed_p > &pushed[ MAX_GENTITIES ] )
G_Error( "pushed_p > &pushed[MAX_GENTITIES]" );
- }
+
pushed_p->ent = check;
- VectorCopy (check->s.pos.trBase, pushed_p->origin);
- VectorCopy (check->s.apos.trBase, pushed_p->angles);
- if ( check->client ) {
- pushed_p->deltayaw = check->client->ps.delta_angles[YAW];
- VectorCopy (check->client->ps.origin, pushed_p->origin);
+ VectorCopy( check->s.pos.trBase, pushed_p->origin );
+ VectorCopy( check->s.apos.trBase, pushed_p->angles );
+
+ if( check->client )
+ {
+ pushed_p->deltayaw = check->client->ps.delta_angles[ YAW ];
+ VectorCopy( check->client->ps.origin, pushed_p->origin );
}
pushed_p++;
@@ -138,52 +148,58 @@ qboolean G_TryPushingEntity( gentity_t *check, gentity_t *pusher, vec3_t move,
// figure movement due to the pusher's amove
G_CreateRotationMatrix( amove, transpose );
G_TransposeMatrix( transpose, matrix );
- if ( check->client ) {
- VectorSubtract (check->client->ps.origin, pusher->r.currentOrigin, org);
- }
- else {
- VectorSubtract (check->s.pos.trBase, pusher->r.currentOrigin, org);
- }
+
+ if( check->client )
+ VectorSubtract( check->client->ps.origin, pusher->r.currentOrigin, org );
+ else
+ VectorSubtract( check->s.pos.trBase, pusher->r.currentOrigin, org );
+
VectorCopy( org, org2 );
G_RotatePoint( org2, matrix );
- VectorSubtract (org2, org, move2);
+ VectorSubtract( org2, org, move2 );
// add movement
- VectorAdd (check->s.pos.trBase, move, check->s.pos.trBase);
- VectorAdd (check->s.pos.trBase, move2, check->s.pos.trBase);
- if ( check->client ) {
- VectorAdd (check->client->ps.origin, move, check->client->ps.origin);
- VectorAdd (check->client->ps.origin, move2, check->client->ps.origin);
+ VectorAdd( check->s.pos.trBase, move, check->s.pos.trBase );
+ VectorAdd( check->s.pos.trBase, move2, check->s.pos.trBase );
+
+ if( check->client )
+ {
+ VectorAdd( check->client->ps.origin, move, check->client->ps.origin );
+ VectorAdd( check->client->ps.origin, move2, check->client->ps.origin );
// make sure the client's view rotates when on a rotating mover
- check->client->ps.delta_angles[YAW] += ANGLE2SHORT(amove[YAW]);
+ check->client->ps.delta_angles[ YAW ] += ANGLE2SHORT( amove[ YAW ] );
}
// may have pushed them off an edge
- if ( check->s.groundEntityNum != pusher->s.number ) {
+ if( check->s.groundEntityNum != pusher->s.number )
check->s.groundEntityNum = -1;
- }
block = G_TestEntityPosition( check );
- if (!block) {
+
+ if( !block )
+ {
// pushed ok
- if ( check->client ) {
+ if( check->client )
VectorCopy( check->client->ps.origin, check->r.currentOrigin );
- } else {
+ else
VectorCopy( check->s.pos.trBase, check->r.currentOrigin );
- }
- trap_LinkEntity (check);
+
+ trap_LinkEntity( check );
return qtrue;
}
// if it is ok to leave in the old position, do it
// this is only relevent for riding entities, not pushed
// Sliding trapdoors can cause this.
- VectorCopy( (pushed_p-1)->origin, check->s.pos.trBase);
- if ( check->client ) {
- VectorCopy( (pushed_p-1)->origin, check->client->ps.origin);
- }
- VectorCopy( (pushed_p-1)->angles, check->s.apos.trBase );
- block = G_TestEntityPosition (check);
- if ( !block ) {
+ VectorCopy( ( pushed_p - 1 )->origin, check->s.pos.trBase );
+
+ if( check->client )
+ VectorCopy( ( pushed_p - 1 )->origin, check->client->ps.origin );
+
+ VectorCopy( ( pushed_p - 1 )->angles, check->s.apos.trBase );
+ block = G_TestEntityPosition( check );
+
+ if( !block )
+ {
check->s.groundEntityNum = -1;
pushed_p--;
return qtrue;
@@ -203,13 +219,14 @@ otherwise riders would continue to slide.
If qfalse is returned, *obstacle will be the blocking entity
============
*/
-qboolean G_MoverPush( gentity_t *pusher, vec3_t move, vec3_t amove, gentity_t **obstacle ) {
- int i, e;
+qboolean G_MoverPush( gentity_t *pusher, vec3_t move, vec3_t amove, gentity_t **obstacle )
+{
+ int i, e;
gentity_t *check;
vec3_t mins, maxs;
pushed_t *p;
- int entityList[MAX_GENTITIES];
- int listedEntities;
+ int entityList[ MAX_GENTITIES ];
+ int listedEntities;
vec3_t totalMins, totalMaxs;
*obstacle = NULL;
@@ -217,31 +234,37 @@ qboolean G_MoverPush( gentity_t *pusher, vec3_t move, vec3_t amove, gentity_t **
// mins/maxs are the bounds at the destination
// totalMins / totalMaxs are the bounds for the entire move
- if ( pusher->r.currentAngles[0] || pusher->r.currentAngles[1] || pusher->r.currentAngles[2]
- || amove[0] || amove[1] || amove[2] ) {
+ if( pusher->r.currentAngles[ 0 ] || pusher->r.currentAngles[ 1 ] || pusher->r.currentAngles[ 2 ]
+ || amove[ 0 ] || amove[ 1 ] || amove[ 2 ] )
+ {
float radius;
radius = RadiusFromBounds( pusher->r.mins, pusher->r.maxs );
- for ( i = 0 ; i < 3 ; i++ ) {
- mins[i] = pusher->r.currentOrigin[i] + move[i] - radius;
- maxs[i] = pusher->r.currentOrigin[i] + move[i] + radius;
- totalMins[i] = mins[i] - move[i];
- totalMaxs[i] = maxs[i] - move[i];
+
+ for( i = 0 ; i < 3 ; i++ )
+ {
+ mins[ i ] = pusher->r.currentOrigin[ i ] + move[ i ] - radius;
+ maxs[ i ] = pusher->r.currentOrigin[ i ] + move[ i ] + radius;
+ totalMins[ i ] = mins[ i ] - move[ i ];
+ totalMaxs[ i ] = maxs[ i ] - move[ i ];
}
- } else {
- for (i=0 ; i<3 ; i++) {
- mins[i] = pusher->r.absmin[i] + move[i];
- maxs[i] = pusher->r.absmax[i] + move[i];
+ }
+ else
+ {
+ for( i = 0; i < 3; i++ )
+ {
+ mins[ i ] = pusher->r.absmin[ i ] + move[ i ];
+ maxs[ i ] = pusher->r.absmax[ i ] + move[ i ];
}
VectorCopy( pusher->r.absmin, totalMins );
VectorCopy( pusher->r.absmax, totalMaxs );
- for (i=0 ; i<3 ; i++) {
- if ( move[i] > 0 ) {
- totalMaxs[i] += move[i];
- } else {
- totalMins[i] += move[i];
- }
+ for( i = 0; i < 3; i++ )
+ {
+ if( move[ i ] > 0 )
+ totalMaxs[ i ] += move[ i ];
+ else
+ totalMins[ i ] += move[ i ];
}
}
@@ -256,43 +279,43 @@ qboolean G_MoverPush( gentity_t *pusher, vec3_t move, vec3_t amove, gentity_t **
trap_LinkEntity( pusher );
// see if any solid entities are inside the final position
- for ( e = 0 ; e < listedEntities ; e++ ) {
+ for( e = 0 ; e < listedEntities ; e++ )
+ {
check = &g_entities[ entityList[ e ] ];
// only push items and players
- if ( check->s.eType != ET_ITEM && check->s.eType != ET_BUILDABLE &&
- check->s.eType != ET_CORPSE && check->s.eType != ET_PLAYER &&
- !check->physicsObject ) {
+ if( check->s.eType != ET_ITEM && check->s.eType != ET_BUILDABLE &&
+ check->s.eType != ET_CORPSE && check->s.eType != ET_PLAYER &&
+ !check->physicsObject )
continue;
- }
// if the entity is standing on the pusher, it will definitely be moved
- if ( check->s.groundEntityNum != pusher->s.number ) {
+ if( check->s.groundEntityNum != pusher->s.number )
+ {
// see if the ent needs to be tested
- if ( check->r.absmin[0] >= maxs[0]
- || check->r.absmin[1] >= maxs[1]
- || check->r.absmin[2] >= maxs[2]
- || check->r.absmax[0] <= mins[0]
- || check->r.absmax[1] <= mins[1]
- || check->r.absmax[2] <= mins[2] ) {
+ if( check->r.absmin[ 0 ] >= maxs[ 0 ]
+ || check->r.absmin[ 1 ] >= maxs[ 1 ]
+ || check->r.absmin[ 2 ] >= maxs[ 2 ]
+ || check->r.absmax[ 0 ] <= mins[ 0 ]
+ || check->r.absmax[ 1 ] <= mins[ 1 ]
+ || check->r.absmax[ 2 ] <= mins[ 2 ] )
continue;
- }
+
// see if the ent's bbox is inside the pusher's final position
// this does allow a fast moving object to pass through a thin entity...
- if (!G_TestEntityPosition (check)) {
+ if( !G_TestEntityPosition( check ) )
continue;
- }
}
// the entity needs to be pushed
- if ( G_TryPushingEntity( check, pusher, move, amove ) ) {
+ if( G_TryPushingEntity( check, pusher, move, amove ) )
continue;
- }
// the move was blocked an entity
// bobbing entities are instant-kill and never get blocked
- if ( pusher->s.pos.trType == TR_SINE || pusher->s.apos.trType == TR_SINE ) {
+ if( pusher->s.pos.trType == TR_SINE || pusher->s.apos.trType == TR_SINE )
+ {
G_Damage( check, pusher, pusher, NULL, NULL, 99999, 0, MOD_CRUSH );
continue;
}
@@ -304,15 +327,20 @@ qboolean G_MoverPush( gentity_t *pusher, vec3_t move, vec3_t amove, gentity_t **
// move back any entities we already moved
// go backwards, so if the same entity was pushed
// twice, it goes back to the original position
- for ( p=pushed_p-1 ; p>=pushed ; p-- ) {
- VectorCopy (p->origin, p->ent->s.pos.trBase);
- VectorCopy (p->angles, p->ent->s.apos.trBase);
- if ( p->ent->client ) {
- p->ent->client->ps.delta_angles[YAW] = p->deltayaw;
- VectorCopy (p->origin, p->ent->client->ps.origin);
+ for( p = pushed_p - 1; p >= pushed; p-- )
+ {
+ VectorCopy( p->origin, p->ent->s.pos.trBase );
+ VectorCopy( p->angles, p->ent->s.apos.trBase );
+
+ if( p->ent->client )
+ {
+ p->ent->client->ps.delta_angles[ YAW ] = p->deltayaw;
+ VectorCopy( p->origin, p->ent->client->ps.origin );
}
- trap_LinkEntity (p->ent);
+
+ trap_LinkEntity( p->ent );
}
+
return qfalse;
}
@@ -325,7 +353,8 @@ qboolean G_MoverPush( gentity_t *pusher, vec3_t move, vec3_t amove, gentity_t **
G_MoverTeam
=================
*/
-void G_MoverTeam( gentity_t *ent ) {
+void G_MoverTeam( gentity_t *ent )
+{
vec3_t move, amove;
gentity_t *part, *obstacle;
vec3_t origin, angles;
@@ -336,20 +365,22 @@ void G_MoverTeam( gentity_t *ent ) {
// any moves or calling any think functions
// if the move is blocked, all moved objects will be backed out
pushed_p = pushed;
- for (part = ent ; part ; part=part->teamchain) {
+ for( part = ent; part; part = part->teamchain )
+ {
// get current position
BG_EvaluateTrajectory( &part->s.pos, level.time, origin );
BG_EvaluateTrajectory( &part->s.apos, level.time, angles );
VectorSubtract( origin, part->r.currentOrigin, move );
VectorSubtract( angles, part->r.currentAngles, amove );
- if ( !G_MoverPush( part, move, amove, &obstacle ) ) {
+ if( !G_MoverPush( part, move, amove, &obstacle ) )
break; // move was blocked
- }
}
- if (part) {
+ if( part )
+ {
// go back to the previous position
- for ( part = ent ; part ; part = part->teamchain ) {
+ for( part = ent; part; part = part->teamchain )
+ {
part->s.pos.trTime += level.time - level.previousTime;
part->s.apos.trTime += level.time - level.previousTime;
BG_EvaluateTrajectory( &part->s.pos, level.time, part->r.currentOrigin );
@@ -358,20 +389,22 @@ void G_MoverTeam( gentity_t *ent ) {
}
// if the pusher has a "blocked" function, call it
- if (ent->blocked) {
+ if( ent->blocked )
ent->blocked( ent, obstacle );
- }
+
return;
}
// the move succeeded
- for ( part = ent ; part ; part = part->teamchain ) {
+ for( part = ent; part; part = part->teamchain )
+ {
// call the reached function if time is at or past end point
- if ( part->s.pos.trType == TR_LINEAR_STOP ) {
- if ( level.time >= part->s.pos.trTime + part->s.pos.trDuration ) {
- if ( part->reached ) {
+ if( part->s.pos.trType == TR_LINEAR_STOP )
+ {
+ if( level.time >= part->s.pos.trTime + part->s.pos.trDuration )
+ {
+ if( part->reached )
part->reached( part );
- }
}
}
}
@@ -383,17 +416,16 @@ G_RunMover
================
*/
-void G_RunMover( gentity_t *ent ) {
+void G_RunMover( gentity_t *ent )
+{
// if not a team captain, don't do anything, because
// the captain will handle everything
- if ( ent->flags & FL_TEAMSLAVE ) {
+ if( ent->flags & FL_TEAMSLAVE )
return;
- }
// if stationary at one of the positions, don't move anything
- if ( ent->s.pos.trType != TR_STATIONARY || ent->s.apos.trType != TR_STATIONARY ) {
+ if( ent->s.pos.trType != TR_STATIONARY || ent->s.apos.trType != TR_STATIONARY )
G_MoverTeam( ent );
- }
// check think function
G_RunThink( ent );
@@ -414,37 +446,43 @@ Pos1 is "at rest", pos2 is "activated"
SetMoverState
===============
*/
-void SetMoverState( gentity_t *ent, moverState_t moverState, int time ) {
- vec3_t delta;
- float f;
+void SetMoverState( gentity_t *ent, moverState_t moverState, int time )
+{
+ vec3_t delta;
+ float f;
ent->moverState = moverState;
ent->s.pos.trTime = time;
- switch( moverState ) {
- case MOVER_POS1:
- VectorCopy( ent->pos1, ent->s.pos.trBase );
- ent->s.pos.trType = TR_STATIONARY;
- break;
- case MOVER_POS2:
- VectorCopy( ent->pos2, ent->s.pos.trBase );
- ent->s.pos.trType = TR_STATIONARY;
- break;
- case MOVER_1TO2:
- VectorCopy( ent->pos1, ent->s.pos.trBase );
- VectorSubtract( ent->pos2, ent->pos1, delta );
- f = 1000.0 / ent->s.pos.trDuration;
- VectorScale( delta, f, ent->s.pos.trDelta );
- ent->s.pos.trType = TR_LINEAR_STOP;
- break;
- case MOVER_2TO1:
- VectorCopy( ent->pos2, ent->s.pos.trBase );
- VectorSubtract( ent->pos1, ent->pos2, delta );
- f = 1000.0 / ent->s.pos.trDuration;
- VectorScale( delta, f, ent->s.pos.trDelta );
- ent->s.pos.trType = TR_LINEAR_STOP;
- break;
- }
+ switch( moverState )
+ {
+ case MOVER_POS1:
+ VectorCopy( ent->pos1, ent->s.pos.trBase );
+ ent->s.pos.trType = TR_STATIONARY;
+ break;
+
+ case MOVER_POS2:
+ VectorCopy( ent->pos2, ent->s.pos.trBase );
+ ent->s.pos.trType = TR_STATIONARY;
+ break;
+
+ case MOVER_1TO2:
+ VectorCopy( ent->pos1, ent->s.pos.trBase );
+ VectorSubtract( ent->pos2, ent->pos1, delta );
+ f = 1000.0 / ent->s.pos.trDuration;
+ VectorScale( delta, f, ent->s.pos.trDelta );
+ ent->s.pos.trType = TR_LINEAR_STOP;
+ break;
+
+ case MOVER_2TO1:
+ VectorCopy( ent->pos2, ent->s.pos.trBase );
+ VectorSubtract( ent->pos1, ent->pos2, delta );
+ f = 1000.0 / ent->s.pos.trDuration;
+ VectorScale( delta, f, ent->s.pos.trDelta );
+ ent->s.pos.trType = TR_LINEAR_STOP;
+ break;
+ }
+
BG_EvaluateTrajectory( &ent->s.pos, level.time, ent->r.currentOrigin );
trap_LinkEntity( ent );
}
@@ -457,12 +495,12 @@ All entities in a mover team will move from pos1 to pos2
in the same amount of time
================
*/
-void MatchTeam( gentity_t *teamLeader, int moverState, int time ) {
+void MatchTeam( gentity_t *teamLeader, int moverState, int time )
+{
gentity_t *slave;
- for ( slave = teamLeader ; slave ; slave = slave->teamchain ) {
+ for( slave = teamLeader; slave; slave = slave->teamchain )
SetMoverState( slave, moverState, time );
- }
}
@@ -472,16 +510,16 @@ void MatchTeam( gentity_t *teamLeader, int moverState, int time ) {
ReturnToPos1
================
*/
-void ReturnToPos1( gentity_t *ent ) {
+void ReturnToPos1( gentity_t *ent )
+{
MatchTeam( ent, MOVER_2TO1, level.time );
// looping sound
ent->s.loopSound = ent->soundLoop;
// starting sound
- if ( ent->sound2to1 ) {
+ if( ent->sound2to1 )
G_AddEvent( ent, EV_GENERAL_SOUND, ent->sound2to1 );
- }
}
@@ -490,45 +528,45 @@ void ReturnToPos1( gentity_t *ent ) {
Reached_BinaryMover
================
*/
-void Reached_BinaryMover( gentity_t *ent ) {
-
+void Reached_BinaryMover( gentity_t *ent )
+{
// stop the looping sound
ent->s.loopSound = ent->soundLoop;
- if ( ent->moverState == MOVER_1TO2 ) {
+ if( ent->moverState == MOVER_1TO2 )
+ {
// reached pos2
SetMoverState( ent, MOVER_POS2, level.time );
// play sound
- if ( ent->soundPos2 ) {
+ if( ent->soundPos2 )
G_AddEvent( ent, EV_GENERAL_SOUND, ent->soundPos2 );
- }
// return to pos1 after a delay
ent->think = ReturnToPos1;
ent->nextthink = level.time + ent->wait;
// fire targets
- if ( !ent->activator ) {
+ if( !ent->activator )
ent->activator = ent;
- }
+
G_UseTargets( ent, ent->activator );
- } else if ( ent->moverState == MOVER_2TO1 ) {
+ }
+ else if( ent->moverState == MOVER_2TO1 )
+ {
// reached pos1
SetMoverState( ent, MOVER_POS1, level.time );
// play sound
- if ( ent->soundPos1 ) {
+ if( ent->soundPos1 )
G_AddEvent( ent, EV_GENERAL_SOUND, ent->soundPos1 );
- }
// close areaportals
- if ( ent->teammaster == ent || !ent->teammaster ) {
+ if( ent->teammaster == ent || !ent->teammaster )
trap_AdjustAreaPortalState( ent, qfalse );
- }
- } else {
- G_Error( "Reached_BinaryMover: bad moverState" );
}
+ else
+ G_Error( "Reached_BinaryMover: bad moverState" );
}
@@ -537,73 +575,78 @@ void Reached_BinaryMover( gentity_t *ent ) {
Use_BinaryMover
================
*/
-void Use_BinaryMover( gentity_t *ent, gentity_t *other, gentity_t *activator ) {
+void Use_BinaryMover( gentity_t *ent, gentity_t *other, gentity_t *activator )
+{
int total;
int partial;
// only the master should be used
- if ( ent->flags & FL_TEAMSLAVE ) {
+ if( ent->flags & FL_TEAMSLAVE )
+ {
Use_BinaryMover( ent->teammaster, other, activator );
return;
}
ent->activator = activator;
- if ( ent->moverState == MOVER_POS1 ) {
+ if( ent->moverState == MOVER_POS1 )
+ {
// start moving 50 msec later, becase if this was player
// triggered, level.time hasn't been advanced yet
MatchTeam( ent, MOVER_1TO2, level.time + 50 );
// starting sound
- if ( ent->sound1to2 ) {
+ if( ent->sound1to2 )
G_AddEvent( ent, EV_GENERAL_SOUND, ent->sound1to2 );
- }
// looping sound
ent->s.loopSound = ent->soundLoop;
// open areaportal
- if ( ent->teammaster == ent || !ent->teammaster ) {
+ if( ent->teammaster == ent || !ent->teammaster )
trap_AdjustAreaPortalState( ent, qtrue );
- }
+
return;
}
// if all the way up, just delay before coming down
- if ( ent->moverState == MOVER_POS2 ) {
+ if( ent->moverState == MOVER_POS2 )
+ {
ent->nextthink = level.time + ent->wait;
return;
}
// only partway down before reversing
- if ( ent->moverState == MOVER_2TO1 ) {
+ if( ent->moverState == MOVER_2TO1 )
+ {
total = ent->s.pos.trDuration;
partial = level.time - ent->s.pos.trTime;
- if ( partial > total ) {
+
+ if( partial > total )
partial = total;
- }
MatchTeam( ent, MOVER_1TO2, level.time - ( total - partial ) );
- if ( ent->sound1to2 ) {
+ if( ent->sound1to2 )
G_AddEvent( ent, EV_GENERAL_SOUND, ent->sound1to2 );
- }
+
return;
}
// only partway up before reversing
- if ( ent->moverState == MOVER_1TO2 ) {
+ if( ent->moverState == MOVER_1TO2 )
+ {
total = ent->s.pos.trDuration;
partial = level.time - ent->s.pos.trTime;
- if ( partial > total ) {
+
+ if( partial > total )
partial = total;
- }
MatchTeam( ent, MOVER_2TO1, level.time - ( total - partial ) );
- if ( ent->sound2to1 ) {
+ if( ent->sound2to1 )
G_AddEvent( ent, EV_GENERAL_SOUND, ent->sound2to1 );
- }
+
return;
}
}
@@ -618,47 +661,48 @@ InitMover
so the movement delta can be calculated
================
*/
-void InitMover( gentity_t *ent ) {
+void InitMover( gentity_t *ent )
+{
vec3_t move;
- float distance;
- float light;
+ float distance;
+ float light;
vec3_t color;
qboolean lightSet, colorSet;
- char *sound;
+ char *sound;
// if the "model2" key is set, use a seperate model
// for drawing, but clip against the brushes
- if ( ent->model2 ) {
+ if( ent->model2 )
ent->s.modelindex2 = G_ModelIndex( ent->model2 );
- }
// if the "loopsound" key is set, use a constant looping sound when moving
- if ( G_SpawnString( "noise", "100", &sound ) ) {
+ if( G_SpawnString( "noise", "100", &sound ) )
ent->s.loopSound = G_SoundIndex( sound );
- }
// if the "color" or "light" keys are set, setup constantLight
lightSet = G_SpawnFloat( "light", "100", &light );
colorSet = G_SpawnVector( "color", "1 1 1", color );
- if ( lightSet || colorSet ) {
+
+ if( lightSet || colorSet )
+ {
int r, g, b, i;
- r = color[0] * 255;
- if ( r > 255 ) {
+ r = color[ 0 ] * 255;
+ if( r > 255 )
r = 255;
- }
- g = color[1] * 255;
- if ( g > 255 ) {
+
+ g = color[ 1 ] * 255;
+ if( g > 255 )
g = 255;
- }
- b = color[2] * 255;
- if ( b > 255 ) {
+
+ b = color[ 2 ] * 255;
+ if( b > 255 )
b = 255;
- }
+
i = light / 4;
- if ( i > 255 ) {
+ if( i > 255 )
i = 255;
- }
+
ent->s.constantLight = r | ( g << 8 ) | ( b << 16 ) | ( i << 24 );
}
@@ -669,8 +713,8 @@ void InitMover( gentity_t *ent ) {
ent->moverState = MOVER_POS1;
ent->r.svFlags = SVF_USE_CURRENT_ORIGIN;
ent->s.eType = ET_MOVER;
- VectorCopy (ent->pos1, ent->r.currentOrigin);
- trap_LinkEntity (ent);
+ VectorCopy( ent->pos1, ent->r.currentOrigin );
+ trap_LinkEntity( ent );
ent->s.pos.trType = TR_STATIONARY;
VectorCopy( ent->pos1, ent->s.pos.trBase );
@@ -678,14 +722,14 @@ void InitMover( gentity_t *ent ) {
// calculate time to reach second position from speed
VectorSubtract( ent->pos2, ent->pos1, move );
distance = VectorLength( move );
- if ( ! ent->speed ) {
+ if( ! ent->speed )
ent->speed = 100;
- }
+
VectorScale( move, ent->speed, ent->s.pos.trDelta );
ent->s.pos.trDuration = distance * 1000 / ent->speed;
- if ( ent->s.pos.trDuration <= 0 ) {
+
+ if( ent->s.pos.trDuration <= 0 )
ent->s.pos.trDuration = 1;
- }
}
@@ -705,21 +749,22 @@ targeted by another entity.
Blocked_Door
================
*/
-void Blocked_Door( gentity_t *ent, gentity_t *other ) {
+void Blocked_Door( gentity_t *ent, gentity_t *other )
+{
// remove anything other than a client
- if ( !other->client ) {
+ if( !other->client )
+ {
// except CTF flags!!!!
G_TempEntity( other->s.origin, EV_ITEM_POP );
G_FreeEntity( other );
return;
}
- if ( ent->damage ) {
+ if( ent->damage )
G_Damage( other, ent, ent, NULL, NULL, ent->damage, 0, MOD_CRUSH );
- }
- if ( ent->spawnflags & 4 ) {
+
+ if( ent->spawnflags & 4 )
return; // crushers don't reverse
- }
// reverse direction
Use_BinaryMover( ent, ent, other );
@@ -730,27 +775,36 @@ void Blocked_Door( gentity_t *ent, gentity_t *other ) {
Touch_DoorTriggerSpectator
================
*/
-static void Touch_DoorTriggerSpectator( gentity_t *ent, gentity_t *other, trace_t *trace ) {
- int i, axis;
- vec3_t origin, dir, angles;
+static void Touch_DoorTriggerSpectator( gentity_t *ent, gentity_t *other, trace_t *trace )
+{
+ int i, axis;
+ vec3_t origin, dir, angles;
axis = ent->count;
- VectorClear(dir);
- if (fabs(other->s.origin[axis] - ent->r.absmax[axis]) <
- fabs(other->s.origin[axis] - ent->r.absmin[axis])) {
- origin[axis] = ent->r.absmin[axis] - 10;
- dir[axis] = -1;
- }
- else {
- origin[axis] = ent->r.absmax[axis] + 10;
- dir[axis] = 1;
- }
- for (i = 0; i < 3; i++) {
- if (i == axis) continue;
- origin[i] = (ent->r.absmin[i] + ent->r.absmax[i]) * 0.5;
+ VectorClear( dir );
+
+ if( fabs( other->s.origin[ axis ] - ent->r.absmax[ axis ] ) <
+ fabs( other->s.origin[ axis ] - ent->r.absmin[ axis ] ) )
+ {
+ origin[ axis ] = ent->r.absmin[ axis ] - 10;
+ dir[ axis ] = -1;
+ }
+ else
+ {
+ origin[ axis ] = ent->r.absmax[ axis ] + 10;
+ dir[ axis ] = 1;
+ }
+
+ for( i = 0; i < 3; i++ )
+ {
+ if( i == axis )
+ continue;
+
+ origin[ i ] = ( ent->r.absmin[ i ] + ent->r.absmax[ i ] ) * 0.5;
}
- vectoangles(dir, angles);
- TeleportPlayer(other, origin, angles );
+
+ vectoangles( dir, angles );
+ TeleportPlayer( other, origin, angles );
}
/*
@@ -758,17 +812,17 @@ static void Touch_DoorTriggerSpectator( gentity_t *ent, gentity_t *other, trace_
Touch_DoorTrigger
================
*/
-void Touch_DoorTrigger( gentity_t *ent, gentity_t *other, trace_t *trace ) {
- if ( other->client && other->client->sess.sessionTeam == TEAM_SPECTATOR ) {
+void Touch_DoorTrigger( gentity_t *ent, gentity_t *other, trace_t *trace )
+{
+ if( other->client && other->client->sess.sessionTeam == TEAM_SPECTATOR )
+ {
// if the door is not open and not opening
- if ( ent->parent->moverState != MOVER_1TO2 &&
- ent->parent->moverState != MOVER_POS2) {
+ if( ent->parent->moverState != MOVER_1TO2 &&
+ ent->parent->moverState != MOVER_POS2 )
Touch_DoorTriggerSpectator( ent, other, trace );
- }
}
- else if ( ent->parent->moverState != MOVER_1TO2 ) {
+ else if( ent->parent->moverState != MOVER_1TO2 )
Use_BinaryMover( ent->parent, ent, other );
- }
}
@@ -780,51 +834,54 @@ All of the parts of a door have been spawned, so create
a trigger that encloses all of them
======================
*/
-void Think_SpawnNewDoorTrigger( gentity_t *ent ) {
- gentity_t *other;
+void Think_SpawnNewDoorTrigger( gentity_t *ent )
+{
+ gentity_t *other;
vec3_t mins, maxs;
- int i, best;
+ int i, best;
// set all of the slaves as shootable
- for ( other = ent ; other ; other = other->teamchain ) {
+ for( other = ent; other; other = other->teamchain )
other->takedamage = qtrue;
- }
// find the bounds of everything on the team
- VectorCopy (ent->r.absmin, mins);
- VectorCopy (ent->r.absmax, maxs);
+ VectorCopy( ent->r.absmin, mins );
+ VectorCopy( ent->r.absmax, maxs );
- for (other = ent->teamchain ; other ; other=other->teamchain) {
- AddPointToBounds (other->r.absmin, mins, maxs);
- AddPointToBounds (other->r.absmax, mins, maxs);
+ for( other = ent->teamchain; other; other=other->teamchain )
+ {
+ AddPointToBounds( other->r.absmin, mins, maxs );
+ AddPointToBounds( other->r.absmax, mins, maxs );
}
// find the thinnest axis, which will be the one we expand
best = 0;
- for ( i = 1 ; i < 3 ; i++ ) {
- if ( maxs[i] - mins[i] < maxs[best] - mins[best] ) {
+ for( i = 1; i < 3; i++ )
+ {
+ if( maxs[ i ] - mins[ i ] < maxs[ best ] - mins[ best ] )
best = i;
- }
}
- maxs[best] += 120;
- mins[best] -= 120;
+
+ maxs[ best ] += 120;
+ mins[ best ] -= 120;
// create a trigger with this size
- other = G_Spawn ();
+ other = G_Spawn( );
other->classname = "door_trigger";
- VectorCopy (mins, other->r.mins);
- VectorCopy (maxs, other->r.maxs);
+ VectorCopy( mins, other->r.mins );
+ VectorCopy( maxs, other->r.maxs );
other->parent = ent;
other->r.contents = CONTENTS_TRIGGER;
other->touch = Touch_DoorTrigger;
// remember the thinnest axis
other->count = best;
- trap_LinkEntity (other);
+ trap_LinkEntity( other );
MatchTeam( ent, ent->moverState, level.time );
}
-void Think_MatchTeam( gentity_t *ent ) {
+void Think_MatchTeam( gentity_t *ent )
+{
MatchTeam( ent, ent->moverState, level.time );
}
@@ -845,24 +902,26 @@ NOMONSTER monsters will not trigger this door
"light" constantLight radius
"health" if set, the door must be shot open
*/
-void SP_func_door (gentity_t *ent) {
+void SP_func_door( gentity_t *ent )
+{
vec3_t abs_movedir;
- float distance;
+ float distance;
vec3_t size;
- float lip;
+ float lip;
- ent->sound1to2 = ent->sound2to1 = G_SoundIndex("sound/movers/doors/dr1_strt.wav");
- ent->soundPos1 = ent->soundPos2 = G_SoundIndex("sound/movers/doors/dr1_end.wav");
+ ent->sound1to2 = ent->sound2to1 = G_SoundIndex( "sound/movers/doors/dr1_strt.wav" );
+ ent->soundPos1 = ent->soundPos2 = G_SoundIndex( "sound/movers/doors/dr1_end.wav" );
ent->blocked = Blocked_Door;
// default speed of 400
- if (!ent->speed)
+ if( !ent->speed )
ent->speed = 400;
// default wait of 2 seconds
- if (!ent->wait)
+ if( !ent->wait )
ent->wait = 2;
+
ent->wait *= 1000;
// default lip of 8 units
@@ -876,16 +935,17 @@ void SP_func_door (gentity_t *ent) {
// calculate second position
trap_SetBrushModel( ent, ent->model );
- G_SetMovedir (ent->s.angles, ent->movedir);
- abs_movedir[0] = fabs(ent->movedir[0]);
- abs_movedir[1] = fabs(ent->movedir[1]);
- abs_movedir[2] = fabs(ent->movedir[2]);
+ G_SetMovedir( ent->s.angles, ent->movedir );
+ abs_movedir[ 0 ] = fabs( ent->movedir[ 0 ] );
+ abs_movedir[ 1 ] = fabs( ent->movedir[ 1 ] );
+ abs_movedir[ 2 ] = fabs( ent->movedir[ 2 ] );
VectorSubtract( ent->r.maxs, ent->r.mins, size );
distance = DotProduct( abs_movedir, size ) - lip;
VectorMA( ent->pos1, distance, ent->movedir, ent->pos2 );
// if "start_open", reverse position 1 and 2
- if ( ent->spawnflags & 1 ) {
+ if( ent->spawnflags & 1 )
+ {
vec3_t temp;
VectorCopy( ent->pos2, temp );
@@ -897,22 +957,22 @@ void SP_func_door (gentity_t *ent) {
ent->nextthink = level.time + FRAMETIME;
- if ( ! (ent->flags & FL_TEAMSLAVE ) ) {
+ if( ! (ent->flags & FL_TEAMSLAVE ) )
+ {
int health;
G_SpawnInt( "health", "0", &health );
- if ( health ) {
+ if( health )
ent->takedamage = qtrue;
- }
- if ( ent->targetname || health ) {
+
+ if( ent->targetname || health )
+ {
// non touch/shoot doors
ent->think = Think_MatchTeam;
- } else {
- ent->think = Think_SpawnNewDoorTrigger;
}
+ else
+ ent->think = Think_SpawnNewDoorTrigger;
}
-
-
}
/*
@@ -930,15 +990,14 @@ Touch_Plat
Don't allow decent if a living player is on it
===============
*/
-void Touch_Plat( gentity_t *ent, gentity_t *other, trace_t *trace ) {
- if ( !other->client || other->client->ps.stats[STAT_HEALTH] <= 0 ) {
+void Touch_Plat( gentity_t *ent, gentity_t *other, trace_t *trace )
+{
+ if( !other->client || other->client->ps.stats[ STAT_HEALTH ] <= 0 )
return;
- }
// delay return-to-pos1 by one second
- if ( ent->moverState == MOVER_POS2 ) {
+ if( ent->moverState == MOVER_POS2 )
ent->nextthink = level.time + 1000;
- }
}
/*
@@ -948,14 +1007,13 @@ Touch_PlatCenterTrigger
If the plat is at the bottom position, start it going up
===============
*/
-void Touch_PlatCenterTrigger(gentity_t *ent, gentity_t *other, trace_t *trace ) {
- if ( !other->client ) {
+void Touch_PlatCenterTrigger( gentity_t *ent, gentity_t *other, trace_t *trace )
+{
+ if( !other->client )
return;
- }
- if ( ent->parent->moverState == MOVER_POS1 ) {
+ if( ent->parent->moverState == MOVER_POS1 )
Use_BinaryMover( ent->parent, ent, other );
- }
}
@@ -968,39 +1026,43 @@ Elevator cars require that the trigger extend through the entire low position,
not just sit on top of it.
================
*/
-void SpawnPlatTrigger( gentity_t *ent ) {
+void SpawnPlatTrigger( gentity_t *ent )
+{
gentity_t *trigger;
- vec3_t tmin, tmax;
+ vec3_t tmin, tmax;
// the middle trigger will be a thin trigger just
// above the starting position
- trigger = G_Spawn();
+ trigger = G_Spawn( );
trigger->classname = "plat_trigger";
trigger->touch = Touch_PlatCenterTrigger;
trigger->r.contents = CONTENTS_TRIGGER;
trigger->parent = ent;
- tmin[0] = ent->pos1[0] + ent->r.mins[0] + 33;
- tmin[1] = ent->pos1[1] + ent->r.mins[1] + 33;
- tmin[2] = ent->pos1[2] + ent->r.mins[2];
+ tmin[ 0 ] = ent->pos1[ 0 ] + ent->r.mins[ 0 ] + 33;
+ tmin[ 1 ] = ent->pos1[ 1 ] + ent->r.mins[ 1 ] + 33;
+ tmin[ 2 ] = ent->pos1[ 2 ] + ent->r.mins[ 2 ];
- tmax[0] = ent->pos1[0] + ent->r.maxs[0] - 33;
- tmax[1] = ent->pos1[1] + ent->r.maxs[1] - 33;
- tmax[2] = ent->pos1[2] + ent->r.maxs[2] + 8;
+ tmax[ 0 ] = ent->pos1[ 0 ] + ent->r.maxs[ 0 ] - 33;
+ tmax[ 1 ] = ent->pos1[ 1 ] + ent->r.maxs[ 1 ] - 33;
+ tmax[ 2 ] = ent->pos1[ 2 ] + ent->r.maxs[ 2 ] + 8;
- if ( tmax[0] <= tmin[0] ) {
- tmin[0] = ent->pos1[0] + (ent->r.mins[0] + ent->r.maxs[0]) *0.5;
- tmax[0] = tmin[0] + 1;
+ if( tmax[ 0 ] <= tmin[ 0 ] )
+ {
+ tmin[ 0 ] = ent->pos1[ 0 ] + ( ent->r.mins[ 0 ] + ent->r.maxs[ 0 ] ) * 0.5;
+ tmax[ 0 ] = tmin[ 0 ] + 1;
}
- if ( tmax[1] <= tmin[1] ) {
- tmin[1] = ent->pos1[1] + (ent->r.mins[1] + ent->r.maxs[1]) *0.5;
- tmax[1] = tmin[1] + 1;
+
+ if( tmax[ 1 ] <= tmin[ 1 ] )
+ {
+ tmin[ 1 ] = ent->pos1[ 1 ] + ( ent->r.mins[ 1 ] + ent->r.maxs[ 1 ] ) * 0.5;
+ tmax[ 1 ] = tmin[ 1 ] + 1;
}
- VectorCopy (tmin, trigger->r.mins);
- VectorCopy (tmax, trigger->r.maxs);
+ VectorCopy( tmin, trigger->r.mins );
+ VectorCopy( tmax, trigger->r.maxs );
- trap_LinkEntity (trigger);
+ trap_LinkEntity( trigger );
}
@@ -1015,13 +1077,14 @@ Plats are always drawn in the extended position so they will light correctly.
"color" constantLight color
"light" constantLight radius
*/
-void SP_func_plat (gentity_t *ent) {
- float lip, height;
+void SP_func_plat( gentity_t *ent )
+{
+ float lip, height;
- ent->sound1to2 = ent->sound2to1 = G_SoundIndex("sound/movers/plats/pt1_strt.wav");
- ent->soundPos1 = ent->soundPos2 = G_SoundIndex("sound/movers/plats/pt1_end.wav");
+ ent->sound1to2 = ent->sound2to1 = G_SoundIndex( "sound/movers/plats/pt1_strt.wav" );
+ ent->soundPos1 = ent->soundPos2 = G_SoundIndex( "sound/movers/plats/pt1_end.wav" );
- VectorClear (ent->s.angles);
+ VectorClear( ent->s.angles );
G_SpawnFloat( "speed", "200", &ent->speed );
G_SpawnInt( "dmg", "2", &ent->damage );
@@ -1033,14 +1096,13 @@ void SP_func_plat (gentity_t *ent) {
// create second position
trap_SetBrushModel( ent, ent->model );
- if ( !G_SpawnFloat( "height", "0", &height ) ) {
- height = (ent->r.maxs[2] - ent->r.mins[2]) - lip;
- }
+ if( !G_SpawnFloat( "height", "0", &height ) )
+ height = ( ent->r.maxs[ 2 ] - ent->r.mins[ 2 ] ) - lip;
// pos1 is the rest (bottom) position, pos2 is the top
VectorCopy( ent->s.origin, ent->pos2 );
VectorCopy( ent->pos2, ent->pos1 );
- ent->pos1[2] -= height;
+ ent->pos1[ 2 ] -= height;
InitMover( ent );
@@ -1053,9 +1115,8 @@ void SP_func_plat (gentity_t *ent) {
ent->parent = ent; // so it can be treated as a door
// spawn the trigger if one hasn't been custom made
- if ( !ent->targetname ) {
- SpawnPlatTrigger(ent);
- }
+ if( !ent->targetname )
+ SpawnPlatTrigger( ent );
}
@@ -1073,14 +1134,13 @@ Touch_Button
===============
*/
-void Touch_Button(gentity_t *ent, gentity_t *other, trace_t *trace ) {
- if ( !other->client ) {
+void Touch_Button( gentity_t *ent, gentity_t *other, trace_t *trace )
+{
+ if( !other->client )
return;
- }
- if ( ent->moverState == MOVER_POS1 ) {
+ if( ent->moverState == MOVER_POS1 )
Use_BinaryMover( ent, other, other );
- }
}
@@ -1097,21 +1157,21 @@ When a button is touched, it moves some distance in the direction of it's angle,
"color" constantLight color
"light" constantLight radius
*/
-void SP_func_button( gentity_t *ent ) {
- vec3_t abs_movedir;
+void SP_func_button( gentity_t *ent )
+{
+ vec3_t abs_movedir;
float distance;
- vec3_t size;
+ vec3_t size;
float lip;
- ent->sound1to2 = G_SoundIndex("sound/movers/switches/butn2.wav");
+ ent->sound1to2 = G_SoundIndex( "sound/movers/switches/butn2.wav" );
- if ( !ent->speed ) {
+ if( !ent->speed )
ent->speed = 40;
- }
- if ( !ent->wait ) {
+ if( !ent->wait )
ent->wait = 1;
- }
+
ent->wait *= 1000;
// first position
@@ -1123,17 +1183,20 @@ void SP_func_button( gentity_t *ent ) {
G_SpawnFloat( "lip", "4", &lip );
G_SetMovedir( ent->s.angles, ent->movedir );
- abs_movedir[0] = fabs(ent->movedir[0]);
- abs_movedir[1] = fabs(ent->movedir[1]);
- abs_movedir[2] = fabs(ent->movedir[2]);
+ abs_movedir[ 0 ] = fabs( ent->movedir[ 0 ] );
+ abs_movedir[ 1 ] = fabs( ent->movedir[ 1 ] );
+ abs_movedir[ 2 ] = fabs( ent->movedir[ 2 ] );
VectorSubtract( ent->r.maxs, ent->r.mins, size );
- distance = abs_movedir[0] * size[0] + abs_movedir[1] * size[1] + abs_movedir[2] * size[2] - lip;
- VectorMA (ent->pos1, distance, ent->movedir, ent->pos2);
+ distance = abs_movedir[ 0 ] * size[ 0 ] + abs_movedir[ 1 ] * size[ 1 ] + abs_movedir[ 2 ] * size[ 2 ] - lip;
+ VectorMA( ent->pos1, distance, ent->movedir, ent->pos2 );
- if (ent->health) {
+ if( ent->health )
+ {
// shootable button
ent->takedamage = qtrue;
- } else {
+ }
+ else
+ {
// touchable button
ent->touch = Touch_Button;
}
@@ -1163,7 +1226,8 @@ Think_BeginMoving
The wait time at a corner has completed, so start moving again
===============
*/
-void Think_BeginMoving( gentity_t *ent ) {
+void Think_BeginMoving( gentity_t *ent )
+{
ent->s.pos.trTime = level.time;
ent->s.pos.trType = TR_LINEAR_STOP;
}
@@ -1173,17 +1237,17 @@ void Think_BeginMoving( gentity_t *ent ) {
Reached_Train
===============
*/
-void Reached_Train( gentity_t *ent ) {
- gentity_t *next;
+void Reached_Train( gentity_t *ent )
+{
+ gentity_t *next;
float speed;
- vec3_t move;
+ vec3_t move;
float length;
// copy the apropriate values
next = ent->nextTrain;
- if ( !next || !next->nextTrain ) {
+ if( !next || !next->nextTrain )
return; // just stop
- }
// fire all other targets
G_UseTargets( next, NULL );
@@ -1194,15 +1258,18 @@ void Reached_Train( gentity_t *ent ) {
VectorCopy( next->nextTrain->s.origin, ent->pos2 );
// if the path_corner has a speed, use that
- if ( next->speed ) {
+ if( next->speed )
+ {
speed = next->speed;
- } else {
+ }
+ else
+ {
// otherwise use the train's speed
speed = ent->speed;
}
- if ( speed < 1 ) {
+
+ if( speed < 1 )
speed = 1;
- }
// calculate duration
VectorSubtract( ent->pos2, ent->pos1, move );
@@ -1217,7 +1284,8 @@ void Reached_Train( gentity_t *ent ) {
SetMoverState( ent, MOVER_1TO2, level.time );
// if there is a "wait" value on the target, don't start moving yet
- if ( next->wait ) {
+ if( next->wait )
+ {
ent->nextthink = level.time + next->wait * 1000;
ent->think = Think_BeginMoving;
ent->s.pos.trType = TR_STATIONARY;
@@ -1232,25 +1300,29 @@ Think_SetupTrainTargets
Link all the corners together
===============
*/
-void Think_SetupTrainTargets( gentity_t *ent ) {
- gentity_t *path, *next, *start;
-
- ent->nextTrain = G_Find( NULL, FOFS(targetname), ent->target );
- if ( !ent->nextTrain ) {
+void Think_SetupTrainTargets( gentity_t *ent )
+{
+ gentity_t *path, *next, *start;
+
+ ent->nextTrain = G_Find( NULL, FOFS( targetname ), ent->target );
+
+ if( !ent->nextTrain )
+ {
G_Printf( "func_train at %s with an unfound target\n",
- vtos(ent->r.absmin) );
+ vtos( ent->r.absmin ) );
return;
}
start = NULL;
- for ( path = ent->nextTrain ; path != start ; path = next ) {
- if ( !start ) {
+ for( path = ent->nextTrain; path != start; path = next )
+ {
+ if( !start )
start = path;
- }
- if ( !path->target ) {
+ if( !path->target )
+ {
G_Printf( "Train corner at %s without a target\n",
- vtos(path->s.origin) );
+ vtos( path->s.origin ) );
return;
}
@@ -1258,14 +1330,17 @@ void Think_SetupTrainTargets( gentity_t *ent ) {
// there may also be other targets that get fired when the corner
// is reached
next = NULL;
- do {
- next = G_Find( next, FOFS(targetname), path->target );
- if ( !next ) {
+ do
+ {
+ next = G_Find( next, FOFS( targetname ), path->target );
+
+ if( !next )
+ {
G_Printf( "Train corner at %s without a target path_corner\n",
- vtos(path->s.origin) );
+ vtos( path->s.origin ) );
return;
}
- } while ( strcmp( next->classname, "path_corner" ) );
+ } while( strcmp( next->classname, "path_corner" ) );
path->nextTrain = next;
}
@@ -1282,9 +1357,11 @@ Target: next path corner and other targets to fire
"speed" speed to move to the next corner
"wait" seconds to wait before behining move to next corner
*/
-void SP_path_corner( gentity_t *self ) {
- if ( !self->targetname ) {
- G_Printf ("path_corner with no targetname at %s\n", vtos(self->s.origin));
+void SP_path_corner( gentity_t *self )
+{
+ if( !self->targetname )
+ {
+ G_Printf( "path_corner with no targetname at %s\n", vtos( self->s.origin ) );
G_FreeEntity( self );
return;
}
@@ -1305,23 +1382,23 @@ The train spawns at the first target it is pointing at.
"color" constantLight color
"light" constantLight radius
*/
-void SP_func_train (gentity_t *self) {
- VectorClear (self->s.angles);
+void SP_func_train( gentity_t *self )
+{
+ VectorClear( self->s.angles );
- if (self->spawnflags & TRAIN_BLOCK_STOPS) {
+ if( self->spawnflags & TRAIN_BLOCK_STOPS )
+ {
self->damage = 0;
- } else {
- if (!self->damage) {
- self->damage = 2;
- }
}
+ else if( !self->damage )
+ self->damage = 2;
- if ( !self->speed ) {
+ if( !self->speed )
self->speed = 100;
- }
- if ( !self->target ) {
- G_Printf ("func_train without a target at %s\n", vtos(self->r.absmin));
+ if( !self->target )
+ {
+ G_Printf( "func_train without a target at %s\n", vtos( self->r.absmin ) );
G_FreeEntity( self );
return;
}
@@ -1352,7 +1429,8 @@ A bmodel that just sits there, doing nothing. Can be used for conditional walls
"color" constantLight color
"light" constantLight radius
*/
-void SP_func_static( gentity_t *ent ) {
+void SP_func_static( gentity_t *ent )
+{
trap_SetBrushModel( ent, ent->model );
InitMover( ent );
VectorCopy( ent->s.origin, ent->s.pos.trBase );
@@ -1380,24 +1458,23 @@ check either the X_AXIS or Y_AXIS box to change that.
"color" constantLight color
"light" constantLight radius
*/
-void SP_func_rotating (gentity_t *ent) {
- if ( !ent->speed ) {
+void SP_func_rotating( gentity_t *ent )
+{
+ if( !ent->speed )
ent->speed = 100;
- }
// set the axis of rotation
ent->s.apos.trType = TR_LINEAR;
- if ( ent->spawnflags & 4 ) {
- ent->s.apos.trDelta[2] = ent->speed;
- } else if ( ent->spawnflags & 8 ) {
- ent->s.apos.trDelta[0] = ent->speed;
- } else {
- ent->s.apos.trDelta[1] = ent->speed;
- }
- if (!ent->damage) {
+ if( ent->spawnflags & 4 )
+ ent->s.apos.trDelta[ 2 ] = ent->speed;
+ else if( ent->spawnflags & 8 )
+ ent->s.apos.trDelta[ 0 ] = ent->speed;
+ else
+ ent->s.apos.trDelta[ 1 ] = ent->speed;
+
+ if( !ent->damage )
ent->damage = 2;
- }
trap_SetBrushModel( ent, ent->model );
InitMover( ent );
@@ -1429,7 +1506,8 @@ Normally bobs on the Z axis
"color" constantLight color
"light" constantLight radius
*/
-void SP_func_bobbing (gentity_t *ent) {
+void SP_func_bobbing( gentity_t *ent )
+{
float height;
float phase;
@@ -1449,13 +1527,12 @@ void SP_func_bobbing (gentity_t *ent) {
ent->s.pos.trType = TR_SINE;
// set the axis of bobbing
- if ( ent->spawnflags & 1 ) {
- ent->s.pos.trDelta[0] = height;
- } else if ( ent->spawnflags & 2 ) {
- ent->s.pos.trDelta[1] = height;
- } else {
- ent->s.pos.trDelta[2] = height;
- }
+ if( ent->spawnflags & 1 )
+ ent->s.pos.trDelta[ 0 ] = height;
+ else if( ent->spawnflags & 2 )
+ ent->s.pos.trDelta[ 1 ] = height;
+ else
+ ent->s.pos.trDelta[ 2 ] = height;
}
/*
@@ -1478,11 +1555,12 @@ Pendulum frequency is a physical constant based on the length of the beam and gr
"color" constantLight color
"light" constantLight radius
*/
-void SP_func_pendulum(gentity_t *ent) {
- float freq;
- float length;
- float phase;
- float speed;
+void SP_func_pendulum( gentity_t *ent )
+{
+ float freq;
+ float length;
+ float phase;
+ float speed;
G_SpawnFloat( "speed", "30", &speed );
G_SpawnInt( "dmg", "2", &ent->damage );
@@ -1491,10 +1569,10 @@ void SP_func_pendulum(gentity_t *ent) {
trap_SetBrushModel( ent, ent->model );
// find pendulum length
- length = fabs( ent->r.mins[2] );
- if ( length < 8 ) {
+ length = fabs( ent->r.mins[ 2 ] );
+
+ if( length < 8 )
length = 8;
- }
freq = 1 / ( M_PI * 2 ) * sqrt( g_gravity.value / ( 3 * length ) );
@@ -1510,5 +1588,5 @@ void SP_func_pendulum(gentity_t *ent) {
ent->s.apos.trDuration = 1000 / freq;
ent->s.apos.trTime = ent->s.apos.trDuration * phase;
ent->s.apos.trType = TR_SINE;
- ent->s.apos.trDelta[2] = speed;
+ ent->s.apos.trDelta[ 2 ] = speed;
}
diff --git a/src/game/g_session.c b/src/game/g_session.c
index 0ac65709..7f44d5b0 100644
--- a/src/game/g_session.c
+++ b/src/game/g_session.c
@@ -34,11 +34,12 @@ G_WriteClientSessionData
Called on game shutdown
================
*/
-void G_WriteClientSessionData( gclient_t *client ) {
+void G_WriteClientSessionData( gclient_t *client )
+{
const char *s;
const char *var;
- s = va("%i %i %i %i %i %i %i",
+ s = va( "%i %i %i %i %i %i %i",
client->sess.sessionTeam,
client->sess.spectatorTime,
client->sess.spectatorState,
@@ -60,8 +61,9 @@ G_ReadSessionData
Called on a reconnect
================
*/
-void G_ReadSessionData( gclient_t *client ) {
- char s[MAX_STRING_CHARS];
+void G_ReadSessionData( gclient_t *client )
+{
+ char s[ MAX_STRING_CHARS ];
const char *var;
// bk001205 - format
@@ -96,9 +98,10 @@ G_InitSessionData
Called on a first-time connect
================
*/
-void G_InitSessionData( gclient_t *client, char *userinfo ) {
+void G_InitSessionData( gclient_t *client, char *userinfo )
+{
clientSession_t *sess;
- const char *value;
+ const char *value;
sess = &client->sess;
@@ -131,7 +134,8 @@ G_WriteSessionData
==================
*/
-void G_WriteSessionData( void ) {
+void G_WriteSessionData( void )
+{
int i;
//TA: ?
diff --git a/src/game/g_spawn.c b/src/game/g_spawn.c
index b9fb1851..b66675c0 100644
--- a/src/game/g_spawn.c
+++ b/src/game/g_spawn.c
@@ -16,17 +16,21 @@
#include "g_local.h"
-qboolean G_SpawnString( const char *key, const char *defaultString, char **out ) {
+qboolean G_SpawnString( const char *key, const char *defaultString, char **out )
+{
int i;
- if ( !level.spawning ) {
+ if( !level.spawning )
+ {
*out = (char *)defaultString;
// G_Error( "G_SpawnString() called while not spawning" );
}
- for ( i = 0 ; i < level.numSpawnVars ; i++ ) {
- if ( !Q_stricmp( key, level.spawnVars[i][0] ) ) {
- *out = level.spawnVars[i][1];
+ for( i = 0; i < level.numSpawnVars; i++ )
+ {
+ if( !Q_stricmp( key, level.spawnVars[ i ][ 0 ] ) )
+ {
+ *out = level.spawnVars[ i ][ 1 ];
return qtrue;
}
}
@@ -35,7 +39,8 @@ qboolean G_SpawnString( const char *key, const char *defaultString, char **out
return qfalse;
}
-qboolean G_SpawnFloat( const char *key, const char *defaultString, float *out ) {
+qboolean G_SpawnFloat( const char *key, const char *defaultString, float *out )
+{
char *s;
qboolean present;
@@ -44,8 +49,9 @@ qboolean G_SpawnFloat( const char *key, const char *defaultString, float *out )
return present;
}
-qboolean G_SpawnInt( const char *key, const char *defaultString, int *out ) {
- char *s;
+qboolean G_SpawnInt( const char *key, const char *defaultString, int *out )
+{
+ char *s;
qboolean present;
present = G_SpawnString( key, defaultString, &s );
@@ -53,21 +59,23 @@ qboolean G_SpawnInt( const char *key, const char *defaultString, int *out ) {
return present;
}
-qboolean G_SpawnVector( const char *key, const char *defaultString, float *out ) {
+qboolean G_SpawnVector( const char *key, const char *defaultString, float *out )
+{
char *s;
qboolean present;
present = G_SpawnString( key, defaultString, &s );
- sscanf( s, "%f %f %f", &out[0], &out[1], &out[2] );
+ sscanf( s, "%f %f %f", &out[ 0 ], &out[ 1 ], &out[ 2 ] );
return present;
}
-qboolean G_SpawnVector4( const char *key, const char *defaultString, float *out ) {
+qboolean G_SpawnVector4( const char *key, const char *defaultString, float *out )
+{
char *s;
qboolean present;
present = G_SpawnString( key, defaultString, &s );
- sscanf( s, "%f %f %f %f", &out[0], &out[1], &out[2], &out[3] );
+ sscanf( s, "%f %f %f %f", &out[ 0 ], &out[ 1 ], &out[ 2 ], &out[ 3 ] );
return present;
}
@@ -76,7 +84,8 @@ qboolean G_SpawnVector4( const char *key, const char *defaultString, float *out
//
// fields are needed for spawning from the entity string
//
-typedef enum {
+typedef enum
+{
F_INT,
F_FLOAT,
F_LSTRING, // string on disk, pointer in memory, TAG_LEVEL
@@ -98,7 +107,8 @@ typedef struct
int flags;
} field_t;
-field_t fields[] = {
+field_t fields[ ] =
+{
{"classname", FOFS(classname), F_LSTRING},
{"origin", FOFS(s.origin), F_VECTOR},
{"model", FOFS(model), F_LSTRING},
@@ -131,65 +141,66 @@ field_t fields[] = {
};
-typedef struct {
+typedef struct
+{
char *name;
void (*spawn)(gentity_t *ent);
} spawn_t;
-void SP_info_player_start (gentity_t *ent);
-void SP_info_player_deathmatch (gentity_t *ent);
-void SP_info_player_intermission (gentity_t *ent);
+void SP_info_player_start( gentity_t *ent );
+void SP_info_player_deathmatch( gentity_t *ent );
+void SP_info_player_intermission( gentity_t *ent );
//TA: extra bits
void SP_info_alien_intermission( gentity_t *ent );
void SP_info_human_intermission( gentity_t *ent );
-void SP_info_firstplace(gentity_t *ent);
-void SP_info_secondplace(gentity_t *ent);
-void SP_info_thirdplace(gentity_t *ent);
-void SP_info_podium(gentity_t *ent);
+void SP_info_firstplace( gentity_t *ent );
+void SP_info_secondplace( gentity_t *ent );
+void SP_info_thirdplace( gentity_t *ent );
+void SP_info_podium( gentity_t *ent );
-void SP_func_plat (gentity_t *ent);
-void SP_func_static (gentity_t *ent);
-void SP_func_rotating (gentity_t *ent);
-void SP_func_bobbing (gentity_t *ent);
+void SP_func_plat( gentity_t *ent );
+void SP_func_static( gentity_t *ent );
+void SP_func_rotating( gentity_t *ent );
+void SP_func_bobbing( gentity_t *ent );
void SP_func_pendulum( gentity_t *ent );
-void SP_func_button (gentity_t *ent);
-void SP_func_door (gentity_t *ent);
-void SP_func_train (gentity_t *ent);
-void SP_func_timer (gentity_t *self);
+void SP_func_button( gentity_t *ent );
+void SP_func_door( gentity_t *ent );
+void SP_func_train( gentity_t *ent );
+void SP_func_timer( gentity_t *self);
-void SP_trigger_always (gentity_t *ent);
-void SP_trigger_multiple (gentity_t *ent);
-void SP_trigger_push (gentity_t *ent);
-void SP_trigger_teleport (gentity_t *ent);
-void SP_trigger_hurt (gentity_t *ent);
+void SP_trigger_always( gentity_t *ent );
+void SP_trigger_multiple( gentity_t *ent );
+void SP_trigger_push( gentity_t *ent );
+void SP_trigger_teleport( gentity_t *ent );
+void SP_trigger_hurt( gentity_t *ent );
void SP_target_remove_powerups( gentity_t *ent );
-void SP_target_give (gentity_t *ent);
-void SP_target_delay (gentity_t *ent);
-void SP_target_speaker (gentity_t *ent);
-void SP_target_print (gentity_t *ent);
-void SP_target_laser (gentity_t *self);
-void SP_target_character (gentity_t *ent);
+void SP_target_give( gentity_t *ent );
+void SP_target_delay( gentity_t *ent );
+void SP_target_speaker( gentity_t *ent );
+void SP_target_print( gentity_t *ent );
+void SP_target_laser( gentity_t *self);
+void SP_target_character( gentity_t *ent );
void SP_target_score( gentity_t *ent );
void SP_target_teleporter( gentity_t *ent );
-void SP_target_relay (gentity_t *ent);
-void SP_target_kill (gentity_t *ent);
-void SP_target_position (gentity_t *ent);
-void SP_target_location (gentity_t *ent);
-void SP_target_push (gentity_t *ent);
-
-void SP_light (gentity_t *self);
-void SP_info_null (gentity_t *self);
-void SP_info_notnull (gentity_t *self);
-void SP_info_camp (gentity_t *self);
-void SP_path_corner (gentity_t *self);
-
-void SP_misc_teleporter_dest (gentity_t *self);
-void SP_misc_model(gentity_t *ent);
-void SP_misc_portal_camera(gentity_t *ent);
-void SP_misc_portal_surface(gentity_t *ent);
+void SP_target_relay( gentity_t *ent );
+void SP_target_kill( gentity_t *ent );
+void SP_target_position( gentity_t *ent );
+void SP_target_location( gentity_t *ent );
+void SP_target_push( gentity_t *ent );
+
+void SP_light( gentity_t *self );
+void SP_info_null( gentity_t *self );
+void SP_info_notnull( gentity_t *self );
+void SP_info_camp( gentity_t *self );
+void SP_path_corner( gentity_t *self );
+
+void SP_misc_teleporter_dest( gentity_t *self );
+void SP_misc_model( gentity_t *ent );
+void SP_misc_portal_camera( gentity_t *ent );
+void SP_misc_portal_surface( gentity_t *ent );
void SP_shooter_rocket( gentity_t *ent );
void SP_shooter_plasma( gentity_t *ent );
@@ -200,7 +211,8 @@ void SP_misc_spriter( gentity_t *ent );
void SP_misc_anim_model( gentity_t *ent );
void SP_misc_light_flare( gentity_t *ent );
-spawn_t spawns[] = {
+spawn_t spawns[ ] =
+{
// info entities don't do anything at all, but provide positional
// information for things controlled by other processes
{"info_player_start", SP_info_player_start},
@@ -286,8 +298,9 @@ qboolean G_CallSpawn( gentity_t *ent )
gitem_t *item;
buildable_t buildable;
- if ( !ent->classname ) {
- G_Printf ("G_CallSpawn: NULL classname\n");
+ if( !ent->classname )
+ {
+ G_Printf( "G_CallSpawn: NULL classname\n" );
return qfalse;
}
@@ -321,28 +334,30 @@ Builds a copy of the string, translating \n to real linefeeds
so message texts can be multi-line
=============
*/
-char *G_NewString( const char *string ) {
+char *G_NewString( const char *string )
+{
char *newb, *new_p;
int i,l;
- l = strlen(string) + 1;
+ l = strlen( string ) + 1;
newb = G_Alloc( l );
new_p = newb;
// turn \n into a real linefeed
- for ( i=0 ; i< l ; i++ ) {
- if (string[i] == '\\' && i < l-1) {
+ for( i = 0 ; i < l ; i++ )
+ {
+ if( string[ i ] == '\\' && i < l - 1 )
+ {
i++;
- if (string[i] == 'n') {
+ if( string[ i ] == 'n' )
*new_p++ = '\n';
- } else {
+ else
*new_p++ = '\\';
- }
- } else {
- *new_p++ = string[i];
}
+ else
+ *new_p++ = string[ i ];
}
return newb;
@@ -359,51 +374,62 @@ Takes a key/value pair and sets the binary values
in a gentity
===============
*/
-void G_ParseField( const char *key, const char *value, gentity_t *ent ) {
+void G_ParseField( const char *key, const char *value, gentity_t *ent )
+{
field_t *f;
byte *b;
float v;
vec3_t vec;
vec4_t vec4;
- for ( f=fields ; f->name ; f++ ) {
- if ( !Q_stricmp(f->name, key) ) {
+ for( f = fields; f->name; f++ )
+ {
+ if( !Q_stricmp( f->name, key ) )
+ {
// found it
b = (byte *)ent;
- switch( f->type ) {
- case F_LSTRING:
- *(char **)(b+f->ofs) = G_NewString (value);
- break;
- case F_VECTOR:
- sscanf (value, "%f %f %f", &vec[0], &vec[1], &vec[2]);
- ((float *)(b+f->ofs))[0] = vec[0];
- ((float *)(b+f->ofs))[1] = vec[1];
- ((float *)(b+f->ofs))[2] = vec[2];
- break;
- case F_VECTOR4:
- sscanf (value, "%f %f %f %f", &vec4[0], &vec4[1], &vec4[2], &vec4[3]);
- ((float *)(b+f->ofs))[0] = vec4[0];
- ((float *)(b+f->ofs))[1] = vec4[1];
- ((float *)(b+f->ofs))[2] = vec4[2];
- ((float *)(b+f->ofs))[3] = vec4[3];
- break;
- case F_INT:
- *(int *)(b+f->ofs) = atoi(value);
- break;
- case F_FLOAT:
- *(float *)(b+f->ofs) = atof(value);
- break;
- case F_ANGLEHACK:
- v = atof(value);
- ((float *)(b+f->ofs))[0] = 0;
- ((float *)(b+f->ofs))[1] = v;
- ((float *)(b+f->ofs))[2] = 0;
- break;
- default:
- case F_IGNORE:
- break;
+ switch( f->type )
+ {
+ case F_LSTRING:
+ *(char **)( b + f->ofs ) = G_NewString( value );
+ break;
+
+ case F_VECTOR:
+ sscanf( value, "%f %f %f", &vec[ 0 ], &vec[ 1 ], &vec[ 2 ] );
+ ( (float *)( b + f->ofs ) )[ 0 ] = vec[ 0 ];
+ ( (float *)( b + f->ofs ) )[ 1 ] = vec[ 1 ];
+ ( (float *)( b + f->ofs ) )[ 2 ] = vec[ 2 ];
+ break;
+
+ case F_VECTOR4:
+ sscanf( value, "%f %f %f %f", &vec4[ 0 ], &vec4[ 1 ], &vec4[ 2 ], &vec4[ 3 ] );
+ ( (float *)( b + f->ofs ) )[ 0 ] = vec4[ 0 ];
+ ( (float *)( b + f->ofs ) )[ 1 ] = vec4[ 1 ];
+ ( (float *)( b + f->ofs ) )[ 2 ] = vec4[ 2 ];
+ ( (float *)( b + f->ofs ) )[ 3 ] = vec4[ 3 ];
+ break;
+
+ case F_INT:
+ *(int *)( b + f->ofs ) = atoi( value );
+ break;
+
+ case F_FLOAT:
+ *(float *)( b + f->ofs ) = atof( value );
+ break;
+
+ case F_ANGLEHACK:
+ v = atof( value );
+ ( (float *)( b + f->ofs ) )[ 0 ] = 0;
+ ( (float *)( b + f->ofs ) )[ 1 ] = v;
+ ( (float *)( b + f->ofs ) )[ 2 ] = 0;
+ break;
+
+ default:
+ case F_IGNORE:
+ break;
}
+
return;
}
}
@@ -420,22 +446,25 @@ Spawn an entity and fill in all of the level fields from
level.spawnVars[], then call the class specfic spawn function
===================
*/
-void G_SpawnGEntityFromSpawnVars( void ) {
- int i;
- gentity_t *ent;
- char *s, *value, *gametypeName;
- static char *gametypeNames[] = {"ffa", "tournament", "single", "team", "ctf", "oneflag", "obelisk", "harvester", "teamtournament"};
+void G_SpawnGEntityFromSpawnVars( void )
+{
+ int i;
+ gentity_t *ent;
+ char *s, *value, *gametypeName;
+ static char *gametypeNames[ ] = { "ffa", "tournament", "single",
+ "team", "ctf", "oneflag",
+ "obelisk", "harvester", "teamtournament" };
-
// get the next free entity
- ent = G_Spawn();
+ ent = G_Spawn( );
- for ( i = 0 ; i < level.numSpawnVars ; i++ ) {
- G_ParseField( level.spawnVars[i][0], level.spawnVars[i][1], ent );
- }
+ for( i = 0 ; i < level.numSpawnVars ; i++ )
+ G_ParseField( level.spawnVars[ i ][ 0 ], level.spawnVars[ i ][ 1 ], ent );
G_SpawnInt( "notq3a", "0", &i );
- if ( i ) {
+
+ if( i )
+ {
G_FreeEntity( ent );
return;
}
@@ -445,9 +474,8 @@ void G_SpawnGEntityFromSpawnVars( void ) {
VectorCopy( ent->s.origin, ent->r.currentOrigin );
// if we didn't get a classname, don't bother spawning anything
- if ( !G_CallSpawn( ent ) ) {
+ if ( !G_CallSpawn( ent ) )
G_FreeEntity( ent );
- }
}
@@ -457,18 +485,17 @@ void G_SpawnGEntityFromSpawnVars( void ) {
G_AddSpawnVarToken
====================
*/
-char *G_AddSpawnVarToken( const char *string ) {
+char *G_AddSpawnVarToken( const char *string )
+{
int l;
char *dest;
l = strlen( string );
- if ( level.numSpawnVarChars + l + 1 > MAX_SPAWN_VARS_CHARS ) {
+ if( level.numSpawnVarChars + l + 1 > MAX_SPAWN_VARS_CHARS )
G_Error( "G_AddSpawnVarToken: MAX_SPAWN_CHARS" );
-
- }
dest = level.spawnVarChars + level.numSpawnVarChars;
- memcpy( dest, string, l+1 );
+ memcpy( dest, string, l + 1 );
level.numSpawnVarChars += l + 1;
@@ -485,46 +512,46 @@ level's entity strings into level.spawnVars[]
This does not actually spawn an entity.
====================
*/
-qboolean G_ParseSpawnVars( void ) {
- char keyname[MAX_TOKEN_CHARS];
- char com_token[MAX_TOKEN_CHARS];
+qboolean G_ParseSpawnVars( void )
+{
+ char keyname[ MAX_TOKEN_CHARS ];
+ char com_token[ MAX_TOKEN_CHARS ];
level.numSpawnVars = 0;
level.numSpawnVarChars = 0;
// parse the opening brace
- if ( !trap_GetEntityToken( com_token, sizeof( com_token ) ) ) {
+ if( !trap_GetEntityToken( com_token, sizeof( com_token ) ) )
+ {
// end of spawn string
return qfalse;
}
- if ( com_token[0] != '{' ) {
- G_Error( "G_ParseSpawnVars: found %s when expecting {",com_token );
- }
+
+ if( com_token[ 0 ] != '{' )
+ G_Error( "G_ParseSpawnVars: found %s when expecting {", com_token );
// go through all the key / value pairs
- while ( 1 ) {
+ while( 1 )
+ {
// parse key
- if ( !trap_GetEntityToken( keyname, sizeof( keyname ) ) ) {
+ if( !trap_GetEntityToken( keyname, sizeof( keyname ) ) )
G_Error( "G_ParseSpawnVars: EOF without closing brace" );
- }
- if ( keyname[0] == '}' ) {
+ if( keyname[0] == '}' )
break;
- }
// parse value
- if ( !trap_GetEntityToken( com_token, sizeof( com_token ) ) ) {
+ if( !trap_GetEntityToken( com_token, sizeof( com_token ) ) )
G_Error( "G_ParseSpawnVars: EOF without closing brace" );
- }
- if ( com_token[0] == '}' ) {
+ if( com_token[0] == '}' )
G_Error( "G_ParseSpawnVars: closing brace without data" );
- }
- if ( level.numSpawnVars == MAX_SPAWN_VARS ) {
+
+ if( level.numSpawnVars == MAX_SPAWN_VARS )
G_Error( "G_ParseSpawnVars: MAX_SPAWN_VARS" );
- }
- level.spawnVars[ level.numSpawnVars ][0] = G_AddSpawnVarToken( keyname );
- level.spawnVars[ level.numSpawnVars ][1] = G_AddSpawnVarToken( com_token );
+
+ level.spawnVars[ level.numSpawnVars ][ 0 ] = G_AddSpawnVarToken( keyname );
+ level.spawnVars[ level.numSpawnVars ][ 1 ] = G_AddSpawnVarToken( com_token );
level.numSpawnVars++;
}
@@ -540,18 +567,19 @@ Every map should have exactly one worldspawn.
"gravity" 800 is default gravity
"message" Text to print during connection process
*/
-void SP_worldspawn( void ) {
- char *s;
+void SP_worldspawn( void )
+{
+ char *s;
G_SpawnString( "classname", "", &s );
- if ( Q_stricmp( s, "worldspawn" ) ) {
+
+ if( Q_stricmp( s, "worldspawn" ) )
G_Error( "SP_worldspawn: The first entity isn't 'worldspawn'" );
- }
// make some data visible to connecting client
trap_SetConfigstring( CS_GAME_VERSION, GAME_VERSION );
- trap_SetConfigstring( CS_LEVEL_START_TIME, va("%i", level.startTime ) );
+ trap_SetConfigstring( CS_LEVEL_START_TIME, va( "%i", level.startTime ) );
G_SpawnString( "music", "", &s );
trap_SetConfigstring( CS_MUSIC, s );
@@ -594,17 +622,21 @@ void SP_worldspawn( void ) {
G_SpawnString( "enableBreath", "0", &s );
trap_Cvar_Set( "g_enableBreath", s );
- g_entities[ENTITYNUM_WORLD].s.number = ENTITYNUM_WORLD;
- g_entities[ENTITYNUM_WORLD].classname = "worldspawn";
+ g_entities[ ENTITYNUM_WORLD ].s.number = ENTITYNUM_WORLD;
+ g_entities[ ENTITYNUM_WORLD ].classname = "worldspawn";
// see if we want a warmup time
trap_SetConfigstring( CS_WARMUP, "" );
- if ( g_restarted.integer ) {
+ if( g_restarted.integer )
+ {
trap_Cvar_Set( "g_restarted", "0" );
level.warmupTime = 0;
- } else if ( g_doWarmup.integer ) { // Turn it on
+ }
+ else if( g_doWarmup.integer )
+ {
+ // Turn it on
level.warmupTime = -1;
- trap_SetConfigstring( CS_WARMUP, va("%i", level.warmupTime) );
+ trap_SetConfigstring( CS_WARMUP, va( "%i", level.warmupTime ) );
G_LogPrintf( "Warmup:\n" );
}
@@ -618,7 +650,8 @@ G_SpawnEntitiesFromString
Parses textual entity definitions out of an entstring and spawns gentities.
==============
*/
-void G_SpawnEntitiesFromString( void ) {
+void G_SpawnEntitiesFromString( void )
+{
// allow calls to G_Spawn*()
level.spawning = qtrue;
level.numSpawnVars = 0;
@@ -626,15 +659,14 @@ void G_SpawnEntitiesFromString( void ) {
// the worldspawn is not an actual entity, but it still
// has a "spawn" function to perform any global setup
// needed by a level (setting configstrings or cvars, etc)
- if ( !G_ParseSpawnVars() ) {
+ if( !G_ParseSpawnVars( ) )
G_Error( "SpawnEntities: no entities" );
- }
- SP_worldspawn();
+
+ SP_worldspawn( );
// parse ents
- while( G_ParseSpawnVars() ) {
- G_SpawnGEntityFromSpawnVars();
- }
+ while( G_ParseSpawnVars( ) )
+ G_SpawnGEntityFromSpawnVars( );
level.spawning = qfalse; // any future calls to G_Spawn*() will be errors
}
diff --git a/src/game/g_svcmds.c b/src/game/g_svcmds.c
index 3fb05cf8..7386d90b 100644
--- a/src/game/g_svcmds.c
+++ b/src/game/g_svcmds.c
@@ -59,47 +59,48 @@ typedef struct ipFilter_s
#define MAX_IPFILTERS 1024
-static ipFilter_t ipFilters[MAX_IPFILTERS];
-static int numIPFilters;
+static ipFilter_t ipFilters[ MAX_IPFILTERS ];
+static int numIPFilters;
/*
=================
StringToFilter
=================
*/
-static qboolean StringToFilter (char *s, ipFilter_t *f)
+static qboolean StringToFilter( char *s, ipFilter_t *f )
{
- char num[128];
+ char num[ 128 ];
int i, j;
- byte b[4];
- byte m[4];
+ byte b[ 4 ];
+ byte m[ 4 ];
- for (i=0 ; i<4 ; i++)
+ for( i = 0; i < 4; i++ )
{
- b[i] = 0;
- m[i] = 0;
+ b[ i ] = 0;
+ m[ i ] = 0;
}
- for (i=0 ; i<4 ; i++)
+ for( i = 0; i < 4; i++ )
{
- if (*s < '0' || *s > '9')
+ if( *s < '0' || *s > '9' )
{
G_Printf( "Bad filter address: %s\n", s );
return qfalse;
}
j = 0;
- while (*s >= '0' && *s <= '9')
- {
- num[j++] = *s++;
- }
- num[j] = 0;
- b[i] = atoi(num);
- if (b[i] != 0)
- m[i] = 255;
-
- if (!*s)
+ while( *s >= '0' && *s <= '9' )
+ num[ j++ ] = *s++;
+
+ num[ j ] = 0;
+ b[ i ] = atoi( num );
+
+ if( b[ i ] != 0 )
+ m[ i ] = 255;
+
+ if( !*s )
break;
+
s++;
}
@@ -114,21 +115,22 @@ static qboolean StringToFilter (char *s, ipFilter_t *f)
UpdateIPBans
=================
*/
-static void UpdateIPBans (void)
+static void UpdateIPBans( void )
{
- byte b[4];
+ byte b[ 4 ];
int i;
- char iplist[MAX_INFO_STRING];
+ char iplist[ MAX_INFO_STRING ];
*iplist = 0;
- for (i = 0 ; i < numIPFilters ; i++)
+
+ for( i = 0 ; i < numIPFilters ; i++ )
{
- if (ipFilters[i].compare == 0xffffffff)
+ if( ipFilters[ i ].compare == 0xffffffff )
continue;
- *(unsigned *)b = ipFilters[i].compare;
- Com_sprintf( iplist + strlen(iplist), sizeof(iplist) - strlen(iplist),
- "%i.%i.%i.%i ", b[0], b[1], b[2], b[3]);
+ *(unsigned *)b = ipFilters[ i ].compare;
+ Com_sprintf( iplist + strlen( iplist ), sizeof( iplist ) - strlen( iplist ),
+ "%i.%i.%i.%i ", b[ 0 ], b[ 1 ], b[ 2 ], b[ 3 ] );
}
trap_Cvar_Set( "g_banIPs", iplist );
@@ -139,30 +141,34 @@ static void UpdateIPBans (void)
G_FilterPacket
=================
*/
-qboolean G_FilterPacket (char *from)
+qboolean G_FilterPacket( char *from )
{
- int i;
+ int i;
unsigned in;
- byte m[4];
- char *p;
+ byte m[ 4 ];
+ char *p;
i = 0;
p = from;
- while (*p && i < 4) {
- m[i] = 0;
- while (*p >= '0' && *p <= '9') {
- m[i] = m[i]*10 + (*p - '0');
+ while( *p && i < 4 )
+ {
+ m[ i ] = 0;
+ while( *p >= '0' && *p <= '9' )
+ {
+ m[ i ] = m[ i ] * 10 + ( *p - '0' );
p++;
}
- if (!*p || *p == ':')
+
+ if( !*p || *p == ':' )
break;
+
i++, p++;
}
in = *(unsigned *)m;
- for (i=0 ; i<numIPFilters ; i++)
- if ( (in & ipFilters[i].mask) == ipFilters[i].compare)
+ for( i = 0; i < numIPFilters; i++ )
+ if( ( in & ipFilters[ i ].mask ) == ipFilters[ i ].compare )
return g_filterBan.integer != 0;
return g_filterBan.integer == 0;
@@ -177,23 +183,25 @@ static void AddIP( char *str )
{
int i;
- for (i = 0 ; i < numIPFilters ; i++)
- if (ipFilters[i].compare == 0xffffffff)
+ for( i = 0 ; i < numIPFilters ; i++ )
+ if( ipFilters[ i ].compare == 0xffffffff )
break; // free spot
- if (i == numIPFilters)
+
+ if( i == numIPFilters )
{
- if (numIPFilters == MAX_IPFILTERS)
+ if( numIPFilters == MAX_IPFILTERS )
{
- G_Printf ("IP filter list is full\n");
+ G_Printf( "IP filter list is full\n" );
return;
}
+
numIPFilters++;
}
- if (!StringToFilter (str, &ipFilters[i]))
- ipFilters[i].compare = 0xffffffffu;
+ if( !StringToFilter( str, &ipFilters[ i ] ) )
+ ipFilters[ i ].compare = 0xffffffffu;
- UpdateIPBans();
+ UpdateIPBans( );
}
/*
@@ -201,21 +209,26 @@ static void AddIP( char *str )
G_ProcessIPBans
=================
*/
-void G_ProcessIPBans(void)
+void G_ProcessIPBans( void )
{
char *s, *t;
- char str[MAX_TOKEN_CHARS];
+ char str[ MAX_TOKEN_CHARS ];
- Q_strncpyz( str, g_banIPs.string, sizeof(str) );
+ Q_strncpyz( str, g_banIPs.string, sizeof( str ) );
- for (t = s = g_banIPs.string; *t; /* */ ) {
- s = strchr(s, ' ');
- if (!s)
+ for( t = s = g_banIPs.string; *t; /* */ )
+ {
+ s = strchr( s, ' ' );
+
+ if( !s )
break;
- while (*s == ' ')
+
+ while( *s == ' ' )
*s++ = 0;
- if (*t)
+
+ if( *t )
AddIP( t );
+
t = s;
}
}
@@ -226,19 +239,19 @@ void G_ProcessIPBans(void)
Svcmd_AddIP_f
=================
*/
-void Svcmd_AddIP_f (void)
+void Svcmd_AddIP_f( void )
{
- char str[MAX_TOKEN_CHARS];
+ char str[ MAX_TOKEN_CHARS ];
- if ( trap_Argc() < 2 ) {
- G_Printf("Usage: addip <ip-mask>\n");
+ if( trap_Argc( ) < 2 )
+ {
+ G_Printf( "Usage: addip <ip-mask>\n" );
return;
}
trap_Argv( 1, str, sizeof( str ) );
AddIP( str );
-
}
/*
@@ -246,29 +259,32 @@ void Svcmd_AddIP_f (void)
Svcmd_RemoveIP_f
=================
*/
-void Svcmd_RemoveIP_f (void)
+void Svcmd_RemoveIP_f( void )
{
ipFilter_t f;
- int i;
- char str[MAX_TOKEN_CHARS];
+ int i;
+ char str[ MAX_TOKEN_CHARS ];
- if ( trap_Argc() < 2 ) {
- G_Printf("Usage: sv removeip <ip-mask>\n");
+ if( trap_Argc( ) < 2 )
+ {
+ G_Printf( "Usage: sv removeip <ip-mask>\n" );
return;
}
trap_Argv( 1, str, sizeof( str ) );
- if (!StringToFilter (str, &f))
+ if( !StringToFilter( str, &f ) )
return;
- for (i=0 ; i<numIPFilters ; i++) {
- if (ipFilters[i].mask == f.mask &&
- ipFilters[i].compare == f.compare) {
- ipFilters[i].compare = 0xffffffffu;
- G_Printf ("Removed.\n");
+ for( i = 0; i < numIPFilters; i++ )
+ {
+ if( ipFilters[ i ].mask == f.mask &&
+ ipFilters[ i ].compare == f.compare)
+ {
+ ipFilters[ i ].compare = 0xffffffffu;
+ G_Printf ( "Removed.\n" );
- UpdateIPBans();
+ UpdateIPBans( );
return;
}
}
@@ -281,98 +297,110 @@ void Svcmd_RemoveIP_f (void)
Svcmd_EntityList_f
===================
*/
-void Svcmd_EntityList_f (void) {
- int e;
- gentity_t *check;
+void Svcmd_EntityList_f( void )
+{
+ int e;
+ gentity_t *check;
- check = g_entities+1;
- for (e = 1; e < level.num_entities ; e++, check++) {
- if ( !check->inuse ) {
+ check = g_entities + 1;
+
+ for( e = 1; e < level.num_entities; e++, check++ )
+ {
+ if( !check->inuse )
continue;
- }
- G_Printf("%3i:", e);
- switch ( check->s.eType ) {
- case ET_GENERAL:
- G_Printf("ET_GENERAL ");
- break;
- case ET_PLAYER:
- G_Printf("ET_PLAYER ");
- break;
- case ET_ITEM:
- G_Printf("ET_ITEM ");
- break;
- case ET_BUILDABLE:
- G_Printf("ET_BUILDABLE ");
- break;
- case ET_MISSILE:
- G_Printf("ET_MISSILE ");
- break;
- case ET_MOVER:
- G_Printf("ET_MOVER ");
- break;
- case ET_BEAM:
- G_Printf("ET_BEAM ");
- break;
- case ET_PORTAL:
- G_Printf("ET_PORTAL ");
- break;
- case ET_SPEAKER:
- G_Printf("ET_SPEAKER ");
- break;
- case ET_PUSH_TRIGGER:
- G_Printf("ET_PUSH_TRIGGER ");
- break;
- case ET_TELEPORT_TRIGGER:
- G_Printf("ET_TELEPORT_TRIGGER ");
- break;
- case ET_INVISIBLE:
- G_Printf("ET_INVISIBLE ");
- break;
- case ET_GRAPPLE:
- G_Printf("ET_GRAPPLE ");
- break;
- default:
- G_Printf("%3i ", check->s.eType);
- break;
- }
- if ( check->classname ) {
- G_Printf("%s", check->classname);
+ G_Printf( "%3i:", e );
+
+ switch( check->s.eType )
+ {
+ case ET_GENERAL:
+ G_Printf( "ET_GENERAL " );
+ break;
+ case ET_PLAYER:
+ G_Printf( "ET_PLAYER " );
+ break;
+ case ET_ITEM:
+ G_Printf( "ET_ITEM " );
+ break;
+ case ET_BUILDABLE:
+ G_Printf( "ET_BUILDABLE " );
+ break;
+ case ET_MISSILE:
+ G_Printf( "ET_MISSILE " );
+ break;
+ case ET_MOVER:
+ G_Printf( "ET_MOVER " );
+ break;
+ case ET_BEAM:
+ G_Printf( "ET_BEAM " );
+ break;
+ case ET_PORTAL:
+ G_Printf( "ET_PORTAL " );
+ break;
+ case ET_SPEAKER:
+ G_Printf( "ET_SPEAKER " );
+ break;
+ case ET_PUSH_TRIGGER:
+ G_Printf( "ET_PUSH_TRIGGER " );
+ break;
+ case ET_TELEPORT_TRIGGER:
+ G_Printf( "ET_TELEPORT_TRIGGER " );
+ break;
+ case ET_INVISIBLE:
+ G_Printf( "ET_INVISIBLE " );
+ break;
+ case ET_GRAPPLE:
+ G_Printf( "ET_GRAPPLE " );
+ break;
+ default:
+ G_Printf( "%3i ", check->s.eType );
+ break;
}
- G_Printf("\n");
+
+ if( check->classname )
+ G_Printf( "%s", check->classname );
+
+ G_Printf( "\n" );
}
}
-gclient_t *ClientForString( const char *s ) {
+gclient_t *ClientForString( const char *s )
+{
gclient_t *cl;
- int i;
- int idnum;
+ int i;
+ int idnum;
// numeric values are just slot numbers
- if ( s[0] >= '0' && s[0] <= '9' ) {
+ if( s[ 0 ] >= '0' && s[ 0 ] <= '9' )
+ {
idnum = atoi( s );
- if ( idnum < 0 || idnum >= level.maxclients ) {
+
+ if( idnum < 0 || idnum >= level.maxclients )
+ {
Com_Printf( "Bad client slot: %i\n", idnum );
return NULL;
}
- cl = &level.clients[idnum];
- if ( cl->pers.connected == CON_DISCONNECTED ) {
+ cl = &level.clients[ idnum ];
+
+ if( cl->pers.connected == CON_DISCONNECTED )
+ {
G_Printf( "Client %i is not connected\n", idnum );
return NULL;
}
+
return cl;
}
// check for a name match
- for ( i=0 ; i < level.maxclients ; i++ ) {
- cl = &level.clients[i];
- if ( cl->pers.connected == CON_DISCONNECTED ) {
+ for( i = 0; i < level.maxclients; i++ )
+ {
+ cl = &level.clients[ i ];
+ if( cl->pers.connected == CON_DISCONNECTED )
continue;
- }
- if ( !Q_stricmp( cl->pers.netname, s ) ) {
+
+ if( !Q_stricmp( cl->pers.netname, s ) )
return cl;
- }
}
G_Printf( "User %s is not on the server\n", s );
@@ -387,20 +415,22 @@ Svcmd_ForceTeam_f
forceteam <player> <team>
===================
*/
-void Svcmd_ForceTeam_f( void ) {
+void Svcmd_ForceTeam_f( void )
+{
gclient_t *cl;
- char str[MAX_TOKEN_CHARS];
+ char str[ MAX_TOKEN_CHARS ];
// find the player
trap_Argv( 1, str, sizeof( str ) );
cl = ClientForString( str );
- if ( !cl ) {
+
+ if( !cl )
return;
- }
// set the team
trap_Argv( 2, str, sizeof( str ) );
/*SetTeam( &g_entities[cl - level.clients], str );*/
+ //FIXME: tremulise this
}
char *ConcatArgs( int start );
@@ -411,48 +441,58 @@ ConsoleCommand
=================
*/
-qboolean ConsoleCommand( void ) {
- char cmd[MAX_TOKEN_CHARS];
+qboolean ConsoleCommand( void )
+{
+ char cmd[ MAX_TOKEN_CHARS ];
trap_Argv( 0, cmd, sizeof( cmd ) );
- if ( Q_stricmp (cmd, "entitylist") == 0 ) {
- Svcmd_EntityList_f();
+ if( Q_stricmp( cmd, "entitylist" ) == 0 )
+ {
+ Svcmd_EntityList_f( );
return qtrue;
}
- if ( Q_stricmp (cmd, "forceteam") == 0 ) {
- Svcmd_ForceTeam_f();
+ if( Q_stricmp( cmd, "forceteam" ) == 0 )
+ {
+ Svcmd_ForceTeam_f( );
return qtrue;
}
- if (Q_stricmp (cmd, "game_memory") == 0) {
- Svcmd_GameMem_f();
+ if( Q_stricmp( cmd, "game_memory" ) == 0 )
+ {
+ Svcmd_GameMem_f( );
return qtrue;
}
- if (Q_stricmp (cmd, "addip") == 0) {
- Svcmd_AddIP_f();
+ if( Q_stricmp( cmd, "addip" ) == 0 )
+ {
+ Svcmd_AddIP_f( );
return qtrue;
}
- if (Q_stricmp (cmd, "removeip") == 0) {
- Svcmd_RemoveIP_f();
+ if( Q_stricmp( cmd, "removeip" ) == 0 )
+ {
+ Svcmd_RemoveIP_f( );
return qtrue;
}
- if (Q_stricmp (cmd, "listip") == 0) {
+ if( Q_stricmp( cmd, "listip" ) == 0 )
+ {
trap_SendConsoleCommand( EXEC_NOW, "g_banIPs\n" );
return qtrue;
}
- if (g_dedicated.integer) {
- if (Q_stricmp (cmd, "say") == 0) {
- trap_SendServerCommand( -1, va("print \"server: %s\"", ConcatArgs(1) ) );
+ if( g_dedicated.integer )
+ {
+ if( Q_stricmp( cmd, "say" ) == 0 )
+ {
+ trap_SendServerCommand( -1, va( "print \"server: %s\"", ConcatArgs( 1 ) ) );
return qtrue;
}
+
// everything else will also be printed as a say command
- trap_SendServerCommand( -1, va("print \"server: %s\"", ConcatArgs(0) ) );
+ trap_SendServerCommand( -1, va( "print \"server: %s\"", ConcatArgs( 0 ) ) );
return qtrue;
}
diff --git a/src/game/g_syscalls.asm b/src/game/g_syscalls.asm
index e997e293..4fe395d4 100644
--- a/src/game/g_syscalls.asm
+++ b/src/game/g_syscalls.asm
@@ -1,224 +1,60 @@
code
-equ trap_Printf -1
-equ trap_Error -2
-equ trap_Milliseconds -3
-equ trap_Cvar_Register -4
-equ trap_Cvar_Update -5
-equ trap_Cvar_Set -6
+equ trap_Printf -1
+equ trap_Error -2
+equ trap_Milliseconds -3
+equ trap_Cvar_Register -4
+equ trap_Cvar_Update -5
+equ trap_Cvar_Set -6
equ trap_Cvar_VariableIntegerValue -7
equ trap_Cvar_VariableStringBuffer -8
-equ trap_Argc -9
-equ trap_Argv -10
-equ trap_FS_FOpenFile -11
-equ trap_FS_Read -12
-equ trap_FS_Write -13
-equ trap_FS_FCloseFile -14
-equ trap_SendConsoleCommand -15
-equ trap_LocateGameData -16
-equ trap_DropClient -17
-equ trap_SendServerCommand -18
-equ trap_SetConfigstring -19
-equ trap_GetConfigstring -20
-equ trap_GetUserinfo -21
-equ trap_SetUserinfo -22
-equ trap_GetServerinfo -23
-equ trap_SetBrushModel -24
-equ trap_Trace -25
-equ trap_PointContents -26
-equ trap_InPVS -27
-equ trap_InPVSIgnorePortals -28
-equ trap_AdjustAreaPortalState -29
-equ trap_AreasConnected -30
-equ trap_LinkEntity -31
-equ trap_UnlinkEntity -32
-equ trap_EntitiesInBox -33
-equ trap_EntityContact -34
-equ trap_BotAllocateClient -35
-equ trap_BotFreeClient -36
-equ trap_GetUsercmd -37
-equ trap_GetEntityToken -38
-equ trap_FS_GetFileList -39
-equ trap_DebugPolygonCreate -40
-equ trap_DebugPolygonDelete -41
-equ trap_RealTime -42
-equ trap_SnapVector -43
-equ trap_TraceCapsule -44
-equ trap_EntityContactCapsule -45
-
-
-equ memset -101
-equ memcpy -102
-equ strncpy -103
-equ sin -104
-equ cos -105
-equ atan2 -106
-equ sqrt -107
-equ floor -111
-equ ceil -112
-equ testPrintInt -113
-equ testPrintFloat -114
-
-
-equ trap_BotLibSetup -201
-equ trap_BotLibShutdown -202
-equ trap_BotLibVarSet -203
-equ trap_BotLibVarGet -204
-equ trap_BotLibDefine -205
-equ trap_BotLibStartFrame -206
-equ trap_BotLibLoadMap -207
-equ trap_BotLibUpdateEntity -208
-equ trap_BotLibTest -209
-
-equ trap_BotGetSnapshotEntity -210
-equ trap_BotGetServerCommand -211
-equ trap_BotUserCommand -212
-
-
-
-equ trap_AAS_EnableRoutingArea -301
-equ trap_AAS_BBoxAreas -302
-equ trap_AAS_AreaInfo -303
-equ trap_AAS_EntityInfo -304
-
-equ trap_AAS_Initialized -305
-equ trap_AAS_PresenceTypeBoundingBox -306
-equ trap_AAS_Time -307
-
-equ trap_AAS_PointAreaNum -308
-equ trap_AAS_TraceAreas -309
-
-equ trap_AAS_PointContents -310
-equ trap_AAS_NextBSPEntity -311
-equ trap_AAS_ValueForBSPEpairKey -312
-equ trap_AAS_VectorForBSPEpairKey -313
-equ trap_AAS_FloatForBSPEpairKey -314
-equ trap_AAS_IntForBSPEpairKey -315
-
-equ trap_AAS_AreaReachability -316
-
-equ trap_AAS_AreaTravelTimeToGoalArea -317
-
-equ trap_AAS_Swimming -318
-equ trap_AAS_PredictClientMovement -319
-
-
-
-equ trap_EA_Say -401
-equ trap_EA_SayTeam -402
-equ trap_EA_Command -403
-
-equ trap_EA_Action -404
-equ trap_EA_Gesture -405
-equ trap_EA_Talk -406
-equ trap_EA_Attack -407
-equ trap_EA_Use -408
-equ trap_EA_Respawn -409
-equ trap_EA_Crouch -410
-equ trap_EA_MoveUp -411
-equ trap_EA_MoveDown -412
-equ trap_EA_MoveForward -413
-equ trap_EA_MoveBack -414
-equ trap_EA_MoveLeft -415
-equ trap_EA_MoveRight -416
-
-equ trap_EA_SelectWeapon -417
-equ trap_EA_Jump -418
-equ trap_EA_DelayedJump -419
-equ trap_EA_Move -420
-equ trap_EA_View -421
-
-equ trap_EA_EndRegular -422
-equ trap_EA_GetInput -423
-equ trap_EA_ResetInput -424
-
-
-
-equ trap_BotLoadCharacter -501
-equ trap_BotFreeCharacter -502
-equ trap_Characteristic_Float -503
-equ trap_Characteristic_BFloat -504
-equ trap_Characteristic_Integer -505
-equ trap_Characteristic_BInteger -506
-equ trap_Characteristic_String -507
-
-equ trap_BotAllocChatState -508
-equ trap_BotFreeChatState -509
-equ trap_BotQueueConsoleMessage -510
-equ trap_BotRemoveConsoleMessage -511
-equ trap_BotNextConsoleMessage -512
-equ trap_BotNumConsoleMessages -513
-equ trap_BotInitialChat -514
-equ trap_BotReplyChat -515
-equ trap_BotChatLength -516
-equ trap_BotEnterChat -517
-equ trap_StringContains -518
-equ trap_BotFindMatch -519
-equ trap_BotMatchVariable -520
-equ trap_UnifyWhiteSpaces -521
-equ trap_BotReplaceSynonyms -522
-equ trap_BotLoadChatFile -523
-equ trap_BotSetChatGender -524
-equ trap_BotSetChatName -525
-
-equ trap_BotResetGoalState -526
-equ trap_BotResetAvoidGoals -527
-equ trap_BotPushGoal -528
-equ trap_BotPopGoal -529
-equ trap_BotEmptyGoalStack -530
-equ trap_BotDumpAvoidGoals -531
-equ trap_BotDumpGoalStack -532
-equ trap_BotGoalName -533
-equ trap_BotGetTopGoal -534
-equ trap_BotGetSecondGoal -535
-equ trap_BotChooseLTGItem -536
-equ trap_BotChooseNBGItem -537
-equ trap_BotTouchingGoal -538
-equ trap_BotItemGoalInVisButNotVisible -539
-equ trap_BotGetLevelItemGoal -540
-equ trap_BotAvoidGoalTime -541
-equ trap_BotInitLevelItems -542
-equ trap_BotUpdateEntityItems -543
-equ trap_BotLoadItemWeights -544
-equ trap_BotFreeItemWeights -546
-equ trap_BotSaveGoalFuzzyLogic -546
-equ trap_BotAllocGoalState -547
-equ trap_BotFreeGoalState -548
-
-equ trap_BotResetMoveState -549
-equ trap_BotMoveToGoal -550
-equ trap_BotMoveInDirection -551
-equ trap_BotResetAvoidReach -552
-equ trap_BotResetLastAvoidReach -553
-equ trap_BotReachabilityArea -554
-equ trap_BotMovementViewTarget -555
-equ trap_BotAllocMoveState -556
-equ trap_BotFreeMoveState -557
-equ trap_BotInitMoveState -558
-
-equ trap_BotChooseBestFightWeapon -559
-equ trap_BotGetWeaponInfo -560
-equ trap_BotLoadWeaponWeights -561
-equ trap_BotAllocWeaponState -562
-equ trap_BotFreeWeaponState -563
-equ trap_BotResetWeaponState -564
-equ trap_GeneticParentsAndChildSelection -565
-equ trap_BotInterbreedGoalFuzzyLogic -566
-equ trap_BotMutateGoalFuzzyLogic -567
-equ trap_BotGetNextCampSpotGoal -568
-equ trap_BotGetMapLocationGoal -569
-equ trap_BotNumInitialChats -570
-equ trap_BotGetChatMessage -571
-equ trap_BotRemoveFromAvoidGoals -572
-equ trap_BotPredictVisiblePosition -573
-equ trap_BotSetAvoidGoalTime -574
-equ trap_BotAddAvoidSpot -575
-equ trap_AAS_AlternativeRouteGoals -576
-equ trap_AAS_PredictRoute -577
-equ trap_AAS_PointReachabilityAreaIndex -578
-
-equ trap_BotLibLoadSource -579
-equ trap_BotLibFreeSource -580
-equ trap_BotLibReadToken -581
-equ trap_BotLibSourceFileAndLine -582
-
+equ trap_Argc -9
+equ trap_Argv -10
+equ trap_FS_FOpenFile -11
+equ trap_FS_Read -12
+equ trap_FS_Write -13
+equ trap_FS_FCloseFile -14
+equ trap_SendConsoleCommand -15
+equ trap_LocateGameData -16
+equ trap_DropClient -17
+equ trap_SendServerCommand -18
+equ trap_SetConfigstring -19
+equ trap_GetConfigstring -20
+equ trap_GetUserinfo -21
+equ trap_SetUserinfo -22
+equ trap_GetServerinfo -23
+equ trap_SetBrushModel -24
+equ trap_Trace -25
+equ trap_PointContents -26
+equ trap_InPVS -27
+equ trap_InPVSIgnorePortals -28
+equ trap_AdjustAreaPortalState -29
+equ trap_AreasConnected -30
+equ trap_LinkEntity -31
+equ trap_UnlinkEntity -32
+equ trap_EntitiesInBox -33
+equ trap_EntityContact -34
+equ trap_BotAllocateClient -35
+equ trap_BotFreeClient -36
+equ trap_GetUsercmd -37
+equ trap_GetEntityToken -38
+equ trap_FS_GetFileList -39
+equ trap_DebugPolygonCreate -40
+equ trap_DebugPolygonDelete -41
+equ trap_RealTime -42
+equ trap_SnapVector -43
+equ trap_TraceCapsule -44
+equ trap_EntityContactCapsule -45
+
+
+equ memset -101
+equ memcpy -102
+equ strncpy -103
+equ sin -104
+equ cos -105
+equ atan2 -106
+equ sqrt -107
+equ floor -111
+equ ceil -112
+equ testPrintInt -113
+equ testPrintFloat -114
diff --git a/src/game/g_syscalls.c b/src/game/g_syscalls.c
index 8bbe8ab6..6a3f70c4 100644
--- a/src/game/g_syscalls.c
+++ b/src/game/g_syscalls.c
@@ -22,756 +22,243 @@
static int (QDECL *syscall)( int arg, ... ) = (int (QDECL *)( int, ...))-1;
-void dllEntry( int (QDECL *syscallptr)( int arg,... ) ) {
- syscall = syscallptr;
+void dllEntry( int (QDECL *syscallptr)( int arg,... ) )
+{
+ syscall = syscallptr;
}
-int PASSFLOAT( float x ) {
- float floatTemp;
- floatTemp = x;
- return *(int *)&floatTemp;
+int PASSFLOAT( float x )
+{
+ float floatTemp;
+ floatTemp = x;
+ return *(int *)&floatTemp;
}
-void trap_Printf( const char *fmt ) {
- syscall( G_PRINT, fmt );
+void trap_Printf( const char *fmt )
+{
+ syscall( G_PRINT, fmt );
}
-void trap_Error( const char *fmt ) {
- syscall( G_ERROR, fmt );
+void trap_Error( const char *fmt )
+{
+ syscall( G_ERROR, fmt );
}
-int trap_Milliseconds( void ) {
- return syscall( G_MILLISECONDS );
+int trap_Milliseconds( void )
+{
+ return syscall( G_MILLISECONDS );
}
-int trap_Argc( void ) {
- return syscall( G_ARGC );
+int trap_Argc( void )
+{
+ return syscall( G_ARGC );
}
-void trap_Argv( int n, char *buffer, int bufferLength ) {
- syscall( G_ARGV, n, buffer, bufferLength );
+void trap_Argv( int n, char *buffer, int bufferLength )
+{
+ syscall( G_ARGV, n, buffer, bufferLength );
}
-int trap_FS_FOpenFile( const char *qpath, fileHandle_t *f, fsMode_t mode ) {
- return syscall( G_FS_FOPEN_FILE, qpath, f, mode );
+int trap_FS_FOpenFile( const char *qpath, fileHandle_t *f, fsMode_t mode )
+{
+ return syscall( G_FS_FOPEN_FILE, qpath, f, mode );
}
-void trap_FS_Read( void *buffer, int len, fileHandle_t f ) {
- syscall( G_FS_READ, buffer, len, f );
+void trap_FS_Read( void *buffer, int len, fileHandle_t f )
+{
+ syscall( G_FS_READ, buffer, len, f );
}
-void trap_FS_Write( const void *buffer, int len, fileHandle_t f ) {
- syscall( G_FS_WRITE, buffer, len, f );
+void trap_FS_Write( const void *buffer, int len, fileHandle_t f )
+{
+ syscall( G_FS_WRITE, buffer, len, f );
}
-void trap_FS_FCloseFile( fileHandle_t f ) {
- syscall( G_FS_FCLOSE_FILE, f );
+void trap_FS_FCloseFile( fileHandle_t f )
+{
+ syscall( G_FS_FCLOSE_FILE, f );
}
-int trap_FS_GetFileList( const char *path, const char *extension, char *listbuf, int bufsize ) {
- return syscall( G_FS_GETFILELIST, path, extension, listbuf, bufsize );
+int trap_FS_GetFileList( const char *path, const char *extension, char *listbuf, int bufsize )
+{
+ return syscall( G_FS_GETFILELIST, path, extension, listbuf, bufsize );
}
-void trap_SendConsoleCommand( int exec_when, const char *text ) {
- syscall( G_SEND_CONSOLE_COMMAND, exec_when, text );
+void trap_SendConsoleCommand( int exec_when, const char *text )
+{
+ syscall( G_SEND_CONSOLE_COMMAND, exec_when, text );
}
-void trap_Cvar_Register( vmCvar_t *cvar, const char *var_name, const char *value, int flags ) {
- syscall( G_CVAR_REGISTER, cvar, var_name, value, flags );
+void trap_Cvar_Register( vmCvar_t *cvar, const char *var_name, const char *value, int flags )
+{
+ syscall( G_CVAR_REGISTER, cvar, var_name, value, flags );
}
-void trap_Cvar_Update( vmCvar_t *cvar ) {
- syscall( G_CVAR_UPDATE, cvar );
+void trap_Cvar_Update( vmCvar_t *cvar )
+{
+ syscall( G_CVAR_UPDATE, cvar );
}
-void trap_Cvar_Set( const char *var_name, const char *value ) {
- syscall( G_CVAR_SET, var_name, value );
+void trap_Cvar_Set( const char *var_name, const char *value )
+{
+ syscall( G_CVAR_SET, var_name, value );
}
-int trap_Cvar_VariableIntegerValue( const char *var_name ) {
- return syscall( G_CVAR_VARIABLE_INTEGER_VALUE, var_name );
+int trap_Cvar_VariableIntegerValue( const char *var_name )
+{
+ return syscall( G_CVAR_VARIABLE_INTEGER_VALUE, var_name );
}
-void trap_Cvar_VariableStringBuffer( const char *var_name, char *buffer, int bufsize ) {
- syscall( G_CVAR_VARIABLE_STRING_BUFFER, var_name, buffer, bufsize );
+void trap_Cvar_VariableStringBuffer( const char *var_name, char *buffer, int bufsize )
+{
+ syscall( G_CVAR_VARIABLE_STRING_BUFFER, var_name, buffer, bufsize );
}
void trap_LocateGameData( gentity_t *gEnts, int numGEntities, int sizeofGEntity_t,
- playerState_t *clients, int sizeofGClient ) {
- syscall( G_LOCATE_GAME_DATA, gEnts, numGEntities, sizeofGEntity_t, clients, sizeofGClient );
+ playerState_t *clients, int sizeofGClient )
+{
+ syscall( G_LOCATE_GAME_DATA, gEnts, numGEntities, sizeofGEntity_t, clients, sizeofGClient );
}
-void trap_DropClient( int clientNum, const char *reason ) {
- syscall( G_DROP_CLIENT, clientNum, reason );
+void trap_DropClient( int clientNum, const char *reason )
+{
+ syscall( G_DROP_CLIENT, clientNum, reason );
}
-void trap_SendServerCommand( int clientNum, const char *text ) {
- syscall( G_SEND_SERVER_COMMAND, clientNum, text );
+void trap_SendServerCommand( int clientNum, const char *text )
+{
+ syscall( G_SEND_SERVER_COMMAND, clientNum, text );
}
-void trap_SetConfigstring( int num, const char *string ) {
- syscall( G_SET_CONFIGSTRING, num, string );
+void trap_SetConfigstring( int num, const char *string )
+{
+ syscall( G_SET_CONFIGSTRING, num, string );
}
-void trap_GetConfigstring( int num, char *buffer, int bufferSize ) {
- syscall( G_GET_CONFIGSTRING, num, buffer, bufferSize );
+void trap_GetConfigstring( int num, char *buffer, int bufferSize )
+{
+ syscall( G_GET_CONFIGSTRING, num, buffer, bufferSize );
}
-void trap_GetUserinfo( int num, char *buffer, int bufferSize ) {
- syscall( G_GET_USERINFO, num, buffer, bufferSize );
+void trap_GetUserinfo( int num, char *buffer, int bufferSize )
+{
+ syscall( G_GET_USERINFO, num, buffer, bufferSize );
}
-void trap_SetUserinfo( int num, const char *buffer ) {
- syscall( G_SET_USERINFO, num, buffer );
+void trap_SetUserinfo( int num, const char *buffer )
+{
+ syscall( G_SET_USERINFO, num, buffer );
}
-void trap_GetServerinfo( char *buffer, int bufferSize ) {
- syscall( G_GET_SERVERINFO, buffer, bufferSize );
+void trap_GetServerinfo( char *buffer, int bufferSize )
+{
+ syscall( G_GET_SERVERINFO, buffer, bufferSize );
}
-void trap_SetBrushModel( gentity_t *ent, const char *name ) {
- syscall( G_SET_BRUSH_MODEL, ent, name );
+void trap_SetBrushModel( gentity_t *ent, const char *name )
+{
+ syscall( G_SET_BRUSH_MODEL, ent, name );
}
-void trap_Trace( trace_t *results, const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end, int passEntityNum, int contentmask ) {
- syscall( G_TRACE, results, start, mins, maxs, end, passEntityNum, contentmask );
+void trap_Trace( trace_t *results, const vec3_t start, const vec3_t mins,
+ const vec3_t maxs, const vec3_t end, int passEntityNum, int contentmask )
+{
+ syscall( G_TRACE, results, start, mins, maxs, end, passEntityNum, contentmask );
}
-void trap_TraceCapsule( trace_t *results, const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end, int passEntityNum, int contentmask ) {
+void trap_TraceCapsule( trace_t *results, const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end, int passEntityNum, int contentmask )
+{
syscall( G_TRACECAPSULE, results, start, mins, maxs, end, passEntityNum, contentmask );
}
-int trap_PointContents( const vec3_t point, int passEntityNum ) {
- return syscall( G_POINT_CONTENTS, point, passEntityNum );
+int trap_PointContents( const vec3_t point, int passEntityNum )
+{
+ return syscall( G_POINT_CONTENTS, point, passEntityNum );
}
-qboolean trap_InPVS( const vec3_t p1, const vec3_t p2 ) {
- return syscall( G_IN_PVS, p1, p2 );
+qboolean trap_InPVS( const vec3_t p1, const vec3_t p2 )
+{
+ return syscall( G_IN_PVS, p1, p2 );
}
-qboolean trap_InPVSIgnorePortals( const vec3_t p1, const vec3_t p2 ) {
- return syscall( G_IN_PVS_IGNORE_PORTALS, p1, p2 );
+qboolean trap_InPVSIgnorePortals( const vec3_t p1, const vec3_t p2 )
+{
+ return syscall( G_IN_PVS_IGNORE_PORTALS, p1, p2 );
}
-void trap_AdjustAreaPortalState( gentity_t *ent, qboolean open ) {
- syscall( G_ADJUST_AREA_PORTAL_STATE, ent, open );
+void trap_AdjustAreaPortalState( gentity_t *ent, qboolean open )
+{
+ syscall( G_ADJUST_AREA_PORTAL_STATE, ent, open );
}
-qboolean trap_AreasConnected( int area1, int area2 ) {
- return syscall( G_AREAS_CONNECTED, area1, area2 );
+qboolean trap_AreasConnected( int area1, int area2 )
+{
+ return syscall( G_AREAS_CONNECTED, area1, area2 );
}
-void trap_LinkEntity( gentity_t *ent ) {
- syscall( G_LINKENTITY, ent );
+void trap_LinkEntity( gentity_t *ent )
+{
+ syscall( G_LINKENTITY, ent );
}
-void trap_UnlinkEntity( gentity_t *ent ) {
- syscall( G_UNLINKENTITY, ent );
+void trap_UnlinkEntity( gentity_t *ent )
+{
+ syscall( G_UNLINKENTITY, ent );
}
-int trap_EntitiesInBox( const vec3_t mins, const vec3_t maxs, int *list, int maxcount ) {
- return syscall( G_ENTITIES_IN_BOX, mins, maxs, list, maxcount );
+int trap_EntitiesInBox( const vec3_t mins, const vec3_t maxs, int *list, int maxcount )
+{
+ return syscall( G_ENTITIES_IN_BOX, mins, maxs, list, maxcount );
}
-qboolean trap_EntityContact( const vec3_t mins, const vec3_t maxs, const gentity_t *ent ) {
- return syscall( G_ENTITY_CONTACT, mins, maxs, ent );
+qboolean trap_EntityContact( const vec3_t mins, const vec3_t maxs, const gentity_t *ent )
+{
+ return syscall( G_ENTITY_CONTACT, mins, maxs, ent );
}
-qboolean trap_EntityContactCapsule( const vec3_t mins, const vec3_t maxs, const gentity_t *ent ) {
+qboolean trap_EntityContactCapsule( const vec3_t mins, const vec3_t maxs, const gentity_t *ent )
+{
return syscall( G_ENTITY_CONTACTCAPSULE, mins, maxs, ent );
}
-int trap_BotAllocateClient( void ) {
- return syscall( G_BOT_ALLOCATE_CLIENT );
+int trap_BotAllocateClient( void )
+{
+ return syscall( G_BOT_ALLOCATE_CLIENT );
}
-void trap_BotFreeClient( int clientNum ) {
- syscall( G_BOT_FREE_CLIENT, clientNum );
+void trap_BotFreeClient( int clientNum )
+{
+ syscall( G_BOT_FREE_CLIENT, clientNum );
}
-void trap_GetUsercmd( int clientNum, usercmd_t *cmd ) {
- syscall( G_GET_USERCMD, clientNum, cmd );
+void trap_GetUsercmd( int clientNum, usercmd_t *cmd )
+{
+ syscall( G_GET_USERCMD, clientNum, cmd );
}
-qboolean trap_GetEntityToken( char *buffer, int bufferSize ) {
- return syscall( G_GET_ENTITY_TOKEN, buffer, bufferSize );
+qboolean trap_GetEntityToken( char *buffer, int bufferSize )
+{
+ return syscall( G_GET_ENTITY_TOKEN, buffer, bufferSize );
}
-int trap_DebugPolygonCreate(int color, int numPoints, vec3_t *points) {
- return syscall( G_DEBUG_POLYGON_CREATE, color, numPoints, points );
+int trap_DebugPolygonCreate(int color, int numPoints, vec3_t *points)
+{
+ return syscall( G_DEBUG_POLYGON_CREATE, color, numPoints, points );
}
-void trap_DebugPolygonDelete(int id) {
- syscall( G_DEBUG_POLYGON_DELETE, id );
+void trap_DebugPolygonDelete(int id)
+{
+ syscall( G_DEBUG_POLYGON_DELETE, id );
}
-int trap_RealTime( qtime_t *qtime ) {
+int trap_RealTime( qtime_t *qtime )
+{
return syscall( G_REAL_TIME, qtime );
}
-void trap_SnapVector( float *v ) {
+void trap_SnapVector( float *v )
+{
syscall( G_SNAPVECTOR, v );
return;
}
-
-// BotLib traps start here
-int trap_BotLibSetup( void ) {
- return syscall( BOTLIB_SETUP );
-}
-
-int trap_BotLibShutdown( void ) {
- return syscall( BOTLIB_SHUTDOWN );
-}
-
-int trap_BotLibVarSet(char *var_name, char *value) {
- return syscall( BOTLIB_LIBVAR_SET, var_name, value );
-}
-
-int trap_BotLibVarGet(char *var_name, char *value, int size) {
- return syscall( BOTLIB_LIBVAR_GET, var_name, value, size );
-}
-
-int trap_BotLibDefine(char *string) {
- return syscall( BOTLIB_PC_ADD_GLOBAL_DEFINE, string );
-}
-
-int trap_BotLibStartFrame(float time) {
- return syscall( BOTLIB_START_FRAME, PASSFLOAT( time ) );
-}
-
-int trap_BotLibLoadMap(const char *mapname) {
- return syscall( BOTLIB_LOAD_MAP, mapname );
-}
-
-int trap_BotLibUpdateEntity(int ent, void /* struct bot_updateentity_s */ *bue) {
- return syscall( BOTLIB_UPDATENTITY, ent, bue );
-}
-
-int trap_BotLibTest(int parm0, char *parm1, vec3_t parm2, vec3_t parm3) {
- return syscall( BOTLIB_TEST, parm0, parm1, parm2, parm3 );
-}
-
-int trap_BotGetSnapshotEntity( int clientNum, int sequence ) {
- return syscall( BOTLIB_GET_SNAPSHOT_ENTITY, clientNum, sequence );
-}
-
-int trap_BotGetServerCommand(int clientNum, char *message, int size) {
- return syscall( BOTLIB_GET_CONSOLE_MESSAGE, clientNum, message, size );
-}
-
-void trap_BotUserCommand(int clientNum, usercmd_t *ucmd) {
- syscall( BOTLIB_USER_COMMAND, clientNum, ucmd );
-}
-
-void trap_AAS_EntityInfo(int entnum, void /* struct aas_entityinfo_s */ *info) {
- syscall( BOTLIB_AAS_ENTITY_INFO, entnum, info );
-}
-
-int trap_AAS_Initialized(void) {
- return syscall( BOTLIB_AAS_INITIALIZED );
-}
-
-void trap_AAS_PresenceTypeBoundingBox(int presencetype, vec3_t mins, vec3_t maxs) {
- syscall( BOTLIB_AAS_PRESENCE_TYPE_BOUNDING_BOX, presencetype, mins, maxs );
-}
-
-float trap_AAS_Time(void) {
- int temp;
- temp = syscall( BOTLIB_AAS_TIME );
- return (*(float*)&temp);
-}
-
-int trap_AAS_PointAreaNum(vec3_t point) {
- return syscall( BOTLIB_AAS_POINT_AREA_NUM, point );
-}
-
-int trap_AAS_PointReachabilityAreaIndex(vec3_t point) {
- return syscall( BOTLIB_AAS_POINT_REACHABILITY_AREA_INDEX, point );
-}
-
-int trap_AAS_TraceAreas(vec3_t start, vec3_t end, int *areas, vec3_t *points, int maxareas) {
- return syscall( BOTLIB_AAS_TRACE_AREAS, start, end, areas, points, maxareas );
-}
-
-int trap_AAS_BBoxAreas(vec3_t absmins, vec3_t absmaxs, int *areas, int maxareas) {
- return syscall( BOTLIB_AAS_BBOX_AREAS, absmins, absmaxs, areas, maxareas );
-}
-
-int trap_AAS_AreaInfo( int areanum, void /* struct aas_areainfo_s */ *info ) {
- return syscall( BOTLIB_AAS_AREA_INFO, areanum, info );
-}
-
-int trap_AAS_PointContents(vec3_t point) {
- return syscall( BOTLIB_AAS_POINT_CONTENTS, point );
-}
-
-int trap_AAS_NextBSPEntity(int ent) {
- return syscall( BOTLIB_AAS_NEXT_BSP_ENTITY, ent );
-}
-
-int trap_AAS_ValueForBSPEpairKey(int ent, char *key, char *value, int size) {
- return syscall( BOTLIB_AAS_VALUE_FOR_BSP_EPAIR_KEY, ent, key, value, size );
-}
-
-int trap_AAS_VectorForBSPEpairKey(int ent, char *key, vec3_t v) {
- return syscall( BOTLIB_AAS_VECTOR_FOR_BSP_EPAIR_KEY, ent, key, v );
-}
-
-int trap_AAS_FloatForBSPEpairKey(int ent, char *key, float *value) {
- return syscall( BOTLIB_AAS_FLOAT_FOR_BSP_EPAIR_KEY, ent, key, value );
-}
-
-int trap_AAS_IntForBSPEpairKey(int ent, char *key, int *value) {
- return syscall( BOTLIB_AAS_INT_FOR_BSP_EPAIR_KEY, ent, key, value );
-}
-
-int trap_AAS_AreaReachability(int areanum) {
- return syscall( BOTLIB_AAS_AREA_REACHABILITY, areanum );
-}
-
-int trap_AAS_AreaTravelTimeToGoalArea(int areanum, vec3_t origin, int goalareanum, int travelflags) {
- return syscall( BOTLIB_AAS_AREA_TRAVEL_TIME_TO_GOAL_AREA, areanum, origin, goalareanum, travelflags );
-}
-
-int trap_AAS_EnableRoutingArea( int areanum, int enable ) {
- return syscall( BOTLIB_AAS_ENABLE_ROUTING_AREA, areanum, enable );
-}
-
-int trap_AAS_PredictRoute(void /*struct aas_predictroute_s*/ *route, int areanum, vec3_t origin,
- int goalareanum, int travelflags, int maxareas, int maxtime,
- int stopevent, int stopcontents, int stoptfl, int stopareanum) {
- return syscall( BOTLIB_AAS_PREDICT_ROUTE, route, areanum, origin, goalareanum, travelflags, maxareas, maxtime, stopevent, stopcontents, stoptfl, stopareanum );
-}
-
-int trap_AAS_AlternativeRouteGoals(vec3_t start, int startareanum, vec3_t goal, int goalareanum, int travelflags,
- void /*struct aas_altroutegoal_s*/ *altroutegoals, int maxaltroutegoals,
- int type) {
- return syscall( BOTLIB_AAS_ALTERNATIVE_ROUTE_GOAL, start, startareanum, goal, goalareanum, travelflags, altroutegoals, maxaltroutegoals, type );
-}
-
-int trap_AAS_Swimming(vec3_t origin) {
- return syscall( BOTLIB_AAS_SWIMMING, origin );
-}
-
-int trap_AAS_PredictClientMovement(void /* struct aas_clientmove_s */ *move, int entnum, vec3_t origin, int presencetype, int onground, vec3_t velocity, vec3_t cmdmove, int cmdframes, int maxframes, float frametime, int stopevent, int stopareanum, int visualize) {
- return syscall( BOTLIB_AAS_PREDICT_CLIENT_MOVEMENT, move, entnum, origin, presencetype, onground, velocity, cmdmove, cmdframes, maxframes, PASSFLOAT(frametime), stopevent, stopareanum, visualize );
-}
-
-void trap_EA_Say(int client, char *str) {
- syscall( BOTLIB_EA_SAY, client, str );
-}
-
-void trap_EA_SayTeam(int client, char *str) {
- syscall( BOTLIB_EA_SAY_TEAM, client, str );
-}
-
-void trap_EA_Command(int client, char *command) {
- syscall( BOTLIB_EA_COMMAND, client, command );
-}
-
-void trap_EA_Action(int client, int action) {
- syscall( BOTLIB_EA_ACTION, client, action );
-}
-
-void trap_EA_Gesture(int client) {
- syscall( BOTLIB_EA_GESTURE, client );
-}
-
-void trap_EA_Talk(int client) {
- syscall( BOTLIB_EA_TALK, client );
-}
-
-void trap_EA_Attack(int client) {
- syscall( BOTLIB_EA_ATTACK, client );
-}
-
-void trap_EA_Use(int client) {
- syscall( BOTLIB_EA_USE, client );
-}
-
-void trap_EA_Respawn(int client) {
- syscall( BOTLIB_EA_RESPAWN, client );
-}
-
-void trap_EA_Crouch(int client) {
- syscall( BOTLIB_EA_CROUCH, client );
-}
-
-void trap_EA_MoveUp(int client) {
- syscall( BOTLIB_EA_MOVE_UP, client );
-}
-
-void trap_EA_MoveDown(int client) {
- syscall( BOTLIB_EA_MOVE_DOWN, client );
-}
-
-void trap_EA_MoveForward(int client) {
- syscall( BOTLIB_EA_MOVE_FORWARD, client );
-}
-
-void trap_EA_MoveBack(int client) {
- syscall( BOTLIB_EA_MOVE_BACK, client );
-}
-
-void trap_EA_MoveLeft(int client) {
- syscall( BOTLIB_EA_MOVE_LEFT, client );
-}
-
-void trap_EA_MoveRight(int client) {
- syscall( BOTLIB_EA_MOVE_RIGHT, client );
-}
-
-void trap_EA_SelectWeapon(int client, int weapon) {
- syscall( BOTLIB_EA_SELECT_WEAPON, client, weapon );
-}
-
-void trap_EA_Jump(int client) {
- syscall( BOTLIB_EA_JUMP, client );
-}
-
-void trap_EA_DelayedJump(int client) {
- syscall( BOTLIB_EA_DELAYED_JUMP, client );
-}
-
-void trap_EA_Move(int client, vec3_t dir, float speed) {
- syscall( BOTLIB_EA_MOVE, client, dir, PASSFLOAT(speed) );
-}
-
-void trap_EA_View(int client, vec3_t viewangles) {
- syscall( BOTLIB_EA_VIEW, client, viewangles );
-}
-
-void trap_EA_EndRegular(int client, float thinktime) {
- syscall( BOTLIB_EA_END_REGULAR, client, PASSFLOAT(thinktime) );
-}
-
-void trap_EA_GetInput(int client, float thinktime, void /* struct bot_input_s */ *input) {
- syscall( BOTLIB_EA_GET_INPUT, client, PASSFLOAT(thinktime), input );
-}
-
-void trap_EA_ResetInput(int client) {
- syscall( BOTLIB_EA_RESET_INPUT, client );
-}
-
-int trap_BotLoadCharacter(char *charfile, float skill) {
- return syscall( BOTLIB_AI_LOAD_CHARACTER, charfile, PASSFLOAT(skill));
-}
-
-void trap_BotFreeCharacter(int character) {
- syscall( BOTLIB_AI_FREE_CHARACTER, character );
-}
-
-float trap_Characteristic_Float(int character, int index) {
- int temp;
- temp = syscall( BOTLIB_AI_CHARACTERISTIC_FLOAT, character, index );
- return (*(float*)&temp);
-}
-
-float trap_Characteristic_BFloat(int character, int index, float min, float max) {
- int temp;
- temp = syscall( BOTLIB_AI_CHARACTERISTIC_BFLOAT, character, index, PASSFLOAT(min), PASSFLOAT(max) );
- return (*(float*)&temp);
-}
-
-int trap_Characteristic_Integer(int character, int index) {
- return syscall( BOTLIB_AI_CHARACTERISTIC_INTEGER, character, index );
-}
-
-int trap_Characteristic_BInteger(int character, int index, int min, int max) {
- return syscall( BOTLIB_AI_CHARACTERISTIC_BINTEGER, character, index, min, max );
-}
-
-void trap_Characteristic_String(int character, int index, char *buf, int size) {
- syscall( BOTLIB_AI_CHARACTERISTIC_STRING, character, index, buf, size );
-}
-
-int trap_BotAllocChatState(void) {
- return syscall( BOTLIB_AI_ALLOC_CHAT_STATE );
-}
-
-void trap_BotFreeChatState(int handle) {
- syscall( BOTLIB_AI_FREE_CHAT_STATE, handle );
-}
-
-void trap_BotQueueConsoleMessage(int chatstate, int type, char *message) {
- syscall( BOTLIB_AI_QUEUE_CONSOLE_MESSAGE, chatstate, type, message );
-}
-
-void trap_BotRemoveConsoleMessage(int chatstate, int handle) {
- syscall( BOTLIB_AI_REMOVE_CONSOLE_MESSAGE, chatstate, handle );
-}
-
-int trap_BotNextConsoleMessage(int chatstate, void /* struct bot_consolemessage_s */ *cm) {
- return syscall( BOTLIB_AI_NEXT_CONSOLE_MESSAGE, chatstate, cm );
-}
-
-int trap_BotNumConsoleMessages(int chatstate) {
- return syscall( BOTLIB_AI_NUM_CONSOLE_MESSAGE, chatstate );
-}
-
-void trap_BotInitialChat(int chatstate, char *type, int mcontext, char *var0, char *var1, char *var2, char *var3, char *var4, char *var5, char *var6, char *var7 ) {
- syscall( BOTLIB_AI_INITIAL_CHAT, chatstate, type, mcontext, var0, var1, var2, var3, var4, var5, var6, var7 );
-}
-
-int trap_BotNumInitialChats(int chatstate, char *type) {
- return syscall( BOTLIB_AI_NUM_INITIAL_CHATS, chatstate, type );
-}
-
-int trap_BotReplyChat(int chatstate, char *message, int mcontext, int vcontext, char *var0, char *var1, char *var2, char *var3, char *var4, char *var5, char *var6, char *var7 ) {
- return syscall( BOTLIB_AI_REPLY_CHAT, chatstate, message, mcontext, vcontext, var0, var1, var2, var3, var4, var5, var6, var7 );
-}
-
-int trap_BotChatLength(int chatstate) {
- return syscall( BOTLIB_AI_CHAT_LENGTH, chatstate );
-}
-
-void trap_BotEnterChat(int chatstate, int client, int sendto) {
- syscall( BOTLIB_AI_ENTER_CHAT, chatstate, client, sendto );
-}
-
-void trap_BotGetChatMessage(int chatstate, char *buf, int size) {
- syscall( BOTLIB_AI_GET_CHAT_MESSAGE, chatstate, buf, size);
-}
-
-int trap_StringContains(char *str1, char *str2, int casesensitive) {
- return syscall( BOTLIB_AI_STRING_CONTAINS, str1, str2, casesensitive );
-}
-
-int trap_BotFindMatch(char *str, void /* struct bot_match_s */ *match, unsigned long int context) {
- return syscall( BOTLIB_AI_FIND_MATCH, str, match, context );
-}
-
-void trap_BotMatchVariable(void /* struct bot_match_s */ *match, int variable, char *buf, int size) {
- syscall( BOTLIB_AI_MATCH_VARIABLE, match, variable, buf, size );
-}
-
-void trap_UnifyWhiteSpaces(char *string) {
- syscall( BOTLIB_AI_UNIFY_WHITE_SPACES, string );
-}
-
-void trap_BotReplaceSynonyms(char *string, unsigned long int context) {
- syscall( BOTLIB_AI_REPLACE_SYNONYMS, string, context );
-}
-
-int trap_BotLoadChatFile(int chatstate, char *chatfile, char *chatname) {
- return syscall( BOTLIB_AI_LOAD_CHAT_FILE, chatstate, chatfile, chatname );
-}
-
-void trap_BotSetChatGender(int chatstate, int gender) {
- syscall( BOTLIB_AI_SET_CHAT_GENDER, chatstate, gender );
-}
-
-void trap_BotSetChatName(int chatstate, char *name, int client) {
- syscall( BOTLIB_AI_SET_CHAT_NAME, chatstate, name, client );
-}
-
-void trap_BotResetGoalState(int goalstate) {
- syscall( BOTLIB_AI_RESET_GOAL_STATE, goalstate );
-}
-
-void trap_BotResetAvoidGoals(int goalstate) {
- syscall( BOTLIB_AI_RESET_AVOID_GOALS, goalstate );
-}
-
-void trap_BotRemoveFromAvoidGoals(int goalstate, int number) {
- syscall( BOTLIB_AI_REMOVE_FROM_AVOID_GOALS, goalstate, number);
-}
-
-void trap_BotPushGoal(int goalstate, void /* struct bot_goal_s */ *goal) {
- syscall( BOTLIB_AI_PUSH_GOAL, goalstate, goal );
-}
-
-void trap_BotPopGoal(int goalstate) {
- syscall( BOTLIB_AI_POP_GOAL, goalstate );
-}
-
-void trap_BotEmptyGoalStack(int goalstate) {
- syscall( BOTLIB_AI_EMPTY_GOAL_STACK, goalstate );
-}
-
-void trap_BotDumpAvoidGoals(int goalstate) {
- syscall( BOTLIB_AI_DUMP_AVOID_GOALS, goalstate );
-}
-
-void trap_BotDumpGoalStack(int goalstate) {
- syscall( BOTLIB_AI_DUMP_GOAL_STACK, goalstate );
-}
-
-void trap_BotGoalName(int number, char *name, int size) {
- syscall( BOTLIB_AI_GOAL_NAME, number, name, size );
-}
-
-int trap_BotGetTopGoal(int goalstate, void /* struct bot_goal_s */ *goal) {
- return syscall( BOTLIB_AI_GET_TOP_GOAL, goalstate, goal );
-}
-
-int trap_BotGetSecondGoal(int goalstate, void /* struct bot_goal_s */ *goal) {
- return syscall( BOTLIB_AI_GET_SECOND_GOAL, goalstate, goal );
-}
-
-int trap_BotChooseLTGItem(int goalstate, vec3_t origin, int *inventory, int travelflags) {
- return syscall( BOTLIB_AI_CHOOSE_LTG_ITEM, goalstate, origin, inventory, travelflags );
-}
-
-int trap_BotChooseNBGItem(int goalstate, vec3_t origin, int *inventory, int travelflags, void /* struct bot_goal_s */ *ltg, float maxtime) {
- return syscall( BOTLIB_AI_CHOOSE_NBG_ITEM, goalstate, origin, inventory, travelflags, ltg, PASSFLOAT(maxtime) );
-}
-
-int trap_BotTouchingGoal(vec3_t origin, void /* struct bot_goal_s */ *goal) {
- return syscall( BOTLIB_AI_TOUCHING_GOAL, origin, goal );
-}
-
-int trap_BotItemGoalInVisButNotVisible(int viewer, vec3_t eye, vec3_t viewangles, void /* struct bot_goal_s */ *goal) {
- return syscall( BOTLIB_AI_ITEM_GOAL_IN_VIS_BUT_NOT_VISIBLE, viewer, eye, viewangles, goal );
-}
-
-int trap_BotGetLevelItemGoal(int index, char *classname, void /* struct bot_goal_s */ *goal) {
- return syscall( BOTLIB_AI_GET_LEVEL_ITEM_GOAL, index, classname, goal );
-}
-
-int trap_BotGetNextCampSpotGoal(int num, void /* struct bot_goal_s */ *goal) {
- return syscall( BOTLIB_AI_GET_NEXT_CAMP_SPOT_GOAL, num, goal );
-}
-
-int trap_BotGetMapLocationGoal(char *name, void /* struct bot_goal_s */ *goal) {
- return syscall( BOTLIB_AI_GET_MAP_LOCATION_GOAL, name, goal );
-}
-
-float trap_BotAvoidGoalTime(int goalstate, int number) {
- int temp;
- temp = syscall( BOTLIB_AI_AVOID_GOAL_TIME, goalstate, number );
- return (*(float*)&temp);
-}
-
-void trap_BotSetAvoidGoalTime(int goalstate, int number, float avoidtime) {
- syscall( BOTLIB_AI_SET_AVOID_GOAL_TIME, goalstate, number, PASSFLOAT(avoidtime));
-}
-
-void trap_BotInitLevelItems(void) {
- syscall( BOTLIB_AI_INIT_LEVEL_ITEMS );
-}
-
-void trap_BotUpdateEntityItems(void) {
- syscall( BOTLIB_AI_UPDATE_ENTITY_ITEMS );
-}
-
-int trap_BotLoadItemWeights(int goalstate, char *filename) {
- return syscall( BOTLIB_AI_LOAD_ITEM_WEIGHTS, goalstate, filename );
-}
-
-void trap_BotFreeItemWeights(int goalstate) {
- syscall( BOTLIB_AI_FREE_ITEM_WEIGHTS, goalstate );
-}
-
-void trap_BotInterbreedGoalFuzzyLogic(int parent1, int parent2, int child) {
- syscall( BOTLIB_AI_INTERBREED_GOAL_FUZZY_LOGIC, parent1, parent2, child );
-}
-
-void trap_BotSaveGoalFuzzyLogic(int goalstate, char *filename) {
- syscall( BOTLIB_AI_SAVE_GOAL_FUZZY_LOGIC, goalstate, filename );
-}
-
-void trap_BotMutateGoalFuzzyLogic(int goalstate, float range) {
- syscall( BOTLIB_AI_MUTATE_GOAL_FUZZY_LOGIC, goalstate, range );
-}
-
-int trap_BotAllocGoalState(int state) {
- return syscall( BOTLIB_AI_ALLOC_GOAL_STATE, state );
-}
-
-void trap_BotFreeGoalState(int handle) {
- syscall( BOTLIB_AI_FREE_GOAL_STATE, handle );
-}
-
-void trap_BotResetMoveState(int movestate) {
- syscall( BOTLIB_AI_RESET_MOVE_STATE, movestate );
-}
-
-void trap_BotAddAvoidSpot(int movestate, vec3_t origin, float radius, int type) {
- syscall( BOTLIB_AI_ADD_AVOID_SPOT, movestate, origin, PASSFLOAT(radius), type);
-}
-
-void trap_BotMoveToGoal(void /* struct bot_moveresult_s */ *result, int movestate, void /* struct bot_goal_s */ *goal, int travelflags) {
- syscall( BOTLIB_AI_MOVE_TO_GOAL, result, movestate, goal, travelflags );
-}
-
-int trap_BotMoveInDirection(int movestate, vec3_t dir, float speed, int type) {
- return syscall( BOTLIB_AI_MOVE_IN_DIRECTION, movestate, dir, PASSFLOAT(speed), type );
-}
-
-void trap_BotResetAvoidReach(int movestate) {
- syscall( BOTLIB_AI_RESET_AVOID_REACH, movestate );
-}
-
-void trap_BotResetLastAvoidReach(int movestate) {
- syscall( BOTLIB_AI_RESET_LAST_AVOID_REACH,movestate );
-}
-
-int trap_BotReachabilityArea(vec3_t origin, int testground) {
- return syscall( BOTLIB_AI_REACHABILITY_AREA, origin, testground );
-}
-
-int trap_BotMovementViewTarget(int movestate, void /* struct bot_goal_s */ *goal, int travelflags, float lookahead, vec3_t target) {
- return syscall( BOTLIB_AI_MOVEMENT_VIEW_TARGET, movestate, goal, travelflags, PASSFLOAT(lookahead), target );
-}
-
-int trap_BotPredictVisiblePosition(vec3_t origin, int areanum, void /* struct bot_goal_s */ *goal, int travelflags, vec3_t target) {
- return syscall( BOTLIB_AI_PREDICT_VISIBLE_POSITION, origin, areanum, goal, travelflags, target );
-}
-
-int trap_BotAllocMoveState(void) {
- return syscall( BOTLIB_AI_ALLOC_MOVE_STATE );
-}
-
-void trap_BotFreeMoveState(int handle) {
- syscall( BOTLIB_AI_FREE_MOVE_STATE, handle );
-}
-
-void trap_BotInitMoveState(int handle, void /* struct bot_initmove_s */ *initmove) {
- syscall( BOTLIB_AI_INIT_MOVE_STATE, handle, initmove );
-}
-
-int trap_BotChooseBestFightWeapon(int weaponstate, int *inventory) {
- return syscall( BOTLIB_AI_CHOOSE_BEST_FIGHT_WEAPON, weaponstate, inventory );
-}
-
-void trap_BotGetWeaponInfo(int weaponstate, int weapon, void /* struct weaponinfo_s */ *weaponinfo) {
- syscall( BOTLIB_AI_GET_WEAPON_INFO, weaponstate, weapon, weaponinfo );
-}
-
-int trap_BotLoadWeaponWeights(int weaponstate, char *filename) {
- return syscall( BOTLIB_AI_LOAD_WEAPON_WEIGHTS, weaponstate, filename );
-}
-
-int trap_BotAllocWeaponState(void) {
- return syscall( BOTLIB_AI_ALLOC_WEAPON_STATE );
-}
-
-void trap_BotFreeWeaponState(int weaponstate) {
- syscall( BOTLIB_AI_FREE_WEAPON_STATE, weaponstate );
-}
-
-void trap_BotResetWeaponState(int weaponstate) {
- syscall( BOTLIB_AI_RESET_WEAPON_STATE, weaponstate );
-}
-
-int trap_GeneticParentsAndChildSelection(int numranks, float *ranks, int *parent1, int *parent2, int *child) {
- return syscall( BOTLIB_AI_GENETIC_PARENTS_AND_CHILD_SELECTION, numranks, ranks, parent1, parent2, child );
-}
-
-int trap_PC_LoadSource( const char *filename ) {
- return syscall( BOTLIB_PC_LOAD_SOURCE, filename );
-}
-
-int trap_PC_FreeSource( int handle ) {
- return syscall( BOTLIB_PC_FREE_SOURCE, handle );
-}
-
-int trap_PC_ReadToken( int handle, pc_token_t *pc_token ) {
- return syscall( BOTLIB_PC_READ_TOKEN, handle, pc_token );
-}
-
-int trap_PC_SourceFileAndLine( int handle, char *filename, int *line ) {
- return syscall( BOTLIB_PC_SOURCE_FILE_AND_LINE, handle, filename, line );
-}
diff --git a/src/game/g_target.c b/src/game/g_target.c
index 2f938a65..249d120a 100644
--- a/src/game/g_target.c
+++ b/src/game/g_target.c
@@ -58,15 +58,16 @@ void SP_target_give( gentity_t *ent )
takes away all the activators powerups.
Used to drop flight powerups into death puts.
*/
-void Use_target_remove_powerups( gentity_t *ent, gentity_t *other, gentity_t *activator ) {
- if( !activator->client ) {
+void Use_target_remove_powerups( gentity_t *ent, gentity_t *other, gentity_t *activator )
+{
+ if( !activator->client )
return;
- }
memset( activator->client->ps.powerups, 0, sizeof( activator->client->ps.powerups ) );
}
-void SP_target_remove_powerups( gentity_t *ent ) {
+void SP_target_remove_powerups( gentity_t *ent )
+{
ent->use = Use_target_remove_powerups;
}
@@ -77,25 +78,27 @@ void SP_target_remove_powerups( gentity_t *ent ) {
"wait" seconds to pause before firing targets.
"random" delay variance, total delay = delay +/- random seconds
*/
-void Think_Target_Delay( gentity_t *ent ) {
+void Think_Target_Delay( gentity_t *ent )
+{
G_UseTargets( ent, ent->activator );
}
-void Use_Target_Delay( gentity_t *ent, gentity_t *other, gentity_t *activator ) {
- ent->nextthink = level.time + ( ent->wait + ent->random * crandom() ) * 1000;
+void Use_Target_Delay( gentity_t *ent, gentity_t *other, gentity_t *activator )
+{
+ ent->nextthink = level.time + ( ent->wait + ent->random * crandom( ) ) * 1000;
ent->think = Think_Target_Delay;
ent->activator = activator;
}
-void SP_target_delay( gentity_t *ent ) {
+void SP_target_delay( gentity_t *ent )
+{
// check delay for backwards compatability
- if ( !G_SpawnFloat( "delay", "0", &ent->wait ) ) {
+ if( !G_SpawnFloat( "delay", "0", &ent->wait ) )
G_SpawnFloat( "wait", "1", &ent->wait );
- }
- if ( !ent->wait ) {
+ if( !ent->wait )
ent->wait = 1;
- }
+
ent->use = Use_Target_Delay;
}
@@ -107,14 +110,16 @@ void SP_target_delay( gentity_t *ent ) {
The activator is given this many points.
*/
-void Use_Target_Score (gentity_t *ent, gentity_t *other, gentity_t *activator) {
+void Use_Target_Score( gentity_t *ent, gentity_t *other, gentity_t *activator )
+{
AddScore( activator, ent->count );
}
-void SP_target_score( gentity_t *ent ) {
- if ( !ent->count ) {
+void SP_target_score( gentity_t *ent )
+{
+ if( !ent->count )
ent->count = 1;
- }
+
ent->use = Use_Target_Score;
}
@@ -125,7 +130,7 @@ void SP_target_score( gentity_t *ent ) {
"message" text to print
If "private", only the activator gets the message. If no checks, all clients get the message.
*/
-void Use_Target_Print (gentity_t *ent, gentity_t *other, gentity_t *activator)
+void Use_Target_Print( gentity_t *ent, gentity_t *other, gentity_t *activator )
{
if( activator->client && ( ent->spawnflags & 4 ) )
{
@@ -146,7 +151,8 @@ void Use_Target_Print (gentity_t *ent, gentity_t *other, gentity_t *activator)
trap_SendServerCommand( -1, va("cp \"%s\"", ent->message ) );
}
-void SP_target_print( gentity_t *ent ) {
+void SP_target_print( gentity_t *ent )
+{
ent->use = Use_Target_Print;
}
@@ -166,46 +172,49 @@ Multiple identical looping sounds will just increase volume without any speed co
"wait" : Seconds between auto triggerings, 0 = don't auto trigger
"random" wait variance, default is 0
*/
-void Use_Target_Speaker (gentity_t *ent, gentity_t *other, gentity_t *activator) {
- if (ent->spawnflags & 3) { // looping sound toggles
- if (ent->s.loopSound)
+void Use_Target_Speaker( gentity_t *ent, gentity_t *other, gentity_t *activator )
+{
+ if( ent->spawnflags & 3 )
+ { // looping sound toggles
+ if( ent->s.loopSound )
ent->s.loopSound = 0; // turn it off
else
ent->s.loopSound = ent->noise_index; // start it
- }else { // normal sound
- if ( ent->spawnflags & 8 ) {
+ }
+ else
+ {
+ // normal sound
+ if( ent->spawnflags & 8 )
G_AddEvent( activator, EV_GENERAL_SOUND, ent->noise_index );
- } else if (ent->spawnflags & 4) {
+ else if( ent->spawnflags & 4 )
G_AddEvent( ent, EV_GLOBAL_SOUND, ent->noise_index );
- } else {
+ else
G_AddEvent( ent, EV_GENERAL_SOUND, ent->noise_index );
- }
}
}
-void SP_target_speaker( gentity_t *ent ) {
- char buffer[MAX_QPATH];
+void SP_target_speaker( gentity_t *ent )
+{
+ char buffer[ MAX_QPATH ];
char *s;
G_SpawnFloat( "wait", "0", &ent->wait );
G_SpawnFloat( "random", "0", &ent->random );
- if ( !G_SpawnString( "noise", "NOSOUND", &s ) ) {
+ if( !G_SpawnString( "noise", "NOSOUND", &s ) )
G_Error( "target_speaker without a noise key at %s", vtos( ent->s.origin ) );
- }
// force all client reletive sounds to be "activator" speakers that
// play on the entity that activates it
- if ( s[0] == '*' ) {
+ if( s[ 0 ] == '*' )
ent->spawnflags |= 8;
- }
- if (!strstr( s, ".wav" )) {
- Com_sprintf (buffer, sizeof(buffer), "%s.wav", s );
- } else {
- Q_strncpyz( buffer, s, sizeof(buffer) );
- }
- ent->noise_index = G_SoundIndex(buffer);
+ if( !strstr( s, ".wav" ) )
+ Com_sprintf( buffer, sizeof( buffer ), "%s.wav", s );
+ else
+ Q_strncpyz( buffer, s, sizeof( buffer ) );
+
+ ent->noise_index = G_SoundIndex( buffer );
// a repeating speaker can be done completely client side
ent->s.eType = ET_SPEAKER;
@@ -215,15 +224,13 @@ void SP_target_speaker( gentity_t *ent ) {
// check for prestarted looping sound
- if ( ent->spawnflags & 1 ) {
+ if( ent->spawnflags & 1 )
ent->s.loopSound = ent->noise_index;
- }
ent->use = Use_Target_Speaker;
- if (ent->spawnflags & 4) {
+ if( ent->spawnflags & 4 )
ent->r.svFlags |= SVF_BROADCAST;
- }
VectorCopy( ent->s.origin, ent->s.pos.trBase );
@@ -239,88 +246,94 @@ void SP_target_speaker( gentity_t *ent ) {
/*QUAKED target_laser (0 .5 .8) (-8 -8 -8) (8 8 8) START_ON
When triggered, fires a laser. You can either set a target or a direction.
*/
-void target_laser_think (gentity_t *self) {
+void target_laser_think( gentity_t *self )
+{
vec3_t end;
trace_t tr;
vec3_t point;
// if pointed at another entity, set movedir to point at it
- if ( self->enemy ) {
- VectorMA (self->enemy->s.origin, 0.5, self->enemy->r.mins, point);
- VectorMA (point, 0.5, self->enemy->r.maxs, point);
- VectorSubtract (point, self->s.origin, self->movedir);
- VectorNormalize (self->movedir);
+ if( self->enemy )
+ {
+ VectorMA( self->enemy->s.origin, 0.5, self->enemy->r.mins, point );
+ VectorMA( point, 0.5, self->enemy->r.maxs, point );
+ VectorSubtract( point, self->s.origin, self->movedir );
+ VectorNormalize( self->movedir );
}
// fire forward and see what we hit
- VectorMA (self->s.origin, 2048, self->movedir, end);
+ VectorMA( self->s.origin, 2048, self->movedir, end );
- trap_Trace( &tr, self->s.origin, NULL, NULL, end, self->s.number, CONTENTS_SOLID|CONTENTS_BODY|CONTENTS_CORPSE);
+ trap_Trace( &tr, self->s.origin, NULL, NULL, end, self->s.number,
+ CONTENTS_SOLID | CONTENTS_BODY | CONTENTS_CORPSE );
- if ( tr.entityNum ) {
+ if( tr.entityNum )
+ {
// hurt it if we can
- G_Damage ( &g_entities[tr.entityNum], self, self->activator, self->movedir,
- tr.endpos, self->damage, DAMAGE_NO_KNOCKBACK, MOD_TARGET_LASER);
+ G_Damage( &g_entities[ tr.entityNum ], self, self->activator, self->movedir,
+ tr.endpos, self->damage, DAMAGE_NO_KNOCKBACK, MOD_TARGET_LASER );
}
- VectorCopy (tr.endpos, self->s.origin2);
+ VectorCopy( tr.endpos, self->s.origin2 );
trap_LinkEntity( self );
self->nextthink = level.time + FRAMETIME;
}
-void target_laser_on (gentity_t *self)
+void target_laser_on( gentity_t *self )
{
- if (!self->activator)
+ if( !self->activator )
self->activator = self;
- target_laser_think (self);
+
+ target_laser_think( self );
}
-void target_laser_off (gentity_t *self)
+void target_laser_off( gentity_t *self )
{
trap_UnlinkEntity( self );
self->nextthink = 0;
}
-void target_laser_use (gentity_t *self, gentity_t *other, gentity_t *activator)
+void target_laser_use( gentity_t *self, gentity_t *other, gentity_t *activator )
{
self->activator = activator;
- if ( self->nextthink > 0 )
- target_laser_off (self);
+ if( self->nextthink > 0 )
+ target_laser_off( self );
else
- target_laser_on (self);
+ target_laser_on( self );
}
-void target_laser_start (gentity_t *self)
+void target_laser_start( gentity_t *self )
{
gentity_t *ent;
self->s.eType = ET_BEAM;
- if (self->target) {
- ent = G_Find (NULL, FOFS(targetname), self->target);
- if (!ent) {
- G_Printf ("%s at %s: %s is a bad target\n", self->classname, vtos(self->s.origin), self->target);
- }
+ if( self->target )
+ {
+ ent = G_Find( NULL, FOFS( targetname ), self->target );
+
+ if( !ent )
+ G_Printf ( "%s at %s: %s is a bad target\n", self->classname, vtos( self->s.origin ), self->target );
+
self->enemy = ent;
- } else {
- G_SetMovedir (self->s.angles, self->movedir);
}
+ else
+ G_SetMovedir( self->s.angles, self->movedir );
self->use = target_laser_use;
self->think = target_laser_think;
- if ( !self->damage ) {
+ if( !self->damage )
self->damage = 1;
- }
- if (self->spawnflags & 1)
- target_laser_on (self);
+ if( self->spawnflags & 1 )
+ target_laser_on( self );
else
- target_laser_off (self);
+ target_laser_off( self );
}
-void SP_target_laser (gentity_t *self)
+void SP_target_laser( gentity_t *self )
{
// let everything else get spawned before we start firing
self->think = target_laser_start;
@@ -330,14 +343,18 @@ void SP_target_laser (gentity_t *self)
//==========================================================
-void target_teleporter_use( gentity_t *self, gentity_t *other, gentity_t *activator ) {
+void target_teleporter_use( gentity_t *self, gentity_t *other, gentity_t *activator )
+{
gentity_t *dest;
- if (!activator->client)
+ if( !activator->client )
return;
+
dest = G_PickTarget( self->target );
- if (!dest) {
- G_Printf ("Couldn't find teleporter destination\n");
+
+ if( !dest )
+ {
+ G_Printf( "Couldn't find teleporter destination\n" );
return;
}
@@ -347,9 +364,10 @@ void target_teleporter_use( gentity_t *self, gentity_t *other, gentity_t *activa
/*QUAKED target_teleporter (1 0 0) (-8 -8 -8) (8 8 8)
The activator will be teleported away.
*/
-void SP_target_teleporter( gentity_t *self ) {
- if (!self->targetname)
- G_Printf("untargeted %s at %s\n", self->classname, vtos(self->s.origin));
+void SP_target_teleporter( gentity_t *self )
+{
+ if( !self->targetname )
+ G_Printf( "untargeted %s at %s\n", self->classname, vtos( self->s.origin ) );
self->use = target_teleporter_use;
}
@@ -397,27 +415,30 @@ void SP_target_relay( gentity_t *self )
/*QUAKED target_kill (.5 .5 .5) (-8 -8 -8) (8 8 8)
Kills the activator.
*/
-void target_kill_use( gentity_t *self, gentity_t *other, gentity_t *activator ) {
- G_Damage ( activator, NULL, NULL, NULL, NULL, 100000, DAMAGE_NO_PROTECTION, MOD_TELEFRAG);
+void target_kill_use( gentity_t *self, gentity_t *other, gentity_t *activator )
+{
+ G_Damage( activator, NULL, NULL, NULL, NULL, 100000, DAMAGE_NO_PROTECTION, MOD_TELEFRAG );
}
-void SP_target_kill( gentity_t *self ) {
+void SP_target_kill( gentity_t *self )
+{
self->use = target_kill_use;
}
/*QUAKED target_position (0 0.5 0) (-4 -4 -4) (4 4 4)
Used as a positional target for in-game calculation, like jumppad targets.
*/
-void SP_target_position( gentity_t *self ){
+void SP_target_position( gentity_t *self )
+{
G_SetOrigin( self, self->s.origin );
}
-static void target_location_linkup(gentity_t *ent)
+static void target_location_linkup( gentity_t *ent )
{
int i;
int n;
- if (level.locationLinked)
+ if( level.locationLinked )
return;
level.locationLinked = qtrue;
@@ -426,10 +447,10 @@ static void target_location_linkup(gentity_t *ent)
trap_SetConfigstring( CS_LOCATIONS, "unknown" );
- for (i = 0, ent = g_entities, n = 1;
- i < level.num_entities;
- i++, ent++) {
- if (ent->classname && !Q_stricmp(ent->classname, "target_location")) {
+ for( i = 0, ent = g_entities, n = 1; i < level.num_entities; i++, ent++)
+ {
+ if( ent->classname && !Q_stricmp( ent->classname, "target_location" ) )
+ {
// lets overload some variables!
ent->health = n; // use for location marking
trap_SetConfigstring( CS_LOCATIONS + n, ent->message );
@@ -438,7 +459,6 @@ static void target_location_linkup(gentity_t *ent)
level.locationHead = ent;
}
}
-
// All linked together now
}
@@ -450,7 +470,8 @@ Set "count" to 0-7 for color.
Closest target_location in sight used for the location, if none
in site, closest in distance
*/
-void SP_target_location( gentity_t *self ){
+void SP_target_location( gentity_t *self )
+{
self->think = target_location_linkup;
self->nextthink = level.time + 200; // Let them all spawn first
diff --git a/src/game/g_team.c b/src/game/g_team.c
index 33292381..538a29e2 100644
--- a/src/game/g_team.c
+++ b/src/game/g_team.c
@@ -16,39 +16,25 @@
#include "g_local.h"
-typedef struct teamgame_s {
- float last_flag_capture;
- int last_capture_team;
- flagStatus_t redStatus; // CTF
- flagStatus_t blueStatus; // CTF
- flagStatus_t flagStatus; // One Flag CTF
- int redTakenTime;
- int blueTakenTime;
- int redObeliskAttackedTime;
- int blueObeliskAttackedTime;
-} teamgame_t;
-
-teamgame_t teamgame;
-
-void Team_SetFlagStatus( int team, flagStatus_t status );
-
// NULL for everyone
-void QDECL PrintMsg( gentity_t *ent, const char *fmt, ... ) {
- char msg[1024];
- va_list argptr;
+void QDECL PrintMsg( gentity_t *ent, const char *fmt, ... )
+{
+ char msg[ 1024 ];
+ va_list argptr;
char *p;
- va_start (argptr,fmt);
- if (vsprintf (msg, fmt, argptr) > sizeof(msg)) {
+ va_start( argptr,fmt );
+
+ if( vsprintf( msg, fmt, argptr ) > sizeof( msg ) )
G_Error ( "PrintMsg overrun" );
- }
- va_end (argptr);
+
+ va_end( argptr );
// double quotes are bad
- while ((p = strchr(msg, '"')) != NULL)
+ while( ( p = strchr( msg, '"' ) ) != NULL )
*p = '\'';
- trap_SendServerCommand ( ( (ent == NULL) ? -1 : ent-g_entities ), va("print \"%s\"", msg ));
+ trap_SendServerCommand( ( ( ent == NULL ) ? -1 : ent-g_entities ), va( "print \"%s\"", msg ) );
}
@@ -156,60 +142,69 @@ Format:
==================
*/
-void TeamplayInfoMessage( gentity_t *ent ) {
- char entry[1024];
- char string[8192];
- int stringlength;
- int i, j;
+void TeamplayInfoMessage( gentity_t *ent )
+{
+ char entry[ 1024 ];
+ char string[ 8192 ];
+ int stringlength;
+ int i, j;
gentity_t *player;
- int cnt;
- int h, a = 0;
- int clients[TEAM_MAXOVERLAY];
+ int cnt;
+ int h, a = 0;
+ int clients[ TEAM_MAXOVERLAY ];
- if ( ! ent->client->pers.teamInfo )
+ if( ! ent->client->pers.teamInfo )
return;
// figure out what client should be on the display
// we are limited to 8, but we want to use the top eight players
// but in client order (so they don't keep changing position on the overlay)
- for (i = 0, cnt = 0; i < g_maxclients.integer && cnt < TEAM_MAXOVERLAY; i++) {
- player = g_entities + level.sortedClients[i];
- if (player->inuse && player->client->sess.sessionTeam ==
- ent->client->sess.sessionTeam ) {
- clients[cnt++] = level.sortedClients[i];
- }
+ for( i = 0, cnt = 0; i < g_maxclients.integer && cnt < TEAM_MAXOVERLAY; i++ )
+ {
+ player = g_entities + level.sortedClients[ i ];
+
+ if( player->inuse && player->client->sess.sessionTeam ==
+ ent->client->sess.sessionTeam )
+ clients[ cnt++ ] = level.sortedClients[ i ];
}
// We have the top eight players, sort them by clientNum
- qsort( clients, cnt, sizeof( clients[0] ), SortClients );
+ qsort( clients, cnt, sizeof( clients[ 0 ] ), SortClients );
// send the latest information on all clients
- string[0] = 0;
+ string[ 0 ] = 0;
stringlength = 0;
- for (i = 0, cnt = 0; i < g_maxclients.integer && cnt < TEAM_MAXOVERLAY; i++) {
+ for( i = 0, cnt = 0; i < g_maxclients.integer && cnt < TEAM_MAXOVERLAY; i++)
+ {
player = g_entities + i;
- if (player->inuse && player->client->sess.sessionTeam ==
- ent->client->sess.sessionTeam ) {
-
- h = player->client->ps.stats[STAT_HEALTH];
- if (h < 0) h = 0;
+
+ if( player->inuse && player->client->sess.sessionTeam ==
+ ent->client->sess.sessionTeam )
+ {
+ h = player->client->ps.stats[ STAT_HEALTH ];
+
+ if( h < 0 )
+ h = 0;
- Com_sprintf (entry, sizeof(entry),
+ Com_sprintf( entry, sizeof( entry ),
" %i %i %i %i %i %i",
// level.sortedClients[i], player->client->pers.teamState.location, h, a,
i, player->client->pers.teamState.location, h, a,
- player->client->ps.weapon, player->s.powerups);
- j = strlen(entry);
- if (stringlength + j > sizeof(string))
+ player->client->ps.weapon, player->s.powerups );
+
+ j = strlen( entry );
+
+ if( stringlength + j > sizeof( string ) )
break;
- strcpy (string + stringlength, entry);
+
+ strcpy( string + stringlength, entry );
stringlength += j;
cnt++;
}
}
- trap_SendServerCommand( ent-g_entities, va("tinfo %i %s", cnt, string) );
+ trap_SendServerCommand( ent - g_entities, va( "tinfo %i %s", cnt, string ) );
}
void CheckTeamStatus( void )
diff --git a/src/game/g_trigger.c b/src/game/g_trigger.c
index 27b136c6..95359f7a 100644
--- a/src/game/g_trigger.c
+++ b/src/game/g_trigger.c
@@ -17,9 +17,10 @@
#include "g_local.h"
-void InitTrigger( gentity_t *self ) {
- if (!VectorCompare (self->s.angles, vec3_origin))
- G_SetMovedir (self->s.angles, self->movedir);
+void InitTrigger( gentity_t *self )
+{
+ if( !VectorCompare( self->s.angles, vec3_origin ) )
+ G_SetMovedir( self->s.angles, self->movedir );
trap_SetBrushModel( self, self->model );
self->r.contents = CONTENTS_TRIGGER; // replaces the -1 from trap_SetBrushModel
@@ -28,7 +29,8 @@ void InitTrigger( gentity_t *self ) {
// the wait time has passed, so set back up for another activation
-void multi_wait( gentity_t *ent ) {
+void multi_wait( gentity_t *ent )
+{
ent->nextthink = 0;
}
@@ -70,14 +72,16 @@ void multi_trigger( gentity_t *ent, gentity_t *activator )
}
}
-void Use_Multi( gentity_t *ent, gentity_t *other, gentity_t *activator ) {
+void Use_Multi( gentity_t *ent, gentity_t *other, gentity_t *activator )
+{
multi_trigger( ent, activator );
}
-void Touch_Multi( gentity_t *self, gentity_t *other, trace_t *trace ) {
- if( !other->client ) {
+void Touch_Multi( gentity_t *self, gentity_t *other, trace_t *trace )
+{
+ if( !other->client )
return;
- }
+
multi_trigger( self, other );
}
@@ -88,11 +92,13 @@ Variable sized repeatable trigger. Must be targeted at one or more entities.
so, the basic time between firing is a random time between
(wait - random) and (wait + random)
*/
-void SP_trigger_multiple( gentity_t *ent ) {
+void SP_trigger_multiple( gentity_t *ent )
+{
G_SpawnFloat( "wait", "0.5", &ent->wait );
G_SpawnFloat( "random", "0", &ent->random );
- if ( ent->random >= ent->wait && ent->wait >= 0 ) {
+ if( ent->random >= ent->wait && ent->wait >= 0 )
+ {
ent->random = ent->wait - FRAMETIME;
G_Printf( "trigger_multiple has random >= wait\n" );
}
@@ -101,7 +107,7 @@ void SP_trigger_multiple( gentity_t *ent ) {
ent->use = Use_Multi;
InitTrigger( ent );
- trap_LinkEntity (ent);
+ trap_LinkEntity( ent );
}
@@ -114,15 +120,17 @@ trigger_always
==============================================================================
*/
-void trigger_always_think( gentity_t *ent ) {
- G_UseTargets(ent, ent);
+void trigger_always_think( gentity_t *ent )
+{
+ G_UseTargets( ent, ent );
G_FreeEntity( ent );
}
/*QUAKED trigger_always (.5 .5 .5) (-8 -8 -8) (8 8 8)
This trigger will always fire. It is activated by the world.
*/
-void SP_trigger_always (gentity_t *ent) {
+void SP_trigger_always( gentity_t *ent )
+{
// we must have some delay to make sure our use targets are present
ent->nextthink = level.time + 300;
ent->think = trigger_always_think;
@@ -137,10 +145,10 @@ trigger_push
==============================================================================
*/
-void trigger_push_touch (gentity_t *self, gentity_t *other, trace_t *trace ) {
- if ( !other->client ) {
+void trigger_push_touch( gentity_t *self, gentity_t *other, trace_t *trace )
+{
+ if( !other->client )
return;
- }
BG_TouchJumpPad( &other->client->ps, &self->s );
}
@@ -153,38 +161,43 @@ AimAtTarget
Calculate origin2 so the target apogee will be hit
=================
*/
-void AimAtTarget( gentity_t *self ) {
+void AimAtTarget( gentity_t *self )
+{
gentity_t *ent;
vec3_t origin;
- float height, gravity, time, forward;
- float dist;
+ float height, gravity, time, forward;
+ float dist;
VectorAdd( self->r.absmin, self->r.absmax, origin );
- VectorScale ( origin, 0.5, origin );
+ VectorScale( origin, 0.5, origin );
ent = G_PickTarget( self->target );
- if ( !ent ) {
+
+ if( !ent )
+ {
G_FreeEntity( self );
return;
}
- height = ent->s.origin[2] - origin[2];
+ height = ent->s.origin[ 2 ] - origin[ 2 ];
gravity = g_gravity.value;
- time = sqrt( height / ( .5 * gravity ) );
- if ( !time ) {
+ time = sqrt( height / ( 0.5 * gravity ) );
+
+ if( !time )
+ {
G_FreeEntity( self );
return;
}
// set s.origin2 to the push velocity
- VectorSubtract ( ent->s.origin, origin, self->s.origin2 );
- self->s.origin2[2] = 0;
- dist = VectorNormalize( self->s.origin2);
+ VectorSubtract( ent->s.origin, origin, self->s.origin2 );
+ self->s.origin2[ 2 ] = 0;
+ dist = VectorNormalize( self->s.origin2 );
forward = dist / time;
VectorScale( self->s.origin2, forward, self->s.origin2 );
- self->s.origin2[2] = time * gravity;
+ self->s.origin2[ 2 ] = time * gravity;
}
@@ -192,39 +205,37 @@ void AimAtTarget( gentity_t *self ) {
Must point at a target_position, which will be the apex of the leap.
This will be client side predicted, unlike target_push
*/
-void SP_trigger_push( gentity_t *self ) {
- InitTrigger (self);
+void SP_trigger_push( gentity_t *self )
+{
+ InitTrigger( self );
// unlike other triggers, we need to send this one to the client
self->r.svFlags &= ~SVF_NOCLIENT;
// make sure the client precaches this sound
- G_SoundIndex("sound/world/jumppad.wav");
+ G_SoundIndex( "sound/world/jumppad.wav" );
self->s.eType = ET_PUSH_TRIGGER;
self->touch = trigger_push_touch;
self->think = AimAtTarget;
self->nextthink = level.time + FRAMETIME;
- trap_LinkEntity (self);
+ trap_LinkEntity( self );
}
-void Use_target_push( gentity_t *self, gentity_t *other, gentity_t *activator ) {
- if ( !activator->client ) {
+void Use_target_push( gentity_t *self, gentity_t *other, gentity_t *activator )
+{
+ if( !activator->client )
return;
- }
- if ( activator->client->ps.pm_type != PM_NORMAL ) {
+ if( activator->client->ps.pm_type != PM_NORMAL )
return;
- }
- /*if ( activator->client->ps.powerups[PW_FLIGHT] ) {
- return;
- }*/
- VectorCopy (self->s.origin2, activator->client->ps.velocity);
+ VectorCopy( self->s.origin2, activator->client->ps.velocity );
// play fly sound every 1.5 seconds
- if ( activator->fly_sound_debounce_time < level.time ) {
+ if( activator->fly_sound_debounce_time < level.time )
+ {
activator->fly_sound_debounce_time = level.time + 1500;
G_Sound( activator, CHAN_AUTO, self->noise_index );
}
@@ -235,24 +246,27 @@ Pushes the activator in the direction.of angle, or towards a target apex.
"speed" defaults to 1000
if "bouncepad", play bounce noise instead of windfly
*/
-void SP_target_push( gentity_t *self ) {
- if (!self->speed) {
+void SP_target_push( gentity_t *self )
+{
+ if( !self->speed )
self->speed = 1000;
- }
- G_SetMovedir (self->s.angles, self->s.origin2);
- VectorScale (self->s.origin2, self->speed, self->s.origin2);
- if ( self->spawnflags & 1 ) {
- self->noise_index = G_SoundIndex("sound/world/jumppad.wav");
- } else {
- self->noise_index = G_SoundIndex("sound/misc/windfly.wav");
- }
- if ( self->target ) {
+ G_SetMovedir( self->s.angles, self->s.origin2 );
+ VectorScale( self->s.origin2, self->speed, self->s.origin2 );
+
+ if( self->spawnflags & 1 )
+ self->noise_index = G_SoundIndex( "sound/world/jumppad.wav" );
+ else
+ self->noise_index = G_SoundIndex( "sound/misc/windfly.wav" );
+
+ if( self->target )
+ {
VectorCopy( self->s.origin, self->r.absmin );
VectorCopy( self->s.origin, self->r.absmax );
self->think = AimAtTarget;
self->nextthink = level.time + FRAMETIME;
}
+
self->use = Use_target_push;
}
@@ -264,25 +278,27 @@ trigger_teleport
==============================================================================
*/
-void trigger_teleporter_touch (gentity_t *self, gentity_t *other, trace_t *trace ) {
+void trigger_teleporter_touch( gentity_t *self, gentity_t *other, trace_t *trace )
+{
gentity_t *dest;
- if ( !other->client ) {
+ if( !other->client )
return;
- }
- if ( other->client->ps.pm_type == PM_DEAD ) {
+
+ if( other->client->ps.pm_type == PM_DEAD )
return;
- }
+
// Spectators only?
- if ( ( self->spawnflags & 1 ) &&
- other->client->sess.sessionTeam != TEAM_SPECTATOR ) {
+ if( ( self->spawnflags & 1 ) &&
+ other->client->sess.sessionTeam != TEAM_SPECTATOR )
return;
- }
- dest = G_PickTarget( self->target );
- if (!dest) {
- G_Printf ("Couldn't find teleporter destination\n");
+ dest = G_PickTarget( self->target );
+
+ if( !dest )
+ {
+ G_Printf( "Couldn't find teleporter destination\n" );
return;
}
@@ -298,24 +314,24 @@ If spectator is set, only spectators can use this teleport
Spectator teleporters are not normally placed in the editor, but are created
automatically near doors to allow spectators to move through them
*/
-void SP_trigger_teleport( gentity_t *self ) {
- InitTrigger (self);
+void SP_trigger_teleport( gentity_t *self )
+{
+ InitTrigger( self );
// unlike other triggers, we need to send this one to the client
// unless is a spectator trigger
- if ( self->spawnflags & 1 ) {
+ if( self->spawnflags & 1 )
self->r.svFlags |= SVF_NOCLIENT;
- } else {
+ else
self->r.svFlags &= ~SVF_NOCLIENT;
- }
// make sure the client precaches this sound
- G_SoundIndex("sound/world/jumppad.wav");
+ G_SoundIndex( "sound/world/jumppad.wav" );
self->s.eType = ET_TELEPORT_TRIGGER;
self->touch = trigger_teleporter_touch;
- trap_LinkEntity (self);
+ trap_LinkEntity( self );
}
@@ -339,63 +355,59 @@ NO_PROTECTION *nothing* stops the damage
"dmg" default 5 (whole numbers only)
*/
-void hurt_use( gentity_t *self, gentity_t *other, gentity_t *activator ) {
- if ( self->r.linked ) {
+void hurt_use( gentity_t *self, gentity_t *other, gentity_t *activator )
+{
+ if( self->r.linked )
trap_UnlinkEntity( self );
- } else {
+ else
trap_LinkEntity( self );
- }
}
-void hurt_touch( gentity_t *self, gentity_t *other, trace_t *trace ) {
+void hurt_touch( gentity_t *self, gentity_t *other, trace_t *trace )
+{
int dflags;
- if ( !other->takedamage ) {
+ if( !other->takedamage )
return;
- }
- if ( self->timestamp > level.time ) {
+ if( self->timestamp > level.time )
return;
- }
- if ( self->spawnflags & 16 ) {
+ if( self->spawnflags & 16 )
self->timestamp = level.time + 1000;
- } else {
+ else
self->timestamp = level.time + FRAMETIME;
- }
// play sound
- if ( !(self->spawnflags & 4) ) {
+ if( !( self->spawnflags & 4 ) )
G_Sound( other, CHAN_AUTO, self->noise_index );
- }
- if (self->spawnflags & 8)
+ if( self->spawnflags & 8 )
dflags = DAMAGE_NO_PROTECTION;
else
dflags = 0;
- G_Damage (other, self, self, NULL, NULL, self->damage, dflags, MOD_TRIGGER_HURT);
+
+ G_Damage( other, self, self, NULL, NULL, self->damage, dflags, MOD_TRIGGER_HURT );
}
-void SP_trigger_hurt( gentity_t *self ) {
- InitTrigger (self);
+void SP_trigger_hurt( gentity_t *self )
+{
+ InitTrigger( self );
self->noise_index = G_SoundIndex( "sound/world/electro.wav" );
self->touch = hurt_touch;
- if ( !self->damage ) {
+ if( !self->damage )
self->damage = 5;
- }
self->r.contents = CONTENTS_TRIGGER;
- if ( self->spawnflags & 2 ) {
+ if( self->spawnflags & 2 )
self->use = hurt_use;
- }
// link in to the world if starting active
- if ( ! (self->spawnflags & 1) ) {
- trap_LinkEntity (self);
- }
+ if( !( self->spawnflags & 1 ) )
+ trap_LinkEntity( self );
}
@@ -419,38 +431,44 @@ so, the basic time between firing is a random time between
(wait - random) and (wait + random)
*/
-void func_timer_think( gentity_t *self ) {
- G_UseTargets (self, self->activator);
+void func_timer_think( gentity_t *self )
+{
+ G_UseTargets( self, self->activator );
// set time before next firing
- self->nextthink = level.time + 1000 * ( self->wait + crandom() * self->random );
+ self->nextthink = level.time + 1000 * ( self->wait + crandom( ) * self->random );
}
-void func_timer_use( gentity_t *self, gentity_t *other, gentity_t *activator ) {
+void func_timer_use( gentity_t *self, gentity_t *other, gentity_t *activator )
+{
self->activator = activator;
// if on, turn it off
- if ( self->nextthink ) {
+ if( self->nextthink )
+ {
self->nextthink = 0;
return;
}
// turn it on
- func_timer_think (self);
+ func_timer_think( self );
}
-void SP_func_timer( gentity_t *self ) {
- G_SpawnFloat( "random", "1", &self->random);
+void SP_func_timer( gentity_t *self )
+{
+ G_SpawnFloat( "random", "1", &self->random );
G_SpawnFloat( "wait", "1", &self->wait );
self->use = func_timer_use;
self->think = func_timer_think;
- if ( self->random >= self->wait ) {
+ if( self->random >= self->wait )
+ {
self->random = self->wait - FRAMETIME;
G_Printf( "func_timer at %s has random >= wait\n", vtos( self->s.origin ) );
}
- if ( self->spawnflags & 1 ) {
+ if( self->spawnflags & 1 )
+ {
self->nextthink = level.time + FRAMETIME;
self->activator = self;
}
diff --git a/src/game/g_utils.c b/src/game/g_utils.c
index 14a1b9fa..708c3799 100644
--- a/src/game/g_utils.c
+++ b/src/game/g_utils.c
@@ -17,45 +17,55 @@
#include "g_local.h"
-typedef struct {
- char oldShader[MAX_QPATH];
- char newShader[MAX_QPATH];
+typedef struct
+{
+ char oldShader[ MAX_QPATH ];
+ char newShader[ MAX_QPATH ];
float timeOffset;
} shaderRemap_t;
#define MAX_SHADER_REMAPS 128
int remapCount = 0;
-shaderRemap_t remappedShaders[MAX_SHADER_REMAPS];
+shaderRemap_t remappedShaders[ MAX_SHADER_REMAPS ];
-void AddRemap(const char *oldShader, const char *newShader, float timeOffset) {
+void AddRemap( const char *oldShader, const char *newShader, float timeOffset )
+{
int i;
- for (i = 0; i < remapCount; i++) {
- if (Q_stricmp(oldShader, remappedShaders[i].oldShader) == 0) {
+ for( i = 0; i < remapCount; i++ )
+ {
+ if( Q_stricmp( oldShader, remappedShaders[ i ].oldShader ) == 0 )
+ {
// found it, just update this one
- strcpy(remappedShaders[i].newShader,newShader);
- remappedShaders[i].timeOffset = timeOffset;
+ strcpy( remappedShaders[ i ].newShader,newShader );
+ remappedShaders[ i ].timeOffset = timeOffset;
return;
}
}
- if (remapCount < MAX_SHADER_REMAPS) {
- strcpy(remappedShaders[remapCount].newShader,newShader);
- strcpy(remappedShaders[remapCount].oldShader,oldShader);
- remappedShaders[remapCount].timeOffset = timeOffset;
+
+ if( remapCount < MAX_SHADER_REMAPS )
+ {
+ strcpy( remappedShaders[ remapCount ].newShader,newShader );
+ strcpy( remappedShaders[ remapCount ].oldShader,oldShader );
+ remappedShaders[ remapCount ].timeOffset = timeOffset;
remapCount++;
}
}
-const char *BuildShaderStateConfig() {
- static char buff[MAX_STRING_CHARS*4];
- char out[(MAX_QPATH * 2) + 5];
- int i;
+const char *BuildShaderStateConfig( )
+{
+ static char buff[ MAX_STRING_CHARS * 4 ];
+ char out[ ( MAX_QPATH * 2 ) + 5 ];
+ int i;
+
+ memset( buff, 0, MAX_STRING_CHARS );
- memset(buff, 0, MAX_STRING_CHARS);
- for (i = 0; i < remapCount; i++) {
- Com_sprintf(out, (MAX_QPATH * 2) + 5, "%s=%s:%5.2f@", remappedShaders[i].oldShader, remappedShaders[i].newShader, remappedShaders[i].timeOffset);
- Q_strcat( buff, sizeof( buff ), out);
+ for( i = 0; i < remapCount; i++ )
+ {
+ Com_sprintf( out, ( MAX_QPATH * 2 ) + 5, "%s=%s:%5.2f@", remappedShaders[ i ].oldShader,
+ remappedShaders[ i ].newShader, remappedShaders[ i ].timeOffset );
+ Q_strcat( buff, sizeof( buff ), out );
}
return buff;
}
@@ -75,48 +85,49 @@ G_FindConfigstringIndex
================
*/
-int G_FindConfigstringIndex( char *name, int start, int max, qboolean create ) {
- int i;
- char s[MAX_STRING_CHARS];
-
- if ( !name || !name[0] ) {
- return 0;
- }
-
- for ( i=1 ; i<max ; i++ ) {
- trap_GetConfigstring( start + i, s, sizeof( s ) );
- if ( !s[0] ) {
- break;
- }
- if ( !strcmp( s, name ) ) {
- return i;
- }
- }
-
- if ( !create ) {
- return 0;
- }
-
- if ( i == max ) {
- G_Error( "G_FindConfigstringIndex: overflow" );
- }
-
- trap_SetConfigstring( start + i, name );
-
- return i;
+int G_FindConfigstringIndex( char *name, int start, int max, qboolean create )
+{
+ int i;
+ char s[ MAX_STRING_CHARS ];
+
+ if( !name || !name[ 0 ] )
+ return 0;
+
+ for( i = 1; i < max; i++ )
+ {
+ trap_GetConfigstring( start + i, s, sizeof( s ) );
+ if( !s[ 0 ] )
+ break;
+
+ if( !strcmp( s, name ) )
+ return i;
+ }
+
+ if( !create )
+ return 0;
+
+ if( i == max )
+ G_Error( "G_FindConfigstringIndex: overflow" );
+
+ trap_SetConfigstring( start + i, name );
+
+ return i;
}
//TA: added ShaderIndex
-int G_ShaderIndex( char *name ) {
- return G_FindConfigstringIndex (name, CS_SHADERS, MAX_SHADERS, qtrue);
+int G_ShaderIndex( char *name )
+{
+ return G_FindConfigstringIndex( name, CS_SHADERS, MAX_SHADERS, qtrue );
}
-int G_ModelIndex( char *name ) {
- return G_FindConfigstringIndex (name, CS_MODELS, MAX_MODELS, qtrue);
+int G_ModelIndex( char *name )
+{
+ return G_FindConfigstringIndex( name, CS_MODELS, MAX_MODELS, qtrue );
}
-int G_SoundIndex( char *name ) {
- return G_FindConfigstringIndex (name, CS_SOUNDS, MAX_SOUNDS, qtrue);
+int G_SoundIndex( char *name )
+{
+ return G_FindConfigstringIndex( name, CS_SOUNDS, MAX_SOUNDS, qtrue );
}
//=====================================================================
@@ -131,16 +142,16 @@ Broadcasts a command to only a specific team
*/
void G_TeamCommand( pTeam_t team, char *cmd )
{
- int i;
+ int i;
- for( i = 0 ; i < level.maxclients ; i++ )
+ for( i = 0 ; i < level.maxclients ; i++ )
{
- if( level.clients[ i ].pers.connected == CON_CONNECTED )
+ if( level.clients[ i ].pers.connected == CON_CONNECTED )
{
- if( level.clients[ i ].ps.stats[ STAT_PTEAM ] == team )
- trap_SendServerCommand( i, va( "%s", cmd ) );
- }
- }
+ if( level.clients[ i ].ps.stats[ STAT_PTEAM ] == team )
+ trap_SendServerCommand( i, va( "%s", cmd ) );
+ }
+ }
}
@@ -156,27 +167,29 @@ NULL will be returned if the end of the list is reached.
=============
*/
-gentity_t *G_Find (gentity_t *from, int fieldofs, const char *match)
+gentity_t *G_Find( gentity_t *from, int fieldofs, const char *match )
{
- char *s;
-
- if (!from)
- from = g_entities;
- else
- from++;
-
- for ( ; from < &g_entities[level.num_entities] ; from++)
- {
- if (!from->inuse)
- continue;
- s = *(char **) ((byte *)from + fieldofs);
- if (!s)
- continue;
- if (!Q_stricmp (s, match))
- return from;
- }
-
- return NULL;
+ char *s;
+
+ if( !from )
+ from = g_entities;
+ else
+ from++;
+
+ for( ; from < &g_entities[ level.num_entities ]; from++ )
+ {
+ if( !from->inuse )
+ continue;
+ s = *(char **)( (byte *)from + fieldofs );
+
+ if( !s )
+ continue;
+
+ if( !Q_stricmp( s, match ) )
+ return from;
+ }
+
+ return NULL;
}
@@ -187,37 +200,40 @@ G_PickTarget
Selects a random entity from among the targets
=============
*/
-#define MAXCHOICES 32
+#define MAXCHOICES 32
-gentity_t *G_PickTarget (char *targetname)
+gentity_t *G_PickTarget( char *targetname )
{
- gentity_t *ent = NULL;
- int num_choices = 0;
- gentity_t *choice[MAXCHOICES];
-
- if (!targetname)
- {
- G_Printf("G_PickTarget called with NULL targetname\n");
- return NULL;
- }
-
- while(1)
- {
- ent = G_Find (ent, FOFS(targetname), targetname);
- if (!ent)
- break;
- choice[num_choices++] = ent;
- if (num_choices == MAXCHOICES)
- break;
- }
-
- if (!num_choices)
- {
- G_Printf("G_PickTarget: target %s not found\n", targetname);
- return NULL;
- }
-
- return choice[rand() % num_choices];
+ gentity_t *ent = NULL;
+ int num_choices = 0;
+ gentity_t *choice[ MAXCHOICES ];
+
+ if( !targetname )
+ {
+ G_Printf("G_PickTarget called with NULL targetname\n");
+ return NULL;
+ }
+
+ while( 1 )
+ {
+ ent = G_Find( ent, FOFS( targetname ), targetname );
+
+ if( !ent )
+ break;
+
+ choice[ num_choices++ ] = ent;
+
+ if( num_choices == MAXCHOICES )
+ break;
+ }
+
+ if( !num_choices )
+ {
+ G_Printf( "G_PickTarget: target %s not found\n", targetname );
+ return NULL;
+ }
+
+ return choice[ rand( ) % num_choices ];
}
@@ -232,37 +248,40 @@ match (string)self.target and call their .use function
==============================
*/
-void G_UseTargets( gentity_t *ent, gentity_t *activator ) {
- gentity_t *t;
-
- if ( !ent ) {
- return;
- }
-
- if (ent->targetShaderName && ent->targetShaderNewName) {
+void G_UseTargets( gentity_t *ent, gentity_t *activator )
+{
+ gentity_t *t;
+
+ if( !ent )
+ return;
+
+ if( ent->targetShaderName && ent->targetShaderNewName )
+ {
float f = level.time * 0.001;
- AddRemap(ent->targetShaderName, ent->targetShaderNewName, f);
- trap_SetConfigstring(CS_SHADERSTATE, BuildShaderStateConfig());
+ AddRemap( ent->targetShaderName, ent->targetShaderNewName, f );
+ trap_SetConfigstring( CS_SHADERSTATE, BuildShaderStateConfig( ) );
}
- if ( !ent->target ) {
- return;
- }
-
- t = NULL;
- while ( (t = G_Find (t, FOFS(targetname), ent->target)) != NULL ) {
- if ( t == ent ) {
- G_Printf ("WARNING: Entity used itself.\n");
- } else {
- if ( t->use ) {
- t->use (t, ent, activator);
- }
- }
- if ( !ent->inuse ) {
- G_Printf("entity was removed while using targets\n");
- return;
- }
- }
+ if( !ent->target )
+ return;
+
+ t = NULL;
+ while( ( t = G_Find( t, FOFS( targetname ), ent->target) ) != NULL )
+ {
+ if( t == ent )
+ G_Printf( "WARNING: Entity used itself.\n" );
+ else
+ {
+ if( t->use )
+ t->use( t, ent, activator );
+ }
+
+ if( !ent->inuse )
+ {
+ G_Printf( "entity was removed while using targets\n" );
+ return;
+ }
+ }
}
@@ -274,21 +293,22 @@ This is just a convenience function
for making temporary vectors for function calls
=============
*/
-float *tv( float x, float y, float z ) {
- static int index;
- static vec3_t vecs[8];
- float *v;
+float *tv( float x, float y, float z )
+{
+ static int index;
+ static vec3_t vecs[ 8 ];
+ float *v;
- // use an array so that multiple tempvectors won't collide
- // for a while
- v = vecs[index];
- index = (index + 1)&7;
+ // use an array so that multiple tempvectors won't collide
+ // for a while
+ v = vecs[ index ];
+ index = ( index + 1 ) & 7;
- v[0] = x;
- v[1] = y;
- v[2] = z;
+ v[ 0 ] = x;
+ v[ 1 ] = y;
+ v[ 2 ] = z;
- return v;
+ return v;
}
@@ -300,18 +320,19 @@ This is just a convenience function
for printing vectors
=============
*/
-char *vtos( const vec3_t v ) {
- static int index;
- static char str[8][32];
- char *s;
+char *vtos( const vec3_t v )
+{
+ static int index;
+ static char str[ 8 ][ 32 ];
+ char *s;
- // use an array so that multiple vtos won't collide
- s = str[index];
- index = (index + 1)&7;
+ // use an array so that multiple vtos won't collide
+ s = str[ index ];
+ index = ( index + 1 ) & 7;
- Com_sprintf (s, 32, "(%i %i %i)", (int)v[0], (int)v[1], (int)v[2]);
+ Com_sprintf( s, 32, "(%i %i %i)", (int)v[ 0 ], (int)v[ 1 ], (int)v[ 2 ] );
- return s;
+ return s;
}
@@ -325,50 +346,55 @@ Angles will be cleared, because it is being used to represent a direction
instead of an orientation.
===============
*/
-void G_SetMovedir( vec3_t angles, vec3_t movedir ) {
- static vec3_t VEC_UP = {0, -1, 0};
- static vec3_t MOVEDIR_UP = {0, 0, 1};
- static vec3_t VEC_DOWN = {0, -2, 0};
- static vec3_t MOVEDIR_DOWN = {0, 0, -1};
-
- if ( VectorCompare (angles, VEC_UP) ) {
- VectorCopy (MOVEDIR_UP, movedir);
- } else if ( VectorCompare (angles, VEC_DOWN) ) {
- VectorCopy (MOVEDIR_DOWN, movedir);
- } else {
- AngleVectors (angles, movedir, NULL, NULL);
- }
- VectorClear( angles );
+void G_SetMovedir( vec3_t angles, vec3_t movedir )
+{
+ static vec3_t VEC_UP = { 0, -1, 0 };
+ static vec3_t MOVEDIR_UP = { 0, 0, 1 };
+ static vec3_t VEC_DOWN = { 0, -2, 0 };
+ static vec3_t MOVEDIR_DOWN = { 0, 0, -1 };
+
+ if( VectorCompare( angles, VEC_UP ) )
+ VectorCopy( MOVEDIR_UP, movedir );
+ else if( VectorCompare( angles, VEC_DOWN ) )
+ VectorCopy( MOVEDIR_DOWN, movedir );
+ else
+ AngleVectors( angles, movedir, NULL, NULL );
+
+ VectorClear( angles );
}
-float vectoyaw( const vec3_t vec ) {
- float yaw;
-
- if (vec[YAW] == 0 && vec[PITCH] == 0) {
- yaw = 0;
- } else {
- if (vec[PITCH]) {
- yaw = ( atan2( vec[YAW], vec[PITCH]) * 180 / M_PI );
- } else if (vec[YAW] > 0) {
- yaw = 90;
- } else {
- yaw = 270;
- }
- if (yaw < 0) {
- yaw += 360;
- }
- }
-
- return yaw;
+float vectoyaw( const vec3_t vec )
+{
+ float yaw;
+
+ if( vec[ YAW ] == 0 && vec[ PITCH ] == 0 )
+ {
+ yaw = 0;
+ }
+ else
+ {
+ if( vec[ PITCH ] )
+ yaw = ( atan2( vec[ YAW ], vec[ PITCH ] ) * 180 / M_PI );
+ else if( vec[ YAW ] > 0 )
+ yaw = 90;
+ else
+ yaw = 270;
+
+ if( yaw < 0 )
+ yaw += 360;
+ }
+
+ return yaw;
}
-void G_InitGentity( gentity_t *e ) {
- e->inuse = qtrue;
- e->classname = "noclass";
- e->s.number = e - g_entities;
- e->r.ownerNum = ENTITYNUM_NONE;
+void G_InitGentity( gentity_t *e )
+{
+ e->inuse = qtrue;
+ e->classname = "noclass";
+ e->s.number = e - g_entities;
+ e->r.ownerNum = ENTITYNUM_NONE;
}
/*
@@ -386,51 +412,56 @@ instead of being removed and recreated, which can cause interpolated
angles and bad trails.
=================
*/
-gentity_t *G_Spawn( void ) {
- int i, force;
- gentity_t *e;
-
- e = NULL; // shut up warning
- i = 0; // shut up warning
- for ( force = 0 ; force < 2 ; force++ ) {
- // if we go through all entities and can't find one to free,
- // override the normal minimum times before use
- e = &g_entities[MAX_CLIENTS];
- for ( i = MAX_CLIENTS ; i<level.num_entities ; i++, e++) {
- if ( e->inuse ) {
- continue;
- }
-
- // the first couple seconds of server time can involve a lot of
- // freeing and allocating, so relax the replacement policy
- if ( !force && e->freetime > level.startTime + 2000 && level.time - e->freetime < 1000 ) {
- continue;
- }
-
- // reuse this slot
- G_InitGentity( e );
- return e;
- }
- if ( i != MAX_GENTITIES ) {
- break;
- }
- }
- if ( i == ENTITYNUM_MAX_NORMAL ) {
- for (i = 0; i < MAX_GENTITIES; i++) {
- G_Printf("%4i: %s\n", i, g_entities[i].classname);
+gentity_t *G_Spawn( void )
+{
+ int i, force;
+ gentity_t *e;
+
+ e = NULL; // shut up warning
+ i = 0; // shut up warning
+
+ for( force = 0; force < 2; force++ )
+ {
+ // if we go through all entities and can't find one to free,
+ // override the normal minimum times before use
+ e = &g_entities[ MAX_CLIENTS ];
+
+ for( i = MAX_CLIENTS; i < level.num_entities; i++, e++ )
+ {
+ if( e->inuse )
+ continue;
+
+ // the first couple seconds of server time can involve a lot of
+ // freeing and allocating, so relax the replacement policy
+ if( !force && e->freetime > level.startTime + 2000 && level.time - e->freetime < 1000 )
+ continue;
+
+ // reuse this slot
+ G_InitGentity( e );
+ return e;
}
- G_Error( "G_Spawn: no free entities" );
- }
-
- // open up a new slot
- level.num_entities++;
-
- // let the server system know that there are more entities
- trap_LocateGameData( level.gentities, level.num_entities, sizeof( gentity_t ),
- &level.clients[0].ps, sizeof( level.clients[0] ) );
-
- G_InitGentity( e );
- return e;
+
+ if( i != MAX_GENTITIES )
+ break;
+ }
+
+ if( i == ENTITYNUM_MAX_NORMAL )
+ {
+ for( i = 0; i < MAX_GENTITIES; i++ )
+ G_Printf( "%4i: %s\n", i, g_entities[ i ].classname );
+
+ G_Error( "G_Spawn: no free entities" );
+ }
+
+ // open up a new slot
+ level.num_entities++;
+
+ // let the server system know that there are more entities
+ trap_LocateGameData( level.gentities, level.num_entities, sizeof( gentity_t ),
+ &level.clients[ 0 ].ps, sizeof( level.clients[ 0 ] ) );
+
+ G_InitGentity( e );
+ return e;
}
@@ -439,18 +470,22 @@ gentity_t *G_Spawn( void ) {
G_EntitiesFree
=================
*/
-qboolean G_EntitiesFree( void ) {
+qboolean G_EntitiesFree( void )
+{
int i;
gentity_t *e;
- e = &g_entities[MAX_CLIENTS];
- for ( i = MAX_CLIENTS; i < level.num_entities; i++, e++) {
- if ( e->inuse ) {
+ e = &g_entities[ MAX_CLIENTS ];
+
+ for( i = MAX_CLIENTS; i < level.num_entities; i++, e++ )
+ {
+ if( e->inuse )
continue;
- }
+
// slot available
return qtrue;
}
+
return qfalse;
}
@@ -462,17 +497,17 @@ G_FreeEntity
Marks the entity as free
=================
*/
-void G_FreeEntity( gentity_t *ed ) {
- trap_UnlinkEntity (ed); // unlink from world
+void G_FreeEntity( gentity_t *ent )
+{
+ trap_UnlinkEntity( ent ); // unlink from world
- if ( ed->neverFree ) {
- return;
- }
+ if( ent->neverFree )
+ return;
- memset (ed, 0, sizeof(*ed));
- ed->classname = "freed";
- ed->freetime = level.time;
- ed->inuse = qfalse;
+ memset( ent, 0, sizeof( *ent ) );
+ ent->classname = "freent";
+ ent->freetime = level.time;
+ ent->inuse = qfalse;
}
/*
@@ -484,25 +519,26 @@ The origin will be snapped to save net bandwidth, so care
must be taken if the origin is right on a surface (snap towards start vector first)
=================
*/
-gentity_t *G_TempEntity( vec3_t origin, int event ) {
- gentity_t *e;
- vec3_t snapped;
+gentity_t *G_TempEntity( vec3_t origin, int event )
+{
+ gentity_t *e;
+ vec3_t snapped;
- e = G_Spawn();
- e->s.eType = ET_EVENTS + event;
+ e = G_Spawn( );
+ e->s.eType = ET_EVENTS + event;
- e->classname = "tempEntity";
- e->eventTime = level.time;
- e->freeAfterEvent = qtrue;
+ e->classname = "tempEntity";
+ e->eventTime = level.time;
+ e->freeAfterEvent = qtrue;
- VectorCopy( origin, snapped );
- SnapVector( snapped ); // save network bandwidth
- G_SetOrigin( e, snapped );
+ VectorCopy( origin, snapped );
+ SnapVector( snapped ); // save network bandwidth
+ G_SetOrigin( e, snapped );
- // find cluster for PVS
- trap_LinkEntity( e );
+ // find cluster for PVS
+ trap_LinkEntity( e );
- return e;
+ return e;
}
@@ -523,29 +559,32 @@ Kills all entities that would touch the proposed new positioning
of ent. Ent should be unlinked before calling this!
=================
*/
-void G_KillBox (gentity_t *ent) {
- int i, num;
- int touch[MAX_GENTITIES];
- gentity_t *hit;
- vec3_t mins, maxs;
+void G_KillBox( gentity_t *ent )
+{
+ int i, num;
+ int touch[ MAX_GENTITIES ];
+ gentity_t *hit;
+ vec3_t mins, maxs;
- VectorAdd( ent->client->ps.origin, ent->r.mins, mins );
- VectorAdd( ent->client->ps.origin, ent->r.maxs, maxs );
- num = trap_EntitiesInBox( mins, maxs, touch, MAX_GENTITIES );
+ VectorAdd( ent->client->ps.origin, ent->r.mins, mins );
+ VectorAdd( ent->client->ps.origin, ent->r.maxs, maxs );
+ num = trap_EntitiesInBox( mins, maxs, touch, MAX_GENTITIES );
- for (i=0 ; i<num ; i++) {
- hit = &g_entities[touch[i]];
- if ( !hit->client )
- continue;
+ for( i = 0; i < num; i++ )
+ {
+ hit = &g_entities[ touch[ i ] ];
+
+ if( !hit->client )
+ continue;
//TA: impossible to telefrag self
if( ent == hit )
continue;
- // nail it
- G_Damage ( hit, ent, ent, NULL, NULL,
- 100000, DAMAGE_NO_PROTECTION, MOD_TELEFRAG);
- }
+ // nail it
+ G_Damage( hit, ent, ent, NULL, NULL,
+ 100000, DAMAGE_NO_PROTECTION, MOD_TELEFRAG );
+ }
}
@@ -560,11 +599,12 @@ client side: jumppads and item pickups
Adds an event+parm and twiddles the event counter
===============
*/
-void G_AddPredictableEvent( gentity_t *ent, int event, int eventParm ) {
- if ( !ent->client ) {
- return;
- }
- BG_AddPredictableEventToPlayerstate( event, eventParm, &ent->client->ps );
+void G_AddPredictableEvent( gentity_t *ent, int event, int eventParm )
+{
+ if( !ent->client )
+ return;
+
+ BG_AddPredictableEventToPlayerstate( event, eventParm, &ent->client->ps );
}
@@ -575,28 +615,34 @@ G_AddEvent
Adds an event+parm and twiddles the event counter
===============
*/
-void G_AddEvent( gentity_t *ent, int event, int eventParm ) {
- int bits;
-
- if ( !event ) {
- G_Printf( "G_AddEvent: zero event added for entity %i\n", ent->s.number );
- return;
- }
-
- // clients need to add the event in playerState_t instead of entityState_t
- if ( ent->client ) {
- bits = ent->client->ps.externalEvent & EV_EVENT_BITS;
- bits = ( bits + EV_EVENT_BIT1 ) & EV_EVENT_BITS;
- ent->client->ps.externalEvent = event | bits;
- ent->client->ps.externalEventParm = eventParm;
- ent->client->ps.externalEventTime = level.time;
- } else {
- bits = ent->s.event & EV_EVENT_BITS;
- bits = ( bits + EV_EVENT_BIT1 ) & EV_EVENT_BITS;
- ent->s.event = event | bits;
- ent->s.eventParm = eventParm;
- }
- ent->eventTime = level.time;
+void G_AddEvent( gentity_t *ent, int event, int eventParm )
+{
+ int bits;
+
+ if( !event )
+ {
+ G_Printf( "G_AddEvent: zero event added for entity %i\n", ent->s.number );
+ return;
+ }
+
+ // clients need to add the event in playerState_t instead of entityState_t
+ if( ent->client )
+ {
+ bits = ent->client->ps.externalEvent & EV_EVENT_BITS;
+ bits = ( bits + EV_EVENT_BIT1 ) & EV_EVENT_BITS;
+ ent->client->ps.externalEvent = event | bits;
+ ent->client->ps.externalEventParm = eventParm;
+ ent->client->ps.externalEventTime = level.time;
+ }
+ else
+ {
+ bits = ent->s.event & EV_EVENT_BITS;
+ bits = ( bits + EV_EVENT_BIT1 ) & EV_EVENT_BITS;
+ ent->s.event = event | bits;
+ ent->s.eventParm = eventParm;
+ }
+
+ ent->eventTime = level.time;
}
@@ -605,11 +651,12 @@ void G_AddEvent( gentity_t *ent, int event, int eventParm ) {
G_Sound
=============
*/
-void G_Sound( gentity_t *ent, int channel, int soundIndex ) {
- gentity_t *te;
+void G_Sound( gentity_t *ent, int channel, int soundIndex )
+{
+ gentity_t *te;
- te = G_TempEntity( ent->r.currentOrigin, EV_GENERAL_SOUND );
- te->s.eventParm = soundIndex;
+ te = G_TempEntity( ent->r.currentOrigin, EV_GENERAL_SOUND );
+ te->s.eventParm = soundIndex;
}
@@ -625,14 +672,14 @@ Sets the pos trajectory for a fixed position
*/
void G_SetOrigin( gentity_t *ent, vec3_t origin )
{
- VectorCopy( origin, ent->s.pos.trBase );
- ent->s.pos.trType = TR_STATIONARY;
- ent->s.pos.trTime = 0;
- ent->s.pos.trDuration = 0;
- VectorClear( ent->s.pos.trDelta );
-
- VectorCopy( origin, ent->r.currentOrigin );
- VectorCopy( origin, ent->s.origin ); //TA: if shit breaks - blame this line
+ VectorCopy( origin, ent->s.pos.trBase );
+ ent->s.pos.trType = TR_STATIONARY;
+ ent->s.pos.trTime = 0;
+ ent->s.pos.trDuration = 0;
+ VectorClear( ent->s.pos.trDelta );
+
+ VectorCopy( origin, ent->r.currentOrigin );
+ VectorCopy( origin, ent->s.origin ); //TA: if shit breaks - blame this line
}
//TA: from quakestyle.telefragged.com
@@ -688,31 +735,35 @@ DebugLine
with r_debugSurface set to 2
================
*/
-int DebugLine(vec3_t start, vec3_t end, int color) {
- vec3_t points[4], dir, cross, up = {0, 0, 1};
- float dot;
+int DebugLine( vec3_t start, vec3_t end, int color )
+{
+ vec3_t points[ 4 ], dir, cross, up = { 0, 0, 1 };
+ float dot;
- VectorCopy(start, points[0]);
- VectorCopy(start, points[1]);
+ VectorCopy( start, points[ 0 ] );
+ VectorCopy( start, points[ 1 ] );
//points[1][2] -= 2;
- VectorCopy(end, points[2]);
+ VectorCopy( end, points[ 2 ] );
//points[2][2] -= 2;
- VectorCopy(end, points[3]);
+ VectorCopy( end, points[ 3 ] );
- VectorSubtract(end, start, dir);
- VectorNormalize(dir);
- dot = DotProduct(dir, up);
- if (dot > 0.99 || dot < -0.99) VectorSet(cross, 1, 0, 0);
- else CrossProduct(dir, up, cross);
+ VectorSubtract( end, start, dir );
+ VectorNormalize( dir );
+ dot = DotProduct( dir, up );
+
+ if( dot > 0.99 || dot < -0.99 )
+ VectorSet( cross, 1, 0, 0 );
+ else
+ CrossProduct( dir, up, cross );
- VectorNormalize(cross);
+ VectorNormalize( cross );
- VectorMA(points[0], 2, cross, points[0]);
- VectorMA(points[1], -2, cross, points[1]);
- VectorMA(points[2], -2, cross, points[2]);
- VectorMA(points[3], 2, cross, points[3]);
+ VectorMA(points[ 0 ], 2, cross, points[ 0 ] );
+ VectorMA(points[ 1 ], -2, cross, points[ 1 ] );
+ VectorMA(points[ 2 ], -2, cross, points[ 2 ] );
+ VectorMA(points[ 3 ], 2, cross, points[ 3 ] );
- return trap_DebugPolygonCreate(color, 4, points);
+ return trap_DebugPolygonCreate( color, 4, points );
}
diff --git a/src/game/g_weapon.c b/src/game/g_weapon.c
index fc32b16c..24cce9dd 100644
--- a/src/game/g_weapon.c
+++ b/src/game/g_weapon.c
@@ -219,23 +219,6 @@ void lockBlobLauncherFire( gentity_t *ent )
/*
======================================================================
-PLASMAGUN
-
-======================================================================
-*/
-
-void plasmaFire( gentity_t *ent )
-{
- gentity_t *m;
-
- m = fire_plasma (ent, muzzle, forward);
-
-// VectorAdd( m->s.pos.trDelta, ent->client->ps.velocity, m->s.pos.trDelta ); // "real" physics
-}
-
-/*
-======================================================================
-
PULSE RIFLE
======================================================================
@@ -1069,9 +1052,6 @@ void FireWeapon( gentity_t *ent )
case WP_FLAMER:
flamerFire( ent );
break;
- case WP_PLASMAGUN:
- plasmaFire( ent );
- break;
case WP_PULSE_RIFLE:
pulseRifleFire( ent );
break;
diff --git a/src/game/q_math.c b/src/game/q_math.c
index a23a3456..f4b737ec 100644
--- a/src/game/q_math.c
+++ b/src/game/q_math.c
@@ -156,8 +156,9 @@ int VectorCompare( const vec3_t v1, const vec3_t v2 ) {
return 1;
}
-vec_t VectorLength( const vec3_t v ) {
- return (vec_t)sqrt (v[0]*v[0] + v[1]*v[1] + v[2]*v[2]);
+vec_t VectorLength( const vec3_t v )
+{
+ return (vec_t)sqrt( v[ 0 ] * v[ 0 ] + v[ 1 ] * v[ 1 ] + v[ 2 ] * v[ 2 ] );
}
vec_t VectorLengthSquared( const vec3_t v ) {
@@ -228,20 +229,22 @@ signed short ClampShort( int i ) {
// this isn't a real cheap function to call!
-int DirToByte( vec3_t dir ) {
+int DirToByte( vec3_t dir )
+{
int i, best;
float d, bestd;
- if ( !dir ) {
+ if( !dir )
return 0;
- }
bestd = 0;
best = 0;
- for (i=0 ; i<NUMVERTEXNORMALS ; i++)
+
+ for( i = 0; i < NUMVERTEXNORMALS; i++ )
{
- d = DotProduct (dir, bytedirs[i]);
- if (d > bestd)
+ d = DotProduct( dir, bytedirs[ i ] );
+
+ if( d > bestd )
{
bestd = d;
best = i;
@@ -251,12 +254,15 @@ int DirToByte( vec3_t dir ) {
return best;
}
-void ByteToDir( int b, vec3_t dir ) {
- if ( b < 0 || b >= NUMVERTEXNORMALS ) {
+void ByteToDir( int b, vec3_t dir )
+{
+ if( b < 0 || b >= NUMVERTEXNORMALS )
+ {
VectorCopy( vec3_origin, dir );
return;
}
- VectorCopy (bytedirs[b], dir);
+
+ VectorCopy( bytedirs[ b ], dir);
}
@@ -389,67 +395,64 @@ void RotatePointAroundVector(vec3_t dst, const vec3_t dir, const vec3_t point, f
RotateAroundDirection
===============
*/
-void RotateAroundDirection(vec3_t axis[3], vec_t angle)
+void RotateAroundDirection( vec3_t axis[ 3 ], vec_t angle )
{
vec_t scale;
- angle = DEG2RAD(angle);
+ angle = DEG2RAD( angle );
// create an arbitrary axis[1]
- PerpendicularVector(axis[1], axis[0]);
+ PerpendicularVector( axis[ 1 ], axis[ 0 ] );
// cross to get axis[2]
- CrossProduct(axis[0], axis[1], axis[2]);
+ CrossProduct( axis[ 0 ], axis[ 1 ], axis[ 2 ] );
// rotate
- scale = cos(angle);
- VectorScale(axis[1], scale, axis[1]);
+ scale = cos( angle );
+ VectorScale( axis[ 1 ], scale, axis[ 1 ] );
- scale = sin(angle);
- VectorMA(axis[1], scale, axis[2], axis[1]);
+ scale = sin( angle );
+ VectorMA( axis[ 1 ], scale, axis[ 2 ], axis[ 1 ] );
// recalculate axis[2]
- CrossProduct(axis[0], axis[1], axis[2]);
+ CrossProduct( axis[ 0 ], axis[ 1 ], axis[ 2 ] );
}
-void vectoangles( const vec3_t value1, vec3_t angles ) {
+void vectoangles( const vec3_t value1, vec3_t angles )
+{
float forward;
float yaw, pitch;
- if ( value1[1] == 0 && value1[0] == 0 ) {
+ if( value1[ 1 ] == 0 && value1[ 0 ] == 0 )
+ {
yaw = 0;
- if ( value1[2] > 0 ) {
+ if( value1[ 2 ] > 0 )
pitch = 90;
- }
- else {
+ else
pitch = 270;
- }
}
- else {
- if ( value1[0] ) {
- yaw = ( atan2 ( value1[1], value1[0] ) * 180 / M_PI );
- }
- else if ( value1[1] > 0 ) {
+ else
+ {
+ if( value1[ 0 ] )
+ yaw = ( atan2 ( value1[ 1 ], value1[ 0 ] ) * 180 / M_PI );
+ else if( value1[ 1 ] > 0 )
yaw = 90;
- }
- else {
+ else
yaw = 270;
- }
- if ( yaw < 0 ) {
+
+ if( yaw < 0 )
yaw += 360;
- }
- forward = sqrt ( value1[0]*value1[0] + value1[1]*value1[1] );
- pitch = ( atan2(value1[2], forward) * 180 / M_PI );
- if ( pitch < 0 ) {
+ forward = sqrt( value1[ 0 ] * value1[ 0 ] + value1[ 1 ] * value1[ 1 ] );
+ pitch = ( atan2( value1[ 2 ], forward ) * 180 / M_PI );
+ if( pitch < 0 )
pitch += 360;
- }
}
- angles[PITCH] = -pitch;
- angles[YAW] = yaw;
- angles[ROLL] = 0;
+ angles[ PITCH ] = -pitch;
+ angles[ YAW ] = yaw;
+ angles[ ROLL ] = 0;
}
@@ -517,16 +520,17 @@ void AnglesToAxis( const vec3_t angles, vec3_t axis[3] ) {
VectorSubtract( vec3_origin, right, axis[1] );
}
-void AxisClear( vec3_t axis[3] ) {
- axis[0][0] = 1;
- axis[0][1] = 0;
- axis[0][2] = 0;
- axis[1][0] = 0;
- axis[1][1] = 1;
- axis[1][2] = 0;
- axis[2][0] = 0;
- axis[2][1] = 0;
- axis[2][2] = 1;
+void AxisClear( vec3_t axis[ 3 ] )
+{
+ axis[ 0 ][ 0 ] = 1;
+ axis[ 0 ][ 1 ] = 0;
+ axis[ 0 ][ 2 ] = 0;
+ axis[ 1 ][ 0 ] = 0;
+ axis[ 1 ][ 1 ] = 1;
+ axis[ 1 ][ 2 ] = 0;
+ axis[ 2 ][ 0 ] = 0;
+ axis[ 2 ][ 1 ] = 0;
+ axis[ 2 ][ 2 ] = 1;
}
void AxisCopy( vec3_t in[3], vec3_t out[3] ) {
@@ -677,8 +681,9 @@ void AnglesSubtract( vec3_t v1, vec3_t v2, vec3_t v3 ) {
}
-float AngleMod(float a) {
- a = (360.0/65536) * ((int)(a*(65536/360.0)) & 65535);
+float AngleMod( float a )
+{
+ a = ( 360.0 / 65536 ) * ( (int)( a * ( 65536 / 360.0 ) ) & 65535 );
return a;
}
@@ -1252,60 +1257,64 @@ int PlaneTypeForNormal (vec3_t normal) {
MatrixMultiply
================
*/
-void MatrixMultiply(float in1[3][3], float in2[3][3], float out[3][3]) {
- out[0][0] = in1[0][0] * in2[0][0] + in1[0][1] * in2[1][0] +
- in1[0][2] * in2[2][0];
- out[0][1] = in1[0][0] * in2[0][1] + in1[0][1] * in2[1][1] +
- in1[0][2] * in2[2][1];
- out[0][2] = in1[0][0] * in2[0][2] + in1[0][1] * in2[1][2] +
- in1[0][2] * in2[2][2];
- out[1][0] = in1[1][0] * in2[0][0] + in1[1][1] * in2[1][0] +
- in1[1][2] * in2[2][0];
- out[1][1] = in1[1][0] * in2[0][1] + in1[1][1] * in2[1][1] +
- in1[1][2] * in2[2][1];
- out[1][2] = in1[1][0] * in2[0][2] + in1[1][1] * in2[1][2] +
- in1[1][2] * in2[2][2];
- out[2][0] = in1[2][0] * in2[0][0] + in1[2][1] * in2[1][0] +
- in1[2][2] * in2[2][0];
- out[2][1] = in1[2][0] * in2[0][1] + in1[2][1] * in2[1][1] +
- in1[2][2] * in2[2][1];
- out[2][2] = in1[2][0] * in2[0][2] + in1[2][1] * in2[1][2] +
- in1[2][2] * in2[2][2];
+void MatrixMultiply( float in1[ 3 ][ 3 ], float in2[ 3 ][ 3 ], float out[ 3 ][ 3 ] )
+{
+ out[ 0 ][ 0 ] = in1[ 0 ][ 0 ] * in2[ 0 ][ 0 ] + in1[ 0 ][ 1 ] * in2[ 1 ][ 0 ] +
+ in1[ 0 ][ 2 ] * in2[ 2 ][ 0 ];
+ out[ 0 ][ 1 ] = in1[ 0 ][ 0 ] * in2[ 0 ][ 1 ] + in1[ 0 ][ 1 ] * in2[ 1 ][ 1 ] +
+ in1[ 0 ][ 2 ] * in2[ 2 ][ 1 ];
+ out[ 0 ][ 2 ] = in1[ 0 ][ 0 ] * in2[ 0 ][ 2 ] + in1[ 0 ][ 1 ] * in2[ 1 ][ 2 ] +
+ in1[ 0 ][ 2 ] * in2[ 2 ][ 2 ];
+ out[ 1 ][ 0 ] = in1[ 1 ][ 0 ] * in2[ 0 ][ 0 ] + in1[ 1 ][ 1 ] * in2[ 1 ][ 0 ] +
+ in1[ 1 ][ 2 ] * in2[ 2 ][ 0 ];
+ out[ 1 ][ 1 ] = in1[ 1 ][ 0 ] * in2[ 0 ][ 1 ] + in1[ 1 ][ 1 ] * in2[ 1 ][ 1 ] +
+ in1[ 1 ][ 2 ] * in2[ 2 ][ 1 ];
+ out[ 1 ][ 2 ] = in1[ 1 ][ 0 ] * in2[ 0 ][ 2 ] + in1[ 1 ][ 1 ] * in2[ 1 ][ 2 ] +
+ in1[ 1 ][ 2 ] * in2[ 2 ][ 2 ];
+ out[ 2 ][ 0 ] = in1[ 2 ][ 0 ] * in2[ 0 ][ 0 ] + in1[ 2 ][ 1 ] * in2[ 1 ][ 0 ] +
+ in1[ 2 ][ 2 ] * in2[ 2 ][ 0 ];
+ out[ 2 ][ 1 ] = in1[ 2 ][ 0 ] * in2[ 0 ][ 1 ] + in1[ 2 ][ 1 ] * in2[ 1 ][ 1 ] +
+ in1[ 2 ][ 2 ] * in2[ 2 ][ 1 ];
+ out[ 2 ][ 2 ] = in1[ 2 ][ 0 ] * in2[ 0 ][ 2 ] + in1[ 2 ][ 1 ] * in2[ 1 ][ 2 ] +
+ in1[ 2 ][ 2 ] * in2[ 2 ][ 2 ];
}
-void AngleVectors( const vec3_t angles, vec3_t forward, vec3_t right, vec3_t up) {
- float angle;
- static float sr, sp, sy, cr, cp, cy;
+void AngleVectors( const vec3_t angles, vec3_t forward, vec3_t right, vec3_t up)
+{
+ float angle;
+ static float sr, sp, sy, cr, cp, cy;
// static to help MS compiler fp bugs
- angle = angles[YAW] * (M_PI*2 / 360);
- sy = sin(angle);
- cy = cos(angle);
- angle = angles[PITCH] * (M_PI*2 / 360);
- sp = sin(angle);
- cp = cos(angle);
- angle = angles[ROLL] * (M_PI*2 / 360);
- sr = sin(angle);
- cr = cos(angle);
-
- if (forward)
+ angle = angles[ YAW ] * ( M_PI * 2 / 360 );
+ sy = sin( angle );
+ cy = cos( angle );
+ angle = angles[ PITCH ] * ( M_PI * 2 / 360 );
+ sp = sin( angle );
+ cp = cos( angle );
+ angle = angles[ ROLL ] * ( M_PI * 2 / 360 );
+ sr = sin( angle );
+ cr = cos( angle );
+
+ if( forward )
{
- forward[0] = cp*cy;
- forward[1] = cp*sy;
- forward[2] = -sp;
+ forward[ 0 ] = cp * cy;
+ forward[ 1 ] = cp * sy;
+ forward[ 2 ] = -sp;
}
- if (right)
+
+ if( right )
{
- right[0] = (-1*sr*sp*cy+-1*cr*-sy);
- right[1] = (-1*sr*sp*sy+-1*cr*cy);
- right[2] = -1*sr*cp;
+ right[ 0 ] = ( -1 * sr * sp * cy + -1 * cr * -sy );
+ right[ 1 ] = ( -1 * sr * sp * sy + -1 * cr * cy );
+ right[ 2 ] = -1 * sr * cp;
}
- if (up)
+
+ if( up )
{
- up[0] = (cr*sp*cy+-sr*-sy);
- up[1] = (cr*sp*sy+-sr*cy);
- up[2] = cr*cp;
+ up[ 0 ] = ( cr * sp * cy + -sr * -sy );
+ up[ 1 ] = ( cr * sp * sy + -sr * cy );
+ up[ 2 ] = cr * cp;
}
}
diff --git a/src/game/q_shared.c b/src/game/q_shared.c
index 4bf77a8d..bd133ab9 100644
--- a/src/game/q_shared.c
+++ b/src/game/q_shared.c
@@ -307,72 +307,98 @@ static char *SkipWhitespace( char *data, qboolean *hasNewLines ) {
}
-int COM_Compress( char *data_p ) {
- char *in, *out;
- int c;
- qboolean newline = qfalse, whitespace = qfalse;
-
- in = out = data_p;
- if (in) {
- while ((c = *in) != 0) {
- // skip double slash comments
- if ( c == '/' && in[1] == '/' ) {
- while (*in && *in != '\n') {
- in++;
- }
- // skip /* */ comments
- } else if ( c == '/' && in[1] == '*' ) {
- while ( *in && ( *in != '*' || in[1] != '/' ) )
- in++;
- if ( *in )
- in += 2;
- // record when we hit a newline
- } else if ( c == '\n' || c == '\r' ) {
- newline = qtrue;
- in++;
- // record when we hit whitespace
- } else if ( c == ' ' || c == '\t') {
- whitespace = qtrue;
- in++;
- // an actual token
- } else {
- // if we have a pending newline, emit it (and it counts as whitespace)
- if (newline) {
- *out++ = '\n';
- newline = qfalse;
- whitespace = qfalse;
- } if (whitespace) {
- *out++ = ' ';
- whitespace = qfalse;
- }
-
- // copy quoted strings unmolested
- if (c == '"') {
- *out++ = c;
- in++;
- while (1) {
- c = *in;
- if (c && c != '"') {
- *out++ = c;
- in++;
- } else {
- break;
- }
- }
- if (c == '"') {
- *out++ = c;
- in++;
- }
- } else {
- *out = c;
- out++;
- in++;
- }
- }
- }
- }
- *out = 0;
- return out - data_p;
+int COM_Compress( char *data_p )
+{
+ char *in, *out;
+ int c;
+ qboolean newline = qfalse, whitespace = qfalse;
+
+ in = out = data_p;
+ if( in )
+ {
+ while( ( c = *in ) != 0 )
+ {
+ // skip double slash comments
+ if( c == '/' && in[ 1 ] == '/' )
+ {
+ while( *in && *in != '\n' )
+ in++;
+ // skip /* */ comments
+ }
+ else if( c == '/' && in[ 1 ] == '*' )
+ {
+ while( *in && ( *in != '*' || in[ 1 ] != '/' ) )
+ in++;
+
+ if( *in )
+ in += 2;
+ // record when we hit a newline
+ }
+ else if( c == '\n' || c == '\r' )
+ {
+ newline = qtrue;
+ in++;
+ // record when we hit whitespace
+ }
+ else if( c == ' ' || c == '\t')
+ {
+ whitespace = qtrue;
+ in++;
+ // an actual token
+ }
+ else
+ {
+ // if we have a pending newline, emit it (and it counts as whitespace)
+ if( newline )
+ {
+ *out++ = '\n';
+ newline = qfalse;
+ whitespace = qfalse;
+ }
+
+ if( whitespace )
+ {
+ *out++ = ' ';
+ whitespace = qfalse;
+ }
+
+ // copy quoted strings unmolested
+ if( c == '"' )
+ {
+ *out++ = c;
+ in++;
+
+ while( 1 )
+ {
+ c = *in;
+
+ if( c && c != '"' )
+ {
+ *out++ = c;
+ in++;
+ }
+ else
+ break;
+ }
+
+ if( c == '"' )
+ {
+ *out++ = c;
+ in++;
+ }
+ }
+ else
+ {
+ *out = c;
+ out++;
+ in++;
+ }
+ }
+ }
+ }
+
+ *out = 0;
+ return out - data_p;
}
char *COM_ParseExt( char **data_p, qboolean allowLineBreaks )
@@ -703,55 +729,57 @@ Q_strncpyz
Safe strncpy that ensures a trailing zero
=============
*/
-void Q_strncpyz( char *dest, const char *src, int destsize ) {
+void Q_strncpyz( char *dest, const char *src, int destsize )
+{
// bk001129 - also NULL dest
- if ( !dest ) {
+ if( !dest )
Com_Error( ERR_FATAL, "Q_strncpyz: NULL dest" );
- }
- if ( !src ) {
+
+ if( !src )
Com_Error( ERR_FATAL, "Q_strncpyz: NULL src" );
- }
- if ( destsize < 1 ) {
- Com_Error(ERR_FATAL,"Q_strncpyz: destsize < 1" );
- }
- strncpy( dest, src, destsize-1 );
- dest[destsize-1] = 0;
+ if( destsize < 1 )
+ Com_Error( ERR_FATAL, "Q_strncpyz: destsize < 1" );
+
+ strncpy( dest, src, destsize - 1 );
+ dest[ destsize - 1 ] = 0;
}
-int Q_stricmpn (const char *s1, const char *s2, int n) {
+int Q_stricmpn( const char *s1, const char *s2, int n )
+{
int c1, c2;
// bk001129 - moved in 1.17 fix not in id codebase
- if ( s1 == NULL ) {
- if ( s2 == NULL )
+ if( s1 == NULL )
+ {
+ if( s2 == NULL )
return 0;
else
return -1;
}
- else if ( s2==NULL )
+ else if( s2==NULL )
return 1;
- do {
+ do
+ {
c1 = *s1++;
c2 = *s2++;
- if (!n--) {
+ if( !n-- )
return 0; // strings are equal until end point
- }
- if (c1 != c2) {
- if (c1 >= 'a' && c1 <= 'z') {
- c1 -= ('a' - 'A');
- }
- if (c2 >= 'a' && c2 <= 'z') {
- c2 -= ('a' - 'A');
- }
- if (c1 != c2) {
+ if( c1 != c2 )
+ {
+ if( c1 >= 'a' && c1 <= 'z' )
+ c1 -= ( 'a' - 'A' );
+
+ if( c2 >= 'a' && c2 <= 'z' )
+ c2 -= ( 'a' - 'A' );
+
+ if( c1 != c2 )
return c1 < c2 ? -1 : 1;
- }
}
- } while (c1);
+ } while( c1 );
return 0; // strings are equal
}
@@ -775,8 +803,9 @@ int Q_strncmp (const char *s1, const char *s2, int n) {
return 0; // strings are equal
}
-int Q_stricmp (const char *s1, const char *s2) {
- return (s1 && s2) ? Q_stricmpn (s1, s2, 99999) : -1;
+int Q_stricmp( const char *s1, const char *s2 )
+{
+ return ( s1 && s2 ) ? Q_stricmpn( s1, s2, 99999 ) : -1;
}
@@ -804,13 +833,14 @@ char *Q_strupr( char *s1 ) {
// never goes past bounds or leaves without a terminating 0
-void Q_strcat( char *dest, int size, const char *src ) {
+void Q_strcat( char *dest, int size, const char *src )
+{
int l1;
l1 = strlen( dest );
- if ( l1 >= size ) {
+ if( l1 >= size )
Com_Error( ERR_FATAL, "Q_strcat: already overflowed" );
- }
+
Q_strncpyz( dest + l1, src, size - l1 );
}
@@ -860,26 +890,28 @@ char *Q_CleanStr( char *string ) {
}
-void QDECL Com_sprintf( char *dest, int size, const char *fmt, ...) {
- int len;
- va_list argptr;
- char bigbuffer[32000]; // big, but small enough to fit in PPC stack
+void QDECL Com_sprintf( char *dest, int size, const char *fmt, ...)
+{
+ int len;
+ va_list argptr;
+ char bigbuffer[ 32000 ]; // big, but small enough to fit in PPC stack
- va_start (argptr,fmt);
- len = vsprintf (bigbuffer,fmt,argptr);
- va_end (argptr);
- if ( len >= sizeof( bigbuffer ) ) {
+ va_start( argptr, fmt );
+ len = vsprintf( bigbuffer, fmt, argptr );
+ va_end( argptr );
+
+ if( len >= sizeof( bigbuffer ) )
Com_Error( ERR_FATAL, "Com_sprintf: overflowed bigbuffer" );
- }
- if (len >= size) {
- Com_Printf ("Com_sprintf: overflow of %i in %i\n", len, size);
- }
+
+ if( len >= size )
+ Com_Printf( "Com_sprintf: overflow of %i in %i\n", len, size );
+
#ifdef _DEBUG
__asm {
int 3;
}
#endif
- Q_strncpyz (dest, bigbuffer, size );
+ Q_strncpyz( dest, bigbuffer, size );
}
@@ -926,49 +958,52 @@ key and returns the associated value, or an empty string.
FIXME: overflow check?
===============
*/
-char *Info_ValueForKey( const char *s, const char *key ) {
- char pkey[BIG_INFO_KEY];
- static char value[2][BIG_INFO_VALUE]; // use two buffers so compares
+char *Info_ValueForKey( const char *s, const char *key )
+{
+ char pkey[ BIG_INFO_KEY ];
+ static char value[ 2 ][ BIG_INFO_VALUE ]; // use two buffers so compares
// work without stomping on each other
- static int valueindex = 0;
- char *o;
+ static int valueindex = 0;
+ char *o;
- if ( !s || !key ) {
+ if( !s || !key )
return "";
- }
- if ( strlen( s ) >= BIG_INFO_STRING ) {
+ if( strlen( s ) >= BIG_INFO_STRING )
Com_Error( ERR_DROP, "Info_ValueForKey: oversize infostring" );
- }
valueindex ^= 1;
- if (*s == '\\')
+
+ if( *s == '\\' )
s++;
- while (1)
+
+ while( 1 )
{
o = pkey;
- while (*s != '\\')
+ while( *s != '\\' )
{
- if (!*s)
+ if( !*s )
return "";
+
*o++ = *s++;
}
+
*o = 0;
s++;
- o = value[valueindex];
+ o = value[ valueindex ];
- while (*s != '\\' && *s)
- {
+ while( *s != '\\' && *s )
*o++ = *s++;
- }
+
*o = 0;
- if (!Q_stricmp (key, pkey) )
- return value[valueindex];
+ if( !Q_stricmp( key, pkey ) )
+ return value[ valueindex ];
- if (!*s)
+ if( !*s )
break;
+
s++;
}
@@ -1137,13 +1172,14 @@ Some characters are illegal in info strings because they
can mess up the server's parsing
==================
*/
-qboolean Info_Validate( const char *s ) {
- if ( strchr( s, '\"' ) ) {
+qboolean Info_Validate( const char *s )
+{
+ if( strchr( s, '\"' ) )
return qfalse;
- }
- if ( strchr( s, ';' ) ) {
+
+ if( strchr( s, ';' ) )
return qfalse;
- }
+
return qtrue;
}
diff --git a/src/ui/ui_main.c b/src/ui/ui_main.c
index 63179021..cc9d952b 100644
--- a/src/ui/ui_main.c
+++ b/src/ui/ui_main.c
@@ -235,7 +235,7 @@ void AssetCache() {
uiInfo.uiDC.Assets.crosshairShader[n] = trap_R_RegisterShaderNoMip( va("gfx/2d/crosshair%c", 'a' + n ) );
}
- uiInfo.newHighScoreSound = trap_S_RegisterSound("sound/feedback/voc_newhighscore.wav", qfalse);
+ /*uiInfo.newHighScoreSound = trap_S_RegisterSound("sound/feedback/voc_newhighscore.wav", qfalse);*/
}
void _UI_DrawSides(float x, float y, float w, float h, float size) {
@@ -768,9 +768,10 @@ void _UI_Refresh( int realtime )
// draw cursor
UI_SetColor( NULL );
- if (Menu_Count() > 0) {
+
+ //TA: don't draw the cursor whilst loading
+ if( Menu_Count( ) > 0 && !trap_Cvar_VariableValue( "ui_loading" ) )
UI_DrawHandlePic( uiInfo.uiDC.cursorx-16, uiInfo.uiDC.cursory-16, 32, 32, uiInfo.uiDC.Assets.cursor);
- }
#ifndef NDEBUG
if (uiInfo.uiDC.debug)
@@ -988,7 +989,7 @@ void UI_ParseMenu(const char *menuFile) {
int handle;
pc_token_t token;
- Com_Printf("Parsing menu file:%s\n", menuFile);
+ /*Com_Printf("Parsing menu file:%s\n", menuFile);*/
handle = trap_PC_LoadSource(menuFile);
if (!handle) {
@@ -6058,7 +6059,7 @@ void _UI_Init( qboolean inGameLoad ) {
UI_LoadBestScores(uiInfo.mapList[ui_currentMap.integer].mapLoadName, uiInfo.gameTypes[ui_gameType.integer].gtEnum);
UI_BuildQ3Model_List();
- UI_LoadBots();
+ /*UI_LoadBots();*/
// sets defaults for ui temp cvars
uiInfo.effectsColor = gamecodetoui[(int)trap_Cvar_VariableValue("color1")-1];
diff --git a/src/ui/ui_players.c b/src/ui/ui_players.c
index a2745552..4a7740a6 100644
--- a/src/ui/ui_players.c
+++ b/src/ui/ui_players.c
@@ -114,10 +114,6 @@ tryagain:
MAKERGB( pi->flashDlightColor, 1, 0.5f, 0 );
break;*/
- case WP_PLASMAGUN:
- MAKERGB( pi->flashDlightColor, 0.6f, 0.6f, 1 );
- break;
-
/* case WP_BFG:
MAKERGB( pi->flashDlightColor, 1, 0.7f, 1 );
break;*/
diff --git a/src/ui/ui_shared.c b/src/ui/ui_shared.c
index e110e8de..14a2d202 100644
--- a/src/ui/ui_shared.c
+++ b/src/ui/ui_shared.c
@@ -85,19 +85,21 @@ static int allocPoint, outOfMemory;
UI_Alloc
===============
*/
-void *UI_Alloc( int size ) {
+void *UI_Alloc( int size )
+{
char *p;
- if ( allocPoint + size > MEM_POOL_SIZE ) {
+ if( allocPoint + size > MEM_POOL_SIZE )
+ {
outOfMemory = qtrue;
- if (DC->Print) {
- DC->Print("UI_Alloc: Failure. Out of memory!\n");
- }
+
+ if( DC->Print )
+ DC->Print( "UI_Alloc: Failure. Out of memory!\n" );
//DC->trap_Print(S_COLOR_YELLOW"WARNING: UI Out of Memory!\n");
return NULL;
}
- p = &UI_memoryPool[allocPoint];
+ p = &UI_memoryPool[ allocPoint ];
allocPoint += ( size + 15 ) & ~15;
@@ -109,12 +111,14 @@ void *UI_Alloc( int size ) {
UI_InitMemory
===============
*/
-void UI_InitMemory( void ) {
+void UI_InitMemory( void )
+{
allocPoint = 0;
outOfMemory = qfalse;
}
-qboolean UI_OutOfMemory() {
+qboolean UI_OutOfMemory( )
+{
return outOfMemory;
}
@@ -225,21 +229,22 @@ void String_Report() {
String_Init
=================
*/
-void String_Init() {
+void String_Init( )
+{
int i;
- for (i = 0; i < HASH_TABLE_SIZE; i++) {
- strHandle[i] = 0;
- }
+ for( i = 0; i < HASH_TABLE_SIZE; i++ )
+ strHandle[ i ] = 0;
+
strHandleCount = 0;
strPoolIndex = 0;
menuCount = 0;
openMenuCount = 0;
- UI_InitMemory();
- Item_SetupKeywordHash();
- Menu_SetupKeywordHash();
- if (DC && DC->getBindingBuf) {
- Controls_GetConfig();
- }
+ UI_InitMemory( );
+ Item_SetupKeywordHash( );
+ Menu_SetupKeywordHash( );
+
+ if( DC && DC->getBindingBuf )
+ Controls_GetConfig( );
}
/*
@@ -541,9 +546,10 @@ qboolean PC_Script_Parse(int handle, const char **out) {
Init_Display
Initializes the display with a structure to all the drawing routines
- ==================
+==================
*/
-void Init_Display(displayContextDef_t *dc) {
+void Init_Display( displayContextDef_t *dc )
+{
DC = dc;
}
@@ -551,10 +557,11 @@ void Init_Display(displayContextDef_t *dc) {
// type and style painting
-void GradientBar_Paint(rectDef_t *rect, vec4_t color) {
+void GradientBar_Paint( rectDef_t *rect, vec4_t color )
+{
// gradient bar takes two paints
DC->setColor( color );
- DC->drawHandlePic(rect->x, rect->y, rect->w, rect->h, DC->Assets.gradientBar);
+ DC->drawHandlePic( rect->x, rect->y, rect->w, rect->h, DC->Assets.gradientBar );
DC->setColor( NULL );
}
@@ -2897,7 +2904,7 @@ void Item_Text_AutoWrapped_Paint( itemDef_t *item )
char lastCMod[ 2 ] = { 0, 0 };
qboolean forwardColor;
int width, height, len, textWidth, newLine, newLineWidth, skipLines, totalLines;
- float y, totalY;
+ float y, totalY, diffY;
vec4_t color;
textWidth = 0;
@@ -2932,12 +2939,13 @@ void Item_Text_AutoWrapped_Paint( itemDef_t *item )
totalLines = Item_Text_AutoWrapped_Lines( item );
totalY = totalLines * ( height + 5 );
+ diffY = totalY - item->window.rect.h;
- if( totalY - item->window.rect.h > 0.0f )
- skipLines = (int)( totalY / ( (float)height + 5.0f ) );
+ if( diffY > 0.0f )
+ skipLines = (int)( diffY / ( (float)height + 5.0f ) );
else
skipLines = 0;
-
+
while( p )
{
textWidth = DC->textWidth( buff, item->textscale, 0 );
@@ -3378,16 +3386,15 @@ Controls_GetConfig
void Controls_GetConfig( void )
{
int i;
- int twokeys[2];
+ int twokeys[ 2 ];
// iterate each command, get its numeric binding
- for (i=0; i < g_bindCount; i++)
+ for( i = 0; i < g_bindCount; i++ )
{
+ Controls_GetKeyAssignment( g_bindings[ i ].command, twokeys );
- Controls_GetKeyAssignment(g_bindings[i].command, twokeys);
-
- g_bindings[i].bind1 = twokeys[0];
- g_bindings[i].bind2 = twokeys[1];
+ g_bindings[ i ].bind1 = twokeys[ 0 ];
+ g_bindings[ i ].bind2 = twokeys[ 1 ];
}
//s_controls.invertmouse.curvalue = DC->getCVarValue( "m_pitch" ) < 0;
@@ -5309,13 +5316,14 @@ keywordHash_t *itemParseKeywordHash[KEYWORDHASH_SIZE];
Item_SetupKeywordHash
===============
*/
-void Item_SetupKeywordHash(void) {
+void Item_SetupKeywordHash( void )
+{
int i;
- memset(itemParseKeywordHash, 0, sizeof(itemParseKeywordHash));
- for (i = 0; itemParseKeywords[i].keyword; i++) {
- KeywordHash_Add(itemParseKeywordHash, &itemParseKeywords[i]);
- }
+ memset( itemParseKeywordHash, 0, sizeof( itemParseKeywordHash ) );
+
+ for( i = 0; itemParseKeywords[ i ].keyword; i++ )
+ KeywordHash_Add( itemParseKeywordHash, &itemParseKeywords[ i ] );
}
/*
@@ -5710,13 +5718,14 @@ keywordHash_t *menuParseKeywordHash[KEYWORDHASH_SIZE];
Menu_SetupKeywordHash
===============
*/
-void Menu_SetupKeywordHash(void) {
+void Menu_SetupKeywordHash( void )
+{
int i;
- memset(menuParseKeywordHash, 0, sizeof(menuParseKeywordHash));
- for (i = 0; menuParseKeywords[i].keyword; i++) {
- KeywordHash_Add(menuParseKeywordHash, &menuParseKeywords[i]);
- }
+ memset( menuParseKeywordHash, 0, sizeof( menuParseKeywordHash ) );
+
+ for(i = 0; menuParseKeywords[ i ].keyword; i++ )
+ KeywordHash_Add( menuParseKeywordHash, &menuParseKeywords[ i ] );
}
/*
@@ -5796,7 +5805,8 @@ void Menu_PaintAll() {
}
}
-void Menu_Reset() {
+void Menu_Reset( void )
+{
menuCount = 0;
}